@splinetool/loader 2.0.63 → 2.0.65

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.
@@ -624,7 +624,7 @@ void main() {
624
624
  }
625
625
  `;var R0=10,ty=class extends Ze.Object3D{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new Ze.TextureLoader;this.textureRequestId=0;this.currentWorldPosition=new Ze.Vector3;this.systemQuaternion=new Ze.Quaternion;this.worldGravity=new Ze.Vector3(0,0,0);this.directionAxis=new Ze.Vector3(0,0,0);this.colliderV3=new Ze.Vector3(0,0,0);this.colliderQuaternion=new Ze.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let n=r.data;this.material=ey(e)?I0()?.createMaterial(n.renderMaterial,r.context)??$m().createMaterial(n.renderMaterial,r.context):$m().createMaterial(n.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:n.renderMaterial.color},uColor2:{value:n.renderMaterial.color2},uPosition:{value:new Ze.Vector3(0,0,0)},uEmissionData:{value:new Ze.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ze.Vector3(0,0,0)},uWorldQuaternion:{value:new Ze.Vector4(0,0,0,1)},uRandScaleFactor:{value:n.randomScale??0},uRandRotationFactor:{value:n.randomRotation??0},uRotation:{value:n.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:n.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,n.renderMaterial.texture),this.init(n)}setTexture(e,r){let n=r.data,o=++this.textureRequestId;if(typeof r=="string"){let a=this.shared.image(r),s=()=>{if(o!==this.textureRequestId)return;let l=new Ze.Texture(a.img);l.needsUpdate=!0,e.uTexture.value=l};a.loaded?s():a.loadPromise.then(s);return}if(typeof n!="string"){let a=new Image;a.onload=()=>{if(o!==this.textureRequestId)return;let c=new Ze.Texture(a);c.needsUpdate=!0,e.uTexture.value=c};let s=new Blob([n],{type:"image/*"}),l=URL.createObjectURL(s);a.src=l}}updateGeometryAttributes(e,r){let n=eP(r);if(!this.emitterShape?.positionsAttribute)return;let a=new Ze.InstancedBufferAttribute(n,2);e.geometry.setAttribute("ref",a),ey(this.renderer)&&e.geometry.setAttribute("particleRef",a)}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let n=1e3/r,o=this.targetFPS/n,a=this.previousRatio+(o-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],r=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&r&&this.init(gs({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let n=e.data.size;this.colliderV3.fromArray(n),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let n=(o,a)=>{let s=[...this.system.data.shape.size];s[o]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&n(0,e),r[2]==="shape_size_1"&&n(1,e),r[2]==="shape_size_2"&&n(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/R0),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(gs(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/R0),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,n=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],o={...gs(this.system.data).shape,size:n};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,o)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Ze.MathUtils.DEG2RAD,Number(e[1])*Ze.MathUtils.DEG2RAD,Number(e[2])*Ze.MathUtils.DEG2RAD],n=new Ze.Euler(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(n).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:n,colliderEntityId:o,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:d,noiseType:u}=e;return r!==void 0||n!==void 0||(o||o===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||d!==void 0||u!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!this.emitterShape)return;let g=this.emitterShape.positionsTexture.source.data.data;if(!g||isNaN(g[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let n=this.updateSimulationDefinition(e),o=ey(this.renderer)?I0().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer,this.simFeaturesDefinition):$m().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),a=o.addVariable("uCurrentPosition",n+oP,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",n+dP,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",mP,iP(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=nP({size:this.emitterShape.textureSize}),d={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ze.Vector3(0,0,0)},uWorldQuaternion:{value:new Ze.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ze.Vector3(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=d;let u=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(u),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),h={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ze.Vector4(0,0,0,1)},uColliderPos:{value:new Ze.Vector3(0,0,0)},uColliderSize:{value:new Ze.Vector3(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Ze.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Ze.Vector4(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/R0}};s.material.uniforms=h;let f={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=f;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...gs(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.material.uniforms.uPosition.value=o.getCurrentRenderTarget(a)?.texture,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),n=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),o=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,n,o]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let n=this.system.getColliderData(e.colliderEntityId);switch(n?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let o=n?.colliderType;o==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),o==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),n?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[n,o]of Object.entries(this.simFeaturesDefinition))o&&(r+=`#define ${n}
626
626
  `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let n=new Ze.Vector3(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let o=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(o=a)}),o?new Kc(n,r,e.type,o):new Kc(n,r,"SphereEmitterShape")}else return new Kc(n,r,e.type)}createPrimaryEmitter(e){let r=e*e,n=new Ze.InstancedMesh(new Ze.PlaneGeometry(1,1,1),this.material,r);return n.renderOrder=1,this.updateGeometryAttributes(n,e),this.material.needsUpdate=!0,n.onBeforeRender=()=>{this.applyWorldSpace()},n}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:n=0}){return Math.ceil(e*(r+n))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let n=e-this.lastEmitTime,o=1/r;if(n>=o){let a=Math.max(1,Math.floor(n/o));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(gs(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var Zc=require("three");gt();var ry=class extends it{constructor(e,r,n){super(e,r);this.type="ParticleSystem";this.isParticleSystem=!0;this.geometry=new Zc.BufferGeometry;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{e.warmupInFlight||this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=n,this.data={...r,...gs(r)},this.geometry.setAttribute("position",new Zc.Float32BufferAttribute([],3)),this.material=new Zc.MeshBasicMaterial({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new ty(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let o=this.actualTime/1e3;this.emitter.update(o,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(n=>n.identity===e);return r?r.data:null}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),Ye(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...ir.drop(e,1).props}}),Ye(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...ir.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3),this._requestRender()}froze(){this.isFrozen=!0,this._requestRender()}unFroze(){this.isFrozen=!1,this._requestRender()}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId),this._requestRender()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset(),this._requestRender()}_requestRender(){this.context.shared.requestRender()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};var B0=class{add(t,e,r){if(typeof arguments[0]!="string")for(let n in arguments[0])this.add(n,arguments[0][n],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(n){this[n]=this[n]||[],e&&this[n][r?"unshift":"push"](e)},this)}run(t,e){this[t]=this[t]||[],this[t].forEach(function(r){r.call(e&&e.context?e.context:e,e)})}},N0=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(e=>{if(typeof e!="object"||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}},Z=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+Z.version}static addUnaryOp(t){return Z.max_unop_len=Math.max(t.length,Z.max_unop_len),Z.unary_ops[t]=1,Z}static addBinaryOp(t,e,r){return Z.max_binop_len=Math.max(t.length,Z.max_binop_len),Z.binary_ops[t]=e,r?Z.right_associative.add(t):Z.right_associative.delete(t),Z}static addIdentifierChar(t){return Z.additional_identifier_chars.add(t),Z}static addLiteral(t,e){return Z.literals[t]=e,Z}static removeUnaryOp(t){return delete Z.unary_ops[t],t.length===Z.max_unop_len&&(Z.max_unop_len=Z.getMaxKeyLen(Z.unary_ops)),Z}static removeAllUnaryOps(){return Z.unary_ops={},Z.max_unop_len=0,Z}static removeIdentifierChar(t){return Z.additional_identifier_chars.delete(t),Z}static removeBinaryOp(t){return delete Z.binary_ops[t],t.length===Z.max_binop_len&&(Z.max_binop_len=Z.getMaxKeyLen(Z.binary_ops)),Z.right_associative.delete(t),Z}static removeAllBinaryOps(){return Z.binary_ops={},Z.max_binop_len=0,Z}static removeLiteral(t){return delete Z.literals[t],Z}static removeAllLiterals(){return Z.literals={},Z}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new Z(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(e=>e.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return Z.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!Z.binary_ops[String.fromCharCode(t)]||Z.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return Z.isIdentifierStart(t)||Z.isDecimalDigit(t)}throwError(t){let e=new Error(t+" at character "+this.index);throw e.index=this.index,e.description=t,e}runHook(t,e){if(Z.hooks[t]){let r={context:this,node:e};return Z.hooks.run(t,r),r.node}return e}searchHook(t){if(Z.hooks[t]){let e={context:this};return Z.hooks[t].find(function(r){return r.call(e.context,e),e.node}),e.node}}gobbleSpaces(){let t=this.code;for(;t===Z.SPACE_CODE||t===Z.TAB_CODE||t===Z.LF_CODE||t===Z.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),e=t.length===1?t[0]:{type:Z.COMPOUND,body:t};return this.runHook("after-all",e)}gobbleExpressions(t){let e=[],r,n;for(;this.index<this.expr.length;)if(r=this.code,r===Z.SEMCOL_CODE||r===Z.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())e.push(n);else if(this.index<this.expr.length){if(r===t)break;this.throwError('Unexpected "'+this.char+'"')}return e}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,Z.max_binop_len),e=t.length;for(;e>0;){if(Z.binary_ops.hasOwnProperty(t)&&(!Z.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!Z.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=e,t;t=t.substr(0,--e)}return!1}gobbleBinaryExpression(){let t,e,r,n,o,a,s,l,c;if(a=this.gobbleToken(),!a||(e=this.gobbleBinaryOp(),!e))return a;for(o={value:e,prec:Z.binaryPrecedence(e),right_a:Z.right_associative.has(e)},s=this.gobbleToken(),s||this.throwError("Expected expression after "+e),n=[a,o,s];e=this.gobbleBinaryOp();){if(r=Z.binaryPrecedence(e),r===0){this.index-=e.length;break}o={value:e,prec:r,right_a:Z.right_associative.has(e)},c=e;let d=u=>o.right_a&&u.right_a?r>u.prec:r<=u.prec;for(;n.length>2&&d(n[n.length-2]);)s=n.pop(),e=n.pop().value,a=n.pop(),t={type:Z.BINARY_EXP,operator:e,left:a,right:s},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),n.push(o,t)}for(l=n.length-1,t=n[l];l>1;)t={type:Z.BINARY_EXP,operator:n[l-1].value,left:n[l-2],right:t},l-=2;return t}gobbleToken(){let t,e,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,Z.isDecimalDigit(t)||t===Z.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===Z.SQUOTE_CODE||t===Z.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===Z.OBRACK_CODE)n=this.gobbleArray();else{for(e=this.expr.substr(this.index,Z.max_unop_len),r=e.length;r>0;){if(Z.unary_ops.hasOwnProperty(e)&&(!Z.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!Z.isIdentifierPart(this.expr.charCodeAt(this.index+e.length)))){this.index+=r;let o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:Z.UNARY_EXP,operator:e,argument:o,prefix:!0})}e=e.substr(0,--r)}Z.isIdentifierStart(t)?(n=this.gobbleIdentifier(),Z.literals.hasOwnProperty(n.name)?n={type:Z.LITERAL,value:Z.literals[n.name],raw:n.name}:n.name===Z.this_str&&(n={type:Z.THIS_EXP})):t===Z.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let e=this.code;for(;e===Z.PERIOD_CODE||e===Z.OBRACK_CODE||e===Z.OPAREN_CODE||e===Z.QUMARK_CODE;){let r;if(e===Z.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==Z.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),e=this.code}this.index++,e===Z.OBRACK_CODE?(t={type:Z.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},this.gobbleSpaces(),e=this.code,e!==Z.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):e===Z.OPAREN_CODE?t={type:Z.CALL_EXP,arguments:this.gobbleArguments(Z.CPAREN_CODE),callee:t}:(e===Z.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),t={type:Z.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),r&&(t.optional=!0),this.gobbleSpaces(),e=this.code}return t}gobbleNumericLiteral(){let t="",e,r;for(;Z.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===Z.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);Z.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(e=this.char,e==="e"||e==="E"){for(t+=this.expr.charAt(this.index++),e=this.char,(e==="+"||e==="-")&&(t+=this.expr.charAt(this.index++));Z.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);Z.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return r=this.code,Z.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(r===Z.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===Z.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:Z.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",e=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let o=this.expr.charAt(this.index++);if(o===r){n=!0;break}else if(o==="\\")switch(o=this.expr.charAt(this.index++),o){case"n":t+=`
627
- `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:Z.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(Z.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Z.isIdentifierPart(t));)this.index++;return{type:Z.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===t){r=!0,this.index++,t===Z.CPAREN_CODE&&n&&n>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(o===Z.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===Z.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Z.CBRACK_CODE)for(let a=e.length;a<n;a++)e.push(null)}}else if(e.length!==n&&n!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===Z.COMPOUND)&&this.throwError("Expected comma"),e.push(a)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Z.CPAREN_CODE);if(this.code===Z.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:Z.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Z.ARRAY_EXP,elements:this.gobbleArguments(Z.CBRACK_CODE)}}},AF=new B0;Object.assign(Z,{hooks:AF,plugins:new N0(Z),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"});Z.max_unop_len=Z.getMaxKeyLen(Z.unary_ops);Z.max_binop_len=Z.getMaxKeyLen(Z.binary_ops);var wl=i=>new Z(i).parse(),wF=Object.getOwnPropertyNames(Z);wF.forEach(i=>{wl[i]===void 0&&i!=="prototype"&&(wl[i]=Z[i])});wl.Jsep=Z;var EF="ConditionalExpression",CF={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),e.node={type:EF,test:r,consequent:n,alternate:o},r.operator&&i.binary_ops[r.operator]<=.9){let a=r;for(;a.right.operator&&i.binary_ops[a.right.operator]<=.9;)a=a.right;e.node.test=a.right,a.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};wl.plugins.register(CF);var TF=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],PF=["0","1","2","3","4","5","6","7","8","9","."],MF=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function OF(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}wl.addBinaryOp("^",11,!0);function ny(i,t,e="number"){let r="";for(let a=0;a<i.length;a++){let s=i[a];if("objType"in s&&s.objType==="api"){let l=JSON.parse(s.id),c=l[0],d=t.getUserAPI(c);if(d!==void 0&&typeof d.retrieveValue=="function"){let u=d.retrieveValue(l.slice(1));u!==void 0&&(r+=u)}continue}if("objType"in s&&s.objType==="webhook"){let l=JSON.parse(s.id),[c,d]=l,u=t.getUserWebhook(c);if(u!==void 0){let p=u.getParameterValue(d);p!==void 0&&(r+=p)}continue}if("objType"in s&&s.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in s&&s.objId!==void 0){let c;if(t.scene.data.objects.traverse((d,u)=>{let p=u.events?.find(h=>h.id===s.objId);p&&(c=p)}),c!==void 0&&c.data.type==="AIAssistantListener"){let d=l?.computeAnalysisForListenerEvent(c.data);if(d!==void 0){r+=d;continue}}}r+=l?.voice??0;continue}if("id"in s){let l=i[a-1];if(a>0&&"id"in l){console.error("Two variables in a row",i);return}let c=t.getVariable(s.id),d=Pr.getDisplayedValue(c);e==="number"&&Pr.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?d=parseFloat(d).toString():e==="boolean"&&Pr.isBoolean(c)?d=c?"true":"false":e==="boolean"&&Pr.isTextValue(c)&&!Array.isArray(c.textValue)&&(d='"'+d+'"'),r+=d;continue}else if(e==="string"){s.name!=='"'&&(s.name!=="+"||s.escaped)&&(r+=s.name),s.name==="+"&&!s.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+s.name);continue}if(s.name==="and"){r+="&&";continue}if(s.name==="or"){r+="||";continue}if(s.name==="True"){r+="true";continue}if(s.name==="False"){r+="false";continue}if(e==="boolean"&&!OF(s.name)&&!PF.includes(s.name)&&!TF.includes(s.name)&&!MF.includes(s.name.replace(/\($/g,""))){r+='"'+s.name+'"';continue}r+=s.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=wl(r)}catch(a){console.error(r,a);return}let o;try{o=pt(n)}catch(a){console.error(r,n,a)}return o}function pt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(pt(i.left)===pt(i.right));case"!=":return Number(pt(i.left)!==pt(i.right));case">":return Number(pt(i.left)>pt(i.right));case">=":return Number(pt(i.left)>=pt(i.right));case"<":return Number(pt(i.left)<pt(i.right));case"<=":return Number(pt(i.left)<=pt(i.right));case"+":return pt(i.left)+pt(i.right);case"-":return pt(i.left)-pt(i.right);case"*":return pt(i.left)*pt(i.right);case"/":return pt(i.left)/pt(i.right);case"%":return pt(i.left)%pt(i.right);case"&&":return pt(i.left)&&pt(i.right);case"||":return pt(i.left)||pt(i.right);case"^":return Math.pow(pt(i.left),pt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-pt(i.argument);case"!":return Number(!pt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=pt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=pt(i.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(pt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var gP=new Map;function Zt(i,t){gP.set(i,t)}function vP(i){return gP.get(i)}var DF={mousehover:!0,scroll:!0,dragdrop:!0,tracking:!0,resize:!0,conditional:!0,variables:!0,"api-services":!0,"ai-assistant":!0,textinputs:!0,audio:!0,video:!0,"create-destroy":!0,"scene-transition":!0,timeline:!0,transitions:!0,"misc-actions":!0},sX=Object.keys(DF),lX={["MouseHover"]:"mousehover",["Scroll"]:"scroll",["DragDrop"]:"dragdrop",["Follow"]:"tracking",["LookAt"]:"tracking",["Resize"]:"resize",["Conditional"]:"conditional",["VariableChange"]:"variables",["API"]:"api-services",["WEBHOOK"]:"api-services",["AIAssistantListener"]:"ai-assistant",["AIAssistantTrigger"]:"ai-assistant"},bP={Audio:"audio",Video:"video",Particles:"particles",Link:"misc-actions",Reset:"misc-actions",SwitchCamera:"misc-actions",ClearLocalStorage:"misc-actions",Create:"create-destroy",Destroy:"create-destroy",Transition:"transitions",Animation:"transitions",TimelineAnimation:"timeline",SceneTransition:"scene-transition",SetVariable:"variables",DynamicVariablePlay:"variables",UserAPI:"api-services"};function We(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=ny(t.expression,i,"boolean");return t.negate?!e:!!e}function Vt(i,t,e,r,n,o,a){let s={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},l=c=>({id:d,data:u})=>{try{if(u.type==="Conditional"){Dx[i.type].includes("Conditional")&&(u.ifActions.forEach(l({expression:u.condition,negate:!1})),u.elseActions.forEach(l({expression:u.condition,negate:!0})));return}if(!Dx[i.type].includes(u.type))return;let p=vP(u.type);if(p===void 0){gr(bP[u.type]??"misc-actions",`a "${u.type}" action`);return}let h=p({id:d,data:u,object:o,page:e,shared:r,eventManager:n,eventType:i.type,actionCondition:c,runModeOverride:a});h!=null&&u.type in s&&s[u.type].push(h)}catch(p){!1&&console.error(p)}};return t.forEach(l()),s}function vr(i){Object.values(i).forEach(t=>{t.forEach(e=>{typeof e.dispose=="function"&&e.dispose()})})}var iy=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.delay=0;this.emission=t.emission,t.delay!==void 0&&(this.delay=t.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},t);return}this.particleSystem.start()}stop(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},t);return}this.particleSystem.stop()}freeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},t);return}this.particleSystem.froze()}unFreeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},t);return}this.particleSystem.unFroze()}reset(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},t);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(We(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(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchConditional(){if(We(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchGameControl(t){if(We(this.shared,this.condition)===!1||!this.particleSystem)return!1;t==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};xl("Particle",(i,t,e)=>new ry(i,t,e));Zt("Particles",({data:i,page:t,shared:e,actionCondition:r})=>new iy(i,t,e,r));Pe("particles");var bt=require("three");var IF=null;function xP(){return IF}var sy=require("three");var oy=new sy.Color;function SP(i,t,e){return oy.setRGB(i,t,e,sy.SRGBColorSpace),{r:oy.r,g:oy.g,b:oy.b}}var ay=(i,t)=>typeof i=="number"&&Number.isFinite(i)?i:t,AP=i=>Array.isArray(i)&&typeof i[0]=="number"&&typeof i[1]=="number"?[i[0],i[1]]:[0,0];function RF(i,t,e){let r=ay(i.angle,0),[n,o]=AP(i.offset),[a,s]=AP(i.morph),l=i.colors??[],c=i.steps??[],d=Math.min(10,l.length,c.length);if(d===0)return[1,1,1,1];let u;if(i.gradientType===1){let y=(t+a)*3-(t+n)-1,g=(e+s)*3-(e+o)-1;u=Math.hypot(y,g)+r}else if(i.gradientType===2){let y=Math.atan2(t+a-.5+n,e+s-.5+o)*-1,g=r/Math.PI/-2+.5*y/Math.PI;u=g-Math.floor(g)}else{let y=a/(t!==0?t:1e-6),g=s/(e!==0?e:1e-6),v=.5+y,b=g,S=Math.cos(r)*v-Math.sin(r)*b,x=Math.sin(r)*v+Math.cos(r)*b,A=(t-.5+n)/2+S/2,w=(e-.5+o)/2+x/2,E=S*S+x*x;u=E>1e-12?(A*S+w*x)/E:0}let p=l[0][0],h=l[0][1],f=l[0][2],m=l[0][3];for(let y=1;y<d;y++){let g=c[y-1],b=c[y]-g,S=b!==0?Math.min(1,Math.max(0,(u-g)/b)):u>=g?1:0;i.smooth&&(S=S*S*(3-2*S)),p+=(l[y][0]-p)*S,h+=(l[y][1]-h)*S,f+=(l[y][2]-f)*S,m+=(l[y][3]-m)*S}return[p,h,f,m]}function wP(i,t){let e=i,r=e?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,o=[];return r.forEach(a=>{let s=a.data;if(s.visible===!1||s.isMask===!0)return;let l=ay(s.alpha,1);if(!(l<=0))if(s.type==="color"){let c=s.color,d;typeof c=="string"?d=typeof n?.color=="function"?n.color(c):void 0:c&&typeof c.r=="number"&&(d=c),d&&o.push({kind:"color",layer:s,rgb:{...SP(d.r,d.g,d.b),a:d.a??1},alpha:l})}else s.type==="gradient"&&o.push({kind:"gradient",layer:s,alpha:l})}),o.length===0?null:(a,s)=>{let l=1,c=1,d=1,u=!0;for(let p of o){let h,f,m,y;if(p.kind==="color")({r:h,g:f,b:m}=p.rgb),y=p.rgb.a;else{let[v,b,S,x]=RF(p.layer,a,s);({r:h,g:f,b:m}=SP(v,b,S)),y=x}let g=u?1:Math.min(1,Math.max(0,y*p.alpha));l+=(h-l)*g,c+=(f-c)*g,d+=(m-d)*g,u=!1}return{r:l,g:c,b:d}}}if(e?.color&&e.color.isColor===!0){let{r:n,g:o,b:a}=e.color;return()=>({r:n,g:o,b:a})}return null}function EP(i,t){let e=i,r=0,n=1,o=s=>{r+=s*n,n+=1},a=e?.data?.layers;if(a&&typeof a.forEach=="function"){let s=t;a.forEach(l=>{let c=l.data;if(c.visible!==!1){if(c.type==="color"){let d=c.color,u=typeof d=="string"?typeof s?.color=="function"?s.color(d):void 0:d;u&&typeof u.r=="number"&&(o(u.r),o(u.g),o(u.b)),o(ay(c.alpha,1))}else if(c.type==="gradient"){let d=c;for(let u of d.colors??[])o(u[0]),o(u[1]),o(u[2]),o(u[3]);for(let u of d.steps??[])o(u);o(ay(d.angle,0)),o(d.gradientType),o(d.smooth?1:0)}}})}else e?.color&&e.color.isColor===!0&&(o(e.color.r),o(e.color.g),o(e.color.b));return r}var CP=require("three"),El=32,L0=16384,_0=L0*El,Uo=100;function BF(i){let t=i>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function NF(i,t){if(i==="torus"){let d=t()*Math.PI*2,u=t()*Math.PI*2,p=Math.cos(d),h=Math.sin(d),f=Math.cos(u),m=Math.sin(u),y=(1.4+.7*f)*p,g=.7*m,v=(1.4+.7*f)*h;return{x:y,y:-v,z:g,nx:f*p,ny:-(f*h),nz:m,cr:1,cg:1,cb:1}}if(i==="cylinder"){let d=t()*Math.PI*2,u=Math.cos(d),p=Math.sin(d),h=(t()-.5)*1.6;return{x:u*.8,y:h,z:p*.8,nx:u,ny:0,nz:p,cr:1,cg:1,cb:1}}let e=t()*Math.PI*2,r=t()*2-1,n=Math.acos(r),o=Math.sin(n)*Math.cos(e),a=Math.cos(n),s=Math.sin(n)*Math.sin(e);return{x:o,y:a,z:s,nx:o,ny:a,nz:s,cr:1,cg:1,cb:1}}function LF(i){let{geometry:t,matrix:e}=i,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),o=t.getAttribute("uv"),a=t.getAttribute("color"),s=t.getIndex(),l=s?s.count/3:r.count/3;if(l<1)return null;let c=(v,b)=>s?s.getX(v*3+b):v*3+b,d=e?e.elements:null,u=e?new CP.Matrix3().getNormalMatrix(e).elements:null,p=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[0]*b+d[4]*S+d[8]*x+d[12]:b},h=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[1]*b+d[5]*S+d[9]*x+d[13]:S},f=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[2]*b+d[6]*S+d[10]*x+d[14]:x},m=new Float64Array(l),y=0;for(let v=0;v<l;v++){let b=c(v,0),S=c(v,1),x=c(v,2),A=p(b),w=h(b),E=f(b),P=p(S)-A,M=h(S)-w,D=f(S)-E,R=p(x)-A,L=h(x)-w,C=f(x)-E,B=M*C-D*L,_=D*R-P*C,F=P*L-M*R;y+=Math.sqrt(B*B+_*_+F*F)*.5,m[v]=y}return y<=0?null:{total:y,sample:(v,b)=>{let S=0,x=l-1;for(;S<x;){let z=S+x>>1;m[z]<v?S=z+1:x=z}let A=S,w=c(A,0),E=c(A,1),P=c(A,2),M=b(),D=b();M+D>1&&(M=1-M,D=1-D);let R=1-M-D,L=p(w)*R+p(E)*M+p(P)*D,C=h(w)*R+h(E)*M+h(P)*D,B=f(w)*R+f(E)*M+f(P)*D,_,F,k;if(n){if(_=n.getX(w)*R+n.getX(E)*M+n.getX(P)*D,F=n.getY(w)*R+n.getY(E)*M+n.getY(P)*D,k=n.getZ(w)*R+n.getZ(E)*M+n.getZ(P)*D,u){let z=u[0]*_+u[3]*F+u[6]*k,Q=u[1]*_+u[4]*F+u[7]*k,K=u[2]*_+u[5]*F+u[8]*k;_=z,F=Q,k=K}}else{let z=p(w),Q=h(w),K=f(w),ee=p(E)-z,ve=h(E)-Q,le=f(E)-K,de=p(P)-z,ce=h(P)-Q,me=f(P)-K;_=ve*me-le*ce,F=le*de-ee*me,k=ee*ce-ve*de}let q=Math.sqrt(_*_+F*F+k*k)||1,W=1,G=1,X=1;if(a)W=a.getX(w)*R+a.getX(E)*M+a.getX(P)*D,G=a.getY(w)*R+a.getY(E)*M+a.getY(P)*D,X=a.getZ(w)*R+a.getZ(E)*M+a.getZ(P)*D;else if(i.sampleColor){let z=o?o.getX(w)*R+o.getX(E)*M+o.getX(P)*D:.5,Q=o?o.getY(w)*R+o.getY(E)*M+o.getY(P)*D:.5,K=i.sampleColor(z,Q);K&&(W=K.r,G=K.g,X=K.b)}return{x:L,y:C,z:B,nx:_/q,ny:F/q,nz:k/q,cr:W,cg:G,cb:X}}}}function TP(i){let t=[];for(let n of i){let o=LF(n);o&&t.push(o)}if(t.length===0)return null;let e=new Float64Array(t.length),r=0;for(let n=0;n<t.length;n++)r+=t[n].total,e[n]=r;return r<=0?null:n=>{let o=n()*r,a=0,s=t.length-1;for(;a<s;){let c=a+s>>1;e[c]<o?a=c+1:s=c}let l=a===0?o:o-e[a-1];return t[a].sample(l,n)}}function F0(i){let t=Math.min(Math.max(1,Math.floor(i.guideStrands)),L0),e=BF(i.seed??1337),r=i.shape==="object"&&i.sampler,n=r?i.samplerRadius??Uo:Uo,o=new Float32Array(_0*4),a=new Float32Array(_0),s=new Float32Array(L0*4).fill(1);for(let l=0;l<t;l++){let c=r?i.sampler(e):NF(i.shape,e),d=r?c.x:c.x*n,u=r?c.y:c.y*n,p=r?c.z:c.z*n,{nx:h,ny:f,nz:m}=c;s[l*4+0]=c.cr,s[l*4+1]=c.cg,s[l*4+2]=c.cb;let y=l*El,v=(1.8+e()*.8)*i.hairLength*n/(El-1),b=.5+e()*1.5,S=(.02+e()*.06)*n,x,A,w;Math.abs(f)<.99?(x=-m,A=0,w=h):(x=1,A=0,w=0);let E=Math.sqrt(x*x+A*A+w*w)||1;for(let P=0;P<El;P++){let M=P/(El-1),D=M*M*.4*n,R=S*Math.sin(M*b*Math.PI*2),L=(y+P)*4;o[L+0]=d+h*v*P+R*x/E,o[L+1]=u+f*v*P-D+R*A/E,o[L+2]=p+m*v*P+R*w/E,o[L+3]=P===0?0:1,P<El-1&&(a[y+P]=v)}}return{initialPositions:o,restLengths:a,unitScale:n,rootColors:s}}var _F=1/60,FF=4,kF=6,ly=new bt.Matrix4,Ip=new bt.Quaternion,Jc=new bt.Vector3,Rp=new bt.Vector3,Cl=class extends it{constructor(e,r,n){super(e,r);this.type="HairSystem";this.isHairSystem=!0;this.simRunning=!1;this.previewRequested=!1;this.playModeActive=!1;this.pendingSimSeconds=0;this.simTime=0;this.resetRequested=!0;this.generation=0;this.settledSimSeconds=0;this.lastMotionFingerprint=0;this.lastBoneQuat=new bt.Quaternion;this.lastBonePos=new bt.Vector3;this.hasLastBone=!1;this.baseFoundAtRegen=!1;this.baseSourceGeomsAtRegen=[];this.baseSourceHashesAtRegen=[];this.baseColorHashAtRegen=0;this.baseScaleAtRegen=0;this.classicFallbackWarned=!1;this.regenSnapshot=null;this.context=n,this.data=r,this.geometry.setAttribute("position",new bt.BufferAttribute(new Float32Array(0),3)),this.material=new bt.MeshBasicMaterial({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new bt.Mesh(new bt.SphereGeometry(Uo,48,32),new bt.MeshBasicMaterial({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let o=new bt.InstancedBufferGeometry;o.setAttribute("position",new bt.BufferAttribute(new Float32Array(12),3)),o.setIndex([0,2,1,2,3,1]),o.instanceCount=0,this.ribbonMesh=new bt.Mesh(o,new bt.MeshBasicMaterial({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=r.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:r.guideStrands,hairLength:r.hairLength,spreadRadius:r.spreadRadius,headShape:r.headShape,baseObjectId:r.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,FF*_F*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform(Ip,Jc);let r=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(Ip))<.9999995||this.lastBonePos.distanceToSquared(Jc)>1e-8),n=this.motionFingerprint(),o=!this.hasLastBone||r||this.resetRequested||n!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(Ip),this.lastBonePos.copy(Jc),this.lastMotionFingerprint=n,this.hasLastBone=!0,this.settledSimSeconds=o?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+e.damping*2+e.localStiffness*3+e.globalStiffness*4+e.globalRange*5+e.stiffnessFalloff*6+e.windStrength*7+e.vspCoefficient*8+e.kink*9+e.kinkFrequency*10+e.clumpStrength*11+e.clumpSize*12+e.clumpTipScale*13}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>kF}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(e){this.playModeActive=e,e&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(e,r){super.updateState(e,r),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let n=this.scalpMesh.material;n.isMeshBasicMaterial===!0&&n.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,bt.SRGBColorSpace)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,r=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=r,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=r,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=r}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let e=this.data,r=this.regenSnapshot;if(r===null||r.guideStrands!==e.guideStrands||r.hairLength!==e.hairLength||r.spreadRadius!==e.spreadRadius||r.headShape!==e.headShape||r.baseObjectId!==e.baseObjectId){let n=r===null||r.headShape!==e.headShape||r.baseObjectId!==e.baseObjectId;this.regenerate(),n&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:r,guideStrands:n,hairLength:o}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&r){let a=this.context.scene.find(r);if(a){this.baseFoundAtRegen=!0,a.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(a),l=s?TP(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(c=>c.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&l){let c=this.baseWorldScale(a),d=Math.max(s.radius*c,.001);this.baseScaleAtRegen=c;let u=c;return F0({shape:"object",guideStrands:n,hairLength:o,sampler:p=>{let h=l(p);return{...h,x:h.x*u,y:h.y*u,z:h.z*u}},samplerRadius:d})}}}return F0({shape:e==="object"?"sphere":e,guideStrands:n,hairLength:o})}collectBaseSources(e){let r=[],n=[],o=0,a=0;ly.copy(e.matrixWorld).invert();let s=ly.clone(),l=c=>{if(c.isHairSystem===!0||c!==e&&c.visible===!1)return;let d=c.geometry;if(c.isMesh===!0&&d&&(d.getAttribute("position")?.count??0)>=3){let u=c===e?void 0:new bt.Matrix4().multiplyMatrices(s,c.matrixWorld),p=Array.isArray(c.material)?c.material[0]:c.material;r.push({geometry:d,matrix:u,sampleColor:wP(p,this.context.shared)??void 0}),n.push(Cl.matrixHash(u)),a+=EP(p,this.context.shared),d.boundingSphere===null&&d.computeBoundingSphere();let h=d.boundingSphere;if(h){let f=0,m=1;u?(Jc.copy(h.center).applyMatrix4(u),f=Jc.length(),m=Cl.matrixMaxScale(u)):f=h.center.length(),o=Math.max(o,f+h.radius*m)}}for(let u of c.children)l(u)};return l(e),r.length===0?null:{sources:r,hashes:n,radius:Math.max(o,.001),colorHash:a}}static matrixHash(e){if(!e)return 0;let r=e.elements,n=0;for(let o=0;o<16;o++)n+=r[o]*(o+1);return n}static matrixMaxScale(e){let r=e.elements,n=Math.hypot(r[0],r[1],r[2]),o=Math.hypot(r[4],r[5],r[6]),a=Math.hypot(r[8],r[9],r[10]);return Math.max(n,o,a,1e-6)}baseWorldScale(e){return ly.copy(e.matrixWorld).decompose(Jc,Ip,Rp),Math.max(Math.abs(Rp.x),Math.abs(Rp.y),Math.abs(Rp.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen){this.regenerate();return}e.updateWorldMatrix(!0,!0);let r=this.collectBaseSources(e),n=r?.sources??[],o=r?.hashes??[],a=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,l=n.length!==a.length;if(!l){for(let c=0;c<n.length;c++)if(n[c].geometry!==a[c]||Math.abs(o[c]-s[c])>Math.max(Math.abs(s[c]),1)*1e-4){l=!0;break}}if(!l&&this.data.hairColorSource==="object"&&(r?.colorHash??0)!==this.baseColorHashAtRegen&&(l=!0),!l&&n.length>0){let c=this.baseWorldScale(e);l=Math.abs(c-this.baseScaleAtRegen)>Math.max(this.baseScaleAtRegen,1e-6)*.001}l&&this.regenerate()}applyScalpState(){let e=this.data.headShape,r=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!r,!r&&(this.scalpMesh.geometry.dispose(),e==="torus"?this.scalpMesh.geometry=new bt.TorusGeometry(1.4*Uo,.7*Uo,24,48):e==="cylinder"?this.scalpMesh.geometry=new bt.CylinderGeometry(.8*Uo,.8*Uo,1.6*Uo,48,1):this.scalpMesh.geometry=new bt.SphereGeometry(Uo,48,32))}boneTransform(e,r){let n=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let a=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;a&&(n=a)}ly.copy(n).decompose(r,e,Rp)}raycast(e,r){if(!this.scalpMesh.visible)return;let n=[];this.scalpMesh.raycast(e,n);for(let o of n)o.object=this,r.push(o)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform(Ip,e),e}updateEntityBoxSize(e,r){let n=this.shadowBoundsRadius;e.set(0,0,0),r.set(n,n,n)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),xP()?.release(this)}};xl("Hair",(i,t,e)=>new Cl(i,t,e));Pe("hair");var fe=require("three");var en=require("three"),Ma=5,$c=new en.BufferGeometry;$c.setAttribute("position",new en.BufferAttribute(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Tl=class extends en.RawShaderMaterial{constructor(t){super({...t,depthTest:!1,depthWrite:!1,glslVersion:en.GLSL3,vertexShader:`
627
+ `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return n||this.throwError('Unclosed quote after "'+t+'"'),{type:Z.LITERAL,value:t,raw:this.expr.substring(e,this.index)}}gobbleIdentifier(){let t=this.code,e=this.index;for(Z.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,Z.isIdentifierPart(t));)this.index++;return{type:Z.IDENTIFIER,name:this.expr.slice(e,this.index)}}gobbleArguments(t){let e=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===t){r=!0,this.index++,t===Z.CPAREN_CODE&&n&&n>=e.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(o===Z.COMMA_CODE){if(this.index++,n++,n!==e.length){if(t===Z.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Z.CBRACK_CODE)for(let a=e.length;a<n;a++)e.push(null)}}else if(e.length!==n&&n!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===Z.COMPOUND)&&this.throwError("Expected comma"),e.push(a)}}return r||this.throwError("Expected "+String.fromCharCode(t)),e}gobbleGroup(){this.index++;let t=this.gobbleExpressions(Z.CPAREN_CODE);if(this.code===Z.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:Z.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:Z.ARRAY_EXP,elements:this.gobbleArguments(Z.CBRACK_CODE)}}},AF=new B0;Object.assign(Z,{hooks:AF,plugins:new N0(Z),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"});Z.max_unop_len=Z.getMaxKeyLen(Z.unary_ops);Z.max_binop_len=Z.getMaxKeyLen(Z.binary_ops);var wl=i=>new Z(i).parse(),wF=Object.getOwnPropertyNames(Z);wF.forEach(i=>{wl[i]===void 0&&i!=="prototype"&&(wl[i]=Z[i])});wl.Jsep=Z;var EF="ConditionalExpression",CF={name:"ternary",init(i){i.hooks.add("after-expression",function(e){if(e.node&&this.code===i.QUMARK_CODE){this.index++;let r=e.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===i.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),e.node={type:EF,test:r,consequent:n,alternate:o},r.operator&&i.binary_ops[r.operator]<=.9){let a=r;for(;a.right.operator&&i.binary_ops[a.right.operator]<=.9;)a=a.right;e.node.test=a.right,a.right=e.node,e.node=r}}else this.throwError("Expected :")}})}};wl.plugins.register(CF);var TF=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],PF=["0","1","2","3","4","5","6","7","8","9","."],MF=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function OF(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}wl.addBinaryOp("^",11,!0);function ny(i,t,e="number"){let r="";for(let a=0;a<i.length;a++){let s=i[a];if("objType"in s&&s.objType==="api"){let l=JSON.parse(s.id),c=l[0],d=t.getUserAPI(c);if(d!==void 0&&typeof d.retrieveValue=="function"){let u=d.retrieveValue(l.slice(1));u!==void 0&&(r+=u)}continue}if("objType"in s&&s.objType==="webhook"){let l=JSON.parse(s.id),[c,d]=l,u=t.getUserWebhook(c);if(u!==void 0){let p=u.getParameterValue(d);p!==void 0&&(r+=p)}continue}if("objType"in s&&s.objType==="aiAssistant"){let l=t.openAIRealtime;if("objId"in s&&s.objId!==void 0){let c;if(t.scene.data.objects.traverse((d,u)=>{let p=u.events?.find(h=>h.id===s.objId);p&&(c=p)}),c!==void 0&&c.data.type==="AIAssistantListener"){let d=l?.computeAnalysisForListenerEvent(c.data);if(d!==void 0){r+=d;continue}}}r+=l?.voice??0;continue}if("id"in s){let l=i[a-1];if(a>0&&"id"in l){console.error("Two variables in a row",i);return}let c=t.getVariable(s.id),d=Pr.getDisplayedValue(c);e==="number"&&Pr.isTextValue(c)&&Array.isArray(c.textValue)&&c.textValue.length===1?d=parseFloat(d).toString():e==="boolean"&&Pr.isBoolean(c)?d=c?"true":"false":e==="boolean"&&Pr.isTextValue(c)&&!Array.isArray(c.textValue)&&(d='"'+d+'"'),r+=d;continue}else if(e==="string"){s.name!=='"'&&(s.name!=="+"||s.escaped)&&(r+=s.name),s.name==="+"&&!s.escaped&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+s.name);continue}if(s.name==="and"){r+="&&";continue}if(s.name==="or"){r+="||";continue}if(s.name==="True"){r+="true";continue}if(s.name==="False"){r+="false";continue}if(e==="boolean"&&!OF(s.name)&&!PF.includes(s.name)&&!TF.includes(s.name)&&!MF.includes(s.name.replace(/\($/g,""))){r+='"'+s.name+'"';continue}r+=s.name}if(e==="string")return r;if(i.length===0){if(e==="number")return 0;if(e==="boolean")return!1}let n;try{n=wl(r)}catch(a){console.error(r,a);return}let o;try{o=pt(n)}catch(a){console.error(r,n,a)}if(e==="number"&&o!==void 0&&!Number.isFinite(o)){console.error(r,"evaluated to",o);return}return o}function pt(i){switch(i.type){case"BinaryExpression":switch(i.operator){case"==":return Number(pt(i.left)===pt(i.right));case"!=":return Number(pt(i.left)!==pt(i.right));case">":return Number(pt(i.left)>pt(i.right));case">=":return Number(pt(i.left)>=pt(i.right));case"<":return Number(pt(i.left)<pt(i.right));case"<=":return Number(pt(i.left)<=pt(i.right));case"+":return pt(i.left)+pt(i.right);case"-":return pt(i.left)-pt(i.right);case"*":return pt(i.left)*pt(i.right);case"/":return pt(i.left)/pt(i.right);case"%":return pt(i.left)%pt(i.right);case"&&":return pt(i.left)&&pt(i.right);case"||":return pt(i.left)||pt(i.right);case"^":return Math.pow(pt(i.left),pt(i.right));default:throw new Error("Unknown operator: "+i.operator)}case"UnaryExpression":switch(i.operator){case"-":return-pt(i.argument);case"!":return Number(!pt(i.argument));default:throw new Error("Unknown operator: "+i.operator)}case"Identifier":throw new Error("Unknown identifier: "+i.name);case"Literal":return i.value;case"CallExpression":if(i.callee.type==="Identifier"){if(i.callee.name==="random"){let t=0,e=1;if(i.arguments.length>=1)try{t=pt(i.arguments[0])}catch(r){console.warn(r)}if(i.arguments.length>=2)try{e=pt(i.arguments[1])}catch(r){console.warn(r)}return t=Math.min(e,t),e=Math.max(e,t),t+Math.random()*(e-t)}return Math[i.callee.name].apply(null,i.arguments.map(pt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+i.type)}}var gP=new Map;function Zt(i,t){gP.set(i,t)}function vP(i){return gP.get(i)}var DF={mousehover:!0,scroll:!0,dragdrop:!0,tracking:!0,resize:!0,conditional:!0,variables:!0,"api-services":!0,"ai-assistant":!0,textinputs:!0,audio:!0,video:!0,"create-destroy":!0,"scene-transition":!0,timeline:!0,transitions:!0,"misc-actions":!0},sX=Object.keys(DF),lX={["MouseHover"]:"mousehover",["Scroll"]:"scroll",["DragDrop"]:"dragdrop",["Follow"]:"tracking",["LookAt"]:"tracking",["Resize"]:"resize",["Conditional"]:"conditional",["VariableChange"]:"variables",["API"]:"api-services",["WEBHOOK"]:"api-services",["AIAssistantListener"]:"ai-assistant",["AIAssistantTrigger"]:"ai-assistant"},bP={Audio:"audio",Video:"video",Particles:"particles",Link:"misc-actions",Reset:"misc-actions",SwitchCamera:"misc-actions",ClearLocalStorage:"misc-actions",Create:"create-destroy",Destroy:"create-destroy",Transition:"transitions",Animation:"transitions",TimelineAnimation:"timeline",SceneTransition:"scene-transition",SetVariable:"variables",DynamicVariablePlay:"variables",UserAPI:"api-services"};function We(i,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let e=ny(t.expression,i,"boolean");return t.negate?!e:!!e}function Vt(i,t,e,r,n,o,a){let s={Audio:[],Video:[],Particles:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],TimelineAnimation:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[],ClearLocalStorage:[],UserAPI:[]},l=c=>({id:d,data:u})=>{try{if(u.type==="Conditional"){Dx[i.type].includes("Conditional")&&(u.ifActions.forEach(l({expression:u.condition,negate:!1})),u.elseActions.forEach(l({expression:u.condition,negate:!0})));return}if(!Dx[i.type].includes(u.type))return;let p=vP(u.type);if(p===void 0){gr(bP[u.type]??"misc-actions",`a "${u.type}" action`);return}let h=p({id:d,data:u,object:o,page:e,shared:r,eventManager:n,eventType:i.type,actionCondition:c,runModeOverride:a});h!=null&&u.type in s&&s[u.type].push(h)}catch(p){!1&&console.error(p)}};return t.forEach(l()),s}function vr(i){Object.values(i).forEach(t=>{t.forEach(e=>{typeof e.dispose=="function"&&e.dispose()})})}var iy=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n;this.delay=0;this.emission=t.emission,t.delay!==void 0&&(this.delay=t.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},t);return}this.particleSystem.start()}stop(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},t);return}this.particleSystem.stop()}freeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},t);return}this.particleSystem.froze()}unFreeze(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},t);return}this.particleSystem.unFroze()}reset(t=0){if(t){this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},t);return}this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze();break}}dispatchBasic(){if(We(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(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchConditional(){if(We(this.shared,this.condition)===!1||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay);break;default:break}}dispatchGameControl(t){if(We(this.shared,this.condition)===!1||!this.particleSystem)return!1;t==="start"?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};xl("Particle",(i,t,e)=>new ry(i,t,e));Zt("Particles",({data:i,page:t,shared:e,actionCondition:r})=>new iy(i,t,e,r));Pe("particles");var bt=require("three");var IF=null;function xP(){return IF}var sy=require("three");var oy=new sy.Color;function SP(i,t,e){return oy.setRGB(i,t,e,sy.SRGBColorSpace),{r:oy.r,g:oy.g,b:oy.b}}var ay=(i,t)=>typeof i=="number"&&Number.isFinite(i)?i:t,AP=i=>Array.isArray(i)&&typeof i[0]=="number"&&typeof i[1]=="number"?[i[0],i[1]]:[0,0];function RF(i,t,e){let r=ay(i.angle,0),[n,o]=AP(i.offset),[a,s]=AP(i.morph),l=i.colors??[],c=i.steps??[],d=Math.min(10,l.length,c.length);if(d===0)return[1,1,1,1];let u;if(i.gradientType===1){let y=(t+a)*3-(t+n)-1,g=(e+s)*3-(e+o)-1;u=Math.hypot(y,g)+r}else if(i.gradientType===2){let y=Math.atan2(t+a-.5+n,e+s-.5+o)*-1,g=r/Math.PI/-2+.5*y/Math.PI;u=g-Math.floor(g)}else{let y=a/(t!==0?t:1e-6),g=s/(e!==0?e:1e-6),v=.5+y,b=g,S=Math.cos(r)*v-Math.sin(r)*b,x=Math.sin(r)*v+Math.cos(r)*b,A=(t-.5+n)/2+S/2,w=(e-.5+o)/2+x/2,E=S*S+x*x;u=E>1e-12?(A*S+w*x)/E:0}let p=l[0][0],h=l[0][1],f=l[0][2],m=l[0][3];for(let y=1;y<d;y++){let g=c[y-1],b=c[y]-g,S=b!==0?Math.min(1,Math.max(0,(u-g)/b)):u>=g?1:0;i.smooth&&(S=S*S*(3-2*S)),p+=(l[y][0]-p)*S,h+=(l[y][1]-h)*S,f+=(l[y][2]-f)*S,m+=(l[y][3]-m)*S}return[p,h,f,m]}function wP(i,t){let e=i,r=e?.data?.layers;if(r&&typeof r.forEach=="function"){let n=t,o=[];return r.forEach(a=>{let s=a.data;if(s.visible===!1||s.isMask===!0)return;let l=ay(s.alpha,1);if(!(l<=0))if(s.type==="color"){let c=s.color,d;typeof c=="string"?d=typeof n?.color=="function"?n.color(c):void 0:c&&typeof c.r=="number"&&(d=c),d&&o.push({kind:"color",layer:s,rgb:{...SP(d.r,d.g,d.b),a:d.a??1},alpha:l})}else s.type==="gradient"&&o.push({kind:"gradient",layer:s,alpha:l})}),o.length===0?null:(a,s)=>{let l=1,c=1,d=1,u=!0;for(let p of o){let h,f,m,y;if(p.kind==="color")({r:h,g:f,b:m}=p.rgb),y=p.rgb.a;else{let[v,b,S,x]=RF(p.layer,a,s);({r:h,g:f,b:m}=SP(v,b,S)),y=x}let g=u?1:Math.min(1,Math.max(0,y*p.alpha));l+=(h-l)*g,c+=(f-c)*g,d+=(m-d)*g,u=!1}return{r:l,g:c,b:d}}}if(e?.color&&e.color.isColor===!0){let{r:n,g:o,b:a}=e.color;return()=>({r:n,g:o,b:a})}return null}function EP(i,t){let e=i,r=0,n=1,o=s=>{r+=s*n,n+=1},a=e?.data?.layers;if(a&&typeof a.forEach=="function"){let s=t;a.forEach(l=>{let c=l.data;if(c.visible!==!1){if(c.type==="color"){let d=c.color,u=typeof d=="string"?typeof s?.color=="function"?s.color(d):void 0:d;u&&typeof u.r=="number"&&(o(u.r),o(u.g),o(u.b)),o(ay(c.alpha,1))}else if(c.type==="gradient"){let d=c;for(let u of d.colors??[])o(u[0]),o(u[1]),o(u[2]),o(u[3]);for(let u of d.steps??[])o(u);o(ay(d.angle,0)),o(d.gradientType),o(d.smooth?1:0)}}})}else e?.color&&e.color.isColor===!0&&(o(e.color.r),o(e.color.g),o(e.color.b));return r}var CP=require("three"),El=32,L0=16384,_0=L0*El,Uo=100;function BF(i){let t=i>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function NF(i,t){if(i==="torus"){let d=t()*Math.PI*2,u=t()*Math.PI*2,p=Math.cos(d),h=Math.sin(d),f=Math.cos(u),m=Math.sin(u),y=(1.4+.7*f)*p,g=.7*m,v=(1.4+.7*f)*h;return{x:y,y:-v,z:g,nx:f*p,ny:-(f*h),nz:m,cr:1,cg:1,cb:1}}if(i==="cylinder"){let d=t()*Math.PI*2,u=Math.cos(d),p=Math.sin(d),h=(t()-.5)*1.6;return{x:u*.8,y:h,z:p*.8,nx:u,ny:0,nz:p,cr:1,cg:1,cb:1}}let e=t()*Math.PI*2,r=t()*2-1,n=Math.acos(r),o=Math.sin(n)*Math.cos(e),a=Math.cos(n),s=Math.sin(n)*Math.sin(e);return{x:o,y:a,z:s,nx:o,ny:a,nz:s,cr:1,cg:1,cb:1}}function LF(i){let{geometry:t,matrix:e}=i,r=t.getAttribute("position");if(!r||r.count<3)return null;let n=t.getAttribute("normal"),o=t.getAttribute("uv"),a=t.getAttribute("color"),s=t.getIndex(),l=s?s.count/3:r.count/3;if(l<1)return null;let c=(v,b)=>s?s.getX(v*3+b):v*3+b,d=e?e.elements:null,u=e?new CP.Matrix3().getNormalMatrix(e).elements:null,p=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[0]*b+d[4]*S+d[8]*x+d[12]:b},h=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[1]*b+d[5]*S+d[9]*x+d[13]:S},f=v=>{let b=r.getX(v),S=r.getY(v),x=r.getZ(v);return d?d[2]*b+d[6]*S+d[10]*x+d[14]:x},m=new Float64Array(l),y=0;for(let v=0;v<l;v++){let b=c(v,0),S=c(v,1),x=c(v,2),A=p(b),w=h(b),E=f(b),P=p(S)-A,M=h(S)-w,D=f(S)-E,R=p(x)-A,L=h(x)-w,C=f(x)-E,B=M*C-D*L,_=D*R-P*C,F=P*L-M*R;y+=Math.sqrt(B*B+_*_+F*F)*.5,m[v]=y}return y<=0?null:{total:y,sample:(v,b)=>{let S=0,x=l-1;for(;S<x;){let z=S+x>>1;m[z]<v?S=z+1:x=z}let A=S,w=c(A,0),E=c(A,1),P=c(A,2),M=b(),D=b();M+D>1&&(M=1-M,D=1-D);let R=1-M-D,L=p(w)*R+p(E)*M+p(P)*D,C=h(w)*R+h(E)*M+h(P)*D,B=f(w)*R+f(E)*M+f(P)*D,_,F,k;if(n){if(_=n.getX(w)*R+n.getX(E)*M+n.getX(P)*D,F=n.getY(w)*R+n.getY(E)*M+n.getY(P)*D,k=n.getZ(w)*R+n.getZ(E)*M+n.getZ(P)*D,u){let z=u[0]*_+u[3]*F+u[6]*k,Q=u[1]*_+u[4]*F+u[7]*k,K=u[2]*_+u[5]*F+u[8]*k;_=z,F=Q,k=K}}else{let z=p(w),Q=h(w),K=f(w),ee=p(E)-z,ve=h(E)-Q,le=f(E)-K,de=p(P)-z,ce=h(P)-Q,me=f(P)-K;_=ve*me-le*ce,F=le*de-ee*me,k=ee*ce-ve*de}let q=Math.sqrt(_*_+F*F+k*k)||1,W=1,G=1,X=1;if(a)W=a.getX(w)*R+a.getX(E)*M+a.getX(P)*D,G=a.getY(w)*R+a.getY(E)*M+a.getY(P)*D,X=a.getZ(w)*R+a.getZ(E)*M+a.getZ(P)*D;else if(i.sampleColor){let z=o?o.getX(w)*R+o.getX(E)*M+o.getX(P)*D:.5,Q=o?o.getY(w)*R+o.getY(E)*M+o.getY(P)*D:.5,K=i.sampleColor(z,Q);K&&(W=K.r,G=K.g,X=K.b)}return{x:L,y:C,z:B,nx:_/q,ny:F/q,nz:k/q,cr:W,cg:G,cb:X}}}}function TP(i){let t=[];for(let n of i){let o=LF(n);o&&t.push(o)}if(t.length===0)return null;let e=new Float64Array(t.length),r=0;for(let n=0;n<t.length;n++)r+=t[n].total,e[n]=r;return r<=0?null:n=>{let o=n()*r,a=0,s=t.length-1;for(;a<s;){let c=a+s>>1;e[c]<o?a=c+1:s=c}let l=a===0?o:o-e[a-1];return t[a].sample(l,n)}}function F0(i){let t=Math.min(Math.max(1,Math.floor(i.guideStrands)),L0),e=BF(i.seed??1337),r=i.shape==="object"&&i.sampler,n=r?i.samplerRadius??Uo:Uo,o=new Float32Array(_0*4),a=new Float32Array(_0),s=new Float32Array(L0*4).fill(1);for(let l=0;l<t;l++){let c=r?i.sampler(e):NF(i.shape,e),d=r?c.x:c.x*n,u=r?c.y:c.y*n,p=r?c.z:c.z*n,{nx:h,ny:f,nz:m}=c;s[l*4+0]=c.cr,s[l*4+1]=c.cg,s[l*4+2]=c.cb;let y=l*El,v=(1.8+e()*.8)*i.hairLength*n/(El-1),b=.5+e()*1.5,S=(.02+e()*.06)*n,x,A,w;Math.abs(f)<.99?(x=-m,A=0,w=h):(x=1,A=0,w=0);let E=Math.sqrt(x*x+A*A+w*w)||1;for(let P=0;P<El;P++){let M=P/(El-1),D=M*M*.4*n,R=S*Math.sin(M*b*Math.PI*2),L=(y+P)*4;o[L+0]=d+h*v*P+R*x/E,o[L+1]=u+f*v*P-D+R*A/E,o[L+2]=p+m*v*P+R*w/E,o[L+3]=P===0?0:1,P<El-1&&(a[y+P]=v)}}return{initialPositions:o,restLengths:a,unitScale:n,rootColors:s}}var _F=1/60,FF=4,kF=6,ly=new bt.Matrix4,Ip=new bt.Quaternion,Jc=new bt.Vector3,Rp=new bt.Vector3,Cl=class extends it{constructor(e,r,n){super(e,r);this.type="HairSystem";this.isHairSystem=!0;this.simRunning=!1;this.previewRequested=!1;this.playModeActive=!1;this.pendingSimSeconds=0;this.simTime=0;this.resetRequested=!0;this.generation=0;this.settledSimSeconds=0;this.lastMotionFingerprint=0;this.lastBoneQuat=new bt.Quaternion;this.lastBonePos=new bt.Vector3;this.hasLastBone=!1;this.baseFoundAtRegen=!1;this.baseSourceGeomsAtRegen=[];this.baseSourceHashesAtRegen=[];this.baseColorHashAtRegen=0;this.baseScaleAtRegen=0;this.classicFallbackWarned=!1;this.regenSnapshot=null;this.context=n,this.data=r,this.geometry.setAttribute("position",new bt.BufferAttribute(new Float32Array(0),3)),this.material=new bt.MeshBasicMaterial({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new bt.Mesh(new bt.SphereGeometry(Uo,48,32),new bt.MeshBasicMaterial({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let o=new bt.InstancedBufferGeometry;o.setAttribute("position",new bt.BufferAttribute(new Float32Array(12),3)),o.setIndex([0,2,1,2,3,1]),o.instanceCount=0,this.ribbonMesh=new bt.Mesh(o,new bt.MeshBasicMaterial({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=r.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:r.guideStrands,hairLength:r.hairLength,spreadRadius:r.spreadRadius,headShape:r.headShape,baseObjectId:r.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,FF*_F*2),this.trackMotionRest(e/1e3))}trackMotionRest(e){this.boneTransform(Ip,Jc);let r=this.hasLastBone&&(Math.abs(this.lastBoneQuat.dot(Ip))<.9999995||this.lastBonePos.distanceToSquared(Jc)>1e-8),n=this.motionFingerprint(),o=!this.hasLastBone||r||this.resetRequested||n!==this.lastMotionFingerprint||this.data.windStrength>.001;this.lastBoneQuat.copy(Ip),this.lastBonePos.copy(Jc),this.lastMotionFingerprint=n,this.hasLastBone=!0,this.settledSimSeconds=o?0:this.settledSimSeconds+e}motionFingerprint(){let e=this.data;return e.gravity+e.damping*2+e.localStiffness*3+e.globalStiffness*4+e.globalRange*5+e.stiffnessFalloff*6+e.windStrength*7+e.vspCoefficient*8+e.kink*9+e.kinkFrequency*10+e.clumpStrength*11+e.clumpSize*12+e.clumpTipScale*13}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}get isMotionSettled(){return this.settledSimSeconds>kF}get isVisiblyAnimating(){return this.isSimulating&&!this.isMotionSettled}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(e){this.playModeActive=e,e&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0,this.settledSimSeconds=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer \u2014 the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(e,r){super.updateState(e,r),this.updateHairState(e)}updateHairState(e){if((e.guideStrands!==void 0||e.hairLength!==void 0||e.spreadRadius!==void 0||e.headShape!==void 0||e.baseObjectId!==void 0)&&this.regenerate(),(e.headShape!==void 0||e.baseObjectId!==void 0)&&this.applyScalpState(),e.headColor!==void 0){let n=this.scalpMesh.material;n.isMeshBasicMaterial===!0&&n.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,bt.SRGBColorSpace)}(e.castShadow!==void 0||e.receiveShadow!==void 0)&&this.applyShadowState(),e.autoPlay!==void 0&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,r=this.data.receiveShadow??!0;this.castShadow=e,this.receiveShadow=r,this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=r,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=r}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let e=this.data,r=this.regenSnapshot;if(r===null||r.guideStrands!==e.guideStrands||r.hairLength!==e.hairLength||r.spreadRadius!==e.spreadRadius||r.headShape!==e.headShape||r.baseObjectId!==e.baseObjectId){let n=r===null||r.headShape!==e.headShape||r.baseObjectId!==e.baseObjectId;this.regenerate(),n&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:r,guideStrands:n,hairLength:o}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,e==="object"&&r){let a=this.context.scene.find(r);if(a){this.baseFoundAtRegen=!0,a.updateWorldMatrix(!0,!0);let s=this.collectBaseSources(a),l=s?TP(s.sources):null;if(this.baseSourceGeomsAtRegen=s?.sources.map(c=>c.geometry)??[],this.baseSourceHashesAtRegen=s?.hashes??[],this.baseColorHashAtRegen=s?.colorHash??0,s&&l){let c=this.baseWorldScale(a),d=Math.max(s.radius*c,.001);this.baseScaleAtRegen=c;let u=c;return F0({shape:"object",guideStrands:n,hairLength:o,sampler:p=>{let h=l(p);return{...h,x:h.x*u,y:h.y*u,z:h.z*u}},samplerRadius:d})}}}return F0({shape:e==="object"?"sphere":e,guideStrands:n,hairLength:o})}collectBaseSources(e){let r=[],n=[],o=0,a=0;ly.copy(e.matrixWorld).invert();let s=ly.clone(),l=c=>{if(c.isHairSystem===!0||c!==e&&c.visible===!1)return;let d=c.geometry;if(c.isMesh===!0&&d&&(d.getAttribute("position")?.count??0)>=3){let u=c===e?void 0:new bt.Matrix4().multiplyMatrices(s,c.matrixWorld),p=Array.isArray(c.material)?c.material[0]:c.material;r.push({geometry:d,matrix:u,sampleColor:wP(p,this.context.shared)??void 0}),n.push(Cl.matrixHash(u)),a+=EP(p,this.context.shared),d.boundingSphere===null&&d.computeBoundingSphere();let h=d.boundingSphere;if(h){let f=0,m=1;u?(Jc.copy(h.center).applyMatrix4(u),f=Jc.length(),m=Cl.matrixMaxScale(u)):f=h.center.length(),o=Math.max(o,f+h.radius*m)}}for(let u of c.children)l(u)};return l(e),r.length===0?null:{sources:r,hashes:n,radius:Math.max(o,.001),colorHash:a}}static matrixHash(e){if(!e)return 0;let r=e.elements,n=0;for(let o=0;o<16;o++)n+=r[o]*(o+1);return n}static matrixMaxScale(e){let r=e.elements,n=Math.hypot(r[0],r[1],r[2]),o=Math.hypot(r[4],r[5],r[6]),a=Math.hypot(r[8],r[9],r[10]);return Math.max(n,o,a,1e-6)}baseWorldScale(e){return ly.copy(e.matrixWorld).decompose(Jc,Ip,Rp),Math.max(Math.abs(Rp.x),Math.abs(Rp.y),Math.abs(Rp.z),1e-6)}get widthWorldScale(){return this.data.headShape==="object"&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if(this.data.headShape!=="object"||!this.data.baseObjectId)return;let e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen){this.regenerate();return}e.updateWorldMatrix(!0,!0);let r=this.collectBaseSources(e),n=r?.sources??[],o=r?.hashes??[],a=this.baseSourceGeomsAtRegen,s=this.baseSourceHashesAtRegen,l=n.length!==a.length;if(!l){for(let c=0;c<n.length;c++)if(n[c].geometry!==a[c]||Math.abs(o[c]-s[c])>Math.max(Math.abs(s[c]),1)*1e-4){l=!0;break}}if(!l&&this.data.hairColorSource==="object"&&(r?.colorHash??0)!==this.baseColorHashAtRegen&&(l=!0),!l&&n.length>0){let c=this.baseWorldScale(e);l=Math.abs(c-this.baseScaleAtRegen)>Math.max(this.baseScaleAtRegen,1e-6)*.001}l&&this.regenerate()}applyScalpState(){let e=this.data.headShape,r=e==="object"&&this.data.baseObjectId!==null;this.scalpMesh.visible=!r,!r&&(this.scalpMesh.geometry.dispose(),e==="torus"?this.scalpMesh.geometry=new bt.TorusGeometry(1.4*Uo,.7*Uo,24,48):e==="cylinder"?this.scalpMesh.geometry=new bt.CylinderGeometry(.8*Uo,.8*Uo,1.6*Uo,48,1):this.scalpMesh.geometry=new bt.SphereGeometry(Uo,48,32))}boneTransform(e,r){let n=this.matrixWorld;if(this.data.headShape==="object"&&this.data.baseObjectId){let a=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;a&&(n=a)}ly.copy(n).decompose(r,e,Rp)}raycast(e,r){if(!this.scalpMesh.visible)return;let n=[];this.scalpMesh.raycast(e,n);for(let o of n)o.object=this,r.push(o)}get shadowBoundsRadius(){let e=this.data.headShape==="torus"?2.6:1.5;return this.roots.unitScale*(e+2.6*Math.max(this.data.hairLength,0))}getShadowBoundsCenter(e){return this.boneTransform(Ip,e),e}updateEntityBoxSize(e,r){let n=this.shadowBoundsRadius;e.set(0,0,0),r.set(n,n,n)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),xP()?.release(this)}};xl("Hair",(i,t,e)=>new Cl(i,t,e));Pe("hair");var fe=require("three");var en=require("three"),Ma=5,$c=new en.BufferGeometry;$c.setAttribute("position",new en.BufferAttribute(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Tl=class extends en.RawShaderMaterial{constructor(t){super({...t,depthTest:!1,depthWrite:!1,glslVersion:en.GLSL3,vertexShader:`
628
628
  precision highp float;
629
629
  in vec3 position;
630
630
  void main() {
@@ -725,7 +725,7 @@ void main() {
725
725
  }
726
726
  `;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new en.Mesh($c,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,n,o){new en.Box2().min.setScalar(0);let s=e.length-1,l=new en.Vector4;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let u=c;u>=0;u--){let p=u%2===c%2?o[0]:o[1],h=u===c?n:u%2===c%2?o[1]:o[0];this.pyramidPassUniforms.inputTexture.value=h.textures.length>1?h.textures[1]:h.texture,this.pyramidPassUniforms.inputWidth.value="width"in h?h.width:1,this.pyramidPassUniforms.inputHeight.value="height"in h?h.height:1,r.setRenderTarget(p);let f=e[u],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,f/m,f/m),u===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,Bp);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,u<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[u+1])}r.setViewport(l);let d=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(o[d],o[d].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};gt();var MP=require("three"),Gt=class extends MP.Color{constructor(e,r,n,o){super(e,r,n);this.isColorA=!0;this.a=o}setRGBA(e,r,n,o){super.setRGB(e,r,n),this.a=o}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,r="srgb"){let n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let o,a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(o[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(o[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};var Oa=class extends Gt{};var hy=require("three");var dy=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.cleanupTimer=null;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;){this.dispose(e.src,e.data),this.cache.delete(e.src);let r=e;e=e.next,e.prev=this.head,this.head.next=e,r.next=null,r.prev=null,r.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}};var V0=class extends dy{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},k0;function OP(i){return typeof i=="string"?i:(k0||(k0=new V0),k0.load(i))}var uy=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},py=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Da=require("three"),DP=require("three/examples/jsm/loaders/HDRLoader.js");function G0(i){return i.length>2&&i[0]===35&&i[1]===63}function IP(i){try{let t=new DP.HDRLoader().parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength));if(!t||!t.width||!t.height)return null;let{width:e,height:r}=t,n=t.data,o=new Uint16Array(n.length),a=e*4,s=d=>Da.DataUtils.toHalfFloat(Math.pow(Math.max(Da.DataUtils.fromHalfFloat(d),0),1/2.2)),l=new Map,c=d=>{let u=l.get(d);return u===void 0&&(u=s(d),l.set(d,u)),u};for(let d=0;d<r;d++){let u=d*a,p=(r-1-d)*a;for(let h=0;h<a;h+=4)o[p+h]=c(n[u+h]),o[p+h+1]=c(n[u+h+1]),o[p+h+2]=c(n[u+h+2]),o[p+h+3]=n[u+h+3]}return{isSplineHdr:!0,data:o,width:e,height:r}}catch{return null}}function RP(i){let t=new Da.DataTexture(i.data,i.width,i.height,Da.RGBAFormat,Da.HalfFloatType);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var VF=0,ed=class extends uy{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.instanceId=++VF;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this.isHdr=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let o of Object.values(n))for(let a of Object.values(o))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){let n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"}));let o;await new Promise(a=>{n.onloadend=s=>{o=s.target?.result,a(null)}}),this.img.src=o}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else if(e instanceof Uint8Array?G0(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let n=e instanceof Uint8Array?e:null;if(n===null)try{n=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{n=null}let o=n!==null&&G0(n)?IP(n):null;o!==null&&(this.isHdr=!0,this.img=o,r())}else this.img=new Image,this.img.src=OP(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,n=1006){let o=this._cache[e]?.[r]?.[n];if(o)return o;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new hy.VideoTexture(this.img,void 0,e,e):this.isHdr?(a=RP(this.img),a.wrapS=e,a.wrapT=e,a.magFilter=n,a.minFilter=r):a=new hy.Texture(this.img,void 0,e,e,n,r),this.isBuffer||(a.anisotropy=8,a.generateMipmaps=r===1008),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][n]=a,a}}setNeedsUpdate(e){if(!this.isBuffer)for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let o of Object.values(n))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[n,o]of Object.entries(r))for(let[a,s]of Object.entries(o))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][n]!==void 0&&(this._cache[e][n][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var di=class extends ed{};var BP=new Map;function NP(i){if(typeof i=="string")return i;let t=BP.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},BP.set(i,t)),t.url}var GF,LP=new Promise(i=>{GF=i});var _P;LP.then(i=>_P=i);var Ia=class{constructor({src:t,volume:e,delay:r,loop:n}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let o;typeof t=="string"?o={src:t}:o={src:NP(t),format:"wav"},this.sound=new _P.Howl(o),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),n!==void 0&&(this.loop=n)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var FP=null;function kP(i){FP=i}function VP(){return FP}function U0(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var XM=require("three");var vs=require("three");var Or=require("three"),fy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);n.thetaLength=Or.MathUtils.clamp(n.thetaLength,0,360),n.hollow=Or.MathUtils.clamp(n.hollow??0,0,1);let o=n.width/2,a=n.radiusTop??o,s=n.radiusBottom??o;if(a===s?(a=o,s=o):a>s?(a=o,s=s*o/a):(a=a*o/s,s=o),n.shapeBlendNode){a=e??o,s=r??o;let l=Math.max(a,s)*2;n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:u,cornerSegments:p,hollow:h}=i.parameters,f;l===0?(f=new Or.BufferGeometry,f.setAttribute("position",new Or.Float32BufferAttribute([],3))):u||h?f=new Np(c,d,r,n,o,a,s,l*Math.PI/180,u,u,p,h):f=new Or.CylinderGeometry(c,d,r,n,o,a,s,l*Math.PI/180);let m=e/t;return m!==1&&f.scale(1,1,m),Object.assign(f,{userData:{...i,type:"CylinderGeometry"}})}};function GP(i){return new Or.Vector2(i.y,-i.x)}var Np=class extends Or.BufferGeometry{constructor(t,e,r,n,o,a,s,l,c,d,u,p,h=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,d=0);let f=r/2;h&&t==0&&(t=c),h&&e==0&&(e=d);let m=new Or.Vector2(t,f),y=new Or.Vector2(e,-f),g=null,v=null,b=null,S=null,x=m.clone().sub(y),A=0,w=0,E=0;p>0&&(A=Math.min(t,e)*(1-p),w=t-A,E=e-A);let P=m.clone();P.x-=A;let M=Math.PI-x.angle(),D=x.angle(),R=Math.tan(D/2),L=Math.tan(M/2),C=R+L,B=p?C:L,_=p?C:R;if(c=Math.min(c,(t-w)/B,x.length()/C),d=Math.min(d,(e-E)/_,x.length()/C),c>0){let ae=c/R;g=m.clone().sub(new Or.Vector2(ae,c)),p&&(b=g.clone(),b.x-=A-C*c),m.sub(x.clone().setLength(ae))}if(d>0){let ae=d/L;v=y.clone().sub(new Or.Vector2(ae,-d)),y.add(x.clone().setLength(ae)),p&&(S=v.clone(),S.x-=A-C*d,P.sub(x.clone().setLength(ae)))}x=m.clone().sub(y);let F=x.length()<.5,k=[],q=[],W=[],G=[],X=[],z=[],Q=(ae,ge,I,ie,Ke)=>{for(let De=0;De<u+1;De++){let Xe=De/u,Ee=ie<0?Xe:1-Xe;Ke&&(Ee-=1),Ee*=ae;let Ue=Math.sin(Ee),qe=Math.cos(Ee)*ie,$e=qe*ge+I.y;k.push(Ue*ge+I.x),q.push($e),W.push(Ue),G.push(qe),X.push(.5+$e/r),z.push(!1)}},K=(ae,ge,I)=>{let ie=[ae,ge];I<0&&ie.reverse();for(let Ke of ie)k.push(Ke),q.push(f*I),W.push(0),G.push(I),X.push(.5),z.push(!0)};if(S&&v?(Q(M,d,S,-1,!0),Q(D,d,v,-1,!1)):v?(K(v.x,0,-1),Q(D,d,v,-1,!1)):a||K(e,E,-1),!F){let ae=GP(x).normalize();for(let ge=0;ge<=o;ge++){let I=ge/o,ie=x.y*I+y.y;k.push(x.x*I+y.x),q.push(ie),W.push(ae.x),G.push(ae.y),X.push(.5+ie/r),z.push(!1)}}if(b&&g?(Q(M,c,g,1,!1),Q(D,c,b,1,!0)):g?(Q(M,c,g,1,!1),K(g.x,0,1)):a||K(t,w,1),p&&!F){let ae=GP(x).multiplyScalar(-1).normalize();for(let ge=0;ge<=o;ge++){let I=ge/o,ie=x.y*-I+P.y;k.push(x.x*-I+P.x),q.push(ie),W.push(ae.x),G.push(ae.y),X.push(.5+ie/r),z.push(!1)}}let ee=k.length,le=ee+(p&&!a?1:0),de=(ae,ge)=>ae*ee+(ge===ee?0:ge),ce=l<Math.PI*2,me=(n+1)*ee+(ce?2*(1+le):0),be=new Float32Array(me*3),xe=new Float32Array(me*3),J=new Float32Array(me*2),pe=me-1>65535?new Uint32Array(n*Math.max(0,le-1)*6+(ce?2*(le+1)*3:0)):new Uint16Array(n*Math.max(0,le-1)*6+(ce?2*(le+1)*3:0)),ne=0,Ae=0;for(let ae=0;ae<=n;ae++){let ge=ae/n,I=ge*l+s,ie=Math.sin(I),Ke=Math.cos(I);for(let De=0;De<ee;De++){let Xe=Ae*3,Ee=Ae*2,Ue=k[De],qe=W[De];be[Xe]=Ue*ie,be[Xe+1]=q[De],be[Xe+2]=Ue*Ke,xe[Xe]=qe*ie,xe[Xe+1]=G[De],xe[Xe+2]=qe*Ke,z[De]?(J[Ee]=.5,J[Ee+1]=.5):(J[Ee]=ge,J[Ee+1]=X[De]),Ae++}}for(let ae=0;ae<n;ae++)for(let ge=0;ge<le-1;ge++){if(a&&p&&ge==o)continue;let I=de(ae,ge),ie=de(ae+1,ge),Ke=de(ae+1,ge+1),De=de(ae,ge+1),Xe=be[Ke*3+0],Ee=be[Ke*3+2];pe[ne++]=I,pe[ne++]=ie,pe[ne++]=De,(Xe!=0||Ee!=0)&&(pe[ne++]=ie,pe[ne++]=Ke,pe[ne++]=De)}ce&&(Te(-1,0,s),Te(1,n*ee,s+l)),this.setIndex(new Or.BufferAttribute(pe.slice(0,ne),1)),this.setAttribute("position",new Or.BufferAttribute(be,3)),this.setAttribute("normal",new Or.BufferAttribute(xe,3)),this.setAttribute("uv",new Or.BufferAttribute(J,2));function Te(ae,ge,I){let ie=Math.sin(I),Ke=Math.cos(I),De=-Ke,Xe=ie,Ee=ae<0?(Ie,Et,nt)=>{pe[ne++]=Ie,pe[ne++]=Et,pe[ne++]=nt}:(Ie,Et,nt)=>{pe[ne++]=Ie,pe[ne++]=nt,pe[ne++]=Et},Ue=(t+e+w+E)/4,qe=Ae*3,$e=Ae*2;be[qe]=Ue*ie,be[qe+1]=0,be[qe+2]=Ue*Ke,xe[qe]=De,xe[qe+1]=0,xe[qe+2]=Xe,J[$e]=.5,J[$e+1]=.5;let Ft=Ae++;for(let Ie=0;Ie<le;Ie++){let Et=(ge+(Ie===ee?0:Ie))*3;qe=Ae*3,$e=Ae*2,be[qe]=be[Et],be[qe+1]=be[Et+1],be[qe+2]=be[Et+2],xe[qe]=De,xe[qe+1]=0,xe[qe+2]=Xe;let nt=Et/3*2|0;J[$e]=J[nt],J[$e+1]=J[nt+1],Ae++}for(let Ie=Ft+1;Ie<Ae-1;Ie++)Ee(Ft,Ie,Ie+1);Ee(Ft,Ae-1,Ft+1)}}};var UP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=vs.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:u}=i.parameters,p;l===0?(p=new vs.BufferGeometry,p.setAttribute("position",new vs.Float32BufferAttribute([],3))):c>0||d>0||l<360?p=new Np(0,t/2,r,n,o,a,s,l*Math.PI/180,c,d,u,0,!0):p=new vs.ConeGeometry(t/2,r,n,o,a);let h=e/t;return h!==1&&p.scale(1,1,h),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};var Yn=require("three"),zP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:o,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new Yn.BoxGeometry(t,e,r,n,o,a):c=new j0(t,e,r,n,o,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},z0=Math.PI/2,j0=class extends Yn.BufferGeometry{constructor(t=1,e=1,r=1,n=1,o=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",n=Math.floor(n),o=Math.floor(o),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=s>0,d=l+1,p=2*((a+1)*(o+1)+(n+1)*(a+1)+(n+1)*(o+1))+(c?d*4*(a+1+(n+1)+(o+1))+8*(d*(d+1)/2):0),h=2*(a*o+n*a+n*o)+(c?l*4*(a+n+o):0),f=c?8*l*l:0,m=new Float32Array(p*3),y=new Float32Array(p*3),g=new Float32Array(p*2),v=p-1>65535?new Uint32Array(h*6+f*3):new Uint16Array(h*6+f*3),b=0,S=0,x=new Float64Array(d),A=new Float64Array(d),w=new Float64Array(d),E=new Float64Array(d);for(let B=0;B<d;B++){let _=B/l*z0;x[B]=Math.sin(_)*s,A[B]=(1-Math.cos(_))*s,w[B]=Math.sin(_),E[B]=Math.cos(_)}let P=d*(d+1)/2,M=new Float64Array(P*3),D=new Float64Array(P*3);{let B=new Yn.Vector3(t/2,e/2,r/2);B.subScalar(s);let _=0;for(let F=0;F<=l;F++){let k=z0*(1-F/l),q=Math.cos(k),W=Math.sin(k),G=0;for(let X=0;X<=F;X++){let z=Math.cos(G),Q=Math.sin(G),K=q*z,ee=W,ve=q*Q;M[_*3]=K,M[_*3+1]=ee,M[_*3+2]=ve,D[_*3]=B.x+K*s,D[_*3+1]=B.y+ee*s,D[_*3+2]=B.z+ve*s,_++,G+=z0/F}}}R("z","y","x",-1,-1,r,e,t,a,o),R("z","y","x",1,-1,r,e,-t,a,o),R("x","z","y",1,1,t,r,e,n,a),R("x","z","y",1,-1,t,r,-e,n,a),R("x","y","z",1,-1,t,e,r,n,o),R("x","y","z",-1,-1,t,e,-r,n,o),s>0&&(L("z","y","x",-1,-1,1,r,e,t,a),L("z","y","x",1,-1,-1,r,e,t,a),L("z","y","x",-1,1,-1,r,e,t,a),L("z","y","x",1,1,1,r,e,t,a),L("x","y","z",-1,-1,-1,t,e,r,n),L("x","y","z",1,-1,1,t,e,r,n),L("x","y","z",-1,1,1,t,e,r,n),L("x","y","z",1,1,-1,t,e,r,n),L("y","x","z",-1,-1,1,e,t,r,o),L("y","x","z",1,-1,-1,e,t,r,o),L("y","x","z",1,1,1,e,t,r,o),L("y","x","z",-1,1,-1,e,t,r,o),C(1,1,1),C(-1,1,1),C(1,-1,1),C(-1,-1,1),C(1,1,-1),C(-1,1,-1),C(1,-1,-1),C(-1,-1,-1)),this.setIndex(new Yn.BufferAttribute(v,1)),this.setAttribute("position",new Yn.BufferAttribute(m,3)),this.setAttribute("normal",new Yn.BufferAttribute(y,3)),this.setAttribute("uv",new Yn.BufferAttribute(g,2));function R(B,_,F,k,q,W,G,X,z,Q){let K=(W-2*s)/z,ee=(G-2*s)/Q,ve=W/2-s,le=G/2-s,de=X/2,ce=z+1,me=Q+1,be=0,xe=new Yn.Vector3;for(let J=0;J<me;J++){let pe=J*ee-le;for(let ne=0;ne<ce;ne++){let Ae=ne*K-ve,Te=(b+be)*3,ae=(b+be)*2;xe[B]=Ae*k,xe[_]=pe*q,xe[F]=de,m[Te]=xe.x,m[Te+1]=xe.y,m[Te+2]=xe.z,xe[B]=0,xe[_]=0,xe[F]=X>0?1:-1,y[Te]=xe.x,y[Te+1]=xe.y,y[Te+2]=xe.z,g[ae]=ne/z,g[ae+1]=1-J/Q,be+=1}}for(let J=0;J<Q;J++)for(let pe=0;pe<z;pe++){let ne=b+pe+ce*J,Ae=b+pe+ce*(J+1),Te=b+(pe+1)+ce*(J+1),ae=b+(pe+1)+ce*J;v[S++]=ne,v[S++]=Ae,v[S++]=ae,v[S++]=Ae,v[S++]=Te,v[S++]=ae}b+=be}function L(B,_,F,k,q,W,G,X,z,Q){let K=(G-2*s)/Q,ee=G/2-s,ve=X/2-s,le=z/2,de=Q+1,ce=0,me=new Yn.Vector3,be=new Yn.Vector3;for(let xe=0;xe<l+1;xe++){me[_]=(ve+x[xe])*q,me[F]=(le-A[xe])*W,be[B]=0,be[_]=w[xe]*Math.sign(me[_]),be[F]=E[xe]*Math.sign(me[F]);for(let J=0;J<de;J++){let pe=J*K-ee;me[B]=pe*k;let ne=(b+ce)*3,Ae=(b+ce)*2;m[ne]=me.x,m[ne+1]=me.y,m[ne+2]=me.z,y[ne]=be.x,y[ne+1]=be.y,y[ne+2]=be.z,g[Ae]=J/Q,g[Ae+1]=0,ce+=1}}for(let xe=0;xe<l;xe++)for(let J=0;J<Q;J++){let pe=b+J+de*xe,ne=b+J+de*(xe+1),Ae=b+(J+1)+de*(xe+1),Te=b+(J+1)+de*xe;v[S++]=pe,v[S++]=ne,v[S++]=Te,v[S++]=ne,v[S++]=Ae,v[S++]=Te}b+=ce}function C(B,_,F){let q=B*_*F>0?(G,X,z)=>{v[S++]=G,v[S++]=X,v[S++]=z}:(G,X,z)=>{v[S++]=G,v[S++]=z,v[S++]=X},W=b;for(let G=0;G<P;G++){let X=G*3,z=b*3,Q=b*2;m[z]=B*D[X],m[z+1]=_*D[X+1],m[z+2]=F*D[X+2],y[z]=B*M[X],y[z+1]=_*M[X+1],y[z+2]=F*M[X+2],g[Q]=0,g[Q+1]=0,b++}for(let G=0;G<l;G++){let X=W+G*(G+1)/2,z=W+(G+1)*(G+2)/2;q(X,z+1,z);for(let Q=1;Q<=G;Q++)q(X+Q-1,X+Q,z+Q),q(X+Q,z+Q+1,z+Q)}}}};var dr=require("three"),bs=class extends dr.BufferGeometry{constructor(t=[],e=[],r="",n=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s,l,c,d=0;u(),p(),this.setAttribute("position",new dr.BufferAttribute(new Float32Array(s.subarray(0,d)),3)),this.setAttribute("normal",new dr.BufferAttribute(new Float32Array(l.subarray(0,d)),3)),this.setAttribute("uv",new dr.BufferAttribute(new Float32Array(c.subarray(0,d/3*2)),2));return;function u(){o=Math.min(1-1e-5,o),o==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new dr.Vector3,y=m.clone(),g=new dr.Triangle,v=o*n,b=n-v,S=a+1,x=new dr.Vector3,A=(J,pe)=>x.subVectors(J,pe).normalize(),w=(J,pe)=>Array(J).fill(void 0).map(pe),E=w(t.length/3,(J,pe)=>new dr.Vector3().fromArray(t,pe*3).setLength(n)),P=[],M=1e6;for(let J=0;J<E.length;J++){let pe=E[J],ne=[],Ae,Te,ae,ge=1e10,I=-1;for(;(I=e.indexOf(J,I+1))!=-1;){let Xe=I-I%3;Ae=e[Xe+(I+1)%3],Te=e[Xe+(I+2)%3],ae=pe.distanceToSquared(E[Ae]),ge=Math.min(ge,ae),ne.push([Ae,Te,ae])}ge+=1e-6;let ie=[],Ke=0,De=ne.length;for(let Xe=0;Xe<De;Xe++){[Ae,Te,ae]=ne[Ke];let Ee=P[Ae]?.includes(J)==!0;ae<=ge&&ie.push(Ae+ +Ee*M),Ke=ne.findIndex(Ue=>Ue[0]==Te)}P.push(ie)}let D=[];{let J=0,pe=0,ne,Ae,Te=f==3;for(let ae=0;ae<=a;ae++){ne=ae*(ae+1)/2,Ae=(ae+1)*(ae+2)/2;for(let ge=0;ge<a-ae;ge++)[J,pe]=[ne+ge+ae+2,Ae+ge+ae+3],D.push(ne,Ae,...Te?[pe,ne]:[J,Ae],pe,J),[ne,Ae]=[J,pe];D.push(ne,Ae,ne+a+2)}}let R=0;for(let J=0;J<P.length;J++)for(let pe=0;pe<f;pe++)P[J][pe]<M&&R++;let L=E.length*f*D.length*3,C=R*S*6*3,B=R*2*3*3,_=L+C+B;s=new Float64Array(_),l=new Float64Array(_),c=new Float64Array(_/3*2);let F=(J,pe,ne)=>{let Ae=d/3*2;c[Ae]=Math.atan2(ne,-J)/2/Math.PI+.5,c[Ae+1]=1-(Math.atan2(-pe,Math.sqrt(J*J+ne*ne))/Math.PI+.5)},k=J=>{s[d]=J.x,s[d+1]=J.y,s[d+2]=J.z,l[d]=x.x,l[d+1]=x.y,l[d+2]=x.z,F(J.x,J.y,J.z),d+=3},q=J=>{s[d]=J[0].x,s[d+1]=J[0].y,s[d+2]=J[0].z,l[d]=J[1].x,l[d+1]=J[1].y,l[d+2]=J[1].z,F(J[0].x,J[0].y,J[0].z),d+=3},W=(a+2)*(a+3)/2,G=new Float64Array(W*3),X=new Float64Array(W*3),z=new Float64Array(W*2),Q=w(f*2*S,()=>new dr.Vector3),K=w(a*Math.max(0,a-1)/2,()=>new dr.Vector3),ee=m.clone(),ve=m.clone(),le=m.clone(),de=m.clone(),ce=m.clone(),me=[],be=w(E.length,()=>w(f,()=>m.clone()));for(let J=0;J<E.length;J++){m.copy(E[J]).normalize(),ee.copy(m).multiplyScalar(b);let pe=P[J];for(let ie=0;ie<pe.length;ie++){let Ke=pe[ie],De=pe[(ie+1)%f];g.setFromPointsAndIndices(E,J,Ke%M,De%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(ee,be[J][ie])}let ne=0,Ae=[],Te=[],ae=new dr.Vector3;a==0&&[...be[J]].reduce((ie,Ke)=>ie.add(Ke),ae).multiplyScalar(1/f);for(let ie=0;ie<f;ie++){let Ke=[],De=(ie-1+f)%f,Xe=be[J][De],Ee=be[J][ie];m.copy(Xe).sub(ee),y.copy(Ee).sub(ee);let Ue=ee.angleTo(m),qe=m.angleTo(y),$e=Math.cos(Ue)*v;a==0?ve.copy(ae):ve.copy(ee).setLength(b+$e),Ae.push($e);let Ft=[ve,Xe,Ee];for(let Ie=0;Ie<2;Ie++){let Et=Ft[Ie],nt=Ft[Ie+1];de.subVectors(Et,ee),ce.subVectors(nt,ee),le.crossVectors(de,ce).normalize();for(let Js=0;Js<S;Js++){let Ku=[Ue,qe][Ie]*Js/S;m.copy(de).applyAxisAngle(le,Ku).add(ee),Q[ne++].copy(m),Ie&&(A(m,ee),Ke.push([Js==0?Et:m.clone(),x.clone()]))}Ie&&(A(nt,ee),Ke.push([nt,x.clone()]))}Te.push(Ke)}me.push(Te);let ge=2*S,I=2;for(let ie=0;ie<f;ie++){let Ke=ge*ie,De=ge*((ie+1)%f),Xe=0,Ee=[Q[Ke]];for(let Ue=1;Ue<S;Ue++){let qe=Q[Ke+Ue],$e=Q[De+Ue];Ee.push(qe);for(let Ft=1,Ie=Ue-I+1;Ft<=Ie;Ft++)m.lerpVectors(qe,$e,Ft/(Ie+1)),m.sub(ee).setLength(Ae[ie]).add(ee),Ee.push(K[Xe++].copy(m));Ee.push($e)}for(let Ue=0;Ue<S;Ue++)Ee.push(Q[Ue+S+Ke]);Ee.push(Q[De+S]);for(let Ue=0,qe=Ee.length;Ue<qe;Ue++){let $e=Ee[Ue],Ft=Ue*3,Ie=Ue*2;G[Ft]=$e.x,G[Ft+1]=$e.y,G[Ft+2]=$e.z,A($e,ee),X[Ft]=x.x,X[Ft+1]=x.y,X[Ft+2]=x.z,z[Ie]=Math.atan2($e.z,-$e.x)/2/Math.PI+.5,z[Ie+1]=1-(Math.atan2(-$e.y,Math.sqrt($e.x*$e.x+$e.z*$e.z))/Math.PI+.5)}for(let Ue=0,qe=D.length;Ue<qe;Ue++){let $e=D[Ue]*3,Ft=D[Ue]*2,Ie=d/3*2;s[d]=G[$e],s[d+1]=G[$e+1],s[d+2]=G[$e+2],l[d]=X[$e],l[d+1]=X[$e+1],l[d+2]=X[$e+2],c[Ie]=z[Ft],c[Ie+1]=z[Ft+1],d+=3}}}let xe=[];for(let J=0;J<P.length;J++)for(let pe=0;pe<f;pe++){let ne=P[J][pe];if(ne<M){let Ae=P[ne].findIndex(ge=>ge%M==J),Te=me[J][pe],ae=me[ne][Ae];for(let ge=0;ge<S;ge++){let I=Te[ge],ie=ae[S-ge],Ke=Te[ge+1],De=ae[S-(ge+1)];q(I),q(ie),q(Ke),q(Ke),q(ie),q(De)}xe.push(Te[0][0],ae[S][0],Te[S][0],ae[0][0])}}for(;xe.length;){let J,pe,ne,[Ae,Te]=xe.splice(0,2);J=Te;let ae=[Ae];for(;Ae!=J;)ae.push(J),pe=xe.indexOf(J),ne=pe%2,J=xe.splice(pe-ne,2)[1-ne];x.subVectors(ae[0],ae[1]).cross(m.subVectors(ae[0],ae[2])).normalize();let ge=x.dot(ae[0])<0;ge&&x.negate();for(let I=1;I<=ae.length-2;I++)k(ae[I+ +ge]),k(ae[I+1-+ge]),k(ae[0])}}function p(){let h=new dr.Vector3,f=new dr.Vector3,m=new dr.Vector3,y=new dr.Vector3,g=new dr.Vector2,v=new dr.Vector2,b=new dr.Vector2,S=(w,E,P,M)=>{M<0&&w.x===1&&(c[E]=w.x-1),P.x===0&&P.z===0&&(c[E]=M/2/Math.PI+.5)};for(let w=0,E=0;w<d;w+=9,E+=6){h.set(s[w+0],s[w+1],s[w+2]),f.set(s[w+3],s[w+4],s[w+5]),m.set(s[w+6],s[w+7],s[w+8]),g.set(c[E+0],c[E+1]),v.set(c[E+2],c[E+3]),b.set(c[E+4],c[E+5]),y.copy(h).add(f).add(m).divideScalar(3);let P=A(y);S(g,E+0,h,P),S(v,E+2,f,P),S(b,E+4,m,P)}let x=d/3*2;for(let w=0;w<x;w+=6){let E=c[w+0],P=c[w+2],M=c[w+4],D=Math.max(E,P,M),R=Math.min(E,P,M);D>.9&&R<.1&&(E<.2&&(c[w+0]+=1),P<.2&&(c[w+2]+=1),M<.2&&(c[w+4]+=1))}function A(w){return Math.atan2(w.z,-w.x)}}}static fromJSON(t){return new bs(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var jP=require("three"),HP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,s=n===0&&o!==0?new Lp(t*.5,o,a):new jP.DodecahedronGeometry(t*.5,n),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},Lp=class extends bs{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=1/n,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,-o,-n,0,-o,n,0,o,-n,0,o,n,-o,-n,0,-o,n,0,o,-n,0,o,n,0,-n,0,-o,n,0,-o,-n,0,o,n,0,o],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],l="DodecahedronGeometry";super(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new Lp(t.radius,t.corner,t.cornerSides)}};var dt=require("three");var Qe=require("three"),_p=1e-12,td=class{constructor(t){this.position=new Qe.Vector2;this.startPosition=new Qe.Vector2;this.uuid=Qe.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new td(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},rd=class extends td{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new rd(this.parent).copy(this)}},co=class extends td{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new rd(this),new rd(this))}static create(e,r){let n=new co(e,new Qe.Vector2(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let n=0,o=this.controls.length;n<o;n++){let a=this.controls[n];this.position.distanceTo(a.position)<=r?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 co(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),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Qe.Vector2,r=new Qe.Vector2){let[n,o]=this.computeTangents();return n&&o&&(WP(n,e),WP(o,r)),[e,r]}computeTangent(e=new Qe.Vector2){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new Qe.Vector2){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function WP(i,t=new Qe.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var W0=i=>i,nd=new Qe.Vector2,my=new Qe.Vector2,UF=new Qe.Vector2,zF=new Qe.Vector2,jF=new Qe.Vector2,HF=new Qe.Vector2,XP=new Qe.Vector3,YP=new Qe.Vector3;function QP(i){let t=new Qe.Vector2;t.addVectors(i.v0,nd.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Qe.Vector2;return e.addVectors(i.v2,my.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Qe.CubicBezierCurve(i.v0,t,e,i.v2)}function Fp(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function WF(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function qF(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function q0(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-o*o)/(2*n*r))}function KP(i,t,e){return qP(i,t)&&qP(t,e)&&H0(i.position,t.position,e.position)}function H0(i,t,e){return nd.copy(t).sub(i).cross(my.copy(e).sub(i))===0}function ZP(i,t,e,r,n){let o=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(i.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-i.x)/o;return r.set(s+l,a+c),n.set(s-l,a-c),[r,n]}function JP(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function $P(i,t,e,r,n,o){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,d=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),u;return q0(t,i,e)>Math.PI&&(d*=-1),Fp(c,s)?u=(s+c)*(r/d-.5)*8/3/(a-l):u=(a+l)*(r/d-.5)*8/3/(c-s),n.set(t.x-u*s,t.y+u*a),o.set(e.x+u*c,e.y-u*l),[n,o]}function X0(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function qP(i,t){return H0(i.position,i.controls[1].position,t.position)&&H0(i.position,t.controls[0].position,t.position)}function eM(i,t,e,r,n=.5){let o=nd.subVectors(t,i).multiplyScalar(n).add(i),a=my.subVectors(e,t).multiplyScalar(n).add(t),s=UF.subVectors(r,e).multiplyScalar(n).add(e),l=o,c=zF.subVectors(a,o).multiplyScalar(n).add(o),d=jF.subVectors(s,a).multiplyScalar(n).add(a),u=s,p=HF.subVectors(d,c).multiplyScalar(n).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,u.x,u.y,r.x,r.y]}function tM(i,t,e=12,r=!0){let n=YP.set(0,0,0),o,a=0,s=[];for(let l=0;l<t.length;l++){let c=W0(t[l]),d=nd,u=xs(c,e);s.push(u);for(let p=0;p<=u;p++)if(c instanceof Qe.CubicBezierCurve||c instanceof Qe.QuadraticBezierCurve||c instanceof Qe.LineCurve){if(c.getPoint(p/u,d),n.set(d.x,d.y,0),o!==void 0&&qF(o,n))continue;o===void 0&&(o=XP),o.copy(n),i.setXYZ(a,n.x,n.y,n.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function rM(i,t,e,r=12,n=!0){let o=YP.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,d=W0(t[l]),u=nd,p=xs(d,r);s.push(p);for(let h=0;h<=p;h++)if(d instanceof Qe.CubicBezierCurve||d instanceof Qe.QuadraticBezierCurve||d instanceof Qe.LineCurve){if(d.getPoint(h/p,u),o.set(u.x,u.y,0),c?.equals(o))continue;c===void 0?c=XP:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,o.x,o.y,o.z),a++),c.copy(o)}}return n&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function Y0(i,t=12,e=!1){let r=[];for(let n=0,o=i.length;n<o;n++){let a=i[n],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=xs(a.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=xs(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=xs(i[0].roundedCurveCorner,t)*.5),r}function xs(i,t=12){return i&&i instanceof Qe.EllipseCurve?t*2:i&&(i instanceof Qe.LineCurve||i instanceof Qe.LineCurve3)?1:i&&i instanceof Qe.SplineCurve?t*i.points.length:t}function nM(i,t,e=12,r=!0){let n,o=0;for(let a=0;a<t.length;a++){let s=W0(t[a]),l=xs(s,e),c=nd;for(let d=0;d<=l;d++)if(s instanceof Qe.CubicBezierCurve||s instanceof Qe.QuadraticBezierCurve||s instanceof Qe.LineCurve){if(s.getPoint(d/l,c),n!==void 0&&WF(n,c,_p))continue;n===void 0&&(n=my),n.copy(c),i.push(c.x,c.y),o++}}return Fp(i[0],i[i.length-2],_p)&&Fp(i[1],i[i.length-1],_p)&&(i.pop(),i.pop()),r&&o>1&&!(Fp(i[o-1],i[1],_p)&&Fp(i[o-2],i[0],_p))&&(i.push(i[0],i[1]),o++),i}var Q0=new dt.Vector2,XF=new dt.Vector2,YF=new dt.Vector2,QF=new dt.Vector2,KF=new dt.Vector2,ZF=new dt.Vector2,ht=class extends dt.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new dt.Plane(new dt.Vector3(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.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let o=new ht;return o.isClosed=e.isClosed,o.points=e.points.map(a=>co.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>ht.createFromState(a)),r!==void 0&&n!==void 0&&o.applySize(r,n),o.update(),o}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 r=0,n=this.points.length;r<n;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,n=this.points.findIndex(o=>o.uuid===e);if(n<0){let o=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,d=l.getPointIndexById(e);if(d<0)o+=c;else return d+o}}return n}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let n=Q0.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let s=this.points[o];s.position.multiply(n),s.controls[0].position.multiply(n),s.controls[1].position.multiply(n)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update()}createPoint(e,r=0,n=dt.MathUtils.generateUUID()){let o;e instanceof dt.Vector2?o=e:o=new dt.Vector2(e,r);let a=new co(n,o);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,n=this.points.length;r<n;r++){let o=this.points[r];if(o.uuid===e)return o}for(let r=0,n=this.shapeHoles.length;r<n;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(n=>n.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=n?this.roundedCurveDivisions:this.curveDivisions;return tM(e,n?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Y0(this.points,e,!1),this.roundedCurveDivisions=Y0(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return rM(e,this.curves,r,n,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),nM(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=xs(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let d=o[l];if(s<n+d)return[l,(s-n+1)/d];n+=d}return[0,1]}getCurveT(e,r,n){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(X0(o,a)){let u=o.position.distanceTo(a.position);return o.position.distanceTo(Q0.set(n.x,n.y))/u}let c=0;for(let u=0;u<e;u++)c+=s[u];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){X0(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let o=n.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let o=this.points[r];if(r===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(o,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,o=this.points.length;n<o;n++){let a=this.points[n],s=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],c=a.roundness,d=s&&l&&KP(s,a,l);if(!a.controlsMoved()&&c>0&&!d){let u=a.curveBefore,p=a.curveAfter;if(u===void 0||p===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=u instanceof dt.LineCurve?u.v1.distanceTo(u.v2):u.getLength(),y=p instanceof dt.LineCurve?p.v1.distanceTo(p.v2):p.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),b=Math.min(g,v),S=1-b/m,x=b/y,A=u.getPointAt(S,Q0),w=p.getPointAt(x,XF);this._subSplitCurve(u,h,S,A,void 0),this._subSplitCurve(p,f,x,void 0,w);let E;if(this.useCubicForRoundedCorners){let P=q0(A,a.position,w)/2,M=Math.tan(P)*A.distanceTo(a.position),[D,R]=ZP(A,w,M,YF,QF),L=JP(D,R,a.position),[C,B]=$P(L,A,w,M,KF,ZF);E=new dt.CubicBezierCurve(A.clone(),C.clone(),B.clone(),w.clone())}else E=new dt.QuadraticBezierCurve(A.clone(),a.position.clone(),w.clone());a.roundedCurveCorner=E,this.roundedCurves.splice(n+r,0,E),r++}}}}_subSplitCurve(e,r,n,o,a){if(e instanceof dt.LineCurve)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(n,0),d=eM(s.v0,s.v1,s.v2,s.v3,c);return o!==void 0&&(l.v0.set(d[0],d[1]),l.v1.set(d[2],d[3]),l.v2.set(d[4],d[5]),l.v3.set(d[6],d[7])),a!==void 0&&(l.v0.set(d[6],d[7]),l.v1.set(d[8],d[9]),l.v2.set(d[10],d[11]),l.v3.set(d[12],d[13])),l}return r}clone(){let e=new ht(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let n=0;n<r;n++){let o=n*7,a=e.points[o+0],s=e.points[o+1],l=e.points[o+2],c=e.points[o+3],d=e.points[o+4],u=e.points[o+5],p=e.points[o+6],h=new co(dt.MathUtils.generateUUID(),new dt.Vector2(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(d,u),h.roundness=p,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let o=new ht;return o.fromJSON(n),o}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(a,s)=>{s instanceof dt.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},o=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof dt.QuadraticBezierCurve&&(a[l]=QP(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],h=l>0?a[l-1]:null,f;p instanceof dt.CubicBezierCurve?(f=this.createPoint(p.v0),f.controls[1].position.copy(p.v1)):p instanceof dt.LineCurve&&(f=this.createPoint(p.v1)),f!==void 0&&(h!==null&&n(f,h),s.push(f))}let d=a[a.length-1],u=!1;return d instanceof dt.CubicBezierCurve?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),u=!0):d instanceof dt.LineCurve&&d.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=o(e.curves),e instanceof dt.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new ht;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let o=this.getPointByUuid(e)?.controls[0];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let o=this.getPointByUuid(e)?.controls[1];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}};var Z0=Math.PI*2;function K0({x:i,y:t},e,r,n,o){return{x:i*e+n,y:t*r+o}}function JF(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function iM(i,t,e,r){let n=i*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(o)}function $F(i,t,e,r,n,o,a,s,l,c){let d=Math.pow(n,2),u=Math.pow(o,2),p=Math.pow(a,2),h=Math.pow(s,2),f=d*u-d*h-u*p;f<0&&(f=0),f/=d*h+u*p,f=Math.sqrt(f)*(l===c?-1:1);let m=f*n/o*s,y=f*-o/n*a,g=m+(i+e)/2,v=y+(t+r)/2,b=(a-m)/n,S=(s-y)/o,x=(-a-m)/n,A=(-s-y)/o,w=iM(1,0,b,S),E=iM(b,S,x,A);return!c&&E>0&&(E-=Z0),c&&E<0&&(E+=Z0),{centerx:g,centery:v,ang1:w,ang2:E}}function oM({px:i,py:t,cx:e,cy:r,rx:n,ry:o,largeArcFlag:a,sweepFlag:s}){let l=[];if(n===0||o===0)return[];let c=(i-e)/2,d=(t-r)/2;if(c===0&&d===0)return[];n=Math.abs(n),o=Math.abs(o);let u=Math.pow(c,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);u>1&&(n*=Math.sqrt(u),o*=Math.sqrt(u));let p=$F(i,t,e,r,n,o,c,d,a,s),{ang1:h,ang2:f}=p,{centerx:m,centery:y}=p,g=Math.abs(f)/(Z0/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let b=0;b<v;b++)l.push(JF(h,f)),h+=f;return l.map(b=>{let{x:S,y:x}=K0(b[0],n,o,m,y),{x:A,y:w}=K0(b[1],n,o,m,y),{x:E,y:P}=K0(b[2],n,o,m,y);return{x1:S,y1:x,x2:A,y2:w,x:E,y:P}})}var Pl=require("three");var Ct;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Ct||(Ct={}));var _r;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(_r||(_r={}));function Be(i,t){if(!i)throw t||"Assertion Failed!"}var Me=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Be(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?n<o?e.t-t.t+(t.t-r.t)*(n/(n+o)):e.t-r.t+(r.t-t.t)*(o/(n+o)):0},i.edgeSign=function(t,e,r){Be(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?(e.t-r.t)*n+(e.t-t.t)*o:0},i.transEval=function(t,e,r){Be(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?n<o?e.s-t.s+(t.s-r.s)*(n/(n+o)):e.s-r.s+(r.s-t.s)*(o/(n+o)):0},i.transSign=function(t,e,r){Be(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?(e.s-r.s)*n+(e.s-t.s)*o:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,o){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,n),a+s<0&&(a=-a,s=-s),o.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,n,e),a+s<0&&(a=-a,s=-s),o.s=i.interpolate(a,r.s,s,n.s)):o.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(a=i.transEval(t,r,e),s=i.transEval(r,e,n),a+s<0&&(a=-a,s=-s),o.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,n,e),a+s<0&&(a=-a,s=-s),o.t=i.interpolate(a,r.t,s,n.t)):o.t=(r.t+e.t)/2},i}(),kp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),yy=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),id=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),aM=function(){function i(){var t=new id,e=new kp,r=new yy(0),n=new yy(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new yy(0),r=new yy(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;Be(n,"Vertex can't be null!");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e;var a=e;do a.Org=n,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;Be(n,"Face can't be null");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var a=e;do a.Lface=n,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.makeEdge=function(){var t=new id,e=new id,r=new kp,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var o=new id;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new kp;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=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 n=new kp;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new id;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.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},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),o=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(o,e),n.Org=t.Dst,o.Org=e.Org,n.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new kp;this.makeFace_(a,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,o,a,s;n=e.Lnext;do r=n,n=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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,o,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;n=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),s+l-2<=t&&Me.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Me.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(n=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,o,a,s,l,c;for(o=t,o=t;(n=o.next)!==t;o=n){Be(n.prev===o),l=n.anEdge;do Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l),Be(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(Be(n.prev===o&&n.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Be(a.prev===s),l=a.anEdge;do Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l),Be(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Be(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Be(l.Sym.next===c.Sym),Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Org!==null),Be(l.Dst!==null),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l);Be(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),sM=function(){function i(){this.handle=null}return i}(),lM=function(){function i(){this.key=null,this.node=0}return i}(),ek=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new sM,this.handles[r]=new lM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Be(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[n].key,r[o].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,o;for(o=this.nodes.length,this.nodes.length=this.max+1,n=o;n<this.nodes.length;n++)this.nodes[n]=new sM;for(o=this.handles.length,this.handles.length=this.max+1,n=o;n<this.handles.length;n++)this.handles[n]=new lM}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;Be(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),J0=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),cM=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),tk=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new cM,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new cM;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),rk=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,o=e.eUp,a=r.eUp;if(o.Dst===n)return a.Dst===n?Me.vertLeq(o.Org,a.Org)?Me.edgeSign(a.Dst,o.Org,a.Org)<=0:Me.edgeSign(o.Dst,a.Org,o.Org)>=0:Me.edgeSign(a.Dst,n,a.Org)<=0;if(a.Dst===n)return Me.edgeSign(o.Dst,n,o.Org)>=0;var s=Me.edgeEval(o.Dst,n,o.Org),l=Me.edgeEval(a.Dst,n,a.Org);return s>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&Be(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Be(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new J0;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case Ct.ODD:return(e&1)!==0;case Ct.NONZERO:return e!==0;case Ct.POSITIVE:return e>0;case Ct.NEGATIVE:return e<0;case Ct.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,o=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=i.regionBelow(a),n=o.eUp,n.Org!=s.Org){if(!o.fixUpperEdge){i.finishRegion(t,a);break}n=t.mesh.connect(s.Lprev,n.Sym),i.fixUpperEdge(t,o,n)}s.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(s,n)),i.finishRegion(t,a),s=o.eUp,a=o}return s},i.addRightEdges=function(t,e,r,n,o,a){var s,l,c,d,u=!0;c=r;do Be(Me.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==n);for(o===null&&(o=i.regionBelow(e).eUp.Rprev),l=e,d=o;s=i.regionBelow(l),c=s.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(d.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!u&&i.checkForRightSplice(t,l)&&(i.addWinding(c,d),i.deleteRegion(t,l),t.mesh.delete(d)),u=!1,l=s,d=c;l.dirty=!0,Be(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Me.vertL1dist(e,t),o=Me.vertL1dist(r,t),a=.5*o/(n+o),s=.5*n/(n+o);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,n,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,o,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp;if(Me.vertLeq(n.Org,o.Org)){if(Me.edgeSign(o.Dst,n.Org,o.Org)>0)return!1;Me.vertEq(n.Org,o.Org)?n.Org!==o.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,o.Oprev,n)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(n,o.Oprev),e.dirty=r.dirty=!0)}else{if(Me.edgeSign(n.Dst,o.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a;if(Be(!Me.vertEq(n.Dst,o.Dst)),Me.vertLeq(n.Dst,o.Dst)){if(Me.edgeSign(n.Dst,o.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Me.edgeSign(o.Dst,n.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a=n.Org,s=o.Org,l=n.Dst,c=o.Dst,d,u,p=new id,h,f;if(Be(!Me.vertEq(c,l)),Be(Me.edgeSign(l,t.event,a)<=0),Be(Me.edgeSign(c,t.event,s)>=0),Be(a!==t.event&&s!==t.event),Be(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(d=Math.min(a.t,l.t),u=Math.max(s.t,c.t),d>u))return!1;if(Me.vertLeq(a,s)){if(Me.edgeSign(c,a,s)>0)return!1}else if(Me.edgeSign(l,s,a)<0)return!1;return i.debugEvent(t),Me.intersect(l,a,c,s,p),Be(Math.min(a.t,l.t)<=p.t),Be(p.t<=Math.max(s.t,c.t)),Be(Math.min(c.s,l.s)<=p.s),Be(p.s<=Math.max(s.s,a.s)),Me.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),h=Me.vertLeq(a,s)?a:s,Me.vertLeq(h,p)&&(p.s=h.s,p.t=h.t),Me.vertEq(p,a)||Me.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!Me.vertEq(l,t.event)&&Me.edgeSign(l,t.event,p)>=0||!Me.vertEq(c,t.event)&&Me.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Lnext,o.Oprev),r=e,e=i.topRightRegion(e),f=i.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,o.Onext,n.Rprev,f,!0),!0):(Me.edgeSign(l,t.event,p)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Me.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,n),n.Org.s=p.s,n.Org.t=p.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,o;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,o=r.eUp,n.Dst!==o.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(o),r=i.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==o.Org)if(n.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||o.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===o.Org&&n.Dst===o.Dst&&(i.addWinding(o,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,o=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),Me.vertEq(s.Org,t.event)&&(t.mesh.splice(o.Oprev,s),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),Me.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,o,o,!0);return}Me.vertLeq(l.Org,s.Org)?n=l.Oprev:n=s,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,o,a,s,l;if(n=e.eUp,Me.vertEq(n.Org,r)){Be(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Me.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}Be(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,o=s=a.Onext,l.fixUpperEdge&&(Be(o!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Me.edgeGoesLeft(o)||(o=null),i.addRightEdges(t,e,a.Onext,s,o,!0)},i.connectLeftVertex=function(t,e){var r,n,o,a,s,l,c=new J0;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,n=i.regionBelow(r),!!n){if(a=r.eUp,s=n.eUp,Me.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(o=Me.vertLeq(s.Dst,a.Dst)?r:n,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(s.Dnext,e.anEdge);l=d.Sym}o.fixUpperEdge?i.fixUpperEdge(t,o,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);Be(n!==null);var o=i.regionBelow(n),a=o.eUp,s=i.finishLeftRegions(t,o,null);s.Onext===a?i.connectRightVertex(t,n,s):i.addRightEdges(t,n,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,n){var o=new J0,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=n,a.Dst.s=e,a.Dst.t=n,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},i.initEdgeDict=function(t){t.dict=new tk(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,n,o,a),i.addSentinel(t,n,o,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Be(e.fixUpperEdge),Be(++r===1)),Be(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,n=e.Lnext,Me.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,o=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)o++;for(o+=8,e=t.pq=new ek(o,Me.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,o;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,o=r.anEdge,Be(o.Lnext!==o),o.Lnext.Lnext===o&&(i.addWinding(o.Onext,o),t.mesh.delete(o));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Me.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),nk=function(){function i(){this.mesh=new aM,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=Ct.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,o,a,s,l=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)o=e.coords[y],c[y]=o,f[y]=e,l[y]=o,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)o=e.coords[g],o<c[g]&&(c[g]=o,f[g]=e),o>l[g]&&(l[g]=o,h[g]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=f[v],n=h[v],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)u[0]=e.coords[0]-n.coords[0],u[1]=e.coords[1]-n.coords[1],u[2]=e.coords[2]-n.coords[2],p[0]=d[1]*u[2]-d[2]*u[1],p[1]=d[2]*u[0]-d[0]*u[2],p[2]=d[0]*u[1]-d[1]*u[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,o=0,a=t.next;a!==t;a=a.next)if(n=a.anEdge,!(n.winding<=0))do o+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==a.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,n=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,n[a]=0,n[(a+1)%3]=0,n[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,n);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Me.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Me.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var o=void 0;r.Lnext!==n;)if(Me.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Me.edgeGoesLeft(n.Lnext)||Me.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)o=t.connect(n.Lnext,n),n=o.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Me.edgeGoesRight(r.Lprev)||Me.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)o=t.connect(n.Lnext,n),n=o.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,o=t.eHead.next;o!==t.eHead;o=n)n=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var o,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=s,s++),l++,o=o.Lnext}while(o!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===_r.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*n,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var u=c.n*n;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],n>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;this.elements[p++]=c.n,l++,o=o.Lnext}while(o!==d.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1;if(e===_r.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){n=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;o=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,n=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==n);this.elements[d++]=o,this.elements[d++]=a,o+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new aM),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,o,a){if(t===void 0&&(t=Ct.ODD),e===void 0&&(e=_r.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),rk.computeInterior(this,a);var s=this.mesh;return e===_r.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===_r.BOUNDARY_CONTOURS?this.outputContours_(s,n):this.outputPolymesh_(s,e,r,n),!0},i}();function Ss(i){var t=i.windingRule,e=t===void 0?Ct.ODD:t,r=i.elementType,n=r===void 0?_r.POLYGONS:r,o=i.polySize,a=o===void 0?3:o,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,d=c===void 0?[0,0,1]:c,u=i.contours,p=u===void 0?[]:u,h=i.strict,f=h===void 0?!0:h,m=i.debug,y=m===void 0?!1:m;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var g=new nk;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(l||2,p[v]);return g.tesselate(e,n,a,l,d,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var UY=Ct.ODD,zY=Ct.NONZERO,jY=Ct.POSITIVE,HY=Ct.NEGATIVE,WY=Ct.ABS_GEQ_TWO,qY=_r.POLYGONS,XY=_r.CONNECTED_POLYGONS,YY=_r.BOUNDARY_CONTOURS;function gy(i,t){let e=i.length/2;if(e<2)return[];let r=0;for(let l=0;l<e;l++){let c=(l+1)%e;r+=i[l*2]*i[c*2+1]-i[c*2]*i[l*2+1]}let n=r>0!==t?1:-1,o=[];for(let l=0;l<e;l++){let c=(l+1)%e,d=i[c*2]-i[l*2],u=i[c*2+1]-i[l*2+1],p=Math.hypot(d,u);o.push(p>0?[n*u/p,-n*d/p]:[0,0])}let a=Math.cos(40*Math.PI/180),s=(l,c)=>{if(l[0]*c[0]+l[1]*c[1]<=a)return l;let[d,u]=[l[0]+c[0],l[1]+c[1]],p=Math.hypot(d,u);return p>0?[d/p,u/p]:l};return o.map((l,c)=>[s(l,o[(c+e-1)%e]),s(l,o[(c+1)%e])])}function vy(i,t,e){let r=i.length/2,n=new Float32Array(r+1);if(!(t>0)||!(e>0)||r<2)return{u:n,vScale:0};let o=0;for(let a=0;a<r;a++){let s=(a+1)%r;o+=Math.hypot((i[s*2]-i[a*2])/t,(i[s*2+1]-i[a*2+1])/e),n[a+1]=o}return{u:n,vScale:Math.sqrt(t*e)}}function by(i,t,e){for(let r=0;r<e.length;r+=3){let n=e[r]*3,o=e[r+1]*3,a=e[r+2]*3,s=i[o]-i[n],l=i[o+1]-i[n+1],c=i[o+2]-i[n+2],d=i[a]-i[n],u=i[a+1]-i[n+1],p=i[a+2]-i[n+2],h=l*p-c*u,f=c*d-s*p,m=s*u-l*d,y=t[n]+t[o]+t[a],g=t[n+1]+t[o+1]+t[a+1],v=t[n+2]+t[o+2]+t[a+2];if(h*y+f*g+m*v<0){let b=e[r+1];e[r+1]=e[r+2],e[r+2]=b}}}var xy={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},dM={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Sy={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};var uM=2,Ml=class extends Pl.BufferGeometry{constructor(e,r,n=12,o=Ct.ODD,a){super();this.type="FlatExtrusionGeometry";this._nearSide=new Uint8Array(0);this._vScale=0;this._shape=e,this._depth=r,this._curveSegments=n,this._windingRule=o,this._uvPitch=a;let s=[e.extractShapePointsToFlatArray([],n),...e.shapeHoles.map(k=>k.extractShapePointsToFlatArray([],n))],l;try{l=Ss({contours:s,windingRule:o,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{l=Sy}let c=l?.vertexCount??0,d=l?.elementCount??0,u=1/0,p=1/0,h=-1/0,f=-1/0;for(let k of s)for(let q=0;q<k.length;q+=2)k[q]<u&&(u=k[q]),k[q]>h&&(h=k[q]),k[q+1]<p&&(p=k[q+1]),k[q+1]>f&&(f=k[q+1]);let m=this._uvPitch,y=m??(h-u||1),g=m??(f-p||1),v=m===void 0?u:0,b=m===void 0?p:0,S=s.map((k,q)=>gy(k,q>0)),x=0;for(let k of S)x+=k.length;let A=c*2+x*4,w=d*3*2+x*6,E=new Float32Array(A*3),P=new Float32Array(A*3),M=new Float32Array(A*2),D=new Uint32Array(w),R=new Uint8Array(A),L=0,C=0,B=0,_=!1,F=(k,q,W,G,X,z,Q=(k-v)/y,K=(q-b)/g)=>{let ee=C*3;E[ee]=k,E[ee+1]=q,E[ee+2]=W,P[ee]=G,P[ee+1]=X,P[ee+2]=z,R[C]=W===r?_?uM:1:0,M[C*2]=Q,M[C*2+1]=K,C++};if(l!==void 0)for(let[k,q]of[[r,1],[0,-1]]){let W=C;for(let G=0;G<c;G++)F(l.vertices[G*2],l.vertices[G*2+1],k,0,0,q);for(let G=0;G<d;G++){let[X,z,Q]=[l.elements[G*3],l.elements[G*3+1],l.elements[G*3+2]];D[B++]=W+X,D[B++]=W+(q>0?z:Q),D[B++]=W+(q>0?Q:z)}}_=!0;for(let k=0;k<s.length;k++){let q=s[k],W=S[k],G=q.length/2,{u:X,vScale:z}=vy(q,y,g);L=z;let Q=z===0?0:r/z;for(let K=0;K<W.length;K++){let ee=(K+1)%G,[ve,le]=W[K],[de,ce]=[X[K],X[K+1]],me=C;F(q[K*2],q[K*2+1],r,ve[0],ve[1],0,de,Q),F(q[K*2],q[K*2+1],0,ve[0],ve[1],0,de,0),F(q[ee*2],q[ee*2+1],r,le[0],le[1],0,ce,Q),F(q[ee*2],q[ee*2+1],0,le[0],le[1],0,ce,0),D[B++]=me,D[B++]=me+1,D[B++]=me+2,D[B++]=me+3,D[B++]=me+2,D[B++]=me+1}}by(E,P,D),this.setAttribute("position",new Pl.BufferAttribute(E,3)),this.setAttribute("normal",new Pl.BufferAttribute(P,3)),this.setAttribute("uv",new Pl.BufferAttribute(M,2)),this.setIndex(new Pl.BufferAttribute(D,1)),this._nearSide=R,this._vScale=L}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position");if(n===void 0)return!1;let o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===uM&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}clone(){let e=new Ml(this._shape,this._depth,this._curveSegments,this._windingRule);return e.userData=ys(this.userData),e}};var Ol=require("three");var od=class extends Ol.BufferGeometry{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=Ct.ODD;this.elementType=_r.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Ct.ODD,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,d,u;for(let f=0,m=o.length/2;f<m;f++){let y=f*2,g=o[y+0],v=o[y+1];if(d!==void 0&&g!==d&&(l=!1),u!==void 0&&v!==u&&(c=!1),d=g,u=v,!l&&!c)break}if(!l&&!c)try{s=Ss({contours:[o,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=xy}let p=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new Ol.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Ol.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Ol.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Ol.BufferAttribute(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let S=0,x=p;S<x;S++){let A=S*2,w=s.vertices[A+0],E=s.vertices[A+1];w<f&&(f=w),w>m&&(m=w),E<y&&(y=E),E>g&&(g=E)}let v=m-f,b=g-y;for(let S=0,x=p;S<x;S++){let A=S*2,w=s.vertices[A+0],E=s.vertices[A+1],P=(w-f)/v,M=(E-y)/b;this._positionAttribute.setXYZ(S,w,E,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,M)}for(let S=0,x=h;S<x;S++){let A=S*3,w=s.elements[A+0],E=s.elements[A+1],P=s.elements[A+2];this._indexAttribute.setX(A+0,w),this._indexAttribute.setX(A+1,E),this._indexAttribute.setX(A+2,P)}}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 od(this._shape,this._curveSegments);return e.userData=ys(this.userData),e}};var ui=require("three");var Ay;var ok=.4;function hM(){return Ay!==void 0}function fM(i,t){let r=[i.extractShapePointsToFlatArray([],t)];for(let l of i.shapeHoles)r.push(l.extractShapePointsToFlatArray([],t));let n=0;for(let l of r)n+=l.length>>1;let o=new Float64Array(n*2),a=new Uint32Array(r.length),s=0;for(let l=0;l<r.length;l++)o.set(r[l],s*2),s+=r[l].length>>1,a[l]=s;return{points:o,ends:a}}function ak(i){let t=2166136261;for(let e=0;e<i.length;e++)t^=i[e],t=Math.imul(t,16777619)>>>0;return t}function sk(i,t){let e=[t],r=n=>{e.push(n.points.length,n.isClosed?1:0,n.roundness??0);for(let o of n.points){e.push(o.roundness??0,o.position.x,o.position.y);for(let a of o.controls)e.push(a.position.x,a.position.y)}e.push(n.shapeHoles.length);for(let o of n.shapeHoles)r(o)};return r(i),ak(new Uint8Array(new Float64Array(e).buffer))}var lk=new ui.Matrix3;function ck(i,t,e,r,n){let o=1/0;for(let a=2;a<i.length;a+=3)i[a]<o&&(o=i[a]);if(o===1/0&&(o=0),o!==0)for(let a=2;a<i.length;a+=3)i[a]-=o;return{positions:i,normals:t,uvs:e,indices:r,rise:n-o}}function Vp(i,t,e,r,n,o){let a=i.positions.length/3,s=n.elements,l=lk.getNormalMatrix(n).elements;for(let d=0;d<a;d++){let u=d*3,p=(e+d)*3,h=i.positions[u],f=i.positions[u+1],m=i.positions[u+2];t.positions[p]=s[0]*h+s[4]*f+s[8]*m+s[12],t.positions[p+1]=s[1]*h+s[5]*f+s[9]*m+s[13],t.positions[p+2]=s[2]*h+s[6]*f+s[10]*m+s[14];let y=i.normals[u],g=i.normals[u+1],v=i.normals[u+2];t.normals[p]=l[0]*y+l[3]*g+l[6]*v,t.normals[p+1]=l[1]*y+l[4]*g+l[7]*v,t.normals[p+2]=l[2]*y+l[5]*g+l[8]*v;let b=(e+d)*2;if(o===void 0)t.uvs[b]=i.uvs[d*2],t.uvs[b+1]=i.uvs[d*2+1];else{let[S,x]=o(h,f,i.uvs[d*2],i.uvs[d*2+1]);t.uvs[b]=S,t.uvs[b+1]=x}}let c=n.determinant()<0;for(let d=0;d<i.indices.length;d+=3)t.indices[r+d]=i.indices[d]+e,t.indices[r+d+1]=i.indices[d+(c?2:1)]+e,t.indices[r+d+2]=i.indices[d+(c?1:2)]+e}var dk=new ui.Matrix4,uk=new ui.Matrix4,pk=new ui.Matrix4().makeScale(1,1,-1);function hk(i,t,e,r,n){let o=r.positions.length/3,a=e-r.rise,s=r.rise,{points:l,ends:c}=fM(i,t),d=1/0,u=1/0,p=-1/0,h=-1/0;for(let C=0;C<l.length;C+=2)l[C]<d&&(d=l[C]),l[C]>p&&(p=l[C]),l[C+1]<u&&(u=l[C+1]),l[C+1]>h&&(h=l[C+1]);let f=n??p-d,m=n??h-u,y=[],g=0;for(let C of c)y.push({at:g,count:C-g}),g=C;let v=0;for(let C of y)v+=C.count;let b=o*2+v*4,S=new Float32Array(b*3),x=new Float32Array(b*3),A=new Float32Array(b*2),w=new Uint32Array(r.indices.length*2+v*6),E=new Uint8Array(b),P=0,M=n===void 0?void 0:(C,B)=>[C/n,B/n],D={positions:S,normals:x,uvs:A,indices:w};Vp(r,D,0,0,dk.makeTranslation(0,0,a),M),Vp(r,D,o,r.indices.length,uk.makeTranslation(0,0,s).multiply(pk),M),E.fill(1,0,o);let R=o*2,L=r.indices.length*2;for(let C=0;C<y.length;C++){let{at:B,count:_}=y[C],F=l.subarray(B*2,(B+_)*2),k=gy(F,C>0),q=vy(F,f,m),W=q.u;P=q.vScale;for(let G=0;G<_;G++){let X=(G+1)%_,[z,Q]=k[G],K=R;for(let[ee,ve,le,de,ce,me]of[[F[G*2],F[G*2+1],z,a,W[G],$0],[F[X*2],F[X*2+1],Q,a,W[G+1],$0],[F[X*2],F[X*2+1],Q,s,W[G+1],0],[F[G*2],F[G*2+1],z,s,W[G],0]]){let be=R*3;S[be]=ee,S[be+1]=ve,S[be+2]=de,x[be]=le[0],x[be+1]=le[1],x[be+2]=0,A[R*2]=ce,A[R*2+1]=P===0?0:(de-s)/P,E[R]=me,R++}w[L++]=K,w[L++]=K+1,w[L++]=K+2,w[L++]=K,w[L++]=K+2,w[L++]=K+3}}return by(S,x,w),{positions:S,normals:x,uvs:A,indices:w,nearSide:E,vScale:P}}var $0=2,eS=new Map,pM={assemblies:0,placements:0};function mM(i){let{owner:t,shape:e,curveSegments:r,assembledAt:n,bevel:o,bevelSegments:a}=i,s=sk(e,r),l=t??`outline:${s}`,c=`${o}/${a}`,d=eS.get(l);if(d!==void 0&&d.outlineVersion===s&&d.capKey===c&&(i.stillServes?.(d)??!0))return pM.placements++,d.cap;let u=fk(e,r,n,o,a);pM.assemblies++;try{let p=mk(u,n);return eS.set(l,{outlineVersion:s,capKey:c,assembledAt:n,cap:p}),p}finally{u.free()}}function yM(i){eS.delete(i)}var ad=class extends ui.BufferGeometry{constructor(e,r,n=0,o=12,a=3,s,l){super();this.type="ShapeGeometry";this._nearSide=new Uint8Array(0);this._effectiveBevel=0;this._vScale=0;if(Ay===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=l,this._depth=r,this._bevel=n,this._curveSegments=o,this._bevelSegments=a,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale,this._effectiveBevel=r._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&Dl(this._effectiveBevel,e)&&Dl(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position");if(n===void 0)return!1;let o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===$0&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=mM({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:l=>Dl(l.cap.rise,this._depth)&&Dl(l.cap.rise,l.assembledAt)}),r=hk(this._shape,this._curveSegments,this._depth,e,this._uvPitch);this._nearSide=r.nearSide,this._vScale=r.vScale,this._effectiveBevel=e.rise;let n=this.getAttribute("position"),o=this.getAttribute("normal"),a=this.getAttribute("uv"),s=this.getIndex();if(n!==void 0&&o!==void 0&&a!==void 0&&s!==null&&n.array.length===r.positions.length&&o.array.length===r.normals.length&&a.array.length===r.uvs.length&&s.array.length===r.indices.length){n.array.set(r.positions),o.array.set(r.normals),a.array.set(r.uvs),s.array.set(r.indices),n.needsUpdate=!0,o.needsUpdate=!0,a.needsUpdate=!0,s.needsUpdate=!0;return}this.setAttribute("position",new ui.BufferAttribute(r.positions,3)),this.setAttribute("normal",new ui.BufferAttribute(r.normals,3)),this.setAttribute("uv",new ui.BufferAttribute(r.uvs,2)),this.setIndex(new ui.BufferAttribute(r.indices,1))}clone(){let e=new ad(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId);return e.userData=ys(this.userData),e}};function fk(i,t,e,r,n){let{points:o,ends:a}=fM(i,t);return Ay.assemble_cap(o,a,e,r,0,Math.max(1,Math.floor(n)),ok,40)}function gM(i,t,e,r,n){if(!(Ay===void 0||!(t>0)))return mM({owner:n,shape:i,curveSegments:r,assembledAt:2*t,bevel:t,bevelSegments:e})}function mk(i,t){return ck(i.positions(),i.normals(),i.uvs(),i.indices(),t)}function Dl(i,t){return t*.5>i*(1+.001)}var Qn=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Ct.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shape??t?.shape,s=a?.roundness??e.roundness,l;a!==void 0&&(a instanceof ht?(l=a,(l.width!==r||l.height!==n)&&l.applySize(r,n)):l=new ht(r,n).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&l.update());let c=l??new ht(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:o,roundness:s}),shape:c,ownerId:i.ownerId??t?.ownerId}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:o,windingRule:a,uvPitch:s}=i.parameters;i.shape.roundness=o;let l;return t<=0?l=new od(i.shape,n,{windingRule:a}):e<=0?l=new Ml(i.shape,t,n,a,s):hM()?l=new ad(i.shape,t,e,n,r,i.ownerId,s):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),l=new Ml(i.shape,t,n,a,s)),Object.assign(l,{userData:{...i,type:"VectorGeometry"}})}};var uo=require("three"),bM=Math.PI*2,ld=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=uo.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,d=t*.5,u=e*.5,p=yk(c,d,u,n*Math.PI/180,r,o);c.isClosed=!0,c.update();let h;return n===0?(h=new uo.BufferGeometry,h.setAttribute("position",new uo.Float32BufferAttribute([],3))):h=Qn.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(h,{userData:{...i,type:"EllipseGeometry"}})}};function yk(i,t,e,r,n,o){if(r>=bM)return n>30||n%4===0?(vk(i,t,e,o),Math.round(n/4)):vM(i,r,n,t,e,o);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=oM({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%c.length===0?gk(i,a.x,a.y,c,n,t,e,o):vM(i,r,n,t,e,o)}function gk(i,t,e,r,n,o,a,s){let l=Math.round(n/r.length);i.addPoint(sd(t,e));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=i.points[c],h=sd(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),h.controls[0].position.set(u.x2,u.y2),i.addPoint(h)}return s>0?xM(i,o,a,s):i.addPoint(sd(0,0)),l}function vM(i,t,e,r,n,o){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,d=Math.cos(l)*n;i.addPoint(sd(c,d))}return t<bM?o>0?xM(i,r,n,o):i.addPoint(sd(0,0)):(i.removePoint(i.points[i.points.length-1]),o>0&&SM(i,r,n,o)),1}function vk(i,t,e,r=0,n=0,o=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(wy(n-t,o,n-t,o-l,n-t,o+l)),i.addPoint(wy(n,o+e,n-s,o+e,n+s,o+e)),i.addPoint(wy(n+t,o,n+t,o+l,n+t,o-l)),i.addPoint(wy(n,o-e,n+s,o-e,n-s,o-e)),r>0&&SM(i,t,e,r)}function sd(i,t){return new co(uo.MathUtils.generateUUID(),new uo.Vector2(i,t))}function wy(i,t,e,r,n,o){let a=sd(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(n,o),a}function xM(i,t,e,r){AM(i,t,e,r).forEach(o=>i.addPoint(o))}function SM(i,t,e,r){let n=AM(i,t,e,r),o=new ht;n.forEach(a=>o.addPoint(a)),o.isClosed=!0,i.shapeHoles.push(o)}function AM(i,t,e,r){let n=r*t/100,o=n*(Math.abs(e)/Math.abs(t)),a=new uo.Vector2(n/t,o/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=uo.MathUtils.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),s}var wM=require("three");var EM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,s=n===0&&o!==0?new Gp(t*.5,o,a):new wM.IcosahedronGeometry(t*.5,n),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},Gp=class extends bs{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],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],s="IcosahedronGeometry";super(o,a,s,t,e,r),this.type=s}static fromJSON(t){return new Gp(t.radius,t.corner,t.cornerSides)}};var Ey=require("three"),CM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new Ey.Shape;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Ey.LatheGeometry(n.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:{...i,type:"LatheGeometry"}})}};var Ni=require("three");var Il=require("three"),tS=1e4;function cd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}var Cy=class{constructor(t=1){this.subdivisions=t}modify(t){let e=bk(t),r=this.subdivisions;for(;r-- >0;)e=xk(e);return Sk(e,t)}};function bk(i){let t=i.getAttribute("position");if(t===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let e=i.getAttribute("uv"),r=i.getIndex(),n=t.count,o=new Map,a=new Uint32Array(n),s=[],l=0;for(let m=0;m<n;m++){let y=t.getX(m),g=t.getY(m),v=t.getZ(m),b=Math.round(y*tS),S=Math.round(g*tS),x=Math.round(v*tS),A=o.get(b);A===void 0&&(A=new Map,o.set(b,A));let w=A.get(S);w===void 0&&(w=new Map,A.set(S,w));let E=w.get(x);E===void 0&&(E=l++,w.set(x,E),s.push(y,g,v)),a[m]=E}let c=[],d=[],u=e===void 0?null:[],p=r!==null?r.count:n,h=(m,y)=>{let g=r!==null?r.getX(m):m,v=r!==null?r.getX(m+1):m+1,b=r!==null?r.getX(m+2):m+2;if(!(g<n&&v<n&&b<n))return;let S=a[g],x=a[v],A=a[b];S===x||x===A||A===S||(c.push(S,x,A),d.push(y),u!==null&&u.push(e.getX(g),e.getY(g),e.getX(v),e.getY(v),e.getX(b),e.getY(b)))},f=i.groups;if(f.length>0)for(let m=0;m<f.length;m++){let y=f[m],g=y.materialIndex===void 0?0:y.materialIndex,v=Math.max(y.start,0),b=Math.min(y.start+y.count,p);for(let S=v;S<b&&S+2<p;S+=3)h(S,g)}else for(let m=0;m+2<p;m+=3)h(m,0);return{positions:Float64Array.from(s),faces:Uint32Array.from(c),materialIndices:d,uvs:u===null?null:Float64Array.from(u)}}function xk(i){let{positions:t,faces:e,materialIndices:r,uvs:n}=i,o=t.length/3,a=e.length/3,s=n!==null&&a>0,l=a*3,c=new Uint32Array(l),d=new Uint32Array(l),u=new Uint32Array(l),p=new Uint32Array(l),h=new Uint32Array(l),f=0,m=8;for(;m<l*2;)m*=2;let y=m-1,g=new Int32Array(m).fill(-1),v=(C,B)=>{let _=(Math.imul(C,2654435761)^B)&y;for(;;){let F=g[_];if(F===-1)return g[_]=f,c[f]=C,d[f]=B,f++;if(c[F]===C&&d[F]===B)return F;_=_+1&y}},b=(C,B)=>{let _=C<B?C:B,F=C<B?B:C,k=(Math.imul(_,2654435761)^F)&y;for(;;){let q=g[k];if(c[q]===_&&d[q]===F)return q;k=k+1&y}},S=new Uint32Array(o),x=new Float64Array(o*3),A=(C,B,_)=>{let F=C<B?v(C,B):v(B,C),k=++u[F];k===1?p[F]=_:k===2&&(h[F]=_),S[C]++,S[B]++,x[C*3]+=t[B*3],x[C*3+1]+=t[B*3+1],x[C*3+2]+=t[B*3+2],x[B*3]+=t[C*3],x[B*3+1]+=t[C*3+1],x[B*3+2]+=t[C*3+2]};for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2];A(B,_,F),A(_,F,B),A(F,B,_)}let w=new Float64Array(f*3);for(let C=0;C<f;C++){let B=c[C]*3,_=d[C]*3;if(u[C]===2){let q=p[C]*3,W=h[C]*3;w[C*3]=(t[B]+t[_])*.375+(t[q]+t[W])*.125,w[C*3+1]=(t[B+1]+t[_+1])*.375+(t[q+1]+t[W+1])*.125,w[C*3+2]=(t[B+2]+t[_+2])*.375+(t[q+2]+t[W+2])*.125}else w[C*3]=(t[B]+t[_])*.5,w[C*3+1]=(t[B+1]+t[_+1])*.5,w[C*3+2]=(t[B+2]+t[_+2])*.5}let E=new Float64Array(o*3),P;for(let C=0;C<o;C++){let B=S[C];B===3?P=3/16:B>3&&(P=3/(8*B));let _=1-B*Number(P),F=Number(P);B===2&&(_=3/4,F=1/8),E[C*3]=t[C*3]*_+x[C*3]*F,E[C*3+1]=t[C*3+1]*_+x[C*3+1]*F,E[C*3+2]=t[C*3+2]*_+x[C*3+2]*F}let M=new Float64Array((o+f)*3);M.set(E),M.set(w,o*3);let D=new Uint32Array(a*12),R=new Array(a*4),L=s?new Float64Array(a*24):null;for(let C=0;C<a;C++){let B=e[C*3],_=e[C*3+1],F=e[C*3+2],k=b(B,_)+o,q=b(_,F)+o,W=b(F,B)+o,G=C*12;D[G++]=k,D[G++]=q,D[G++]=W,D[G++]=B,D[G++]=k,D[G++]=W,D[G++]=_,D[G++]=q,D[G++]=k,D[G++]=F,D[G++]=W,D[G++]=q;let X=r[C];if(R[C*4]=X,R[C*4+1]=X,R[C*4+2]=X,R[C*4+3]=X,L!==null){let z=C*6,Q=n[z],K=n[z+1],ee=n[z+2],ve=n[z+3],le=n[z+4],de=n[z+5],ce=cd(Q,ee),me=cd(K,ve),be=cd(ee,le),xe=cd(ve,de),J=cd(Q,le),pe=cd(K,de),ne=C*24;L[ne++]=ce,L[ne++]=me,L[ne++]=be,L[ne++]=xe,L[ne++]=J,L[ne++]=pe,L[ne++]=Q,L[ne++]=K,L[ne++]=ce,L[ne++]=me,L[ne++]=J,L[ne++]=pe,L[ne++]=ee,L[ne++]=ve,L[ne++]=be,L[ne++]=xe,L[ne++]=ce,L[ne++]=me,L[ne++]=le,L[ne++]=de,L[ne++]=J,L[ne++]=pe,L[ne++]=be,L[ne++]=xe}}return{positions:M,faces:D,materialIndices:R,uvs:L}}function Sk(i,t){let{positions:e,faces:r,materialIndices:n,uvs:o}=i,a=e.length/3,s=r.length/3,l=new Float64Array(a*3);for(let f=0;f<s;f++){let m=r[f*3]*3,y=r[f*3+1]*3,g=r[f*3+2]*3,v=e[g]-e[y],b=e[g+1]-e[y+1],S=e[g+2]-e[y+2],x=e[m]-e[y],A=e[m+1]-e[y+1],w=e[m+2]-e[y+2],E=b*w-S*A,P=S*x-v*w,M=v*A-b*x;l[m]+=E,l[m+1]+=P,l[m+2]+=M,l[y]+=E,l[y+1]+=P,l[y+2]+=M,l[g]+=E,l[g+1]+=P,l[g+2]+=M}for(let f=0;f<a;f++){let m=l[f*3],y=l[f*3+1],g=l[f*3+2],v=Math.sqrt(m*m+y*y+g*g)||1;l[f*3]=m/v,l[f*3+1]=y/v,l[f*3+2]=g/v}let c=s*3,d=new Float32Array(c*3),u=new Float32Array(c*3),p=o!==null&&o.length>0?new Float32Array(c*2):null;for(let f=0;f<c;f++){let m=r[f]*3;d[f*3]=e[m],d[f*3+1]=e[m+1],d[f*3+2]=e[m+2],u[f*3]=l[m],u[f*3+1]=l[m+1],u[f*3+2]=l[m+2]}p!==null&&p.set(o.subarray(0,c*2));let h=new Il.BufferGeometry;h.setAttribute("position",new Il.BufferAttribute(d,3)),c>0&&(h.setAttribute("normal",new Il.BufferAttribute(u,3)),h.setAttribute("color",new Il.BufferAttribute(new Float32Array(c*3).fill(1),3))),p!==null&&h.setAttribute("uv",new Il.BufferAttribute(p,2));for(let f=0;f<s;){let m=n[f],y=f;do f++;while(f<s&&n[f]===m);h.addGroup(y*3,(f-y)*3,m)}return t.boundingBox!==null&&(h.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(h.boundingSphere=t.boundingSphere.clone()),h}var zr=new Ni.Vector3,TM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ni.BufferGeometry().copy(new Ni.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(zr),r={width:zr.x,height:zr.y,depth:zr.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,o=i.geometry??new Ni.BufferGeometry().copy(new Ni.BoxGeometry(100,100,100)),a=o.userData.parameters;a===void 0?(o.boundingBox=Ak(o),o.boundingBox.getSize(zr)):zr.set(a.width,a.height,a.depth),(t!==zr.x||e!==zr.y||r!==zr.z)&&o.scale(zr.x===0?1:t/zr.x,zr.y===0?1:e/zr.y,zr.z===0?1:r/zr.z);let s=o.originalGeometry;try{n>0?(s===void 0||a?.subdivisions!==n)&&(s===void 0&&(s=o),o=new Cy(n).modify(s)):(s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals())}catch{s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()}return s!==void 0&&Object.assign(o,{originalGeometry:s}),delete i.geometry,Object.assign(o,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ni.BufferGeometryLoader(e).load(i,n=>{let o=this.normalizeInputs({geometry:n});n.boundingBox.getSize(zr);let a=100/zr.x;Object.assign(o.parameters,{width:100,height:zr.y*a,depth:zr.z*a}),t(this.build(o))})}};function Ak(i){let t=new Ni.Box3,e=i.attributes.position;return e?(t.setFromBufferAttribute(e),t):(t.makeEmpty(),t)}var Ty=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=t*.5,d=e*.5,u=0,p=0,h=2*Math.PI/r;for(let m=0;m<r;m++){let y=h*m,g=u+Math.sin(y)*c,v=p+Math.cos(y)*d;l.addPoint(l.createPoint(g,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=n;l.roundness=n,l.update();let f=Qn.create({shape:l,parameters:{roundness:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(f,{userData:{...i,type:"PolygonGeometry"}})}};var et=require("three"),PM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:o,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new nS(t*.5,e,n,o,a,s,l),d=r/t;return d!==1&&c.scale(1,1,d),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Up(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}var wk=new et.Vector3,Ek=new et.Vector3;function rS(i,t,e,r,n,o){let a=wk.copy(t).sub(i),s=Ek.copy(e).sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===n){let c=a.add(s).normalize();o.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);o.copy(i),o.addScaledVector(a,n/Math.sin(c)),o.addScaledVector(s,r/Math.sin(c))}}function Ck(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var nS=class extends et.BufferGeometry{constructor(t=.5,e=1,r=4,n=1,o=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),s=Math.floor(s);let l=[],c=[],d=[],u=[],p=0,h=e/2,f=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,v=Math.PI-g,b=new et.Vector3(0,-h,0),S=new et.Vector3(0,h,0),x=new et.Vector2(t,-h),A=new et.Vector2(m,-h),w=new et.Vector2(0,S.y).sub(A),E=new et.Vector2(0,S.y).sub(x),P=new et.Vector2(w.y,-w.x).normalize(),M=new et.Vector2(E.y,-E.x).normalize(),R=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-w.angle())/2)-1e-8;a=Math.min(a,R);let L;{let W=new et.Vector3(P.x,P.y,0),G=new et.Vector3(Math.cos(y)*W.x,W.y,Math.sin(y)*W.x);L=W.angleTo(G)}let C=a/Math.tan((Math.PI-w.angle())/2),B=a/Math.tan((Math.PI-L)/2),_=new et.Vector3;if(!o){c.push(b.x,b.y,b.z),d.push(0,-1,0),u.push(0,0);let W=p++,G=[],X=x.clone(),z=C/Math.cos(Math.PI/r);X.x-=z;for(let Q=0;Q<r;Q++){let K=Q/r*Math.PI*2+f,ee=new et.Vector2(Math.sin(K),Math.cos(K));Up(X,ee,_),c.push(_.x,_.y,_.z),d.push(0,-1,0),u.push(0,0),G.push(p++)}for(let Q=0;Q<G.length;Q++)l.push(G[Q],W,G[(Q+1)%G.length])}let F=[];{let W=new et.Vector3,G=new et.Vector3,X=new et.Vector3,z=new et.Vector3,Q=new et.Vector3,K=new et.Vector3;for(let ee=0;ee<r;ee++){let ve=ee/r*Math.PI*2+f,le=(ee+.5)/r*Math.PI*2+f,de=(ee+1)/r*Math.PI*2+f,ce=new et.Vector2(Math.sin(ve),Math.cos(ve)),me=new et.Vector2(Math.sin(le),Math.cos(le)),be=new et.Vector2(Math.sin(de),Math.cos(de));Up(x,ce,G),Up(x,be,X),Up(P,me,W),rS(S,G,X,B,B,z),c.push(z.x,z.y,z.z),rS(G,S,X,B,C,Q),c.push(Q.x,Q.y,Q.z),rS(X,G,S,C,B,K),c.push(K.x,K.y,K.z),d.push(W.x,W.y,W.z),d.push(W.x,W.y,W.z),d.push(W.x,W.y,W.z),u.push(0,0),u.push(0,0),u.push(0,0);let xe=p++,J=p++,pe=p++;if(l.push(xe,J,pe),a>0){{let Te=G.clone().add(X).multiplyScalar(.5),ae=S.clone().sub(Te).normalize(),I=b.clone().sub(Te).normalize().add(ae).normalize().multiplyScalar(-1),ie=K.clone().sub(Q);k(Te,ie,I,w.angle())}let ne,Ae;{let Te=new et.Vector3;Up(M,be,Te);let ae=K.clone().add(z).multiplyScalar(.5);ae=Ck(ae,X,S);let ge=K.clone().sub(z);[ne,Ae]=k(ae,ge,Te,L,z.y)}{let Te=ne,ae=Te.clone().setY(0).normalize(),ge=new et.Vector3(0,-1,0),I=ae.clone().cross(ge);q(Te,ae,ge,I)}F.concat(Ae);{let Te=w.angle(),ae=Math.PI-Te,ge=S.clone();ge.y-=a/Math.sin(Te-Math.PI/2);let I=new et.Vector3,ie=[];for(let De=0;De<s;De++){let Xe=[],Ee=Math.PI/2-ae*De/s,Ue=Math.cos(Ee),qe=Math.sin(Ee),$e=le;for(let Ft=0;Ft<=De;Ft++){let Ie=Math.cos($e),Et=Math.sin($e);W.x=Ue*Et,W.y=qe,W.z=Ue*Ie,I.copy(ge).addScaledVector(W,a),c.push(I.x,I.y,I.z),d.push(W.x,W.y,W.z),u.push(0,0),Xe.push(p++),$e+=Math.PI*2/De/r}ie.push(Xe)}Ae.reverse(),ie.push(Ae);let Ke=ie.length-1;for(let De=0;De<Ke;De++){let Xe=ie[De],Ee=ie[De+1],Ue=Xe.length-1;l.push(Ee[1],Xe[0],Ee[0]);for(let qe=1;qe<=Ue;qe++)l.push(Xe[qe],Xe[qe-1],Ee[qe]),l.push(Ee[qe+1],Xe[qe],Ee[qe])}}}}}this.setIndex(l),this.setAttribute("position",new et.Float32BufferAttribute(c,3)),this.setAttribute("normal",new et.Float32BufferAttribute(d,3)),this.setAttribute("uv",new et.Float32BufferAttribute(u,2));function k(W,G,X,z,Q){let K=-z/2,ee=(Math.PI-z)/2,ve=G.clone().normalize().cross(X);W.addScaledVector(X,-a/Math.sin(ee));let le=new et.Vector3,de=new et.Vector3,ce=1,me=p,be=[];for(let xe=0;xe<=s;xe++){let J=K+xe/s*z;de.set(0,0,0),de.addScaledVector(ve,Math.sin(J)),de.addScaledVector(X,Math.cos(J));for(let pe=0;pe<=ce;pe++){let ne=pe/ce-.5;if(le.copy(W),le.addScaledVector(G,ne),le.addScaledVector(de,a),Q!=null){let Ae=Math.max(0,le.y-Q);le.addScaledVector(G,-Ae/G.y)}c.push(le.x,le.y,le.z),d.push(de.x,de.y,de.z),u.push(0,0),pe===0&&be.push(p),p++}}for(let xe=0;xe<s;xe++)for(let J=0;J<ce;J++){let pe=me+J+(ce+1)*xe,ne=pe+(ce+1),Ae=ne+1,Te=pe+1;l.push(pe,ne,Te),l.push(ne,Ae,Te)}return[W.clone().addScaledVector(G,.5),be]}function q(W,G,X,z){let Q=Math.PI/2,K=E.angle()-Q,ee=[],ve=new et.Vector3,le=new et.Vector3;for(let ce=0;ce<=s;ce++){let me=[],be=ce/s;for(let xe=0;xe<=ce;xe++){let pe=((ce?xe/ce:0)-.5)*v,ne=Math.cos(pe),Ae=Math.sin(pe),Te=Math.atan(Math.tan(K)*ne),ae=(Q+Te)*be,ge=Math.cos(ae),I=Math.sin(ae);ve.set(0,0,0),ve.addScaledVector(G,I*ne),ve.addScaledVector(X,ge),ve.addScaledVector(z,I*Ae),le.copy(W).addScaledVector(ve,a),c.push(le.x,le.y,le.z),d.push(ve.x,ve.y,ve.z),u.push(0,0),me.push(p++)}ee.push(me)}let de=ee.length-1;for(let ce=0;ce<de;ce++){let me=ee[ce],be=ee[ce+1],xe=me.length-1;l.push(me[0],be[1],be[0]);for(let J=1;J<=xe;J++)l.push(me[J-1],me[J],be[J]),l.push(me[J],be[J+1],be[J])}}}};var dd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},d={x:-c.x,y:-c.y},u={x:c.x,y:c.y};function p(S,x,A){return x>e&&A>r?Math.min(S*e/x,S*r/A):x>e?S*e/x:A>r?S*r/A:S}let h=[];h[0]=n[0]===0?0:p(n[0],n[0]+n[3],n[0]+n[1]),h[1]=n[1]===0?0:p(n[1],n[1]+n[2],n[1]+n[0]),h[2]=n[2]===0?0:p(n[2],n[2]+n[1],n[2]+n[3]),h[3]=n[3]===0?0:p(n[3],n[3]+n[0],n[3]+n[2]);let f=d.x,m=u.x,y=u.y,g=d.y;t.addPoint(t.createPoint(f,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(f,g)),t.isClosed=!0;let v=!0;for(let S=0,x=t.points.length;S<x;S++)t.points[S].roundness=h[S],S>0&&h[S]!==h[S-1]&&(v=!1);v&&(t.roundness=h[0]),t.useCubicForRoundedCorners=o!==1,t.update();let b=Qn.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...i,type:"RectangleGeometry"}})}};var Ra=require("three"),MM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Ra.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:o=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,d;return c===0?(d=new Ra.BufferGeometry,d.setAttribute("position",new Ra.Float32BufferAttribute([],3))):d=new Ra.SphereGeometry(.5*t,n,o,a,s,l,c*Ra.MathUtils.DEG2RAD),d.scale(1,e/t,r/t),Object.assign(d,{userData:{...i,type:"SphereGeometry"}})}};var OM=require("three"),DM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,o=new OM.PlaneGeometry(t,e,r,n);return o.scale(1,1,1),Object.assign(o,{userData:{...i,type:"PlaneGeometry"}})}};var As=require("three"),IM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:o,cornerSegments:a}=i.parameters,s=new iS(t,e,r,n,o,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},iS=class extends As.BufferGeometry{constructor(t=1,e=1,r=1,n=90,o=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],d=.001;o==0&&(a=1),a=Math.max(1,Math.floor(a)),o=Math.min(o,100),n=Math.min(180-d,n),n*=Math.PI/180;let u=[],p=Math.PI/2,h=(le=0,de=0,ce=0)=>new As.Vector3(le,de,ce),f=h(),m=h(),[y,g,v]=[e/2,t/2,r/2],b=-g,S=+g,[x,A,w]=[h(b,-y,+v),h(b,-y,-v),h(b,+y,-v)],E=(le,de=!1)=>Math.sin(le-Math.PI/(1+ +de)),P=(le,de=!1)=>Math.cos(le-Math.PI/(1+ +de));w.y=Math.sin(n)*e-y;let M=Math.cos(n)*e-v,D=x.z-d;n<=p?(w.z=Math.min(M,D),w.z==D&&(w.y-=(M-D)/Math.tan(p-n))):A.z=Math.min(A.z-M-v,x.z-d),f.subVectors(x,A),m.subVectors(w,A);let R=Math.min(f.length(),m.length())*o/100,L=R*Math.tan(n/2),C=R/Math.cos(n/2),B=f.clone().normalize().add(m.normalize()).setLength(C).add(A);f.set(0,E(n,!0),P(n,!0)),u.push([w,f.clone()]);let _=(Math.PI-n)/a;for(let le=0;le<=a;le++){let de=p+n+le*_;f.set(0,Math.sin(de)*L,Math.cos(de)*L),f.add(B),m.set(0,E(de),P(de)),u.push([f.clone(),m.clone()])}u.push([x,h(0,1,0)]);let F=Math.sin(_/2)*L*2,k=u.length-1,q=u[0][0].distanceTo(u[1][0]),W=u[k-1][0].distanceTo(u[k][0]),G=q+F*a+W;u[0].push(1);for(let le=0;le<=a;le++)u[le+1].push(1-(q+le*F)/G);u[k].push(0);let[X,z,Q]=u[0],K,ee,ve;for(let le=1;le<u.length;le++)[K,ee,ve]=u[le],s.push(b,X.y,X.z,b,K.y,K.z,S,X.y,X.z,S,X.y,X.z,b,K.y,K.z,S,K.y,K.z),l.push(0,z.y,z.z,0,ee.y,ee.z,0,z.y,z.z,0,z.y,z.z,0,ee.y,ee.z,0,ee.y,ee.z),c.push(0,Q,0,ve,1,Q,1,Q,0,ve,1,ve),[X,z,Q]=[K,ee,ve];this.setAttribute("position",new As.Float32BufferAttribute(s,3)),this.setAttribute("normal",new As.Float32BufferAttribute(l,3)),this.setAttribute("uv",new As.Float32BufferAttribute(c,2))}};var Py=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:o,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,d=i.shape,u=t*.5,p=e*.5,h=0,f=0,m=a*Math.PI/360/n,y=Math.PI/2*3*-1,g=u*r/100,v=p*r/100;if(n===3&&r===50){m=2*Math.PI/n;for(let S=0;S<n;S++){let x=m*S,A=h+Math.sin(x)*u,w=f+Math.cos(x)*p;d.addPoint(d.createPoint(A,w))}}else for(let S=0;S<n;S++){let x=h+Math.cos(y)*u,A=f+Math.sin(y)*p;d.addPoint(d.createPoint(x,A)),y+=m,x=h+Math.cos(y)*g,A=f+Math.sin(y)*v,d.addPoint(d.createPoint(x,A)),y+=m}d.isClosed=!0;for(let S=0,x=d.points.length;S<x;S++)d.points[S].roundness=o;d.roundness=o,d.update();let b=Qn.create({shape:d,parameters:{roundness:o,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...i,type:"StarGeometry"}})}};var RM=require("three"),BM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new RM.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var ud=require("three");var NM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width);e.shapeBlendNode&&(n=r);let o=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:o})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:o,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=Tk(t,e,r,t*.5,a,o,0,0,n,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function Tk(i,t,e,r,n,o,a,s,l,c,d){[t,e]=[e,t],a=t/2;let u=ud.MathUtils.clamp(n/360,0,1);if(u===0){let p=new ud.BufferGeometry;return p.setAttribute("position",new ud.Float32BufferAttribute([],3)),p}return u===1&&(c=0),new Mp(!0,i,t,e,r,u,o,a,s,l,c,d)}var LM=require("three"),_M=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:o,q:a}=i.parameters,s=t*.5;s!==e&&(s-=e);let l=new LM.TorusKnotGeometry(s,e,r,n,o,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var FM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.shape,c=t*.5,d=e*.5;s?(l.addPoint(l.createPoint(-c,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(c,-d)),l.addPoint(l.createPoint(-c,-d))),l.isClosed=!0;for(let p=0,h=l.points.length;p<h;p++)l.points[p].roundness=r;l.roundness=r,l.update();let u=Qn.create({shape:l,parameters:{roundness:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(u,{userData:{...i,type:"TriangleGeometry"}})}};fr();var Rl=require("three"),kM=require("three/examples/jsm/utils/BufferGeometryUtils.js");function VM(){let i=new Rl.BufferGeometry;return i.setAttribute("position",new Rl.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Rl.BufferAttribute(new Uint16Array([]),1)),i}var Mk=VM().attributes,Ok=12,Dk=1,pd=class extends Rl.BufferGeometry{constructor(e,r){super();this.isTextGeometry=!0;this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this._nearSide=new Uint8Array(0);this._depth=0;this._effectiveBevel=0;this._vScale=0;Object.assign(this.attributes,Mk),this.userData={parameters:e,type:"TextGeometry"};let n=r.getFont(e.font);n?.isLoaded?(this.font=n,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.loadingPromise)}update(e,r){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:d,textTransform:u,fontSize:p}=e,h=Pr.getDisplayedValue(d),f=u===2?h.toUpperCase():u===3?h.toLowerCase():h,m=Ik(e,n,f,r),{shapes:y,charWidths:g,charCoords:v}=n.generateShapes(m,e,r),b=(typeof o=="number"?o:Number(r.getVariable(o)))*.5,S=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,x=y.map(E=>new ht().fromShape(E,!0));this.vectorShapes=x;let A=x.map(E=>Qn.create({shape:E,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,uvPitch:p,windingRule:s<=0?Ct.NONZERO:Ct.ODD,subdivisions:this.isLowResolution&&s>0?Dk:Ok}})),w=A.length?(0,kM.mergeGeometries)(A):VM();w.translate(-b,S,0),this.dispose(),this.wrappedText=m,this.charCoords=v,this.charWidths=g,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([E,P])=>{this.setAttribute(E,P)}),this.setIndex(w.index),this.adoptNearSide(A,s),this.computeBoundingSphere()}adoptNearSide(e,r){this._depth=r;let n=0,o=0,a=0;for(let c of e){let d=c,u=d._nearSide;if(u===void 0||u.length===0){this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0;return}n+=u.length,o=Math.max(o,d._effectiveBevel??0),a=d._vScale??a}this._effectiveBevel=o,this._vScale=a;let s=new Uint8Array(n),l=0;for(let c of e){let d=c._nearSide;s.set(d,l),l+=d.length}this._nearSide=s}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale,this._effectiveBevel=r._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length!==this.getAttribute("position")?.count?!1:Dl(this._effectiveBevel,e)&&Dl(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position"),o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===2&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}clone(){let e=Er(new Rl.BufferGeometry,pd.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function Ik(i,t,e,r){let n=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,o=[""],a="";for(let s of e)a+=s,s===" "||s===`
727
727
  `?(o[o.length-1]+=a,a="",s===`
728
- `&&o.push("")):t.getTextWidth(o[o.length-1]+a,i)>n&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,i)>n&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}var Tt=require("three");var UM,Oy=new Promise(i=>{UM=i}),GM=!1;var My;function zM(i){if(GM)return;if(My)return My;async function t(){let r=i??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.63/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});UM(c),GM=!0}return My=t(),My}var jM=require("three"),Rk=new jM.Matrix4;function Dy(i,t){if(Object.keys(i.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(i.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let l of r){let c=i.attributes[l],d=t.attributes[l];if(c===void 0||c.isInterleavedBufferAttribute===!0||d.isInterleavedBufferAttribute===!0||c.itemSize!==d.itemSize||c.normalized!==d.normalized||c.array.constructor!==d.array.constructor||c.array.length!==d.array.length)return!1}let n=i.index,o=t.index;if(n===null!=(o===null))return!1;let a=!1;if(n!==null&&o!==null){if(n.array.length!==o.array.length)return!1;let l=n.array.constructor,c=o.array.constructor;if(l!==c){if(l!==Uint32Array||c!==Uint16Array)return!1;a=!0}}if(i.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let c=i.groups[l],d=t.groups[l];if(c.start!==d.start||c.count!==d.count||c.materialIndex!==d.materialIndex)return!1}for(let l of r){let c=i.attributes[l],d=t.attributes[l];c.array.set(d.array),c.needsUpdate=!0}let s=i.takeDepthStateFrom;if(typeof s=="function"&&s.call(i,t),n!==null&&o!==null){if(a){let l=n.array,c=o.array;for(let d=0,u=c.length;d<u;d++){let p=c[d];l[d]=p===65535?4294967295:p}}else n.array.set(o.array);n.needsUpdate=!0}return i.drawRange.start=t.drawRange.start,i.drawRange.count=t.drawRange.count,i.userData=t.userData,i.boundingBox=null,i.boundingSphere=null,!0}function zp(i,t,e,r){let n=i.position.array,o=i.normal.array,a=Rk.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=n.length;d<u;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Iy=new Tt.Box3,hd=new Tt.Vector3,we;Oy.then(i=>{we=i});var HM=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),WM=new Uint32Array([0,1,2,3]),qM=new Uint8Array([4]);function cS(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&String(t)===i?t:-1}function Bk(i){let t=Object.keys(i),e=0;for(let n of t){let o=cS(n);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let n=0;n<e;n++){let o=i[n];if(typeof o!="number")return;r[n]=o}return r}function Ry(i){if(i!=null){if(Array.isArray(i)||ArrayBuffer.isView(i)&&!(i instanceof DataView))return i;if(typeof i=="object")return Bk(i)}}function oS(i){if(i==null)return"missing";if(Array.isArray(i))return`Array(${i.length})`;if(ArrayBuffer.isView(i)){let l=i;return`${i.constructor.name}(${l.length})`}if(typeof i!="object")return typeof i;let t=Object.keys(i),e=t.filter(l=>cS(l)===-1),r=0;for(let l of t){let c=cS(l);c>=r&&(r=c+1)}let n=i,o=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof n[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var Bt=class extends Tt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=Ei.div(r.map(l=>typeof l=="number"?l:0),n);if(o.every(l=>l===1))return;this.subdividedGeometry&&zp(this.subdividedGeometry.attributes,...o),this.originalGeometry&&zp(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(hd.fromArray(o));let s=hd.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let n=null;if(e.subdivisions>0){let a=0;try{a=Bt.allocate(e),n=Bt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&Bt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Tt.BoxGeometry(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Iy.setFromBufferAttribute(r),Iy.getCenter(n),e.boundingSphere.radius=n.distanceTo(Iy.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Iy.getSize(hd);let o={width:hd.x,height:hd.y,depth:hd.z};return this.userData.parameters=o,o}static build(e,r,n,o){let a,s,l=e?.phongAngle??35;n===!1&&(l=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=Bt.allocate(e,o)}catch(d){console.error(d,e),a=Bt.allocate({positionWASM:HM,indexWASM:WM,verticesPerFaceWASM:qM},o)}we.set_destination_refinement_level(a,0);let c=Bt.buildLevel(a,!0,l);return e.subdivisions>0?s=Bt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,n){try{return we.set_destination_refinement_level(e,r),Bt.buildLevel(e,!1,n)??null}catch{try{return we.set_destination_refinement_level(e,r-1),Bt.buildLevel(e,!1,n)??null}catch{return null}}}static primitiveToQuads(e,r,n){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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Li(e,n,!1,r),a;Wm(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=jp(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=Nk(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let n,o,a,s=[],l=[],c=Ry(e.positionWASM),d=Ry(e.indexWASM),u=Ry(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${oS(e.positionWASM)}, indexWASM ${oS(e.indexWASM)}, verticesPerFaceWASM ${oS(e.verticesPerFaceWASM)}`);n=c,o=d,a=u;let P=Ry(e.uvWASM);we.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else n=HM,o=WM,a=qM;let p=n.length,h=o.length,f=a.length,m=n.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,v=m*Float32Array.BYTES_PER_ELEMENT,b=we._malloc(g);if(!b)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(we.HEAPF32.buffer,b,m),x=new Uint32Array(we.HEAPU32.buffer,b+v,y);S.set(n,0),S.set(s,n.length),S.set(l,n.length+s.length),x.set(o,0),x.set(a,o.length);let A;e?.scaleBaked?.some(P=>P!==1)&&(A=new Tt.Matrix4().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(A?A.premultiply(r):A=r);let w=b+(n.length+s.length)*Float32Array.BYTES_PER_ELEMENT,E=l.length?A?we.alloc_subdivision_surface_uvs2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w,l.length,A.elements):we.alloc_subdivision_surface_uvs(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w,l.length):A?we.alloc_subdivision_surface2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A.elements):we.alloc_subdivision_surface(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return we._free(b),E}static buildLevel(e,r,n,o,a,s=!1){let l=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,n,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,n),c=10,d=we.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=we.HEAPU32[d[p]>>2],f=we.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=we.HEAPU32[d[p]>>2],y=we.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=we.HEAPU32[d[p]>>2],v=we.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=we.HEAPU32[d[p]>>2],S=we.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(we.alloc_subdivision_surface_uvs){let w=d[9];if(w>0){let E=we.HEAPU32[d[8]>>2];x=we.HEAPF32.subarray(E>>2,(E>>2)+w)}}if(o===void 0){let w=new Tt.BufferGeometry;if(w.setIndex(new Tt.Uint32BufferAttribute(S,1)),w.setAttribute("position",new Tt.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Tt.Float32BufferAttribute(y,3)),x&&w.setAttribute("uv",new Tt.Float32BufferAttribute(x,2)),r){w.setAttribute("faceMap",new Tt.Uint32BufferAttribute(v,1));let E=new Float32Array(y.length/3*4).fill(0);w.setAttribute("color",new Tt.BufferAttribute(E,4))}return we.free_mesh_data(l),w.userData.type="SubdivGeometry",w}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let w=o.getIndex();w!==null&&w.array.length===S.length&&(w.copyArray(S),w.needsUpdate=!0)}let A=o.getAttribute("uv");x&&A&&A.array.length===x.length&&(A.copyArray(x),A.needsUpdate=!0),we.free_mesh_data(l)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let o=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=we.HEAPU32[s[c]>>2],u=we.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],h=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Tt.BufferGeometry;f.setAttribute("position",new Tt.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=n.r,m[y++]=n.g,m[y++]=n.b;return f.setAttribute("color",new Tt.BufferAttribute(m,3)),f.setIndex(new Tt.Uint32BufferAttribute(h,1)),we.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,n){let o=r===0;o||we.set_destination_refinement_level(e,r);let a=n?we.get_topological_data2(e,o?we.Level.CONTROL:we.Level.REFINED,n.elements):we.get_topological_data(e,o?we.Level.CONTROL:we.Level.REFINED),s=8,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=we.HEAPU32[l[d]>>2],p=new Float32Array(we.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=we.HEAPU32[l[d]>>2],f=new Uint32Array(we.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=we.HEAPU32[l[d]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(we.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=we.HEAPU32[l[6]>>2];g=new Float32Array(we.HEAPF32.subarray(b>>2,(b>>2)+v))}}return we.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function Ny(i){let t=Object.keys(i);return t.length===1&&t[0]==="subdivisions"}function jp(i,t){let e=t?t.count:i.count,r=0,n=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=i.getX(u),h=i.getY(u),f=i.getZ(u),m=Math.round(p*n),y=Math.round(h*n),g=Math.round(f*n),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var By=new Tt.Vector3,aS=new Tt.Vector3,sS=new Tt.Vector3,lS=new Tt.Vector3;function Nk(i,t,e,r,n){let o=[],a=[],s=n?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=n[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);i.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)i.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)i.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((i[t[u]*3+2]===d||i[t[u]*3+2]===0)&&p++,(i[t[u+1]*3+2]===d||i[t[u+1]*3+2]===0)&&p++,(i[t[u+2]*3+2]===d||i[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){By.set(i[t[u]*3],i[t[u]*3+1],i[t[u]*3+2]),aS.set(i[t[u+1]*3],i[t[u+1]*3+1],i[t[u+1]*3+2]),sS.set(i[t[u+4]*3],i[t[u+4]*3+1],i[t[u+4]*3+2]),lS.set(i[t[u+5]*3],i[t[u+5]*3+1],i[t[u+5]*3+2]),aS.sub(By).normalize(),sS.sub(By).normalize(),lS.sub(By).normalize();let p=aS.cross(sS).dot(lS),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<i.length;m+=3,y++)i[m+2]===0&&(p.push(y),f++),i[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var Lk={ConeGeometry:UP,CubeGeometry:zP,CylinderGeometry:fy,DodecahedronGeometry:HP,EllipseGeometry:ld,HelixGeometry:WT,IcosahedronGeometry:EM,LatheGeometry:CM,NonParametricGeometry:TM,PolygonGeometry:Ty,PyramidGeometry:PM,RectangleGeometry:dd,SphereGeometry:MM,PlaneGeometry:DM,BackdropGeometry:IM,StarGeometry:Py,TextFrameGeometry:BM,TorusGeometry:NM,TorusKnotGeometry:_M,TriangleGeometry:FM,VectorGeometry:Qn},Ly=i=>{let t=Lk[i.type]??km(i.type);if(t===void 0)throw new Error(`No geometry factory registered for "${i.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(i)};var _k=["font"];function Li(i,t,e,r){let n,o,a;i.type==="PathGeometry"?(o={...i,extrusion:{...i.extrusion}},a=[[],["extrusion"]]):(o={...i},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(n in d){let u=d[n];Ix(u)&&!_k.includes(n)&&(d[n]=t.getVariable(u,[r.uuid,"geometry",...c,n]),Ix(d[n])&&(d[n]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry"){s.path=o.path;let c=r.profileShape;c!==void 0&&(s.shapeData=c),s.ownerId=r.uuid}else if(o.type==="VectorGeometry"){let c=ht.createFromState(o.shape,o.width,o.height);s.shape=c,s.ownerId=r.uuid}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new XM.BufferGeometryLoader().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new Bt(o,e);return c.data=i,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=km(o.type);if(c)return c.create(o,t);gr("text",`a ${o.type}`);let d=ht.createFromState(pl.defaultData(),100,100);return Ly({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return dd.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=Ly(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=ht.createFromState(pl.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=Ly(s)}return l}var dS=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Hp=class extends dS{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let o=Li(e,r,this.flatShading,n);return o.computeBoundingSphere(),o}};var hS="webgl",YM,uS,QM=!1;function fS(){return hS}function ZM(i){uS=i}function JM(){if(hS==="webgpu"){if(YM!==void 0)return YM;QM||(QM=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(uS===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return uS}function _y(i,t){return JM().createRootMaterial(i,t)}function mS(i,t,e){return JM().createSharedMaterial(i,t,e)}function yS(i){return i.getLayersOfType===void 0&&Object.assign(i,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),i}var KM,$M;function e2(i){$M=i}function t2(){let i=hS==="webgpu"&&KM!==void 0?KM:$M;return i===void 0?null:yS(i())}var pS;function r2(i){pS=i}function n2(i,t){return pS===void 0?!1:pS(i,t)}var i2={markNeedsUpdateRendererDirty:()=>{}};function zo(i,t){let e=0;if(!i.layers||i.layers.length===0)return!1;let r=i.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,o=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?o/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let o=n.data.visible?n.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,s=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var _i=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,ue=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e);function gS(i){let t=typeof i=="string"?i:i.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function po(i){return typeof i=="string"||typeof i=="number"&&i!==0}var fd={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},o2={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};var a2=require("three");var vS=class extends Hc(a2.Object3D){},Fk=i=>i.type==="Mesh",Dr=class extends vS{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new Dr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix,n.pivotMatrix=r.pivotMatrix),n.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 Fk(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};gt();var pi=require("three");var s2=null,l2=null;function c2(i){s2=i}function bS(){return s2}function d2(i){l2=i}function u2(){return l2}function Fy(i){return"variable_"+i}var p2=new pi.Matrix4,h2=new pi.Vector3,f2=new pi.Quaternion,Gk=new pi.Vector3,m2=new pi.Euler,xS=class extends py{constructor(e){super();this.shared=e}create(e){return new ed(e,this.shared)}},y2=new Set;function Uk(i,t){let e=`${i}/${t}`;y2.has(e)||(y2.add(e),console.warn(`[spline] updateObject: ignoring a geometry update of ${i} vertices for a mesh that holds ${t}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}var SS=class{constructor(t,e={},r=!0,n=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=n;this.geometryCache=new Hp(!0);this.geometryCache2=new Hp(!1);this.imageHolderCache=new xS(this);this.thisContext={scene:i2,shared:this};this.deletedImage=new di(Om.emptyImage,this);this.deletedVideo=new di(Tc.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=mS(lr.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:o}of t.variables)this.addVariableHolder(n,o),e&&this.updateVariableHolder(n,o);for(let[n,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,o);for(let[n,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,o);if(!r){for(let[n,o]of Object.entries(t.images))this.addImage(n,o);for(let[n,o]of Object.entries(t.videos))this.addVideo(n,o)}for(let[n,o]of Object.entries(t.colors))this.addColor(n,o);for(let[n,o]of Object.entries(t.lib.materials))this.addMaterial(n,o.asset);for(let[n,o]of Object.entries(t.materials))this.addMaterial(n,o);for(let[n,o]of Object.entries(t.audios))this.addAudio(n,o);for(let[n,o]of Object.entries(t.particles))this.addParticle(n,o);for(let[n,o]of Object.entries(t.fonts))this.addFont(n,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:lr.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=mS(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:lr.defaultTwoLayerData("phong").layers}),_y(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new di(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new di(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let r=t.material;if(!r)return null;for(let n of Array.isArray(r)?r:[r]){let o=n.root??n;for(let a of o?.data?.layers??[]){let s=a?.data;if(s?.type!=="texture"&&s?.type!=="matcap"||e.layer!==void 0&&a.id!==e.layer&&s.type!==e.layer)continue;let l=s.texture?.image;if(l==null)continue;let c=(typeof l=="string"?this.uiBuffer(l):void 0)??this.image(l);if(!c)continue;let d=c.getTexture(s.texture.wrapping??(s.type==="texture"?1e3:1001),s.texture.minFilter??1008,s.texture.magFilter??1006),u=c.img;return{texture:d,width:u?.width??0,height:u?.height??0,layerId:a.id,layerType:s.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new di(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oa(e.r,e.g,e.b,e.a):this.colors[t]=new Oa(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Gt(0,0,0,0))}else return"a"in t?new Gt(t.r,t.g,t.b,t.a):new Gt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Ia)return e;{let r=new Ia({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Ia&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=VP();if(r===null){gr("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Ia&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(Fy(t));r=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(Fy(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:n,shared:this},u=s.slice(2);n.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=n.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*pi.MathUtils.DEG2RAD:l[s[s.length-1]]=r}if(l=n.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Le.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...n,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let n=e.dataPatched?.geometry;return!n||!this.transientGeometryKeys.has(n)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(n),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>SS.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let A=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(A.length===0||A.length%3!==0)return!1;for(let w=0;w<A.length;w++)if(A[w]>=l)return!1;u={array:A,itemSize:1,type:A.constructor.name,normalized:!1}}else{let A=o.data,w=A?.index;if(w?.array?.length){let E=(A?.attributes?.position?.array?.length??0)/3;if(l!==E)return Uk(l,E),!1;u=w}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let A=0;A<s.length;A+=3){let w=s[A],E=s[A+1],P=s[A+2];w<p&&(p=w),w>m&&(m=w),E<h&&(h=E),E>y&&(y=E),P<f&&(f=P),P>g&&(g=P)}let v=(A,w)=>({array:A,itemSize:w,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...n,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let n=r.cloner;if(n===void 0)return-1;let o=n.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let n=new Dr(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let o=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),r.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let n=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!n.includes(u)&&n.push(u)}if(n.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Gt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oa?d.setValue(u,new Gt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of n){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:zo(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=fd[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(A=>A===v)??g.find(A=>a(A)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(A=>typeof A=="number"&&isFinite(A))){let A=["x","y","z"];b.forEach((w,E)=>{d.onVariableUpdate?.(["layer",f.id,S,A[E]],w,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(p2))return p2.decompose(h2,f2,Gk),t[1]==="position"?h2[t[2]]:(m2.setFromQuaternion(f2,r.rotation.order),m2[t[2]]*pi.MathUtils.RAD2DEG);for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=pi.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],o=n.locations?.findIndex(a=>zt.equal(a,e));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ir.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(n):a?.update(n,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(ir.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};n.update(o),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=u2();return r===null?(gr("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=bS();return r===null?(gr("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=bS();return r===null?(gr("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},ws=SS;ws.MAX_TRANSIENT_VERTICES=6e4;var v2=new ws(Bn.emptyData());function Bl(i){return i?.isClassicNodeMaterial===!0}function b2(i){return i?.isClassicSharedMaterial===!0}function ky(i){return Bl(i)||i?.isTSLNodeMaterial===!0}function x2(i){return b2(i)||i?.isTSLSharedMaterial===!0}gt();fr();var Ln=5,md=3;var S2=.98;var br=class extends it{setMaterialOverride(e,r){this.materialOverride=yS(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.syncShadowCatcher(n),Jw(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=n.shared.material(a);l!==s&&br.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(ir.drop(e,1),r.material,n)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(ir.drop(e,2),a,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let n=t2();if(n===null)return;this.shadowCatcherMaterial=n}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){ky(e)&&!x2(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&Pf(this.material).forEach(e=>{br.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};var wn=require("three");var A2=new wn.Vector3,w2=new wn.Vector4,E2=new wn.Vector4,zk=new wn.Vector3,C2=new wn.Matrix4,tt=class extends br{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new wn.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new wn.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof wn.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof wn.BufferGeometry?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ws){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),n=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(n,e,this),this._geometryCacheKey=n}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return hp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return hp.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ir.drop(e,1),r.geometry,n)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){super.dispose(),yM(this.uuid)}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(!(e===void 0||e.sxPrev===void 0))return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Li(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&zp(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else if(!this.absorbDepthInteraction(e)){let o={...this.data.geometry,...e},a=Li(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&Dy(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}absorbDepthInteraction(e){let r=this.localGeometry;if(r?.shiftDepthTo===void 0)return!1;let n=e;if(typeof n.depth!="number")return!1;let o=r.userData?.parameters;if(o===void 0)return!1;for(let a of Object.keys(n))if(a!=="depth"&&n[a]!==o[a])return!1;return r.shiftDepthTo(n.depth)?(o.depth=n.depth,!0):!1}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Bt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&Ny(e.props)&&this.geometryCreateDeleyed instanceof Bt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof wn.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Bt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=n.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Li(d,a,this.data.flatShading,this);Dy(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)}}o||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let n=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof wn.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Bt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(n),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Li(o,n,this.data.flatShading,this);Dy(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(n).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let n=e.morphTargetInfluences;if(n){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of n)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let n=this.morphTargetDictionary[e];n!==void 0&&(this.morphTargetInfluences[n]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):n.centerOffset?e.fromArray(n.centerOffset):e.setScalar(0),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new wn.Vector4,n=this.geometry.attributes.skinWeight;for(let o=0,a=n.count;o<a;o++){r.fromBufferAttribute(n,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),n.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let o=this.geometry;w2.fromBufferAttribute(o.attributes.skinIndex,e),E2.fromBufferAttribute(o.attributes.skinWeight,e),A2.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=E2.getComponent(a);if(s!==0){let l=w2.getComponent(a);C2.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(zk.copy(A2).applyMatrix4(C2),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};var D2=require("three");var Wo=require("three");var T2=require("three"),jo=i=>{var t;return t=class extends i{},t.geometryHelper=new T2.BoxGeometry(30,30,30),t};var En=require("three"),Vy=new En.Ray,wS=new En.Sphere,P2=new En.Matrix4,Ho=(i,t,e,r,n=!1,o=i)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),wS.copy(a.boundingSphere),wS.applyMatrix4(s),e.ray.intersectsSphere(wS)===!1||(P2.copy(s).invert(),Vy.copy(e.ray).applyMatrix4(P2),a.boundingBox!==null&&Vy.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(n===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(i,e,Vy,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new En.Vector3,x=new En.Vector3,A=new En.Vector3,w=new En.Vector3,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),D=M*M,R=Math.max(0,f.start),L=Math.min(b.count,f.start+f.count);for(let C=R,B=L-1;C<B;C+=E){if(S.fromBufferAttribute(b,C),x.fromBufferAttribute(b,C+1),Vy.distanceSqToSegment(S,x,w,A)>D)continue;w.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(w);F<e.near||F>e.far||r.push({distance:F,point:A.clone().applyMatrix4(o.matrixWorld),object:i})}}function g(v,b,S,x,A,w,E){let P=new En.Vector3,M=new En.Vector3,D=new En.Vector3,R=new En.Vector3,L=new En.Vector3;if(P.fromBufferAttribute(x,A),M.fromBufferAttribute(x,w),D.fromBufferAttribute(x,E),S.intersectTriangle(P,M,D,!1,R)===null)return null;L.copy(R),L.applyMatrix4(v.matrixWorld);let B=b.ray.origin.distanceTo(L);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:L.clone(),object:v}}};var jk=new Wo.Vector3(1,1,1),M2=new Wo.Vector3,Hk=new Wo.Vector3,O2=new Wo.Quaternion,Fi=class extends jo(Wo.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new Wo.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Ho(this.object,Fi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(M2,O2,Hk),this.matrix.compose(M2,O2,jk),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var Wp=require("three");var Gy;(t=>t.is=e=>"objectHelper"in e)(Gy||(Gy={}));var ki=(i,t)=>class extends Xc(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,o){this.objectHelper.raycast(n,o)}showGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof Wp.Box3Helper&&(o.visible=!0)}}updateEntityBoxSize(n,o){this.objectHelper.visible&&this.geometryHelper instanceof Wp.BoxGeometry?(n.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,o)}hideGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof Wp.Box3Helper&&(o.visible=!1)}}};var gd=class extends ki(D2.Group,Fi){constructor(e,r,n){super();this.super_Entity(e,r),this.context=n,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var Wk=null;function I2(){return Wk}var Je=require("three"),Qy=mc(B2());var qk=.5*(Math.sqrt(3)-1),qp=(3-Math.sqrt(3))/6,Xk=1/3,qo=1/6,iee=(Math.sqrt(5)-1)/4,oee=(5-Math.sqrt(5))/20,Xp=i=>Math.floor(i)|0,N2=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]),CS=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 L2(i=Math.random){let t=F2(i),e=new Float64Array(t).map(n=>N2[n%12*2]),r=new Float64Array(t).map(n=>N2[n%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*qk,u=Xp(o+d),p=Xp(a+d),h=(u+p)*qp,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+qp,x=g-b+qp,A=y-1+2*qp,w=g-1+2*qp,E=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let L=E+t[P],C=e[L],B=r[L];M*=M,s=M*M*(C*y+B*g)}let D=.5-S*S-x*x;if(D>=0){let L=E+v+t[P+b],C=e[L],B=r[L];D*=D,l=D*D*(C*S+B*x)}let R=.5-A*A-w*w;if(R>=0){let L=E+1+t[P+1],C=e[L],B=r[L];R*=R,c=R*R*(C*A+B*w)}return 70*(s+l+c)}}function _2(i=Math.random){let t=F2(i),e=new Float64Array(t).map(o=>CS[o%12*3]),r=new Float64Array(t).map(o=>CS[o%12*3+1]),n=new Float64Array(t).map(o=>CS[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*Xk,f=Xp(a+h),m=Xp(s+h),y=Xp(l+h),g=(f+m+y)*qo,v=f-g,b=m-g,S=y-g,x=a-v,A=s-b,w=l-S,E,P,M,D,R,L;x>=A?A>=w?(E=1,P=0,M=0,D=1,R=1,L=0):x>=w?(E=1,P=0,M=0,D=1,R=0,L=1):(E=0,P=0,M=1,D=1,R=0,L=1):A<w?(E=0,P=0,M=1,D=0,R=1,L=1):x<w?(E=0,P=1,M=0,D=0,R=1,L=1):(E=0,P=1,M=0,D=1,R=1,L=0);let C=x-E+qo,B=A-P+qo,_=w-M+qo,F=x-D+2*qo,k=A-R+2*qo,q=w-L+2*qo,W=x-1+3*qo,G=A-1+3*qo,X=w-1+3*qo,z=f&255,Q=m&255,K=y&255,ee=.6-x*x-A*A-w*w;if(ee<0)c=0;else{let ce=z+t[Q+t[K]];ee*=ee,c=ee*ee*(e[ce]*x+r[ce]*A+n[ce]*w)}let ve=.6-C*C-B*B-_*_;if(ve<0)d=0;else{let ce=z+E+t[Q+P+t[K+M]];ve*=ve,d=ve*ve*(e[ce]*C+r[ce]*B+n[ce]*_)}let le=.6-F*F-k*k-q*q;if(le<0)u=0;else{let ce=z+D+t[Q+R+t[K+L]];le*=le,u=le*le*(e[ce]*F+r[ce]*k+n[ce]*q)}let de=.6-W*W-G*G-X*X;if(de<0)p=0;else{let ce=z+1+t[Q+1+t[K+1]];de*=de,p=de*de*(e[ce]*W+r[ce]*G+n[ce]*X)}return 32*(c+d+u+p)}}function F2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),o=e[r];e[r]=e[n],e[n]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var k2=require("three"),ho=new k2.Triangle,Uy=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let o=1;ho.a.fromBufferAttribute(t,n),ho.b.fromBufferAttribute(t,n+1),ho.c.fromBufferAttribute(t,n+2),o*=ho.getArea(),e[n/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,o=-1;for(;r<=n;){let a=Math.ceil((r+n)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?n=a-1:r=a+1}return o}sampleFace(t,e,r){let n=this.randomFunction(),o=this.randomFunction();return n+o>1&&(n=1-n,o=1-o),ho.a.fromBufferAttribute(this.positionAttribute,t*3),ho.b.fromBufferAttribute(this.positionAttribute,t*3+1),ho.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ho.a,n).addScaledVector(ho.b,o).addScaledVector(ho.c,1-(n+o)),ho.getNormal(r),this}};var Ba=require("three");var hi=require("three");function Yk(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new hi.Vector3(n[a],n[a+1],n[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new hi.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(o,3))}function Qk(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new hi.Vector3;for(let o=0;o<e.length;o+=3)n.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=n.x,r[o+1]=n.y,r[o+2]=n.z;i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(r,3))}function Xo(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!Bl(i.material)||i.material.getLayersOfType("outline").length===0)return;i instanceof tt&&i.is2DAndNoDepth?Qk(i):Yk(i)}function TS(i){return Math.min(2047,Math.max(1,Math.round(i*2048)))/2048}function Yo(i){if(!i.geometry.attributes.position)return;let t=i.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let n=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),a=[TS(hi.MathUtils.seededRandom(o)),TS(hi.MathUtils.seededRandom(o+1e4)),TS(hi.MathUtils.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)n[s]=a[s%3];i.geometry.setAttribute("randomColor",new hi.BufferAttribute(n,3))}var Qo=new Ba.Box3,Yp=new Ba.Vector3;function V2(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Na=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new Ba.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:o,subdivPointer:a}=Bt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=Array.isArray(n)?n.map(o=>o.getFlavor(!1,o.side,o.wireframe)):n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,n=!1){r&&this.subdividedGeometry||Bt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,n),this.subdividedGeometry&&Bt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Bt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Bt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,it.prototype.raycast.call(this,e,r),this.localGeometry=n}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ba.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Qo.setFromBufferAttribute(r),Qo.getCenter(n),e.boundingSphere.radius=n.distanceTo(Qo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qo.getSize(Yp),this.hasNonUniformScale&&Yp.divide(this.scale);let o={width:Yp.x,height:Yp.y,depth:Yp.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Qo.min.set(e[0],e[2],e[4]),Qo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Qo.min.applyMatrix4(this.shearScaleInv),Qo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Ba.Sphere);let n=r.boundingSphere.center;Qo.getCenter(n),r.boundingSphere.radius=n.distanceTo(Qo.max)}freeSubdivPointer(){this.subdivPointer&&(Bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,n=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?Bt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),o!==void 0&&(this.localGeometry.userData.parameters=o),n&&(this.localGeometry.uuid=n)}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&(e.type===0&&e.path.length===0&&Ny(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};var Ko=require("three"),G2=-1,Kk=1,U2={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},z2={polygon_center:0,edge:1,vertex:2},Qp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ze=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-G2)*(e-r)/(Kk-G2)+r},Zk=new Ko.Vector3,zy=new Ko.Vector3,Jk=new Ko.Vector3,$k=new Ko.Vector3;function vd(i,t){let e=Jk.fromArray(i),r=$k.fromArray(t);zy.copy(r).sub(e);let n=zy.length();return zy.normalize().multiplyScalar(n*.5),Zk.copy(e).add(zy).toArray()}var Vi=new Ko.Triangle,jy=new Ko.Vector3,Hy=new Ko.Vector3,Nl=new Ko.Vector3;function j2(i){let t=[],e=Math.floor(i.index.count/3);for(let r=0;r<e;r++)if(jy.fromArray(i.index.array,r*3),Vi.setFromAttributeAndIndices(i.attributes.position,jy.x,jy.y,jy.z),Vi.getNormal(Hy),Vi.getMidpoint(Nl),!(isNaN(Nl.x)||isNaN(Nl.y)||isNaN(Nl.z))){let{a:n,b:o,c:a}=Vi,s=n.toArray(),l=o.toArray(),c=a.toArray(),d=n.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(n),h=vd(s,l),f=vd(l,c),m=vd(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Vi.getMidpoint(Nl).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Vi.getNormal(Hy).toArray()})}return t}function H2(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Vi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Vi.getNormal(Hy),Vi.getMidpoint(Nl);let n=Vi.a.toArray(),o=Vi.b.toArray(),a=Vi.c.toArray();t.push({vertices:[n,o,a],faceCenters:[vd(n,o),vd(o,a),vd(a,n)],midpoint:Nl.toArray(),norm:Hy.toArray()})}return t}var bd=require("three"),PS=class extends bd.InstancedMesh{},Wy=class extends PS{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new bd.Matrix4;this.pivotMatrix=new bd.Matrix4;this.previousModelViewMatrix=new bd.Matrix4;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let n=this.parent;if(e&&n!==null&&n.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)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,n,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var MS=i=>.5*(1-Math.cos(i*Math.PI)),OS=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-n,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=n+(o<<4)+(a<<8);d=MS(s),u=MS(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=MS(c)*(m-f),p+=f*h,h*=.5,n<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(n++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},W2=OS;var xd=require("three");var q2=new xd.Vector3,X2=new xd.Matrix4,Y2=new xd.Ray,Es=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(X2.copy(n).invert(),Y2.copy(e.ray).applyMatrix4(X2),Y2.intersectBox(this.singleBBox,q2))){let o=q2.applyMatrix4(n),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var _n=1e-4,Zo,aO,sO,lO,Q2=new Je.Vector3,K2=new Je.Vector3;Oy.then(i=>{Zo=i,aO=[Zo.get_face_center,Zo.get_edge_midpoint,Zo.get_vertex_position],sO=[Zo.get_face_normal,Zo.get_edge_normal,Zo.get_vertex_normal],lO=[Zo.face_count,Zo.edge_count,Zo.vertex_count]});var ute=new Je.Matrix4,eV=new Je.Matrix4,Z2=new Je.Matrix4,J2=new Je.Matrix4,$2=new Je.Matrix4,eO=new Je.Matrix4,tO=new Je.Matrix4,rO=new Je.Matrix4,Cs=new Je.Vector3,qy=new Je.Vector3,Kp=new Je.Vector3,DS=new Je.Vector3,tV=new Je.Vector3,nO=new Je.Vector3,Xy=new Je.Vector3,IS=new Je.Vector3,iO=new Je.Vector3,RS=new Je.Vector3,oO=new Je.Vector3,fo=new Je.Euler,rV=new Je.Quaternion;function Yy(i){return i?i.version??i.data?.version??0:-1}function or(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var BS=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new W2;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(n,o,a)=>this.perlin.noise(n,o,a):this.noise=n=>this.perlin.noise(n)):e?this.noise=_2((0,Qy.default)(t.seed)):this.noise=L2((0,Qy.default)(t.seed??""))}},Fn=class extends Hc(Je.Object3D){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof it&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof Dr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let n=r.transformOverride;n!==void 0&&(r.position.fromArray(n.position),r.rotation.fromArray(n.rotation),r.scale.fromArray(n.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||li(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Wy(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let n of this.children)n.playModeVisible!==!1&&(Z2.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix),e.setMatrixAt(r++,Z2));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let n;if(r!==void 0)n=r;else{let o=or(this.parameters.grid.count,e);n=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)n=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==n)if(this.children.length<n)for(let o=0,a=n-this.children.length;o<a;++o){let s=new Dr(this.object);s.expand(),this.add(s)}else for(;this.children.length>n;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new BS(e,r)),this.random}_updateRadial(e,r){let n=e.radial,o=n.start*Je.MathUtils.DEG2RAD,a=n.end*Je.MathUtils.DEG2RAD,s=o-a,l=or(n.rotation,r),c=new Je.Euler(l[0],l[1],l[2]),d;switch(n.axis){case"z":d=new Je.Vector3(0,0,1);break;case"y":d=new Je.Vector3(0,1,0);break;default:case"x":d=new Je.Vector3(1,0,0);break}let u=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=or(n.scale,r),m=or(n.position,r),y=or(u.scale,r),g=or(u.position,r),v=or(u.rotation,r),b=s/e.count,S=Qp(u.strength,this.parameters.randomness);for(let[x,A]of this.children.entries()){let w=x*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(w,w,w),P=x+1;A.scale.x=f[0]+S(P,ze(E,y[0]))||_n,A.scale.y=f[1]+S(P,ze(E,y[1]))||_n,A.scale.z=f[2]+S(P,ze(E,y[2]))||_n;let M=b*x-o;switch(n.axis){default:case"x":fo.set(0,M,0);break;case"y":fo.set(0,0,M);break;case"z":fo.set(M,0,0);break}Xy.copy(d).applyQuaternion(rV.setFromEuler(fo)).multiplyScalar(n.radius),A.position.set(Xy.x+(m[0]+S(P,ze(E,g[0]))),Xy.y+(m[1]+S(P,ze(E,g[1]))),Xy.z+(m[2]+S(P,ze(E,g[2]))));let D=S(P,ze(E,v[0])),R=S(P,ze(E,v[1])),L=S(P,ze(E,v[2]));n.alignment===!0?A.rotation.set(fo.x+(c.x+D),fo.y+(c.y+R),fo.z+(c.z+L)):A.rotation.set(c.x+D,c.y+R,c.z+L)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let n=e.linear,o=or(n.rotation,r),a=or(n.scale,r),s=or(n.position,r),l=new Je.Euler(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,d=or(c.rotation,r),u=or(c.scale,r),p=or(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Qp(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,ze(b,d[0])),A=m(S,ze(b,d[1])),w=m(S,ze(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,ze(b,u[0]))||_n,g.scale.y=1+(a[1]-1)*y+m(S,ze(b,u[1]))||_n,g.scale.z=1+(a[2]-1)*y+m(S,ze(b,u[2]))||_n,g.rotation.set(l.x*y+x,l.y*y+A,l.z*y+w),g.position.x=s[0]*y+m(S,ze(b,p[0])),g.position.y=s[1]*y+m(S,ze(b,p[1])),g.position.z=s[2]*y+m(S,ze(b,p[2]))}}_updateGrid(e,r){let n=0,o=e.grid,a=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,s=or(a.scale,r),l=or(a.rotation,r),c=or(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Qp(a.strength,this.parameters.randomness),h=or(o.count,r),f=or(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Je.Vector3(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[n++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(n,ze(x,s[0]))||_n,S.scale.y=1+p(n,ze(x,s[1]))||_n,S.scale.z=1+p(n,ze(x,s[2]))||_n;let A=p(n,ze(x,l[0])),w=p(n,ze(x,l[1])),E=p(n,ze(x,l[2]));S.rotation.set(A,w,E),S.position.x=f[0]*g-y.x+p(n,ze(x,c[0])),S.position.y=f[1]*v-y.y+p(n,ze(x,c[1])),S.position.z=f[2]*b-y.z+p(n,ze(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[n++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(n,ze(b,s[0]))||_n,v.scale.y=1+p(n,ze(b,s[1]))||_n,v.scale.z=1+p(n,ze(b,s[2]))||_n;let S=p(n,ze(b,l[0])),x=p(n,ze(b,l[1])),A=p(n,ze(b,l[2]));v.rotation.set(S,x,A),v.position.x=f[0]*m+p(n,ze(b,c[0])),v.position.y=-f[1]*y+p(n,ze(b,c[1])),v.position.z=-f[2]*g+p(n,ze(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:n}=e,o=or(n.rotation,r),a=or(n.position,r),s=or(n.scale,r),l=new Je.Euler(o[0],o[1],o[2]),c=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,d=or(c.rotation,r),u=or(c.position,r),p=or(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Qp(c.strength,this.parameters.randomness);if(!n.object){for(let[,A]of this.children.entries())A.position.set(0,0,0),A.scale.setScalar(1),A.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Es)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let A=Math.round(y.length*n.count/100);this._updateCount(r,A)}else{let A=this.objectForSample.geometry.getAttribute("position");if(!A||isNaN(A.count)||A.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=n.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Qy.default)(this.object.uuid+n.seed)));let b=U2[n.axis],S=this.children;Cs.fromArray(b),J2.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Na;x&&$2.copy(this.objectForSample.matrixWorld).invert(),n.align!=="normal"&&this.object.getWorldDirection(nO),RS.set(Cs.y,Cs.z,Cs.x).normalize(),oO.copy(RS).cross(Cs).normalize(),tO.makeBasis(RS,Cs,oO).invert();for(let[A,w]of S.entries()){let E=A*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(E,E,E),M=A+1,D=m(M,ze(P,d[0])),R=m(M,ze(P,d[1])),L=m(M,ze(P,d[2]));g?v.sample(Kp,DS):(y.length&&(Kp.fromArray(y[A].pos),DS.fromArray(y[A].norm)),x&&Kp.applyMatrix4($2)),Kp.applyMatrix4(J2),w.position.copy(Kp);let C=n.align==="normal"?DS:nO,B=qy.fromArray(a);qy.x+=m(M,ze(P,u[0])),qy.y+=m(M,ze(P,u[1])),qy.z+=m(M,ze(P,u[2]));let _=Math.acos(C.dot(Cs)),F=tV.crossVectors(Cs,C).normalize(),k=eV.makeRotationAxis(F,_);IS.copy(C).cross(this.object.up).normalize(),iO.copy(IS).cross(C).normalize(),eO.makeBasis(IS,C,iO),rO.multiplyMatrices(eO,tO),fo.setFromRotationMatrix(rO),B.applyMatrix4(k),w.position.add(B),w.rotation.set(fo.x+l.x+D,fo.y+l.y+R,fo.z+l.z+L),w.scale.set(1+s[0]+m(M,ze(P,p[0]))||_n,1+s[1]+m(M,ze(P,p[1]))||_n,1+s[2]+m(M,ze(P,p[2]))||_n),w.scale.multiply(this.object.scale),w.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,n=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===n&&a.positionVersion===Yy(n)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new Uy(e).build();return this.surfaceSamplerCache={geometry:r,position:n,positionVersion:Yy(n),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Na,n=this.objectForSample.geometry;if(!r&&n){let l=this.surfacePointsCache,c=n.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===n&&l.position===c&&l.positionVersion===Yy(c)&&l.index===n.index&&l.indexVersion===(n.index===null?-1:n.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=z2[e],d=lO[c],u=aO[c],p=sO[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);Q2.fromArray(m).applyMatrix4(l.matrixWorld),K2.fromArray(y),a(Q2.toArray(),K2.toArray())}}else(n.index?j2(n):H2(n)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&n){let l=n.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:n,position:l,positionVersion:Yy(l),index:n.index,indexVersion:n.index===null?-1:n.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ys(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let n=r.scene.find(this.parameters.toObject.object);n instanceof it?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new Je.Matrix4,this.hiddenMatrix=new Je.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=24,Ir=96,Jo=PP(),La=2;var NS=!1,cO=!0;try{let i=new URLSearchParams(window.location.search);NS=i.get("dbgsbstatic")==="0",cO=i.get("sb512")!=="0"}catch{}function nV(i){let t=i.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var LS=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(Ir);this._prevReach=new Float32Array(Ir);this._fieldDirtyFull=!0;this._fieldDirtyMin=new fe.Vector3;this._fieldDirtyMax=new fe.Vector3;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new fe.Scene;this.potentialPassScene=new fe.Scene;this.voxelPassScene=new fe.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new fe.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new fe.Mesh($c,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new fe.DataTexture(Jo.triTable,16,256,fe.RedFormat,fe.FloatType);o.needsUpdate=!0;let a=new fe.DataTexture(Jo.numTrisTable,256,1,fe.RedFormat,fe.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new fe.Mesh($c,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new fe.Mesh($c,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=lV.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new fe.ShaderMaterial({vertexShader:c.vertexShader,fragmentShader:`
728
+ `&&o.push("")):t.getTextWidth(o[o.length-1]+a,i)>n&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,i)>n&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}var Tt=require("three");var UM,Oy=new Promise(i=>{UM=i}),GM=!1;var My;function zM(i){if(GM)return;if(My)return My;async function t(){let r=i??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.65/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});UM(c),GM=!0}return My=t(),My}var jM=require("three"),Rk=new jM.Matrix4;function Dy(i,t){if(Object.keys(i.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(i.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let l of r){let c=i.attributes[l],d=t.attributes[l];if(c===void 0||c.isInterleavedBufferAttribute===!0||d.isInterleavedBufferAttribute===!0||c.itemSize!==d.itemSize||c.normalized!==d.normalized||c.array.constructor!==d.array.constructor||c.array.length!==d.array.length)return!1}let n=i.index,o=t.index;if(n===null!=(o===null))return!1;let a=!1;if(n!==null&&o!==null){if(n.array.length!==o.array.length)return!1;let l=n.array.constructor,c=o.array.constructor;if(l!==c){if(l!==Uint32Array||c!==Uint16Array)return!1;a=!0}}if(i.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let c=i.groups[l],d=t.groups[l];if(c.start!==d.start||c.count!==d.count||c.materialIndex!==d.materialIndex)return!1}for(let l of r){let c=i.attributes[l],d=t.attributes[l];c.array.set(d.array),c.needsUpdate=!0}let s=i.takeDepthStateFrom;if(typeof s=="function"&&s.call(i,t),n!==null&&o!==null){if(a){let l=n.array,c=o.array;for(let d=0,u=c.length;d<u;d++){let p=c[d];l[d]=p===65535?4294967295:p}}else n.array.set(o.array);n.needsUpdate=!0}return i.drawRange.start=t.drawRange.start,i.drawRange.count=t.drawRange.count,i.userData=t.userData,i.boundingBox=null,i.boundingSphere=null,!0}function zp(i,t,e,r){let n=i.position.array,o=i.normal.array,a=Rk.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=n.length;d<u;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Iy=new Tt.Box3,hd=new Tt.Vector3,we;Oy.then(i=>{we=i});var HM=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),WM=new Uint32Array([0,1,2,3]),qM=new Uint8Array([4]);function cS(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&String(t)===i?t:-1}function Bk(i){let t=Object.keys(i),e=0;for(let n of t){let o=cS(n);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let n=0;n<e;n++){let o=i[n];if(typeof o!="number")return;r[n]=o}return r}function Ry(i){if(i!=null){if(Array.isArray(i)||ArrayBuffer.isView(i)&&!(i instanceof DataView))return i;if(typeof i=="object")return Bk(i)}}function oS(i){if(i==null)return"missing";if(Array.isArray(i))return`Array(${i.length})`;if(ArrayBuffer.isView(i)){let l=i;return`${i.constructor.name}(${l.length})`}if(typeof i!="object")return typeof i;let t=Object.keys(i),e=t.filter(l=>cS(l)===-1),r=0;for(let l of t){let c=cS(l);c>=r&&(r=c+1)}let n=i,o=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof n[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var Bt=class extends Tt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=Ei.div(r.map(l=>typeof l=="number"?l:0),n);if(o.every(l=>l===1))return;this.subdividedGeometry&&zp(this.subdividedGeometry.attributes,...o),this.originalGeometry&&zp(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(hd.fromArray(o));let s=hd.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let n=null;if(e.subdivisions>0){let a=0;try{a=Bt.allocate(e),n=Bt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&Bt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Bt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Tt.BoxGeometry(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Tt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Iy.setFromBufferAttribute(r),Iy.getCenter(n),e.boundingSphere.radius=n.distanceTo(Iy.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Iy.getSize(hd);let o={width:hd.x,height:hd.y,depth:hd.z};return this.userData.parameters=o,o}static build(e,r,n,o){let a,s,l=e?.phongAngle??35;n===!1&&(l=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=Bt.allocate(e,o)}catch(d){console.error(d,e),a=Bt.allocate({positionWASM:HM,indexWASM:WM,verticesPerFaceWASM:qM},o)}we.set_destination_refinement_level(a,0);let c=Bt.buildLevel(a,!0,l);return e.subdivisions>0?s=Bt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,n){try{return we.set_destination_refinement_level(e,r),Bt.buildLevel(e,!1,n)??null}catch{try{return we.set_destination_refinement_level(e,r-1),Bt.buildLevel(e,!1,n)??null}catch{return null}}}static primitiveToQuads(e,r,n){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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Li(e,n,!1,r),a;Wm(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=jp(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=Nk(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let n,o,a,s=[],l=[],c=Ry(e.positionWASM),d=Ry(e.indexWASM),u=Ry(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${oS(e.positionWASM)}, indexWASM ${oS(e.indexWASM)}, verticesPerFaceWASM ${oS(e.verticesPerFaceWASM)}`);n=c,o=d,a=u;let P=Ry(e.uvWASM);we.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else n=HM,o=WM,a=qM;let p=n.length,h=o.length,f=a.length,m=n.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,v=m*Float32Array.BYTES_PER_ELEMENT,b=we._malloc(g);if(!b)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(we.HEAPF32.buffer,b,m),x=new Uint32Array(we.HEAPU32.buffer,b+v,y);S.set(n,0),S.set(s,n.length),S.set(l,n.length+s.length),x.set(o,0),x.set(a,o.length);let A;e?.scaleBaked?.some(P=>P!==1)&&(A=new Tt.Matrix4().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(A?A.premultiply(r):A=r);let w=b+(n.length+s.length)*Float32Array.BYTES_PER_ELEMENT,E=l.length?A?we.alloc_subdivision_surface_uvs2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w,l.length,A.elements):we.alloc_subdivision_surface_uvs(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w,l.length):A?we.alloc_subdivision_surface2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A.elements):we.alloc_subdivision_surface(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return we._free(b),E}static buildLevel(e,r,n,o,a,s=!1){let l=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,n,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,n),c=10,d=we.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=we.HEAPU32[d[p]>>2],f=we.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=we.HEAPU32[d[p]>>2],y=we.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=we.HEAPU32[d[p]>>2],v=we.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=we.HEAPU32[d[p]>>2],S=we.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(we.alloc_subdivision_surface_uvs){let w=d[9];if(w>0){let E=we.HEAPU32[d[8]>>2];x=we.HEAPF32.subarray(E>>2,(E>>2)+w)}}if(o===void 0){let w=new Tt.BufferGeometry;if(w.setIndex(new Tt.Uint32BufferAttribute(S,1)),w.setAttribute("position",new Tt.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Tt.Float32BufferAttribute(y,3)),x&&w.setAttribute("uv",new Tt.Float32BufferAttribute(x,2)),r){w.setAttribute("faceMap",new Tt.Uint32BufferAttribute(v,1));let E=new Float32Array(y.length/3*4).fill(0);w.setAttribute("color",new Tt.BufferAttribute(E,4))}return we.free_mesh_data(l),w.userData.type="SubdivGeometry",w}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let w=o.getIndex();w!==null&&w.array.length===S.length&&(w.copyArray(S),w.needsUpdate=!0)}let A=o.getAttribute("uv");x&&A&&A.array.length===x.length&&(A.copyArray(x),A.needsUpdate=!0),we.free_mesh_data(l)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let o=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=we.HEAPU32[s[c]>>2],u=we.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=we.HEAPU32[s[c]>>2],h=we.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Tt.BufferGeometry;f.setAttribute("position",new Tt.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=n.r,m[y++]=n.g,m[y++]=n.b;return f.setAttribute("color",new Tt.BufferAttribute(m,3)),f.setIndex(new Tt.Uint32BufferAttribute(h,1)),we.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,n){let o=r===0;o||we.set_destination_refinement_level(e,r);let a=n?we.get_topological_data2(e,o?we.Level.CONTROL:we.Level.REFINED,n.elements):we.get_topological_data(e,o?we.Level.CONTROL:we.Level.REFINED),s=8,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=we.HEAPU32[l[d]>>2],p=new Float32Array(we.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=we.HEAPU32[l[d]>>2],f=new Uint32Array(we.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=we.HEAPU32[l[d]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(we.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=we.HEAPU32[l[6]>>2];g=new Float32Array(we.HEAPF32.subarray(b>>2,(b>>2)+v))}}return we.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function Ny(i){let t=Object.keys(i);return t.length===1&&t[0]==="subdivisions"}function jp(i,t){let e=t?t.count:i.count,r=0,n=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=i.getX(u),h=i.getY(u),f=i.getZ(u),m=Math.round(p*n),y=Math.round(h*n),g=Math.round(f*n),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var By=new Tt.Vector3,aS=new Tt.Vector3,sS=new Tt.Vector3,lS=new Tt.Vector3;function Nk(i,t,e,r,n){let o=[],a=[],s=n?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=n[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);i.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)i.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)i.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((i[t[u]*3+2]===d||i[t[u]*3+2]===0)&&p++,(i[t[u+1]*3+2]===d||i[t[u+1]*3+2]===0)&&p++,(i[t[u+2]*3+2]===d||i[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){By.set(i[t[u]*3],i[t[u]*3+1],i[t[u]*3+2]),aS.set(i[t[u+1]*3],i[t[u+1]*3+1],i[t[u+1]*3+2]),sS.set(i[t[u+4]*3],i[t[u+4]*3+1],i[t[u+4]*3+2]),lS.set(i[t[u+5]*3],i[t[u+5]*3+1],i[t[u+5]*3+2]),aS.sub(By).normalize(),sS.sub(By).normalize(),lS.sub(By).normalize();let p=aS.cross(sS).dot(lS),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<i.length;m+=3,y++)i[m+2]===0&&(p.push(y),f++),i[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var Lk={ConeGeometry:UP,CubeGeometry:zP,CylinderGeometry:fy,DodecahedronGeometry:HP,EllipseGeometry:ld,HelixGeometry:WT,IcosahedronGeometry:EM,LatheGeometry:CM,NonParametricGeometry:TM,PolygonGeometry:Ty,PyramidGeometry:PM,RectangleGeometry:dd,SphereGeometry:MM,PlaneGeometry:DM,BackdropGeometry:IM,StarGeometry:Py,TextFrameGeometry:BM,TorusGeometry:NM,TorusKnotGeometry:_M,TriangleGeometry:FM,VectorGeometry:Qn},Ly=i=>{let t=Lk[i.type]??km(i.type);if(t===void 0)throw new Error(`No geometry factory registered for "${i.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(i)};var _k=["font"];function Li(i,t,e,r){let n,o,a;i.type==="PathGeometry"?(o={...i,extrusion:{...i.extrusion}},a=[[],["extrusion"]]):(o={...i},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(n in d){let u=d[n];Ix(u)&&!_k.includes(n)&&(d[n]=t.getVariable(u,[r.uuid,"geometry",...c,n]),Ix(d[n])&&(d[n]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry"){s.path=o.path;let c=r.profileShape;c!==void 0&&(s.shapeData=c),s.ownerId=r.uuid}else if(o.type==="VectorGeometry"){let c=ht.createFromState(o.shape,o.width,o.height);s.shape=c,s.ownerId=r.uuid}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new XM.BufferGeometryLoader().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new Bt(o,e);return c.data=i,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=km(o.type);if(c)return c.create(o,t);gr("text",`a ${o.type}`);let d=ht.createFromState(pl.defaultData(),100,100);return Ly({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return dd.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=Ly(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=ht.createFromState(pl.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=Ly(s)}return l}var dS=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Hp=class extends dS{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let o=Li(e,r,this.flatShading,n);return o.computeBoundingSphere(),o}};var hS="webgl",YM,uS,QM=!1;function fS(){return hS}function ZM(i){uS=i}function JM(){if(hS==="webgpu"){if(YM!==void 0)return YM;QM||(QM=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(uS===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return uS}function _y(i,t){return JM().createRootMaterial(i,t)}function mS(i,t,e){return JM().createSharedMaterial(i,t,e)}function yS(i){return i.getLayersOfType===void 0&&Object.assign(i,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),i}var KM,$M;function e2(i){$M=i}function t2(){let i=hS==="webgpu"&&KM!==void 0?KM:$M;return i===void 0?null:yS(i())}var pS;function r2(i){pS=i}function n2(i,t){return pS===void 0?!1:pS(i,t)}var i2={markNeedsUpdateRendererDirty:()=>{}};function zo(i,t){let e=0;if(!i.layers||i.layers.length===0)return!1;let r=i.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,o=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?o/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let o=n.data.visible?n.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,s=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var _i=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,ue=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e);function gS(i){let t=typeof i=="string"?i:i.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function po(i){return typeof i=="string"||typeof i=="number"&&i!==0}var fd={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},o2={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};var a2=require("three");var vS=class extends Hc(a2.Object3D){},Fk=i=>i.type==="Mesh",Dr=class extends vS{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new Dr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix,n.pivotMatrix=r.pivotMatrix),n.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 Fk(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}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};gt();var pi=require("three");var s2=null,l2=null;function c2(i){s2=i}function bS(){return s2}function d2(i){l2=i}function u2(){return l2}function Fy(i){return"variable_"+i}var p2=new pi.Matrix4,h2=new pi.Vector3,f2=new pi.Quaternion,Gk=new pi.Vector3,m2=new pi.Euler,xS=class extends py{constructor(e){super();this.shared=e}create(e){return new ed(e,this.shared)}},y2=new Set;function Uk(i,t){let e=`${i}/${t}`;y2.has(e)||(y2.add(e),console.warn(`[spline] updateObject: ignoring a geometry update of ${i} vertices for a mesh that holds ${t}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}var SS=class{constructor(t,e={},r=!0,n=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=n;this.geometryCache=new Hp(!0);this.geometryCache2=new Hp(!1);this.imageHolderCache=new xS(this);this.thisContext={scene:i2,shared:this};this.deletedImage=new di(Om.emptyImage,this);this.deletedVideo=new di(Tc.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=mS(lr.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:o}of t.variables)this.addVariableHolder(n,o),e&&this.updateVariableHolder(n,o);for(let[n,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,o);for(let[n,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,o);if(!r){for(let[n,o]of Object.entries(t.images))this.addImage(n,o);for(let[n,o]of Object.entries(t.videos))this.addVideo(n,o)}for(let[n,o]of Object.entries(t.colors))this.addColor(n,o);for(let[n,o]of Object.entries(t.lib.materials))this.addMaterial(n,o.asset);for(let[n,o]of Object.entries(t.materials))this.addMaterial(n,o);for(let[n,o]of Object.entries(t.audios))this.addAudio(n,o);for(let[n,o]of Object.entries(t.particles))this.addParticle(n,o);for(let[n,o]of Object.entries(t.fonts))this.addFont(n,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:lr.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=mS(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:lr.defaultTwoLayerData("phong").layers}),_y(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new di(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new di(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let r=t.material;if(!r)return null;for(let n of Array.isArray(r)?r:[r]){let o=n.root??n;for(let a of o?.data?.layers??[]){let s=a?.data;if(s?.type!=="texture"&&s?.type!=="matcap"||e.layer!==void 0&&a.id!==e.layer&&s.type!==e.layer)continue;let l=s.texture?.image;if(l==null)continue;let c=(typeof l=="string"?this.uiBuffer(l):void 0)??this.image(l);if(!c)continue;let d=c.getTexture(s.texture.wrapping??(s.type==="texture"?1e3:1001),s.texture.minFilter??1008,s.texture.magFilter??1006),u=c.img;return{texture:d,width:u?.width??0,height:u?.height??0,layerId:a.id,layerType:s.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new di(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oa(e.r,e.g,e.b,e.a):this.colors[t]=new Oa(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Gt(0,0,0,0))}else return"a"in t?new Gt(t.r,t.g,t.b,t.a):new Gt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Ia)return e;{let r=new Ia({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Ia&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=VP();if(r===null){gr("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Ia&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(Fy(t));r=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(Fy(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:n,shared:this},u=s.slice(2);n.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=n.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*pi.MathUtils.DEG2RAD:l[s[s.length-1]]=r}if(l=n.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Le.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...n,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let n=e.dataPatched?.geometry;return!n||!this.transientGeometryKeys.has(n)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(n),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>SS.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let A=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(A.length===0||A.length%3!==0)return!1;for(let w=0;w<A.length;w++)if(A[w]>=l)return!1;u={array:A,itemSize:1,type:A.constructor.name,normalized:!1}}else{let A=o.data,w=A?.index;if(w?.array?.length){let E=(A?.attributes?.position?.array?.length??0)/3;if(l!==E)return Uk(l,E),!1;u=w}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let A=0;A<s.length;A+=3){let w=s[A],E=s[A+1],P=s[A+2];w<p&&(p=w),w>m&&(m=w),E<h&&(h=E),E>y&&(y=E),P<f&&(f=P),P>g&&(g=P)}let v=(A,w)=>({array:A,itemSize:w,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...n,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let n=r.cloner;if(n===void 0)return-1;let o=n.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let n=new Dr(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let o=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),r.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let n=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!n.includes(u)&&n.push(u)}if(n.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Gt(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oa?d.setValue(u,new Gt(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of n){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:zo(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=fd[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(A=>A===v)??g.find(A=>a(A)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(A=>typeof A=="number"&&isFinite(A))){let A=["x","y","z"];b.forEach((w,E)=>{d.onVariableUpdate?.(["layer",f.id,S,A[E]],w,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(p2))return p2.decompose(h2,f2,Gk),t[1]==="position"?h2[t[2]]:(m2.setFromQuaternion(f2,r.rotation.order),m2[t[2]]*pi.MathUtils.RAD2DEG);for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=pi.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],o=n.locations?.findIndex(a=>zt.equal(a,e));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(ir.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(n):a?.update(n,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(ir.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};n.update(o),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=u2();return r===null?(gr("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=bS();return r===null?(gr("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=bS();return r===null?(gr("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},ws=SS;ws.MAX_TRANSIENT_VERTICES=6e4;var v2=new ws(Bn.emptyData());function Bl(i){return i?.isClassicNodeMaterial===!0}function b2(i){return i?.isClassicSharedMaterial===!0}function ky(i){return Bl(i)||i?.isTSLNodeMaterial===!0}function x2(i){return b2(i)||i?.isTSLSharedMaterial===!0}gt();fr();var Ln=5,md=3;var S2=.98;var br=class extends it{setMaterialOverride(e,r){this.materialOverride=yS(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.syncShadowCatcher(n),Jw(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=n.shared.material(a);l!==s&&br.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(ir.drop(e,1),r.material,n)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(ir.drop(e,2),a,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let n=t2();if(n===null)return;this.shadowCatcherMaterial=n}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){ky(e)&&!x2(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&Pf(this.material).forEach(e=>{br.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};var wn=require("three");var A2=new wn.Vector3,w2=new wn.Vector4,E2=new wn.Vector4,zk=new wn.Vector3,C2=new wn.Matrix4,tt=class extends br{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new wn.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new wn.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof wn.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof wn.BufferGeometry?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof ws){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),n=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(n,e,this),this._geometryCacheKey=n}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return hp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return hp.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(ir.drop(e,1),r.geometry,n)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){super.dispose(),yM(this.uuid)}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(!(e===void 0||e.sxPrev===void 0))return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Li(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&zp(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else if(!this.absorbDepthInteraction(e)){let o={...this.data.geometry,...e},a=Li(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&Dy(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}absorbDepthInteraction(e){let r=this.localGeometry;if(r?.shiftDepthTo===void 0)return!1;let n=e;if(typeof n.depth!="number")return!1;let o=r.userData?.parameters;if(o===void 0)return!1;for(let a of Object.keys(n))if(a!=="depth"&&n[a]!==o[a])return!1;return r.shiftDepthTo(n.depth)?(o.depth=n.depth,!0):!1}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Bt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&Ny(e.props)&&this.geometryCreateDeleyed instanceof Bt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof wn.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Bt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=n.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Li(d,a,this.data.flatShading,this);Dy(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)}}o||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let n=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof wn.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Bt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(n),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Li(o,n,this.data.flatShading,this);Dy(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(n).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let n=e.morphTargetInfluences;if(n){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of n)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let n=this.morphTargetDictionary[e];n!==void 0&&(this.morphTargetInfluences[n]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,n.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)):n.centerOffset?e.fromArray(n.centerOffset):e.setScalar(0),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new wn.Vector4,n=this.geometry.attributes.skinWeight;for(let o=0,a=n.count;o<a;o++){r.fromBufferAttribute(n,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),n.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let o=this.geometry;w2.fromBufferAttribute(o.attributes.skinIndex,e),E2.fromBufferAttribute(o.attributes.skinWeight,e),A2.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=E2.getComponent(a);if(s!==0){let l=w2.getComponent(a);C2.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(zk.copy(A2).applyMatrix4(C2),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};var D2=require("three");var Wo=require("three");var T2=require("three"),jo=i=>{var t;return t=class extends i{},t.geometryHelper=new T2.BoxGeometry(30,30,30),t};var En=require("three"),Vy=new En.Ray,wS=new En.Sphere,P2=new En.Matrix4,Ho=(i,t,e,r,n=!1,o=i)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),wS.copy(a.boundingSphere),wS.applyMatrix4(s),e.ray.intersectsSphere(wS)===!1||(P2.copy(s).invert(),Vy.copy(e.ray).applyMatrix4(P2),a.boundingBox!==null&&Vy.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(n===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(i,e,Vy,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new En.Vector3,x=new En.Vector3,A=new En.Vector3,w=new En.Vector3,E=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),D=M*M,R=Math.max(0,f.start),L=Math.min(b.count,f.start+f.count);for(let C=R,B=L-1;C<B;C+=E){if(S.fromBufferAttribute(b,C),x.fromBufferAttribute(b,C+1),Vy.distanceSqToSegment(S,x,w,A)>D)continue;w.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(w);F<e.near||F>e.far||r.push({distance:F,point:A.clone().applyMatrix4(o.matrixWorld),object:i})}}function g(v,b,S,x,A,w,E){let P=new En.Vector3,M=new En.Vector3,D=new En.Vector3,R=new En.Vector3,L=new En.Vector3;if(P.fromBufferAttribute(x,A),M.fromBufferAttribute(x,w),D.fromBufferAttribute(x,E),S.intersectTriangle(P,M,D,!1,R)===null)return null;L.copy(R),L.applyMatrix4(v.matrixWorld);let B=b.ray.origin.distanceTo(L);return B<b.near||B>b.far?null:{faceIndex:1,distance:B,point:L.clone(),object:v}}};var jk=new Wo.Vector3(1,1,1),M2=new Wo.Vector3,Hk=new Wo.Vector3,O2=new Wo.Quaternion,Fi=class extends jo(Wo.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new Wo.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Ho(this.object,Fi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(M2,O2,Hk),this.matrix.compose(M2,O2,jk),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var Wp=require("three");var Gy;(t=>t.is=e=>"objectHelper"in e)(Gy||(Gy={}));var ki=(i,t)=>class extends Xc(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,o){this.objectHelper.raycast(n,o)}showGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof Wp.Box3Helper&&(o.visible=!0)}}updateEntityBoxSize(n,o){this.objectHelper.visible&&this.geometryHelper instanceof Wp.BoxGeometry?(n.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,o)}hideGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof Wp.Box3Helper&&(o.visible=!1)}}};var gd=class extends ki(D2.Group,Fi){constructor(e,r,n){super();this.super_Entity(e,r),this.context=n,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var Wk=null;function I2(){return Wk}var Je=require("three"),Qy=mc(B2());var qk=.5*(Math.sqrt(3)-1),qp=(3-Math.sqrt(3))/6,Xk=1/3,qo=1/6,iee=(Math.sqrt(5)-1)/4,oee=(5-Math.sqrt(5))/20,Xp=i=>Math.floor(i)|0,N2=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]),CS=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 L2(i=Math.random){let t=F2(i),e=new Float64Array(t).map(n=>N2[n%12*2]),r=new Float64Array(t).map(n=>N2[n%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*qk,u=Xp(o+d),p=Xp(a+d),h=(u+p)*qp,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+qp,x=g-b+qp,A=y-1+2*qp,w=g-1+2*qp,E=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let L=E+t[P],C=e[L],B=r[L];M*=M,s=M*M*(C*y+B*g)}let D=.5-S*S-x*x;if(D>=0){let L=E+v+t[P+b],C=e[L],B=r[L];D*=D,l=D*D*(C*S+B*x)}let R=.5-A*A-w*w;if(R>=0){let L=E+1+t[P+1],C=e[L],B=r[L];R*=R,c=R*R*(C*A+B*w)}return 70*(s+l+c)}}function _2(i=Math.random){let t=F2(i),e=new Float64Array(t).map(o=>CS[o%12*3]),r=new Float64Array(t).map(o=>CS[o%12*3+1]),n=new Float64Array(t).map(o=>CS[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*Xk,f=Xp(a+h),m=Xp(s+h),y=Xp(l+h),g=(f+m+y)*qo,v=f-g,b=m-g,S=y-g,x=a-v,A=s-b,w=l-S,E,P,M,D,R,L;x>=A?A>=w?(E=1,P=0,M=0,D=1,R=1,L=0):x>=w?(E=1,P=0,M=0,D=1,R=0,L=1):(E=0,P=0,M=1,D=1,R=0,L=1):A<w?(E=0,P=0,M=1,D=0,R=1,L=1):x<w?(E=0,P=1,M=0,D=0,R=1,L=1):(E=0,P=1,M=0,D=1,R=1,L=0);let C=x-E+qo,B=A-P+qo,_=w-M+qo,F=x-D+2*qo,k=A-R+2*qo,q=w-L+2*qo,W=x-1+3*qo,G=A-1+3*qo,X=w-1+3*qo,z=f&255,Q=m&255,K=y&255,ee=.6-x*x-A*A-w*w;if(ee<0)c=0;else{let ce=z+t[Q+t[K]];ee*=ee,c=ee*ee*(e[ce]*x+r[ce]*A+n[ce]*w)}let ve=.6-C*C-B*B-_*_;if(ve<0)d=0;else{let ce=z+E+t[Q+P+t[K+M]];ve*=ve,d=ve*ve*(e[ce]*C+r[ce]*B+n[ce]*_)}let le=.6-F*F-k*k-q*q;if(le<0)u=0;else{let ce=z+D+t[Q+R+t[K+L]];le*=le,u=le*le*(e[ce]*F+r[ce]*k+n[ce]*q)}let de=.6-W*W-G*G-X*X;if(de<0)p=0;else{let ce=z+1+t[Q+1+t[K+1]];de*=de,p=de*de*(e[ce]*W+r[ce]*G+n[ce]*X)}return 32*(c+d+u+p)}}function F2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),o=e[r];e[r]=e[n],e[n]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var k2=require("three"),ho=new k2.Triangle,Uy=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let n=0;n<t.count;n+=3){let o=1;ho.a.fromBufferAttribute(t,n),ho.b.fromBufferAttribute(t,n+1),ho.c.fromBufferAttribute(t,n+2),o*=ho.getArea(),e[n/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,o=-1;for(;r<=n;){let a=Math.ceil((r+n)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?n=a-1:r=a+1}return o}sampleFace(t,e,r){let n=this.randomFunction(),o=this.randomFunction();return n+o>1&&(n=1-n,o=1-o),ho.a.fromBufferAttribute(this.positionAttribute,t*3),ho.b.fromBufferAttribute(this.positionAttribute,t*3+1),ho.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ho.a,n).addScaledVector(ho.b,o).addScaledVector(ho.c,1-(n+o)),ho.getNormal(r),this}};var Ba=require("three");var hi=require("three");function Yk(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new hi.Vector3(n[a],n[a+1],n[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new hi.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(o,3))}function Qk(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new hi.Vector3;for(let o=0;o<e.length;o+=3)n.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=n.x,r[o+1]=n.y,r[o+2]=n.z;i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(r,3))}function Xo(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!Bl(i.material)||i.material.getLayersOfType("outline").length===0)return;i instanceof tt&&i.is2DAndNoDepth?Qk(i):Yk(i)}function TS(i){return Math.min(2047,Math.max(1,Math.round(i*2048)))/2048}function Yo(i){if(!i.geometry.attributes.position)return;let t=i.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let n=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),a=[TS(hi.MathUtils.seededRandom(o)),TS(hi.MathUtils.seededRandom(o+1e4)),TS(hi.MathUtils.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)n[s]=a[s%3];i.geometry.setAttribute("randomColor",new hi.BufferAttribute(n,3))}var Qo=new Ba.Box3,Yp=new Ba.Vector3;function V2(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Na=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new Ba.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:o,subdivPointer:a}=Bt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=Array.isArray(n)?n.map(o=>o.getFlavor(!1,o.side,o.wireframe)):n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,n=!1){r&&this.subdividedGeometry||Bt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,n),this.subdividedGeometry&&Bt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Bt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Bt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,it.prototype.raycast.call(this,e,r),this.localGeometry=n}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ba.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Qo.setFromBufferAttribute(r),Qo.getCenter(n),e.boundingSphere.radius=n.distanceTo(Qo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qo.getSize(Yp),this.hasNonUniformScale&&Yp.divide(this.scale);let o={width:Yp.x,height:Yp.y,depth:Yp.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Qo.min.set(e[0],e[2],e[4]),Qo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Qo.min.applyMatrix4(this.shearScaleInv),Qo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Ba.Sphere);let n=r.boundingSphere.center;Qo.getCenter(n),r.boundingSphere.radius=n.distanceTo(Qo.max)}freeSubdivPointer(){this.subdivPointer&&(Bt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,n=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?Bt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),o!==void 0&&(this.localGeometry.userData.parameters=o),n&&(this.localGeometry.uuid=n)}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&(e.type===0&&e.path.length===0&&Ny(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};var Ko=require("three"),G2=-1,Kk=1,U2={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},z2={polygon_center:0,edge:1,vertex:2},Qp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ze=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-G2)*(e-r)/(Kk-G2)+r},Zk=new Ko.Vector3,zy=new Ko.Vector3,Jk=new Ko.Vector3,$k=new Ko.Vector3;function vd(i,t){let e=Jk.fromArray(i),r=$k.fromArray(t);zy.copy(r).sub(e);let n=zy.length();return zy.normalize().multiplyScalar(n*.5),Zk.copy(e).add(zy).toArray()}var Vi=new Ko.Triangle,jy=new Ko.Vector3,Hy=new Ko.Vector3,Nl=new Ko.Vector3;function j2(i){let t=[],e=Math.floor(i.index.count/3);for(let r=0;r<e;r++)if(jy.fromArray(i.index.array,r*3),Vi.setFromAttributeAndIndices(i.attributes.position,jy.x,jy.y,jy.z),Vi.getNormal(Hy),Vi.getMidpoint(Nl),!(isNaN(Nl.x)||isNaN(Nl.y)||isNaN(Nl.z))){let{a:n,b:o,c:a}=Vi,s=n.toArray(),l=o.toArray(),c=a.toArray(),d=n.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(n),h=vd(s,l),f=vd(l,c),m=vd(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Vi.getMidpoint(Nl).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Vi.getNormal(Hy).toArray()})}return t}function H2(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Vi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Vi.getNormal(Hy),Vi.getMidpoint(Nl);let n=Vi.a.toArray(),o=Vi.b.toArray(),a=Vi.c.toArray();t.push({vertices:[n,o,a],faceCenters:[vd(n,o),vd(o,a),vd(a,n)],midpoint:Nl.toArray(),norm:Hy.toArray()})}return t}var bd=require("three"),PS=class extends bd.InstancedMesh{},Wy=class extends PS{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new bd.Matrix4;this.pivotMatrix=new bd.Matrix4;this.previousModelViewMatrix=new bd.Matrix4;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(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.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let n=this.parent;if(e&&n!==null&&n.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)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,n,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var MS=i=>.5*(1-Math.cos(i*Math.PI)),OS=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-n,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=n+(o<<4)+(a<<8);d=MS(s),u=MS(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=MS(c)*(m-f),p+=f*h,h*=.5,n<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(n++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},W2=OS;var xd=require("three");var q2=new xd.Vector3,X2=new xd.Matrix4,Y2=new xd.Ray,Es=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(X2.copy(n).invert(),Y2.copy(e.ray).applyMatrix4(X2),Y2.intersectBox(this.singleBBox,q2))){let o=q2.applyMatrix4(n),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var _n=1e-4,Zo,aO,sO,lO,Q2=new Je.Vector3,K2=new Je.Vector3;Oy.then(i=>{Zo=i,aO=[Zo.get_face_center,Zo.get_edge_midpoint,Zo.get_vertex_position],sO=[Zo.get_face_normal,Zo.get_edge_normal,Zo.get_vertex_normal],lO=[Zo.face_count,Zo.edge_count,Zo.vertex_count]});var ute=new Je.Matrix4,eV=new Je.Matrix4,Z2=new Je.Matrix4,J2=new Je.Matrix4,$2=new Je.Matrix4,eO=new Je.Matrix4,tO=new Je.Matrix4,rO=new Je.Matrix4,Cs=new Je.Vector3,qy=new Je.Vector3,Kp=new Je.Vector3,DS=new Je.Vector3,tV=new Je.Vector3,nO=new Je.Vector3,Xy=new Je.Vector3,IS=new Je.Vector3,iO=new Je.Vector3,RS=new Je.Vector3,oO=new Je.Vector3,fo=new Je.Euler,rV=new Je.Quaternion;function Yy(i){return i?i.version??i.data?.version??0:-1}function or(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var BS=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new W2;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(n,o,a)=>this.perlin.noise(n,o,a):this.noise=n=>this.perlin.noise(n)):e?this.noise=_2((0,Qy.default)(t.seed)):this.noise=L2((0,Qy.default)(t.seed??""))}},Fn=class extends Hc(Je.Object3D){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof it&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof Dr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let n=r.transformOverride;n!==void 0&&(r.position.fromArray(n.position),r.rotation.fromArray(n.rotation),r.scale.fromArray(n.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||li(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Wy(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let n of this.children)n.playModeVisible!==!1&&(Z2.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix),e.setMatrixAt(r++,Z2));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let n;if(r!==void 0)n=r;else{let o=or(this.parameters.grid.count,e);n=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)n=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==n)if(this.children.length<n)for(let o=0,a=n-this.children.length;o<a;++o){let s=new Dr(this.object);s.expand(),this.add(s)}else for(;this.children.length>n;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new BS(e,r)),this.random}_updateRadial(e,r){let n=e.radial,o=n.start*Je.MathUtils.DEG2RAD,a=n.end*Je.MathUtils.DEG2RAD,s=o-a,l=or(n.rotation,r),c=new Je.Euler(l[0],l[1],l[2]),d;switch(n.axis){case"z":d=new Je.Vector3(0,0,1);break;case"y":d=new Je.Vector3(0,1,0);break;default:case"x":d=new Je.Vector3(1,0,0);break}let u=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=or(n.scale,r),m=or(n.position,r),y=or(u.scale,r),g=or(u.position,r),v=or(u.rotation,r),b=s/e.count,S=Qp(u.strength,this.parameters.randomness);for(let[x,A]of this.children.entries()){let w=x*(u.freqScale/10)+u.movement,E=h===null?0:h.noise(w,w,w),P=x+1;A.scale.x=f[0]+S(P,ze(E,y[0]))||_n,A.scale.y=f[1]+S(P,ze(E,y[1]))||_n,A.scale.z=f[2]+S(P,ze(E,y[2]))||_n;let M=b*x-o;switch(n.axis){default:case"x":fo.set(0,M,0);break;case"y":fo.set(0,0,M);break;case"z":fo.set(M,0,0);break}Xy.copy(d).applyQuaternion(rV.setFromEuler(fo)).multiplyScalar(n.radius),A.position.set(Xy.x+(m[0]+S(P,ze(E,g[0]))),Xy.y+(m[1]+S(P,ze(E,g[1]))),Xy.z+(m[2]+S(P,ze(E,g[2]))));let D=S(P,ze(E,v[0])),R=S(P,ze(E,v[1])),L=S(P,ze(E,v[2]));n.alignment===!0?A.rotation.set(fo.x+(c.x+D),fo.y+(c.y+R),fo.z+(c.z+L)):A.rotation.set(c.x+D,c.y+R,c.z+L)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let n=e.linear,o=or(n.rotation,r),a=or(n.scale,r),s=or(n.position,r),l=new Je.Euler(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,d=or(c.rotation,r),u=or(c.scale,r),p=or(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Qp(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,ze(b,d[0])),A=m(S,ze(b,d[1])),w=m(S,ze(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,ze(b,u[0]))||_n,g.scale.y=1+(a[1]-1)*y+m(S,ze(b,u[1]))||_n,g.scale.z=1+(a[2]-1)*y+m(S,ze(b,u[2]))||_n,g.rotation.set(l.x*y+x,l.y*y+A,l.z*y+w),g.position.x=s[0]*y+m(S,ze(b,p[0])),g.position.y=s[1]*y+m(S,ze(b,p[1])),g.position.z=s[2]*y+m(S,ze(b,p[2]))}}_updateGrid(e,r){let n=0,o=e.grid,a=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,s=or(a.scale,r),l=or(a.rotation,r),c=or(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Qp(a.strength,this.parameters.randomness),h=or(o.count,r),f=or(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Je.Vector3(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[n++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(n,ze(x,s[0]))||_n,S.scale.y=1+p(n,ze(x,s[1]))||_n,S.scale.z=1+p(n,ze(x,s[2]))||_n;let A=p(n,ze(x,l[0])),w=p(n,ze(x,l[1])),E=p(n,ze(x,l[2]));S.rotation.set(A,w,E),S.position.x=f[0]*g-y.x+p(n,ze(x,c[0])),S.position.y=f[1]*v-y.y+p(n,ze(x,c[1])),S.position.z=f[2]*b-y.z+p(n,ze(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[n++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(n,ze(b,s[0]))||_n,v.scale.y=1+p(n,ze(b,s[1]))||_n,v.scale.z=1+p(n,ze(b,s[2]))||_n;let S=p(n,ze(b,l[0])),x=p(n,ze(b,l[1])),A=p(n,ze(b,l[2]));v.rotation.set(S,x,A),v.position.x=f[0]*m+p(n,ze(b,c[0])),v.position.y=-f[1]*y+p(n,ze(b,c[1])),v.position.z=-f[2]*g+p(n,ze(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:n}=e,o=or(n.rotation,r),a=or(n.position,r),s=or(n.scale,r),l=new Je.Euler(o[0],o[1],o[2]),c=e.randomnessObject??Io.defaultData([1,1,1]).randomnessObject,d=or(c.rotation,r),u=or(c.position,r),p=or(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Qp(c.strength,this.parameters.randomness);if(!n.object){for(let[,A]of this.children.entries())A.position.set(0,0,0),A.scale.setScalar(1),A.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Es)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let A=Math.round(y.length*n.count/100);this._updateCount(r,A)}else{let A=this.objectForSample.geometry.getAttribute("position");if(!A||isNaN(A.count)||A.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=n.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Qy.default)(this.object.uuid+n.seed)));let b=U2[n.axis],S=this.children;Cs.fromArray(b),J2.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Na;x&&$2.copy(this.objectForSample.matrixWorld).invert(),n.align!=="normal"&&this.object.getWorldDirection(nO),RS.set(Cs.y,Cs.z,Cs.x).normalize(),oO.copy(RS).cross(Cs).normalize(),tO.makeBasis(RS,Cs,oO).invert();for(let[A,w]of S.entries()){let E=A*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(E,E,E),M=A+1,D=m(M,ze(P,d[0])),R=m(M,ze(P,d[1])),L=m(M,ze(P,d[2]));g?v.sample(Kp,DS):(y.length&&(Kp.fromArray(y[A].pos),DS.fromArray(y[A].norm)),x&&Kp.applyMatrix4($2)),Kp.applyMatrix4(J2),w.position.copy(Kp);let C=n.align==="normal"?DS:nO,B=qy.fromArray(a);qy.x+=m(M,ze(P,u[0])),qy.y+=m(M,ze(P,u[1])),qy.z+=m(M,ze(P,u[2]));let _=Math.acos(C.dot(Cs)),F=tV.crossVectors(Cs,C).normalize(),k=eV.makeRotationAxis(F,_);IS.copy(C).cross(this.object.up).normalize(),iO.copy(IS).cross(C).normalize(),eO.makeBasis(IS,C,iO),rO.multiplyMatrices(eO,tO),fo.setFromRotationMatrix(rO),B.applyMatrix4(k),w.position.add(B),w.rotation.set(fo.x+l.x+D,fo.y+l.y+R,fo.z+l.z+L),w.scale.set(1+s[0]+m(M,ze(P,p[0]))||_n,1+s[1]+m(M,ze(P,p[1]))||_n,1+s[2]+m(M,ze(P,p[2]))||_n),w.scale.multiply(this.object.scale),w.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,n=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===n&&a.positionVersion===Yy(n)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new Uy(e).build();return this.surfaceSamplerCache={geometry:r,position:n,positionVersion:Yy(n),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Na,n=this.objectForSample.geometry;if(!r&&n){let l=this.surfacePointsCache,c=n.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===n&&l.position===c&&l.positionVersion===Yy(c)&&l.index===n.index&&l.indexVersion===(n.index===null?-1:n.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=z2[e],d=lO[c],u=aO[c],p=sO[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);Q2.fromArray(m).applyMatrix4(l.matrixWorld),K2.fromArray(y),a(Q2.toArray(),K2.toArray())}}else(n.index?j2(n):H2(n)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&n){let l=n.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:n,position:l,positionVersion:Yy(l),index:n.index,indexVersion:n.index===null?-1:n.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ys(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let n=r.scene.find(this.parameters.toObject.object);n instanceof it?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new Je.Matrix4,this.hiddenMatrix=new Je.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=24,Ir=96,Jo=PP(),La=2;var NS=!1,cO=!0;try{let i=new URLSearchParams(window.location.search);NS=i.get("dbgsbstatic")==="0",cO=i.get("sb512")!=="0"}catch{}function nV(i){let t=i.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var LS=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(Ir);this._prevReach=new Float32Array(Ir);this._fieldDirtyFull=!0;this._fieldDirtyMin=new fe.Vector3;this._fieldDirtyMax=new fe.Vector3;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new fe.Scene;this.potentialPassScene=new fe.Scene;this.voxelPassScene=new fe.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new fe.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new fe.Mesh($c,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new fe.DataTexture(Jo.triTable,16,256,fe.RedFormat,fe.FloatType);o.needsUpdate=!0;let a=new fe.DataTexture(Jo.numTrisTable,256,1,fe.RedFormat,fe.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new fe.Mesh($c,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new fe.Mesh($c,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=lV.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new fe.ShaderMaterial({vertexShader:c.vertexShader,fragmentShader:`
729
729
  #include <packing>
730
730
  void main()
731
731
  {
@@ -1308,7 +1308,7 @@ void main() {
1308
1308
  gl_FragColor = texture(inputTexture, vUv);
1309
1309
  gVelocity = vec4(0.0);
1310
1310
  }
1311
- `,r.pyramidTextureSize.value=new fe.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=n,this.material.root.shapeBlendhack=n}dispose(){super.dispose(),I2()?.release(this)}},Zp=LS;Zp.streamCompaction=new cy;var iV=new fe.Matrix4,oV=new fe.Matrix4,Sd=new fe.Quaternion,Ll=new fe.Vector3,Ky=new fe.Vector3,aV=new fe.Quaternion;function sV(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Pa.is(r)&&dO.call(r,i,t+1)}}function dO(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let n=this.children[r];Pa.is(n)&&dO.call(n,i,t+1)}}}function lV(){if(this.shapesDataTexture.value===void 0){let y=new fe.DataTexture(new Float32Array(4*Ir*Ma),Ir,Ma,fe.RGBAFormat,fe.FloatType);this.shapesDataTexture.value=y}let i=this.shapesDataTexture.value,t=i.image.data,e=0,r=0,n=this.data.geometry.blendRange,o=iV.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(sV.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof Fn)return;if(y instanceof gd||Ap(y))return;y instanceof Dr?g=y.object:g=y;let v=y.data?.cloner;if(Le.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof tt))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(oV.multiplyMatrices(o,y.matrixWorld).decompose(Ky,Sd,Ll),b?.type==="TorusGeometry"&&b.arc!==360){let C=b.arc*Math.PI/180;C=C/4,Sd.multiply(aV.set(0,0,Math.sin(C),Math.cos(C)))}let A=S.overrideGlobalBlend?S.blendRange:n;A=A/this.bboxSize*2,t[s*4]=(Ky.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Ky.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Ky.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[Ir*4+s*4]=-Sd.x,t[Ir*4+s*4+1]=-Sd.y,t[Ir*4+s*4+2]=-Sd.z,t[Ir*4+s*4+3]=Sd.w;let w=new Float32Array(4),E=0,P=A;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?w[0]=0:w[0]=1,w[1]=b.width/this.bboxSize,w[2]=b.height/this.bboxSize,w[3]=b.depth/this.bboxSize,P=Math.max(w[1],w[2],w[3])*Ll.x+A;else if(b?.type==="CubeGeometry"){E=b.cornerRadius;let C=b.width,B=b.height,_=b.depth;w[0]=2,w[1]=(C-2*E)/this.bboxSize,w[2]=(B-2*E)/this.bboxSize,w[3]=(_-2*E)/this.bboxSize,P=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Ll.x+A}else if(b?.type==="CylinderGeometry"){E=b.cornerRadius;let C=b.height,B=b.radiusBottom,_=b.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),k=(Math.PI/2-F)/2;_-=E/Math.tan(k),B-=E*Math.tan(k)}else if(B>_){let F=Math.atan2(B-_,C),k=(Math.PI/2-F)/2;_-=E*Math.tan(k),B-=E/Math.tan(k)}w[1]=(b.height-2*E)/this.bboxSize,B===_?(w[0]=3,w[2]=B/this.bboxSize*2):(w[0]=4,w[2]=B/this.bboxSize*2,w[3]=_/this.bboxSize*2),P=(Math.hypot(w[1],Math.max(Math.abs(w[2]),Math.abs(w[3])))+E/this.bboxSize*2)*Ll.x+A}else if(b?.type==="TorusGeometry"){if(w[0]=5,w[1]=(b.width-b.depth)/this.bboxSize,w[2]=b.depth/this.bboxSize,b.arc!==360){w[0]=6,w[3]=w[1],t[Ir*12+s*4+3]=w[2];let C=2*Math.atan2(w[2]/2,w[1]),B=b.arc*Math.PI/180/2-C;w[1]=Math.sin(B),w[2]=Math.cos(B)}P=b.width*Ll.x/this.bboxSize+A}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nV(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;w[0]=7,w[1]=B.slot,w[2]=B.boxHalf.x/this.bboxSize*2,w[3]=B.boxHalf.y/this.bboxSize*2,t[Ir*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,P=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Ll.x+A}t.set(w,Ir*8+s*4),e=Math.max(e,P),r=Math.max(r,A),this._reach[s]=P,t[Ir*12+s*4]=A,t[Ir*12+s*4+1]=E/this.bboxSize*2,t[Ir*12+s*4+2]=Ll.x;let M=Array.isArray(g.material)?g.material[0]:g.material,D=M,R,L;if(D?.getShapeBlendBaseColor){let C=D.getShapeBlendBaseColor();R=C,L=C.a}else M?.uniforms?.nodeU0!==void 0?(R=M.uniforms.nodeU0.node.value,L=M.uniforms.nodeU1?.value??1):(R={r:1,g:1,b:1},L=1);S.operation!==0&&!S.useColor&&(L=-1),t[Ir*16+s*4]=R.r,t[Ir*16+s*4+1]=R.g,t[Ir*16+s*4+2]=R.b,t[Ir*16+s*4+3]=L,L<1&&this.material.defines?.SHAPEBLEND_C===1&&this.material.setTransparent(!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||NS,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let D=0;D<Ma;D++){let R=Ir*4*D+g*4;if(t[R]!==d[R]||t[R+1]!==d[R+1]||t[R+2]!==d[R+2]||t[R+3]!==d[R+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],A=d[g*4],w=d[g*4+1],E=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+P)||!Number.isFinite(A+w+E+M)){h=!0;continue}f.x=Math.min(f.x,b-P,A-M),f.y=Math.min(f.y,S-P,w-M),f.z=Math.min(f.z,x-P,E-M),m.x=Math.max(m.x,b+P,A+M),m.y=Math.max(m.y,S+P,w+M),m.z=Math.max(m.z,x+P,E+M)}}return NS&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,i.needsUpdate=!0),p}Oi("ShapeBlendGeometry",(i,t,e)=>new Zp(i,t,e));Pe("shape-blends");var Zy=class extends tt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Dp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Oi("VectorGeometry",(i,t,e)=>new Zy(i,t,e));Pe("vector-shapes");var Jy=class extends tt{constructor(e,r,n){super(e,r,n);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=n}get profileShape(){return this._lastShape??void 0}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=dd;break;case"Ellipse":o=ld;break;case"Polygon":o=Ty;break;case"Star":o=Py;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let n=this.geometry;if(r&&n.inputs){if(this._lastShape=r,e.type==="Custom"&&(this._lastShapeParams=null),n.inputs.shapeData===r)return;n.inputs.shapeData=r,n.build()}}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let n in e)if(!Object.is(e[n],r[n]))return!1;for(let n in r)if(!(n in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let n=this.geometry.getAttribute("position");n!==void 0&&n.count>0?Dp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var ke=require("three");function uO(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var pO=new ke.Matrix4,cV=new ke.Matrix4,dV=new ke.Matrix4().makeScale(1,1,-1),hO=new ke.Vector3,fO=new ke.Vector3,_S=new ke.Vector3,uV=new ke.Vector3,pV=new ke.Vector3,hV=new ke.Vector3,fV=new ke.Vector3,mO=new WeakMap,FS=new WeakMap;function mV(i,t,e){let r=[new ke.Vector3,new ke.Vector3,new ke.Vector3],n=[new ke.Vector3,new ke.Vector3,new ke.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((o,a)=>{let s=n[a],l=ke.MathUtils.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new ke.Matrix4().makeBasis(r[0],r[1],r[2])}function yO(i){i.setIndex(null),i.setAttribute("position",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("normal",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("uv",new ke.BufferAttribute(new Float32Array(0),2)),i.setDrawRange(0,0)}var gO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shapeData??t?.shapeData??ld.create({parameters:{...hl,width:typeof hl.width=="number"?hl.width:100,height:typeof hl.height=="number"?hl.height:100}}).userData.shape;return{ownerId:i.ownerId??t?.ownerId,path:i.path??Pc.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:o,extrusion:{...vm,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new kS(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else{let e=new ke.BufferGeometry;return yO(e),Object.assign(e,{userData:{...i,type:"PathGeometry"}})}}},kS=class extends ke.BufferGeometry{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)||!uO(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){yO(this);return}let{depth:n,offset:o}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((n+o)*a):Math.ceil(Math.min(1,n+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let z=0;z<c;z++){let Q=this.inputs.path.isClosed?(z+s)%e.length:Math.min(z+s,e.length-1);d.push(e[Q].clone()),u.push(r[Q].clone())}let p=(z,Q,K)=>{d[z]=d[z].clone().lerp(d[Q],K),u[z]=mV(u[z],u[Q],K)},h=0,f=o*a%1;(!this.inputs.path.isClosed||n<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+n)*a%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&o+n<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),n===0){let z=d.length-1;d[z].copy(d[0]),u[z].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:x,vertices:A}=this._getShapePoints(b),w=g>0?this.inputs.parameters.extrusion.capType:"flat",E=w==="round"?gM(this.inputs.shapeData,g,v,b,this.inputs.ownerId):void 0,P=w==="round"&&E===void 0?"flat":w,M=E!==void 0?E.positions.length/3:0,D=0,R=0;x.sort((z,Q)=>z.start-Q.start),x.forEach(z=>{z.verticesStart=D,z.verticesCount=z.continuous.reduce((Q,K,ee)=>Q+(ee===0||!K?2:1),0),R+=z.verticesCount,D=R});let L=R*c,C,B=0;this._isOpenEnded()&&P==="flat"&&(C=this._getSurfaceTesselation(S),B=C.vertexCount);let _=L+2*B+M*2,F=L+2*B,k={positions:new Float32Array(_*3),normals:new Float32Array(_*3),uvs:new Float32Array(_*2)},q=0;x.forEach(z=>{q+=z.count});let W=q*(c-1)*6+(C?2*C.elementCount*3:0)+(E!==void 0?2*E.indices.length:0),G=new Uint32Array(W),X=0;if(x.forEach(z=>{X=this._extrudeRegion(z,A,u,d,k,G,X,this._isGeometryClosed()&&!this._isOpenEnded())}),C&&(X=this._closeEnd(C,L,G,X,k,u[0],d[0],!1),X=this._closeEnd(C,L+B,G,X,k,u[u.length-1],d[d.length-1],!0)),E!==void 0){let z={positions:k.positions,normals:k.normals,uvs:k.uvs,indices:G};Vp(E,z,F,X,pO.copy(u[0]).setPosition(d[0]).multiply(dV),(Q,K,ee)=>[ee,1e-4]),X+=E.indices.length,F+=M,Vp(E,z,F,X,pO.copy(u[u.length-1]).setPosition(d[d.length-1]),(Q,K,ee)=>[ee,1]),X+=E.indices.length}this.setAttribute("position",new ke.BufferAttribute(k.positions,3)),this.setAttribute("normal",new ke.BufferAttribute(k.normals,3)),this.setAttribute("uv",new ke.BufferAttribute(k.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let n=e.length-1;n>=0;--n)if(e[n]>=65535){r=!0;break}this.setIndex(new ke.BufferAttribute(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=jm(e),n=mO.get(r);if(n===void 0||n.subdivisions!==e.subdivisions||n.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);n={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},mO.set(r,n)}return n}_extractPathPoints(e){let r=this.inputs.path.subdivisions,n=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(n.length<2)return[];let o=[n[0]];return n.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],n=e.length,o=this.inputs.path.isClosed,a=new ke.Vector3,s=new ke.Vector3,l=new ke.Vector3,c=new ke.Vector3,d=new ke.Vector3(0,1,0);for(let y=0;y<n;y++){let g=e[y],v;y===0?v=o?e[n-1]:hO.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===n-1?b=o?e[0]:hO.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],fO.subVectors(g,v).normalize(),_S.subVectors(b,g).normalize();let S=uV.addVectors(fO,_S);S.lengthSq()<1e-10&&(S.copy(_S),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||pV.copy(S).negate().equals(d))&&d.set(0,0,1);let x=hV.crossVectors(d,S).normalize(),A=fV.crossVectors(S,x).normalize();d.copy(A),c.copy(x),y===0&&(a.copy(A),s.copy(S));let w=new ke.Matrix4().makeBasis(x,A,S);r.push(w)}let u=o?s:l,p=o?a:new ke.Vector3(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(cV.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,n){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new ke.Matrix4,u=new ke.Matrix4;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(n===0?0:1)-(r+(1-n)));d.makeRotationZ(ke.MathUtils.lerp(a,a+s,f)*ke.MathUtils.DEG2RAD);let m=ke.MathUtils.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=Ct.ODD){let n=this.inputs.shapeData,o=FS.get(n);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},FS.set(n,o)),o.shapePoints}_getSurfaceTesselation(e){let r=FS.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let n;try{n=Ss({windingRule:Ct.ODD,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{n=Sy}return r!==void 0&&(r.surfaceTesselation=n),n}_computeShapePoints(e=12,r=Ct.ODD){let n=this.inputs.shapeData,o=n.extractShapePointsToFlatArray([],e),a=n.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=Ss({windingRule:r,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=xy}let l;try{l=Ss({windingRule:Ct.ODD,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=dM}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let A=v,w=S-1,E=v+1,P=n.roundedCurves.length;do{let M=A-v,D=s.vertices[w*2+0],R=s.vertices[w*2+1],L=s.vertices[A*2+0],C=s.vertices[A*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=L-D,k=C-R,q=Math.sqrt(F*F+k*k);F/=q,k/=q;let W=L-B,G=C-_,X=Math.sqrt(W*W+G*G);W/=X,G/=X,x.normals[M*2+0]=-G,x.normals[M*2+1]=W;let z=s.vertexIndices[A];if(Array.isArray(z))x.continuous[M]=!1;else{let[Q,K]=n.getCurveIndexFromVertexId(z-1,!0);if(K>0&&K<1)x.continuous[M]=!0;else{let ee=K===1?Q+1:Q-1;ee=(ee+P)%P;let ve=K===1?0:1,le=n.roundedCurves[Q].getTangent(K),de=n.roundedCurves[ee].getTangent(ve);x.continuous[M]=le.dot(de)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[w,A,E]=[A,E,E+1],E>=S&&(E-=b)}while(E!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,n,o,a){let s=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,n,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,A=r[x+0],w=r[x+1],E,P;if(e.continuous[S])E=e.normals[S*2+0],P=e.normals[S*2+1];else{let D=S===0?(e.start+e.count-1)*2:x-2,R=A-r[D+0];E=-(w-r[D+1]),P=R,e.isHole||(E=-E,P=-P)}let M=S===0?1:S/e.count;if(d.push(A,w,E,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(A,w,e.normals[0],e.normals[1],0,1);else{let D=S===e.count-1?e.start*2:x+2,R=r[D+0]-A;E=-(r[D+1]-w),P=R,e.isHole||(E=-E,P=-P),d.push(A,w,E,P,M,1)}}e.wallTemplate=d}let u=n.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=n[S].elements,A=x[0],w=x[1],E=x[2],P=x[4],M=x[5],D=x[6],R=x[12],L=x[13],C=x[14],B=o[S],_=S/(u-1),F=0,k=0,q=0,W=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let ce=d[G+0],me=d[G+1];F=A*ce+P*me+R+B.x,k=w*ce+M*me+L+B.y,q=E*ce+D*me+C+B.z}let X=d[G+2],z=d[G+3],Q=A*X+P*z+R,K=w*X+M*z+L,ee=E*X+D*z+C,ve=1/(Math.sqrt(Q*Q+K*K+ee*ee)||1);Q*=ve,K*=ve,ee*=ve;let le=W*2,de=W*3;h[de+0]=F,h[de+1]=k,h[de+2]=q,f[de+0]=Q,f[de+1]=K,f[de+2]=ee,m[le+0]=d[G+4],m[le+1]=_,W++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,A=x+e.verticesCount;for(let w=0;w<v;w+=2){let E=x+y[w],P=x+y[w+1],M=A+y[w+1],D=A+y[w];b?(s[l++]=E,s[l++]=M,s[l++]=P,s[l++]=E,s[l++]=D,s[l++]=M):(s[l++]=E,s[l++]=P,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=D)}}return l}_closeEnd(e,r,n,o,a,s,l,c){let d=e.vertexCount,u=new ke.Vector3(0,0,c?-1:1).applyMatrix4(s),p=new ke.Vector3,h=new ke.Vector2;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;n[o++]=f[y+0]+r,n[o++]=f[y+(c?1:2)]+r,n[o++]=f[y+(c?2:1)]+r}return o}};Oi("PathGeometry",(i,t,e)=>new Jy(i,t,e));Ep("PathGeometry",gO);Pe("3d-paths");Mi.Cloner=Fn;Pe("cloners");gt();var Ad=require("three");function Jp(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Le.is(e)&&Jp(e)}}var $p=class extends ki(Ad.Group,Fi){constructor(e,r,n){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),this.super_Entity(e,r),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,r){let n=fs.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let o,a;for(let s of No.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=n.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Mo.apply(n.data[s],e[s]));return this.overrideData=a,o}else return{...mr.defaultData,...e,...xp(mr.defaultData,No.rootOverrideProps)}}updateByOp(e,r,n,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let s of No.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&&No.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,n,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,o=!1;if(n!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Jp(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(n){let a={};bO(e,[this.uuid],r.overrides,this,n,n,0,o,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof tt&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new Ad.Matrix4().fromArray(m)),f=new Ad.Skeleton(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function vO(i,t,e,r){return i.component===t&&so(i.identity,r)?i.overrideData===e?2:1:0}function bO(i,t,e,r,n,o,a,s,l){if(a>50)return!1;if(r.component!==n){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}n.instances.find(d=>d===r)||n.instances.push(r),r.component=n}n instanceof $p&&n.isInstanceRoot&&n.expandInstanceChildren(i);let c=0;for(let d of n.children)if(Le.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=Oc.resolve(e,u,1);p!=null&&!(p instanceof kt)&&(Object.setPrototypeOf(p,kt.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Le.is(m)?m:null,h!==null){let y=vO(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=i.scene.findInstance(u)??null,h!==null)){let y=vO(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),i.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Mo.apply(d.data,p):d.data;no.is(m.type)&&(m={...m,type:"Empty"}),h=Mi.createEntity(u,m,i),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,i),f&&h.changeSelectedState(f,i),i.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,bO(i,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Le.is(u))i.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var xO=(i,t,e)=>new $p(i,t,e);xl("Component",xO);xl("Instance",xO);Pe("components");var VS=1e-10;function SO(i){let t=i[0][0],e=i[1][0],r=i[0][1],n=i[1][1],o=Math.sqrt(t*t+e*e),a=o>VS?t/o:1,s=o>VS?e/o:0,l=a*t+s*e,c=a*n-s*r,d=a*r+s*n;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>VS?d/c:0,0]}}function AO({rotation:i,scale:t,shear:e}){let r=Math.cos(i),n=Math.sin(i),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-n*a,n*t[0]+r*a,r*o-n*t[1],n*o+r*t[1]]}var Oe;(x=>{function i(){return[1,0,0,0,1,0,0,0,1]}x.identity=i;function t(A,w=x.identity()){for(let E=0,P=A.length;E<P;E++)w[E]=A[E];return w}x.copy=t;function e(A,w,E,P,M,D){return x.setAbcdef(x.identity(),A,w,E,P,M,D)}x.create=e;function r(A,w,E,P,M,D,R){return A[0]=w,A[1]=P,A[2]=D,A[3]=E,A[4]=M,A[5]=R,A}x.setAbcdef=r;function n(A,w){let[E,P,M,D,R,L]=a(A),[C,B,_,F,k,q]=a(w),W=C*E+B*M,G=C*P+B*D,X=_*E+F*M,z=_*P+F*D,Q=k*E+q*M+R,K=k*P+q*D+L;return x.create(W,G,X,z,Q,K)}x.append=n;function o(A,w){let[E,P,M,D,R,L]=a(A),[C,B,_,F,k,q]=a(w),W=E,G=P,X=M,z=D;(C!==1||B!==0||_!==0||F!==1)&&(W=E*C+P*_,G=E*B+P*F,X=M*C+D*_,z=M*B+D*F);let Q=R*C+L*_+k,K=R*B+L*F+q;return x.create(W,G,X,z,Q,K)}x.prepend=o;function a(A){return[A[0],A[3],A[1],A[4],A[2],A[5]]}x.getAbcdef=a;function s(A){let[w,E,P,M,D,R]=x.getAbcdef(A),L=w*M-E*P,C=M/L,B=-E/L,_=-P/L,F=w/L,k=(P*R-M*D)/L,q=-(w*R-E*D)/L;return x.create(C,B,_,F,k,q)}x.invert=s;function l([A,w],E){let[P,M,D,R,L,C]=x.getAbcdef(E);return[P*A+D*w+L,M*A+R*w+C]}x.apply=l;function c(A,w){let[E,P,M,D,R,L]=x.getAbcdef(w),C=1/(E*D+M*-P),[B,_]=A;return[D*C*B+-M*C*_+(L*M-R*D)*C,E*C*_+-P*C*B+(-L*E+R*P)*C]}x.applyInverse=c;function d(A,w,E=w){let[P,M,D,R,L,C]=x.getAbcdef(A);return x.setAbcdef(A,P*w,M*E,D*w,R*E,L*w,C*E),A}x.scale=d;function u(A,w){let E=Math.cos(w),P=Math.sin(w),[M,D,R,L,C,B]=x.getAbcdef(A);return x.setAbcdef(A,M*E-D*P,M*P+D*E,R*E-L*P,R*P+L*E,C*E-B*P,C*P+B*E),A}x.rotate=u;function p(A,w,E){let[P,M]=E,D=x.translate(A,-P,-M);return D=x.rotate(D,w),D=x.translate(D,P,M),D}x.rotateAround=p;function h(A,w,E){let[P,M,D,R,L,C]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,L+w,C+E),A}x.translate=h;function f(A,w,E){let[P,M,D,R]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,w,E),A}x.setTranslate=f;function m(A,w,E){let[P,M,D,R]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,w,E),A}x.setPosition=m;function y(A){let[w,E,P,M]=x.getAbcdef(A),D=Math.sqrt(w*w+E*E),R=Math.sqrt(P*P+M*M);return[D,R]}x.getScale=y;function g(A){let[,,,,w,E]=x.getAbcdef(A);return[w,E]}x.getPosition=g;function v(A,w){return x.decompose(A,w).rotation}x.getRotation=v;function b(A,w){let[E,P,M,D,R,L]=x.getAbcdef(A),{rotation:C,scale:B,shear:_}=SO([[E,M],[P,D]]);return{position:[R+(w[0]*E+w[1]*M)-w[0],L+(w[0]*P+w[1]*D)-w[1]],scale:B,rotation:C,shear:_,pivot:w}}x.decompose=b;function S(A,w,E,P,M=[0,0]){let[D,R]=A,[L,C]=P,[B,_,F,k]=AO({rotation:E,scale:w,shear:M}),q=D-(L*B+C*F)+L,W=R-(L*_+C*k)+C;return x.create(B,_,F,k,q,W)}x.compose=S})(Oe||(Oe={}));function yV(i,t){let[[e,r],[n,o]]=i,[[a,s],[l,c]]=t,d=(e-n)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-n)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var EO=[[-1,1],[-1,-1],[1,-1],[1,1]],wO=(i,t,e)=>{let r=i.getCenter(),n=i.getHalfSize(),o=Oe.append(t,i.worldMatrix);n[0]===0&&n[1]===0?e.push(Oe.apply(r,o)):EO.forEach(a=>{let s=[a[0]*n[0]+r[0],a[1]*n[1]+r[1]];e.push(Oe.apply(s,o))})},Ts=class{constructor(){this.matrix=Oe.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Oe.copy(t.worldMatrix,this.matrix);let r=Oe.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let n=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&wO(a,e,n)}):wO(t,e,n),this.setFromPoints(n)}setFromSize(t,e,r){this.makeEmpty(),Oe.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Oe.apply([0,0],r),Oe.apply([0,e],r),Oe.apply([t,e],r),Oe.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,n]=this.getHalfSize();return Oe.apply([t+r,e+n],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(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[n,o,a,s]=Oe.getAbcdef(this.matrix),l=Oe.create(n,o,a,s,r[0],r[1]);this.vertices=EO.map(([c,d])=>Oe.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:n}=this;return t>=r[0]&&t<=n[0]&&e>=r[1]&&e<=n[1]}containsPoint(t){let[e,r]=t,[n,o]=this.min,[a,s]=this.max;return e>=n&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let n=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(yV(n,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let n=t.vertices[e];if(this.containsPoint(n))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Oe.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ts;return t.copy(this),t}};var gV='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',CO=()=>JSON.parse(gV);async function vV(i,t){return await i.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(i.Engine.prototype,"scene")||Object.defineProperty(i.Engine.prototype,"scene",{get:function(){let e=Object.create(i.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>i.Engine.create(e,CO(),!0)}}var $y,eh;function bV(i){$y=i}function GS(){if(!eh){if(!$y)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));eh=$y(),eh.catch(()=>{eh=void 0})}return eh}var TO;function xV(){let i=typeof process<"u"?"2.0.63":void 0;return`https://cdn.spline.design/@splinetool/runtime${i?`@${i}`:""}/build/hana-ui.wasm`}function PO(i){TO=i}function eg(){return $y||bV(async()=>{let t=await import("./hana-ui.js");return vV(t,TO??xV())}),GS().then(()=>{})}var ng=mc(rg(),1);function IO(i){let t=[],e;try{e=(0,ng.makeAbsolute)((0,ng.parseSVG)(i))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,n=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,n=a=c.y,t.push({MoveTo:{x:r,y:n}});break;case"L":r=c.x,n=c.y,t.push({LineTo:{x:r,y:n}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:n}});break;case"V":n=c.y,t.push({LineTo:{x:r,y:n}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*n-s.y}:{x:r,y:n},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*n-l.y}:{x:r,y:n};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"A":{let p=r,h=n;r=c.x,n=c.y,EV(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,n);break}case"Z":r=o,n=a,t.push("ClosePath");break}s=d,l=u}return t}function EV(i,t,e,r,n,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),n=Math.abs(n),r===0||n===0){i.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(n*n);if(g>1){let W=Math.sqrt(g);r*=W,n*=W}let v=r*r,b=n*n,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,A=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),w=A*(r*y)/n,E=A*(-n*m)/r,P=u*w-p*E+(t+l)/2,M=p*w+u*E+(e+c)/2,D=Math.atan2((y-E)/n,(m-w)/r),L=Math.atan2((-y-E)/n,(-m-w)/r)-D;!s&&L>0?L-=2*Math.PI:s&&L<0&&(L+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(L)/(Math.PI/2))),B=L/C,_=4/3*Math.tan(B/4),F=D,k=t,q=e;for(let W=0;W<C;W++){let G=F+B,X=Math.cos(F),z=Math.sin(F),Q=Math.cos(G),K=Math.sin(G),ee=P+r*Q*u-n*K*p,ve=M+r*Q*p+n*K*u,le=-r*z*u-n*X*p,de=-r*z*p+n*X*u,ce=-r*K*u-n*Q*p,me=-r*K*p+n*Q*u;i.push({CurveTo:[{x:k+_*le,y:q+_*de},{x:ee-_*ce,y:ve-_*me},{x:ee,y:ve}]}),F=G,k=ee,q=ve}}var og=.5522847498307936,PV=150,MV=5*60*1e3,OV=1536/2816;function kO(i){let t=i.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return i.getUint32(8)>0?i.getUint32(12):void 0}function DV(i){try{return kO(new DataView(i))!==void 0}catch{return!1}}function IV(i){try{let t=new DataView(i),e=kO(t);if(e===void 0)return;let r=t.getUint16(e+4),n=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(n=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(n<0||o<0)return;let a=t.getUint16(n+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var RO=!1;function BO(){RO||(RO=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var ag=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=Oe.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ve.transparent;this._strokeColor=Ve.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ve.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ve.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await GS(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let n=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-n>MV){clearInterval(o);return}r()&&(clearInterval(o),t())},PV)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let n=await r.arrayBuffer();if(n.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(n,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),DV(t)&&this._engineFonts.add(e);let r=IV(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:Oe.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=Oe.identity();if(this.camera?.enabled&&(r=Oe.append(r,this.camera.worldMatrix),e)){let n=Oe.getScale(this.camera.worldMatrix);r=Oe.scale(r,1/n[0],1/n[1])}this._ctm=Oe.append(r,t)}transform(t){this._ctm=Oe.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,n,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:n},{x:o,y:a}]})}quadraticCurveTo(t,e,r,n){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:n}]})}path(t){this._startFreeform(),this._pathEls.push(...IO(t))}rect(t,e,r,n,o=0,a=0,s=0,l=0){if(!_O([t,e,r,n]))return;let c={x:t,y:e,w:r,h:n,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,FO(this._pathEls,c)}ellipse(t,e,r,n,o,a,s,l){if(!!_O([t,e,r,n])){if(r<0||n<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:n}:null,LV(this._pathEls,t,e,r,n)}}clipRect(t,e,r,n,o=0,a=0,s=0,l=0){let c=Oe.invert(this._ctm);!c||this._clips.push({m:Oe.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:n,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let n=this._applyClips(r);if(n==="skip")return;if(!t&&n!==r){let a=th(r);if(a){this._emitClippedRectStroke(a,e);return}}r=n;let o={shape:r,color:t?wd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,n=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-n,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2,radii:s.map(g=>g>0?g+n:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(ig(l,0));if(p==="skip")return;let h=th(p)??l,f=null;if(u){let g=this._applyClips(ig(u,0));f=g==="skip"?null:th(g)??u}let m=[];FO(m,h),f&&NV(m,f);let y={shape:{Custom:m},color:wd(this._strokeColor),transform:Oe.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?ig(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:wd(this._strokeColor),align:RV[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:wd(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[n,o]=Oe.getScale(this._ctm),a=(n+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[n,o,a,s]=Oe.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[n*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:wd(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let n of this._clips){let o=Oe.append(n.inv,e),[a,s,l,c,d,u]=Oe.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=BV(r);if(!h)return r;if(!p){BO();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,v=Math.min(f,m),b=Math.max(f,m),S=Math.min(y,g),x=Math.max(y,g),A=n.rect,w=Math.max(v,A.x),E=Math.max(S,A.y),P=Math.min(b,A.x+A.w),M=Math.min(x,A.y+A.h);if(w>=P||E>=M)return"skip";if(w===v&&E===S&&P===b&&M===x)continue;let R=th(r);if(!R||a===0||c===0){BO();continue}let L=(w-d)/a,C=(P-d)/a,B=(E-u)/c,_=(M-u)/c,F=Math.min(L,C),k=Math.min(B,_),q=Math.abs(C-L),W=Math.abs(_-B),[G,X,z,Q]=R.radii,K=F!==R.x,ee=k!==R.y,ve=F+q!==R.x+R.w,le=k+W!==R.y+R.h,de=Math.min(q,W)/2,ce=[K||ee?0:Math.min(G,de),ve||ee?0:Math.min(X,de),ve||le?0:Math.min(z,de),K||le?0:Math.min(Q,de)];r=ig({x:F,y:k,w:q,h:W,radii:ce},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),n=this._fontXPerEm.get(e.font),o=!r&&n?n/OV:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:NO[e.horizontalAlign]??"Left",vertical_align:LO[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=Oe.append(this._ctm,Oe.translate(Oe.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?wd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,n=this._measureCache.get(r);if(n!==void 0)return n;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:NO[e.horizontalAlign]??"Left",verticalAlign:LO[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1311
+ `,r.pyramidTextureSize.value=new fe.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=n,this.material.root.shapeBlendhack=n}dispose(){super.dispose(),I2()?.release(this)}},Zp=LS;Zp.streamCompaction=new cy;var iV=new fe.Matrix4,oV=new fe.Matrix4,Sd=new fe.Quaternion,Ll=new fe.Vector3,Ky=new fe.Vector3,aV=new fe.Quaternion;function sV(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Pa.is(r)&&dO.call(r,i,t+1)}}function dO(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let n=this.children[r];Pa.is(n)&&dO.call(n,i,t+1)}}}function lV(){if(this.shapesDataTexture.value===void 0){let y=new fe.DataTexture(new Float32Array(4*Ir*Ma),Ir,Ma,fe.RGBAFormat,fe.FloatType);this.shapesDataTexture.value=y}let i=this.shapesDataTexture.value,t=i.image.data,e=0,r=0,n=this.data.geometry.blendRange,o=iV.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(sV.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof Fn)return;if(y instanceof gd||Ap(y))return;y instanceof Dr?g=y.object:g=y;let v=y.data?.cloner;if(Le.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof tt))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(oV.multiplyMatrices(o,y.matrixWorld).decompose(Ky,Sd,Ll),b?.type==="TorusGeometry"&&b.arc!==360){let C=b.arc*Math.PI/180;C=C/4,Sd.multiply(aV.set(0,0,Math.sin(C),Math.cos(C)))}let A=S.overrideGlobalBlend?S.blendRange:n;A=A/this.bboxSize*2,t[s*4]=(Ky.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Ky.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Ky.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[Ir*4+s*4]=-Sd.x,t[Ir*4+s*4+1]=-Sd.y,t[Ir*4+s*4+2]=-Sd.z,t[Ir*4+s*4+3]=Sd.w;let w=new Float32Array(4),E=0,P=A;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?w[0]=0:w[0]=1,w[1]=b.width/this.bboxSize,w[2]=b.height/this.bboxSize,w[3]=b.depth/this.bboxSize,P=Math.max(w[1],w[2],w[3])*Ll.x+A;else if(b?.type==="CubeGeometry"){E=b.cornerRadius;let C=b.width,B=b.height,_=b.depth;w[0]=2,w[1]=(C-2*E)/this.bboxSize,w[2]=(B-2*E)/this.bboxSize,w[3]=(_-2*E)/this.bboxSize,P=Math.sqrt(C**2+B**2+_**2)/this.bboxSize*Ll.x+A}else if(b?.type==="CylinderGeometry"){E=b.cornerRadius;let C=b.height,B=b.radiusBottom,_=b.radiusTop;if(_>=B){let F=Math.atan2(_-B,C),k=(Math.PI/2-F)/2;_-=E/Math.tan(k),B-=E*Math.tan(k)}else if(B>_){let F=Math.atan2(B-_,C),k=(Math.PI/2-F)/2;_-=E*Math.tan(k),B-=E/Math.tan(k)}w[1]=(b.height-2*E)/this.bboxSize,B===_?(w[0]=3,w[2]=B/this.bboxSize*2):(w[0]=4,w[2]=B/this.bboxSize*2,w[3]=_/this.bboxSize*2),P=(Math.hypot(w[1],Math.max(Math.abs(w[2]),Math.abs(w[3])))+E/this.bboxSize*2)*Ll.x+A}else if(b?.type==="TorusGeometry"){if(w[0]=5,w[1]=(b.width-b.depth)/this.bboxSize,w[2]=b.depth/this.bboxSize,b.arc!==360){w[0]=6,w[3]=w[1],t[Ir*12+s*4+3]=w[2];let C=2*Math.atan2(w[2]/2,w[1]),B=b.arc*Math.PI/180/2-C;w[1]=Math.sin(B),w[2]=Math.cos(B)}P=b.width*Ll.x/this.bboxSize+A}else{let C=g.geometry;(l??(l=new Set)).add(C.uuid);let B=this._meshSdfBaked.get(C.uuid),_=nV(C);if((B===void 0||B.posVersion!==_)&&this._meshSdfWanted.set(C.uuid,C),B===void 0)return;w[0]=7,w[1]=B.slot,w[2]=B.boxHalf.x/this.bboxSize*2,w[3]=B.boxHalf.y/this.bboxSize*2,t[Ir*12+s*4+3]=B.boxHalf.z/this.bboxSize*2,P=Math.hypot(B.boxHalf.x,B.boxHalf.y,B.boxHalf.z)/this.bboxSize*2*Ll.x+A}t.set(w,Ir*8+s*4),e=Math.max(e,P),r=Math.max(r,A),this._reach[s]=P,t[Ir*12+s*4]=A,t[Ir*12+s*4+1]=E/this.bboxSize*2,t[Ir*12+s*4+2]=Ll.x;let M=Array.isArray(g.material)?g.material[0]:g.material,D=M,R,L;if(D?.getShapeBlendBaseColor){let C=D.getShapeBlendBaseColor();R=C,L=C.a}else M?.uniforms?.nodeU0!==void 0?(R=M.uniforms.nodeU0.node.value,L=M.uniforms.nodeU1?.value??1):(R={r:1,g:1,b:1},L=1);S.operation!==0&&!S.useColor&&(L=-1),t[Ir*16+s*4]=R.r,t[Ir*16+s*4+1]=R.g,t[Ir*16+s*4+2]=R.b,t[Ir*16+s*4+3]=L,L<1&&this.material.defines?.SHAPEBLEND_C===1&&this.material.setTransparent(!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||NS,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let D=0;D<Ma;D++){let R=Ir*4*D+g*4;if(t[R]!==d[R]||t[R+1]!==d[R+1]||t[R+2]!==d[R+2]||t[R+3]!==d[R+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],A=d[g*4],w=d[g*4+1],E=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+P)||!Number.isFinite(A+w+E+M)){h=!0;continue}f.x=Math.min(f.x,b-P,A-M),f.y=Math.min(f.y,S-P,w-M),f.z=Math.min(f.z,x-P,E-M),m.x=Math.max(m.x,b+P,A+M),m.y=Math.max(m.y,S+P,w+M),m.z=Math.max(m.z,x+P,E+M)}}return NS&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,i.needsUpdate=!0),p}Oi("ShapeBlendGeometry",(i,t,e)=>new Zp(i,t,e));Pe("shape-blends");var Zy=class extends tt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Dp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Oi("VectorGeometry",(i,t,e)=>new Zy(i,t,e));Pe("vector-shapes");var Jy=class extends tt{constructor(e,r,n){super(e,r,n);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=n}get profileShape(){return this._lastShape??void 0}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=dd;break;case"Ellipse":o=ld;break;case"Polygon":o=Ty;break;case"Star":o=Py;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let n=this.geometry;if(r&&n.inputs){if(this._lastShape=r,e.type==="Custom"&&(this._lastShapeParams=null),n.inputs.shapeData===r)return;n.inputs.shapeData=r,n.build()}}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let n in e)if(!Object.is(e[n],r[n]))return!1;for(let n in r)if(!(n in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let n=this.geometry.getAttribute("position");n!==void 0&&n.count>0?Dp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var ke=require("three");function uO(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var pO=new ke.Matrix4,cV=new ke.Matrix4,dV=new ke.Matrix4().makeScale(1,1,-1),hO=new ke.Vector3,fO=new ke.Vector3,_S=new ke.Vector3,uV=new ke.Vector3,pV=new ke.Vector3,hV=new ke.Vector3,fV=new ke.Vector3,mO=new WeakMap,FS=new WeakMap;function mV(i,t,e){let r=[new ke.Vector3,new ke.Vector3,new ke.Vector3],n=[new ke.Vector3,new ke.Vector3,new ke.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((o,a)=>{let s=n[a],l=ke.MathUtils.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new ke.Matrix4().makeBasis(r[0],r[1],r[2])}function yO(i){i.setIndex(null),i.setAttribute("position",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("normal",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("uv",new ke.BufferAttribute(new Float32Array(0),2)),i.setDrawRange(0,0)}var gO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shapeData??t?.shapeData??ld.create({parameters:{...hl,width:typeof hl.width=="number"?hl.width:100,height:typeof hl.height=="number"?hl.height:100}}).userData.shape;return{ownerId:i.ownerId??t?.ownerId,path:i.path??Pc.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:o,extrusion:{...vm,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new kS(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else{let e=new ke.BufferGeometry;return yO(e),Object.assign(e,{userData:{...i,type:"PathGeometry"}})}}},kS=class extends ke.BufferGeometry{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)||!uO(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){yO(this);return}let{depth:n,offset:o}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((n+o)*a):Math.ceil(Math.min(1,n+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let z=0;z<c;z++){let Q=this.inputs.path.isClosed?(z+s)%e.length:Math.min(z+s,e.length-1);d.push(e[Q].clone()),u.push(r[Q].clone())}let p=(z,Q,K)=>{d[z]=d[z].clone().lerp(d[Q],K),u[z]=mV(u[z],u[Q],K)},h=0,f=o*a%1;(!this.inputs.path.isClosed||n<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+n)*a%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&o+n<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),n===0){let z=d.length-1;d[z].copy(d[0]),u[z].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:x,vertices:A}=this._getShapePoints(b),w=g>0?this.inputs.parameters.extrusion.capType:"flat",E=w==="round"?gM(this.inputs.shapeData,g,v,b,this.inputs.ownerId):void 0,P=w==="round"&&E===void 0?"flat":w,M=E!==void 0?E.positions.length/3:0,D=0,R=0;x.sort((z,Q)=>z.start-Q.start),x.forEach(z=>{z.verticesStart=D,z.verticesCount=z.continuous.reduce((Q,K,ee)=>Q+(ee===0||!K?2:1),0),R+=z.verticesCount,D=R});let L=R*c,C,B=0;this._isOpenEnded()&&P==="flat"&&(C=this._getSurfaceTesselation(S),B=C.vertexCount);let _=L+2*B+M*2,F=L+2*B,k={positions:new Float32Array(_*3),normals:new Float32Array(_*3),uvs:new Float32Array(_*2)},q=0;x.forEach(z=>{q+=z.count});let W=q*(c-1)*6+(C?2*C.elementCount*3:0)+(E!==void 0?2*E.indices.length:0),G=new Uint32Array(W),X=0;if(x.forEach(z=>{X=this._extrudeRegion(z,A,u,d,k,G,X,this._isGeometryClosed()&&!this._isOpenEnded())}),C&&(X=this._closeEnd(C,L,G,X,k,u[0],d[0],!1),X=this._closeEnd(C,L+B,G,X,k,u[u.length-1],d[d.length-1],!0)),E!==void 0){let z={positions:k.positions,normals:k.normals,uvs:k.uvs,indices:G};Vp(E,z,F,X,pO.copy(u[0]).setPosition(d[0]).multiply(dV),(Q,K,ee)=>[ee,1e-4]),X+=E.indices.length,F+=M,Vp(E,z,F,X,pO.copy(u[u.length-1]).setPosition(d[d.length-1]),(Q,K,ee)=>[ee,1]),X+=E.indices.length}this.setAttribute("position",new ke.BufferAttribute(k.positions,3)),this.setAttribute("normal",new ke.BufferAttribute(k.normals,3)),this.setAttribute("uv",new ke.BufferAttribute(k.uvs,2)),this._setIndexFromUint32(G)}_setIndexFromUint32(e){let r=!1;for(let n=e.length-1;n>=0;--n)if(e[n]>=65535){r=!0;break}this.setIndex(new ke.BufferAttribute(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=jm(e),n=mO.get(r);if(n===void 0||n.subdivisions!==e.subdivisions||n.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);n={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},mO.set(r,n)}return n}_extractPathPoints(e){let r=this.inputs.path.subdivisions,n=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(n.length<2)return[];let o=[n[0]];return n.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],n=e.length,o=this.inputs.path.isClosed,a=new ke.Vector3,s=new ke.Vector3,l=new ke.Vector3,c=new ke.Vector3,d=new ke.Vector3(0,1,0);for(let y=0;y<n;y++){let g=e[y],v;y===0?v=o?e[n-1]:hO.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===n-1?b=o?e[0]:hO.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],fO.subVectors(g,v).normalize(),_S.subVectors(b,g).normalize();let S=uV.addVectors(fO,_S);S.lengthSq()<1e-10&&(S.copy(_S),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||pV.copy(S).negate().equals(d))&&d.set(0,0,1);let x=hV.crossVectors(d,S).normalize(),A=fV.crossVectors(S,x).normalize();d.copy(A),c.copy(x),y===0&&(a.copy(A),s.copy(S));let w=new ke.Matrix4().makeBasis(x,A,S);r.push(w)}let u=o?s:l,p=o?a:new ke.Vector3(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(cV.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,n){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new ke.Matrix4,u=new ke.Matrix4;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(n===0?0:1)-(r+(1-n)));d.makeRotationZ(ke.MathUtils.lerp(a,a+s,f)*ke.MathUtils.DEG2RAD);let m=ke.MathUtils.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=Ct.ODD){let n=this.inputs.shapeData,o=FS.get(n);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},FS.set(n,o)),o.shapePoints}_getSurfaceTesselation(e){let r=FS.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let n;try{n=Ss({windingRule:Ct.ODD,elementType:_r.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{n=Sy}return r!==void 0&&(r.surfaceTesselation=n),n}_computeShapePoints(e=12,r=Ct.ODD){let n=this.inputs.shapeData,o=n.extractShapePointsToFlatArray([],e),a=n.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=Ss({windingRule:r,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=xy}let l;try{l=Ss({windingRule:Ct.ODD,elementType:_r.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=dM}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let A=v,w=S-1,E=v+1,P=n.roundedCurves.length;do{let M=A-v,D=s.vertices[w*2+0],R=s.vertices[w*2+1],L=s.vertices[A*2+0],C=s.vertices[A*2+1],B=s.vertices[E*2+0],_=s.vertices[E*2+1],F=L-D,k=C-R,q=Math.sqrt(F*F+k*k);F/=q,k/=q;let W=L-B,G=C-_,X=Math.sqrt(W*W+G*G);W/=X,G/=X,x.normals[M*2+0]=-G,x.normals[M*2+1]=W;let z=s.vertexIndices[A];if(Array.isArray(z))x.continuous[M]=!1;else{let[Q,K]=n.getCurveIndexFromVertexId(z-1,!0);if(K>0&&K<1)x.continuous[M]=!0;else{let ee=K===1?Q+1:Q-1;ee=(ee+P)%P;let ve=K===1?0:1,le=n.roundedCurves[Q].getTangent(K),de=n.roundedCurves[ee].getTangent(ve);x.continuous[M]=le.dot(de)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[w,A,E]=[A,E,E+1],E>=S&&(E-=b)}while(E!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,n,o,a){let s=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,n,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,A=r[x+0],w=r[x+1],E,P;if(e.continuous[S])E=e.normals[S*2+0],P=e.normals[S*2+1];else{let D=S===0?(e.start+e.count-1)*2:x-2,R=A-r[D+0];E=-(w-r[D+1]),P=R,e.isHole||(E=-E,P=-P)}let M=S===0?1:S/e.count;if(d.push(A,w,E,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(A,w,e.normals[0],e.normals[1],0,1);else{let D=S===e.count-1?e.start*2:x+2,R=r[D+0]-A;E=-(r[D+1]-w),P=R,e.isHole||(E=-E,P=-P),d.push(A,w,E,P,M,1)}}e.wallTemplate=d}let u=n.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=n[S].elements,A=x[0],w=x[1],E=x[2],P=x[4],M=x[5],D=x[6],R=x[12],L=x[13],C=x[14],B=o[S],_=S/(u-1),F=0,k=0,q=0,W=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let ce=d[G+0],me=d[G+1];F=A*ce+P*me+R+B.x,k=w*ce+M*me+L+B.y,q=E*ce+D*me+C+B.z}let X=d[G+2],z=d[G+3],Q=A*X+P*z+R,K=w*X+M*z+L,ee=E*X+D*z+C,ve=1/(Math.sqrt(Q*Q+K*K+ee*ee)||1);Q*=ve,K*=ve,ee*=ve;let le=W*2,de=W*3;h[de+0]=F,h[de+1]=k,h[de+2]=q,f[de+0]=Q,f[de+1]=K,f[de+2]=ee,m[le+0]=d[G+4],m[le+1]=_,W++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,A=x+e.verticesCount;for(let w=0;w<v;w+=2){let E=x+y[w],P=x+y[w+1],M=A+y[w+1],D=A+y[w];b?(s[l++]=E,s[l++]=M,s[l++]=P,s[l++]=E,s[l++]=D,s[l++]=M):(s[l++]=E,s[l++]=P,s[l++]=M,s[l++]=E,s[l++]=M,s[l++]=D)}}return l}_closeEnd(e,r,n,o,a,s,l,c){let d=e.vertexCount,u=new ke.Vector3(0,0,c?-1:1).applyMatrix4(s),p=new ke.Vector3,h=new ke.Vector2;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;n[o++]=f[y+0]+r,n[o++]=f[y+(c?1:2)]+r,n[o++]=f[y+(c?2:1)]+r}return o}};Oi("PathGeometry",(i,t,e)=>new Jy(i,t,e));Ep("PathGeometry",gO);Pe("3d-paths");Mi.Cloner=Fn;Pe("cloners");gt();var Ad=require("three");function Jp(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Le.is(e)&&Jp(e)}}var $p=class extends ki(Ad.Group,Fi){constructor(e,r,n){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),this.super_Entity(e,r),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,r){let n=fs.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let o,a;for(let s of No.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=n.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Mo.apply(n.data[s],e[s]));return this.overrideData=a,o}else return{...mr.defaultData,...e,...xp(mr.defaultData,No.rootOverrideProps)}}updateByOp(e,r,n,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let s of No.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&&No.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,n,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,o=!1;if(n!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Jp(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(n){let a={};bO(e,[this.uuid],r.overrides,this,n,n,0,o,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof tt&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new Ad.Matrix4().fromArray(m)),f=new Ad.Skeleton(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function vO(i,t,e,r){return i.component===t&&so(i.identity,r)?i.overrideData===e?2:1:0}function bO(i,t,e,r,n,o,a,s,l){if(a>50)return!1;if(r.component!==n){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}n.instances.find(d=>d===r)||n.instances.push(r),r.component=n}n instanceof $p&&n.isInstanceRoot&&n.expandInstanceChildren(i);let c=0;for(let d of n.children)if(Le.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=Oc.resolve(e,u,1);p!=null&&!(p instanceof kt)&&(Object.setPrototypeOf(p,kt.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Le.is(m)?m:null,h!==null){let y=vO(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=i.scene.findInstance(u)??null,h!==null)){let y=vO(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),i.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Mo.apply(d.data,p):d.data;no.is(m.type)&&(m={...m,type:"Empty"}),h=Mi.createEntity(u,m,i),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,i),f&&h.changeSelectedState(f,i),i.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,bO(i,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Le.is(u))i.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var xO=(i,t,e)=>new $p(i,t,e);xl("Component",xO);xl("Instance",xO);Pe("components");var VS=1e-10;function SO(i){let t=i[0][0],e=i[1][0],r=i[0][1],n=i[1][1],o=Math.sqrt(t*t+e*e),a=o>VS?t/o:1,s=o>VS?e/o:0,l=a*t+s*e,c=a*n-s*r,d=a*r+s*n;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>VS?d/c:0,0]}}function AO({rotation:i,scale:t,shear:e}){let r=Math.cos(i),n=Math.sin(i),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-n*a,n*t[0]+r*a,r*o-n*t[1],n*o+r*t[1]]}var Oe;(x=>{function i(){return[1,0,0,0,1,0,0,0,1]}x.identity=i;function t(A,w=x.identity()){for(let E=0,P=A.length;E<P;E++)w[E]=A[E];return w}x.copy=t;function e(A,w,E,P,M,D){return x.setAbcdef(x.identity(),A,w,E,P,M,D)}x.create=e;function r(A,w,E,P,M,D,R){return A[0]=w,A[1]=P,A[2]=D,A[3]=E,A[4]=M,A[5]=R,A}x.setAbcdef=r;function n(A,w){let[E,P,M,D,R,L]=a(A),[C,B,_,F,k,q]=a(w),W=C*E+B*M,G=C*P+B*D,X=_*E+F*M,z=_*P+F*D,Q=k*E+q*M+R,K=k*P+q*D+L;return x.create(W,G,X,z,Q,K)}x.append=n;function o(A,w){let[E,P,M,D,R,L]=a(A),[C,B,_,F,k,q]=a(w),W=E,G=P,X=M,z=D;(C!==1||B!==0||_!==0||F!==1)&&(W=E*C+P*_,G=E*B+P*F,X=M*C+D*_,z=M*B+D*F);let Q=R*C+L*_+k,K=R*B+L*F+q;return x.create(W,G,X,z,Q,K)}x.prepend=o;function a(A){return[A[0],A[3],A[1],A[4],A[2],A[5]]}x.getAbcdef=a;function s(A){let[w,E,P,M,D,R]=x.getAbcdef(A),L=w*M-E*P,C=M/L,B=-E/L,_=-P/L,F=w/L,k=(P*R-M*D)/L,q=-(w*R-E*D)/L;return x.create(C,B,_,F,k,q)}x.invert=s;function l([A,w],E){let[P,M,D,R,L,C]=x.getAbcdef(E);return[P*A+D*w+L,M*A+R*w+C]}x.apply=l;function c(A,w){let[E,P,M,D,R,L]=x.getAbcdef(w),C=1/(E*D+M*-P),[B,_]=A;return[D*C*B+-M*C*_+(L*M-R*D)*C,E*C*_+-P*C*B+(-L*E+R*P)*C]}x.applyInverse=c;function d(A,w,E=w){let[P,M,D,R,L,C]=x.getAbcdef(A);return x.setAbcdef(A,P*w,M*E,D*w,R*E,L*w,C*E),A}x.scale=d;function u(A,w){let E=Math.cos(w),P=Math.sin(w),[M,D,R,L,C,B]=x.getAbcdef(A);return x.setAbcdef(A,M*E-D*P,M*P+D*E,R*E-L*P,R*P+L*E,C*E-B*P,C*P+B*E),A}x.rotate=u;function p(A,w,E){let[P,M]=E,D=x.translate(A,-P,-M);return D=x.rotate(D,w),D=x.translate(D,P,M),D}x.rotateAround=p;function h(A,w,E){let[P,M,D,R,L,C]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,L+w,C+E),A}x.translate=h;function f(A,w,E){let[P,M,D,R]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,w,E),A}x.setTranslate=f;function m(A,w,E){let[P,M,D,R]=x.getAbcdef(A);return x.setAbcdef(A,P,M,D,R,w,E),A}x.setPosition=m;function y(A){let[w,E,P,M]=x.getAbcdef(A),D=Math.sqrt(w*w+E*E),R=Math.sqrt(P*P+M*M);return[D,R]}x.getScale=y;function g(A){let[,,,,w,E]=x.getAbcdef(A);return[w,E]}x.getPosition=g;function v(A,w){return x.decompose(A,w).rotation}x.getRotation=v;function b(A,w){let[E,P,M,D,R,L]=x.getAbcdef(A),{rotation:C,scale:B,shear:_}=SO([[E,M],[P,D]]);return{position:[R+(w[0]*E+w[1]*M)-w[0],L+(w[0]*P+w[1]*D)-w[1]],scale:B,rotation:C,shear:_,pivot:w}}x.decompose=b;function S(A,w,E,P,M=[0,0]){let[D,R]=A,[L,C]=P,[B,_,F,k]=AO({rotation:E,scale:w,shear:M}),q=D-(L*B+C*F)+L,W=R-(L*_+C*k)+C;return x.create(B,_,F,k,q,W)}x.compose=S})(Oe||(Oe={}));function yV(i,t){let[[e,r],[n,o]]=i,[[a,s],[l,c]]=t,d=(e-n)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-n)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var EO=[[-1,1],[-1,-1],[1,-1],[1,1]],wO=(i,t,e)=>{let r=i.getCenter(),n=i.getHalfSize(),o=Oe.append(t,i.worldMatrix);n[0]===0&&n[1]===0?e.push(Oe.apply(r,o)):EO.forEach(a=>{let s=[a[0]*n[0]+r[0],a[1]*n[1]+r[1]];e.push(Oe.apply(s,o))})},Ts=class{constructor(){this.matrix=Oe.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Oe.copy(t.worldMatrix,this.matrix);let r=Oe.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let n=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&wO(a,e,n)}):wO(t,e,n),this.setFromPoints(n)}setFromSize(t,e,r){this.makeEmpty(),Oe.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Oe.apply([0,0],r),Oe.apply([0,e],r),Oe.apply([t,e],r),Oe.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,n]=this.getHalfSize();return Oe.apply([t+r,e+n],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(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[n,o,a,s]=Oe.getAbcdef(this.matrix),l=Oe.create(n,o,a,s,r[0],r[1]);this.vertices=EO.map(([c,d])=>Oe.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:n}=this;return t>=r[0]&&t<=n[0]&&e>=r[1]&&e<=n[1]}containsPoint(t){let[e,r]=t,[n,o]=this.min,[a,s]=this.max;return e>=n&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let n=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(yV(n,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let n=t.vertices[e];if(this.containsPoint(n))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Oe.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ts;return t.copy(this),t}};var gV='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',CO=()=>JSON.parse(gV);async function vV(i,t){return await i.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(i.Engine.prototype,"scene")||Object.defineProperty(i.Engine.prototype,"scene",{get:function(){let e=Object.create(i.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>i.Engine.create(e,CO(),!0)}}var $y,eh;function bV(i){$y=i}function GS(){if(!eh){if(!$y)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));eh=$y(),eh.catch(()=>{eh=void 0})}return eh}var TO;function xV(){let i=typeof process<"u"?"2.0.65":void 0;return`https://cdn.spline.design/@splinetool/runtime${i?`@${i}`:""}/build/hana-ui.wasm`}function PO(i){TO=i}function eg(){return $y||bV(async()=>{let t=await import("./hana-ui.js");return vV(t,TO??xV())}),GS().then(()=>{})}var ng=mc(rg(),1);function IO(i){let t=[],e;try{e=(0,ng.makeAbsolute)((0,ng.parseSVG)(i))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,n=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,n=a=c.y,t.push({MoveTo:{x:r,y:n}});break;case"L":r=c.x,n=c.y,t.push({LineTo:{x:r,y:n}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:n}});break;case"V":n=c.y,t.push({LineTo:{x:r,y:n}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*n-s.y}:{x:r,y:n},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*n-l.y}:{x:r,y:n};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"A":{let p=r,h=n;r=c.x,n=c.y,EV(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,n);break}case"Z":r=o,n=a,t.push("ClosePath");break}s=d,l=u}return t}function EV(i,t,e,r,n,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),n=Math.abs(n),r===0||n===0){i.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(n*n);if(g>1){let W=Math.sqrt(g);r*=W,n*=W}let v=r*r,b=n*n,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,A=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),w=A*(r*y)/n,E=A*(-n*m)/r,P=u*w-p*E+(t+l)/2,M=p*w+u*E+(e+c)/2,D=Math.atan2((y-E)/n,(m-w)/r),L=Math.atan2((-y-E)/n,(-m-w)/r)-D;!s&&L>0?L-=2*Math.PI:s&&L<0&&(L+=2*Math.PI);let C=Math.max(1,Math.ceil(Math.abs(L)/(Math.PI/2))),B=L/C,_=4/3*Math.tan(B/4),F=D,k=t,q=e;for(let W=0;W<C;W++){let G=F+B,X=Math.cos(F),z=Math.sin(F),Q=Math.cos(G),K=Math.sin(G),ee=P+r*Q*u-n*K*p,ve=M+r*Q*p+n*K*u,le=-r*z*u-n*X*p,de=-r*z*p+n*X*u,ce=-r*K*u-n*Q*p,me=-r*K*p+n*Q*u;i.push({CurveTo:[{x:k+_*le,y:q+_*de},{x:ee-_*ce,y:ve-_*me},{x:ee,y:ve}]}),F=G,k=ee,q=ve}}var og=.5522847498307936,PV=150,MV=5*60*1e3,OV=1536/2816;function kO(i){let t=i.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return i.getUint32(8)>0?i.getUint32(12):void 0}function DV(i){try{return kO(new DataView(i))!==void 0}catch{return!1}}function IV(i){try{let t=new DataView(i),e=kO(t);if(e===void 0)return;let r=t.getUint16(e+4),n=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(n=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(n<0||o<0)return;let a=t.getUint16(n+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var RO=!1;function BO(){RO||(RO=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var ag=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=Oe.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ve.transparent;this._strokeColor=Ve.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ve.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ve.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await GS(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let n=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-n>MV){clearInterval(o);return}r()&&(clearInterval(o),t())},PV)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let n=await r.arrayBuffer();if(n.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(n,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),DV(t)&&this._engineFonts.add(e);let r=IV(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:Oe.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=Oe.identity();if(this.camera?.enabled&&(r=Oe.append(r,this.camera.worldMatrix),e)){let n=Oe.getScale(this.camera.worldMatrix);r=Oe.scale(r,1/n[0],1/n[1])}this._ctm=Oe.append(r,t)}transform(t){this._ctm=Oe.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,n,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:n},{x:o,y:a}]})}quadraticCurveTo(t,e,r,n){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:n}]})}path(t){this._startFreeform(),this._pathEls.push(...IO(t))}rect(t,e,r,n,o=0,a=0,s=0,l=0){if(!_O([t,e,r,n]))return;let c={x:t,y:e,w:r,h:n,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,FO(this._pathEls,c)}ellipse(t,e,r,n,o,a,s,l){if(!!_O([t,e,r,n])){if(r<0||n<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:n}:null,LV(this._pathEls,t,e,r,n)}}clipRect(t,e,r,n,o=0,a=0,s=0,l=0){let c=Oe.invert(this._ctm);!c||this._clips.push({m:Oe.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:n,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let n=this._applyClips(r);if(n==="skip")return;if(!t&&n!==r){let a=th(r);if(a){this._emitClippedRectStroke(a,e);return}}r=n;let o={shape:r,color:t?wd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,n=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-n,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2,radii:s.map(g=>g>0?g+n:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(ig(l,0));if(p==="skip")return;let h=th(p)??l,f=null;if(u){let g=this._applyClips(ig(u,0));f=g==="skip"?null:th(g)??u}let m=[];FO(m,h),f&&NV(m,f);let y={shape:{Custom:m},color:wd(this._strokeColor),transform:Oe.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?ig(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:wd(this._strokeColor),align:RV[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:wd(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[n,o]=Oe.getScale(this._ctm),a=(n+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[n,o,a,s]=Oe.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[n*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:wd(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let n of this._clips){let o=Oe.append(n.inv,e),[a,s,l,c,d,u]=Oe.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=BV(r);if(!h)return r;if(!p){BO();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,v=Math.min(f,m),b=Math.max(f,m),S=Math.min(y,g),x=Math.max(y,g),A=n.rect,w=Math.max(v,A.x),E=Math.max(S,A.y),P=Math.min(b,A.x+A.w),M=Math.min(x,A.y+A.h);if(w>=P||E>=M)return"skip";if(w===v&&E===S&&P===b&&M===x)continue;let R=th(r);if(!R||a===0||c===0){BO();continue}let L=(w-d)/a,C=(P-d)/a,B=(E-u)/c,_=(M-u)/c,F=Math.min(L,C),k=Math.min(B,_),q=Math.abs(C-L),W=Math.abs(_-B),[G,X,z,Q]=R.radii,K=F!==R.x,ee=k!==R.y,ve=F+q!==R.x+R.w,le=k+W!==R.y+R.h,de=Math.min(q,W)/2,ce=[K||ee?0:Math.min(G,de),ve||ee?0:Math.min(X,de),ve||le?0:Math.min(z,de),K||le?0:Math.min(Q,de)];r=ig({x:F,y:k,w:q,h:W,radii:ce},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),n=this._fontXPerEm.get(e.font),o=!r&&n?n/OV:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:NO[e.horizontalAlign]??"Left",vertical_align:LO[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=Oe.append(this._ctm,Oe.translate(Oe.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?wd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,n=this._measureCache.get(r);if(n!==void 0)return n;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:NO[e.horizontalAlign]??"Left",verticalAlign:LO[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
1312
1312
  `))c+=Math.max(1,Math.ceil(d.length/l));o=c*e.fontSize*e.lineHeight}return this._measureCache.size>512&&this._measureCache.clear(),this._measureCache.set(r,o),o}clear(){this._shapes=[],this._ctm=Oe.identity(),this._stack.length=0,this._clips.length=0}render(){let t=this._engine;if(!t||this._crashed)return;let e=JSON.stringify(this._shapes);e!==this._lastPushedJSON&&(this._guard(()=>t.scene.updateUiShapes(this._shapes)),this._lastPushedJSON=e),this._guard(()=>t.onFrame())}},RV={inside:"Inside",outside:"Outside",center:"Center"},NO={[1]:"Left",[2]:"Right",[3]:"Center",[4]:"Justify"},LO={[1]:"Top",[2]:"Center",[3]:"Bottom"};function wd({r:i,g:t,b:e,a:r}){return[i,t,e,r]}function _O(i){for(let t=0;t<i.length;t++)if(i[t]!==void 0&&!Number.isFinite(i[t]))return!1;return!0}function ig(i,t){let[e,r,n,o]=i.radii;return e===0&&r===0&&n===0&&o===0?{Rectangle:{x:i.x,y:i.y,width:i.w,height:i.h}}:{RoundedRectangle:{x:i.x,y:i.y,width:i.w,height:i.h,radius:[e,r,n,o],corner_smoothing:t}}}function th(i){if("Rectangle"in i){let t=i.Rectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[0,0,0,0]}}if("RoundedRectangle"in i){let t=i.RoundedRectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[t.radius[0],t.radius[1],t.radius[2],t.radius[3]]}}return null}function BV(i){let t=th(i);if(t)return{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h};if("Ellipse"in i){let e=i.Ellipse;return{minX:e.center_x-e.rx,minY:e.center_y-e.ry,maxX:e.center_x+e.rx,maxY:e.center_y+e.ry}}if("TextSimple"in i){let e=i.TextSimple;return{minX:0,minY:0,maxX:e.size[0],maxY:e.size[1]}}if("Custom"in i){let e=1/0,r=1/0,n=-1/0,o=-1/0,a=s=>{s.x<e&&(e=s.x),s.y<r&&(r=s.y),s.x>n&&(n=s.x),s.y>o&&(o=s.y)};for(let s of i.Custom)s!=="ClosePath"&&("MoveTo"in s?a(s.MoveTo):"LineTo"in s?a(s.LineTo):"QuadTo"in s?s.QuadTo.forEach(a):"CurveTo"in s&&s.CurveTo.forEach(a));return e===1/0?null:{minX:e,minY:r,maxX:n,maxY:o}}return null}function FO(i,t){let{x:e,y:r,w:n,h:o}=t,a=Math.min(n,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){i.push({MoveTo:{x:e,y:r}},{LineTo:{x:e+n,y:r}},{LineTo:{x:e+n,y:r+o}},{LineTo:{x:e,y:r+o}},"ClosePath");return}let u=1-og;i.push({MoveTo:{x:e+s,y:r}}),i.push({LineTo:{x:e+n-l,y:r}}),l>0&&i.push({CurveTo:[{x:e+n-l*u,y:r},{x:e+n,y:r+l*u},{x:e+n,y:r+l}]}),i.push({LineTo:{x:e+n,y:r+o-c}}),c>0&&i.push({CurveTo:[{x:e+n,y:r+o-c*u},{x:e+n-c*u,y:r+o},{x:e+n-c,y:r+o}]}),i.push({LineTo:{x:e+d,y:r+o}}),d>0&&i.push({CurveTo:[{x:e+d*u,y:r+o},{x:e,y:r+o-d*u},{x:e,y:r+o-d}]}),i.push({LineTo:{x:e,y:r+s}}),s>0&&i.push({CurveTo:[{x:e,y:r+s*u},{x:e+s*u,y:r},{x:e+s,y:r}]}),i.push("ClosePath")}function NV(i,t){let{x:e,y:r,w:n,h:o}=t,a=Math.min(n,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){i.push({MoveTo:{x:e,y:r}},{LineTo:{x:e,y:r+o}},{LineTo:{x:e+n,y:r+o}},{LineTo:{x:e+n,y:r}},"ClosePath");return}let u=1-og;i.push({MoveTo:{x:e+s,y:r}}),s>0&&i.push({CurveTo:[{x:e+s*u,y:r},{x:e,y:r+s*u},{x:e,y:r+s}]}),i.push({LineTo:{x:e,y:r+o-d}}),d>0&&i.push({CurveTo:[{x:e,y:r+o-d*u},{x:e+d*u,y:r+o},{x:e+d,y:r+o}]}),i.push({LineTo:{x:e+n-c,y:r+o}}),c>0&&i.push({CurveTo:[{x:e+n-c*u,y:r+o},{x:e+n,y:r+o-c*u},{x:e+n,y:r+o-c}]}),i.push({LineTo:{x:e+n,y:r+l}}),l>0&&i.push({CurveTo:[{x:e+n,y:r+l*u},{x:e+n-l*u,y:r},{x:e+n-l,y:r}]}),i.push("ClosePath")}function LV(i,t,e,r,n){let o=r*og,a=n*og;i.push({MoveTo:{x:t+r,y:e}},{CurveTo:[{x:t+r,y:e+a},{x:t+o,y:e+n},{x:t,y:e+n}]},{CurveTo:[{x:t-o,y:e+n},{x:t-r,y:e+a},{x:t-r,y:e}]},{CurveTo:[{x:t-r,y:e-a},{x:t-o,y:e-n},{x:t,y:e-n}]},{CurveTo:[{x:t+o,y:e-n},{x:t+r,y:e-a},{x:t+r,y:e}]},"ClosePath")}function VO(i){let t=!1;return i.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var _V=Math.PI/180,pne=180/Math.PI;function GO(i,t,e,r,n,o){let a=i-e,s=t-r;return a*a/(n*n)+s*s/(o*o)<=1}function UO(i){return i*_V}gt();function _a(i){return{all:i=i||new Map,on:function(t,e){var r=i.get(t);r?r.push(e):i.set(t,[e])},off:function(t,e){var r=i.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var r=i.get(t);r&&r.slice().map(function(n){n(e)}),(r=i.get("*"))&&r.slice().map(function(n){n(t,e)})}}}var Fa=class{constructor(t,e,r){this.uuid=t;this.data=e;this.isObject2D=!0;this.localMatrix=Oe.identity();this.worldMatrix=Oe.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Ts;this._recursiveBBox=new Ts;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=_a();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r,n=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),n)}intersectsInLocalSpace(t,e,r=!1){let{min:n,max:o}=r?this.recursiveBBox:this.singleBBox;return t>=n[0]&&t<=o[0]&&e>=n[1]&&e<=o[1]}applyTransforms(t){t.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=Oe.compose(this.position,this.scale,UO(this.rotation),Ea.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let n=this.parent;e&&n!==null&&n!==void 0&&n.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Oe.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Oe.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Ea.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(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let n=t,o=Ye(t.path,["states","*"]);if(o!==null){if(t.type===0){let[a]=o;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=zt.zoom(l,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(s[d]=c[d])}}n={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=zt.removeOverridden(t.path,t.props,a);n={...t,props:s}}}this.updateByPatchedOpBase(n,wa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let n of this.data.states)wa.toOps(this.data,n.data).forEach(a=>{let s=vc.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=wa.patch(this.data,n),wa.toOps(this.data,n).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new Fa(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof Fa&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};gt();var rh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var nh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var sg=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var lg=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var Wt=class extends Fa{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new sg(e+"-fill",r.fill,n),this.stroke=new lg(e+"-stroke",r.stroke,n),this.dropShadow=new rh(e+"-dropShadow",r.dropShadow,n),this.innerShadow=new rh(e+"-innerShadow",r.innerShadow,n),this.backgroundBlur=new nh(e+"-backgroundBlur",r.backgroundBlur,n),this.layerBlur=new nh(e+"-layerBlur",r.layerBlur,n)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ve.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ve.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=Ve.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=Ve.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,r,n){super.updateByPatchedOp(e,r,n),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),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 r=new Wt(this.uuid,this.data,e);return r.parent=void 0,r}};var Ps=class extends Wt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,n)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return GO(e,r,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 r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Ps(this.uuid,this.data,e);return r.parent=void 0,r}};var Gi=class extends Wt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,n)}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 r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Gi(this.uuid,this.data,e);return r.parent=void 0,r}};var Ms=class extends Wt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,n)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ve.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ve.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 r=this.data.textTransform,n=this.data.text.textValue.toString(),o=r===2?n.toUpperCase():r===3?n.toLowerCase():n,{height:a}=e.drawText(o,{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 r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Ms(this.uuid,this.data,e);return r.parent=void 0,r}};var Ed=class extends Wt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,n)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(o=>cg.extremas(o)),r=[1/0,1/0],n=[-1/0,-1/0];for(let o=0,a=e.length;o<a;o++){let s=e[o];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>n[0]&&(n[0]=s[1][0]),s[1][1]>n[1]&&(n[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[n[0],n[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let n=1,o=this.data.points.length;n<o;n++){let a=this.data.points[n].data,s=this.data.points[n-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let n={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(n)}}getCenter(){let[e,r]=this.extremasBBox.min,[n,o]=this.getHalfSize();return[e+n,r+o]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let o=0,a=this.data.points.length;o<a;o++){let s=this.data.points[o].data;if(o===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[o-1].data,[c,d]=l.controlNext.position,[u,p]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};cg.derive(m),e.bezierCurveTo(c,d,u,p,h,f)}}let r=this.data.points[0].data,n=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[o,a]=n.controlNext.position,[s,l]=r.controlPrevious.position,[c,d]=r.position;e.bezierCurveTo(o,a,s,l,c,d)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Ed(this.uuid,this.data,e);return r.parent=void 0,r}},cg;(o=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,d=a.end,u=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(d[0]-c[0]),3*(d[1]-c[1])],f={start:u,cp:p,end:h};return a.derivative=f,f.derivative=US.derive(f),f}o.derive=i;function t(a,s,l,c=!1){let d=a-2*s+l;if(d!==0){let u=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,h=-(u+p)/d,f=-(-u+p)/d;return[h,f]}else if(s!==l&&d===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??o.derive(a),l=s.start,c=s.cp,d=s.end;return[t(l[0],c[0],d[0]),t(l[1],c[1],d[1])]}o.droot=e;function r(a){let[s,l]=o.droot(a),c=[a.start[0],a.end[0]],d=[a.start[1],a.end[1]];for(let u of s)c.push(o.compute(a,Math.min(1,Math.max(0,u)))[0]);for(let u of l)d.push(o.compute(a,Math.min(1,Math.max(0,u)))[1]);return c.sort((u,p)=>u-p),d.sort((u,p)=>u-p),[[c[0],d[0]],[c[c.length-1],d[d.length-1]]]}o.extremas=r;function n(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,d=s*s,u=c*l,p=c*s*3,h=l*d*3,f=s*d;return[u*a.start[0]+p*a.cp1[0]+h*a.cp2[0]+f*a.end[0],u*a.start[1]+p*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}o.compute=n})(cg||(cg={}));var US;(r=>{function i(n){let o=n.start,a=n.cp,s=n.end,l=[2*(a[0]-o[0]),2*(a[1]-o[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],d={start:l,end:c};return d.derivative=zS.derive(d),n.derivative=d,d}r.derive=i;function t(n){let o=n.derivative??r.derive(n),a=o.start,s=o.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let a=1-o,s=a*a,l=o*o,c=s,d=a*o*2,u=l;return[c*n.start[0]+d*n.cp[0]+u*n.end[0],c*n.start[1]+d*n.cp[1]+u*n.end[1]]}r.compute=e})(US||(US={}));var zS;(e=>{function i(r){let n=r.start,o=r.end,a=[o[0]-n[0],o[1]-n[1]];return r.derivative=a,r.derivative}e.derive=i;function t(r,n){if(n===0)return[...r.start];if(n===1)return[...r.end];let o=r.start,a=r.end;return[o[0]+(a[0]-o[0])*n,o[1]+(a[1]-o[1])*n]}e.compute=t})(zS||(zS={}));var kn=class extends Fa{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.context=n;this.isBaseGroup=!0;this.children=[]}add(e){e.parent&&e.parent instanceof kn&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let n of this.children)n instanceof kn?n.traverse(e):r=e(n)}intersectsChildrenHelper(e,r,n,o,a){for(let s of this.children)if(s.intersects(e,r,n,!1)&&(a.push(s),o)||s instanceof kn&&s.intersectsChildrenHelper(e,r,n,o,a))return!0;return!1}intersectsChildren(e,r,n,o=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,n,o,a),a}intersectsChildrenHelperReverse(e,r,n,o,a){for(let s of this.children)if(s instanceof kn&&s.intersectsChildrenHelperReverse(e,r,n,o,a)||s.intersects(e,r,n,!1)&&(a.push(s),o))return!0;return!1}intersectsChildrenReverse(e,r,n,o=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,n,o,a),a}updateWorldMatrix(e,r,n){if(super.updateWorldMatrix(e,r,n),n&&this.children)for(let o of this.children)o.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(n=>{n.uuid===e&&(r=n)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new kn(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}},Kn=class extends kn{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.updateState(r,n)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new Kn(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}};gt();var dn=class extends kn{constructor(e,r,n){super(e,r,n);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Gi(e+"-background",kc.defaultData,n),this.background.parent=this,this.updateState(r,n)}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,r,n){super.updateWorldMatrix(e,r,n),this.background?.updateWorldMatrix(e,r,n)}draw(e){if(!this.visible)return;e.save();let r=this.width,n=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=n,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,n,...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 r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),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,r,n){super.updateByPatchedOp(e,r,n),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new dn(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}};var zO=mc(rg(),1),dg=new Map,FV=4096,Cd=null;function kV(i){let t=dg.get(i);if(t!==void 0)return t;if(Cd===null||!Cd.isConnected){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none",Cd=document.createElementNS("http://www.w3.org/2000/svg","path"),r.appendChild(Cd),document.body.appendChild(r)}Cd.setAttribute("d",i);let e=Cd.getBBox();return dg.size>=FV&&dg.clear(),dg.set(i,e),e}var ka=class extends Wt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,n),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;jO(this.path)&&(console.warn("Invalid SVG path",this.uuid),e=""),this._pathBBox=kV(e)}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=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,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new ka(this.uuid,this.data,e);return r.parent=void 0,r}};function jO(i){return/NaN/.test(i)}function HO(i,t=1,e=1){if(t<=0||e<=0)return i;if(jO(i))return console.warn("Cannot scale invalid path",i),ug([]);if(t===1&&e===1)return i;try{let n=(0,zO.parseSVG)(i).map(o=>{let a={...o};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return ug(n)}catch(r){return console.warn("Error parsing SVG path",r),ug([])}}function ug(i){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(r=>{let n=[];t.forEach(a=>{if(a in r){let s=r[a]*1;n.length&&s>=0&&n.push(","),n.push(s)}});let o=(e===r.code?n[0]<0?"":",":r.code)+n.join("");return e=r.code,o}).join("")}function WO(i,t,e){switch(t.type){case"ellipse2d":return new Ps(i,t,e);case"rectangle2d":return new Gi(i,t,e);case"text2d":return new Ms(i,t,e);case"vector2d":return new Ed(i,t,e);case"path2d":return new ka(i,t,e);case"frame2d":return new dn(i,t,e);case"group2d":default:return new Kn(i,t,e)}}fr();var jS=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Kn(jS.GROUP_ID,{...vp.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,n,o,a){let s=WO(t,e,a);s&&(n.add(s),n.children.splice(o,0,n.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof Kn||s instanceof dn)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let n=0;for(let o of t)this.createObject(o.id,o.data,o.children,e,n,r),n+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,n){let o=this.find(t);if(o)try{o.updateByOp(e,r,{shared:n})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof kn&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof kn){let n=r.parent;r.resetBBoxNeedsUpdate(),n?.remove(r),n?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let n=r.parent,o=t.parent===null?this:this.find(t.parent);if(o===void 0&&!1&&console.error("unexpected",o,t),o instanceof kn||o===this){o.add(r);let a=t.localIndex;o.children.splice(a,0,o.children.pop()),r.updateWorldMatrix(!0,!1,!0),n?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,n=!1,o=[]){return this.group.intersectsChildren(t,e,r,n,o,!0)}intersectsChildrenReverse(t,e,r,n=!1,o=[]){return this.group.intersectsChildrenReverse(t,e,r,n,o,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],n=e;for(;n!==this.group;){let o=n;n=n.parent;let a=n.children.indexOf(o);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>rl(r.sortKey,n.sortKey)),e.map(r=>r.entity)}},Fl=jS;Fl.GROUP_ID="scene2d";function HS({constraints:i,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:n,objectInitialWidth:o,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,d=t-r,u=e-n,p=o,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=d;else if(l===3)f+=d/2;else if(l===2)p=Math.max(1,p+d);else if(l===4){let y=t/r;p*=y,f*=y}}if(c!==0){if(c===1)m+=u;else if(c===3)m+=u/2;else if(c===2)h=Math.max(1,h+u);else if(c===4){let y=e/n;h*=y,m*=y}}return{width:p,height:h,position:[f,m]}}var VV=mc(rg(),1);var moe={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}};gt();var Rr=require("three");var GV=new Set;function qO(i){GV.add(i)}function WS(i,t,e,r){return r?e:2048/Math.max(1,i,t)}function XO(i,t,e,r){let n=WS(i,t,e,r),o=Math.max(e,512/Math.min(i,t)),a=Math.min(o,n);return{width:Math.max(1,Math.ceil(i*a)),height:Math.max(1,Math.ceil(t*a))}}var UV=`
1313
1313
  varying vec2 vUv;
1314
1314
  void main() {
@@ -1324,7 +1324,7 @@ void main() {
1324
1324
  `,e),u=e.horizontalAlign===1?d:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],d),h=this.getLineInitialOffsetY(a,t.length,c,o,e.verticalAlign),f=[],m=t.map(()=>[]),y=t.map(()=>[]);for(let v=0;v<t.length;v++){let b=t[v],S={features:{liga:!0},letterSpacing:e.letterSpacing},x=[];try{x=n.stringToGlyphs(b,S)}catch(M){this.warnLayoutError(M)}p=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,b,d);let A=[];try{A=this.reverseLigaturesTable(n,b,x)}catch(M){this.warnLayoutError(M)}let w=this.computeSpaceWidthForLine(t,v,e,r),E=0,P=x[0];P&&e.horizontalAlign===2&&P.leftSideBearing!==void 0&&(p-=P.leftSideBearing*o);try{this.font?.forEachGlyph(b,p,h,e.fontSize,S,(M,D,R,L,C)=>{let B=M.index===0?`
1325
1325
  `:M.unicode?String.fromCharCode(M.unicode):void 0,_=A[E],F=0;if(B===`
1326
1326
  `)F=u;else if(B===" ")F=w;else{let k=this.createPath(M,o,D,R,e);k&&(F=k.offsetX,f.push(k.path))}if(!_||_.replacements.length===1)y[v].push([D,R]),m[v].push(F);else{let k=_.replacements.map(X=>(n.glyphs.get(X).advanceWidth??0)*o),q=k.reduce((X,z)=>X+=z,0),W=k.map(X=>X/q),G=D;for(let X=0;X<W.length;X++){let z=F*W[X];y[v].push([G,R]),m[v].push(z),G+=z}}E++})}catch(M){this.warnLayoutError(M)}h-=a}let g=[];for(let v=0,b=f.length;v<b;v++)g.push(...f[v].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,n,o){return(r===3||r===2)&&n.indexOf(`
1327
- `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*n,l=t-s,c=-this.ascender*n-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,n,o){let a=t.getPath(r,-n,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new hg,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=tG(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,n){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(n.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function tG(i){if(i.length){let t=i[0];if(t instanceof Pd.LineCurve)return t.v1;if(t instanceof Pd.CubicBezierCurve||t instanceof Pd.QuadraticBezierCurve)return t.v0}}Oi("TextGeometry",(i,t,e)=>new Es(i,t,e));var eD={create:(i,t)=>new pd(i,t)};Ep("TextGeometry",eD);Ep("InputGeometry",eD);kP(mg);Pe("text");var tD=200,rG=null;function rD(i){rG=i}var oh=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},nD=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return nG(Math.atan2(r,e))},iD=(i,t,e)=>{let r={x:0,y:0};return e=gg(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},gg=i=>i*(Math.PI/180),nG=i=>i*(180/Math.PI),oD=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,yg=new Map,aD=i=>{yg.has(i)&&clearTimeout(yg.get(i)),yg.set(i,setTimeout(function(){yg.delete(i),i()},100))},Md=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},Od=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var vg=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),$S=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},bg=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},xg=(i,t,e)=>{let r=lD(i);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[n]=o.slice(0,-2)}return r},sD=(i,t)=>{let e=lD(i);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},lD=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Sg=(i,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);return i},cD=(i,t)=>{let e={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);return e},ah=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},dD=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(uD="ontouchstart"in window,pD=!!window.PointerEvent,hD=!!window.MSPointerEvent);var uD,pD,hD,sh={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dd,lh={};pD?Dd=sh.pointer:hD?Dd=sh.MSPointer:uD?(Dd=sh.touch,lh=sh.mouse):Dd=sh.mouse;function kl(){}kl.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};kl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};kl.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(a){a.call(e,{type:n,target:e},t)})};kl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=cD(t.options,i))};kl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Md(i,Dd[t],e._domHandlers_[t]),lh[t]&&Md(i,lh[t],e._domHandlers_[t]),e};kl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Od(i,Dd[t],e._domHandlers_[t]),lh[t]&&Od(i,lh[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Id=kl;function Hr(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Hr.id,Hr.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}Hr.prototype=new Id;Hr.constructor=Hr;Hr.id=0;Hr.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Hr.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=sD("borderRadius","50%"),e=xg("transition","opacity",i),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)"},Sg(r.el,e),this.options.shape==="circle"&&Sg(r.back,t),Sg(r.front,t),this.applyStyles(r),this};Hr.prototype.applyStyles=function(i){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};Hr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Hr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Hr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};Hr.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};Hr.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};Hr.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=xg("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};Hr.prototype.restCallback=function(){var i=this,t={};t.front=xg("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};Hr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Hr.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,o,a;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?o="left":o="right"),i.lockX||(t>0?a="up":a="down"),i.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:n},i.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return i;(!c.x||!c.y)&&this.trigger("plain",i),c.x||this.trigger("plain:"+o,i),c.y||this.trigger("plain:"+a,i),c.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var fD=Hr;function Br(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Br.id,Br.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Br.prototype=new Id;Br.constructor=Br;Br.id=0;Br.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Br.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Br.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Br.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-a.x,y:i.y-a.y};else if(i.top||i.right||i.bottom||i.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=i.top,s.style.right=i.right,s.style.bottom=i.bottom,s.style.left=i.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),n=i,i={x:l.left+r.x,y:l.top+r.y}}var c=new fD(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:i,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(bg(c.ui.el,n),bg(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};Br.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Br.prototype.bindNipple=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Br.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=i.force||i.pressure||i.webkitForce||0;o!==n&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),n=o)}.bind(r),100)};Br.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=vg(i),t.updateBox();var n=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[i[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return ah(i,n),t.manager.bindDocument(),!1};Br.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),o=i.force||i.pressure||i.webkitForce||0,a={x:i.pageX,y:i.pageY},s=t.getOrCreate(n,a);s.identifier!==n&&t.manager.removeIdentifier(s.identifier),s.identifier=n;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(i,d,d.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=oh(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(i);return}}return s};Br.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Br.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.scroll;if(!oD(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:o.x+a.left,y:o.y+a.top}}n.identifier=r;var s=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var c=oh(l,n.position),d=nD(l,n.position),u=gg(d),p=c/s,h={distance:c,position:l},f,m;if(n.options.shape==="circle"?(f=Math.min(c,s),m=iD(n.position,f,d)):(m=dD(l,n.position,s),f=oh(m,n.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;n.position.x+=b,n.position.y+=S,n.el.style.top=n.position.y-(t.box.top+o.y)+"px",n.el.style.left=n.position.x-(t.box.left+o.x)+"px",c=oh(l,n.position)}}else l=m,c=f;var y=l.x-n.position.x,g=l.y-n.position.y;n.frontPosition={x:y,y:g},e.dataOnly||bg(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:p,pressure:i.force||i.pressure||i.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:gg(180-d),degree:180-d},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Br.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};Br.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Br.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)Object.prototype.hasOwnProperty.call(i.pressureIntervals,t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off(),i.pressureIntervals={},i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.manager=null};var mD=Br;function Fr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=$S(),t._windowBound=!1,t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(n){n.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){aD(e)},t._onScroll=function(){t.scroll=$S()},t.collections}Fr.prototype=new Id;Fr.constructor=Fr;Fr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};Fr.prototype.create=function(i){return this.createCollection(i)};Fr.prototype.bindWindowEvents=function(){var i=this;i._windowBound||typeof window>"u"||(i._windowBound=!0,Md(window,"resize",i._onResize),Md(window,"scroll",i._onScroll))};Fr.prototype.unbindWindowEvents=function(){var i=this;!i._windowBound||typeof window>"u"||(i._windowBound=!1,Od(window,"resize",i._onResize),Od(window,"scroll",i._onScroll))};Fr.prototype.createCollection=function(i){var t=this,e=new mD(t,i);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};Fr.prototype.bindCollection=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Fr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};Fr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Fr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Fr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Fr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};Fr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};Fr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};Fr.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=vg(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[n](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),ah(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return ah(t,a),!1};Fr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.unbindWindowEvents(),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.collections=[],i.off()};Fr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var yD=Fr;var Rd=null;function gD(){return Rd||(Rd=new yD),Rd}var iG={create:function(i){return gD().create(i)},destroy:function(){Rd&&(Rd.destroy(),Rd=null)},get factory(){return gD()}},vD=iG;var re=require("three");var xt=require("three");var un=require("three");var wg=new un.Vector3,Ui=new un.Camera,e1=class extends un.LineSegments{constructor(e){let r=new un.BufferGeometry,n=new un.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new un.Color(15711266),c=new un.Color(15711266),d=new un.Color(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new un.Float32BufferAttribute(o,3)),r.setAttribute("color",new un.Float32BufferAttribute(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;Ui.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=n?.8:1e-4;yo("n1",r,e,Ui,-o,-a,s),yo("n2",r,e,Ui,o,-a,s),yo("n3",r,e,Ui,-o,a,s),yo("n4",r,e,Ui,o,a,s);let l=s;yo("f1",r,e,Ui,-o,-a,l),yo("f2",r,e,Ui,o,-a,l),yo("f3",r,e,Ui,-o,a,l),yo("f4",r,e,Ui,o,a,l);let c=l,d=.5;yo("u1",r,e,Ui,o*.7*d,a*1.1,c),yo("u2",r,e,Ui,-o*.7*d,a*1.1,c),yo("u3",r,e,Ui,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yo(i,t,e,r,n,o,a){wg.set(n,o,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],wg.x,wg.y,wg.z)}}var Eg=class extends jo(e1){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Ho(this.object,this.geometry,e,r,!0)}};var Cg=790;function bD(i){return 1-Math.pow(1-i,3)}var Bd=new xt.Vector3,t1=new xt.Vector3,r1=new xt.Quaternion,n1=new xt.Vector3,ch=new xt.Vector3,i1=new xt.Vector3,$o=class extends ki(xt.Camera,Eg){constructor(e="",r={...fl.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=io.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=$o.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new xt.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,o=this.height;this.orthoCamera=new xt.OrthographicCamera(n*-.5,n*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new xt.PerspectiveCamera(45,n/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=$o.projectionTransitionsEnabled;$o.projectionTransitionsEnabled=!1;try{return e()}finally{$o.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new xt.Vector3(e,r,n)),super.lookAt(e),this.getWorldPosition(Bd),this.targetOffset=Bd.distanceTo(e)}getTarget(e=new xt.Vector3){return this.getWorldDirection(t1),this.getWorldPosition(Bd),t1.multiplyScalar(this.targetOffset),e.copy(Bd).add(t1),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Bd),Bd.distanceTo(e)}updateUp(){this.getWorldQuaternion(r1),n1.set(0,0,1).applyQuaternion(r1),ch.copy(xt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&ch.negate(),ch.applyQuaternion(r1),i1.copy(xt.Object3D.DEFAULT_UP).projectOnPlane(n1),this.angleOffsetFromUp=i1.angleTo(ch),this.angleOffsetFromUp*=i1.cross(ch).dot(n1)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new xt.Vector3),o=e.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new xt.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Cg*.5*o,this.right=Cg*.5*o,this.top=Cg*.5*(1/a),this.bottom=-Cg*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:bD(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return $o.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=$o.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new xt.Matrix4,blend:new xt.Matrix4,blendInverse:new xt.Matrix4,start:0,duration:$o.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=$o.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let n=bD(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=n*c/(n*c+(1-n)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let n=this._projectionTransition;n===void 0?(n={from:new xt.Matrix4,blend:new xt.Matrix4,blendInverse:new xt.Matrix4,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=n):n.raf!==0&&(cancelAnimationFrame(n.raf),n.raf=0),n.requestRender=void 0,n.from.copy(r.from),n.start=r.start,n.duration=r.duration,n.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,s):this.orthoCamera.setViewOffset(e,r,n,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=io.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Sp(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(n=>typeof n=="number"?n:0)),e.targetOffset!==void 0&&(this.targetOffset=io.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},St=$o;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var sG=null;function xD(i){sG=i}var lG,SD=new Promise(i=>{lG=i});var Wr=require("three");var Nd=require("three");function cG(i){let t=i.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||n<l||o<l||a<l||s<l}function Tg(i,t){let e=new Nd.BufferGeometry;if(t&&cG(t))return e.setAttribute("position",new Nd.Float32BufferAttribute([],3)),e.setIndex([]),e;if(!i.getAttribute("position"))return e.setAttribute("position",new Nd.Float32BufferAttribute([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=jp(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Nd.Float32BufferAttribute(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var dG=require("three/examples/jsm/utils/BufferGeometryUtils.js");var uG;SD.then(i=>uG=i);var ose=new Wr.Vector3,ase=new Wr.Quaternion,sse=new Wr.Vector3,lse=new Wr.Euler(0,0,0,"YXZ"),cse=new Wr.Euler(0,0,0,"XYZ"),dse=new Wr.Vector3,use=new Wr.Vector3,pse=new Wr.Vector3(1,1,1),hse=new Wr.Quaternion,fse=new Wr.Matrix4,mse=new Wr.Matrix4;var yse=new Wr.Quaternion,gse=new Wr.Sphere;var o1={type:"beginEvent",eventName:"Collision"};var a1=i=>i.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);var ID=require("three");gt();var AD=4,s1=8;var l1=.02,c1=.3,pG=65,wD=new re.Vector3,ED=new re.Vector3,hG=new re.Vector3,Cn=new re.Vector3,Va=new re.Vector3,Ld=new re.Vector3,d1=new re.Matrix4,CD=new re.Matrix4,fG=new re.Matrix4,fi=new re.Quaternion,Vl=new re.Quaternion,_d=new re.Euler(0,0,0,"YXZ"),mG=new re.Vector3(1,0,0),ea=new re.Vector3(0,1,0),yG=new re.Vector3(0,0,1),TD=new re.Vector3(1,1,1),u1=[],PD=i=>u1[i]??(u1[i]=new re.Vector3),p1=new re.Vector3,gG=new re.Vector3,vG=new re.Vector3,bG=new re.Vector3,MD=new re.Quaternion,xG=new re.Vector3,OD=new re.Quaternion,SG=1,AG=.025,wG=16e-6,DD=12,EG=20,tn=new re.Line3,zi=new re.Box3,CG={type:"requestRender"},TG={type:"updateMatrix"},Pg=class extends re.EventDispatcher{constructor(e,r,n,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new re.Matrix4;this.target0=new re.Vector3;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=tD;this.euler0=new re.Euler(0,0,0,"YXZ");this.position0Cam=new re.Vector3;this.quat0Cam=new re.Quaternion;this.scale0Cam=new re.Vector3;this.hiddenMatrix0Cam=new re.Matrix4;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new re.Line3(new re.Vector3(0,-40,0),new re.Vector3(0,40,0)),matrix:new re.Matrix4,position:new re.Vector3,rotation:new re.Quaternion};this.euler=new re.Euler(0,0,0,"YXZ");this.eulerDelta=new re.Vector3;this.lastPosition=new re.Vector3;this.lastCameraQuaternion=new re.Quaternion;this.lastCameraPosition=new re.Vector3;this.PI_2=Math.PI/2;this.prevMouse=new re.Vector2;this.velocityTarget=new re.Vector3;this.velocity=new re.Vector3;this.directionXZ=new re.Vector3;this.rotVelocityStick=new re.Vector3;this.rotVelocityTarget=new re.Vector3;this.rotVelocity=new re.Vector3;this.rotDirection=new re.Vector3;this.nonColliderRotOffset=new re.Matrix4;this.nonColliderPosOffset=new re.Matrix4;this.firstPointerId=-1;this.rot=new re.Vector3;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.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 re.Matrix4;this.objectToTarget=new re.Vector3;this.objectToTarget0=new re.Vector3;this.objectToCamXZ=new re.Vector3;this.objectToCamXZ0=new re.Vector3;this.targetToCamera=new re.Vector3;this.targetToCamera0=new re.Vector3;this.cameraPolarAxis0=new re.Vector3;this.targetPos=new re.Vector3;this.targetQuat=new re.Quaternion;this.lerpFactorPos=new re.Vector3().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new re.Quaternion;this.objXZQuatInv=new re.Quaternion;this.objXZRotMat=new re.Matrix4;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new re.Vector3;this.pushedVelocity=new re.Vector3;this.groundYRotation=0;this.objectRealQuat=new re.Quaternion;this.colliderWorldQuat=new re.Quaternion;this.groundNormal=new re.Vector3;this.groundTilt=new re.Quaternion;this.groundTiltInv=new re.Quaternion;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new re.Vector3;this.quaternion=new re.Quaternion;this.scale=new re.Vector3;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Xn&&!m0&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(m0&&ST<15.5&&!Xn?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Pg.isLocked=!0:Pg.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let o=e.axes[n];r===0?n===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 y=new re.Vector3(0,0,-1).applyQuaternion(this.camera.quaternion),g=new re.Vector3().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new re.Euler().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof St&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*SG,this.speedOrbit=(n.speedRotate??100)*AG,this.mouseOrbitSensitivity=(n.speedRotate??100)*wG,this.keyAssignments=n.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??hs.defaultData.gravity)*DD,this.usePhysics=this.gloabalPhysics.usePhysics??hs.defaultData.usePhysics,this.jumpPower=n.jumpPower*EG,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Lc.defaultDataThirdPerson.orientWith,this.slopeThresh=pG*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*l1/this.pixelsPerMeter,this.stepThresh=n.collider.height*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*l1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*l1/this.pixelsPerMeter,this.stepThresh=n.collider.height*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let h=new re.Vector3().fromArray(n.collider.position.map(y=>typeof y=="number"?y:0)),f=new re.Quaternion().setFromEuler(new re.Euler().fromArray([...n.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,TD),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let y=new se;y.push({fi:0,data:{...Kt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Kt.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let g=_y({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ID.Mesh(fy.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=n.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 r=new re.Euler().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof St?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Nc.list.forEach(n=>{this.actions[n]=Vt({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),vr(this.actions.idle),vr(this.actions.move),vr(this.actions.run),vr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Cn.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 n=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Va.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*DD),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,s,this.object.rigidBody?.collider(0).shape,0,1,!1,s1,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&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(Cn).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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*n),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 s=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=Cn.subVectors(this.path[1],this.position),c=Va.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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)**n),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**n),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**n)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=hG.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Va.copy(a);s.y=0,a.set(0,a.y,s.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 s=Cn;this.camera.getWorldDirection(s);let l=Ld.copy(ea).multiplyScalar(s.dot(ea));s.sub(l);let c=Va.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(_d.setFromVector3(this.rot),this.moveMode==="walk"&&(_d.x=0),a.applyEuler(_d),o&&(Vl.setFromUnitVectors(ea,this.groundNormal),a.applyQuaternion(Vl)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(p1,MD,gG);let c=this.object.getWorldPosition(vG).add(this.collider.position).sub(p1);OD.copy(l.prevQ).invert().premultiply(MD);let d=Ld.subVectors(p1,l.prevT).add(bG.copy(c).applyQuaternion(OD).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Cn.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Le.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof Dr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(o1));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),PD(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=PD(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**n):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**n),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(ea,this.euler.y-this.euler0.y);let s=Va.copy(this.objectToCamXZ).normalize(),l=Ld.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Cn.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,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=re.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=re.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=re.MathUtils.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(_d.copy(this.euler),_d.y=0,this.nonColliderRotOffset.makeRotationFromEuler(_d)),fi.setFromAxisAngle(mG,this.rot.x),Vl.setFromAxisAngle(ea,this.rot.y),Vl.multiply(fi),fi.setFromAxisAngle(yG,this.rot.z),Vl.multiply(fi),this.quaternion.copy(Vl),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Va.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new re.Vector3;for(let p=0;p<5;p++){let h=s.length(),f=Ld.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,s1|AD,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,A;if(m.cloner){for(let w of m.cloner.children)if(w.rigidBody===x){A=w;break}}S.dispatch(A),m.dispatchEvent(o1)}}}let y=wD.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=ED.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=Ld.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,s1|AD,void 0,void 0,this.object.rigidBody);A!==null&&A.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),Cn.copy(this.position).divideScalar(this.pixelsPerMeter),fi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&xG.copy(Cn).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Cn,!0),d.setRotation(fi,!0)):(d.setNextKinematicTranslation(Cn),d.setNextKinematicRotation(fi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);d1.lookAt(l,s,ea).setPosition(l),d1.decompose(this.targetPos,this.targetQuat,Cn),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**n),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**n),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=re.MathUtils.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=re.MathUtils.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(TG),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(CG),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=fi.setFromAxisAngle(ea,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?re.MathUtils.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 r;this.cameraXAxis==="Limit"?r=re.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=re.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=Cn.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let o=Vl.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){ea.angleTo(e)*180/Math.PI<15||ea.angleTo(e)*180/Math.PI>85?fi.identity():fi.setFromUnitVectors(ea,e),this.groundTilt.slerp(fi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=ED.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=d1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Cn,fi,Va).compose(Cn,fi,TD);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;zi.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=CD.copy(s).invert(),c=fG.copy(CD).multiply(n);tn.copy(this.collider.segment),tn.start.applyMatrix4(c),tn.end.applyMatrix4(c);let d=wD.copy(this.position).applyMatrix4(l);zi.expandByPoint(tn.start),zi.expandByPoint(tn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(tn.end)},intersectsBounds:u=>u.intersectsBox(zi),intersectsTriangle:u=>{let p=Cn,h=Va,f=u.closestPointToSegment(tn,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=Ld.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),tn.start.addScaledVector(y,m),tn.end.addScaledVector(y,m)}}})}),zi.makeEmpty(),tn.copy(this.collider.segment),tn.start.applyMatrix4(n),tn.end.applyMatrix4(n),zi.expandByPoint(tn.start),zi.expandByPoint(tn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(tn.end)},intersectsBounds:a=>a.intersectsBox(zi),intersectsTriangle:a=>{let s=Cn,l=Va,c=a.closestPointToSegment(tn,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),tn.start.addScaledVector(u,d),tn.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,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.deactivate()}resume(){this.activate()}},dh=Pg;dh.isLocked=!1;var go=require("three"),LD=require("three/examples/jsm/utils/BufferGeometryUtils.js");var PG,RD=new Promise(i=>{PG=i});var BD;var MG=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.63/build/",OG=i=>`
1327
+ `)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*n,l=t-s,c=-this.ascender*n-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,n,o){let a=t.getPath(r,-n,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new hg,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=tG(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,n){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(n.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function tG(i){if(i.length){let t=i[0];if(t instanceof Pd.LineCurve)return t.v1;if(t instanceof Pd.CubicBezierCurve||t instanceof Pd.QuadraticBezierCurve)return t.v0}}Oi("TextGeometry",(i,t,e)=>new Es(i,t,e));var eD={create:(i,t)=>new pd(i,t)};Ep("TextGeometry",eD);Ep("InputGeometry",eD);kP(mg);Pe("text");var tD=200,rG=null;function rD(i){rG=i}var oh=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},nD=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return nG(Math.atan2(r,e))},iD=(i,t,e)=>{let r={x:0,y:0};return e=gg(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},gg=i=>i*(Math.PI/180),nG=i=>i*(180/Math.PI),oD=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,yg=new Map,aD=i=>{yg.has(i)&&clearTimeout(yg.get(i)),yg.set(i,setTimeout(function(){yg.delete(i),i()},100))},Md=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},Od=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var vg=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),$S=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},bg=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},xg=(i,t,e)=>{let r=lD(i);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[n]=o.slice(0,-2)}return r},sD=(i,t)=>{let e=lD(i);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},lD=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Sg=(i,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);return i},cD=(i,t)=>{let e={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);return e},ah=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},dD=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(uD="ontouchstart"in window,pD=!!window.PointerEvent,hD=!!window.MSPointerEvent);var uD,pD,hD,sh={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dd,lh={};pD?Dd=sh.pointer:hD?Dd=sh.MSPointer:uD?(Dd=sh.touch,lh=sh.mouse):Dd=sh.mouse;function kl(){}kl.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};kl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};kl.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(a){a.call(e,{type:n,target:e},t)})};kl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=cD(t.options,i))};kl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Md(i,Dd[t],e._domHandlers_[t]),lh[t]&&Md(i,lh[t],e._domHandlers_[t]),e};kl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Od(i,Dd[t],e._domHandlers_[t]),lh[t]&&Od(i,lh[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Id=kl;function Hr(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Hr.id,Hr.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}Hr.prototype=new Id;Hr.constructor=Hr;Hr.id=0;Hr.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Hr.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=sD("borderRadius","50%"),e=xg("transition","opacity",i),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)"},Sg(r.el,e),this.options.shape==="circle"&&Sg(r.back,t),Sg(r.front,t),this.applyStyles(r),this};Hr.prototype.applyStyles=function(i){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};Hr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Hr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Hr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};Hr.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};Hr.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};Hr.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=xg("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};Hr.prototype.restCallback=function(){var i=this,t={};t.front=xg("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};Hr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Hr.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,o,a;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?o="left":o="right"),i.lockX||(t>0?a="up":a="down"),i.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:n},i.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return i;(!c.x||!c.y)&&this.trigger("plain",i),c.x||this.trigger("plain:"+o,i),c.y||this.trigger("plain:"+a,i),c.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var fD=Hr;function Br(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Br.id,Br.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Br.prototype=new Id;Br.constructor=Br;Br.id=0;Br.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Br.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Br.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Br.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-a.x,y:i.y-a.y};else if(i.top||i.right||i.bottom||i.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=i.top,s.style.right=i.right,s.style.bottom=i.bottom,s.style.left=i.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),n=i,i={x:l.left+r.x,y:l.top+r.y}}var c=new fD(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:i,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(bg(c.ui.el,n),bg(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};Br.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Br.prototype.bindNipple=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Br.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=i.force||i.pressure||i.webkitForce||0;o!==n&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),n=o)}.bind(r),100)};Br.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=vg(i),t.updateBox();var n=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[i[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return ah(i,n),t.manager.bindDocument(),!1};Br.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),o=i.force||i.pressure||i.webkitForce||0,a={x:i.pageX,y:i.pageY},s=t.getOrCreate(n,a);s.identifier!==n&&t.manager.removeIdentifier(s.identifier),s.identifier=n;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(i,d,d.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=oh(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(i);return}}return s};Br.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Br.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.scroll;if(!oD(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:o.x+a.left,y:o.y+a.top}}n.identifier=r;var s=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var c=oh(l,n.position),d=nD(l,n.position),u=gg(d),p=c/s,h={distance:c,position:l},f,m;if(n.options.shape==="circle"?(f=Math.min(c,s),m=iD(n.position,f,d)):(m=dD(l,n.position,s),f=oh(m,n.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;n.position.x+=b,n.position.y+=S,n.el.style.top=n.position.y-(t.box.top+o.y)+"px",n.el.style.left=n.position.x-(t.box.left+o.x)+"px",c=oh(l,n.position)}}else l=m,c=f;var y=l.x-n.position.x,g=l.y-n.position.y;n.frontPosition={x:y,y:g},e.dataOnly||bg(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:p,pressure:i.force||i.pressure||i.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:gg(180-d),degree:180-d},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Br.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};Br.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Br.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)Object.prototype.hasOwnProperty.call(i.pressureIntervals,t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off(),i.pressureIntervals={},i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.manager=null};var mD=Br;function Fr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=$S(),t._windowBound=!1,t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(n){n.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){aD(e)},t._onScroll=function(){t.scroll=$S()},t.collections}Fr.prototype=new Id;Fr.constructor=Fr;Fr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};Fr.prototype.create=function(i){return this.createCollection(i)};Fr.prototype.bindWindowEvents=function(){var i=this;i._windowBound||typeof window>"u"||(i._windowBound=!0,Md(window,"resize",i._onResize),Md(window,"scroll",i._onScroll))};Fr.prototype.unbindWindowEvents=function(){var i=this;!i._windowBound||typeof window>"u"||(i._windowBound=!1,Od(window,"resize",i._onResize),Od(window,"scroll",i._onScroll))};Fr.prototype.createCollection=function(i){var t=this,e=new mD(t,i);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};Fr.prototype.bindCollection=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Fr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};Fr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Fr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Fr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Fr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};Fr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};Fr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};Fr.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=vg(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[n](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),ah(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return ah(t,a),!1};Fr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.unbindWindowEvents(),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.collections=[],i.off()};Fr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var yD=Fr;var Rd=null;function gD(){return Rd||(Rd=new yD),Rd}var iG={create:function(i){return gD().create(i)},destroy:function(){Rd&&(Rd.destroy(),Rd=null)},get factory(){return gD()}},vD=iG;var re=require("three");var xt=require("three");var un=require("three");var wg=new un.Vector3,Ui=new un.Camera,e1=class extends un.LineSegments{constructor(e){let r=new un.BufferGeometry,n=new un.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new un.Color(15711266),c=new un.Color(15711266),d=new un.Color(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new un.Float32BufferAttribute(o,3)),r.setAttribute("color",new un.Float32BufferAttribute(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;Ui.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=n?.8:1e-4;yo("n1",r,e,Ui,-o,-a,s),yo("n2",r,e,Ui,o,-a,s),yo("n3",r,e,Ui,-o,a,s),yo("n4",r,e,Ui,o,a,s);let l=s;yo("f1",r,e,Ui,-o,-a,l),yo("f2",r,e,Ui,o,-a,l),yo("f3",r,e,Ui,-o,a,l),yo("f4",r,e,Ui,o,a,l);let c=l,d=.5;yo("u1",r,e,Ui,o*.7*d,a*1.1,c),yo("u2",r,e,Ui,-o*.7*d,a*1.1,c),yo("u3",r,e,Ui,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yo(i,t,e,r,n,o,a){wg.set(n,o,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],wg.x,wg.y,wg.z)}}var Eg=class extends jo(e1){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Ho(this.object,this.geometry,e,r,!0)}};var Cg=790;function bD(i){return 1-Math.pow(1-i,3)}var Bd=new xt.Vector3,t1=new xt.Vector3,r1=new xt.Quaternion,n1=new xt.Vector3,ch=new xt.Vector3,i1=new xt.Vector3,$o=class extends ki(xt.Camera,Eg){constructor(e="",r={...fl.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=io.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=$o.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new xt.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,o=this.height;this.orthoCamera=new xt.OrthographicCamera(n*-.5,n*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new xt.PerspectiveCamera(45,n/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=$o.projectionTransitionsEnabled;$o.projectionTransitionsEnabled=!1;try{return e()}finally{$o.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new xt.Vector3(e,r,n)),super.lookAt(e),this.getWorldPosition(Bd),this.targetOffset=Bd.distanceTo(e)}getTarget(e=new xt.Vector3){return this.getWorldDirection(t1),this.getWorldPosition(Bd),t1.multiplyScalar(this.targetOffset),e.copy(Bd).add(t1),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Bd),Bd.distanceTo(e)}updateUp(){this.getWorldQuaternion(r1),n1.set(0,0,1).applyQuaternion(r1),ch.copy(xt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&ch.negate(),ch.applyQuaternion(r1),i1.copy(xt.Object3D.DEFAULT_UP).projectOnPlane(n1),this.angleOffsetFromUp=i1.angleTo(ch),this.angleOffsetFromUp*=i1.cross(ch).dot(n1)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new xt.Vector3),o=e.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new xt.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Cg*.5*o,this.right=Cg*.5*o,this.top=Cg*.5*(1/a),this.bottom=-Cg*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:bD(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return $o.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=$o.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new xt.Matrix4,blend:new xt.Matrix4,blendInverse:new xt.Matrix4,start:0,duration:$o.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=$o.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let n=bD(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=n*c/(n*c+(1-n)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let n=this._projectionTransition;n===void 0?(n={from:new xt.Matrix4,blend:new xt.Matrix4,blendInverse:new xt.Matrix4,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=n):n.raf!==0&&(cancelAnimationFrame(n.raf),n.raf=0),n.requestRender=void 0,n.from.copy(r.from),n.start=r.start,n.duration=r.duration,n.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,s):this.orthoCamera.setViewOffset(e,r,n,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=io.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Sp(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(n=>typeof n=="number"?n:0)),e.targetOffset!==void 0&&(this.targetOffset=io.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},St=$o;St.projectionTransitionsEnabled=!1,St.projectionTransitionDuration=350,St.projectionTransitionMinAgeMs=1e3;var sG=null;function xD(i){sG=i}var lG,SD=new Promise(i=>{lG=i});var Wr=require("three");var Nd=require("three");function cG(i){let t=i.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||n<l||o<l||a<l||s<l}function Tg(i,t){let e=new Nd.BufferGeometry;if(t&&cG(t))return e.setAttribute("position",new Nd.Float32BufferAttribute([],3)),e.setIndex([]),e;if(!i.getAttribute("position"))return e.setAttribute("position",new Nd.Float32BufferAttribute([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=jp(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Nd.Float32BufferAttribute(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var dG=require("three/examples/jsm/utils/BufferGeometryUtils.js");var uG;SD.then(i=>uG=i);var ose=new Wr.Vector3,ase=new Wr.Quaternion,sse=new Wr.Vector3,lse=new Wr.Euler(0,0,0,"YXZ"),cse=new Wr.Euler(0,0,0,"XYZ"),dse=new Wr.Vector3,use=new Wr.Vector3,pse=new Wr.Vector3(1,1,1),hse=new Wr.Quaternion,fse=new Wr.Matrix4,mse=new Wr.Matrix4;var yse=new Wr.Quaternion,gse=new Wr.Sphere;var o1={type:"beginEvent",eventName:"Collision"};var a1=i=>i.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);var ID=require("three");gt();var AD=4,s1=8;var l1=.02,c1=.3,pG=65,wD=new re.Vector3,ED=new re.Vector3,hG=new re.Vector3,Cn=new re.Vector3,Va=new re.Vector3,Ld=new re.Vector3,d1=new re.Matrix4,CD=new re.Matrix4,fG=new re.Matrix4,fi=new re.Quaternion,Vl=new re.Quaternion,_d=new re.Euler(0,0,0,"YXZ"),mG=new re.Vector3(1,0,0),ea=new re.Vector3(0,1,0),yG=new re.Vector3(0,0,1),TD=new re.Vector3(1,1,1),u1=[],PD=i=>u1[i]??(u1[i]=new re.Vector3),p1=new re.Vector3,gG=new re.Vector3,vG=new re.Vector3,bG=new re.Vector3,MD=new re.Quaternion,xG=new re.Vector3,OD=new re.Quaternion,SG=1,AG=.025,wG=16e-6,DD=12,EG=20,tn=new re.Line3,zi=new re.Box3,CG={type:"requestRender"},TG={type:"updateMatrix"},Pg=class extends re.EventDispatcher{constructor(e,r,n,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new re.Matrix4;this.target0=new re.Vector3;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=tD;this.euler0=new re.Euler(0,0,0,"YXZ");this.position0Cam=new re.Vector3;this.quat0Cam=new re.Quaternion;this.scale0Cam=new re.Vector3;this.hiddenMatrix0Cam=new re.Matrix4;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new re.Line3(new re.Vector3(0,-40,0),new re.Vector3(0,40,0)),matrix:new re.Matrix4,position:new re.Vector3,rotation:new re.Quaternion};this.euler=new re.Euler(0,0,0,"YXZ");this.eulerDelta=new re.Vector3;this.lastPosition=new re.Vector3;this.lastCameraQuaternion=new re.Quaternion;this.lastCameraPosition=new re.Vector3;this.PI_2=Math.PI/2;this.prevMouse=new re.Vector2;this.velocityTarget=new re.Vector3;this.velocity=new re.Vector3;this.directionXZ=new re.Vector3;this.rotVelocityStick=new re.Vector3;this.rotVelocityTarget=new re.Vector3;this.rotVelocity=new re.Vector3;this.rotDirection=new re.Vector3;this.nonColliderRotOffset=new re.Matrix4;this.nonColliderPosOffset=new re.Matrix4;this.firstPointerId=-1;this.rot=new re.Vector3;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.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 re.Matrix4;this.objectToTarget=new re.Vector3;this.objectToTarget0=new re.Vector3;this.objectToCamXZ=new re.Vector3;this.objectToCamXZ0=new re.Vector3;this.targetToCamera=new re.Vector3;this.targetToCamera0=new re.Vector3;this.cameraPolarAxis0=new re.Vector3;this.targetPos=new re.Vector3;this.targetQuat=new re.Quaternion;this.lerpFactorPos=new re.Vector3().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new re.Quaternion;this.objXZQuatInv=new re.Quaternion;this.objXZRotMat=new re.Matrix4;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new re.Vector3;this.pushedVelocity=new re.Vector3;this.groundYRotation=0;this.objectRealQuat=new re.Quaternion;this.colliderWorldQuat=new re.Quaternion;this.groundNormal=new re.Vector3;this.groundTilt=new re.Quaternion;this.groundTiltInv=new re.Quaternion;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new re.Vector3;this.quaternion=new re.Quaternion;this.scale=new re.Vector3;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Xn&&!m0&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(m0&&ST<15.5&&!Xn?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Pg.isLocked=!0:Pg.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let o=e.axes[n];r===0?n===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),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 y=new re.Vector3(0,0,-1).applyQuaternion(this.camera.quaternion),g=new re.Vector3().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new re.Euler().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof St&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*SG,this.speedOrbit=(n.speedRotate??100)*AG,this.mouseOrbitSensitivity=(n.speedRotate??100)*wG,this.keyAssignments=n.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??hs.defaultData.gravity)*DD,this.usePhysics=this.gloabalPhysics.usePhysics??hs.defaultData.usePhysics,this.jumpPower=n.jumpPower*EG,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Lc.defaultDataThirdPerson.orientWith,this.slopeThresh=pG*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*l1/this.pixelsPerMeter,this.stepThresh=n.collider.height*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*l1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*l1/this.pixelsPerMeter,this.stepThresh=n.collider.height*c1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let h=new re.Vector3().fromArray(n.collider.position.map(y=>typeof y=="number"?y:0)),f=new re.Quaternion().setFromEuler(new re.Euler().fromArray([...n.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,TD),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let y=new se;y.push({fi:0,data:{...Kt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Kt.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let g=_y({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ID.Mesh(fy.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=n.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 r=new re.Euler().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof St?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,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},Nc.list.forEach(n=>{this.actions[n]=Vt({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,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"),vr(this.actions.idle),vr(this.actions.move),vr(this.actions.run),vr(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return Cn.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){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 n=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Va.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*DD),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,s,this.object.rigidBody?.collider(0).shape,0,1,!1,s1,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&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(Cn).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}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*n),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 s=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=Cn.subVectors(this.path[1],this.position),c=Va.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.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)**n),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**n),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**n)):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.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=hG.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Va.copy(a);s.y=0,a.set(0,a.y,s.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 s=Cn;this.camera.getWorldDirection(s);let l=Ld.copy(ea).multiplyScalar(s.dot(ea));s.sub(l);let c=Va.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).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(_d.setFromVector3(this.rot),this.moveMode==="walk"&&(_d.x=0),a.applyEuler(_d),o&&(Vl.setFromUnitVectors(ea,this.groundNormal),a.applyQuaternion(Vl)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(p1,MD,gG);let c=this.object.getWorldPosition(vG).add(this.collider.position).sub(p1);OD.copy(l.prevQ).invert().premultiply(MD);let d=Ld.subVectors(p1,l.prevT).add(bG.copy(c).applyQuaternion(OD).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),Cn.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Le.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof Dr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(o1));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),PD(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=PD(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**n):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**n),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(ea,this.euler.y-this.euler0.y);let s=Va.copy(this.objectToCamXZ).normalize(),l=Ld.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(Cn.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,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=re.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=re.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=re.MathUtils.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(_d.copy(this.euler),_d.y=0,this.nonColliderRotOffset.makeRotationFromEuler(_d)),fi.setFromAxisAngle(mG,this.rot.x),Vl.setFromAxisAngle(ea,this.rot.y),Vl.multiply(fi),fi.setFromAxisAngle(yG,this.rot.z),Vl.multiply(fi),this.quaternion.copy(Vl),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Va.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new re.Vector3;for(let p=0;p<5;p++){let h=s.length(),f=Ld.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,s1|AD,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,A;if(m.cloner){for(let w of m.cloner.children)if(w.rigidBody===x){A=w;break}}S.dispatch(A),m.dispatchEvent(o1)}}}let y=wD.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=ED.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=Ld.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let A=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,s1|AD,void 0,void 0,this.object.rigidBody);A!==null&&A.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),Cn.copy(this.position).divideScalar(this.pixelsPerMeter),fi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&xG.copy(Cn).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(Cn,!0),d.setRotation(fi,!0)):(d.setNextKinematicTranslation(Cn),d.setNextKinematicRotation(fi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);d1.lookAt(l,s,ea).setPosition(l),d1.decompose(this.targetPos,this.targetQuat,Cn),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**n),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**n),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=re.MathUtils.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=re.MathUtils.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(TG),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(CG),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=fi.setFromAxisAngle(ea,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?re.MathUtils.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 r;this.cameraXAxis==="Limit"?r=re.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=re.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=Cn.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let o=Vl.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){ea.angleTo(e)*180/Math.PI<15||ea.angleTo(e)*180/Math.PI>85?fi.identity():fi.setFromUnitVectors(ea,e),this.groundTilt.slerp(fi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=ED.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=d1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Cn,fi,Va).compose(Cn,fi,TD);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;zi.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=CD.copy(s).invert(),c=fG.copy(CD).multiply(n);tn.copy(this.collider.segment),tn.start.applyMatrix4(c),tn.end.applyMatrix4(c);let d=wD.copy(this.position).applyMatrix4(l);zi.expandByPoint(tn.start),zi.expandByPoint(tn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(tn.end)},intersectsBounds:u=>u.intersectsBox(zi),intersectsTriangle:u=>{let p=Cn,h=Va,f=u.closestPointToSegment(tn,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=Ld.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),tn.start.addScaledVector(y,m),tn.end.addScaledVector(y,m)}}})}),zi.makeEmpty(),tn.copy(this.collider.segment),tn.start.applyMatrix4(n),tn.end.applyMatrix4(n),zi.expandByPoint(tn.start),zi.expandByPoint(tn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(tn.end)},intersectsBounds:a=>a.intersectsBox(zi),intersectsTriangle:a=>{let s=Cn,l=Va,c=a.closestPointToSegment(tn,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),tn.start.addScaledVector(u,d),tn.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,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.deactivate()}resume(){this.activate()}},dh=Pg;dh.isLocked=!1;var go=require("three"),LD=require("three/examples/jsm/utils/BufferGeometryUtils.js");var PG,RD=new Promise(i=>{PG=i});var BD;var MG=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.65/build/",OG=i=>`
1328
1328
  (async function() {
1329
1329
  const [wasmImport, wasmBinary] = await Promise.all([
1330
1330
  import('${i}' + 'navmesh.js'),
@@ -1402,7 +1402,7 @@ onmessage = function(messageEvent) {
1402
1402
  }
1403
1403
  ]
1404
1404
  }`}if(o){n=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let d;a!==void 0?d=a:i.method==="POST"&&i.body&&(d=Ih(JSON.parse(i.body),t)),d!==void 0&&(n+=`&data=${encodeURIComponent(d.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=Ih(JSON.parse(i.body),t));let s=await fetch(n,{method:o?"GET":i.method,headers:o?void 0:qU(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return o&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return o&&(l=l.response),l}}var AR=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return AR(e,t)}return Pr.isBoolean(i)?Pr.getDisplayedValue(i).toLowerCase():Pr.getDisplayedValue(i)},Ih=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
1405
- `:"")+Ih(e.children,t);if(e.type==="variable"){let n=t.getVariable(e.variableId);if(n!==void 0)return AR(n,t)}}return""}).join("");var Ov=1e3,wR=512*Ov;function ZU(i,t){let e=typeof i;return!!((t==="string"||t==="number")&&e===t||t==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||t==="image"&&e==="string"&&i.startsWith("http"))}var ER="https://hooks.spline.design",JU=`${ER}/events?hashFile=`,rme=`${ER}/`,Dv=class{constructor(t,e){this.id=t;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=_a();this.reconnectWaitFor=Ov;this._onError=t=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=t=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ov,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ov,this._connected=!1};this._onMessage=t=>{let e=t.data,r;try{r=JSON.parse(e)}catch(n){console.error("Error parsing webhook message",n)}if(r){let n=!1;this.userWebhook.parametersSchemas.forEach(({data:o})=>{r[o.name]!==void 0&&ZU(r[o.name],o.type)&&(this.result===void 0&&(this.result={}),this.result[o.name]=r[o.name],n=!0)}),n&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(JU+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>wR&&(this.reconnectWaitFor=wR),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let r of this.userWebhook.parametersSchemas)if(r.data.name===t)return Mm.defaultParameterValueByType(r.data.type)}}};ur("API",({eventContext:i,eventManager:t})=>new Cv(i,t));ur("WEBHOOK",({eventContext:i,eventManager:t})=>new Tv(i,t));Zt("UserAPI",({data:i,page:t,shared:e,actionCondition:r})=>new Pv(i,t,e,r));c2({createUserAPI:(i,t,e)=>new Mv(i,t,e),createUserWebhook:(i,t)=>new Dv(i,t)});Pe("api-services");var Iv=class extends Ut{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onVoice=({value:e,frequencies:r})=>{this.events.forEach(n=>{n.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantListener"&&!r.data.disabled).forEach(r=>{this.events.push(new mA(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},mA=class{constructor(t,e,r,n,o,a){this.id=t;this.data=e;this.object=r;this.actions=Vt(e,e.actions,n,o,a,r)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var Rv=class extends Ut{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onTriggerEvent=({description:e,direction:r})=>{let n=this.events.find(o=>o.data.description===e);n&&(r==="backward"?n.dispatchReverse():n.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantTrigger"&&!r.data.disabled).forEach(r=>{this.events.push(new yA(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},yA=class{constructor(t,e,r,n,o,a){this.id=t;this.data=e;this.object=r;this.actions=Vt(e,e.actions,n,o,a,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};function $U(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function ez(i,t,e){let r,n,o,a=Math.floor(i*6),s=i*6-a,l=e*(1-t),c=e*(1-s*t),d=e*(1-(1-s)*t);switch(a%6){case 0:r=e,n=d,o=l;break;case 1:r=c,n=e,o=l;break;case 2:r=l,n=e,o=d;break;case 3:r=l,n=c,o=e;break;case 4:r=d,n=l,o=e;break;case 5:default:r=e,n=l,o=c;break}return{r:r*255,g:n*255,b:o*255}}function tz(i,t,e){i/=255,t/=255,e/=255;let r=Math.max(i,t,e),n=Math.min(i,t,e),o=r,a=r-n,s=r==0?0:a/r,l;if(r==n)l=0;else{switch(r){case i:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-i)/a+2;break;case e:default:l=(i-t)/a+4;break}l/=6}return{h:l,s,v:o}}function rz(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function nz(i,t,e){return(i<<16)+(t<<8)+e}function iz(i,t,e){return i=Math.round(i),t=Math.round(t),e=Math.round(e),"#"+[i,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function oz(i){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(t,(r,n,o,a)=>String(n+n+o+o+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var CR={parseRgba:$U,hsvToRgb:ez,rgbToHsv:tz,hexToRgb:rz,rgbToHex:nz,rgbToHexString:iz,hexStringToRgb:oz};var TR=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],az=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Xa=[],Nv=[];for(let i=1;i<=8;i++)for(let t=0;t<TR.length;t++){let e=TR[t];Xa.push(e/Math.pow(2,8-i)),Nv.push(az[t]+i)}var Bv=[32,2e3],gA=Xa.filter((i,t)=>Xa[t]>Bv[0]&&Xa[t]<Bv[1]),PR=Nv.filter((i,t)=>Xa[t]>Bv[0]&&Xa[t]<Bv[1]);var Lv=class{static getFrequencies(t,e,r,n="frequency",o=-100,a=-30){r||(r=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(r));let s=e/2,l=1/r.length*s,c,d,u;if(n==="music"||n==="voice"){let f=n==="voice"?gA:Xa,m=Array(f.length).fill(o);for(let y=0;y<r.length;y++){let g=y*l,v=r[y];for(let b=f.length-1;b>=0;b--)if(g>f[b]){m[b]=Math.max(m[b],v);break}}c=m,d=n==="voice"?gA:Xa,u=n==="voice"?PR:Nv}else c=Array.from(r),d=c.map((f,m)=>l*m),u=d.map(f=>`${f.toFixed(2)} Hz`);let p=c.map(f=>Math.max(0,Math.min((f-o)/(a-o),1)));return{values:new Float32Array(p),frequencies:d,labels:u}}};var sz="gpt-realtime",lz=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function cz(i){try{return(await(await fetch(lz()+"session?uuidfile="+i)).json()).token}catch(t){console.error("Token generation error:",t)}}var vA=class{constructor(t){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return Lv.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((r,n)=>r+n,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},_v=class{constructor(t){this.callbacks=t;this.rafId=0;this.isOpen=!1;this.onMessage=t=>{this.callbacks.onMessage(t.data)};this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()};this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(t){let e=await cz(t);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=c=>{let d=c.streams[0];this.audioElement.srcObject=d,this.analyser=new vA(d)};let r=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(r.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let n=await this.pc.createOffer();await this.pc.setLocalDescription(n);let l={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime/calls?model=${sz}`,{method:"POST",body:n.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(l),this.animate()}send(t){return this.dc?(this.dc.send(t),!0):!1}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}};function dz(){try{return window.__SPLINE_PLAY_VOICE_HOST__===!0&&window.parent!==window}catch{return!1}}function MR(i,t,e){if(!dz())return null;let r=!1,n=a=>{window.parent.postMessage({__splinePlayFrame:!0,...a},"*")},o=a=>{if(a.source!==window.parent)return;let s=a.data;!s||s.__splinePlayFrameHost!==!0||s.id!==i||(s.type==="voice-open"?(r=!0,e.onOpen()):s.type==="voice-message"&&typeof s.data=="string"?e.onMessage(s.data):s.type==="voice-level"&&typeof s.value=="number"?e.onVoice(s.value,s.frequencies instanceof Float32Array?s.frequencies:new Float32Array(0)):s.type==="voice-error"&&console.error("Voice assistant host error:",s.message))};return window.addEventListener("message",o),n({type:"voice-connect",id:i,hash:t}),{send:a=>r?(n({type:"voice-send",id:i,message:a}),!0):!1,disconnect:()=>{r=!1,window.removeEventListener("message",o),n({type:"voice-disconnect",id:i})}}}var Fv=class{constructor(t,e,r){this.data=t;this.id=e;this.shared=r;this.emitter=_a();this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onServerEvent=t=>{let e=JSON.parse(t);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let r of e.response.output)if(r.type==="function_call")for(let[n,o]of this.tools)r.name===n.name&&(o(JSON.parse(r.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(t){this.data=t}setColorByName(t,e){let r=this.shared.getColorByName(t);if(r){let{id:n}=r,{r:o,g:a,b:s}=CR.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(n,{r:o/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let t={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,r)=>{this.voice=e,this.frequencies=r,this.emitter.emit("voice",{value:e,frequencies:r})}};this.hosted=MR(this.id,this.data.integration.hash,t),!this.hosted&&(this.session=new _v(t),await this.session.connect(this.data.integration.hash))}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){t.event_id=t.event_id||crypto.randomUUID();let e=JSON.stringify(t);(this.hosted?this.hosted.send(e):this.session?.send(e)??!1)?this.appendEvent(t):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:o})=>{this.setColorByName("Voice Assistant Color",o)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:o,value:a})=>{let s=this.shared.getVariableByName(o);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:o,value:a})=>{this.setColorByName(o,a)});let r=this.shared.scene,n=[];r.traverseEntity(o=>{o.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;n.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(n)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:o,direction:a})=>{this.emitter.emit("trigger_event",{description:o,direction:a})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([o])=>o)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((r,n)=>r+n,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};ur("AIAssistantListener",({eventContext:i,eventManager:t})=>new Iv(i,t));ur("AIAssistantTrigger",({eventContext:i,eventManager:t})=>new Rv(i,t));d2((i,t,e)=>new Fv(i,t,e));Pe("ai-assistant");var Vs=class extends Es{constructor(e,r,n){super(e,r,n);this.data=r}};var NR=require("three");var nn=require("three");var su=class extends nn.Group{constructor(){super();this.caretIndex=0;this._caretVisibleAlpha=1;this._selectionVisibleAlpha=.3;this.current={start:0,end:void 0};this.matrixAutoUpdate=!1,this.caretMesh=new nn.Mesh(new nn.PlaneGeometry(1,1),new nn.MeshBasicMaterial({transparent:!0,opacity:0,side:nn.DoubleSide})),this.add(this.caretMesh),this.selectionMesh=new nn.Mesh(new nn.PlaneGeometry(1,1),new nn.MeshBasicMaterial({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:nn.DoubleSide})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(e){this.visible=!0,this.object=e,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=-this.caretHeight*.5,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:e}=this.object.geometry.userData.parameters;this.caretMesh.position.z=e,this.selectionMesh.position.z=e}updateHelperMatrix(){if(this.object===void 0)return;let e=this.object,r=e.parent;r!==null&&r.updateWorldMatrix(!0,!1),e.matrixAutoUpdate&&e.updateMatrix(),r!==null?(this.matrixWorld.multiplyMatrices(r.matrixWorld,e.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,e.matrix)):this.matrixWorld.multiplyMatrices(e.hiddenMatrix,e.matrix),this.matrix.copy(this.matrixWorld);for(let n of this.children)n.matrixWorld.copy(this.matrixWorld);e.updateWorldMatrix(!0,!0)}setCaretColor(e){let r=this.caretMesh.material;r.color.setRGB(e.r,e.g,e.b);let n=this._caretVisibleAlpha===r.opacity;this._caretVisibleAlpha=e.a,n&&(r.opacity=this._caretVisibleAlpha)}setSelectionColor(e){this.selectionMesh.material.color.setRGB(e.r,e.g,e.b)}setCaretPosition(e,r={}){if(this.object===void 0)return;this.caretIndex=e;let n=this.object.wrappedText,[o,a]=kv(n,e),[s,l]=e>0?kv(n,e-1):[null,null];(e>0&&n.length?n[s].charAt(l):null)===`
1405
+ `:"")+Ih(e.children,t);if(e.type==="variable"){let n=t.getVariable(e.variableId);if(n!==void 0)return AR(n,t)}}return""}).join("");var Ov=1e3,wR=512*Ov;function ZU(i,t){let e=typeof i;return!!((t==="string"||t==="number")&&e===t||t==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||t==="image"&&e==="string"&&i.startsWith("http"))}var ER="https://hooks.spline.design",JU=`${ER}/events?hashFile=`,rme=`${ER}/`,Dv=class{constructor(t,e){this.id=t;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=_a();this.reconnectWaitFor=Ov;this._onError=t=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=t=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ov,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ov,this._connected=!1};this._onMessage=t=>{let e=t.data,r;try{r=JSON.parse(e)}catch(n){console.error("Error parsing webhook message",n)}if(r){let n=!1;this.userWebhook.parametersSchemas.forEach(({data:o})=>{r[o.name]!==void 0&&ZU(r[o.name],o.type)&&(this.result===void 0&&(this.result={}),this.result[o.name]=r[o.name],n=!0)}),n&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(JU+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>wR&&(this.reconnectWaitFor=wR),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let r of this.userWebhook.parametersSchemas)if(r.data.name===t)return Mm.defaultParameterValueByType(r.data.type)}}};ur("API",({eventContext:i,eventManager:t})=>new Cv(i,t));ur("WEBHOOK",({eventContext:i,eventManager:t})=>new Tv(i,t));Zt("UserAPI",({data:i,page:t,shared:e,actionCondition:r})=>new Pv(i,t,e,r));c2({createUserAPI:(i,t,e)=>new Mv(i,t,e),createUserWebhook:(i,t)=>new Dv(i,t)});Pe("api-services");var Iv=class extends Ut{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onVoice=({value:e,frequencies:r})=>{this.events.forEach(n=>{n.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantListener"&&!r.data.disabled).forEach(r=>{this.events.push(new mA(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},mA=class{constructor(t,e,r,n,o,a){this.id=t;this.data=e;this.object=r;this.actions=Vt(e,e.actions,n,o,a,r)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(t){t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}};var Rv=class extends Ut{constructor(e,r){super(e);this.eventManager=r;this.events=[];this.onTriggerEvent=({description:e,direction:r})=>{let n=this.events.find(o=>o.data.description===e);n&&(r==="backward"?n.dispatchReverse():n.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(r=>r.data.type==="AIAssistantTrigger"&&!r.data.disabled).forEach(r=>{this.events.push(new yA(r.id,r.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},yA=class{constructor(t,e,r,n,o,a){this.id=t;this.data=e;this.object=r;this.actions=Vt(e,e.actions,n,o,a,r)}dispatch(){let t=this.actions;t.Audio.forEach(e=>e.dispatchConditional()),t.Particles.forEach(e=>e.dispatchConditional()),t.Video.forEach(e=>e.dispatchConditional()),t.Create.forEach(e=>e.dispatch()),t.Destroy.forEach(e=>e.dispatch()),t.Reset.forEach(e=>e.dispatch()),t.Transition.forEach(e=>{!e.shouldReinit()||(e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init())}),t.Transition.forEach(e=>e.play()),t.Animation.forEach(e=>e.play()),t.SwitchCamera.forEach(e=>e.play()),t.SceneTransition.forEach(e=>e.dispatch()),t.SetVariable.forEach(e=>e.checkConditions()),t.SetVariable.forEach(e=>e.dispatch()),t.DynamicVariablePlay.forEach(e=>e.dispatch()),t.ClearLocalStorage.forEach(e=>e.dispatch()),t.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let t=this.actions;t.Transition.forEach(e=>e.reverseFromCurrent()),t.Particles.forEach(e=>e.reverseFromCurrent()),t.Animation.forEach(e=>e.reverseFromCurrent()),t.SwitchCamera.forEach(e=>e.reverseFromCurrent()),t.Create.forEach(e=>e.dispatchStop())}};function $U(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function ez(i,t,e){let r,n,o,a=Math.floor(i*6),s=i*6-a,l=e*(1-t),c=e*(1-s*t),d=e*(1-(1-s)*t);switch(a%6){case 0:r=e,n=d,o=l;break;case 1:r=c,n=e,o=l;break;case 2:r=l,n=e,o=d;break;case 3:r=l,n=c,o=e;break;case 4:r=d,n=l,o=e;break;case 5:default:r=e,n=l,o=c;break}return{r:r*255,g:n*255,b:o*255}}function tz(i,t,e){i/=255,t/=255,e/=255;let r=Math.max(i,t,e),n=Math.min(i,t,e),o=r,a=r-n,s=r==0?0:a/r,l;if(r==n)l=0;else{switch(r){case i:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-i)/a+2;break;case e:default:l=(i-t)/a+4;break}l/=6}return{h:l,s,v:o}}function rz(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function nz(i,t,e){return(i<<16)+(t<<8)+e}function iz(i,t,e){return i=Math.round(i),t=Math.round(t),e=Math.round(e),"#"+[i,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function oz(i){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(t,(r,n,o,a)=>String(n+n+o+o+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var CR={parseRgba:$U,hsvToRgb:ez,rgbToHsv:tz,hexToRgb:rz,rgbToHex:nz,rgbToHexString:iz,hexStringToRgb:oz};var TR=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],az=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Xa=[],Nv=[];for(let i=1;i<=8;i++)for(let t=0;t<TR.length;t++){let e=TR[t];Xa.push(e/Math.pow(2,8-i)),Nv.push(az[t]+i)}var Bv=[32,2e3],gA=Xa.filter((i,t)=>Xa[t]>Bv[0]&&Xa[t]<Bv[1]),PR=Nv.filter((i,t)=>Xa[t]>Bv[0]&&Xa[t]<Bv[1]);var Lv=class{static getFrequencies(t,e,r,n="frequency",o=-100,a=-30){r||(r=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(r));let s=e/2,l=1/r.length*s,c,d,u;if(n==="music"||n==="voice"){let f=n==="voice"?gA:Xa,m=Array(f.length).fill(o);for(let y=0;y<r.length;y++){let g=y*l,v=r[y];for(let b=f.length-1;b>=0;b--)if(g>f[b]){m[b]=Math.max(m[b],v);break}}c=m,d=n==="voice"?gA:Xa,u=n==="voice"?PR:Nv}else c=Array.from(r),d=c.map((f,m)=>l*m),u=d.map(f=>`${f.toFixed(2)} Hz`);let p=c.map(f=>Math.max(0,Math.min((f-o)/(a-o),1)));return{values:new Float32Array(p),frequencies:d,labels:u}}};var sz="gpt-realtime",lz=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function cz(i){try{return(await(await fetch(lz()+"session?uuidfile="+i)).json()).token}catch(t){console.error("Token generation error:",t)}}var vA=class{constructor(t){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return Lv.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((r,n)=>r+n,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},_v=class{constructor(t){this.callbacks=t;this.rafId=0;this.isOpen=!1;this.onMessage=t=>{this.callbacks.onMessage(t.data)};this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()};this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(t){let e=await cz(t);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=c=>{let d=c.streams[0];this.audioElement.srcObject=d,this.analyser=new vA(d)};let r=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(r.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let n=await this.pc.createOffer();await this.pc.setLocalDescription(n);let l={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime/calls?model=${sz}`,{method:"POST",body:n.sdp,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(l),this.animate()}send(t){return this.dc?(this.dc.send(t),!0):!1}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}};function dz(){try{return window.__SPLINE_PLAY_VOICE_HOST__===!0&&window.parent!==window}catch{return!1}}function MR(i,t,e){if(!dz())return null;let r=!1,n=a=>{window.parent.postMessage({__splinePlayFrame:!0,...a},"*")},o=a=>{if(a.source!==window.parent)return;let s=a.data;!s||s.__splinePlayFrameHost!==!0||s.id!==i||(s.type==="voice-open"?(r=!0,e.onOpen()):s.type==="voice-message"&&typeof s.data=="string"?e.onMessage(s.data):s.type==="voice-level"&&typeof s.value=="number"?e.onVoice(s.value,s.frequencies instanceof Float32Array?s.frequencies:new Float32Array(0)):s.type==="voice-error"&&console.error("Voice assistant host error:",s.message))};return window.addEventListener("message",o),n({type:"voice-connect",id:i,hash:t}),{send:a=>r?(n({type:"voice-send",id:i,message:a}),!0):!1,disconnect:()=>{r=!1,window.removeEventListener("message",o),n({type:"voice-disconnect",id:i})}}}var Fv=class{constructor(t,e,r){this.data=t;this.id=e;this.shared=r;this.emitter=_a();this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onServerEvent=t=>{let e=JSON.parse(t);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let r of e.response.output)if(r.type==="function_call")for(let[n,o]of this.tools)r.name===n.name&&(o(JSON.parse(r.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(t){this.data=t}setColorByName(t,e){let r=this.shared.getColorByName(t);if(r){let{id:n}=r,{r:o,g:a,b:s}=CR.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(n,{r:o/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let t={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,r)=>{this.voice=e,this.frequencies=r,this.emitter.emit("voice",{value:e,frequencies:r})}};this.hosted=MR(this.id,this.data.integration.hash,t),!this.hosted&&(this.session=new _v(t),await this.session.connect(this.data.integration.hash))}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){t.event_id=t.event_id||crypto.randomUUID();let e=JSON.stringify(t);(this.hosted?this.hosted.send(e):this.session?.send(e)??!1)?this.appendEvent(t):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:o})=>{this.setColorByName("Voice Assistant Color",o)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:o,value:a})=>{let s=this.shared.getVariableByName(o);if(s){let l=this.shared.getVariable(s.id),c;if(typeof l=="number"){if(c=parseFloat(a),!Number.isFinite(c))return}else typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a};this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:o,value:a})=>{this.setColorByName(o,a)});let r=this.shared.scene,n=[];r.traverseEntity(o=>{o.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;n.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(n)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:o,direction:a})=>{this.emitter.emit("trigger_event",{description:o,direction:a})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([o])=>o)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((r,n)=>r+n,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};ur("AIAssistantListener",({eventContext:i,eventManager:t})=>new Iv(i,t));ur("AIAssistantTrigger",({eventContext:i,eventManager:t})=>new Rv(i,t));d2((i,t,e)=>new Fv(i,t,e));Pe("ai-assistant");var Vs=class extends Es{constructor(e,r,n){super(e,r,n);this.data=r}};var NR=require("three");var nn=require("three");var su=class extends nn.Group{constructor(){super();this.caretIndex=0;this._caretVisibleAlpha=1;this._selectionVisibleAlpha=.3;this.current={start:0,end:void 0};this.matrixAutoUpdate=!1,this.caretMesh=new nn.Mesh(new nn.PlaneGeometry(1,1),new nn.MeshBasicMaterial({transparent:!0,opacity:0,side:nn.DoubleSide})),this.add(this.caretMesh),this.selectionMesh=new nn.Mesh(new nn.PlaneGeometry(1,1),new nn.MeshBasicMaterial({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:nn.DoubleSide})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(e){this.visible=!0,this.object=e,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=-this.caretHeight*.5,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(this.object===void 0)return;this.updateHelperMatrix();let{depth:e}=this.object.geometry.userData.parameters;this.caretMesh.position.z=e,this.selectionMesh.position.z=e}updateHelperMatrix(){if(this.object===void 0)return;let e=this.object,r=e.parent;r!==null&&r.updateWorldMatrix(!0,!1),e.matrixAutoUpdate&&e.updateMatrix(),r!==null?(this.matrixWorld.multiplyMatrices(r.matrixWorld,e.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,e.matrix)):this.matrixWorld.multiplyMatrices(e.hiddenMatrix,e.matrix),this.matrix.copy(this.matrixWorld);for(let n of this.children)n.matrixWorld.copy(this.matrixWorld);e.updateWorldMatrix(!0,!0)}setCaretColor(e){let r=this.caretMesh.material;r.color.setRGB(e.r,e.g,e.b);let n=this._caretVisibleAlpha===r.opacity;this._caretVisibleAlpha=e.a,n&&(r.opacity=this._caretVisibleAlpha)}setSelectionColor(e){this.selectionMesh.material.color.setRGB(e.r,e.g,e.b)}setCaretPosition(e,r={}){if(this.object===void 0)return;this.caretIndex=e;let n=this.object.wrappedText,[o,a]=kv(n,e),[s,l]=e>0?kv(n,e-1):[null,null];(e>0&&n.length?n[s].charAt(l):null)===`
1406
1406
  `&&(o++,a=0),this.current.start=e,this.current.end=void 0;let[d,u]=bA(this.object,o,a),{AD:p,descender:h}=this.object,f=h+p*.5,{width:m,height:y,depth:g}=this.object.geometry.userData.parameters,v=typeof m=="string"?0:m,b=typeof y=="string"?0:y;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(d-v*.5,u+f+b*.5,g),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(e,r){if(this.object===void 0)return;let n=this.object.wrappedText;this.current.start=e,this.current.end=r;let o=[],a=[],s=uz(n,e,r),{lineHeight:l,AD:c,descender:d}=this.object,u=d+c*.5-l*.5;for(let[v,b,S]of s)if(b!==S){let[x,A]=bA(this.object,v,b),[w,E]=bA(this.object,v,S),P=A,M=E;P+=u,M+=u,M+=l;let D=o.length/3;o.push(x,P,0),o.push(w,P,0),o.push(w,M,0),o.push(x,M,0),a.push(D+0,D+1,D+2),a.push(D+2,D+3,D+0)}let p=new nn.BufferGeometry;p.setIndex(a),p.setAttribute("position",new nn.Float32BufferAttribute(o,3));let{width:h,height:f,depth:m}=this.object.geometry.userData.parameters,y=typeof h=="string"?0:h,g=typeof f=="string"?0:f;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=p,this.selectionMesh.position.x=-y*.5,this.selectionMesh.position.y=g*.5,this.selectionMesh.position.z=m,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(e,r,n="previous"){if(this.object===void 0||this.object.font===void 0)return;let o=this.object.wrappedText,a=o.length,s=this.object.lineHeight,l=a*s,{height:c,verticalAlign:d}=this.object.geometry.userData.parameters,u=typeof c=="string"?0:c,p=0;d===3?p=u-l:d===2&&(p=u*.5-l*.5);let h=Math.min(Math.floor(Math.max(Math.min(-r-p,l),0)/s),a-1),f=this.object.charCoords[h],m=this.object.charWidths[h],y=0,g=!1;if(n==="previous"){for(let b=0;b<f.length;b++)if(f[b][0]+m[b]*.5-e>0){y=b,g=!0;break}}else if(n==="closest"){let b=1/0;for(let S=0;S<f.length;S++){let x=f[S][0]+m[S]*.5,A=Math.abs(x-e);A<b&&(b=A,y=S,g=!0)}}else for(let b=0;b<f.length;b++){let S=f[b][0],x=f[b][0]+m[b];if(e>=S&&e<x){y=b,g=!0;break}}return g||(y=f.length),{index:this.getGlobalIndexFromLineAndCharIndexes(o,h,y),lineIndex:h,characterIndex:y}}getGlobalIndexFromLineAndCharIndexes(e,r,n){return e.slice(0,r).reduce((o,a)=>o+=a.length,0)+n}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function bA(i,t,e){let{charCoords:r,charWidths:n,initialOffsetY:o,lineHeight:a}=i;if(r[t]&&r[t].length===0||r.length===0){let u=0,{horizontalAlign:p}=i.data.geometry,h=i.wrappedText,{width:f}=i.geometry.userData.parameters;return h.length===1&&h[0].length===0&&(p===3?u=f*.5:p===2&&(u=f)),[u,o-a*t]}let s=r[t];if(s===void 0||s.length===0)return[0,0];let[l,c]=s[Math.min(e,s.length-1)],d=l;return e>=s.length&&(d+=n[t][e-1]),[d,c]}function kv(i,t){let e=0;for(let r=0;r<i.length;r++){let n=i[r],o=t-e;if(o<=n.length)return[r,o];e+=n.length}return[Math.max(0,i.length-1),i[i.length-1]?.length??0]}function uz(i,t,e){let[r,n]=kv(i,t),[o,a]=kv(i,e),s=[];n>=i[r].length&&(r++,n=0);for(let l=r;l<=o;l++){let c=i[l],d=l===r?n:0,u=l===o?a:c.length;s.push([l,d,u])}return s}function OR(i,t){let e=rr.fromHex(3223857),r=.8;for(let n of i.layers){if(n.data.type==="light"||n.data.type==="displace"||n.data.type==="fresnel"||n.data.type==="dust"||n.data.type==="matcap"||n.data.type==="texture"||n.data.type==="toon"||n.data.type==="outline"||n.data.type==="transmission"||n.data.type==="noise"||n.data.type==="vertexColor")continue;let o=typeof n.data.alpha=="string"?Number(t.getVariable(n.data.alpha)):n.data.alpha;if(n.data.type==="color"&&o>.3){e=pz(n.data.color,t),r=o;break}else if((n.data.type==="depth"||n.data.type==="gradient")&&o>.3){let a=hz(n.data);e={r:a[0],g:a[1],b:a[2]},r=typeof n.data.alpha=="string"?1:n.data.alpha;break}}return{...e,a:r}}function pz(i,t){return typeof i=="string"?t.data.colors[i]:i}function hz(i){return i.colors[0]}var Zi=require("three");var Vv=class{constructor(){this._clickCount=0;this._lastTime=0;this._lastPosition=[0,0];this._delay=500;this._distance=2;this._onMouseDown=t=>{let e=[t.clientX,t.clientY],r=new Date().getTime();if(this._clickCount>0){let n=e[0]-this._lastPosition[0],o=e[1]-this._lastPosition[1];Math.sqrt(n*n+o*o)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=r-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=r};this._onMouseUp=t=>{}}start(t,e=500,r=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=r,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}};function fz(){let i=document.createElement("textarea");return i.style.position="fixed",i.style.top="200px",i.style.left="400px",i.style.zIndex="-1",i.style.border="1px solid rgba(255,0,0,0.5)",i.style.width="10px",i.style.height="500px",i.style.color="white",i.style.opacity="0.5",i.style.background="transparent",i.style.display="none",i.style.margin="0px",i.style.padding="0px",i.style.boxSizing="content-box",i.style.pointerEvents="none",i}var mz=new Zi.Vector3(0,0,1),DR=new Zi.Vector3,IR=new Zi.Vector3,RR=new Zi.Matrix3,Gv=class{constructor(t,e,r,n,o){this.containerScene=t;this.raycaster=e;this.sharedAssets=r;this.requestRender=n;this.onExit=o;this.htmlInput=null;this.virtualInput=null;this.helper=new su;this.doubleClickHandler=new Vv;this.isDragging=!1;this.plane=new Zi.Plane;this.caretInterval=0;this.planeIntersection=new Zi.Vector3;this.projected=new Zi.Vector2;this._lastIndex=0;this._isFirstDragMove=!1;this.selectionOnDragStart=0;this.onTextMaterialChanged=()=>{let t=this.virtualInput?.data;if(this.virtualInput!==void 0&&t){let e=t.material,r=typeof e=="string"?this.sharedAssets.data.materials[e]:e,n=OR(r,this.sharedAssets);this.helper.setCaretColor(n)}};this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)};this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))};this.handleCaretUpdate=t=>{if(!this.htmlInput||!this.virtualInput)return;let e=this.helper,r=t?.key==="ArrowLeft"||t?.key==="ArrowRight",n=t?.key==="ArrowUp"||t?.key==="ArrowDown";this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(e.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:r,verticalKeyMove:n}),this.startAnimateTextCursor()):e.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()};this.containerScene.add(this.helper)}createInput(){return this.htmlInput=fz(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:r}=e,{index:n,characterIndex:o}=e;this.virtualInput?.wrappedText?.length&&this.virtualInput.wrappedText[r][Math.max(0,o-1)]===`
1407
1407
  `&&(n--,o--),this._lastIndex=n,this._isFirstDragMove=!0;let a=this.checkClickedObject();if(t===1){if(a===null)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=n,this.isDragging=!0,this.setInputSelection(n)}else a===this.virtualInput&&(t===2?this.selectClosestWord(r,o):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let e=this.data?.geometry.text;this.htmlInput.value=typeof e=="string"?"":e?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:r,characterIndex:n}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},o=e;r!==void 0&&n!==void 0&&this.virtualInput?.wrappedText[r][n-1]===`
1408
1408
  `&&o--,this.htmlInput.setSelectionRange(Math.min(t,o),Math.max(t,o))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof Vs)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let r=this.virtualInput.wrappedText,n=r[t],o=e+1,a=e;n[e]!==" "&&(o=this.findNextCharOccurence(n,e,"forward"," "),a=this.findNextCharOccurence(n,e,"backward"," "),a>0&&a++,o>=n.length-1&&t===r.length-1&&o++);let s=this.helper,l=s.getGlobalIndexFromLineAndCharIndexes(r,t,a),c=s.getGlobalIndexFromLineAndCharIndexes(r,t,o);this.setInputSelection(l,c)}findNextCharOccurence(t,e,r,n=" "){let o=Math.max(0,t.length-1),a=r==="forward"?o:0,s=r==="forward"?1:-1,l=Math.max(Math.min(e,o),0);for(;l!==a;)if(l+=s,t.charAt(l)===n)return l;return a}getPointOnPlane(){let t=this.virtualInput?.data;if(!(!this.virtualInput||!t)&&this.raycaster.ray.intersectsPlane(this.plane)){this.planeIntersection===null&&(this.planeIntersection=new Zi.Vector3);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let r=typeof t.geometry.width=="number"?t.geometry.width:1,n=typeof t.geometry.height=="number"?t.geometry.height:1;this.projected.set(e.x+r*.5,e.y-n*.5)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(RR.getNormalMatrix(this.virtualInput.matrixWorld),DR.copy(mz).applyMatrix3(RR).normalize(),this.virtualInput.localToWorld(IR.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(DR,IR))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),Vc&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=yz(t.geometry.horizontalAlign))}};function yz(i){return i===4?"justify":i===2?"right":i===3?"center":"left"}var LR=(i,t)=>{if(typeof i=="string"){let e=t.data(i);if(e)return LR(e.value,t)}return Pr.getDisplayedValue(i)};function BR(i,t){let e=i.text,r="";if(typeof e=="string"){let n=t.variables.data(r);n&&(r=LR(n.value,t.variables))}else r=e.textValue.toString();return r}var Uv=class extends Ut{constructor(e,r){super(e);this.eventManager=r;this._textInputs=[];this.sceneHelpers=new NR.Scene;this.helper=new su;this._onMouseDownFocusIn=e=>{if(Mr.length>1)return;this.eventContext.updateRaycaster(e);let r=null;if(this.eventContext.raycaster){for(let n of this._textInputs)if(this.eventContext.raycaster.intersectObject(n,!0).length>0){r=n;break}}this.focusOnTextInput(r),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(e),this._onMouseDown(e)};this.onExit=()=>{let{virtualInput:e}=this.textInputManager;if(e===null)return;let r=this.textInputManager.htmlInput;this.helper.hide(),r?.setSelectionRange(r.value.length,r.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:n}=this.eventContext;n.removeEventListener("pointerdown",this._onMouseDown,!1),n.removeEventListener("pointerup",this._onMouseUp,!1),n.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),n.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()};this._onMouseDown=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)};this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)};this._onMouseMove=e=>{this.eventContext.updateRaycaster(e),this.textInputManager.handleMouseMove()};this._onTextEdit=e=>{let{htmlInput:r,virtualInput:n,helper:o}=this.textInputManager;if(!r||!n)return;let a=r.value;n.textGeometry.setText(a,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let s=n.data;o.update();let l=s.geometry.text;if(typeof l=="string"){let c=l;this.eventContext.sharedAssets.updateVariable(c,{textValue:a})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()};this._onCaretUpdate=e=>{this.textInputManager.handleCaretUpdate(e)};this._onKeyPress=e=>{e.key==="Escape"&&this.onExit()};this.textInputManager=new Gv(this.sceneHelpers,e.raycaster,e.sharedAssets,e.requestRender,this.onExit)}connect(){let e=[];if(this.eventContext.scene.traverseEntity(o=>{o instanceof Vs&&e.push(o)}),this._textInputs=e,e.length===0)return;let{domElement:r}=this.eventContext;r.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let n=this.textInputManager.createInput();document.body.appendChild(n),n.style.display="none",n.addEventListener("keyup",this._onCaretUpdate),n.addEventListener("keydown",this._onCaretUpdate),n.addEventListener("beforeinput",this._onCaretUpdate),n.addEventListener("paste",this._onCaretUpdate),n.addEventListener("cut",this._onCaretUpdate),n.addEventListener("select",this._onCaretUpdate),n.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let e=this.textInputManager.htmlInput,{domElement:r,sharedAssets:n}=this.eventContext;r.removeEventListener("pointerdown",this._onMouseDownFocusIn),e?.removeEventListener("keyup",this._onCaretUpdate),e?.removeEventListener("keydown",this._onCaretUpdate),e?.removeEventListener("beforeinput",this._onCaretUpdate),e?.removeEventListener("paste",this._onCaretUpdate),e?.removeEventListener("cut",this._onCaretUpdate),e?.removeEventListener("select",this._onCaretUpdate),e?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(o=>{let a=BR(o.data.geometry,this.eventContext.sharedAssets.data);o.textGeometry.setText(a,n)}),r.removeEventListener("pointerdown",this._onMouseDown,!1),r.removeEventListener("pointerup",this._onMouseUp,!1),r.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(e){this.textInputManager.focus(e),this.textInputManager.onTextMaterialChanged();let r=this.textInputManager.htmlInput;if(!r||e===null)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let n=BR(e.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);r.value=n,r.setSelectionRange(0,0),this.textInputManager.helper.show(e),r.style.display="block",r.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:o}=this.eventContext;o.removeEventListener("pointerdown",this._onMouseDownFocusIn),o.addEventListener("pointerdown",this._onMouseDown,!1),o.addEventListener("pointerup",this._onMouseUp,!1),o.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};ur("Textfields",({eventContext:i,eventManager:t})=>new Uv(i,t));Oi("InputGeometry",(i,t,e)=>new Vs(i,t,e));Pe("textinputs");var _R=new Map,Rh=new Map,lu=class{constructor(t,e,r,n){this.data=e;this.isPlayAudioAction=!0;let{audio:o,volume:a,delay:s,loop:l}=e;if(!o)throw new Error("Missing property");try{let c=typeof o=="string"?n.getAudio(o).src:o.data;this.audioPlayer=new Ia({src:c,volume:a,delay:s,loop:l})}catch{console.warn(`Could not create an audio player for this object: "${r.name}" and this audio: "${o}"`)}Rh.has(r.uuid)?Rh.get(r.uuid).push(this):Rh.set(r.uuid,[this]),_R.set(t,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer?.status==="playing"?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):this.data.toggle==="pause"?this.audioPlayer?.status==="playing"?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},xA=class{constructor(t){this.data=t;this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let e=_R.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):e.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let e=Rh.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...Rh.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},zv=class{constructor(t,e,r,n,o){this.data=e;this.shared=n;this.condition=o;if(e.interaction==="play")this.interaction=new lu(t,e,r,n);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new xA(e);else throw new Error("Missing property")}dispatchBasic(){if(We(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(We(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(We(this.shared,this.condition)===!1)return!1;this.interaction instanceof lu&&(t==="start"?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};Zt("Audio",({id:i,data:t,object:e,shared:r,actionCondition:n})=>new zv(i,t,e,r,n));Pe("audio");function FR(i,t){let e;if("material"in i){let n=i.material;Array.isArray(n)?e=i.material[0].layers.find(o=>o.uuid===t):e=i.material.layers.find(o=>o.uuid===t)}if(!e)return;let r=e.color?.texture?.image?.img??e.holders?.find(n=>n.isVideo)?.img;return r instanceof HTMLVideoElement?r:void 0}var kR=new Map,Bh=new Map,Nh=class{constructor(t,e,r){this.data=e;this.isPlayVideoAction=!0;this.delay=0;this.status="stopped";let{layerId:n,loop:o,volume:a,delay:s}=e;if(this.object=r,n===void 0)throw new Error("Missing property");let l=FR(r,n);l&&(this.videoElement=l,this.videoElement.loop=o===1/0,Vc&&(this.videoElement.autoplay=!0),a!==void 0&&(this.videoElement.volume=a)),s!==void 0&&(this.delay=s),Bh.has(r.uuid)?Bh.get(r.uuid).push(this):Bh.set(r.uuid,[this]),kR.set(t,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(t){if(!this.videoElement)return;let e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);t?(this.mute(),this.delay+=150):e?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let r=this.videoElement.play();r!==void 0&&r.then(n=>{}).catch(n=>{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())}seek(t){return new Promise(e=>{if(!this.videoElement)return e();let r=this.videoElement.duration;if(r>0){let n=t%r;this.videoElement.currentTime=n}this.videoElement.addEventListener("seeked",()=>e(),{once:!0})})}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)}},SA=class{constructor(t){this.data=t;this.isPauseVideoAction=!0}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(t){let e=kR.get(t);!e||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e[this.data.interaction](),this.disposeDelay()},this.data.delay)):e[this.data.interaction]())}pauseAllVideosFromObject(t){let e=Bh.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllVideos(){let t=[...Bh.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},jv=class{constructor(t,e,r,n,o){this.data=e;this.shared=n;this.condition=o;if(e.interaction==="play")this.interaction=new Nh(t,e,r);else if(e.interaction==="pause"||e.interaction==="stop")this.interaction=new SA(e);else throw new Error("Missing property")}dispatchBasic(){if(We(this.shared,this.condition)===!1)return!1;this.interaction instanceof Nh?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(We(this.shared,this.condition)===!1)return!1;this.interaction instanceof Nh?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}};Zt("Video",({id:i,data:t,object:e,shared:r,actionCondition:n})=>cn(e)?null:new jv(i,t,e,r,n));Pe("video");var Gs=require("three");var AA=(()=>{let i,t,e,r,n=!1;function o(c){!i&&!VR()&&(t?.sharedGameControlGlobals.createdObjects.length??0)>0&&(i=requestAnimationFrame(a)),c&&(t=c,r=c.requestRender,!n&&typeof document<"u"&&(document.addEventListener("visibilitychange",s),n=!0))}function a(c){if(!t||!r){i=void 0,e=void 0;return}let d=e?c-e:0,u=t.sharedGameControlGlobals.createdObjects,p=t.sharedGameControlGlobals.nCreatedPerAction,h=u.length,f=0;for(;f<h;){let m=u[f];m.userData.createdTime===void 0&&(m.userData.createdTime=c),m.userData.lifetime===void 0&&m.userData.quantity===void 0||m.userData.lifetime&&c-m.userData.createdTime<m.userData.lifetime||m.userData.quantity&&p[m.userData.actionId]<=m.userData.quantity?(m.userData.velocity&&(m.position.addScaledVector(m.userData.velocity,d/1e3),m.updateMatrix(),r()),f++):(p[m.userData.actionId]>m.userData.quantity&&p[m.userData.actionId]--,u.splice(f,1),m.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&m.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(m.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(m.rigidBody)):(m.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(y=>y.bvhGeometry!==void 0)),h--,r())}i=f>0?requestAnimationFrame(a):void 0,e=f>0?c:void 0}function s(){VR()?i&&(cancelAnimationFrame(i),i=void 0,e=void 0):o()}function l(){i&&(cancelAnimationFrame(i),i=void 0),n&&typeof document<"u"&&(document.removeEventListener("visibilitychange",s),n=!1),t=void 0,r=void 0,e=void 0}return{play:o,dispose:l}})();function VR(){return!!document&&document.hidden}var GR=new Gs.Quaternion,gz=new Gs.Vector3,vz=new Gs.Vector3,Hv=class{constructor(t,e,r,n,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=o;this.intervalId=null;this.timeoutIdQueue=[];this.uniqueId=Gs.MathUtils.generateUUID();this.dispatch=()=>{if(We(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(We(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))};this.dispatchThrottled=wT(this.dispatch,1e3/this.data.creationSpeed);this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))};this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)};this.dispatchInner=()=>{this.timeoutIdQueue.shift();let t=new Dr(this.object);if(t.playModeVisible=!0,t.expand(),this.data.coordinateSystem!=="world"){let r=this.data.coordinateSystem,n=this.page.scene.find(r);n&&(n.updateMatrixWorldRigid(),t.hiddenMatrix.copy(n.matrixWorldRigid))}t.scale.copy(this.object.scale),t.position.fromArray(this.data.position.map(r=>typeof r=="number"?r:0)),t.rotation.fromArray(this.data.rotation.map(r=>typeof r=="number"?r:0)),t.updateMatrix(),this.page.add(t);let e=this.controlsManager.sharedGameControlGlobals;e.createdObjects.push(t),e.nCreatedPerAction[this.uniqueId]===void 0?e.nCreatedPerAction[this.uniqueId]=1:e.nCreatedPerAction[this.uniqueId]++,t.updateWorldMatrix(!0,!0),t.traverseObject(this.traverseObjectCB),AA.play(),this.controlsManager.requestRender()};this.traverseObjectCB=t=>{t.hasNonUniformScale&&t.updateMatrixWorldRigid();let e;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(t instanceof Fn)if(t.objectForSample){if(t.objectForSample.dataPatched.physics.fusedBody)return;e=t.object}else return t.object.dataPatched.physics.fusedBody===!0&&t.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(t instanceof Dr)e=t.object;else if(e=t,e.dataPatched.cloner?.hideBase)return!0}else{if(t instanceof Fn)return;t instanceof Dr?e=t.object:e=t}this.data.destroy==="Time"?t.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(t.userData.quantity=this.data.destroyAfterQuantity,t.userData.actionId=this.uniqueId);let r=new Gs.Vector3().fromArray(this.data.velocity.map(o=>typeof o=="number"?o:0)),n=e.dataPatched;if(!(n.physics.enabled==="visibility"?!n.visible:!n.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(t,e,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(t.rigidBody?.collider(0).setActiveEvents(1),t.userData.hasCollisionDestroy=!0),t.matrixWorld.decompose(gz,GR,vz),r.applyQuaternion(GR),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&t.rigidBody?.setLinvel(r.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in t.object&&this.controlsManager.addBoundsTree(t),this.data.velocity.some(o=>o!==0)&&this.data.dynamic&&(t.userData.velocity=r)),e.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");AA.play(r)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(t=>window.clearTimeout(t)),this.timeoutIdQueue=[],this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[],AA.dispose()}};var Wv=class{constructor(t,e,r,n,o){this.data=t;this.page=e;this.controlsManager=r;this.shared=n;this.condition=o;this.timeoutIdQueue=[];this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)};this.destroyCallback=t=>{this.timeoutIdQueue.shift();let e=this.page.scene.find(t);if(e===void 0)return;let r=this.controlsManager.sharedGameControlGlobals.rapierWorld,n=r?e.dataPatched.physics?.fusedBody:!0;if(e.cloner){for(let o of e.cloner.children)n?(o.playModeVisible=!1,e.dataPatched.physics?.rigidBody==="positioned"&&this.removeBody(o),o.bvhGeometry&&(o.bvhGeometry=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,this.removeBody(o)):o.playModeVisible===void 0&&(o.playModeVisible=!0);e.cloner.syncInstanceMatrices(),(n||this.clone===void 0||this.clone===!1)&&(e.visible=!1,this.removeBody(e),e.bvhGeometry&&(e.bvhGeometry=void 0))}else this.removeBody(e),e.bvhGeometry&&(e.bvhGeometry=void 0),e.visible=!1;r===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),e.destroyedInAction=!0,this.controlsManager.requestRender()};this.objects=[...t.objects]}removeBody(t){let e=t.rigidBody;if(!e)return;let r=this.controlsManager.sharedGameControlGlobals;r.colliderToEntity.delete(e.collider(0).handle),r.kinematicBodyToEntity.delete(e.handle);let n=this.controlsManager;n.fixedBodiesToWatch=n.fixedBodiesToWatch.filter(([,o])=>o!==e),r.rapierWorld.removeRigidBody(e),t.rigidBody=void 0}dispatch(t){if(We(this.shared,this.condition)===!1)return!1;this.clone=t,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(We(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(t=>window.clearTimeout(t))}};Zt("Create",({data:i,page:t,eventManager:e,shared:r,actionCondition:n})=>new Hv(i,t,e.controlsManager,r,n));Zt("Destroy",({data:i,page:t,eventManager:e,shared:r,actionCondition:n})=>new Wv(i,t,e.controlsManager,r,n));Pe("create-destroy");var HR=require("three");var UR=new HR.Vector3;function qv(i,t,e=!1){let r=[],n=o=>{let a=o.data;delete o.states,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null;for(let s of a.states){let l={...s.data};o.states||(o.states={}),o.states[s.id]=wa.patch(a,l)}jR(i.scene,o,null,t,a.events.find(s=>s.data.type==="Follow"||s.data.type==="LookAt")!==void 0),zR(i)};i.scene.traverse2D(n),i.traverseChildren(o=>{if(e&&(o.rigidBody?.setTranslation(o.position0,!0),o.rigidBody?.setRotation(o.rotation0,!0),o.rigidBody?.setLinvel(UR,!0),o.rigidBody?.setAngvel(UR,!0)),!Le.is(o))return;let a=o.uuid,s=o.data;if(delete o.states,o.uuid===Do)return;let l=!1;r.some(c=>i.scene.find(a)?.isDescendantOf(c))?l=!0:s.physics?.fusedBody===!0&&s.physics.rigidBody==="dynamic"&&r.push(a),o.data=s,o.currentState=null,o.reversibleToState=null,o.currentTransitionEvent=null,o.transitionState={settled:!0,state:null};for(let c of s.states){let d={...c.data};i.data.globalPhysics.usePhysics===!0&&s.physics&&(s.physics.rigidBody==="dynamic"||l)&&(c.data.position!==void 0&&delete d.position,c.data.rotation!==void 0&&delete d.rotation,c.data.hiddenMatrix!==void 0&&delete d.hiddenMatrix),o.states||(o.states={}),o.states[c.id]=va.patch(s,d)}jR(i.scene,o,null,t,s.events.find(c=>c.data.type==="Follow"||c.data.type==="LookAt")!==void 0),Nn(o)&&o.frame&&(o.frame.traverse(c=>n(c)),o.uiCanvas?.applySize())}),zR(i),i.frame&&(i.frame.traverse(o=>n(o)),i.uiCanvas?.applySize())}function zR(i){i.traverseEntity(t=>{for(let e of t.data.events){let r=[];switch(e.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...e.data.actions);break;case"GameControl":for(let n of Object.values(e.data.gameActions))r.push(...n);break;case"DragDrop":r.push(...e.data.dragDropActions.drag,...e.data.dragDropActions.drop);break;case"Conditional":r.push(...e.data.inActions,...e.data.outActions);break}for(let n of r)if(n.data.type==="Create"&&n.data.hideBase==="Yes"){let o=i.scene.find(n.data.object);o&&(o.visible=!1)}}})}function jR(i,t,e,r,n=!1){if(i.markShadowsDirty(),t instanceof tt&&!li(t)&&t.removeInteractionGeometry(r),cn(t)?t.changeSelectedState(e,{shared:r},n):t.changeSelectedState(e,{scene:i,shared:r},n),t instanceof tt&&t.updateGeometryGroupsIfNeeded(),t instanceof St&&t.updateCameraState(t.dataPatched,{scene:i,shared:r}),!cn(t)){if(t.cloner){let o=!1;for(let a of t.cloner.children)a.playModeVisible=void 0,a.transformOverride!==void 0&&(a.transformOverride=void 0,o=!0);o&&i.addPendingUpdateCloner(t),t.cloner.syncInstanceMatrices()}t.updateVisible()}}var Xv=class{constructor(t,e,r,n,o){this.data=t;this.page=e;this.eventManager=r;this.shared=n;this.condition=o;this.timeOutId=-1;this.scene=e.scene}dispatch(){if(We(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(r=>r.uuid!==this.data.target||r.data.uiScene))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let t=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(r=>{r.type==="ParticleSystem"&&(r.sleep(),r.wakeUp(),r.data.autoPlay?r.start():r.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(t),qv(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};Zt("SceneTransition",({data:i,page:t,eventManager:e,shared:r,actionCondition:n})=>new Xv(i,t,e,r,n));Pe("scene-transition");var vB=require("three");function bz(i){return{easing:i.type,control1:Sa(i.cubicControls?.control1,[0,0]),control2:Sa(i.cubicControls?.control2,[1,1]),...i.springParameters}}function Zl(i,t){let e=[];for(let r of i??[]){let n=t(r.data);n!==void 0&&e.push({time:r.data.time,ease:bz(r.data.easing),value:n})}return{keyframes:lR(e)}}function bo(i,t){if(i.keyframes.length===0)return;let{index0:e,index1:r,t:n}=sR(i.keyframes,t),o=i.read;if(o&&o.index0===e&&o.index1===r&&o.t===n)return;let a={index0:e,index1:r,from:i.keyframes[e].value,to:i.keyframes[r].value,t:n};return i.read=a,a}function WR(i){i.read=void 0}function Lh(i,t,e){return i+(t-i)*e}var Vh=require("three");var ti=require("three");var qR=require("three");var cu=class extends jo(qR.PointLightHelper){constructor(e,r=15,n=6710886){super(e,r,n);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){Ho(this.object,cu.geometryHelper,e,r)}};var Jl=class extends Zd(ti.PointLight,cu){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let o=this.shadow.camera;o.fov=90,o.aspect=1,o.near=100,o.far=2500;let a=new ti.Vector3(-o.far+this.position.x,-o.far+this.position.y,-o.far+this.position.z),s=new ti.Vector3(o.far+this.position.x,o.far+this.position.y,o.far+this.position.z),l=new ti.Box3(a,s),c=new ti.Box3Helper(l,new ti.Color(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof ti.Box3Helper){let r=this.shadow.camera,n=new ti.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),o=new ti.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(n,o),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ft=require("three");var{degToRad:Rge,radToDeg:Bge}=ft.MathUtils,XR=new ft.Vector3,YR=new ft.Vector3,QR=new ft.Quaternion;function ZR(i,t,e,r){if(r===0)return e.copy(i);if(r===1)return e.copy(t);let n=i.w*t.w+i.x*t.x+i.y*t.y+i.z*t.z;if(n>=1)return e.copy(i);let o=1-n*n;if(o<=Number.EPSILON){let d=1-r;return e.w=d*i.w+r*t.w,e.x=d*i.x+r*t.x,e.y=d*i.y+r*t.y,e.z=d*i.z+r*t.z,e.normalize(),e}let a=Math.sqrt(o),s=Math.atan2(a,n),l=Math.sin((1-r)*s)/a,c=Math.sin(r*s)/a;return e.w=i.w*l+t.w*c,e.x=i.x*l+t.x*c,e.y=i.y*l+t.y*c,e.z=i.z*l+t.z*c,e}function Sr(i,t,e,r,n,o){let a=e[i]!==void 0?e[i]:void 0,s=r[i];if(s==null)return;let l=a!=null?typeof a=="string"?Number(n.getVariable(a)??0):a:t[i],c=typeof s=="string"?Number(n.getVariable(s)??0):s;if(l!==c)return{update:d=>{let u=ft.MathUtils.lerp(l,c,d);o?t[i]=Math.trunc(u):t[i]=u},start:()=>{t[i]=l},end:()=>{t[i]=c}}}function Fh(i,t,e,r,n,o){let a=e[i]?e[i]:void 0,s=r[i];if(!s)return;let l=t[i],c=[...a??l].map(u=>typeof u=="string"?Number(n.getVariable(u)??0):u),d=[...s].map(u=>typeof u=="string"?Number(n.getVariable(u)??0):u);if(!(c.length!==d.length||so(c,d)))return{update:u=>{c.forEach((p,h)=>{let f=ft.MathUtils.lerp(p,d[h],u);t[i][h]=o?Math.trunc(f):f})},start:()=>{Object.assign(t[i],c)},end:()=>{Object.assign(t[i],d)}}}function _h(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function wA(i,t,e,r,n){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let s=t[i],l=o?_h(new ft.Vector3,o,n):s.clone(),c=_h(new ft.Vector3,a,n);if(!l.equals(c))return{update:d=>{s.lerpVectors(l,c,d)},start:()=>{s.copy(l)},end:()=>{s.copy(c)}}}function KR(i,t,e){return t.forEach((r,n)=>{i.setComponent(n,typeof r=="string"?Number(e.getVariable(r)??0):r)}),i}function du(i,t,e,r,n){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let s=t[i],l=!(s instanceof ft.Vector2),c=s instanceof ft.Vector2?s:new ft.Vector2().fromArray(s),d=o?KR(new ft.Vector2,o,n):c.clone(),u=KR(new ft.Vector2,a,n);if(!d.equals(u))return{update:p=>{c.lerpVectors(d,u,p),l&&(t[i]=c.toArray())},start:()=>{c.copy(d),l&&(t[i]=c.toArray())},end:()=>{c.copy(u),l&&(t[i]=c.toArray())}}}function JR(i,t,e,r){let n=e[i]?e[i]:void 0,o=r[i];if(!o)return;let a=t[i],s=n?new ft.Matrix4().fromArray(n):a.clone(),l=new ft.Vector3,c=new ft.Quaternion,d=new ft.Vector3;s.decompose(l,c,d);let u=new ft.Matrix4().fromArray(o),p=new ft.Vector3,h=new ft.Quaternion,f=new ft.Vector3;if(u.decompose(p,h,f),!s.equals(u))return{update:m=>{QR.slerpQuaternions(c,h,m),XR.lerpVectors(l,p,m),YR.lerpVectors(d,f,m),a.compose(XR,QR,YR)},start:()=>{a.compose(l,c,d)},end:()=>{a.compose(p,h,f)}}}function $R(i,t,e,r,n){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let s=t[i],l=o?typeof o=="string"?n.getColor(o).clone():new ft.Color().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?n.getColor(a).clone():new ft.Color().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{d.lerpColors(l,c,u),t[i]?.copy?.(d)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function kh(i,t,e,r,n){let o=e[i]?e[i]:void 0,a=r[i];if(!a)return;let s=t[i],l=new Gt(s.r,s.g,s.b,s.a),c=o?typeof o=="string"?n.getColor(o).clone():new Gt(o.r,o.g,o.b,o.a):l.clone(),d=typeof a=="string"?n.getColor(a).clone():new Gt(a.r,a.g,a.b,a.a);if(!c.equals(d))return{update:u=>{l.lerpColors(c,d,u);let p=ft.MathUtils.lerp(c.a,d.a,u);l.a=p,t[i]={r:l.r,g:l.g,b:l.b,a:l.a}},start:()=>{l.copy(c)},end:()=>{l.copy(d)}}}function ia(i,t,e,r,n){if(typeof t[i]=="number")return Sr(i,t,e??{},r,n);if(Array.isArray(t[i]))return Fh(i,t,e??{},r,n)}var Nge=new ft.Euler;function eB(i,t){if(!!i)for(let[e,r]of Object.entries(t)){let n=i[e];if(Array.isArray(n)&&Array.isArray(r)){let o=Math.min(n.length,r.length);for(let a=0;a<o;a++)n[a]=r[a]}else i[e]=r}}function uu(i,t,e,r){let n={};if(!t||!e)return n;for(let o of i){let a=t[o],s=e[o];if(typeof a=="number"&&typeof s=="number")n[o]=ft.MathUtils.lerp(a,s,r);else if(Array.isArray(a)&&Array.isArray(s)){let l=Math.min(a.length,s.length);n[o]=Array.from({length:l},(c,d)=>ft.MathUtils.lerp(a[d],s[d],r))}}return n}function tB(i,t,e,r){let n=[];if(!("cloner"in e)||!i.cloner)return n;let o=i.cloner,a="cloner"in t?t.cloner:{},s=e.cloner;Fx.forEach(h=>{let f;h==="count"?f=Sr("count",o.parameters,a,s,r.shared,!0):f=ia(h,o.parameters,a??{},s,r.shared),f&&n.push(f)});let l=xz(o,a,s,r.shared);l?.length&&n.push(...l);let c=Sz(o,a,s,r.shared);c?.length&&n.push(...c);let d=Az(o,a,s,r.shared);d?.length&&n.push(...d);let u=wz(o,a,s,r.shared);u?.length&&n.push(...u);let p=Ez(o,a,s,r.shared);return p?.length&&n.push(...p),n.length&&n.push({update:()=>{o.update(r)}}),n}function xz(i,t,e,r){if(i.parameters.type!=="radial")return;let n=t.radial,o=e.radial;if(!o)return;let a=i.parameters.radial,s=[];return am.forEach(l=>{let c=ia(l,a,n??{},o,r);c&&s.push(c)}),s}function Sz(i,t,e,r){if(i.parameters.type!=="linear")return;let n=t.linear,o=e.linear;if(!o)return;let a=[],s=i.parameters.linear;return sm.forEach(l=>{let c=ia(l,s,n??{},o,r);c&&a.push(c)}),a}function Az(i,t,e,r){if(i.parameters.type!=="grid")return;let n=t.grid,o=e.grid;if(!o)return;let a=[],s=i.parameters.grid;return lm.forEach(l=>{let c;l==="count"?c=Fh(l,s,n??{},o,r,!0):c=ia(l,s,n??{},o,r),c&&a.push(c)}),a}function wz(i,t,e,r){if(i.parameters.type!=="toObject")return;let n=t.toObject,o=e.toObject;if(!o)return;let a=[],s=i.parameters.toObject;return cm.forEach(l=>{let c;l==="count"?c=Sr(l,s,n??{},o,r,!0):c=ia(l,s,n??{},o,r),c&&a.push(c)}),a}function Ez(i,t,e,r){if(!i.parameters.randomness)return;let n=t.randomnessObject,o=e.randomnessObject;if(!o)return;let a=[],s=i.parameters.randomnessObject;return dm.forEach(l=>{let c=ia(l,s,n??{},o,r);c&&a.push(c)}),a}var rB=[["radial",am],["linear",sm],["grid",lm],["toObject",cm],["randomnessObject",dm]];function nB(i,t,e,r){if(!i)return{};let n=uu(["count"],t,e,r);n.count!==void 0&&(n.count=Math.trunc(n.count));for(let[o,a]of rB){if(!i[o])continue;let s=uu(a,t[o],e[o],r);Object.keys(s).length&&(n[o]=s)}return n}function iB(i,t){if(!!i){t.count!==void 0&&(i.count=t.count);for(let[e]of rB){let r=t[e];r&&eB(i[e],r)}}}var Ar=require("three");function aB(i,t,e,r){let n=[];if(Array.isArray(i.material)){if(!("materials"in e&&e.materials))return n;let o="materials"in t&&t.materials?t.materials:[],a=e.materials;i.material.forEach((s,l)=>{if(!a[l])return;let c=o[l]??{},d=a[l];typeof c=="string"||typeof d=="string"||n.push(...oB(s,c,d,r))})}else{if(!("material"in e&&e.material))return n;let o="material"in t&&t.material?t.material:{},a=e.material;if(typeof o=="string"||typeof a=="string")return n;n.push(...oB(i.material,o,a,r))}return n}function Cz(i,t,e){let r=i.ensureRainbowNoiseCompiled;if(typeof r=="function")for(let n of[...i.layers]){if(n.type!=="rainbow")continue;let o=t.layers?.data(n.uuid),a=e.layers.data(n.uuid);(po(o?.noiseStrength)||po(a?.noiseStrength))&&r.call(i,n.uuid)}}function sB(i,t,e,r,n){let o=i.getValue(r);if(o!==void 0){if(r==="colors")return Rz(i,t,e,r);if(Array.isArray(o))return r==="steps"?Iz(i,t,e,r):void 0;if(typeof o=="number")return Tz(i,t,e,r,n);if(typeof o!="boolean"){if(o instanceof Ar.Vector2)return Pz(i,t,e,r);if(o instanceof Ar.Vector3)return Mz(i,t,e,r,n);if(o instanceof Gt)return Dz(i,t,e,r,n);if(o instanceof Ar.Color)return Oz(i,t,e,r,n);if("isTexture"in o)return Nz(i,t,e,r,n)}}}function oB(i,t,e,r){let n=[],o=zo(e,r)||!!t.layers&&zo(t,r);n.push(Lz(i,o)),Cz(i,t,e);for(let a of i.layers){let s=t.layers?.data(a.uuid),l=e.layers.data(a.uuid);if(!l||a.type!=="light"&&(!(a.visible??!0)||!(l.visible??!0)))continue;let c=fd[a.type]??[],d=a.getNames().filter(u=>!c.includes(u)&&!mm.some(p=>u.includes(p)));for(let u of d)try{let p=sB(a,s,l,u,r);p&&(Array.isArray(p)?n.push(...p):n.push(p))}catch(p){console.error(`lerpMaterial: unexpected material layer for ${u}`,p)}}return n}function Tz(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let o=t?t[r]:i.getValue(r),a=e[r],s=typeof o=="string"?Number(n.getVariable(o)??0):o,l=typeof a=="string"?Number(n.getVariable(a)??0):a;return{update:c=>{i.setValue(r,Ar.MathUtils.lerp(s,l,c))},start:()=>{i.setValue(r,s)},end:()=>{i.setValue(r,l)}}}function Pz(i,t,e,r){if(!i.hasValue(r)||!(r in e))return;let n=i.getValue(r),o=t?new Ar.Vector2().fromArray(t[r]):n.clone(),a=new Ar.Vector2().fromArray(e[r]);if(!o.equals(a))return{update:s=>{n.lerpVectors(o,a,s)},start:()=>{n.copy(o)},end:()=>{n.copy(a)}}}function Mz(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let o=i.getValue(r),a=t?t[r]:void 0,s=e[r],l=a?_h(new Ar.Vector3,a,n):o.clone(),c=_h(new Ar.Vector3,s,n);if(!l.equals(c))return{update:d=>{o.lerpVectors(l,c,d)},start:()=>{o.copy(l)},end:()=>{o.copy(c)}}}function Oz(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=i.getValue(r),l=o?typeof o=="string"?n.color(o).clone():new Ar.Color().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?n.color(a).clone():new Ar.Color().setRGB(a.r,a.g,a.b);if(l.equals(c))return;let d=s.clone();return{update:u=>{i.getValue(r)!==d&&i.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function Dz(i,t,e,r,n){if(!i.hasValue(r)||!(r in e))return;let o=t?t[r]:void 0,a=e[r],s=i.getValue(r),l=o?typeof o=="string"?n.color(o).clone():new Ar.Color().setRGB(o.r,o.g,o.b):s.clone(),c=typeof a=="string"?n.color(a).clone():new Gt(a.r,a.g,a.b,a.a);if(l.equals(c))return;let d=s.clone();return{update:u=>{i.getValue(r)!==d&&i.setValue(r,d),d.lerpColors(l,c,u)},start:()=>{d.copy(l)},end:()=>{d.copy(c)}}}function Iz(i,t,e,r="steps"){if(!i.hasValue(r)||!(r in e))return;let n=[],o=i.getValue(r),a=t?t[r]:o,s=e[r];return so(a,s)||n.push({update:l=>{let c=[...o];for(let d=0;d<o.length;++d){let u=a[d],p=s[d];c[d]=Ar.MathUtils.lerp(u,p,l)}i.setValue(r,c)},start:()=>{i.setValue(r,a)},end:()=>{i.setValue(r,s)}}),n.length?n:void 0}function Rz(i,t,e,r="colors"){if(!i.hasValue(r)||!(r in e))return;let n=[],o=i.getValue(r),a=t?t[r]:o.map(l=>l.toArray()),s=e[r];for(let l=0;l<o.length;++l){let c=[...a[l]],d=[...s[l]];cl.isEqual(c,d)||n.push({update:u=>{o[l].fromArray(cl.lerp(c,d,u))},start:()=>{o[l].fromArray(c)},end:()=>{o[l].fromArray(d)}})}return n.length?n:void 0}function Bz(i){let t=i.getNode("mat");if(typeof t?.updateMatrix=="function")return t;let e=i.getValue("mat");return typeof e?.updateMatrix=="function"?e:void 0}function Nz(i,t,e,r="texture",n){if(!i.hasValue(r)||!(r in e))return;let o=v=>Number(typeof v=="string"?n?.getVariable(v)??0:v??0),a=i.getNode("rotation"),s=t?o(t[r]?.rotation):(a?.value??0)*Ar.MathUtils.RAD2DEG,l=o(e[r]?.rotation);if(a&&Math.abs(s-l)>1e-9)return{update:v=>{a.value=Ar.MathUtils.lerp(s,l,v)*Ar.MathUtils.DEG2RAD},start:()=>{a.value=s*Ar.MathUtils.DEG2RAD},end:()=>{a.value=l*Ar.MathUtils.DEG2RAD}};let c=Bz(i);if(!c)return;let d=t?t[r]:c,u=e[r],p=[...d.repeat],h=[...d.offset],f=[...u.repeat],m=[...u.offset],y=d.rotation??0,g=u.rotation??0;if(!ai.isEqual(p,f)||!ai.isEqual(h,m)||y!==g)return{update:v=>{c.repeat=ai.lerp(p,f,v),c.offset=ai.lerp(h,m,v),c.rotation=Ar.MathUtils.lerp(y,g,v),c.updateMatrix()},start:()=>{c.repeat=[...p],c.offset=[...h],c.rotation=y,c.updateMatrix()},end:()=>{c.repeat=[...f],c.offset=[...m],c.rotation=g,c.updateMatrix()}}}function EA(i,t,e,r,n,o){let a=sB(t,e,r,i,o);!a||(Array.isArray(a)?a.forEach(s=>s.update(n)):a.update(n))}function Lz(i,t){return{update:()=>{i.setTransparent(t)}}}function lB(i,t,e,r,n){let o=_z(i,t);return{duration:e,evaluate(a,s){i.resetBBoxNeedsUpdate();let l=kz();for(let c of o)Gz(c,i,a,r,n,s,l);Vz(i,l,r)},invalidate(){for(let a of o)WR(a.track)}}}function _z(i,t){let e=[];return Aa.groupKeyframes(t.keyframes).forEach(r=>{let n=r.path?.[0],o=r.path[1],a=()=>Zl(r.keyframes,s=>s.value);switch(n){case"position":case"rotation":case"scale":o&&Bc.includes(o)&&e.push({on:n,axis:o,track:a()});return;case"shape size":o&&Bc.includes(o)&&"geometry"in i&&e.push({on:"shapeSize",axis:o,track:a()});return;case"path extrusion":bl(i)&&e.push({on:"pathExtrusion",track:Zl(r.keyframes,s=>s.value)});return;case"path snapping":i.data.pathSnapping&&e.push({on:"pathSnapping",track:Zl(r.keyframes,s=>s.value)});return;case"material":i.type==="Mesh"&&"material"in i&&Fz(i,r).forEach(s=>e.push(s));return;case"opacity":i.type==="Mesh"&&"material"in i&&e.push({on:"opacity",track:a()});return;case"cloner":e.push({on:"cloner",track:Zl(r.keyframes,s=>s.value)});return;case"camera":i instanceof St&&e.push({on:"camera",field:"zoom",track:a()});return;case"light":(i instanceof za||i instanceof Jl||i instanceof ja)&&e.push({on:"light",field:r.path[1],track:Zl(r.keyframes,s=>s.value)});return}}),e}function Fz(i,t){let e=ky(i.material)?i.material:void 0,r=t.layerId;if(!e||!r)return[];let n=t.keyframes.some(d=>po(d.data.value?.noiseStrength)),o=e.ensureRainbowNoiseCompiled,a=d=>{n&&typeof o=="function"&&o.call(e,d)},s=d=>"data"in d?[{on:"material",layer:d,track:Zl(t.keyframes,u=>u.value)}]:[];a(r);let l=e.getLayerByUuid(r);if(l)return s(l);let c=t.path[1];for(let d of e.getLayersOfType(c))a(d.uuid);return(e.getLayersOfType(c)??[]).flatMap(s)}function kz(){return{transform:!1,size:!1,cloner:!1,bounds:!1,boolean:!1,render:!1}}function Vz(i,t,e){if(t.size&&i instanceof tt){let{x:r,y:n,z:o}=i.userData.value;i.updateGeometryInteractions({width:r,height:n,depth:o},e.shared)}t.cloner&&i.cloner?.update(e),t.transform&&i.updateMatrix(),t.bounds&&i.resetBBoxNeedsUpdate(),t.boolean&&i instanceof tt&&i.invalidateDownstreamBooleanData(),t.render&&i.dispatchEvent({type:"requestRender"})}function Ya(i,t,e){!i||(i[t]={...i[t],...e})}function Gz(i,t,e,r,n,o,a){let s=()=>{a.transform=!0,a.bounds=!0,a.boolean=!0,a.render=!0};switch(i.on){case"position":case"scale":{let l=bo(i.track,e);if(!l)return;let c=Lh(l.from,l.to,l.t);t[i.on][i.axis]=c,Ya(o,i.on,{[i.axis]:c}),s();return}case"rotation":{let l=bo(i.track,e);if(!l)return;let c=Lh(l.from,l.to,l.t);t.rotation[i.axis]=c*Vh.MathUtils.DEG2RAD,Ya(o,"rotation",{[i.axis]:c}),s();return}case"shapeSize":{let l=bo(i.track,e);if(!l||!(t instanceof tt))return;let c=Lh(l.from,l.to,l.t);t.userData.value={...t.userData.value,[i.axis]:c},Ya(o,"shapeSize",{[i.axis]:c}),a.size=!0,a.bounds=!0,a.boolean=!0,a.render=!0;return}case"opacity":{let l=bo(i.track,e);if(!l||!(t instanceof it)||Array.isArray(t.material))return;let c=t.material.getLayersOfType("light")[0];if(c===void 0)return;let d=Vh.MathUtils.lerp(l.from,l.to,l.t);t.material.transparent=!0,EA("alphaOverride",c,{alphaOverride:d},{alphaOverride:d+1},0,r.shared),o&&(o.opacity=d),a.render=!0;return}case"material":{let l=bo(i.track,e);if(!l||Object.keys(l.from).length===0||Object.keys(l.to).length===0)return;let{layer:c}=i,d={};for(let u in c.data){if(!(u in l.from)||!(u in l.to))continue;let p=CA(l.from[u],l.to[u],l.t,n);if(p===void 0)continue;d[u]=p;let h=c.getValue(u);h!==void 0&&(u==="alpha"&&typeof h=="number"&&h>0&&t instanceof it&&!Array.isArray(t.material)&&(t.material.transparent=!0),EA(u,c,l.from,l.to,l.t,r.shared))}Ya(o,"material",{[c.uuid]:d}),a.render=!0;return}case"light":{let l=bo(i.track,e);if(!l||!(t instanceof za||t instanceof Jl||t instanceof ja))return;let c=CA(l.from,l.to,l.t,n);t[i.field]=c,Ya(o,"light",{[i.field]:c}),a.render=!0;return}case"camera":{let l=bo(i.track,e);if(!l||!(t instanceof St))return;let c=Lh(l.from,l.to,l.t);t[i.field]=c,Ya(o,"camera",{[i.field]:c});return}case"cloner":{let l=bo(i.track,e);if(!l)return;let d=t.cloner?.parameters,u=nB(d,l.from,l.to,l.t);iB(d,u),Ya(o,"cloner",u),a.cloner=!0,a.boolean=!0,a.render=!0;return}case"pathExtrusion":{let l=bo(i.track,e);if(!l||!bl(t))return;let c=uu(pp,l.from,l.to,l.t),d=t.geometry.userData.parameters;d.extrusion={...d.extrusion,...c},Ya(o,"pathExtrusion",c),t.updateGeometryInteractions({extrusion:{...d.extrusion}},r.shared),a.bounds=!0,a.boolean=!0,a.render=!0;return}case"pathSnapping":{let l=bo(i.track,e);if(!l)return;let c=t,d=uu(GC,l.from,l.to,l.t);c.userData.pathSnapping={...c.userData.pathSnapping,...d},Ya(o,"pathSnapping",d),c.updatePathSnapping(c.userData.pathSnapping),a.render=!0;return}}}function CA(i,t,e,r){if(typeof i=="string"&&r&&(i=r.color(i)),typeof t=="string"&&r&&(t=r.color(t)),typeof i=="number")return Vh.MathUtils.lerp(i,t,e);if(Ve.is(i))return Ve.lerp(i,t,e);if(rr.is(i))return rr.lerp(i,t,e);if(Array.isArray(i))return(i.length>t.length?t:i).map((o,a)=>{if(Array.isArray(o)){let s=i[a].length>t[a].length?t[a].length:i[a].length;return(s===4?cl:s===3?Ei:ai).lerp(i[a],t[a],e)}return Vh.MathUtils.lerp(i[a],t[a],e)});if(typeof i=="object"&&i!==null){let n={};for(let o in i){let a=CA(i[o],t[o],e,r);a!==void 0&&(n[o]=a)}return n}}var cB=require("three");function dB(i,t,e,r){let n=[],o=i.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,a=i.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom;if(a!==void 0){let s=o??i.zoom,l=a;s!==l&&n.push({update:c=>{i.zoom=cB.MathUtils.lerp(s,l,c),i.updateProjectionMatrix()},start:()=>{i.zoom=s,i.updateProjectionMatrix()},end:()=>{i.zoom=l,i.updateProjectionMatrix()}})}if(e.targetOffset!==void 0){let s=Sr("targetOffset",i,t,e,r);s&&n.push(s)}return n}var Yv=require("three");function Uz(i,t,e,r){if(e.scaleBaked===void 0)return;let n=(t.scaleBaked??i.appliedGeometrySize??i.data.geometry.scaleBaked).map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s),o=e.scaleBaked.map(s=>typeof s=="string"?Number(r.shared.getVariable(s)??0):s);if(Ei.isEqual(n,o))return;let a=[];return a.push({update:s=>{i.updateGeometryInteractions({scaleBaked:[Yv.MathUtils.lerp(n[0],o[0],s),Yv.MathUtils.lerp(n[1],o[1],s),Yv.MathUtils.lerp(n[2],o[2],s)]},r.shared),i.invalidateDownstreamBooleanData(),i.refreshAttachedClonersInteractions(r)},start:()=>{i.updateGeometryInteractions({scaleBaked:n},r.shared),i.invalidateDownstreamBooleanData(),i.refreshAttachedClonersInteractions(r)},end:()=>{i.updateGeometryInteractions({scaleBaked:o},r.shared),i.invalidateDownstreamBooleanData(),i.refreshAttachedClonersInteractions(r)}}),a}function zz(i,t,e,r){if(!e.extrusion)return;let n=i.extrusion,o=t.extrusion??{},a=e.extrusion,s=[];return pp.forEach(l=>{let c=ia(l,n,o,a,r);c&&s.push(c)}),s}function uB(i,t,e,r){let n=[];if(!("geometry"in e)||li(i))return n;let o=i.geometry.userData.parameters,a="geometry"in t?t.geometry:{},s=e.geometry;if(i instanceof Na){let l=Uz(i,a,s,r);l&&n.push(...l)}else{let l={},c=i.appliedGeometrySize;if(Object.assign(l,xp(o,xm),c?{width:c[0],height:c[1],depth:c[2]}:{},xp(a,xm)),xm.forEach(d=>{let u=ia(d,l,a,s,r.shared);u&&n.push(u)}),bl(i)){Object.assign(l,{extrusion:{...o.extrusion}});let d=zz(l,a,s,r.shared);d&&n.push(...d)}n.length&&n.push({update:d=>{i.updateGeometryInteractions(l,r.shared),i.updateGeometryGroupsIfNeeded(),i.refreshAttachedClonersInteractions(r)},start:d=>{i.updateGeometryInteractions(l,r.shared),i.updateGeometryGroupsIfNeeded(),i.refreshAttachedClonersInteractions(r)},end:d=>{i.updateGeometryInteractions(l,r.shared),i.updateGeometryGroupsIfNeeded(),i.refreshAttachedClonersInteractions(r)}})}return n}function pB(i,t,e,r){let n=[];if(e.intensity!==void 0){let o=Sr("intensity",i,t,e,r);o&&n.push(o)}if(e.color!==void 0){let o=$R("color",i,t,e,r);o&&n.push(o)}return n}var oa=require("three");var PA=require("three"),TA=new oa.Vector3,hB=new oa.Euler;function fB(i,t,e,r,n){let o=[],a,s,l,c,d,u,p,h;if(cn(i)?(a=du("position",i,t,e,n),a&&o.push(a),l=Sr("rotation",i,t,e,n),l&&o.push(l),c=du("shear",i,t,e,n),c&&o.push(c)):(h={slide:t.pathSnapping?.slide??i.updatedPathSnapping?.slide??i.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??i.updatedPathSnapping?.offset??i.dataPatched.pathSnapping?.offset??0},u=Sr("slide",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),u&&o.push(u),p=Sr("offset",h,t.pathSnapping??i.updatedPathSnapping??i.dataPatched.pathSnapping,e.pathSnapping??i.dataPatched.pathSnapping,n),p&&o.push(p),!u&&!p&&(a=wA("position",i,t,e,n),a&&o.push(a),s=wA("scale",i,t,e,n),s&&o.push(s),l=jz(i,t,e,r,n),l&&o.push(l),d=JR("hiddenMatrix",i,t,e),d&&o.push(d))),a||s||l||d||u||p){let f=cn(i)?()=>{i.updateWorldMatrix(!0,!1,!0),i.resetBBoxNeedsUpdate()}:()=>{i.updateMatrix(),i.hasNonUniformScale&&(i.updateMatrixWorld(),i.updateMatrixWorldRigid()),i.parent?.matrixWorldFusedFalse&&(i.matrixWorld.multiplyMatrices(i.parent.matrixWorldFusedFalse,i.matrix),i.matrixWorldNeedsUpdate=!1),ei(i)&&mi(i.parent)&&i.invalidateDownstreamBooleanData(!0),i.updatePathSnapping(Object.assign({},t.pathSnapping,h))};o.push({update:f,start:f,end:f})}return o}function jz(i,t,e,r,n){let o=t?.rotation?t.rotation.map(d=>(typeof d=="string"?Number(n.getVariable(d)??0):d)*oa.MathUtils.DEG2RAD):void 0,a=e.rotation?.map(d=>(typeof d=="string"?Number(n.getVariable(d)??0):d)*oa.MathUtils.DEG2RAD);if(!a)return;let s=o?new oa.Vector3().fromArray(o):new oa.Vector3().setFromEuler(i.rotation),l=new oa.Vector3().fromArray(a);if(s.equals(l))return;let c=TA.subVectors(l,s);if(r&&c.toArray().every(d=>Math.abs(d)<2*Math.PI)){let d=new PA.Quaternion().setFromEuler(hB.setFromVector3(s)),u=new PA.Quaternion().setFromEuler(hB.setFromVector3(l));return{update:p=>{ZR(d,u,i.quaternion,p)},start:()=>{i.rotation.setFromVector3(s)},end:()=>{i.rotation.setFromVector3(l)}}}else return{update:d=>{TA.lerpVectors(s,l,d),i.rotation.setFromVector3(TA)},start:()=>{i.rotation.setFromVector3(s)},end:()=>{i.rotation.setFromVector3(l)}}}function Hz(i,t){return{update:()=>{i instanceof Wt&&(i.fill.enabled=t)}}}function Wz(i,t){return{update:()=>{i instanceof Wt&&(i.stroke.enabled=t)}}}function qz(i,t){return{update:()=>{i instanceof Wt&&(i.dropShadow.enabled=t)}}}function Xz(i,t){return{update:()=>{i instanceof Wt&&(i.innerShadow.enabled=t)}}}function Yz(i,t){return{update:()=>{i instanceof Wt&&(i.backgroundBlur.enabled=t)}}}function Qz(i,t){return{update:()=>{i instanceof Wt&&(i.layerBlur.enabled=t)}}}function mB(i,t,e,r,n){let o=[],a,s,l,c,d,u,p,h,f,m,y,g,v,b,S;if("width"in i&&(a=Sr("width",i,t,e,n),a&&o.push(a)),"height"in i&&(s=Sr("height",i,t,e,n),s&&o.push(s)),i instanceof Wt||i instanceof dn){let x={...t.fill},A={...e.fill};x.enabled!==void 0&&x.enabled!==A.enabled&&(o.push(Hz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,color:{...x.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),l=kh("color",i.fill,x,A,n),l&&o.push(l)}if(i instanceof Wt){let x={...t.stroke},A={...e.stroke};(x.enabled||A.enabled)&&(o.push(Wz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,color:{...x.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),c=kh("color",i.stroke,x,A,n),c&&o.push(c),d=Sr("thickness",i.stroke,x,A,n),d&&o.push(d)}if(i instanceof Wt){let x={...t.dropShadow},A={...e.dropShadow};(x.enabled||A.enabled)&&(o.push(qz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,color:{...x.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),u=kh("color",i.dropShadow,x,A,n),u&&o.push(u),p=Sr("blurRadius",i.dropShadow,x,A,n),p&&o.push(p),f=Sr("spread",i.dropShadow,x,A,n),f&&o.push(f),h=du("offset",i.dropShadow,x,A,n),h&&o.push(h)}if(i instanceof Wt){let x={...t.innerShadow},A={...e.innerShadow};(x.enabled||A.enabled)&&(o.push(Xz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,color:{...x.color,a:0}}),A.enabled||Object.assign(A,{enabled:!0,color:{...A.color,a:0}})),m=kh("color",i.innerShadow,x,A,n),m&&o.push(m),y=Sr("blurRadius",i.innerShadow,x,A,n),y&&o.push(y),v=Sr("spread",i.innerShadow,x,A,n),v&&o.push(v),g=du("offset",i.innerShadow,x,A,n),g&&o.push(g)}if(i instanceof Wt||i instanceof dn){let x={...t.backgroundBlur},A={...e.backgroundBlur};(x.enabled||A.enabled)&&(o.push(Yz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),b=Sr("radius",i.backgroundBlur,x,A,n),b&&o.push(b)}if(i instanceof Wt){let x={...t.layerBlur},A={...e.layerBlur};(x.enabled||A.enabled)&&(o.push(Qz(i,!0)),x.enabled||Object.assign(x,{enabled:!0,radius:0}),A.enabled||Object.assign(A,{enabled:!0,radius:0})),S=Sr("radius",i.layerBlur,x,A,n),S&&o.push(S)}if(i instanceof dn||i instanceof Gi){let x=Fh("cornerRadius",i,t,e,n);x&&o.push(x)}return o}function yB(i,t,e,r,n){let o=[];return i.data.visible&&o.push(...fB(i,t,e,n,r.shared)),cn(i)?o.push(...mB(i,t,e,n,r.shared)):(i.data.visible&&o.push(...tB(i,t,e,r)),i instanceof it?(i instanceof tt&&i.data.visible&&o.push(...uB(i,t,e,r)),i.data.visible&&!(i instanceof br&&i.materialOverride)&&o.push(...aB(i,t,e,r.shared))):$g.is(i)?i.data.visible&&o.push(...pB(i,t,e,r.shared)):i instanceof St&&o.push(...dB(i,t,e,r.shared))),o.length?{update:a=>{o.forEach(s=>s.update(a))},start:a=>{o.forEach(s=>s.start?.(a))},end:a=>{o.forEach(s=>s.end?.(a))}}:void 0}var MA={type:"beginState"};function OA(i){if(i.easing===5){let{control1:t,control2:e}=i;return{easing:5,control1:t??dl.defaultData.control1,control2:e??dl.defaultData.control2}}if(i.easing===6){let{mass:t,stiffness:e,damping:r,velocity:n}=i;return{easing:6,mass:t??ya.defaultData.mass,stiffness:e??ya.defaultData.stiffness,damping:r??ya.defaultData.damping,velocity:n??ya.defaultData.velocity}}return{easing:i.easing}}function DA(i){return{delay:i.delay,delayDirection:i.delayDirection??"start-end",direction:i.direction??"normal",repeat:i.repeat}}function Kz(i){return{duration:i.duration,ease:OA(i),...DA(i)}}var IA={type:"completeState",isfromEntity:!1};function pu(i,t){let e,r;if(typeof t=="string"?(e=t,r=i.states?.[e]):t===null&&(e=null,r=i.data),!(e===void 0||r===void 0))return{id:e,data:r}}var Zz=["position","rotation","scale","shear","hiddenMatrix"],Qv=new Set;function gB(i){if(i.length<2)return Qv;let t=new Set,[e,...r]=i;for(let n of Zz){let o=e[n];o!==void 0&&r.every(a=>so(a[n],o))&&t.add(n)}return t}function Jz(i,t){if(t.size===0)return i;let e={...i};for(let r of t)delete e[r];return e}var $l=class{constructor(t,e,r,n,o,a,s,l={},c=()=>Qv){this.object=t;this.fromRef=e;this.toRef=r;this.data=n;this.sharedAssets=o;this.allowSlerp=a;this.page=s;this.hooks=l;this.inert=c;this.builtReversed=!1;this.startStateId=null;this.buildCallback=()=>{this.builtReversed=this.runner.isReversed,this.startStateId=cn(this.object)?null:this.object.transitionState.state,this.callback=yB(this.object,{},Jz(this.end.data,this.inert()),{scene:this.page.scene,shared:this.sharedAssets},this.allowSlerp)};this.onChange=t=>{this.builtReversed!==this.runner.isReversed&&this.buildCallback(),this.callback&&(this.callback.update(t),this.object.requestRender()),this.writeState(t)};this.runner=new ru(Kz(n),this.onChange,this.buildCallback),this.rebind()}rebind(){let{fromRef:t,toRef:e}=this;if(t===void 0){let n=pu(this.object,this.object.currentState===e?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=pu(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(e===void 0)throw new Error("Missing property");let r=pu(this.object,e);if(!r)throw new Error("Missing property");this.to=r,this.buildCallback()}refresh(){this.buildCallback()}get endpointData(){return[this.from.data,this.to.data]}get targetStateId(){return this.builtReversed?this.from.id:this.to.id}get start(){return this.builtReversed?this.to:this.from}get end(){return this.builtReversed?this.from:this.to}writeState(t){if(t===0||cn(this.object))return;let e=t===1,r=t>.5?this.targetStateId:this.startStateId,n=this.object.transitionState;n.settled===e&&n.state===r||(this.object.transitionState={settled:e,state:r},this.object.reversibleToState=this.end.id,this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=r,this.object.dispatchEvent({type:"transitionState",settled:e,state:r}),this.object.dispatchEvent({type:e?"completeState":"beginState",state:r}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof St&&o.dispatchEvent(e?IA:MA)}),e?this.hooks.onComplete?.(r):this.hooks.onBegin?.(r))}};var RA=new Map,Gh=new Map,yi=class extends vB.EventDispatcher{constructor(e,r,n,o,a,s,l){super();this.id=e;this.data=r;this.scene=n;this.sharedAssets=o;this.object=a;this.eventType=s;this.actionCondition=l;this.evaluators=[];this.elapsed=0;this.lastTime=null;this.direction=1;this._playing=!1;this._finished=!1;this.hasPlayedOnce=!1;this.pauseOnNextCycleEnd=!1;this.lastCycleIndex=0;try{let c=Ic.findTimeline(this.scene.data.objects,this.data.timeline),d=c.duration;this.animatedObjectIds=Object.keys(c.objectTimelines),this.animatedObjectIds.forEach(u=>{let p=this.scene.find(u);if(!p)return;let h=c.objectTimelines[u];!h||this.evaluators.push(lB(p,{...h},d,{scene:n,shared:o},this.sharedAssets))}),this.schedule=new dv(aR(this.data,d))}catch(c){throw!1&&console.error(c),new Error("Missing property")}a&&(Gh.has(a.uuid)?Gh.get(a.uuid).push(this):Gh.set(a.uuid,[this])),RA.set(e,this)}get playing(){return this._playing}get finished(){return this._finished}get paused(){return!this._playing}update(e){this.lastTime!==null&&(this.elapsed=Math.max(0,this.elapsed+(e-this.lastTime)*this.direction)),this.lastTime=e,this.applyAtElapsed()}applyAtElapsed(){if(this.direction===-1&&this.elapsed===0){this.pause();return}let e=this.schedule.resolve(this.elapsed);if(e){if(e.cycleIndex!==this.lastCycleIndex&&(this.lastCycleIndex=e.cycleIndex,this.pauseOnNextCycleEnd)){this.pauseOnNextCycleEnd=!1,this.pause();return}for(let r of this.evaluators)r.evaluate(e.localTime);return}this.direction===1&&this.schedule.isFinished(this.elapsed)&&this.finish()}finish(){this.pause(),this._finished=!0,this.animatedObjectIds.forEach(e=>{let r=this.scene.find(e);r instanceof St&&r.dispatchEvent(IA)})}startTicking(){this._playing=!0,this.lastTime=null;for(let e of this.evaluators)e.invalidate();Vr.add(this)}play(){let e=this.eventType!==void 0&&dp(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&this.paused&&this.elapsed>0&&!this._finished;if(this.eventType!==void 0&&dp(this.eventType)&&this.data.runMode==="Once"&&this.hasPlayedOnce&&!e||this.eventType===void 0&&this._finished)return!1;this.hasPlayedOnce=!0,this.animatedObjectIds.forEach(r=>{let n=this.scene.find(r);n instanceof St&&n.dispatchEvent(MA)}),!e&&(this.elapsed===0||this._finished)&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.startTicking()}pause(){this._playing=!1,this.lastTime=null,Vr.remove(this)}stop(){this.pause(),this.elapsed=0,this.lastCycleIndex=0,this.applyAtElapsed(),this._finished=!1}seek(e){let r=this.schedule.totalDuration;this.elapsed=e*(Number.isFinite(r)?r:this.schedule.effectiveCycleDuration);for(let n of this.evaluators)n.invalidate();this.applyAtElapsed()}toggle(e){let r=e??this.direction===-1;if(this._playing&&this.direction===(r?1:-1)){r&&(this.pauseOnNextCycleEnd=!1);return}r?(this._finished&&(this.elapsed=0,this.lastCycleIndex=0,this._finished=!1),this.direction=1,this.pauseOnNextCycleEnd=!1):(this.direction=this.schedule.resolve(this.elapsed)?.isReverse?1:-1,this.pauseOnNextCycleEnd=!0),this.startTicking()}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}},BA=class{constructor(t){this.data=t}dispatch(){this.data.playTimeline?this.pauseTimeline(this.data.playTimeline):this.data.object?this.pauseAllTimelinesFromObject(this.data.object):this.pauseAllTimelines()}pauseTimeline(t){let e=this.getTimelineActions(t);!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>{r[this.data.interaction]()}),this.disposeDelay()},this.data.delay)):e.forEach(r=>{r[this.data.interaction]()}))}getTimelineActions(t){let e=RA.get(t);return e?[e]:[...RA.values()].filter(r=>r.data.timeline===t)}pauseAllTimelinesFromObject(t){let e=Gh.get(t);!e?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(r=>r[this.data.interaction]()),this.disposeDelay()},this.data.delay)):e.forEach(r=>r[this.data.interaction]()))}pauseAllTimelines(){let t=[...Gh.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(e=>{e.forEach(r=>{r[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Kv=class{constructor(t,e,r,n,o,a,s){this.data=e;let l="interaction"in e?e.interaction:"play";if(l==="play"||l===void 0)this.interaction=new yi(t,e,r,n,o,a,s);else if(l==="pause"||l==="stop")this.interaction=new BA(e);else throw new Error("Missing property")}get playing(){return this.interaction instanceof yi?this.interaction.playing:!1}get finished(){return this.interaction instanceof yi?this.interaction.finished:!0}get paused(){return this.interaction instanceof yi?this.interaction.paused:!0}play(){if(this.interaction instanceof yi)return this.interaction.play();this.interaction.dispatch()}stop(){this.interaction instanceof yi&&this.interaction.stop()}seek(t){this.interaction instanceof yi&&this.interaction.seek(t)}toggle(t){this.interaction instanceof yi?this.interaction.toggle(t):this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof yi?this.interaction.playFromCurrent():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof yi?We(this.interaction.sharedAssets,this.interaction.actionCondition)&&this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof yi&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};Zt("TimelineAnimation",({id:i,data:t,page:e,shared:r,object:n,eventType:o,actionCondition:a})=>new Kv(i,t,e.scene,r,n,o,a));Pe("timeline");var xB=require("three");function bB(i){let t=i.tweens[0]?.data;return{delay:t?.delay??i.delay,delayDirection:t?.delayDirection??"start-once",direction:t?.direction??i.direction,repeat:t?.repeat??i.repeat}}var $z={state:null,duration:0,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,easing:0},Zv=class extends xB.EventDispatcher{constructor(e,r,n,o,a,s){super();this.eventType=e;this.data=r;this.page=n;this.shared=o;this.condition=a;this.runModeOverride=s;this.tweens=[];this.hasPlayedOnce=!1;this.inert=Qv;if(!r.object)throw new Error("Missing property");let l=this.page.scene.find(r.object)??this.page.uiCanvas?.find(r.object)??this.page.scene.find2DInUIObjects(r.object);if(!l)throw new Error("Missing property");if(!l.states)throw new Error("Missing property");if(this.object=l,r.tweens.length<2)throw new Error("Missing property");this.init()}get playing(){return this.runner?.isPlaying===!0}get animating(){return this.runner?.isAnimating===!0}get claimTime(){return this.runner?.claimTime}get contested(){let e=this.object.previousAction;return e!==null&&e!==this&&e.animating}init(){this.initialCurrentState=pu(this.object,this.object.currentState).id,this.build()}shouldReinit(){return We(this.shared,this.condition)?!0:!(this.animating&&!this.loopsForever)}get loopsForever(){return bB(this.data).repeat===-1||this.data.tweens.some((e,r)=>r>0&&e.data.repeat===-1)}get runMode(){return this.runModeOverride!==void 0?this.runModeOverride:dp(this.eventType)?this.data.runMode:"Repeat"}get currentState(){return this.runMode==="Toggle"?this.initialCurrentState:this.object.currentState}get opensOnCurrent(){return this.data.tweens[0].data.state===void 0&&this.runMode!=="Toggle"}build(){let e=this.data.tweens,r=[];try{let n=e[0].data.state;n!==void 0&&r.push(new $l(this.object,n,n,$z,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert));for(let o=1;o<e.length;o++){let a=e[o-1],s=e[o];r.push(new $l(this.object,a.data.state===void 0?this.currentState:a.data.state,s.data.state===void 0?this.currentState:s.data.state,s.data,this.shared,this.data.allowSlerp??!1,this.page,{},()=>this.inert))}}catch(n){n instanceof Error&&console.error(n.message);return}this.tweens=r,this.syncInert(),this.runner=new pv({...DA(bB(this.data)),runMode:this.runMode},r.map(n=>n.runner),{claim:n=>this.claimObject(n),assignCurrentState:()=>this.rebindTweens(),isOwner:()=>this.object.previousAction===this})}claimObject(e){if(this.object.previousAction===this)return!1;let r=this.object.previousAction;if(r?.animating===!0){if(e!==void 0&&r.claimTime!==void 0&&r.claimTime>e)return!1;r.pause()}return this.object.previousAction=this,!0}rebindTweens(){for(let e of this.tweens)try{e.rebind()}catch(r){r instanceof Error&&console.error(r.message)}this.syncInert(),this.object instanceof St&&this.object.wasMovedByUser&&(this.object.wasMovedByUser=!1)}syncInert(){let e=this.tweens.flatMap(r=>r.endpointData);if(this.opensOnCurrent&&e.length>0){let r=pu(this.object,this.object.currentState);r&&(e[0]=r.data)}this.inert=gB(e);for(let r of this.tweens)r.refresh()}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&Vr.remove(this)}play(){if(We(this.shared,this.condition)===!1||this.runMode==="Once"&&this.hasPlayedOnce)return!1;this.hasPlayedOnce=!0,this.start()}start(){!this.runner||(this.runner.play(Vr.time),this.runner.isPlaying&&Vr.add(this))}pause(){this.runner?.stop(),Vr.remove(this)}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;cn(this.object)?this.object.changeSelectedState(e,{shared:this.shared}):this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){if(We(this.shared,this.condition)===!1)return!1;this.runner?.seek(e)}playDirected(e){if(We(this.shared,this.condition)===!1)return!1;!this.runner||(this.runner.playDirected(Vr.time,e),this.runner.isPlaying&&Vr.add(this))}playFromCurrent(){this.playDirected(!0)}reverseFromCurrent(){this.playDirected(!1)}dispose(){this.pause()}};var $v=require("three");function SB(i){let t=i?.tracks.filter(e=>e.ValueTypeName==="vector"||e.ValueTypeName==="quaternion").map(e=>e.times.length);if(t?.length){let e=ET(t);return e&&e>2?e:2}return 2}var hu=new Map,Uh=new WeakSet;function AB(i,t){if(t===void 0)return;let e=i.scene.find(t);return e&&Array.isArray(e.identity)?e.identity[0]:t}var xo=class extends $v.EventDispatcher{constructor(e,r,n,o,a){super();this.page=r;this.animationControls=n;this.shared=o;this.condition=a;this.startOnceDelay=0;this.toggleIsForward=!1;let s=AB(r,e.object)??e.object;this.data={...e,object:s};let l=this.animationControls.clipIdToAction[e.clipId+"/"+s];if(this.duration=l?.getClip()?.duration??1,this.data.crop2){let d=SB(l?.getClip());this.leftFrameTime=this.data.crop2[0]/(d-1)*this.duration,this.rightFrameTime=this.data.crop2[1]/(d-1)*this.duration}else{let d=l?.getClip()?.tracks[0]?.times.length;d&&d>1?(this.leftFrameTime=this.data.crop[0]/d*this.duration,this.rightFrameTime=this.data.crop[1]/d*this.duration):(this.leftFrameTime=0,this.rightFrameTime=this.duration)}this.startOnceDelay=e.delay;let c=hu.get(s);c||(c=new Set,hu.set(s,c)),c.add(this)}get playing(){return this.threeAnimAction?.isRunning()??!1}cancelPending(){window.clearTimeout(this.timeoutId),delete this.timeoutId}resume(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object];return!e||!Uh.has(e)?!1:(Uh.delete(e),this.threeAnimAction=e,e.paused=!1,e.play(),this.animationControls.requestRender(),!0)}play(e=!1){if(We(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.resume()||(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction))return;Uh.delete(this.threeAnimAction),this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let r=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([n,o])=>{let a=n.split("/")[1];this.threeAnimAction!==o&&a===r&&(e?o.fadeOut(.2):o.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),this.cancelPending()}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=$v.MathUtils.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,r=!1){if(We(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing||this.resume()?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 n=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([o,a])=>{let s=o.split("/")[1];this.threeAnimAction!==a&&s===n&&a.isRunning()&&(r?a.fadeOut(.2):a.stop())}),r&&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();let r=hu.get(this.data.object);r&&(r.delete(this),r.size===0&&hu.delete(this.data.object))}},NA=class{constructor(t,e,r){this.data=t;this.page=e;this.animationControls=r;this.objectId=AB(e,t.object)}dispatch(){this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{this.apply(),this.disposeDelay()},this.data.delay)):this.apply()}targetsClip(t,e){return!(this.objectId!==void 0&&e!==this.objectId||this.data.clipId&&t!==this.data.clipId)}apply(){(this.objectId!==void 0?[hu.get(this.objectId)]:[...hu.values()]).forEach(r=>{r?.forEach(n=>{this.targetsClip(n.data.clipId,n.data.object)&&n.cancelPending()})});let e=!1;Object.entries(this.animationControls.clipIdToAction).forEach(([r,n])=>{let[o,a]=r.split("/");if(!!this.targetsClip(o,a))if(this.data.interaction==="pause"){if(!n.isRunning())return;n.paused=!0,Uh.add(n)}else{if(!n.enabled||!n.isRunning()&&!n.paused)return;n.paused=!0,Uh.delete(n),n.time=n._clip.start??0,n._loopCount=-1,e=!0}}),e&&(this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){this.disposeDelay()}},Jv=class{constructor(t,e,r,n,o){im.isPause(t)?this.interaction=new NA(t,e,r):this.interaction=new xo(t,e,r,n,o)}get data(){return this.interaction.data}get playing(){return this.interaction instanceof xo?this.interaction.playing:!1}play(t=!1){if(this.interaction instanceof xo)return this.interaction.play(t);this.interaction.dispatch()}pause(){this.interaction instanceof xo&&this.interaction.pause()}stop(){this.interaction instanceof xo&&this.interaction.stop()}seek(t){this.interaction instanceof xo&&this.interaction.seek(t)}toggle(t,e=!1){if(this.interaction instanceof xo)return this.interaction.toggle(t,e);this.interaction.dispatch()}playFromCurrent(){this.interaction instanceof xo?this.interaction.playFromCurrent():this.interaction.dispatch()}reverseFromCurrent(){this.interaction instanceof xo&&this.interaction.reverseFromCurrent()}dispose(){this.interaction.dispose()}};var ej=null;function wB(i){ej=i}wB($l);Zt("Transition",({eventType:i,data:t,page:e,shared:r,actionCondition:n,runModeOverride:o})=>new Zv(i,t,e,r,n,o));Zt("Animation",({data:i,page:t,eventManager:e,shared:r,actionCondition:n})=>new Jv(i,t,e.animationControls,r,n));Pe("transitions");var tj="text/plain",rj="us-ascii",EB=(i,t)=>t.some(e=>e instanceof RegExp?e.test(i):e===i),nj=(i,{stripHash:t})=>{let e=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(i);if(!e)throw new Error(`Invalid URL: ${i}`);let{type:r,data:n,hash:o}=e.groups,a=r.split(";");o=t?"":o;let s=!1;a[a.length-1]==="base64"&&(a.pop(),s=!0);let l=(a.shift()||"").toLowerCase(),d=[...a.map(u=>{let[p,h=""]=u.split("=").map(f=>f.trim());return p==="charset"&&(h=h.toLowerCase(),h===rj)?"":`${p}${h?`=${h}`:""}`}).filter(Boolean)];return s&&d.push("base64"),(d.length>0||l&&l!==tj)&&d.unshift(l),`data:${d.join(";")},${s?n.trim():n}${o?`#${o}`:""}`};function LA(i,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},i=i.trim(),/^data:/i.test(i))return nj(i,t);if(/^view-source:/i.test(i))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let e=i.startsWith("//");!e&&/^\.*\//.test(i)||(i=i.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let n=new URL(i);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&n.protocol==="https:"&&(n.protocol="http:"),t.forceHttps&&n.protocol==="http:"&&(n.protocol="https:"),t.stripAuthentication&&(n.username="",n.password=""),t.stripHash?n.hash="":t.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname){let a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,s=0,l="";for(;;){let d=a.exec(n.pathname);if(!d)break;let u=d[0],p=d.index,h=n.pathname.slice(s,p);l+=h.replace(/\/{2,}/g,"/"),l+=u,s=p+u.length}let c=n.pathname.slice(s,n.pathname.length);l+=c.replace(/\/{2,}/g,"/"),n.pathname=l}if(n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let a=n.pathname.split("/"),s=a[a.length-1];EB(s,t.removeDirectoryIndex)&&(a=a.slice(0,-1),n.pathname=a.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let a of[...n.searchParams.keys()])EB(a,t.removeQueryParameters)&&n.searchParams.delete(a);if(t.removeQueryParameters===!0&&(n.search=""),t.sortQueryParameters){n.searchParams.sort();try{n.search=decodeURIComponent(n.search)}catch{}}t.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,""));let o=i;return i=n.toString(),!t.removeSingleSlash&&n.pathname==="/"&&!o.endsWith("/")&&n.hash===""&&(i=i.replace(/\/$/,"")),(t.removeTrailingSlash||n.pathname==="/")&&n.hash===""&&t.removeSingleSlash&&(i=i.replace(/\/$/,"")),e&&!t.normalizeProtocol&&(i=i.replace(/^http:\/\//,"//")),t.stripProtocol&&(i=i.replace(/^(?:https?:)?\/\//,"")),i}var eb=class{constructor({url:t,context:e},r,n,o){this.controlsManager=r;this.shared=n;this.condition=o;if(!t)throw new Error("Missing property");this.url=t.startsWith("mailto:")?t:LA(t,{removeTrailingSlash:!1,removeSingleSlash:!1,stripWWW:!1}),this.context=e??"tab"}dispatch(){if(We(this.shared,this.condition)===!1)return!1;Vc?window.location.assign(this.url):(this.context==="tab"||f0&&this.context==="none"?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(Mr[0]),AT())}};var tb=class{constructor(t,e,r,n,o){this.data=t;this.page=e;this.shared=r;this.eventManager=n;this.condition=o}dispatch(){if(We(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),qv(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}};var Us=require("three");var ij={type:"beginState"},CB={type:"completeState",isfromEntity:!1},TB={type:"requestRender"},rb=class extends Us.EventDispatcher{constructor(e,r,n,o){super();this.data=e;this.page=r;this.shared=n;this.condition=o;this.toggleIsForward=!1;this.posStart=new Us.Vector3;this.posEnd=new Us.Vector3;this.qStart=new Us.Quaternion;this.qEnd=new Us.Quaternion;this.zoomStart=1;this.zoomEnd=1}init(){}get playing(){return this.runner?.isPlaying===!0}buildAnimation(e=!1){if(!this.data.animate)return;let r=this.page.scene.find(this.data.targetCamera);if(!r||!r.visible)throw new ReferenceError("Target camera not founded or not visible");this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom;let n={duration:this.data.duration,delay:0,delayDirection:"start-once",direction:"normal",repeat:0,ease:OA(this.data)},o=a=>{let s=this.page.activeCamera;s.position.lerpVectors(this.posStart,this.posEnd,a),s.quaternion.slerpQuaternions(this.qStart,this.qEnd,a),s.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*a,s.wasMovedBySwitchCameraAction=!0,s.updateMatrix(),s.updateMatrixWorld(),s.updateProjectionMatrix(),s.dispatchEvent(TB),a===1&&s.dispatchEvent(CB)};this.runner=new ru(n,o,()=>{this.data.runMode==="Toggle"&&!this.toggleIsForward?this.fromCamera&&(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(r.position),this.qEnd.copy(r.quaternion),this.zoomEnd=r.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(r.uuid)),this.page.activeCamera.dispatchEvent(ij),o(0)})}update(e){this.runner?.update(e),this.runner?.isPlaying!==!0&&Vr.remove(this)}start(){!this.runner||(this.runner.start(Vr.time),Vr.add(this))}switchCamera(e){let r=this.page.activeCamera,n=this.page.scene.find(e);if(!n||!n.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(n),r.dispatchEvent({type:"cameraChange",camera:n})}play(){if(We(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.start()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.runner?.stop(),Vr.remove(this),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(We(this.shared,this.condition)===!1)return!1;if(window.clearTimeout(this.timeoutId),delete this.timeoutId,e!==this.toggleIsForward)try{this.playing?(this.runner?.stop(),this.toggleIsForward=e??!this.toggleIsForward,this.buildAnimation(!0),this.start()):this.timeoutId=window.setTimeout(()=>{this.toggleIsForward=e??!this.toggleIsForward,this.data.animate?(this.runner?.stop(),this.buildAnimation(),this.start()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.fromCamera&&this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(CB),this.page.activeCamera.dispatchEvent(TB))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}};var nb=class{constructor(t,e,r,n){this.data=t;this.page=e;this.shared=r;this.condition=n}dispatch(){if(We(this.shared,this.condition)===!1)return!1;(this.data.target==="single"?this.data.variableId?[this.data.variableId]:[]:Object.keys(this.shared.getVariables())).forEach(e=>{this.shared.getVariable(e);let r=this.shared.data.variables.data(e)?.value;r!==void 0&&this.shared.updateVariable(e,r),this.shared.enableLocalStorageForPersistentVariables&&localStorage.removeItem(Fy(e))})}dispose(){}};Zt("Link",({data:i,eventManager:t,shared:e,actionCondition:r})=>new eb(i,t.controlsManager,e,r));Zt("Reset",({data:i,page:t,shared:e,eventManager:r,actionCondition:n})=>new tb(i,t,e,r,n));Zt("SwitchCamera",({data:i,page:t,shared:e,actionCondition:r})=>new rb(i,t,e,r));Zt("ClearLocalStorage",({data:i,page:t,shared:e,actionCondition:r})=>new nb(i,t,e,r));Pe("misc-actions");var oj=new Map;function on(i,t){oj.set(i,t)}var Qa=require("three"),DB=require("three"),ab=require("three"),Mn=require("three"),ri=require("three"),Hh=require("three"),ni=require("three"),GA=require("three"),Wh=require("three"),qh=require("three"),Xh=require("three"),Ji=require("three"),yu=require("three"),tc=require("three"),UA=require("three"),So=require("three"),aa=require("three"),lb=require("three"),cb=require("three"),rc=require("three"),db=require("three"),yn=require("three"),RB=require("three"),Yh=require("three"),zh=require("three"),jA=require("three"),ub=require("three"),BB=require("three"),gu=require("three"),NB=require("three"),pb=require("three"),vu=require("three"),wo=require("three"),ec=require("three"),hb=require("three"),_B=require("three"),Eo=require("three"),Gj=require("three"),kA=require("three"),jj=require("three"),fb=require("three"),wr=require("three"),zB=require("three"),Xj=require("three"),Qh=require("three"),Kh=require("three"),gi=require("three"),jB=require("three"),jh=require("three"),Za=require("three"),$i=require("three"),bu=require("three"),mu=require("three"),XB=require("three"),YB=require("three"),Zh=require("three"),Hs=require("three"),Zj=require("three"),Ws=require("three"),nc=require("three"),QB=require("three"),mb=require("three"),VA=require("three"),$j=require("three"),qA=require("three"),yb=require("three"),ZB=require("three");var OB={RED:0,GREEN:1,BLUE:2,ALPHA:3};var sb="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var aj=`#ifdef FRAMEBUFFER_PRECISION_HIGH
@@ -5240,4 +5240,4 @@ vec3 lab2rgb (in vec3 lab) {
5240
5240
 
5241
5241
  `;var Wb=class extends EL.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],vt.startContext(vt.globalContext),this.lightLayer=new Hn(0,"",{...Kt.defaultData("light","phong"),visible:!1},new Xs,{},r.shared),vt.endContext(vt.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Cu;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(gN),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(vN),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(xL),e.addFragmentParsCode(AL),e.addVertexFinalCode(SL({easeSize:this.easeSize})),e.addFragmentFinalCode(wL({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var CL=require("three/examples/jsm/misc/GPUComputationRenderer.js");uP({createMaterial:(i,t)=>new Wb(i,t),createComputation:(i,t,e)=>new CL.GPUComputationRenderer(i,t,e)});var Tw=require("three");function TL(i,t,e,r){let n=e,o=n.type==="texture"?n.texture.image!=null?r.uiBuffer(n.texture.image)??r.image(n.texture.image):r.getImage(""):r.video(n.texture.video),a=new $a(o,n.texture.wrapping??(n.type==="texture"?1e3:1001),n.texture.minFilter??1008,n.texture.magFilter??1006),s=new bb(o),l=new xb(lc(n.texture.repeat??[1,1],r),lc(n.texture.offset??[0,0],r),ue(n.texture.rotation??0,r)),c=new te(n.crop?1:0),d=new Fe(n.projection??0),u=new Fe(["x","y","z"].indexOf(n.axis)??0),p=n.projectionAxis?["x","y","z"].indexOf(n.projectionAxis):-1,h=new Fe(n.side??0),f=new Qt(n.size?new Tw.Vector2(...lc(n.size,r)):new Tw.Vector2(100,100)),m=new te(n.blending??0),y=new te(_i(n.alpha,r)),g=new Fe(n.mode??0),v=new _t(n.isMask??!1),b=new ts(a,s,c,d,u,h,f,m,l,y,g,v,p),S=new Re(b.calpha,"f");return new He(i,t,n,{texture:a,textureSize:s,crop:c,projection:d,axis:u,side:h,size:f,blending:m,mat:l,alpha:y,mode:g,isMask:v},b,g,S,v,r)}ut("texture",TL);ut("video",TL);var PL=require("three");ut("matcap",(i,t,e,r)=>{let n=e,o=n.texture.image!=null?r.image(n.texture.image):r.getImage(""),a=new $a(o,n.texture.wrapping??1001,n.texture.minFilter??1008,n.texture.magFilter??1006),s=new te(_i(n.alpha,r)),l=new Fe(n.mode??0),c=new _t(n.isMask??!1),d=new te((ue(n.texture.rotation??0,r)??0)*PL.MathUtils.DEG2RAD),u=new Lu(a,s,l,c,d),p=new Re(u.calpha,"f");return new He(i,t,n,{texture:a,alpha:s,mode:l,isMask:c,rotation:d},u,l,p,c,r)});var ML=require("three");ut("displace",(i,t,e,r)=>{let n=e;if(n.displacementType==="noise"){let o=new pr(new ML.Vector3(...n.offset.map(g=>ue(g,r)??0))),a=new te(ue(n.scale,r)??10),s=new te(ue(n.intensity,r)??8),l=new te(ue(n.movement,r)??1),c=new Fe(n.noiseType??0),d=new Fe(n.voronoiStyle??0),u=new te(ue(n.smoothness,r)??.5),p=new te(ue(n.seed,r)??0),h=new te(ue(n.highCut,r)??1),f=new te(ue(n.lowCut,r)??0),m=new Fe(ue(n.quality,r)??1),y=new ju(s,l,o,d,u,p,h,f,m,a,c);return new Wu(i,t,n,{offset:o,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:d,smoothness:u,seed:p,highCut:h,lowCut:f,quality:m},y,r)}else throw new Error});ut("cavity",(i,t,e,r)=>{let n=Dt(e,r),o=new te(ue(n.ridge,r)??1),a=new te(ue(n.valley,r)??1),s=It(n),l=new Ru(o,a,je.normalViewRenderTarget,je.resolution,s.alpha,s.mode,s.isMask),c=new Re(l.calpha,"f");return new He(i,t,e,{ridge:o,valley:a,...s},l,s.mode,c,s.isMask,r)});ut("dust",(i,t,e,r)=>{let n=Dt(e,r),o=new ot(n.color??10323813),a=new te(n.coverage??.2),s=new te(n.softness??.2),l=new te(n.noiseStrength??.2),c=new te(n.noiseScale??1),d=It(n),u=new Bu(o,a,s,l,c,d.alpha,d.isMask),p=new Re(u.calpha,"f");return new He(i,t,e,{color:o,coverage:a,softness:s,noiseStrength:l,noiseScale:c,...d},u,d.mode,p,d.isMask,r)});ut("fresnel",(i,t,e,r)=>{let n=Dt(e,r),o=new ot(n.color??16777215),a=new te(ue(n.bias,r)??.1),s=new te(ue(n.scale,r)??1),l=new te(ue(n.intensity,r)??2),c=new te(ue(n.factor,r)??1),d=It(n),u=new hf(o,a,s,l,c,d.alpha,d.mode,d.isMask),p=new Re(u.calpha,"f");return new He(i,t,e,{color:o,bias:a,scale:s,intensity:l,factor:c,...d},u,d.mode,p,d.isMask,r)});var Xu=require("three");ut("gradient",(i,t,e,r)=>{let n=Dt(e,r),o=new Fe(n.gradientType??0),a=new _t(n.smooth??!1),s;n.colors?s=new bi(n.colors.length,n.colors):(s=new bi(10,new Xu.Vector4(0,0,0,1)),s.value[1]=new Xu.Vector4(1,1,1,1));let l;n.steps?l=new vi(n.steps.length,n.steps):(l=new vi(10,1),l.value[0]=0);let c=new Qt(eo(n.offset??new Xu.Vector2(0,0),r)),d=new Qt(eo(n.morph??new Xu.Vector2(0,0),r)),u=new te(ue(n.angle??0,r)),p=It(n),h=new Nu(o,a,s,l,c,d,u,p.alpha,p.isMask),f=new Re(h.calpha,"f");return new He(i,t,e,{gradientType:o,smooth:a,colors:s,steps:l,offset:c,morph:d,angle:u,...p},h,p.mode,f,p.isMask,r)});var Pw=require("three");ut("depth",(i,t,e,r)=>{let n=Dt(e,r),o=new Fe(n.gradientType??0),a=new _t(n.smooth??!1),s=new te(ue(n.near,r)??50),l=new te(ue(n.far,r)??200),c=new te(n.isVector??1),d=new te(n.isWorldSpace??0),u=new pr(xi(n.origin,r)),p=new pr(xi(n.direction,r)),h;n.colors?h=new bi(n.colors.length,n.colors):(h=new bi(2,new Pw.Vector4(0,0,0,1)),h.value[1]=new Pw.Vector4(1,1,1,1));let f;n.steps?f=new vi(n.steps.length,n.steps):(f=new vi(2,1),f.value[0]=0);let m=It(n),y=new Iu(o,a,s,l,c,d,u,p,h,f,m.alpha,m.isMask),g=new Re(y.calpha,"f");return new He(i,t,e,{gradientType:o,smooth:a,near:s,far:l,isVector:c,isWorldSpace:d,origin:u,direction:p,colors:h,steps:f,...m},y,m.mode,g,m.isMask,r)});var OL=require("three");ut("normal",(i,t,e,r)=>{let n=Dt(e,r),o=new pr(n.cnormal??new OL.Vector3(1,1,1)),a=It(n),s=new Ou(o,a.alpha),l=new Re(s.calpha,"f");return new He(i,t,e,{cnormal:o,...a},s,a.mode,l,a.isMask,r)});var Yu=require("three");ut("noise",(i,t,e,r)=>{let n=Dt(e,r),o=new te(ue(n.scale,r)??1),a=new pr(xi(n.size??new Yu.Vector3(100,100,100),r)),s=new te(ue(n.move,r)??1),l=new Qt(eo(n.fA??new Yu.Vector2(1.7,9.2),r)),c=new Qt(eo(n.fB??new Yu.Vector2(8.3,2.8),r)),d=new Qt(eo(n.distortion??new Yu.Vector2(1,1),r)),u=new On(n.colorA),p=new On(n.colorB),h=new On(n.colorC),f=new On(n.colorD),m=new Fe(n.noiseType??0),y=new Fe(n.voronoiStyle??0),g=new te(ue(n.highCut,r)??1),v=new te(ue(n.lowCut,r)??0),b=new te(ue(n.smoothness,r)??.5),S=new te(ue(n.seed,r)??.5),x=new Fe(n.quality??1),A=It(n),w=new _u(o,a,s,l,c,d,u,p,h,f,A.alpha,m,A.isMask,y,g,v,b,S,x),E=new Re(w.calpha,"f");return new He(i,t,e,{scale:o,size:a,move:s,fA:l,fB:c,distortion:d,colorA:u,colorB:p,colorC:h,colorD:f,noiseType:m,...A,voronoiStyle:y,highCut:g,lowCut:v,smoothness:b,seed:S,quality:x},w,A.mode,E,A.isMask,r)});ut("rainbow",(i,t,e,r,n)=>{let o=Dt(e,r),a=new te(ue(o.filmThickness,r)??30),s=new te(ue(o.movement,r)??0),l=new pr(xi(o.wavelengths,r)),c=new te(ue(o.noiseStrength,r)??0),d=new te(ue(o.noiseScale,r)??1),u=new pr(xi(o.offset,r)),p=It(o),h=n?.forceRainbowNoise===!0,f=h||po(o.noiseStrength),m=new Vu(a,s,l,c,d,u,p.alpha,p.isMask,f),y=new Re(m.calpha,"f"),g=new He(i,t,e,{filmThickness:a,movement:s,wavelengths:l,noiseStrength:c,noiseScale:d,offset:u,...p},m,p.mode,y,p.isMask,r);return g.noiseCompiledIn=f,g.noiseForced=h,g});var Qu=require("three");ut("toon",(i,t,e,r)=>{let n=Dt(e,r),o=new Fe(n.positioning??0),a;n.colors?a=new bi(n.colors.length,n.colors):(a=new bi(10,new Qu.Vector4(0,0,0,1)),a.value[1]=new Qu.Vector4(1,1,1,1));let s;n.steps?s=new vi(n.steps.length,n.steps):(s=new vi(10,1),s.value[0]=0);let l=new pr(xi(n.source??new Qu.Vector3(0,0,0),r)),c=new _t(n.isWorldSpace??!0),d=new te(ue(n.noiseStrength??0,r)),u=new te(ue(n.noiseScale??1,r)),p=new On(n.shadowColor),h=new pr(xi(n.offset??new Qu.Vector3(0,0,0),r)),f=It(n),m=new Gu(o,a,s,l,c,d,u,p,h,f.alpha),y=new Re(m.calpha,"f");return new He(i,t,e,{positioning:o,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:d,noiseScale:u,shadowColor:p,offset:h,...f},m,f.mode,y,f.isMask,r)});var DL=require("three");ut("outline",(i,t,e,r)=>{let n=Dt(e,r),o=new ot(n.outlineColor??16777215),a=new ot(n.contourColor??16777215),s=new te(ue(n.outlineWidth??.1,r)),l=new te(ue(n.contourWidth??.1,r)),c=new te(ue(n.outlineThreshold??.1,r)),d=new te(ue(n.contourThreshold??.1,r)),u=new te(ue(n.outlineSmoothing??.1,r)),p=new te(ue(n.contourFrequency??.1,r)),h=new pr(xi(n.contourDirection??new DL.Vector3(0,1,0),r)),f=new _t(n.positionalLines??!1),m=new _t(n.compensation??!0),y=je.normalRenderTarget,g=je.normalRenderTargetDepth,v=je.pixelRatioNode,b=je.resolution,S=It(n),x=new Fu(o,a,s,l,c,d,u,p,h,f,m,b,y,g,v,S.alpha),A=new Re(x.calpha,"f");return new He(i,t,e,{outlineColor:o,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:d,outlineSmoothing:u,contourFrequency:p,contourDirection:h,positionalLines:f,compensation:m,...S},x,S.mode,A,S.isMask,r)});ut("transmission",(i,t,e,r)=>{let n=Dt(e,r),o=new te(ue(n.thickness??10,r)),a=new te(ue(n.ior??1.5,r)),s=new te(ue(n.roughness??.5,r)),l=je.transmissionSize,c=je.transmissionRenderTarget,d=je.transmissionRenderTargetDepth,u=window.innerWidth,p=window.innerHeight,h=u>=p?new Qt(p/u,1):new Qt(1,u/p),f=It(n),m=new Uu(o,a,s,l,c,d,h,f.alpha),y=new Re(m.calpha,"f");return new He(i,t,e,{thickness:o,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,r)});var IL=!1;function Z4(){IL||(IL=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer \u2014 it renders as invisible on the classic WebGL pipeline."))}ut("reflection",(i,t,e,r)=>{Z4();let n=Dt(e,r),o=new te(n.blur??0),a=new te(n.thickness??10/1e4),s=new Fe(n.steps??60),l=new te(n.stepSize??5/1e3),c=new Fe(n.tracingMode??1),d=It(n),u=new ot(0,0,0,1),p=new te(0),h=new es(u,p),f=new Re(h.calpha,"f");return new He(i,t,e,{blur:o,thickness:a,steps:s,stepSize:l,tracingMode:c,...d},h,d.mode,f,d.isMask,r)});var qb=require("three");ut("pattern",(i,t,e,r)=>{let n=Dt(e,r),o=new Fe(n.style??0),a=new Fe(n.projection??0),s=new Fe(["x","y","z"].indexOf(n.axis)??0),l=new te(ue(n.blending??0,r)),c=new Qt(eo(n.offset,r)),d=new On(n.colorA),u=new On(n.colorB),p=new Qt(eo(n.frequency??new qb.Vector2(10,10),r)),h=new te(ue(n.size??.5,r)),f=new te(ue(n.variation??0,r)),m=new te(ue(n.smoothness??.5,r)),y=new te(ue(n.zigzag??0,r)),g=new te(ue(n.rotation??0,r)),v=new Qt(eo(n.vertical??new qb.Vector2(0,1),r)),b=new Qt(eo(n.horizontal??new qb.Vector2(0,1),r)),S=new Fe(n.sides??6),x=It(n),A=new ku(o,a,s,l,c,d,u,p,h,f,m,y,g,v,b,S,x.alpha,x.isMask),w=new Re(A.calpha,"f");return new He(i,t,e,{style:o,projection:a,axis:s,blending:l,offset:c,colorA:d,colorB:u,frequency:p,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:b,sides:S,...x},A,x.mode,w,x.isMask,r)});ut("vertexColor",(i,t,e,r)=>{let n=Dt(e,r),o=It(n),a=new zu(o.alpha),s=new Re(a.calpha,"f");return new He(i,t,e,{...o},a,o.mode,s,o.isMask,r)});ZM({createRootMaterial:(i,t)=>new qu(i,t),createSharedMaterial:(i,t,e)=>new Hb(i,t,e)});r2((i,t)=>i?kN(t):VN());e2(()=>{let i=new RL.ShadowMaterial;return i.depthWrite=!1,i.opacity=.5,i.onBeforeCompile=t=>{t.fragmentShader=`layout(location = 1) out vec4 gVelocity;
5242
5242
  `+t.fragmentShader.replace("void main() {",`void main() {
5243
- gVelocity = vec4(0.0);`)},i});var BL="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Xb=class extends Yb.Loader{load(t,e,r,n=console.error){let o=new Yb.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(BL+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(BL),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){n(s)}},r,a=>n(a))}async parse(t){let e=await nN(t,mL),r=iN(e);e.version&&"2.0.63"&&(0,NL.default)(e.version,"2.0.63")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&rN(),V2(e)&&zM(),U0(e)&&JO(),VO(e)&&eg(),Gb(e)&&ww()].filter(Boolean)),r.length&&await oN(r);let n=!1,o=new ws(e.shared,{},n);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new jb(e.scene,o);Gb(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=hL(a),a=cL(a),a=dL(a),a=uL(a),a=fL(a),a}};
5243
+ gVelocity = vec4(0.0);`)},i});var BL="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Xb=class extends Yb.Loader{load(t,e,r,n=console.error){let o=new Yb.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(BL+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(BL),o.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){n(s)}},r,a=>n(a))}async parse(t){let e=await nN(t,mL),r=iN(e);e.version&&"2.0.65"&&(0,NL.default)(e.version,"2.0.65")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&rN(),V2(e)&&zM(),U0(e)&&JO(),VO(e)&&eg(),Gb(e)&&ww()].filter(Boolean)),r.length&&await oN(r);let n=!1,o=new ws(e.shared,{},n);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new jb(e.scene,o);Gb(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=hL(a),a=cL(a),a=dL(a),a=uL(a),a=fL(a),a}};