@joshtol/emotive-engine 3.4.1 โ 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/emotive-mascot-3d-elementals.js +1 -1
- package/dist/emotive-mascot-3d-elementals.umd.js +1 -1
- package/dist/emotive-mascot-3d.js +1 -1
- package/dist/emotive-mascot-3d.umd.js +1 -1
- package/dist/emotive-mascot.lean.js +1 -1
- package/dist/emotive-mascot.lean.umd.js +1 -1
- package/dist/emotive-mascot.minimal.js +1 -1
- package/dist/emotive-mascot.minimal.umd.js +1 -1
- package/dist/emotive-mascot.umd.js +1 -1
- package/dist/mascot.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EmotiveMascotMinimal={})}(this,function(t){"use strict";class e{constructor(){this.errors=[],this.maxErrors=10,this.errorCounts=new Map,this.defaults={emotion:"neutral",gesture:null,audioLevel:0,particleCount:0,glowIntensity:.7,coreSize:1,breathRate:1,color:"#B0B0B0"}}wrap(t,e,i=null){return(...s)=>{try{const a=t(...s);return a&&"function"==typeof a.then?a.catch(t=>(this.logError(t,e),null!==i?i:this.getDefault(e))):a}catch(t){return this.logError(t,e),null!==i?i:this.getDefault(e)}}}logError(t,e){const i={timestamp:(new Date).toISOString(),context:e,message:t.message,stack:t.stack};this.errors.push(i);const s=this.errorCounts.get(e)||0;this.errorCounts.set(e,s+1),this.errors.length>this.maxErrors&&this.errors.shift()}getDefault(t){const e={"emotion-transition":this.defaults.emotion,"gesture-execution":this.defaults.gesture,"audio-processing":this.defaults.audioLevel,"particle-system":this.defaults.particleCount,rendering:{glowIntensity:this.defaults.glowIntensity,coreSize:this.defaults.coreSize,color:this.defaults.color},"canvas-operations":null,"state-management":this.defaults.emotion};return{}.hasOwnProperty.call(e,t)?e[t]:null}validateInput(t,e,i){try{switch(e){case"emotion":return["neutral","joy","sadness","anger","fear","surprise","disgust","love","euphoria"].includes(t)?t:i;case"undertone":return null===t||["nervous","confident","tired","intense","subdued"].includes(t)?t:null;case"gesture":return["bounce","pulse","shake","spin","nod","tilt","expand","contract","flash","drift"].includes(t)?t:i;case"number":return"number"!=typeof t||isNaN(t)?i:t;case"string":return"string"==typeof t?t:i;case"boolean":return"boolean"==typeof t?t:i;default:return null!=t?t:i}}catch(t){return this.logError(t,"input-validation"),i}}hasExceededThreshold(t,e=5){return(this.errorCounts.get(t)||0)>=e}getErrorStats(){return{totalErrors:this.errors.length,errorsByContext:Object.fromEntries(this.errorCounts),recentErrors:this.errors.slice(-5)}}clearErrors(){this.errors=[],this.errorCounts.clear()}async attemptRecovery(t,e,i=3){let s=0;for(;s<i;)try{return await e()}catch(e){if(s++,this.logError(e,`recovery-${t}-attempt-${s}`),s>=i)throw new Error(`Recovery failed for ${t} after ${i} attempts`);await new Promise(t=>setTimeout(t,100*Math.pow(2,s)))}}}class i{constructor(){this.listeners=new Map,this.groups=new Map,this.stats={registered:0,removed:0,active:0},this.t={},this.i=new Map}addEventListener(t,e,i,s={},a="default"){const h=this.generateId(),n={id:h,target:t,eventType:e,handler:i,options:s,group:a,active:!0};return this.listeners.set(h,n),this.groups.has(a)||this.groups.set(a,new Set),this.groups.get(a).add(h),t.addEventListener(e,i,s),this.stats.registered++,this.stats.active++,h}removeEventListener(t){const e=this.listeners.get(t);if(!e||!e.active)return!1;e.target.removeEventListener(e.eventType,e.handler,e.options),e.active=!1;const i=this.groups.get(e.group);return i&&(i.delete(t),0===i.size&&this.groups.delete(e.group)),this.listeners.delete(t),this.stats.removed++,this.stats.active--,!0}removeGroup(t){const e=this.groups.get(t);if(!e)return 0;let i=0;for(const t of e)this.removeEventListener(t)&&i++;return i}removeAllForTarget(t){let e=0;for(const[i,s]of this.listeners.entries())s.target===t&&s.active&&this.removeEventListener(i)&&e++;return e}removeAllOfType(t){let e=0;for(const[i,s]of this.listeners.entries())s.eventType===t&&s.active&&this.removeEventListener(i)&&e++;return e}removeAll(){let t=0;for(const[e,i]of this.listeners.entries())i.active&&this.removeEventListener(e)&&t++;return t}createAutoRemove(t,e,i,s={}){const a=this.addEventListener(t,e,i,s);return{id:a,remove:()=>this.removeEventListener(a)}}once(t,e,i,s={}){const a=this.addEventListener(t,e,t=>{i(t),this.removeEventListener(a)},s);return a}debounced(t,e,i,s=250,a={}){let h;return this.addEventListener(t,e,t=>{clearTimeout(h),h=setTimeout(()=>i(t),s)},a)}throttled(t,e,i,s=100,a={}){let h=!1;return this.addEventListener(t,e,t=>{h||(i(t),h=!0,setTimeout(()=>{h=!1},s))},a)}on(t,e){this.i.has(t)||this.i.set(t,[]),this.i.get(t).push(e)}off(t,e){const i=this.i.get(t);if(!i)return;const s=i.indexOf(e);-1!==s&&i.splice(s,1),0===i.length&&this.i.delete(t)}emit(t,e=null){const i=this.i.get(t);if(i)for(let t=0;t<i.length;t++)try{i[t](e)}catch(t){}}removeAllListeners(t=null){if(t){const e=this.i.get(t),i=e?e.length:0;return this.i.delete(t),i}let e=0;for(const t of this.i.values())e+=t.length;return this.i.clear(),e}listenerCount(t){const e=this.i.get(t);return e?e.length:0}getEventNames(){return Array.from(this.i.keys())}getEventStats(){let t=0;for(const e of this.i.values())t+=e.length;return{domListeners:this.stats.active,emitterEvents:this.i.size,emitterListeners:t}}getDebugInfo(){const t={};for(const[e,i]of this.i)t[e]=i.length;return{domStats:this.getStats(),emitterEvents:t,activeListeners:this.getActiveListeners()}}generateId(){return`listener_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{...this.stats,groups:this.groups.size,listeners:this.listeners.size}}getActiveListeners(){const t=[];for(const[e,i]of this.listeners.entries())i.active&&t.push({id:e,eventType:i.eventType,group:i.group,target:i.target.constructor.name});return t}analyzeLeaks(){const t={totalListeners:this.listeners.size,activeListeners:this.stats.active,inactiveButNotRemoved:0,byTarget:new Map,byType:new Map,potentialLeaks:[]};for(const[e,i]of this.listeners.entries()){const s=i.target.constructor.name;t.byTarget.set(s,(t.byTarget.get(s)||0)+1),t.byType.set(i.eventType,(t.byType.get(i.eventType)||0)+1),i.active||(t.inactiveButNotRemoved++,t.potentialLeaks.push({id:e,eventType:i.eventType,target:s}))}return t.byTarget=Object.fromEntries(t.byTarget),t.byType=Object.fromEntries(t.byType),t}cleanup(){let t=0;for(const[e,i]of this.listeners.entries())i.active||(this.listeners.delete(e),t++);return t}destroy(){const t=this.removeAll();return this.listeners.clear(),this.groups.clear(),this.i.clear(),this.t=null,this.stats={registered:0,removed:0,active:0},t}}class s{constructor(t){this.canvas=t,this.ctx=t.getContext("2d",{alpha:!0,desynchronized:!0,willReadFrequently:!1}),this.ctx||(this.o=!0),this.dpr=window.devicePixelRatio||1,this.width=0,this.height=0,this.centerX=0,this.centerY=0,this.renderSize=null,this.resizeCallbacks=[],this.handleResize=this.handleResize.bind(this),window.addEventListener("resize",this.handleResize),this.resize()}resize(){if(!this.o){if(this.renderSize&&this.renderSize.width&&this.renderSize.height)this.width=this.renderSize.width,this.height=this.renderSize.height,this.canvas.width=this.width,this.canvas.height=this.height;else if(this.canvas.hasAttribute("width")&&this.canvas.hasAttribute("height")){const t=parseInt(this.canvas.getAttribute("width"),10),e=parseInt(this.canvas.getAttribute("height"),10),i=this.canvas.getBoundingClientRect(),s=i.width,a=i.height;t>1.5*s||e>1.5*a?(this.width=s,this.height=a,this.canvas.width=t,this.canvas.height=e,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.dpr,this.dpr)):(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e)}else{const t=this.canvas.getBoundingClientRect();this.width=t.width,this.height=t.height,this.canvas.width=this.width*this.dpr,this.canvas.height=this.height*this.dpr,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.dpr,this.dpr)}this.centerX=this.width/2,this.centerY=this.height/2,this.resizeCallbacks.forEach(t=>{try{t(this.width,this.height,this.dpr)}catch{}})}}onResize(t){"function"==typeof t&&this.resizeCallbacks.push(t)}handleResize(){clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.renderSize&&this.renderSize.width&&this.renderSize.height||this.resize()},100)}setRenderSize(t,e){this.renderSize={width:t,height:e},this.resize()}clear(){this.o||this.ctx.clearRect(0,0,this.width,this.height)}getCenter(){return{x:this.centerX,y:this.centerY}}setTransform(t=0,e=0,i=1,s=0){this.o||(this.ctx.save(),this.ctx.translate(t,e),this.ctx.rotate(s),this.ctx.scale(i,i))}restoreTransform(){this.o||this.ctx.restore()}getContext(){return this.ctx}getDimensions(){return{width:this.width,height:this.height}}destroy(){window.removeEventListener("resize",this.handleResize),clearTimeout(this.resizeTimeout),this.ctx&&(this.ctx.clearRect(0,0,this.width,this.height),this.ctx=null),this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas=null),this.resizeCallbacks=[],this.resizeTimeout=null}}function a(t){return 3===(t=t.replace("#","")).length&&(t=t.split("").map(t=>t+t).join("")),{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)}}function h(t,e,i){const s=t=>{const e=Math.round(Math.max(0,Math.min(255,t))).toString(16);return 1===e.length?`0${e}`:e};return`#${s(t)}${s(e)}${s(i)}`}function n(t,e,i){t/=255,e/=255,i/=255;const s=Math.max(t,e,i),a=Math.min(t,e,i),h=(s+a)/2;let n,r;if(s===a)n=r=0;else{const o=s-a;switch(r=h>.5?o/(2-s-a):o/(s+a),s){case t:n=(e-i)/o+(e<i?6:0);break;case e:n=(i-t)/o+2;break;case i:n=(t-e)/o+4}n/=6}return{h:360*n,s:100*r,l:100*h}}function r(t,e,i){t/=360,i/=100;const s=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t);let a,h,n;if(0==(e/=100))a=h=n=i;else{const r=i<.5?i*(1+e):i+e-i*e,o=2*i-r;a=s(o,r,t+1/3),h=s(o,r,t),n=s(o,r,t-1/3)}return{r:Math.round(255*a),g:Math.round(255*h),b:Math.round(255*n)}}function o(t,e,i){const s=a(t),o=a(e),l=n(s.r,s.g,s.b),c=n(o.r,o.g,o.b),u=l.h;let p=c.h;const d=p-u;d>180?p-=360:d<-180&&(p+=360);const f=r(((u+(p-u)*i)%360+360)%360,l.s+(c.s-l.s)*i,l.l+(c.l-l.l)*i);return h(f.r,f.g,f.b)}const l={intense:1.6,confident:1.3,nervous:1.15,clear:1,tired:.8,subdued:.5};function c(t,e){if(!e||"clear"===e)return t;const i=l[e.toLowerCase()];return i&&1!==i?function(t,e){const i=a(t),s=n(i.r,i.g,i.b);s.s=Math.max(0,Math.min(100,s.s*e));const o=r(s.h,s.s,s.l);return h(o.r,o.g,o.b)}(t,i):t}function u(t){return t}function p(t){return t*(2-t)}function d(t){return t*t}function f(t){return t<.5?2*t*t:(4-2*t)*t-1}function m(t){return 1-Math.pow(1-t,3)}function M(t){return t*t*t}function g(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function y(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin((10*t-.75)*e)+1}function b(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375}function w(t){const e=2.5949095;return t<.5?Math.pow(2*t,2)*(7.189819*t-e)/2:(Math.pow(2*t-2,2)*((e+1)*(2*t-2)+e)+2)/2}function v(t){return Math.sin(t*Math.PI/2)}function S(t){return-(Math.cos(Math.PI*t)-1)/2}function F(t,e,i,s="linear"){return e+(i-e)*("string"==typeof s?{linear:u,easeOutQuad:p,easeInQuad:d,easeInOutQuad:f,easeOutCubic:m,easeInCubic:M,easeInOutCubic:g,easeOutElastic:y,easeOutBounce:b,easeInOutBack:w,easeOutSine:v,easeInOutSine:S}[s]||u:s)(Math.max(0,Math.min(1,t)))}Object.fromEntries(Object.entries({neutral:"#B0B0B0",joy:"#FFD700",sadness:"#4169E1",anger:"#DC143C",fear:"#8B008B",surprise:"#FF8C00",disgust:"#9ACD32",love:"#FF69B4"}).map(([t,e])=>{const i=a(e);return[t,`${i.r}, ${i.g}, ${i.b}`]}));const x=new Map;var k=function(t){return x.get(t)||null},B={name:"suspicion",emoji:"๐คจ",description:"Paranoid watchfulness with surveillance scanning",visual:{glowColor:"#6B46C1",particleRate:4,minParticles:6,maxParticles:12,particleBehavior:"surveillance",particleSpeed:.2,breathRate:.6,breathDepth:.04,coreJitter:.02,blinkRate:1.1,blinkSpeed:1,particleColors:[{color:"#6B46C1",weight:30},{color:"#4A5568",weight:25},{color:"#8B4789",weight:20},{color:"#9F7AEA",weight:15},{color:"#2D3748",weight:10}],threatLevel:0,getGlowIntensity(){return.3+.7*this.threatLevel},getParticleSpeed(){return.2+.8*this.threatLevel},getGlowColor(){const t=this.threatLevel||0,e=Math.round(107+113*t),i=Math.round(70+-32*t),s=Math.round(193+-66*t),a=t=>t.toString(16).padStart(2,"0");return`#${a(e)}${a(i)}${a(s)}`}},modifiers:{speed:.4,amplitude:.6,intensity:1.2,smoothness:.3,regularity:.2,focus:1.5,addWobble:!0},typicalGestures:["scan","twitch","peek","tilt","hold"],transitions:{duration:500,easing:"linear",priority:4},special:{coreSquint:.6,scanInterval:2e3,scanDuration:1200,scanAngle:60,twitchChance:.02,peekInterval:4e3,maxThreatDistance:300,alertThreshold:.7},"3d":{rotation:{type:"suspicious",speed:1,axes:[0,0,0],musicSync:!1},glow:{color:"#6B46C1",intensity:.85,pulse:{speed:.6,range:[.7,1]}},scale:{base:1,breathe:{enabled:!0,depth:.04,rate:.6}}},soulAnimation:{driftSpeed:.9,shimmerSpeed:1.8,turbulence:.4},rhythmModifiers:{windowMultiplier:.9,visualNoise:.3,inputDelay:0,tempoShift:0}},C={name:"calm",emoji:"๐",description:"Serene, peaceful state with gentle movements",visual:{glowColor:"#66D9CC",particleRate:6,minParticles:10,maxParticles:50,particleBehavior:"ascending",breathRate:.4,breathDepth:.12,coreJitter:!1,blinkRate:.8,blinkSpeed:1,particleColors:[{color:"#66D9CC",weight:35},{color:"#99E6D9",weight:25},{color:"#40BFB3",weight:20},{color:"#B3F2E6",weight:15},{color:"#339980",weight:5}]},modifiers:{speed:.5,amplitude:.3,intensity:.4,smoothness:2,regularity:1.5,addWeight:!1,floatHeight:.2,swayAmount:.15,duration:1.5},typicalGestures:["breathe","float","drift","idle"],transitions:{duration:800,easing:"easeInOutSine",priority:1},movement:{floatPattern:"sine_slow",floatPeriod:6e3,floatAmplitude:8,swayPattern:"gentle",swayPeriod:8e3,swayAmplitude:5,microMovements:!1},getCoreParams(t){const e=t.time||Date.now(),i=.5*Math.sin(6e-4*e)+.5;return{scaleX:1-.02*i,scaleY:1-.02*i,eyeOpenness:.85,eyeExpression:"serene",pupilOffset:{x:2*Math.sin(3e-4*e),y:1*Math.cos(4e-4*e)},glowPulse:.95+.05*i}},updateParticle(t,e){t.x+=.1*Math.sin(.001*t.life),t.y-=.02*e,t.opacity=.3*Math.sin(.002*t.life)+.2,t.size=t.baseSize*(1+.2*Math.sin(.001*t.life))},renderCore:(t,e,i,s)=>!1,"3d":{rotation:{type:"gentle",speed:.5,axes:[0,.3,0],musicSync:!0},glow:{color:"#66D9CC",intensity:.6,pulse:{speed:.4,range:[.5,.7]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.4}}},soulAnimation:{driftSpeed:.3,shimmerSpeed:.4,turbulence:.1},rhythmModifiers:{windowMultiplier:1.2,visualNoise:0,inputDelay:0,tempoShift:0}};const R=new Map,T={happy:"joy",peaceful:"calm",curious:"surprise",frustrated:"anger",sad:"sadness",excitement:"excited"};function P(t){const e=T[t]||t,i=R.get(e);return i||(k(e)||null)}function O(t){const e=P(t);if(!e)return P("neutral").visual;if(!e.visual)return{};const{visual:i}=e,s={};for(const t in i)"function"!=typeof i[t]&&(s[t]=i[t]);return"function"==typeof i.getGlowIntensity&&(s.glowIntensity=i.getGlowIntensity()),"function"==typeof i.getParticleSpeed&&(s.particleSpeed=i.getParticleSpeed()),"function"==typeof i.getParticleRate&&(s.particleRate=i.getParticleRate()),"function"==typeof i.getGlowColor&&(s.glowColor=i.getGlowColor()),s}function A(t){const e=P(t);return e?e.modifiers:P("neutral").modifiers}function D(){return[...Array.from(R.keys()),...Array.from(x.keys())]}function z(t){const e=T[t]||t;return R.has(e)||null!==k(e)}function E(t,e){const i=P(t),s=P(e);return i&&s?s.transitions&&s.transitions[t]?s.transitions[t]:{duration:1e3,easing:"ease-in-out",gesture:s.transitions?.defaultGesture||null}:{duration:1e3,easing:"ease-in-out"}}function I(t){const e=P(t);return e?.rhythmModifiers??{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0}}function j(t){if(!t||0===t.length)return{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0};if(1===t.length){const e=I(t[0].emotion),i=t[0].intensity;return{windowMultiplier:1+(e.windowMultiplier-1)*i,visualNoise:e.visualNoise*i,inputDelay:e.inputDelay*i,tempoShift:e.tempoShift*i}}let e=0;for(let i=1;i<t.length;i++)t[i].intensity>t[e].intensity&&(e=i);const i={windowMultiplier:0,visualNoise:0,inputDelay:0,tempoShift:0},s=t.filter((t,i)=>i!==e),a=s.length>0?.25/s.length:0,h=I(t[e].emotion),n=t[e].intensity;i.windowMultiplier+=.75*(1+(h.windowMultiplier-1)*n),i.visualNoise+=h.visualNoise*n*.75,i.inputDelay+=h.inputDelay*n*.75,i.tempoShift+=h.tempoShift*n*.75;for(const t of s){const e=I(t.emotion),s=t.intensity;i.windowMultiplier+=(1+(e.windowMultiplier-1)*s)*a,i.visualNoise+=e.visualNoise*s*a,i.inputDelay+=e.inputDelay*s*a,i.tempoShift+=e.tempoShift*s*a}return i}[{name:"neutral",emoji:"๐",description:"Calm, balanced emotional state",visual:{glowColor:"#00BCD4",particleRate:2,minParticles:8,maxParticles:10,particleBehavior:"ambient",breathRate:1,breathDepth:.08,coreJitter:!1,blinkRate:1,blinkSpeed:1,particleColors:[{color:"#00BCD4",weight:25},{color:"#00ACC1",weight:20},{color:"#26C6DA",weight:15},{color:"#B2EBF2",weight:15},{color:"#0097A7",weight:10},{color:"#80DEEA",weight:10},{color:"#E0F7FA",weight:5}]},modifiers:{speed:1,amplitude:1,intensity:1,smoothness:1,regularity:1},typicalGestures:["breathe","float","idle","blink"],transitions:{duration:500,easing:"easeInOut",priority:0},getCoreParams:t=>({scaleX:1,scaleY:1,eyeOpenness:1,eyeExpression:"neutral",pupilOffset:{x:0,y:0}}),renderCore:(t,e,i,s)=>!1,"3d":{rotation:{type:"gentle",speed:1,axes:[0,.3,0],musicSync:!1},glow:{color:"#00BCD4",intensity:.9,pulse:{speed:1,range:[.8,1]}},scale:{base:1,breathe:{enabled:!0,depth:.08,rate:1}}},soulAnimation:{driftSpeed:.5,shimmerSpeed:.5,turbulence:.2},rhythmModifiers:{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"joy",emoji:"๐",description:"Playful happiness and celebration",visual:{glowColor:"#FFEB3B",particleRate:8,minParticles:0,maxParticles:50,particleBehavior:"popcorn",breathRate:1.5,breathDepth:.1,coreJitter:!1,blinkRate:1.3,blinkSpeed:1.1,particleColors:[{color:"#FFEB3B",weight:25},{color:"#FFC107",weight:20},{color:"#FFFF00",weight:15},{color:"#FFD700",weight:15},{color:"#FFF59D",weight:10},{color:"#FF9800",weight:10},{color:"#FFFDE7",weight:5}]},modifiers:{speed:1.8,amplitude:1.9,intensity:1.1,smoothness:1,regularity:.9,addBounce:!0},typicalGestures:["bounce","spin","wave","expand","shake","float"],transitions:{duration:400,easing:"easeOutBack",priority:5,burstOnEntry:!0},getCoreParams:t=>({scaleX:1,scaleY:1,eyeOpenness:1,eyeExpression:"happy",pupilOffset:{x:0,y:-.1},sparkle:!0}),"3d":{rotation:{type:"rhythmic",speed:1.8,axes:[0,.3,0],musicSync:!0},glow:{color:"#FFEB3B",intensity:1.6,pulse:{speed:1.5,range:[1.2,1.8]}},scale:{base:1,breathe:{enabled:!0,depth:.1,rate:1.5}}},soulAnimation:{driftSpeed:1.2,shimmerSpeed:1.5,turbulence:.3},rhythmModifiers:{windowMultiplier:1.3,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"sadness",emoji:"๐ข",description:"Deep melancholic sorrow",visual:{glowColor:"#4169E1",particleRate:6,minParticles:0,maxParticles:50,particleBehavior:"falling",breathRate:.6,breathDepth:.12,coreJitter:!1,blinkRate:.6,blinkSpeed:.8,particleColors:[{color:"#4169E1",weight:25},{color:"#1E90FF",weight:20},{color:"#6495ED",weight:15},{color:"#B0C4DE",weight:15},{color:"#191970",weight:10},{color:"#87CEEB",weight:10},{color:"#2F4F4F",weight:5}]},modifiers:{speed:.7,amplitude:.6,intensity:.8,smoothness:1.3,regularity:1.1,addGravity:!0},typicalGestures:["droop","sway","contract","drift","sink"],transitions:{duration:800,easing:"easeInOut",priority:3},"3d":{rotation:{type:"gentle",speed:.7,axes:[0,.2,0],musicSync:!1},glow:{color:"#4169E1",intensity:.65,pulse:{speed:.6,range:[.5,.8]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.6}}},soulAnimation:{driftSpeed:.2,shimmerSpeed:.3,turbulence:.1},rhythmModifiers:{windowMultiplier:1,visualNoise:0,inputDelay:45,tempoShift:0}},{name:"anger",emoji:"๐ ",description:"Intense rage and aggression",visual:{glowColor:"#DC143C",particleRate:8,minParticles:8,maxParticles:50,particleBehavior:"aggressive",breathRate:2.2,breathDepth:.15,coreJitter:!0,blinkRate:1.6,blinkSpeed:1.3,particleColors:[{color:"#DC143C",weight:25},{color:"#FF0000",weight:20},{color:"#B22222",weight:15},{color:"#FF4500",weight:15},{color:"#8B0000",weight:10},{color:"#FF6347",weight:10},{color:"#660000",weight:5}]},modifiers:{speed:1.5,amplitude:1.4,intensity:1.3,smoothness:.3,regularity:.7,addShake:!0},typicalGestures:["shake","vibrate","expand","pulse","flicker","strike"],transitions:{duration:300,easing:"easeOutExpo",priority:8,shakeOnEntry:!0},special:{screenShake:!0,particleTrails:"fire",glowPulse:!0,temperatureEffect:"hot"},"3d":{rotation:{type:"unstable",speed:1.5,axes:[0,.3,0],shake:{amplitude:.02,frequency:7},eruption:{enabled:!0,interval:3e3,speedMultiplier:3.5,duration:400},musicSync:!1},glow:{color:"#DC143C",intensity:1.8,pulse:{speed:2.2,range:[.8,2]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:2.2}}},soulAnimation:{driftSpeed:2,shimmerSpeed:.8,turbulence:.8},rhythmModifiers:{windowMultiplier:.75,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"fear",emoji:"๐จ",description:"Anxious state with fleeing particles",visual:{glowColor:"#8A2BE2",particleRate:8,minParticles:8,maxParticles:50,particleBehavior:"scattering",breathRate:2.5,breathDepth:.06,coreJitter:!0,blinkRate:1.7,blinkSpeed:1.4,particleColors:[{color:"#8A2BE2",weight:25},{color:"#4B0082",weight:20},{color:"#9400D3",weight:15},{color:"#6B46C1",weight:15},{color:"#9932CC",weight:10},{color:"#E6E6FA",weight:8},{color:"#301934",weight:7}]},modifiers:{speed:1.4,amplitude:.8,intensity:1.2,smoothness:.5,regularity:.5,addJitter:!0},typicalGestures:["shake","vibrate","contract","flicker","retreat"],transitions:{duration:400,easing:"easeOut",priority:7},"3d":{rotation:{type:"unstable",speed:1.4,axes:[0,.3,0],shake:{amplitude:.015,frequency:3.5},musicSync:!1},glow:{color:"#8A2BE2",intensity:.9,pulse:{speed:2.5,range:[.6,1.2]}},scale:{base:1,breathe:{enabled:!0,depth:.06,rate:2.5}}},soulAnimation:{driftSpeed:1.8,shimmerSpeed:2.5,turbulence:.6},rhythmModifiers:{windowMultiplier:1,visualNoise:.6,inputDelay:0,tempoShift:0}},{name:"surprise",emoji:"๐ฒ",description:"Sudden shock with explosive particles",visual:{glowColor:"#FFD700",particleRate:5,minParticles:0,maxParticles:15,particleBehavior:"burst",breathRate:.3,breathDepth:.18,coreJitter:!1,blinkRate:1.4,blinkSpeed:1.2,particleColors:[{color:"#FFD700",weight:25},{color:"#FFA500",weight:20},{color:"#FFFF00",weight:15},{color:"#FF6347",weight:15},{color:"#FFE4B5",weight:10},{color:"#FF4500",weight:10},{color:"#FFFACD",weight:5}]},modifiers:{speed:1.6,amplitude:1.5,intensity:1.4,smoothness:.7,regularity:.8,addPop:!0},typicalGestures:["expand","bounce","flash","pulse","pop"],transitions:{duration:200,easing:"easeOutBack",priority:6},"3d":{rotation:{type:"unstable",speed:1.6,axes:[0,.45,0],shake:{amplitude:.01,frequency:3},musicSync:!1},glow:{color:"#FFD700",intensity:1.8,pulse:{speed:.3,range:[1,2.2]}},scale:{base:1,breathe:{enabled:!0,depth:.18,rate:.3}}},soulAnimation:{driftSpeed:1.5,shimmerSpeed:2,turbulence:.5},rhythmModifiers:{windowMultiplier:2,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"disgust",emoji:"๐คข",description:"Revulsion with repelling particles",visual:{glowColor:"#9ACD32",particleRate:4,minParticles:5,maxParticles:12,particleBehavior:"repelling",breathRate:.7,breathDepth:.04,coreJitter:!1,blinkRate:.9,blinkSpeed:.9,particleColors:[{color:"#9ACD32",weight:25},{color:"#ADFF2F",weight:20},{color:"#7FFF00",weight:15},{color:"#BDB76B",weight:15},{color:"#6B8E23",weight:10},{color:"#CCFF00",weight:8},{color:"#556B2F",weight:7}]},modifiers:{speed:.9,amplitude:.7,intensity:.9,smoothness:.8,regularity:1,addRecoil:!0},typicalGestures:["contract","shake","recoil","wobble"],transitions:{duration:600,easing:"easeIn",priority:4},"3d":{rotation:{type:"gentle",speed:.9,axes:[0,.25,0],musicSync:!1},glow:{color:"#9ACD32",intensity:1,pulse:{speed:.7,range:[.7,1.2]}},scale:{base:1,breathe:{enabled:!0,depth:.04,rate:.7}}},soulAnimation:{driftSpeed:.4,shimmerSpeed:.6,turbulence:.35},rhythmModifiers:{windowMultiplier:.85,visualNoise:.2,inputDelay:0,tempoShift:0}},{name:"love",emoji:"๐",description:"Warm affection with orbiting particles",visual:{glowColor:"#FF1493",particleRate:6,minParticles:15,maxParticles:50,particleBehavior:"orbiting",breathRate:.75,breathDepth:.15,coreJitter:!1,blinkRate:1.2,blinkSpeed:1,particleColors:[{color:"#FF1493",weight:30},{color:"#FF69B4",weight:25},{color:"#FF007F",weight:15},{color:"#FFB6C1",weight:10},{color:"#FF45A0",weight:10},{color:"#E91E63",weight:5},{color:"#FFC0CB",weight:5}]},modifiers:{speed:.9,amplitude:1.1,intensity:1.2,smoothness:1.4,regularity:1.2,addWarmth:!0},typicalGestures:["pulse","sway","orbit","glow","breathe","float"],transitions:{duration:700,easing:"easeInOut",priority:5},"3d":{rotation:{type:"gentle",speed:.9,axes:[0,.28,0],musicSync:!0},glow:{color:"#FF1493",intensity:1.8,pulse:{speed:.75,range:[1.3,2]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:.75}}},soulAnimation:{driftSpeed:.8,shimmerSpeed:1.2,turbulence:.2},rhythmModifiers:{windowMultiplier:1.15,visualNoise:0,inputDelay:0,tempoShift:0}},B,{name:"excited",emoji:"๐คฉ",description:"High energy with rapid particles",visual:{glowColor:"#FF6B35",particleRate:8,minParticles:10,maxParticles:50,particleBehavior:"burst",breathRate:2,breathDepth:.14,coreJitter:!0,blinkRate:1.5,blinkSpeed:1.2,particleColors:[{color:"#FF6B35",weight:25},{color:"#FF1744",weight:20},{color:"#FFC107",weight:15},{color:"#FF9100",weight:15},{color:"#FFEB3B",weight:10},{color:"#FF5722",weight:10},{color:"#FFF59D",weight:5}]},modifiers:{speed:1.4,amplitude:1.3,intensity:1.3,smoothness:.8,regularity:.7,addVibration:!0},typicalGestures:["bounce","spin","vibrate","expand","shake","pulse"],transitions:{duration:300,easing:"easeOutElastic",priority:6},"3d":{rotation:{type:"unstable",speed:1.4,axes:[0,.4,0],shake:{amplitude:.01,frequency:4},musicSync:!1},glow:{color:"#FF6B35",intensity:1.5,pulse:{speed:2,range:[1,1.8]}},scale:{base:1,breathe:{enabled:!0,depth:.14,rate:2}}},soulAnimation:{driftSpeed:1.5,shimmerSpeed:2,turbulence:.5},rhythmModifiers:{windowMultiplier:1.2,visualNoise:.1,inputDelay:0,tempoShift:0}},{name:"resting",emoji:"๐ด",description:"Deep relaxation with slow drift",visual:{glowColor:"#9370DB",particleRate:1,minParticles:3,maxParticles:5,particleBehavior:"resting",breathRate:.8,breathDepth:.12,coreJitter:!1,blinkRate:.4,blinkSpeed:.7,particleColors:[{color:"#9370DB",weight:30},{color:"#A591C4",weight:20},{color:"#B366FF",weight:20},{color:"#B8A1E6",weight:15},{color:"#674D9B",weight:15}]},modifiers:{speed:.5,amplitude:.4,intensity:.5,smoothness:1.4,regularity:.9,addWeight:!0},typicalGestures:["breathe","drift","sway","float"],transitions:{duration:1e3,easing:"easeInOut",priority:2},"3d":{rotation:{type:"gentle",speed:.5,axes:[0,.15,0],musicSync:!1},glow:{color:"#9370DB",intensity:.8,pulse:{speed:.8,range:[.6,1]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.8}}},soulAnimation:{driftSpeed:.15,shimmerSpeed:.1,turbulence:.05},rhythmModifiers:{windowMultiplier:1.1,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"euphoria",emoji:"๐",description:"Radiant hope and new beginnings",visual:{glowColor:"#FFB6C1",particleRate:6,minParticles:15,maxParticles:30,particleBehavior:"radiant",breathRate:1.3,breathDepth:.25,coreJitter:!1,blinkRate:1.4,blinkSpeed:1.1,particleColors:[{color:"#FFB6C1",weight:20},{color:"#FFD700",weight:18},{color:"#87CEEB",weight:15},{color:"#DDA0DD",weight:15},{color:"#98FB98",weight:12},{color:"#FFA07A",weight:10},{color:"#E6E6FA",weight:8},{color:"#FFFFFF",weight:2}]},modifiers:{speed:1.4,amplitude:1.5,intensity:1.6,smoothness:1.3,regularity:.8,addWarmth:!0,addLift:!0},typicalGestures:["expand","radiate","pulse","glow","float","bloom"],transitions:{duration:600,easing:"easeOutExpo",priority:8},"3d":{rotation:{type:"rhythmic",speed:1.4,axes:[0,.35,0],musicSync:!0},glow:{color:"#FFB6C1",intensity:1.2,pulse:{speed:1.3,range:[.9,1.5]}},scale:{base:1,breathe:{enabled:!0,depth:.25,rate:1.3}}},soulAnimation:{driftSpeed:1.8,shimmerSpeed:2.5,turbulence:.7},rhythmModifiers:{windowMultiplier:1.5,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"focused",emoji:"๐ฏ",description:"Intense concentration with directed flow",visual:{glowColor:"#00CED1",particleRate:4,minParticles:5,maxParticles:12,particleBehavior:"directed",breathRate:1.2,breathDepth:.08,coreJitter:!0,blinkRate:.7,blinkSpeed:1,particleColors:[{color:"#00CED1",weight:30},{color:"#4A9FA0",weight:20},{color:"#00FFFF",weight:20},{color:"#5FE5E7",weight:15},{color:"#006B6D",weight:15}],eyeOpenness:.7,microAdjustments:!0},modifiers:{speed:1,amplitude:.9,intensity:1.1,smoothness:1.1,regularity:1.2,addPrecision:!0},typicalGestures:["track","lock","scan","pulse","vibrate"],transitions:{duration:400,easing:"easeIn",priority:5},getCoreParams:t=>({scaleX:1.1,scaleY:.7,eyeOpenness:.7,eyeExpression:"focused",pupilOffset:{x:0,y:0},microAdjustments:!0}),"3d":{rotation:{type:"still",speed:.5,axes:[0,.1,0],musicSync:!1},glow:{color:"#00CED1",intensity:1.2,pulse:{speed:1.2,range:[1,1.3]}},scale:{base:1,breathe:{enabled:!0,depth:.08,rate:1.2}}},soulAnimation:{driftSpeed:.6,shimmerSpeed:.2,turbulence:.1},rhythmModifiers:{windowMultiplier:.85,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"glitch",emoji:"๐",description:"Surprised sadness with rainbow colors and glitch wiggle",visual:{primaryColor:"#FF6B9D",glowColor:"#4169E1",glowIntensity:1.2,particleRate:5,minParticles:5,maxParticles:15,particleBehavior:"burst",particleSpeed:1,breathRate:.4,breathDepth:.15,coreJitter:!1,coreSize:1,eyeOpenness:.8,blinkRate:1.3,blinkSpeed:1.2,particleColors:[{color:"#FF0080",weight:18},{color:"#00FF80",weight:18},{color:"#8000FF",weight:18},{color:"#FF8000",weight:15},{color:"#0080FF",weight:15},{color:"#FFFF00",weight:10},{color:"#FF6B9D",weight:6}],particleGlitchWiggle:!0,glitchWiggleIntensity:.3,glitchWiggleFrequency:.1},modifiers:{speed:1.1,amplitude:1,intensity:1.1,smoothness:.8,regularity:.7,focus:.6},typicalGestures:["bounce","sway","pulse","drift","flash"],transitions:{duration:300,easing:"easeInOut",priority:5},"3d":{rotation:{type:"unstable",speed:1.1,axes:[0,.35,0],shake:{amplitude:.02,frequency:5},musicSync:!1},glow:{color:"#FF6B9D",intensity:1.2,pulse:{speed:.4,range:[.8,1.6]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:.4}}},rhythmModifiers:{windowMultiplier:1,visualNoise:.8,inputDelay:20,tempoShift:0}},C].forEach(t=>{t&&t.name&&R.set(t.name,t)});const $=new class{constructor(){this.emotionCache=new Map,this.visualParamsCache=new Map,this.modifiersCache=new Map,this.transitionCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1,this.loadStartTime=0,this.initialize()}initialize(){this.loadStartTime=performance.now();try{const t=D();t.forEach(t=>{this.cacheEmotion(t)}),this.cacheCommonTransitions(t),this.isInitialized=!0,this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.emotionCache.size}catch(t){this.isInitialized=!1}}cacheEmotion(t){try{const e=P(t);e&&this.emotionCache.set(t,e);const i=O(t);this.visualParamsCache.set(t,i);const s=A(t);this.modifiersCache.set(t,s)}catch(t){}}cacheCommonTransitions(t){[["neutral","joy"],["neutral","sadness"],["neutral","anger"],["joy","sadness"],["sadness","joy"],["anger","calm"],["calm","anger"]].forEach(([e,i])=>{if(t.includes(e)&&t.includes(i))try{const t=E(e,i),s=`${e}->${i}`;this.transitionCache.set(s,t)}catch(t){}})}getEmotion(t){if(!this.isInitialized)return P(t);const e=this.emotionCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,P(t))}getVisualParams(t){if(!this.isInitialized)return O(t);const e=this.visualParamsCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,O(t))}getModifiers(t){if(!this.isInitialized)return A(t);const e=this.modifiersCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,A(t))}getTransitionParams(t,e){if(!this.isInitialized)return E(t,e);const i=`${t}->${e}`,s=this.transitionCache.get(i);return s?(this.stats.hits++,s):(this.stats.misses++,E(t,e))}hasEmotion(t){return this.emotionCache.has(t)}getStats(){const t=this.stats.hits+this.stats.misses,e=t>0?(this.stats.hits/t*100).toFixed(2):0;return{isInitialized:this.isInitialized,loadTime:this.stats.loadTime,cacheSize:this.stats.cacheSize,hits:this.stats.hits,misses:this.stats.misses,hitRate:`${e}%`,emotions:this.emotionCache.size,visualParams:this.visualParamsCache.size,modifiers:this.modifiersCache.size,transitions:this.transitionCache.size}}clear(){this.emotionCache.clear(),this.visualParamsCache.clear(),this.modifiersCache.clear(),this.transitionCache.clear(),this.isInitialized=!1,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0}}reinitialize(){this.clear(),this.initialize()}};class G{constructor(t){this.errorBoundary=t,this.state={emotion:"neutral",undertone:null,intensity:1,gesture:null,speaking:!1,audioLevel:0},this.slots=[],this.maxSlots=3,this.u=null,this.p=null,this.m=0,this.M=new Set(["anger","fear","sadness","disgust","suspicion"]),this.transitions={emotional:{current:"neutral",target:null,progress:0,duration:500,startTime:0,isActive:!1},intensity:{from:1,to:1,progress:1,duration:500,startTime:0,isActive:!1},undertone:{current:null,target:null,progress:0,duration:300,startTime:0,isActive:!1,currentWeight:0,targetWeight:0}},this.interpolationCache={lastUpdate:0,cacheInterval:100,cachedProperties:null,cachedRenderState:null},this.initializeEmotionalStates(),this.initializeUndertoneModifiers()}initializeEmotionalStates(){this.emotionalStates=this.loadEmotionalStatesFromCache()}loadEmotionalStatesFromCache(){const t={};return["neutral","joy","sadness","anger","fear","surprise","disgust","love","suspicion","excited","resting","euphoria","focused","glitch","calm"].forEach(e=>{const i=$.getVisualParams(e);i&&(t[e]={primaryColor:i.primaryColor||"#B0B0B0",glowIntensity:i.glowIntensity||.7,particleRate:i.particleRate||1,minParticles:i.minParticles||3,maxParticles:i.maxParticles||4,particleBehavior:i.particleBehavior||"ambient",coreSize:i.coreSize||1,breathRate:i.breathRate||1,breathDepth:i.breathDepth||.1})}),t}initializeUndertoneModifiers(){this.undertoneModifiers={nervous:{jitterAmount:.3,breathRateMultiplier:1.2,glowIntensityMultiplier:.9,particleRateMultiplier:1.1},confident:{coreSizeMultiplier:1.1,glowIntensityMultiplier:1.2,breathRateMultiplier:.9,particleRateMultiplier:1},tired:{breathRateMultiplier:.7,particleRateMultiplier:.5,glowIntensityMultiplier:.8,coreSizeMultiplier:.95},intense:{amplificationFactor:1.3},subdued:{dampeningFactor:.7}}}setEmotion(t,e=null,i=500){return this.errorBoundary.wrap(()=>{let s=null,a=1;if("string"==typeof e?s=e:e&&"object"==typeof e&&(s=e.undertone??null,i=e.duration??i,a=e.intensity??1),this.interpolationCache.cachedProperties=null,this.interpolationCache.cachedRenderState=null,!z(t)&&!{}.hasOwnProperty.call(this.emotionalStates,t)){const e=[...Object.keys(this.emotionalStates),...D()],i=[...new Set(e)];throw new Error(`Invalid emotion: ${t}. Valid emotions: ${i.join(", ")}`)}if(null!==s&&!{}.hasOwnProperty.call(this.undertoneModifiers,s))throw new Error(`Invalid undertone: ${s}. Valid undertones: ${Object.keys(this.undertoneModifiers).join(", ")}`);return a=Math.max(0,Math.min(1,a)),this.slots=[{emotion:t,intensity:a}],this.p=t,this.state.emotion===t&&this.state.undertone===s&&this.state.intensity===a||(this.state.emotion!==t&&(i>0?(this.transitions.emotional={current:this.state.emotion,target:t,progress:0,duration:Math.max(100,i),startTime:performance.now(),isActive:!0},void 0!==this.v&&(this.v=0)):this.transitions.emotional={current:t,target:null,progress:1,duration:0,startTime:performance.now(),isActive:!1},this.state.emotion=t),this.state.intensity!==a&&(this.transitions.intensity={from:this.state.intensity,to:a,progress:0,duration:Math.max(100,i),startTime:performance.now(),isActive:!0},this.state.intensity=a),this.state.undertone!==s&&(this.transitions.undertone={current:this.state.undertone,target:s,progress:0,duration:300,startTime:performance.now(),isActive:!0,currentWeight:this.state.undertone?1:0,targetWeight:s?1:0},this.state.undertone=s)),!0},"emotion-setting",!1)()}setEventCallback(t){this.u=t}S(t,e){this.u&&this.u(t,e)}F(){const t=this.getDominant(),e=t?t.emotion:null,i=this.p;e!==i&&(this.p=e,this.S("dominantChanged",{previous:i,current:e,intensity:t?t.intensity:0}))}setEmotionDampening(t){this.m=Math.max(0,Math.min(1,t))}getEmotionDampening(){return this.m}setNegativeEmotions(t){this.M=new Set(t)}pushEmotion(t,e=.5){return this.errorBoundary.wrap(()=>{if(!z(t)&&!{}.hasOwnProperty.call(this.emotionalStates,t))return!1;e=Math.max(0,Math.min(1,e)),this.interpolationCache.cachedProperties=null;const i=this.slots.find(e=>e.emotion===t);if(i){const s=i.intensity;i.intensity=Math.min(1,i.intensity+e),this.S("slotChanged",{emotion:t,intensity:i.intensity,action:"push"}),i.intensity>=1&&s<1&&this.S("emotionPeaked",{emotion:t,intensity:i.intensity})}else if(this.slots.length<this.maxSlots)this.slots.push({emotion:t,intensity:e}),this.S("slotChanged",{emotion:t,intensity:e,action:"push"}),e>=1&&this.S("emotionPeaked",{emotion:t,intensity:e});else{let i=0;for(let t=1;t<this.slots.length;t++)this.slots[t].intensity<this.slots[i].intensity&&(i=t);const s=this.slots[i];this.S("slotChanged",{emotion:s.emotion,intensity:0,action:"replaced"}),this.slots[i]={emotion:t,intensity:e},this.S("slotChanged",{emotion:t,intensity:e,action:"push"})}return this.k(),this.F(),!0},"push-emotion",!1)()}nudgeEmotion(t,e,i=1){e>0&&this.m>0&&this.M.has(t)&&(e*=1-this.m),this.interpolationCache.cachedProperties=null;const s=this.slots.find(e=>e.emotion===t);if(s){const a=s.intensity;s.intensity=Math.max(0,Math.min(i,s.intensity+e)),s.intensity<=0?(this.slots=this.slots.filter(t=>t!==s),this.S("slotChanged",{emotion:t,intensity:0,action:"removed"})):(this.S("slotChanged",{emotion:t,intensity:s.intensity,action:"nudge"}),s.intensity>=i&&a<i&&this.S("emotionPeaked",{emotion:t,intensity:s.intensity}))}else if(e>0)return void this.pushEmotion(t,Math.min(i,e));this.k(),this.F()}clearEmotions(){const t=this.slots.length>0;this.slots=[],this.interpolationCache.cachedProperties=null,this.state.emotion="neutral",this.state.intensity=1,t&&(this.S("slotChanged",{emotion:null,intensity:0,action:"cleared"}),this.p=null,this.S("dominantChanged",{previous:this.p,current:null,intensity:0}))}getSlots(){return this.slots}pruneEmptySlots(){const t=this.slots.length,e=this.slots.filter(t=>t.intensity<=0);if(this.slots=this.slots.filter(t=>t.intensity>0),this.slots.length!==t){this.interpolationCache.cachedProperties=null;for(const t of e)this.S("emotionDecayed",{emotion:t.emotion,intensity:0,removed:!0});this.k(),this.F()}}getDominant(){return this.slots.length?this.slots.reduce((t,e)=>e.intensity>t.intensity?e:t):null}getUndercurrents(){const t=this.getDominant();return t?this.slots.filter(e=>e!==t):[]}getEmotionalState(){const t=this.getDominant();return{dominant:t?{...t}:null,undercurrents:this.getUndercurrents().map(t=>({...t})),slots:this.slots.map(t=>({...t}))}}getCurrentRhythmModifiers(){return this.slots.length>0?j(this.slots):j([{emotion:this.state.emotion,intensity:this.state.intensity}])}k(){const t=this.getDominant();t?(this.state.emotion!==t.emotion&&(this.transitions.emotional={current:this.state.emotion,target:t.emotion,progress:0,duration:300,startTime:performance.now(),isActive:!0},this.state.emotion=t.emotion),this.state.intensity=t.intensity):(this.state.emotion="neutral",this.state.intensity=1)}applyUndertone(t,e){if(!e||!{}.hasOwnProperty.call(this.undertoneModifiers,e))return{...t};const i=this.undertoneModifiers[e],s={...t};if(void 0!==i.glowIntensityMultiplier&&(s.glowIntensity*=i.glowIntensityMultiplier),void 0!==i.breathRateMultiplier&&(s.breathRate*=i.breathRateMultiplier),void 0!==i.particleRateMultiplier&&(s.particleRate=Math.round(s.particleRate*i.particleRateMultiplier)),void 0!==i.coreSizeMultiplier&&(s.coreSize*=i.coreSizeMultiplier),void 0!==i.amplificationFactor){const t=i.amplificationFactor;s.glowIntensity*=t,s.breathRate*=t,s.particleRate=Math.round(s.particleRate*t),s.coreSize*=t}if(void 0!==i.dampeningFactor){const t=i.dampeningFactor;s.glowIntensity*=t,s.breathRate*=t,s.particleRate=Math.round(s.particleRate*t),s.coreSize*=t}return void 0!==i.jitterAmount&&(s.jitterAmount=i.jitterAmount),s}update(t){this.errorBoundary.wrap(()=>{this.transitions.emotional.isActive&&this.updateEmotionalTransition(t),this.transitions.intensity.isActive&&this.updateIntensityTransition(t),this.transitions.undertone.isActive&&this.updateUndertoneTransition(t)},"state-machine-update")()}updateUndertoneTransition(t){const e=this.transitions.undertone,i=performance.now()-e.startTime,s=Math.min(i/e.duration,1),a=g(s);e.current&&e.target?(e.currentWeight=1-a,e.targetWeight=a):e.current&&!e.target?(e.currentWeight=1-a,e.targetWeight=0):!e.current&&e.target&&(e.currentWeight=0,e.targetWeight=a),e.progress=s,s>=1&&(e.isActive=!1,e.current=e.target,e.currentWeight=e.target?1:0,e.targetWeight=0)}updateIntensityTransition(t){const e=this.transitions.intensity,i=performance.now()-e.startTime;e.progress=Math.min(1,i/e.duration),e.progress>=1&&(e.isActive=!1,e.from=e.to,e.progress=1)}getEffectiveIntensity(){const t=this.transitions.intensity;if(!t.isActive)return this.state.intensity;const e=g(t.progress);return t.from+(t.to-t.from)*e}updateEmotionalTransition(t){const e=this.transitions.emotional;let i;void 0!==this.v?(this.v+=t,i=this.v):i=performance.now()-e.startTime,e.progress=Math.min(1,i/e.duration),e.progress>=1&&(e.isActive=!1,e.current=e.target,e.target=null,e.progress=1)}getCurrentEmotionalProperties(){return this.errorBoundary.wrap(()=>{const t=performance.now();if(this.interpolationCache.cachedProperties&&t-this.interpolationCache.lastUpdate<this.interpolationCache.cacheInterval)return this.interpolationCache.cachedProperties;let e;if(this.slots.length>1)e=this.B();else{const t=this.transitions.emotional;e=t.isActive&&t.target?this.interpolateEmotionalProperties(t.current,t.target,t.progress):{...this.emotionalStates[this.state.emotion]||this.emotionalStates.neutral};const i=this.getEffectiveIntensity();i<1&&(e.glowIntensity=this.C(.7,e.glowIntensity,i),e.particleRate=Math.round(this.C(1,e.particleRate,i)),e.breathRate=this.C(1,e.breathRate,i),e.breathDepth=e.breathDepth*i,e.coreSize=this.C(1,e.coreSize,i))}return e=this.applyUndertone(e,this.state.undertone),this.interpolationCache.cachedProperties=e,this.interpolationCache.lastUpdate=t,e},"emotional-properties",()=>this.emotionalStates.neutral)()}B(){const t=this.getDominant(),e=this.getUndercurrents(),i=this.emotionalStates[t.emotion]||this.emotionalStates.neutral,s={...i},a=t.intensity;s.glowIntensity=.75*this.C(.7,i.glowIntensity,a),s.particleRate=i.particleRate*a*.75,s.breathRate=.75*this.C(1,i.breathRate,a),s.breathDepth=i.breathDepth*a*.75,s.coreSize=.75*this.C(1,i.coreSize,a);const h=e.length>0?.25/e.length:0;for(const t of e){const e=this.emotionalStates[t.emotion]||this.emotionalStates.neutral,i=t.intensity;s.glowIntensity+=this.C(.7,e.glowIntensity,i)*h,s.particleRate+=e.particleRate*i*h,s.breathRate+=this.C(1,e.breathRate,i)*h,s.breathDepth+=e.breathDepth*i*h,s.coreSize+=this.C(1,e.coreSize,i)*h}if(s.particleRate=Math.round(s.particleRate),e.length>0){const t=this.slots.reduce((t,e)=>t+e.intensity,0);let a=i.primaryColor;for(const i of e){const e=this.emotionalStates[i.emotion]||this.emotionalStates.neutral,s=i.intensity/t;a=o(a,e.primaryColor,s)}s.primaryColor=a}return s.particleBehavior=i.particleBehavior,s}C(t,e,i){return t+(e-t)*i}interpolateEmotionalProperties(t,e,i){const s=this.emotionalStates[t]||this.emotionalStates.neutral,a=this.emotionalStates[e]||this.emotionalStates.neutral,h=F(i,0,1,"easeOutCubic");return{primaryColor:o(s.primaryColor,a.primaryColor,h),glowIntensity:s.glowIntensity+(a.glowIntensity-s.glowIntensity)*h,particleRate:Math.round(s.particleRate+(a.particleRate-s.particleRate)*h),coreSize:s.coreSize+(a.coreSize-s.coreSize)*h,breathRate:s.breathRate+(a.breathRate-s.breathRate)*h,breathDepth:s.breathDepth+(a.breathDepth-s.breathDepth)*h,particleBehavior:h>.5?a.particleBehavior:s.particleBehavior}}getCurrentState(){return{emotion:this.state.emotion,undertone:this.state.undertone,intensity:this.state.intensity,isTransitioning:this.transitions.emotional.isActive,transitionProgress:this.transitions.emotional.progress,properties:this.getCurrentEmotionalProperties()}}applyUndertoneModifier(t){return this.errorBoundary.wrap(()=>{if(null!==t&&!{}.hasOwnProperty.call(this.undertoneModifiers,t))throw new Error(`Invalid undertone: ${t}. Valid undertones: ${Object.keys(this.undertoneModifiers).join(", ")}`);return this.state.undertone=t,!0},"undertone-application",!1)()}clearUndertone(){this.state.undertone=null}getUndertoneModifier(t){return this.errorBoundary.wrap(()=>{if(this.renderer&&this.renderer.undertoneModifiers&&this.renderer.undertoneModifiers[t])return{...this.renderer.undertoneModifiers[t]};if(!t||!{}.hasOwnProperty.call(this.undertoneModifiers,t))return null;const e={...this.undertoneModifiers[t]};return e.glowRadiusMult||(e.glowRadiusMult=1),e},"undertone-retrieval",null)()}getWeightedUndertoneModifiers(){const t=this.transitions.undertone;if(!t.isActive){if(this.state.undertone){const t=this.getUndertoneModifier(this.state.undertone);if(t)return{...t,weight:1,type:this.state.undertone}}return null}if(t.target){const e=this.getUndertoneModifier(t.target);if(e)return{...e,weight:t.targetWeight,type:t.target}}if(t.current&&t.currentWeight>0){const e=this.getUndertoneModifier(t.current);if(e)return{...e,weight:t.currentWeight,type:t.current}}return null}reset(t=500){this.slots=[],this.setEmotion("neutral",null,t)}isValidEmotion(t){return{}.hasOwnProperty.call(this.emotionalStates,t)}isValidUndertone(t){return null===t||{}.hasOwnProperty.call(this.undertoneModifiers,t)}getAvailableEmotions(){return Object.keys(this.emotionalStates)}getAvailableUndertones(){return Object.keys(this.undertoneModifiers)}isTransitioning(){return this.transitions.emotional.isActive}getTransitionProgress(){return this.transitions.emotional.isActive?this.transitions.emotional.progress:1}completeTransition(){this.transitions.emotional.isActive&&(this.transitions.emotional.progress=1,this.transitions.emotional.isActive=!1,this.transitions.emotional.current=this.transitions.emotional.target,this.transitions.emotional.target=null)}interpolateProperty(t,e,i,s="easeOutCubic"){return t+(e-t)*F(i,0,1,s)}serialize(){return{version:1,emotion:this.state.emotion,undertone:this.state.undertone,intensity:this.state.intensity,slots:this.slots.map(t=>({...t})),dampening:this.m,negativeEmotions:[...this.M]}}deserialize(t){t&&1===t.version&&(this.slots=(t.slots||[]).map(t=>({emotion:t.emotion,intensity:t.intensity})),this.m=t.dampening??0,t.negativeEmotions&&(this.M=new Set(t.negativeEmotions)),this.state.emotion=t.emotion||"neutral",this.state.undertone=t.undertone||null,this.state.intensity=t.intensity??1,this.p=t.emotion||null,this.transitions.emotional.isActive=!1,this.transitions.intensity.isActive=!1,this.transitions.undertone.isActive=!1,this.interpolationCache.cachedProperties=null)}enableSimulatedTime(t=!0){t?this.v=0:delete this.v}}const q=16.67,X=3e4,Y=new class{constructor(){this.enabled=!1}registerConfig(){}getConfig(){return null}initialize(){}update(){}destroy(){}};function H(t){if(!t||0===t.length)return"#FFFFFF";let e=0,i=0;const s=[];for(const a of t)"string"==typeof a?(s.push({color:a,weight:null}),i++):a&&"object"==typeof a&&a.color&&(s.push({color:a.color,weight:a.weight||null}),a.weight?e+=a.weight:i++);const a=Math.max(0,100-e),h=i>0?a/i:0,n=[];let r=0;for(const t of s)r+=null!==t.weight?t.weight:h,n.push({color:t.color,threshold:r});const o=Math.random()*r;for(const t of n)if(o<=t.threshold)return t.color;return s[s.length-1].color}var _={name:"ambient",emoji:"โ๏ธ",description:"Gentle upward drift like smoke",initialize:function(t){t.vx=0,t.vy=-.04-.02*Math.random(),t.lifeDecay=.002,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={upwardSpeed:5e-4,waviness:0,friction:.998}},update:function(t,e,i,s){const a=t.behaviorData;t.vy*=Math.pow(a.friction,e),t.vy-=a.upwardSpeed*e,t.vx=0}};const L=2*Math.PI;var W={name:"orbiting",emoji:"๐",description:"Romantic firefly dance around the orb",initialize:function(t){t.lifeDecay=.001+.002*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.isSparkle="#FFE4E1"===t.color||"#FFCCCB"===t.color||"#FFC0CB"===t.color;const e=40*(t.scaleFactor||1)*(1.3+.9*Math.random());t.blinkPhase=Math.random()*L,t.blinkSpeed=.3+1.2*Math.random(),t.blinkIntensity=.6+.4*Math.random(),t.fadePhase=Math.random()*L,t.fadeSpeed=.1+.3*Math.random(),t.minOpacity=.2+.2*Math.random(),t.maxOpacity=.8+.2*Math.random(),t.isSparkle&&(t.blinkSpeed*=2,t.blinkIntensity=1,t.minOpacity=0,t.maxOpacity=1),t.behaviorData={angle:Math.random()*L,radius:e,baseRadius:e,angularVelocity:8e-4+.0017*Math.random(),swayAmount:3+7*Math.random(),swaySpeed:.2+.5*Math.random(),floatOffset:Math.random()*L,floatSpeed:.3+.7*Math.random(),floatAmount:2+6*Math.random(),twinklePhase:Math.random()*L,twinkleSpeed:2+3*Math.random()}},update:function(t,e,i,s){const a=t.behaviorData;a.angle+=a.angularVelocity*e;const h=Math.sin(a.angle*a.swaySpeed)*a.swayAmount,n=6*Math.sin(1.5*a.angle),r=(a.radius||a.baseRadius)+n+.2*h,o=i+Math.cos(a.angle)*r,l=s+Math.sin(a.angle)*r;a.floatOffset+=a.floatSpeed*e*.001;const c=Math.sin(a.floatOffset)*a.floatAmount;t.vx=.1*(o-t.x),t.vy=.1*(l+c-t.y),t.fadePhase+=t.fadeSpeed*e*.001;const u=.5*Math.sin(t.fadePhase)+.5,p=t.minOpacity+(t.maxOpacity-t.minOpacity)*u;let d;t.blinkPhase+=t.blinkSpeed*e*.002,t.isSparkle?(a.twinklePhase+=a.twinkleSpeed*e*.001,d=.7*Math.pow(Math.sin(a.twinklePhase),16)+.2*Math.sin(5*t.blinkPhase)+.1):d=.4*Math.sin(t.blinkPhase)+.3*Math.sin(3*t.blinkPhase)+.2*Math.sin(7*t.blinkPhase)+.1*Math.sin(11*t.blinkPhase);const f=.5*(d+1),m=.2+f*t.blinkIntensity*.8;t.opacity=t.baseOpacity*p*m,t.isSparkle?t.size=t.baseSize*(.5+1*f):t.size=t.baseSize*(.8+.3*f),t.isSparkle&&(t.tempColor=f>.85?"#FFFFFF":t.color)}},U={name:"rising",emoji:"๐",description:"Buoyant upward movement like balloons",initialize:function(t){t.vx=.02*(Math.random()-.5),t.vy=-.05-.03*Math.random(),t.lifeDecay=.002,t.baseOpacity=.7+.3*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={buoyancy:.001,driftAmount:.005}},update:function(t,e,i,s){const a=t.behaviorData;t.vy-=a.buoyancy*e,t.vx+=(Math.random()-.5)*a.driftAmount*e,t.vx*=Math.pow(.995,e),t.vy*=Math.pow(.998,e)}};function V(t){t.fallingData||(t.fallingData={originalX:t.x,originalY:t.y,originalOpacity:t.opacity??t.life??1,wobblePhase:Math.random()*Math.PI*2,wobbleSpeed:.3+.4*Math.random(),fallProgress:0}),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors));const e=Math.random(),i=Math.random(),s=e*Math.PI*2,a=2*i-1,h=Math.sqrt(1-a*a);t.behaviorData={fallSpeed:8,fallDistance:400,wobbleAmount:1.5,fallingDir:{x:h*Math.cos(s),y:a,z:h*Math.sin(s)},orbitDistanceRatio:.7+.4*Math.random()}}var N={name:"falling",emoji:"๐ง",description:"Heavy downward drift like tears",initialize:V,update:function(t,e,i,s){const a=t.behaviorData;let h=t.fallingData;h||(V(t),h=t.fallingData),h.fallProgress+=.02*e;const n=Math.min(h.fallProgress,1),r=a.fallDistance*n;h.wobblePhase+=h.wobbleSpeed*e*.1;const o=Math.sin(h.wobblePhase)*a.wobbleAmount;if(t.x=h.originalX+o,t.y=h.originalY+r,t.vx=.3*o,t.vy=10*a.fallSpeed,n>.6){const e=(n-.6)/.4;t.opacity=h.originalOpacity*(1-e),void 0!==t.life&&(t.life=h.originalOpacity*(1-e))}}};var Q={name:"popcorn",emoji:"๐ฟ",description:"Spontaneous popping with gravity and bounces",initialize:function(t){if(t.vx=.1*(Math.random()-.5),t.vy=.1*(Math.random()-.5),t.lifeDecay=.008+.012*Math.random(),t.emotionColors&&t.emotionColors.length>0)t.color=H(t.emotionColors);else{const e=["#FFFFFF","#FFFACD","#FFF8DC","#FFFFE0","#FAFAD2"];t.color=H(e)}t.size=Math.random()<.3?(8+4*Math.random())*t.scaleFactor*t.particleSizeMultiplier:(2+4*Math.random())*t.scaleFactor*t.particleSizeMultiplier,t.baseSize=t.size,t.hasGlow=Math.random()<.2,t.glowSizeMultiplier=t.hasGlow?1.2:0,t.behaviorData={popDelay:2e3*Math.random(),hasPopped:!1,popStrength:3+5*Math.random(),gravity:.098,bounceDamping:.7,bounceCount:0,maxBounces:2+Math.floor(2*Math.random()),spinRate:10*(Math.random()-.5),lifetime:0}},update:function(t,e,i,s){const a=t.behaviorData;if(a.lifetime+=16.67*e,!a.hasPopped&&a.lifetime>a.popDelay){a.hasPopped=!0;const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*a.popStrength*1.5,t.vy=Math.sin(e)*a.popStrength-.3,t.size=1.25*t.baseSize}if(a.hasPopped){t.vy+=a.gravity*e;const i=s+100*t.scaleFactor;t.y>i&&a.bounceCount<a.maxBounces&&(t.y=i,t.vy=-Math.abs(t.vy)*a.bounceDamping,t.vx*=.9,a.bounceCount++,t.size=t.baseSize*(1.5-.1*a.bounceCount)),a.bounceCount>=a.maxBounces&&(t.lifeDecay=.03+.02*Math.random(),t.size*=.95),Math.sqrt(t.vx*t.vx+t.vy*t.vy)<.5&&(t.lifeDecay*=1.5)}}},J={name:"burst",emoji:"๐ฅ",description:"Explosive expansion from center",initialize:function(t){const e="suspicion"===t.emotion,i="surprise"===t.emotion,s="glitch"===t.emotion,a=Math.random()*L,h=e?1+.8*Math.random():i?7+5*Math.random():s?2+1.5*Math.random():3.5+2.5*Math.random();t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h,t.lifeDecay=e?.01:i?.006+.008*Math.random():s?.012:.015,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),e&&(t.size=(6+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.opacity=1,t.baseOpacity=t.opacity),t.behaviorData={isSuspicion:e,isSurprise:i,isGlitch:s,age:0,fadeStart:e?.3:.2,glitchPhase:Math.random()*Math.PI*2,glitchIntensity:s?.3:0,glitchFrequency:s?.1:0}},update:function(t,e,i,s){const a=t.behaviorData;if(a.isSurprise)if(a.age+=.016*e,a.age<.15){const i=.98;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}else if(a.age<.25){const i=.85;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}else{const i=.99;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e),t.vx+=.01*(Math.random()-.5)*e,t.vy+=.01*(Math.random()-.5)*e}else{const i=a.isSuspicion?.99:a.isGlitch?.97:.95;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}if(a.isSuspicion){const i=.001*Date.now();t.vx+=.01*Math.sin(2*i+t.id)*e}if(a.isGlitch){a.age+=.016*e,a.glitchPhase+=a.glitchFrequency*e;const i=Math.sin(a.glitchPhase)*a.glitchIntensity*e,s=Math.cos(1.3*a.glitchPhase)*a.glitchIntensity*e;if(t.vx+=i,t.vy+=s,Math.random()<.02){const e=Math.random()*Math.PI*2,i=.5+.5*Math.random();t.vx+=Math.cos(e)*i,t.vy+=Math.sin(e)*i}}}},Z={name:"aggressive",emoji:"โก",description:"Sharp, chaotic movement with violent bursts",initialize:function(t){const e=Math.random()*L,i=1.5+2*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.015,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={acceleration:.05,jitter:.3,speedDecay:.95}},update:function(t,e,i,s){const a=t.behaviorData;if(t.vx+=(Math.random()-.5)*a.jitter*e,t.vy+=(Math.random()-.5)*a.jitter*e,t.vx*=Math.pow(a.speedDecay,e),t.vy*=Math.pow(a.speedDecay,e),Math.random()<Math.min(.05*e,.5)){const e=Math.random()*L;t.vx+=Math.cos(e)*a.acceleration,t.vy+=Math.sin(e)*a.acceleration}}},K={name:"scattering",emoji:"๐จ",description:"Particles flee from center in panic",initialize:function(t){t.vx=0,t.vy=0,t.lifeDecay=.008,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={fleeSpeed:2,panicFactor:1.2,initialized:!1}},update:function(t,e,i,s){const a=t.behaviorData;if(!a.initialized){const e=t.x-i,h=t.y-s,n=Math.sqrt(e*e+h*h);if(n>0)t.vx=e/n*a.fleeSpeed,t.vy=h/n*a.fleeSpeed;else{const e=Math.random()*L;t.vx=Math.cos(e)*a.fleeSpeed,t.vy=Math.sin(e)*a.fleeSpeed}a.initialized=!0}const h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);r>0&&(t.vx+=h/r*a.panicFactor*.01*e,t.vy+=n/r*a.panicFactor*.01*e),t.vx+=.1*(Math.random()-.5)*e,t.vy+=.1*(Math.random()-.5)*e,t.vx*=Math.pow(.98,e),t.vy*=Math.pow(.98,e)}},tt={name:"repelling",emoji:"๐ซ",description:"Particles pushed away from center, maintaining distance",initialize:function(t){t.vx=0,t.vy=0,t.lifeDecay=.01,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={repelStrength:.8,minDistance:50,initialized:!1}},update:function(t,e,i,s){const a=t.behaviorData,h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(!a.initialized||r<a.minDistance){if(r>0){const i=a.repelStrength/Math.max(r,5);t.vx+=h/r*i*e,t.vy+=n/r*i*e}a.initialized=!0}t.vx*=Math.pow(.99,e),t.vy*=Math.pow(.99,e)}},et={name:"connecting",emoji:"๐",description:"Chaotic movement with center attraction for social states",initialize:function(t){const e=Math.random()*L,i=2+5*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.012,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={attractionForce:.008,chaosFactor:1,friction:.95}},update:function(t,e,i,s){const a=t.behaviorData;t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e);const h=(i-t.x)*a.attractionForce,n=(s-t.y)*a.attractionForce,r=(Math.random()-.5)*a.chaosFactor,o=(Math.random()-.5)*a.chaosFactor;t.vx+=h+r,t.vy+=n+o}},it={name:"resting",emoji:"๐ด",description:"Ultra-slow vertical drift for deep rest states",initialize:function(t){t.vx=0,t.vy=-.01,t.lifeDecay=.001,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={upwardSpeed:2e-5,friction:.999}},update:function(t,e,i,s){const a=t.behaviorData;t.vy*=Math.pow(a.friction,e),t.vy-=a.upwardSpeed*e,t.vx=0}},st={name:"radiant",emoji:"โ๏ธ",description:"Particles radiate outward like sunbeams",initialize:function(t){const e=Math.random()*L,i=.8+.4*Math.random();if(t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.006,t.emotionColors&&t.emotionColors.length>0)t.color=H(t.emotionColors);else{const e=["#FFD700","#FFB347","#FFA500","#FF69B4"];t.color=H(e)}t.hasGlow=Math.random()<.7,t.glowSizeMultiplier=t.hasGlow?1.5+.5*Math.random():0,t.behaviorData={radialSpeed:.02,shimmer:Math.random()*L,shimmerSpeed:.1,friction:.99}},update:function(t,e,i,s){const a=t.behaviorData,h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(r>0){const i=h/r,s=n/r;t.vx+=i*a.radialSpeed*e,t.vy+=s*a.radialSpeed*e}a.shimmer+=a.shimmerSpeed*e;const o=Math.sin(a.shimmer);t.size=t.baseSize*(1+.2*o),t.opacity=t.baseOpacity*(1+.3*o),t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e)}};function at(t){t.vx=.02*(Math.random()-.5),t.vy=-.03-.02*Math.random(),t.lifeDecay=8e-4,t.size=(6+6*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1)*1.33,t.baseSize=t.size,t.baseOpacity=.2+.2*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={ascensionSpeed:3e-4,waveFactor:.5,waveFrequency:.001,friction:.998,fadeStartDistance:100}}var ht={name:"ascending",emoji:"๐ง",description:"Slow steady upward float like incense smoke",initialize:at,update:function(t,e,i,s){const a=t.behaviorData;if(!a)return void at(t);t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e),t.vy-=a.ascensionSpeed*e;const h=Math.sin(t.age*a.waveFrequency*1e3)*a.waveFactor;t.vx+=.001*h*e,void 0===t.initialY&&(t.initialY=t.y);const n=t.initialY-t.y;if(n>a.fadeStartDistance){const e=(n-a.fadeStartDistance)/100,i=Math.max(0,1-e);t.baseOpacity*=.995,i<.5&&(t.lifeDecay*=1.02)}Math.abs(t.vx)>.05&&(t.vx*=Math.pow(.95,e)),t.vy<-.1&&(t.vy=-.1)}},nt={name:"erratic",emoji:"๐ฐ",description:"Nervous jittery movement for anxious states",initialize:function(t){const e=Math.random()*L,i=.1+.15*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.004,t.size=(2+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.baseOpacity=.4+.3*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={jitterStrength:.02,directionChangeRate:.1,speedVariation:.3,spinRate:.05+.1*Math.random()}},update:function(t,e){const i=t.behaviorData;if(t.vx+=(Math.random()-.5)*i.jitterStrength*e,t.vy+=(Math.random()-.5)*i.jitterStrength*e,Math.random()<Math.min(i.directionChangeRate*e,.5)){const e=Math.random()*L,i=Math.sqrt(t.vx*t.vx+t.vy*t.vy);t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i}const s=1+(Math.random()-.5)*i.speedVariation*e;t.vx*=s,t.vy*=s;const a=t.age*i.spinRate*1e3;t.size=t.baseSize*(1+.2*Math.sin(a)),t.opacity=t.baseOpacity*(.8+.4*Math.random()),t.vx*=Math.pow(.98,e),t.vy*=Math.pow(.98,e);const h=Math.sqrt(t.vx*t.vx+t.vy*t.vy);h>.5&&(t.vx=t.vx/h*.5,t.vy=t.vy/h*.5)}},rt={name:"cautious",emoji:"๐คจ",description:"Slow careful movement with watchful pauses",initialize:function(t){const e=Math.random()*L,i=.02+.03*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.001,t.life=1,t.size=(4+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.baseOpacity=.8+.2*Math.random(),t.opacity=t.baseOpacity,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={pauseTimer:2*Math.random(),pauseDuration:.5+.5*Math.random(),moveDuration:1+.5*Math.random(),isMoving:Math.random()>.5,moveTimer:0,originalVx:t.vx,originalVy:t.vy,watchRadius:50+30*Math.random()}},update:function(t,e,i,s){const a=t.behaviorData;if(a.moveTimer+=e,a.isMoving)a.moveTimer>a.moveDuration?(a.isMoving=!1,a.moveTimer=0,t.vx=0,t.vy=0):(t.vx=a.originalVx,t.vy=a.originalVy);else if(a.moveTimer>a.pauseDuration){a.isMoving=!0,a.moveTimer=0;const e=Math.random()*L,i=.02+.03*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,a.originalVx=t.vx,a.originalVy=t.vy}const h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(r>a.watchRadius){const i=.02;t.vx-=h/r*i*e,t.vy-=n/r*i*e}t.vx*=Math.pow(.995,e),t.vy*=Math.pow(.995,e),a.isMoving?t.opacity=t.baseOpacity:t.opacity=t.baseOpacity*(.9+.1*Math.sin(5*t.age))}},ot={name:"surveillance",emoji:"๐๏ธ",description:"Searchlight scanning with paranoid watchfulness",initialize(t,e){t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorState={scanAngle:Math.random()*Math.PI-Math.PI/2,scanDirection:Math.random()<.5?1:-1,scanSpeed:.3+.2*Math.random(),scanRange:Math.PI/3+Math.random()*Math.PI/4,scanCenter:Math.random()*Math.PI*2,pauseTimer:0,pauseDuration:500+500*Math.random(),mode:"scanning",modeTimer:0,nextModeChange:2e3+3e3*Math.random(),dartTarget:{x:0,y:0},dartSpeed:0,patrolRadius:150+100*Math.random(),patrolAngle:Math.random()*Math.PI*2,alertLevel:0,lastPosition:{x:t.x,y:t.y}};const i=Math.random();i<.7?t.behaviorState.primaryRole="scanner":i<.9?(t.behaviorState.primaryRole="patroller",t.behaviorState.mode="patrolling"):(t.behaviorState.primaryRole="watcher",t.behaviorState.mode="frozen")},update(t,e,i){const s=t.behaviorState;if(s){switch(s.modeTimer+=16*e,s.modeTimer>s.nextModeChange&&(this.changeMode(t,s,i),s.modeTimer=0,s.nextModeChange=2e3+4e3*Math.random()),s.mode){case"scanning":this.updateScanning(t,e,s,i);break;case"darting":this.updateDarting(t,e,s,i);break;case"frozen":this.updateFrozen(t,e,s,i);break;case"patrolling":this.updatePatrolling(t,e,s,i)}t.vy+=.05*e,t.x+=t.vx*e,t.y+=t.vy*e,s.lastPosition.x=t.x,s.lastPosition.y=t.y}},updateScanning(t,e,i,s){i.pauseTimer>0?(i.pauseTimer-=16*e,t.vx*=.9,t.vy*=.9):(i.scanAngle+=i.scanDirection*i.scanSpeed*e*.02,Math.abs(i.scanAngle)>i.scanRange/2&&(i.scanDirection*=-1,i.pauseTimer=i.pauseDuration,i.scanAngle=Math.sign(i.scanAngle)*i.scanRange/2));const a=i.scanCenter+i.scanAngle,h=.8+.5*i.alertLevel;t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h*.3},updateDarting(t,e,i,s){const a=i.dartTarget.x-t.x,h=i.dartTarget.y-t.y,n=Math.sqrt(a*a+h*h);n>5?(t.vx=a/n*i.dartSpeed,t.vy=h/n*i.dartSpeed):(i.mode="scanning",i.modeTimer=0)},updateFrozen(t,e,i,s){t.vx*=.95,t.vy*=.95,Math.random()<.01&&(t.vx+=.5*(Math.random()-.5),t.vy+=.5*(Math.random()-.5))},updatePatrolling(t,e,i,s){i.patrolAngle+=.01*e;const a=s.corePosition?.x??s.canvasWidth/2,h=s.corePosition?.y??s.canvasHeight/2,n=a+Math.cos(i.patrolAngle)*i.patrolRadius,r=h+Math.sin(i.patrolAngle)*i.patrolRadius,o=n-t.x,l=r-t.y;t.vx=.02*o,t.vy=.02*l},changeMode(t,e,i){const s=Math.random(),a=i?.corePosition?.x??(i?.canvasWidth/2||t.x),h=i?.corePosition?.y??(i?.canvasHeight/2||t.y);"scanner"===e.primaryRole?s<.1?(e.mode="darting",e.dartTarget={x:a+200*(Math.random()-.5),y:h+200*(Math.random()-.5)},e.dartSpeed=3+2*Math.random()):e.mode=s<.2?"frozen":"scanning":"patroller"===e.primaryRole?e.mode=s<.1?"frozen":"patrolling":e.mode=s<.3?"scanning":"frozen"}},lt={name:"glitchy",emoji:"โก",description:"Digital glitch with stuttering orbits and corruption",rhythm:{enabled:!0,glitchTiming:{mode:"subdivision",subdivision:"sixteenth",probability:.3,intensityOnBeat:2,intensityOffBeat:.5},stutterSync:{mode:"pattern",patterns:{dubstep:{freezeOnDrop:!0,dropDuration:100},breakbeat:{randomFreeze:.1,duration:50}}},orbitRhythm:{baseSpeed:"tempo",wobbleSync:"eighth",beatAcceleration:1.5,barReset:!0},rgbSync:{enabled:!0,amount:"intensity",direction:"beat",maxSplit:10},noiseRhythm:{trigger:"accent",duration:50,intensity:"drop"}},initialize(t,e,i,s){t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorState={orbitAngle:Math.random()*Math.PI*2,orbitRadius:300+400*Math.random(),orbitSpeed:.01+.02*Math.random(),glitchTimer:0,nextGlitch:500*Math.random()+100,isGlitching:!1,glitchDuration:0,glitchOffset:{x:0,y:0},stutterTimer:0,nextStutter:200*Math.random()+50,isFrozen:!1,frozenPosition:{x:0,y:0},frozenVelocity:{x:0,y:0},hasGhost:Math.random()<.3,ghostOffset:20*Math.random()+10,ghostAngle:Math.random()*Math.PI*2,rgbSplit:Math.random()<.4,rgbPhase:Math.random()*Math.PI*2,noiseLevel:0,noiseBurst:!1,beatPhase:Math.random()*Math.PI*2,beatFrequency:.05+.03*Math.random(),dropIntensity:0},t.lifeDecay=.0015,t.hasGlow=!0,t.glowSizeMultiplier=3+2*Math.random()},update(t,e,i,s){const a=t.behaviorState;if(!a)return;a.glitchTimer+=16*e,a.stutterTimer+=16*e,a.stutterTimer>a.nextStutter&&(a.isFrozen?(a.isFrozen=!1,a.stutterTimer=0,a.nextStutter=100+300*Math.random(),Math.random()<.3&&(t.x+=60*(Math.random()-.5),t.y+=60*(Math.random()-.5))):(a.isFrozen=!0,a.frozenPosition={x:t.x,y:t.y},a.frozenVelocity={x:t.vx,y:t.vy},a.stutterTimer=0,a.nextStutter=20+40*Math.random())),a.glitchTimer>a.nextGlitch&&!a.isGlitching&&(a.isGlitching=!0,a.glitchDuration=50+100*Math.random(),a.glitchOffset={x:80*(Math.random()-.5),y:80*(Math.random()-.5)},a.glitchTimer=0,Math.random()<.5&&t.emotionColors&&(t.color=H(t.emotionColors))),a.isGlitching&&a.glitchTimer>a.glitchDuration&&(a.isGlitching=!1,a.glitchTimer=0,a.nextGlitch=200+800*Math.random(),a.glitchOffset={x:0,y:0}),a.beatPhase+=a.beatFrequency*e;const h=.5*Math.sin(a.beatPhase)+.5;if(a.beatPhase%(4*Math.PI)<.5*Math.PI?a.dropIntensity=Math.min(1,a.dropIntensity+.1*e):a.dropIntensity=Math.max(0,a.dropIntensity-.05*e),a.isFrozen)t.vx=.5*(Math.random()-.5),t.vy=.5*(Math.random()-.5);else{a.orbitAngle+=a.orbitSpeed*e*(1+.5*h);const n=a.orbitRadius*(1+.3*a.dropIntensity*Math.sin(4*a.beatPhase));let r=i+Math.cos(a.orbitAngle)*n,o=s+Math.sin(a.orbitAngle)*n*.6;if(a.isGlitching&&(r+=a.glitchOffset.x*Math.random()*.8,o+=a.glitchOffset.y*Math.random()*.8),a.rgbSplit){const t=3*(1+a.dropIntensity);r+=Math.sin(a.rgbPhase)*t,o+=Math.cos(a.rgbPhase)*t,a.rgbPhase+=.1*e}a.dropIntensity>.8&&Math.random()<.1&&(r+=30*(Math.random()-.5),o+=30*(Math.random()-.5));const l=a.isGlitching?.02:.03;t.vx=(r-t.x)*l,t.vy=(o-t.y)*l,t.vx+=(Math.random()-.5)*h*2,t.vy+=(Math.random()-.5)*h*2}t.x+=t.vx*e,t.y+=t.vy*e,Math.random()<.02&&(t.opacity=.1+.9*Math.random()),t.size=t.baseSize*(1+.3*h+.5*a.dropIntensity)}},ct={name:"spaz",description:"Ultra-aggressive particles with explosive spread and chaotic motion",initialize(t,e,i,s){t.x=i,t.y=s,t.life=1,t.size=3+4*Math.random();const a=Math.random()*Math.PI*2,h=200+300*Math.random();t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h,t.behaviorState={explosionPhase:0,explosionTimer:0,explosionDuration:1e3+2e3*Math.random(),chaosTimer:0,nextChaosChange:100+200*Math.random(),chaosAngle:a,chaosSpeed:50+100*Math.random(),spazIntensity:.8+.4*Math.random(),zigzagPattern:Math.random()<.5,spiralPattern:Math.random()<.3,teleportChance:.02,sizePulse:!0,sizePulseSpeed:.1+.05*Math.random(),sizePulsePhase:Math.random()*Math.PI*2,colorShift:Math.random()<.3,colorShiftSpeed:.05+.03*Math.random()},t.lifeDecay=8e-4,t.hasGlow=!0,t.glowSizeMultiplier=4+3*Math.random(),t.glowIntensity=1.5+.5*Math.random()},update(t,e,i,s){const a=t.behaviorState;if(a.explosionTimer+=e,a.chaosTimer+=e,0===a.explosionPhase&&a.explosionTimer<500)t.vx*=.98,t.vy*=.98,Math.random()<.1&&(t.vx+=100*(Math.random()-.5),t.vy+=100*(Math.random()-.5));else if(0===a.explosionPhase&&a.explosionTimer>=500)a.explosionPhase=1,a.chaosAngle=Math.random()*Math.PI*2,a.chaosSpeed=30+70*Math.random();else if(1===a.explosionPhase){a.chaosTimer>=a.nextChaosChange&&(a.chaosAngle=Math.random()*Math.PI*2,a.chaosSpeed=20+80*Math.random(),a.nextChaosChange=50+150*Math.random(),a.chaosTimer=0);const e=Math.cos(a.chaosAngle)*a.chaosSpeed,i=Math.sin(a.chaosAngle)*a.chaosSpeed;if(t.vx=.7*t.vx+.3*e,t.vy=.7*t.vy+.3*i,a.zigzagPattern){const e=.01*a.chaosTimer;t.vx+=20*Math.sin(e),t.vy+=20*Math.cos(e)}if(a.spiralPattern){const e=.005*a.chaosTimer,i=50+30*Math.sin(.003*a.chaosTimer);t.vx+=Math.cos(e)*i*.1,t.vy+=Math.sin(e)*i*.1}}if(Math.random()<a.teleportChance){const e=Math.random()*Math.PI*2,a=200+400*Math.random();t.x=i+Math.cos(e)*a,t.y=s+Math.sin(e)*a,t.vx=200*(Math.random()-.5),t.vy=200*(Math.random()-.5)}if(t.x+=t.vx*(e/1e3),t.y+=t.vy*(e/1e3),a.sizePulse){a.sizePulsePhase+=a.sizePulseSpeed*e;const i=1+.5*Math.sin(a.sizePulsePhase);t.size=(3+4*Math.random())*i}a.colorShift&&(a.colorShiftPhase=(a.colorShiftPhase||0)+a.colorShiftSpeed*e),t.vx*=.995,t.vy*=.995,t.life-=t.lifeDecay*e,(t.life<=0||Math.abs(t.x-i)>2e3||Math.abs(t.y-s)>2e3)&&(t.life=0)},getSpawnPosition(t,e){const i=Math.random()*Math.PI*2,s=100+200*Math.random();return{x:t+Math.cos(i)*s,y:e+Math.sin(i)*s}},getVisualProperties:()=>({glowColor:"#FF00AA",glowIntensity:2,particleColors:[{color:"#FF00AA",weight:30},{color:"#00FFAA",weight:25},{color:"#FFAA00",weight:20},{color:"#AA00FF",weight:15},{color:"#00AAFF",weight:10}]})},ut={name:"directed",emoji:"๐ฏ",description:"Focused, straight-line movement toward target",config:{speed:3,acceleration:.15,focusStrength:.8,randomness:.1,edgeBuffer:50},initialize(t,e,i,s,a){const h=e-t.x,n=i-t.y,r=Math.sqrt(h*h+n*n);if(r>0)t.vx=h/r*this.config.speed,t.vy=n/r*this.config.speed;else{const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*this.config.speed,t.vy=Math.sin(e)*this.config.speed}t.targetX=e,t.targetY=i,t.directedPhase=0},update(t,e,i,s,a,h){t.directedPhase+=.05*e;const n=t.targetX-t.x,r=t.targetY-t.y,o=Math.sqrt(n*n+r*r);if(o>10){const i=n/o*this.config.speed,s=r/o*this.config.speed;t.vx+=(i-t.vx)*this.config.acceleration*e,t.vy+=(s-t.vy)*this.config.acceleration*e,t.vx+=(Math.random()-.5)*this.config.randomness,t.vy+=(Math.random()-.5)*this.config.randomness}else{const e=Math.random()*Math.PI*2,n=100+200*Math.random();t.targetX=i+Math.cos(e)*n,t.targetY=s+Math.sin(e)*n,t.targetX=Math.max(this.config.edgeBuffer,Math.min(a-this.config.edgeBuffer,t.targetX)),t.targetY=Math.max(this.config.edgeBuffer,Math.min(h-this.config.edgeBuffer,t.targetY))}t.x+=t.vx*e,t.y+=t.vy*e,(t.x<=0||t.x>=a)&&(t.vx*=-.8,t.x=Math.max(0,Math.min(a,t.x)),t.targetX=i+300*(Math.random()-.5)),(t.y<=0||t.y>=h)&&(t.vy*=-.8,t.y=Math.max(0,Math.min(h,t.y)),t.targetY=s+300*(Math.random()-.5))},visuals:{trailLength:"medium",opacity:.9,sizeMultiplier:1,blurAmount:.2}},pt={name:"fizzy",emoji:"๐ซง",description:"Bubbly, effervescent movement like carbonation",config:{baseRiseSpeed:2.5,wobbleAmplitude:30,wobbleFrequency:.15,popChance:.002,popForce:8,fizziness:.3,gravity:-.05},initialize(t,e,i,s,a){t.vx=2*(Math.random()-.5),t.vy=-this.config.baseRiseSpeed-2*Math.random(),t.wobblePhase=Math.random()*Math.PI*2,t.wobbleSpeed=this.config.wobbleFrequency*(.8+.4*Math.random()),t.bubbleSize=.5+.5*Math.random(),t.popTimer=0,t.isFizzing=!0},update(t,e,i,s,a,h){t.wobblePhase+=t.wobbleSpeed*e;const n=Math.sin(t.wobblePhase)*this.config.wobbleAmplitude;if(t.vx=.05*n+(Math.random()-.5)*this.config.fizziness,t.vy+=this.config.gravity*e,t.vy+=(Math.random()-.5)*this.config.fizziness,Math.random()<this.config.popChance){const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*this.config.popForce,t.vy=Math.sin(e)*this.config.popForce*.7,t.popTimer=1,t.bubbleSize=.3+.7*Math.random()}t.popTimer>0&&(t.popTimer-=.05*e,t.vx*=.95,t.vy*=.95),t.x+=t.vx*e,t.y+=t.vy*e,t.y<-50&&(t.y=h+50,t.x=i+300*(Math.random()-.5),t.vy=-this.config.baseRiseSpeed-2*Math.random(),t.bubbleSize=.5+.5*Math.random()),(t.x<=0||t.x>=a)&&(t.vx*=-.5,t.x=Math.max(0,Math.min(a,t.x))),t.y>h+50&&(t.y=h,t.vy=1.5*-this.config.baseRiseSpeed),t.size=t.baseSize*t.bubbleSize*(1+.1*Math.sin(2*t.wobblePhase))},visuals:{trailLength:"short",opacity:.6,sizeMultiplier:1.2,blurAmount:.5,sparkle:!0}};const dt=new Map;var ft=function(t){return dt.get(t)||null};const mt={};function Mt(t){return mt[t]?mt[t]:ft(t)||null}function gt(t,e){const i=Mt(e);return i&&i.initialize?(i.initialize(t),!0):"ambient"!==e&>(t,"ambient")}[_,ut,pt,W,U,N,Q,J,Z,K,tt,et,it,st,ht,nt,rt,ot,lt,ct].forEach(t=>{mt[t.name]=t}),"undefined"!=typeof window&&window.DEBUG_PARTICLES&&(window.ParticleBehaviors={registry:mt,list:function(){return[...Object.values(mt).map(t=>({name:t.name,emoji:t.emoji||"๐ฏ",description:t.description||"No description",type:"core"})),...Array.from(dt.keys()).map(t=>{const e=ft(t);return{name:e.name,emoji:e.emoji||"๐",description:e.description||"Plugin behavior",type:"plugin"}})]},get:Mt});const yt=new Map;var bt=function(t){return yt.get(t)||null},wt=function(){return Array.from(yt.keys())},vt={name:"breathe",emoji:"๐ซ",type:"blending",description:"Breathing rhythm with inhale and exhale",config:{musicalDuration:{musical:!0,bars:1,minBeats:2,maxBeats:16},phases:[{name:"inhale",beats:1.5},{name:"hold_in",beats:.5},{name:"exhale",beats:1.5},{name:"hold_out",beats:.5}],inhaleRadius:1.5,exhaleRadius:.3,breathRate:.3,spiralStrength:.002,scaleAmount:.25,glowAmount:.4,frequency:1,easing:"sine",strength:.8,particleMotion:{type:"breathe",strength:.8,inhaleRadius:1.5,exhaleRadius:.3}},rhythm:{enabled:!0,syncMode:"phrase",breathRateSync:{mode:"tempo",bpm:"auto",subdivision:"whole",curve:"sine"},radiusSync:{inhale:{onUpbeat:1.8,onDownbeat:1.4,curve:"ease-in"},exhale:{onUpbeat:.2,onDownbeat:.4,curve:"ease-out"}},durationSync:{mode:"phrases",phrases:2,hold:"fermata"},accentResponse:{enabled:!0,multiplier:1.5,type:"expansion"},patternOverrides:{ballad:{breathRateSync:{subdivision:"double-whole"},radiusSync:{inhale:{onUpbeat:2.2,onDownbeat:1.8},exhale:{onUpbeat:.1,onDownbeat:.2}}},uptempo:{breathRateSync:{subdivision:"half"},radiusSync:{inhale:{onUpbeat:1.4,onDownbeat:1.2},exhale:{onUpbeat:.3,onDownbeat:.4}}},ambient:{breathRateSync:{subdivision:"whole",curve:"ease"},radiusSync:{inhale:{onUpbeat:1.6,onDownbeat:1.6},exhale:{onUpbeat:.2,onDownbeat:.2}}}},dynamics:{forte:{radiusSync:{inhale:{multiplier:1.8},exhale:{multiplier:.5}},spiralStrength:.004,scaleAmount:.4},piano:{radiusSync:{inhale:{multiplier:1.2},exhale:{multiplier:.8}},spiralStrength:.001,scaleAmount:.1}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.breathe={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),phaseOffset:.2*Math.random()-.1}},apply(t,e,i,s,a,h){t.gestureData?.breathe||this.initialize(t,i,a,h);const n={...this.config,...i},r=(Math.sin(e*Math.PI*2*n.breathRate)+1)/2,o=100*(t.scaleFactor||1),l=n.inhaleRadius*o,c=n.exhaleRadius*o,u=c+(l-c)*r,p=t.x-a,d=t.y-h,f=Math.sqrt(p*p+d*d),m=u-f,M=.05*(i.strength||.8)*s;if(f>0){const e=p/f*m*M,a=d/f*m*M;t.vx+=e,t.vy+=a;const h=n.spiralStrength*s*(i.strength||1),o=-d/f,l=p/f;t.vx+=o*h*r,t.vy+=l*h*r}t.vx*=.98,t.vy*=.98},cleanup(t){t.gestureData?.breathe&&delete t.gestureData.breathe},"3d":{evaluate(t,e){const i=(e.config||{}).breathRate||.3,s=Math.sin(t*Math.PI*2*i);let a=1;if(t>.8){const e=(t-.8)/(1-.8);a=1-e*e*e}const h=.2*s*a;return{position:[0,.05*s*a,0],rotation:[0,0,0],scale:1+.35*s*a,glowIntensity:1+h,glowBoost:Math.max(0,2*h)}}}},St={name:"expand",emoji:"๐ซ",type:"blending",description:"Radial expansion from center",config:{duration:600,scaleAmount:3,scaleTarget:3,glowAmount:.5,easing:"back",strength:3,particleMotion:{type:"pulse",strength:3,direction:"outward",persist:!0}},rhythm:{enabled:!0,syncMode:"crescendo",strengthSync:{pianissimo:1.5,fortissimo:5,crescendo:"build",sforzando:"burst"},scaleTargetSync:{verse:2,chorus:4.5,climax:6,curve:"exponential"},durationSync:{mode:"phrases",build:1.2,release:.8,sustain:"hold"},accentResponse:{enabled:!0,multiplier:2.8,type:"strength"},patternOverrides:{orchestral:{strengthSync:{pianissimo:2,fortissimo:6.5,crescendo:"dramatic"},scaleTargetSync:{climax:8}},rock:{strengthSync:{pianissimo:1.8,fortissimo:5.5,curve:"power"},accentResponse:{multiplier:3.2}},ambient:{strengthSync:{pianissimo:1.2,fortissimo:3.5,crescendo:"organic"},durationSync:{build:1.8,release:1.2}},electronic:{strengthSync:{pianissimo:1.6,fortissimo:4.8,curve:"digital"},scaleTargetSync:{curve:"linear"}}},dynamics:{forte:{strengthSync:{pianissimo:{multiplier:1.4},fortissimo:{multiplier:1.8}},scaleTargetSync:{multiplier:1.6},accentResponse:{multiplier:3.5}},piano:{strengthSync:{pianissimo:{multiplier:.8},fortissimo:{multiplier:1.2}},scaleTargetSync:{multiplier:.7},accentResponse:{multiplier:2}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.expand={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.expand?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.expand,r={...this.config,...i},o=r.strength||1,l=1+(r.scaleTarget-1)*e*o,c=n.baseRadius*l,u=a+Math.cos(n.angle)*c,p=h+Math.sin(n.angle)*c,d=u-t.x,f=p-t.y;t.vx+=.8*d*s,t.vy+=.8*f*s,t.vx*=.95,t.vy*=.95},cleanup(t){t.gestureData?.expand&&delete t.gestureData.expand},"3d":{evaluate(t,e){const i={...this.config,...e},s=i.strength||3;return{position:[0,0,0],rotation:[0,0,0],scale:1+t*(i.scaleAmount||3)*(s/3),glowIntensity:1+.25*t,glowBoost:.8*t}}}},Ft={name:"contract",emoji:"๐",type:"blending",description:"Radial contraction toward center",config:{duration:600,scaleAmount:.2,scaleTarget:.2,glowAmount:-.2,easing:"cubic",strength:2.5,particleMotion:{type:"pulse",strength:2.5,direction:"inward",persist:!0}},rhythm:{enabled:!0,syncMode:"tension",strengthSync:{onTension:4,onRelease:1.5,curve:"magnetic"},scaleTargetSync:{forte:.1,piano:.4,crescendo:"gradual",diminuendo:"ease"},durationSync:{mode:"phrases",shortPhrase:.8,longPhrase:1.5,hold:"sustain"},accentResponse:{enabled:!0,multiplier:2.2,type:"strength"},patternOverrides:{classical:{strengthSync:{onTension:3.5,onRelease:1.8},scaleTargetSync:{forte:.15,piano:.35}},metal:{strengthSync:{onTension:5,onRelease:2,curve:"sharp"},scaleTargetSync:{forte:.05,piano:.25}},ambient:{strengthSync:{onTension:2.8,onRelease:1.2,curve:"ease"},durationSync:{shortPhrase:1.2,longPhrase:2}},trap:{strengthSync:{onTension:4.5,onRelease:1,dropBeat:6},scaleTargetSync:{forte:.08,piano:.3}}},dynamics:{forte:{strengthSync:{onTension:{multiplier:1.8},onRelease:{multiplier:1.4}},scaleTargetSync:{multiplier:.6},accentResponse:{multiplier:2.8}},piano:{strengthSync:{onTension:{multiplier:.7},onRelease:{multiplier:.8}},scaleTargetSync:{multiplier:1.4},accentResponse:{multiplier:1.6}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.contract={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.contract?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.contract,r={...this.config,...i},o=r.strength||1,l=1-(1-r.scaleTarget)*e*o,c=n.baseRadius*l,u=a+Math.cos(n.angle)*c,p=h+Math.sin(n.angle)*c,d=u-t.x,f=p-t.y;t.vx+=.5*d*s,t.vy+=.5*f*s,t.vx*=.95,t.vy*=.95},cleanup(t){t.gestureData?.contract&&delete t.gestureData.contract},"3d":{evaluate(t,e){const i={...this.config,...e},s=i.strength||2.5,a=i.scaleTarget||.2,h=1-t*(1-a)*(s/2.5),n=1-.15*t;return{position:[0,0,0],rotation:[0,0,0],scale:Math.max(a,h),glowIntensity:n}}}},xt={name:"pulse",emoji:"๐",type:"blending",description:"Radial expansion and contraction from center",config:{duration:600,amplitude:30,frequency:1,holdPeak:.1,easing:"sine",scaleAmount:.2,glowAmount:.3,strength:.15,direction:"outward",particleMotion:{type:"pulse",strength:.15,direction:"outward",frequency:1}},rhythm:{enabled:!0,syncMode:"beat",amplitudeSync:{onBeat:1.6,offBeat:.8,curve:"pulse"},frequencySync:{mode:"locked",subdivision:"quarter"},durationSync:{mode:"beats",beats:1},accentResponse:{enabled:!0,multiplier:2},patternOverrides:{waltz:{amplitudeSync:{onBeat:2,offBeat:.5},durationSync:{beats:3}},swing:{amplitudeSync:{onBeat:1.8,offBeat:.6,curve:"ease"},frequencySync:{subdivision:"swing"}},dubstep:{amplitudeSync:{onBeat:1.2,dropBeat:4,curve:"pulse"}},breakbeat:{frequencySync:{mode:"random",range:[.5,2]},amplitudeSync:{onBeat:2.5,offBeat:.3}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s,n=Math.sqrt(a*a+h*h),r=Math.atan2(h,a);t.gestureData.pulse={baseDistance:n,angle:r,startX:t.x,startY:t.y,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.pulse?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.pulse,r={...this.config,...i},o=i.strength||1,l=this.easeInOutSine(e);let c,{frequency:u}=r,{amplitude:p}=r;i.rhythmModulation&&(p*=i.rhythmModulation.amplitudeMultiplier||1,p*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(u*=i.rhythmModulation.frequencyMultiplier));const d=l*u*2%2;c=r.holdPeak>0&&d>1-r.holdPeak&&d<1+r.holdPeak?1:Math.sin(l*Math.PI*2*u);const f=c*p*o*t.scaleFactor,m=n.baseDistance+f,M=a+Math.cos(n.angle)*m,g=h+Math.sin(n.angle)*m,y=.15*s;if(t.vx+=(M-t.x)*y*.1,t.vy+=(g-t.y)*y*.1,e>.9){const i=1-10*(e-.9);t.vx*=.9+.1*i,t.vy*=.9+.1*i}},cleanup(t){t.gestureData?.pulse&&delete t.gestureData.pulse},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i=e||{},s=i.frequency||1,a=i.strength||.15,h=i.scaleAmount||.2,n=i.glowAmount||.3,r=-(Math.cos(Math.PI*t)-1)/2,o=Math.sin(r*Math.PI*2*s);return{position:[0,0,0],rotation:[0,0,0],scale:1+o*h*a,glowIntensity:1+Math.max(-.3,Math.min(.3,o*n*a*2)),glowBoost:Math.max(0,.8*o)}}}},kt={name:"sway",type:"blending",emoji:"๐",description:"Gentle side-to-side swaying motion",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},amplitude:20,frequency:1,strength:.5},rhythm:{enabled:!0,syncMode:"bar",amplitudeSync:{onBeat:1.2,offBeat:.9,curve:"ease"},durationSync:{mode:"bars",bars:1},patternOverrides:{waltz:{durationSync:{bars:1},amplitudeSync:{onBeat:1.5,curve:"ease"}},swing:{amplitudeSync:{onBeat:1.3,offBeat:.7,curve:"bounce"}}}},apply(t,e,i,s,a,h){const n={...this.config,...i},r=n.amplitude||this.config.amplitude,o=n.frequency||this.config.frequency,l=n.strength||this.config.strength,c=Math.sin(e*Math.PI*2*o)*r;t.vx+=.01*c*s*l,t.vy+=.5*Math.cos(e*Math.PI*4)*s*l},cleanup(t){},"3d":{evaluate(t,e){const i={...this.config,...e};let s=i.amplitude||this.config.amplitude;const a=i.frequency||this.config.frequency,h=i.strength||this.config.strength;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1);const n=Math.sin(t*Math.PI*2*a),r=s*h*.3*.01,o=.15*n*h,l=.08*n*h;return{position:[n*r,.3*Math.cos(t*Math.PI*4)*r,Math.sin(t*Math.PI*a)*r*.5],rotation:[0,l,o],scale:1}}}},Bt={name:"float",type:"blending",emoji:"๐",description:"Gentle floating upward motion",config:{duration:2e3,musicalDuration:{musical:!0,bars:2},amplitude:80,wobbleAmount:20,strength:1},rhythm:{enabled:!0,syncMode:"beat",amplitudeSync:{onBeat:1.5,offBeat:.8,curve:"bounce"},wobbleSync:{subdivision:"eighth",intensity:.7},durationSync:{mode:"bars",bars:2},accentResponse:{enabled:!0,multiplier:1.3},patternOverrides:{waltz:{wobbleSync:{subdivision:"quarter",intensity:.9}},dubstep:{amplitudeSync:{onBeat:2,curve:"pulse"}}}},apply(t,e,i,s,a,h){t.gestureData||(t.gestureData={}),t.gestureData.float||(t.gestureData.float={originalSize:t.size,originalOpacity:t.opacity||1});const n={...this.config,...i};let r=n.amplitude||this.config.amplitude,o=n.wobbleAmount||this.config.wobbleAmount;const l=n.strength||this.config.strength;i.rhythmModulation&&(r*=i.rhythmModulation.amplitudeMultiplier||1,r*=i.rhythmModulation.accentMultiplier||1,o*=i.rhythmModulation.wobbleMultiplier||1);const c=Math.sin(e*Math.PI*4)*o;t.vy-=.01*r*s*l*(1-.5*e),t.vx+=.01*c*s*l,t.size=t.baseSize*(1+.1*e),t.opacity=1-.3*e},cleanup(t){t.gestureData?.float?(t.opacity=t.gestureData.float.originalOpacity,t.size=t.gestureData.float.originalSize,delete t.gestureData.float):(t.opacity=1,t.size=t.baseSize),t.vx*=.5,t.vy*=.5},"3d":{evaluate(t,e){const i={...this.config,...e};let s=i.amplitude||this.config.amplitude,a=i.wobbleAmount||this.config.wobbleAmount;const h=i.strength||this.config.strength;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1,a*=e.rhythmModulation.wobbleMultiplier||1);const n=Math.sin(t*Math.PI),r=s*n*h*.005,o=Math.sin(t*Math.PI*4)*a*.3*.005,l=Math.sin(t*Math.PI)*Math.PI*.5*h,c=Math.sin(t*Math.PI);return{position:[o,r,0],rotation:[c*Math.sin(t*Math.PI*2)*.1,l,c*Math.cos(t*Math.PI*3)*.08],scale:1+.1*n}}}},Ct={name:"shake",emoji:"๐ซจ",type:"blending",description:"Random jitter movement for vibration effects",config:{duration:400,amplitude:15,frequency:15,decay:.9,smoothing:.1,axes:"both",easing:"linear",strength:3,particleMotion:{type:"shake",strength:3,frequency:15,decay:!1}},rhythm:{enabled:!0,syncMode:"subdivision",amplitudeSync:{subdivision:"sixteenth",onBeat:2.5,offBeat:.7,curve:"pulse"},frequencySync:{mode:"tempo",baseFrequency:15,scaling:"linear"},durationSync:{mode:"beats",beats:2},patternOverrides:{breakbeat:{amplitudeSync:{onBeat:3,offBeat:.2},frequencySync:{mode:"random",range:[8,20]}},dubstep:{amplitudeSync:{subdivision:"eighth",onBeat:4,dropBeat:6,curve:"pulse"}},swing:{amplitudeSync:{onBeat:1.8,offBeat:1,curve:"ease"}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.shake={originalX:t.x,originalY:t.y,randomAngle:Math.random()*Math.PI*2,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.shake?.initialized||this.initialize(t,i);const n=t.gestureData.shake,r={...this.config,...i},o=r.strength||this.config.strength||1;let{amplitude:l}=r,{frequency:c}=r;i.rhythmModulation&&(l*=i.rhythmModulation.amplitudeMultiplier||1,l*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(c*=i.rhythmModulation.frequencyMultiplier));const u=r.decay?1-e:1,p=Math.sin(e*Math.PI*c)*l*u*o*t.scaleFactor,d=p*Math.cos(n.randomAngle),f=p*Math.sin(n.randomAngle);t.x=n.originalX+d,t.y=n.originalY+f},pseudoRandom(t){const e=1e4*Math.sin(t);return e-Math.floor(e)},cleanup(t){t.gestureData?.shake&&(t.x=t.gestureData.shake.originalX,t.y=t.gestureData.shake.originalY,delete t.gestureData.shake)},"3d":{evaluate(t,e){const i=e||{},s=.003*(i.amplitude||15),a=i.frequency||15,h=.5*(i.strength||1),n=i.decay?1-t:1,r=Math.sin(t*Math.PI*a)*s*n*h,o=Math.floor(t*a);return{position:[r*(1e4*Math.sin(o)%1-.5)*2,0,r*(1e4*Math.sin(1.3*o)%1-.5)*2],rotation:[0,0,r*(1e4*Math.sin(1.7*o)%1-.5)*.2],scale:1}}}},Rt={name:"wiggle",emoji:"ใฐ๏ธ",type:"additive",description:"Rapid side-to-side oscillation",config:{duration:600,musicalDuration:{musical:!0,beats:1},amplitude:15,frequency:6,strength:1,damping:.3,easing:"linear",particleMotion:{type:"wiggle",strength:1,amplitude:15,frequency:6}},rhythm:{enabled:!0,syncMode:"beat",frequencySync:{subdivision:"sixteenth",wigglePerBeat:4},amplitudeSync:{onBeat:1.5,offBeat:.8,curve:"bounce"},durationSync:{mode:"beats",beats:1}},apply(t,e,i,s,a,h,n){const r=(i.amplitude||this.config.amplitude)*a,o=i.frequency||this.config.frequency,l=1-s*(i.damping||this.config.damping),c=Math.sin(s*Math.PI*o)*r*l;t.vx+=.5*c;const u=Math.cos(s*Math.PI*o*2)*r*.1*l;t.vy+=.3*u},"3d":{evaluate(t,e){const i=e.config||{},s=e.strength||1,a=i.amplitude||15,h=Math.pow(1-t,.5),n=Math.sin(t*Math.PI*14)*h,r=Math.cos(t*Math.PI*14*.7)*h*.4,o=a/15*s,l=.15*n*s;return{cameraRelativePosition:[.08*n*o,.02*Math.abs(r)*o,0],cameraRelativeRotation:[0,0,l],scale:1+.05*Math.abs(n),glowIntensity:1+.2*Math.abs(n)}}}},Tt={name:"bounce",emoji:"โฌ๏ธ",type:"blending",description:"Vertical oscillation with smooth easing",config:{duration:800,musicalDuration:{musical:!0,beats:2},amplitude:30,frequency:2,axis:"vertical",damping:!0,easing:"sine",strength:.6,particleMotion:{type:"bounce",axis:"vertical",strength:.6,frequency:2}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",interruptible:!0,priority:3,blendable:!0,crossfadePoint:"anyBeat",amplitudeSync:{onBeat:1.8,offBeat:.6,curve:"bounce"},frequencySync:{mode:"tempo",multiplier:1},durationSync:{mode:"beats",beats:4},accentResponse:{enabled:!0,multiplier:1.5},patternOverrides:{waltz:{frequencySync:{multiplier:.75},durationSync:{beats:3}},swing:{amplitudeSync:{onBeat:2,offBeat:.4,curve:"ease"}},dubstep:{amplitudeSync:{onBeat:1.5,dropBeat:3,curve:"pulse"}},breakbeat:{frequencySync:{multiplier:1.5},amplitudeSync:{onBeat:2.2,offBeat:.3}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.bounce={startY:t.y,startX:t.x,startVx:t.vx,startVy:t.vy,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.bounce?.initialized||this.initialize(t,i);const n={...this.config,...i},r=n.strength||this.config.strength||1,o=this.easeInOutCubic(e);let{frequency:l}=n;const c=i.phase||0;let u=n.amplitude*r*t.scaleFactor;i.rhythmModulation&&(u*=i.rhythmModulation.amplitudeMultiplier||1,u*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(l*=i.rhythmModulation.frequencyMultiplier));const p=Math.sin((o+c)*Math.PI*2*l);if(n.damping&&e>.7&&(u*=1-(e-.7)/.3*.8),"vertical"===n.axis?(t.vy+=p*u*.01*s,e>.9&&(t.vx*=.98)):"horizontal"===n.axis&&(t.vx+=p*u*.01*s,e>.9&&(t.vy*=.98)),e>.9){const i=1-10*(e-.9);t.vx=t.vx*(.95+.05*i),t.vy=t.vy*(.95+.05*i)}},cleanup(t){t.gestureData?.bounce&&delete t.gestureData.bounce},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,"3d":{evaluate(t,e){const i=e||{},s=i.amplitude||30,a=i.frequency||2,h=.003*s*(i.strength||.6),n=(t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2)*Math.PI*a,r=Math.abs(Math.sin(n));let o=h;return t>.7&&(o*=1-(t-.7)/.3*.8),{position:[0,r*o,0],rotation:[0,0,0],scale:1+.08*r}}}},Pt={name:"spin",emoji:"๐",type:"override",description:"Orbital rotation around center point",config:{duration:600,musicalDuration:{musical:!0,beats:1},rotations:1,direction:"random",radiusMultiplier:1,spiralOut:!1,accelerate:!0,maintainDistance:!0,scaleAmount:.1,easing:"linear",strength:.7,particleMotion:{type:"spin",strength:.7,rotations:1,radius:1}},rhythm:{enabled:!0,syncMode:"bar",rotationSync:{mode:"bars",rotationsPerBar:1,accelerateOnBeat:!0},radiusSync:{subdivision:"quarter",expandOnBeat:1.2,contractOffBeat:.9,curve:"bounce"},durationSync:{mode:"beats",beats:4},patternOverrides:{waltz:{rotationSync:{rotationsPerBar:.75},radiusSync:{curve:"ease"}},swing:{rotationSync:{accelerateOnBeat:!1},direction:"alternating"},dubstep:{radiusSync:{subdivision:"eighth",expandOnBeat:1.5,dropMultiplier:2},spiralOut:!0},breakbeat:{rotationSync:{mode:"random",range:[.5,2]},direction:"random"}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;let n=e.direction||this.config.direction;"random"===n&&(n=Math.random()<.5?"clockwise":"counter-clockwise"),t.gestureData.spin={startAngle:Math.atan2(h,a),startRadius:Math.sqrt(a*a+h*h)||30,originalX:t.x,originalY:t.y,originalVx:t.vx,originalVy:t.vy,direction:n,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.spin?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.spin,r={...this.config,...i},o=i.strength||1;let{rotations:l}=r,{radiusMultiplier:c}=r;i.rhythmModulation&&(i.rhythmModulation.rotationMultiplier&&(l*=i.rhythmModulation.rotationMultiplier),i.rhythmModulation.radiusMultiplier&&(c*=i.rhythmModulation.radiusMultiplier));let u=e;r.accelerate&&(u=e<.5?.5*this.easeInQuad(2*e):.5+.5*this.easeOutQuad(2*(e-.5)));const p=l*Math.PI*2*o,d="counter-clockwise"===n.direction?-1:1,f=n.startAngle+p*u*d;let m=n.startRadius;r.spiralOut&&(m*=1+.5*e),1!==c&&(m*=1+(c-1)*Math.sin(e*Math.PI));const M=a+Math.cos(f)*m,g=h+Math.sin(f)*m;if(t.x+=.25*(M-t.x),t.y+=.25*(g-t.y),t.vx=.5*(M-t.x),t.vy=.5*(g-t.y),e>.9){const i=10*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i)}},cleanup(t){if(t.gestureData?.spin){const e=t.gestureData.spin;t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.spin}},easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),"3d":{evaluate(t,e){const i=e?.config||e||{},s=e?.strength||1,a=e?.particle;let h=1;a?.gestureData?.spin?h="counter-clockwise"===a.gestureData.spin.direction?-1:1:"counter-clockwise"!==i.direction&&"left"!==i.direction||(h=-1);let n=t;return!1!==i.accelerate&&(n=t<.5?t*t*4*.5:.5+(t-.5)*(2-(t-.5))*.5),{position:[0,0,0],rotation:[0,(i.rotations||1)*Math.PI*2*s*n*h,0],scale:1+(i.scaleAmount||.1)*Math.sin(t*Math.PI)*s}}}},Ot={name:"nod",emoji:"๐",type:"blending",description:"Vertical nodding motion",config:{duration:500,amplitude:15,frequency:2,easing:"sine",strength:.4,particleMotion:{type:"bounce",axis:"vertical",strength:.4,frequency:2,phase:0}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",interruptible:!1,priority:5,blendable:!1,minDuration:"halfBar",frequencySync:{mode:"subdivision",subdivision:"half",multiplier:1},amplitudeSync:{onBeat:1.4,offBeat:.8,curve:"ease"},durationSync:{mode:"beats",beats:2},patternOverrides:{waltz:{frequencySync:{subdivision:"quarter"},amplitudeSync:{onBeat:1.6,curve:"ease"}},swing:{amplitudeSync:{onBeat:1.5,offBeat:.9}},dubstep:{amplitudeSync:{onBeat:1.2,dropBeat:3,curve:"pulse"}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.nod={startY:t.y,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.nod?.initialized||this.initialize(t,i);const n={...this.config,...i},r=n.strength||this.config.strength||1;let{frequency:o}=n,{amplitude:l}=n;i.rhythmModulation&&(l*=i.rhythmModulation.amplitudeMultiplier||1,l*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(o*=i.rhythmModulation.frequencyMultiplier));const c=Math.sin(e*Math.PI*2*o);l=l*r*t.scaleFactor,t.vy+=c*l*.01*s,e>.9&&(t.vy*=.95)},cleanup(t){t.gestureData?.nod&&delete t.gestureData.nod},"3d":{evaluate(t,e){const i={...this.config,...e};let{amplitude:s}=i;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1);let a=0;if(t<.4){const e=t/.4;a=.12*Math.sin(e*Math.PI)}else if(t<.8){const e=(t-.4)/.4;a=.07*Math.sin(e*Math.PI)}return a*=s/15,{cameraRelativePosition:[0,0,a],scale:1-.3*Math.abs(a),glowIntensity:1+.5*Math.abs(a)}}}},At={name:"jump",emoji:"๐ฆ",type:"override",description:"Squash, leap, and land with classic animation principles",config:{duration:800,musicalDuration:{musical:!0,beats:2},jumpHeight:60,squashAmount:.8,stretchAmount:1.2,anticipation:.2,hangTime:.1,landingImpact:!0,driftOutward:!0,easing:"quad",particleMotion:{type:"jump",strength:.9,jumpHeight:60,squash:.8,stretch:1.2}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:2},phaseSync:{anticipation:"eighth",jump:"beat",landing:"sixteenth"},heightSync:{onBeat:1.5,offBeat:.8,accent:2,curve:"exponential"},deformationSync:{squashOnBeat:.6,stretchOnBeat:1.4,timing:"anticipatory"},hangTimeSync:{mode:"tempo",baseDuration:.1,scaling:"inverse"},dynamics:{forte:{jumpHeight:80,stretch:1.3},piano:{jumpHeight:30,stretch:1.1}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={}),t.gestureData.jump={startX:t.x,startY:t.y,startSize:t.size,originalVx:t.vx,originalVy:t.vy,driftDirection:.1*(t.x-i),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.jump?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.jump,r={...this.config,...i},o=i.strength||1,l=r.jumpHeight*o*t.scaleFactor,c=r.squashAmount,u=r.stretchAmount,p=r.anticipation,d=1-.5*r.anticipation;if(e<p){const i=e/p,s=this.easeOutQuad(i);t.size=n.startSize*(1-(1-c)*s),t.y=n.startY+5*s*t.scaleFactor,t.vx=0,t.vy=0}else if(e<d){const i=(e-p)/(d-p);let s=Math.sin(i*Math.PI);if(r.hangTime>0&&i>.4&&i<.6){const t=(i-.4)/.2;s=.95+.05*this.easeInOutCubic(t)}if(t.y=n.startY-s*l,r.driftOutward&&(t.x=n.startX+s*n.driftDirection),i<.5){const e=2*i;t.size=n.startSize*(c+(u-c)*e)}else{const e=2*(i-.5);t.size=n.startSize*(u-(u-1)*e*.8)}t.vx=.5*n.driftDirection,t.vy=-Math.cos(i*Math.PI)*l*.1}else{const i=(e-d)/(1-d),s=this.easeOutBounce(i);if(t.y=n.startY,r.landingImpact)if(i<.3){const e=i/.3;t.size=n.startSize*(1-(1-.8*c)*(1-e))}else{const e=(i-.3)/.7;t.size=n.startSize*(.8*c+(1-.8*c)*e)}else t.size=n.startSize*(c+(1-c)*s);t.vx=n.originalVx*s,t.vy=n.originalVy*s}},cleanup(t){if(t.gestureData?.jump){const e=t.gestureData.jump;t.size=e.startSize,t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.jump}},easeOutQuad:t=>t*(2-t),easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},"3d":{evaluate(t,e){const i=e.config||e||{},s=e.strength||1,a=.004*(i.jumpHeight||60)*s,h=i.squashAmount||.8,n=i.stretchAmount||1.2,r=i.anticipation||.2,o=1-.5*r;let l=0,c=1,u=0;if(t<r){const e=t/r,i=e*(2-e);c=1-(1-h)*i,l=.02*-i}else if(t<o){const e=(t-r)/(o-r);l=Math.sin(e*Math.PI)*a,c=e<.5?h+2*e*(n-h):n-2*(e-.5)*(n-1)*.8,u=.05*Math.sin(e*Math.PI)}else{const e=(t-o)/(1-o);if(e<.5){const t=2*e;l=-Math.sin(t*Math.PI)*a*.15}else l=0;c=!1!==i.landingImpact?e<.3?1-(1-.8*h)*(1-e/.3):.8*h+(e-.3)/.7*(1-.8*h):h+(1-h)*e}return{position:[0,l,0],rotation:[u,0,0],scale:c}}}},Dt={name:"stretch",emoji:"โ๏ธ",type:"override",description:"Scale particles along X and Y axes",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},scaleX:1.3,scaleY:.9,alternate:!1,elastic:!0,overshoot:.1,frequency:1,easing:"sine",strength:1,particleMotion:{type:"stretch",scaleX:1.8,scaleY:.6,strength:1},centerBased:!0,preserveArea:!1},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"bars",bars:1},scaleSync:{onBeat:{x:1.5,y:.7},offBeat:{x:.8,y:1.3},subdivision:"eighth",curve:"elastic"},alternateSync:{pattern:"XYXY",beatsPerChange:1,overlap:.1},overshootSync:{normal:.1,accent:.3,downbeat:.2,curve:"spring"},preservationSync:{verse:!0,chorus:!1,bridge:!0},dynamics:{forte:{scaleX:2,scaleY:.5,overshoot:.4},piano:{scaleX:1.1,scaleY:.95,overshoot:.05}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.stretch={offsetX:a,offsetY:h,startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.stretch?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.stretch,r={...this.config,...i},o=i.strength||1;let l,c,{scaleX:u}=r,{scaleY:p}=r;if(r.preserveArea&&1!==u&&1!==p){const t=u*p,e=Math.sqrt(1/t);u*=e,p*=e}if(r.alternate)if(e<.5){const t=2*e;u=1+(u-1)*this.getElasticProgress(t,r),p=1+(1/u-1)*(r.preserveArea?1:0)}else{const t=2*(e-.5);u+=(1-u)*this.getElasticProgress(t,r),p=1+(p-1)*this.getElasticProgress(t,r)}else{const t=this.getElasticProgress(e,r);u=1+(u-1)*t*o,p=1+(p-1)*t*o}if(r.centerBased?(l=a+n.offsetX*u,c=h+n.offsetY*p):(l=n.startX*u,c=n.startY*p),t.x=l,t.y=c,t.vx=n.offsetX*(u-1)*o*.1,t.vy=n.offsetY*(p-1)*o*.1,e>.9){const i=10*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i)}},getElasticProgress(t,e){if(!e.elastic)return this.easeInOutCubic(t);if(0===t)return 0;if(1===t)return 1;const i=e.overshoot||.1;if(t<.5){const e=2*t;return.5*this.easeInElastic(e,i)}{const e=2*(t-.5);return.5+.5*this.easeOutElastic(e,i)}},cleanup(t){if(t.gestureData?.stretch){const e=t.gestureData.stretch;t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.stretch}},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeInElastic:(t,e)=>0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin((t-1-.075)*(2*Math.PI)/.3)*(1+e),easeOutElastic:(t,e)=>0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin((t-.075)*(2*Math.PI)/.3)*(1+e)+1,"3d":{evaluate(t,e){const{particle:i}=e;if(!i||!i.gestureData?.stretch)return{position:[0,0,0],rotation:[0,0,0],scale:1};const s=e.config||{},a=e.strength||1;let h;if(s.elastic){const e=s.overshoot||.1;if(t<.5){const i=2*t,s=.3,a=s/4;h=-Math.pow(2,10*(i-1))*Math.sin((i-1-a)*(2*Math.PI)/s)*(1+e)*.5}else{const i=2*(t-.5),s=.3,a=s/4;h=.5+.5*(Math.pow(2,-10*i)*Math.sin((i-a)*(2*Math.PI)/s)*(1+e)+1)}}else h=t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;let n,r=1;if(t>.8){const e=(t-.8)/(1-.8);r=1-e*e*e}n=s.alternate?t<.5?2*t*.8:.8-2*(t-.5)*1.4:1*h*a;const o=1+n*r;return{position:[0,0,0],rotation:[0,0,.1*Math.sin(t*Math.PI*4)*h*r],scale:o}}}},zt={name:"wobble",emoji:"๐ฅด",type:"override",description:"Unsteady circular wobbling motion",config:{duration:1500,musicalDuration:{musical:!0,beats:4},wobbleRadius:.08,wobbleAngle:.2,rotations:2,decay:.5,strength:1,particleMotion:{type:"wobble",strength:1}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:4},timingSync:"onBeat"},"3d":{evaluate(t,e){const i=e.config||this.config||{},s=i.strength||1,a=i.wobbleRadius||.08,h=i.wobbleAngle||.2,n=i.rotations||2,r=i.decay||.5,o=t*n*Math.PI*2,l=1-r*t,c=Math.sin(o)*a*l*s,u=Math.cos(o)*a*l*s,p=Math.cos(o)*h*l*s,d=Math.sin(o)*h*l*s;return{position:[c,.02*Math.sin(2*o)*l*s,u],rotation:[p,0,d],scale:1+.05*Math.sin(2*o)*l,glowIntensity:1+.2*Math.sin(o)*l,glowBoost:0}}}},Et={name:"drift",emoji:"โ๏ธ",type:"override",description:"Controlled floating with fade effects",config:{duration:800,musicalDuration:{musical:!0,beats:2},distance:50,angle:45,returnToOrigin:!0,fadeOut:!1,holdTime:.2,turbulence:.1,angleSpread:45,smoothness:.08,easing:"ease",strength:1,particleMotion:{type:"drift",strength:1,distance:60}},rhythm:{enabled:!0,syncMode:"ambient",durationSync:{mode:"beats",beats:2},distanceSync:{quiet:30,loud:80,crescendo:"expand",diminuendo:"contract"},angleSync:{major:45,minor:225,modulation:"smooth",cadence:"return"},holdSync:{shortPhrase:.1,longPhrase:.4,fermata:"sustain"},accentResponse:{enabled:!0,multiplier:1.3,type:"distance"},patternOverrides:{ambient:{distanceSync:{quiet:40,loud:100},holdSync:{shortPhrase:.3,longPhrase:.6}},classical:{angleSync:{major:30,minor:210},distanceSync:{quiet:25,loud:60}},jazz:{angleSync:{major:60,minor:240,swing:!0,syncopated:!0}},new_age:{distanceSync:{quiet:35,loud:70},holdSync:{shortPhrase:.4,longPhrase:.8},angleSync:{modulation:"gradual"}}},dynamics:{forte:{distanceSync:{quiet:{multiplier:1.5},loud:{multiplier:1.8}},holdSync:{multiplier:1.2},accentResponse:{multiplier:1.6}},piano:{distanceSync:{quiet:{multiplier:.6},loud:{multiplier:.8}},holdSync:{multiplier:.8},accentResponse:{multiplier:1.1}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;let n=Math.atan2(h,a);const r={...this.config,...e}.angleSpread*Math.PI/180,o=(Math.random()-.5)*r;n+=o;const l=30+30*Math.random();t.gestureData.drift={startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,baseOpacity:t.opacity||t.life||1,driftAngle:n,angleOffset:o,homeRadius:l*t.scaleFactor,homeX:i+Math.cos(n)*l,homeY:s+Math.sin(n)*l,role:Math.random(),turbulencePhase:Math.random()*Math.PI*2,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.drift?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.drift,r={...this.config,...i},o=i.strength||1,l=this.easeInOutCubic(e),c=Math.max(0,l-.1*n.role);let u,p,d;if(r.returnToOrigin)if(c<.4){const t=c/.4,e=this.easeOutQuad(t);u=n.startX+(n.homeX-n.startX)*e,p=n.startY+(n.homeY-n.startY)*e}else if(c<.6+r.holdTime){const e=(c-.4)/(.2+r.holdTime);d=n.homeRadius+Math.sin(e*Math.PI*.5)*r.distance*o*t.scaleFactor}else{const e=(c-.6-r.holdTime)/(.4-r.holdTime);d=n.homeRadius+Math.cos(e*Math.PI*.5)*r.distance*o*t.scaleFactor}else{const e=c;d=n.homeRadius+e*r.distance*o*t.scaleFactor}if(void 0!==d){n.turbulencePhase+=r.turbulence*s;const t=Math.sin(n.turbulencePhase)*r.turbulence*10,e=Math.cos(1.3*n.turbulencePhase)*r.turbulence*10,i=n.driftAngle+n.angleOffset;u=a+Math.cos(i)*d+t,p=h+Math.sin(i)*d+e}const f=r.smoothness+.08*n.role;if(t.x+=(u-t.x)*f,t.y+=(p-t.y)*f,t.vx=.25*(u-t.x),t.vy=.25*(p-t.y),r.fadeOut){let i;i=e<.25?.3+e/.25*.7:e<.75?.7+.3*Math.sin((e-.25)*Math.PI/.5):4*(1-e),t.opacity=n.baseOpacity*i,void 0!==t.life&&(t.life=t.opacity)}e>=.99&&(t.vx=.1*n.originalVx,t.vy=.1*n.originalVy,r.fadeOut&&(t.opacity=n.baseOpacity,void 0!==t.life&&(t.life=n.baseOpacity)))},cleanup(t){if(t.gestureData?.drift){const e=t.gestureData.drift;t.vx=e.originalVx,t.vy=e.originalVy,t.opacity=e.baseOpacity,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.drift}},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutQuad:t=>t*(2-t),"3d":{evaluate(t,e){const i={...this.config,...e},s=e.strength||1,a=(i.angle||45)*Math.PI/180,h=i.returnToOrigin?t<.5?2*t:2*(1-t):t;return{position:[Math.cos(a)*h*.3*s,Math.sin(a)*h*.3*s,.15*Math.sin(t*Math.PI)*s],rotation:[0,10*h*s,0],scale:1+.03*Math.sin(t*Math.PI),glowIntensity:1-.1*h}}}},It={name:"burst",emoji:"๐ฅ",type:"blending",description:"Explosive outward burst from center",config:{decay:.5,strength:2},rhythm:{enabled:!0,syncMode:"beat",strengthSync:{onBeat:3.5,offBeat:1,curve:"explosion"},decaySync:{mode:"tempo",fast:.8,slow:.3,curve:"exponential"},durationSync:{mode:"beats",beats:.5,sustain:!1},accentResponse:{enabled:!0,multiplier:2.5,type:"strength"},patternOverrides:{rock:{strengthSync:{onBeat:4,offBeat:1.5},decaySync:{fast:.6,slow:.4}},electronic:{strengthSync:{onBeat:3.8,offBeat:.8,curve:"sharp"},decaySync:{fast:.9,slow:.7}},jazz:{strengthSync:{onBeat:2.8,offBeat:1.8,swing:!0},decaySync:{fast:.5,slow:.2}},orchestral:{strengthSync:{onBeat:3.2,offBeat:.5},accentResponse:{multiplier:3}}},dynamics:{forte:{strengthSync:{onBeat:{multiplier:2},offBeat:{multiplier:1.5}},decaySync:{multiplier:.7},accentResponse:{multiplier:3.5}},piano:{strengthSync:{onBeat:{multiplier:.6},offBeat:{multiplier:.3}},decaySync:{multiplier:1.3},accentResponse:{multiplier:1.8}}}},apply(t,e,i,s,a,h){const n=i.decay||this.config.decay,r=(i.strength||this.config.strength)*(1-e*n),o=t.x-a,l=t.y-h,c=Math.sqrt(o*o+l*l);c>1&&(t.vx+=o/c*r*2*s,t.vy+=l/c*r*2*s)},"3d":{evaluate(t,e){const i=e.strength||2;let s=0,a=1,h=1,n=0;if(t<.15){const e=t/.15,r=1-Math.pow(1-e,3);s=.15*r*i,a=1+.2*r*i,h=1+.5*r,n=.4*r}else if(t<.35){const e=(t-.15)/.2;s=.15*(1-1.5*e)*i,a=1+.2*(1-e)*i-.1*Math.sin(e*Math.PI),h=1+.4*(1-e),n=.2*(1-e)}else{const e=(t-.35)/.65,n=Math.pow(1-e,2),r=Math.sin(e*Math.PI*2)*n;s=.03*r*i,a=1+.05*r,h=1+.15*Math.abs(r)}return{cameraRelativePosition:[0,0,s],position:[0,0,0],rotation:[0,0,0],scale:a,glowIntensity:h,glowBoost:n}}}},jt={name:"wave",emoji:"๐",type:"override",description:"Infinity pattern flow with phasing",config:{musicalDuration:{musical:!0,bars:1,minBeats:4,maxBeats:16},phases:[{name:"gather",beats:.5},{name:"rise",beats:.5},{name:"waveLeft",beats:1},{name:"waveRight",beats:1},{name:"settle",beats:1}],amplitude:40,frequency:1,phaseShift:.3,liftHeight:20,fadeInOut:!0,smoothness:.1,easing:"sine",strength:1,particleMotion:{type:"wave",strength:1,amplitude:50}},rhythm:{enabled:!0,syncMode:"wave",amplitudeSync:{onWave:65,onStatic:25,curve:"flowing"},frequencySync:{mode:"phrase",slow:.7,fast:1.8,curve:"melodic"},durationSync:{mode:"bars",adaptToPhrase:!0,sustain:!0},phaseSync:{enabled:!0,multiplier:.5,type:"ensemble"},melodicResponse:{enabled:!0,multiplier:1.4,type:"amplitude"},patternOverrides:{ambient:{amplitudeSync:{onWave:80,onStatic:40,curve:"hypnotic"},frequencySync:{slow:.5,fast:1.2},durationSync:{minBeats:16,maxBeats:64}},ocean:{amplitudeSync:{onWave:90,onStatic:20,curve:"natural"},phaseSync:{multiplier:.8},melodicResponse:{multiplier:1.8}},electronic:{amplitudeSync:{onWave:70,onStatic:30,curve:"digital"},frequencySync:{slow:.8,fast:2.5,curve:"precise"}},orchestral:{amplitudeSync:{onWave:75,onStatic:35},phaseSync:{multiplier:.7},melodicResponse:{multiplier:2}}},dynamics:{forte:{amplitudeSync:{onWave:{multiplier:1.8},onStatic:{multiplier:1.4}},frequencySync:{multiplier:1.3},melodicResponse:{multiplier:2.2}},piano:{amplitudeSync:{onWave:{multiplier:.6},onStatic:{multiplier:.4}},frequencySync:{multiplier:.7},melodicResponse:{multiplier:1.1}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s,n=Math.atan2(h,a),r=Math.sqrt(a*a+h*h),o=Math.random()<.5?1:-1;t.gestureData.wave={startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,baseOpacity:t.opacity||t.life||1,angle:n,radius:r,offset:Math.random()*Math.PI*2,role:Math.random(),direction:o,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.wave?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.wave,r={...this.config,...i},o=i.strength||1,l=this.easeInOutSine(e),c=n.role*r.phaseShift,u=Math.max(0,l-c),p=u*Math.PI*2*r.frequency*n.direction+n.offset,d=.5+n.radius/100*.5,f=r.amplitude*d*o*t.scaleFactor,m=a+Math.sin(p)*f,M=h+Math.sin(2*p)*f*.3+-Math.abs(Math.sin(l*Math.PI))*r.liftHeight*t.scaleFactor,g=r.smoothness+.12*n.role;if(t.x+=(m-t.x)*g,t.y+=(M-t.y)*g,t.vx=.3*(m-t.x),t.vy=.3*(M-t.y),r.fadeInOut){let e;e=u<.1?u/.1:u>.9?(1-u)/.1:.5+.5*Math.sin(u*Math.PI),t.opacity=n.baseOpacity*(.3+.7*e),void 0!==t.life&&(t.life=t.opacity)}if(e>=.95){const i=20*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i),r.fadeInOut&&(t.opacity=n.baseOpacity*i,void 0!==t.life&&(t.life=t.opacity))}},cleanup(t){if(t.gestureData?.wave){const e=t.gestureData.wave;t.vx=e.originalVx,t.vy=e.originalVy,t.opacity=e.baseOpacity,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.wave}},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i=e?.strength||1,s=e?.frequency||1,a=-(Math.cos(Math.PI*t)-1)/2,h=a*Math.PI*2*s,n=.12*Math.sin(h)*i,r=.06*Math.sin(2*h)*i,o=.03*Math.sin(h)*i,l=.08*Math.sin(2*h)*i,c=.05*Math.sin(h)*i,u=1+.08*Math.abs(Math.sin(a*Math.PI))*i,p=Math.abs(Math.sin(h));return{position:[n,r,o],rotation:[l,0,c],scale:u,glowIntensity:1+.3*p*i,glowBoost:.6*p*i}}}},$t={name:"flash",emoji:"โก",type:"blending",description:"Bright flash burst effect",config:{duration:400,glowAmount:2.5,glowPeak:3,scalePeak:1.1,easing:"cubic",strength:1,particleMotion:{type:"burst",strength:1,decay:.3}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"immediate",interruptible:!0,priority:8,blendable:!0,intensitySync:{onBeat:3.5,offBeat:1,accent:5,subdivision:"quarter",curve:"exponential"},durationSync:{mode:"tempo",baseDuration:400,scaling:"inverse"},scaleSync:{onBeat:1.2,offBeat:1,accent:1.4,curve:"elastic"},strobeSync:{enabled:!1,pattern:"XXOX",subdivision:"sixteenth"},dynamics:{forte:{glowPeak:4,scalePeak:1.3,duration:300},piano:{glowPeak:2,scalePeak:1.05,duration:500}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.flash={originalOpacity:t.opacity,originalSize:t.size,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.flash?.initialized||this.initialize(t,i);const n=t.gestureData.flash,r={...this.config,...i},o=r.strength||1;let l;if(l=e<.3?e/.3*r.glowPeak:r.glowPeak*(1-(e-.3)/.7),t.opacity=Math.min(1,n.originalOpacity*(1+l*o)),t.size=n.originalSize*(1+(r.scalePeak-1)*l*o*.1),e<.2){const i=(1-e/.2)*o,n=Math.atan2(t.y-h,t.x-a);t.vx+=Math.cos(n)*i*2*s,t.vy+=Math.sin(n)*i*2*s}t.vx*=1-.1*r.particleMotion.decay,t.vy*=1-.1*r.particleMotion.decay},cleanup(t){t.gestureData?.flash&&(t.opacity=t.gestureData.flash.originalOpacity,t.size=t.gestureData.flash.originalSize,delete t.gestureData.flash)},"3d":{evaluate(t,e){let i;i=t<.3?t/.3:1-(t-.3)/.7;const s=1+.4*i;return{position:[0,0,0],rotation:[0,0,0],scale:1+i*(({...this.config,...e}.scalePeak||1.1)-1),glowIntensity:s,glowBoost:2*i}}}},Gt={name:"glow",emoji:"โจ",type:"blending",description:"Pure luminous glow without movement",config:{duration:1500,amplitude:0,frequency:1,holdPeak:.3,easing:"sine",scaleAmount:.1,glowAmount:.8,strength:0,direction:"none",particleMotion:{type:"glow",strength:0,direction:"none",frequency:1}},rhythm:{enabled:!0,syncMode:"phrase",amplitudeSync:{onBeat:2,offBeat:1.2,curve:"smooth"},frequencySync:{mode:"phrase",subdivision:"bar"},durationSync:{mode:"bars",bars:2},accentResponse:{enabled:!0,multiplier:2.5},patternOverrides:{ambient:{amplitudeSync:{onBeat:2.5,offBeat:1.8},durationSync:{bars:4}},electronic:{amplitudeSync:{onBeat:3,offBeat:.5,curve:"sharp"},frequencySync:{subdivision:"quarter"}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={}),t.gestureData.glow={startOpacity:t.opacity,startGlow:t.glowSizeMultiplier||0,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.glow?.initialized||this.initialize(t,i,a,h);const n={...this.config,...i},r=this.easeInOutSine(e);let o,{frequency:l}=n,{glowAmount:c}=n;i.rhythmModulation&&(c*=i.rhythmModulation.amplitudeMultiplier||1,c*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(l*=i.rhythmModulation.frequencyMultiplier));const u=r*l*2%2;o=n.holdPeak>0&&u>1-n.holdPeak&&u<1+n.holdPeak?1:Math.sin(r*Math.PI*2*l);let p=1;e>.9&&(p=.5+.5*(1-10*(e-.9))),t.glowIntensity=1+o*c*p},cleanup(t){t.gestureData?.glow&&(t.glowIntensity=1,delete t.gestureData.glow)},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i={...this.config,...e},s=-(Math.cos(Math.PI*t)-1)/2,a=Math.sin(s*Math.PI);let h=i.glowAmount||.8;e.rhythmModulation&&(h*=e.rhythmModulation.amplitudeMultiplier||1,h*=e.rhythmModulation.accentMultiplier||1);const n=1+a*h;return{position:[0,0,0],rotation:[0,0,0],scale:1+a*(i.scaleAmount||.1)*.5,glowIntensity:n,glowBoost:1.5*a}}}},qt={name:"flicker",emoji:"โก",type:"blending",description:"Rapid opacity changes with motion jitter",config:{duration:800,musicalDuration:{musical:!0,beats:2},flickerRate:15,frequency:6,minOpacity:.3,maxOpacity:1,jitterAmount:2,colorShift:!1,strobe:!1,pulseMode:!1,groupFlicker:.3,easing:"linear",strength:.7,particleMotion:{type:"flicker",strength:.7,frequency:6}},rhythm:{enabled:!0,syncMode:"subdivision",durationSync:{mode:"beats",beats:2},rateSync:{subdivision:"sixteenth",onBeat:30,offBeat:10,triplet:20,curve:"step"},opacitySync:{pattern:"HLMH",subdivision:"eighth",onAccent:.1,regular:.5},jitterSync:{onBeat:5,offBeat:1,accent:10,curve:"random"},strobeSync:{verse:!1,chorus:!0,drop:"intense",pattern:"XOXO"},dynamics:{forte:{flickerRate:25,jitterAmount:5,minOpacity:.1},piano:{flickerRate:8,jitterAmount:1,minOpacity:.5}}},initialize(t,e){t.gestureData||(t.gestureData={});const i={...this.config,...e},s=Math.random()<i.groupFlicker;t.gestureData.flicker={baseOpacity:t.opacity||t.life||1,baseColor:t.color,baseX:t.x,baseY:t.y,flickerTimer:0,lastFlicker:0,flickerState:!0,isGrouped:s,groupId:s?Math.floor(3*Math.random()):-1,phase:Math.random()*Math.PI*2,colorHue:0,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.flicker?.initialized||this.initialize(t,i);const n=t.gestureData.flicker,r={...this.config,...i},o=i.strength||1;let l;if(n.flickerTimer+=s*r.flickerRate,r.strobe)l=(n.flickerTimer+n.phase)%1<.5?1:r.minOpacity;else if(r.pulseMode){const t=n.flickerTimer+n.phase;l=r.minOpacity+(r.maxOpacity-r.minOpacity)*(.5*Math.sin(t)+.5)}else{if(n.flickerTimer-n.lastFlicker>1)if(n.lastFlicker=n.flickerTimer,n.isGrouped){const t=Math.floor(n.flickerTimer)%3;n.flickerState=t===n.groupId}else n.flickerState=Math.random()>.3;const e=n.flickerState?r.maxOpacity:r.minOpacity+.3*Math.random(),i=t.opacity/n.baseOpacity;l=i+.3*(e-i)}const c=n.baseOpacity*(1+(l-1)*o);if(t.opacity=Math.max(0,Math.min(1,c)),void 0!==t.life&&(t.life=t.opacity),r.jitterAmount>0&&l>r.minOpacity){const e=r.jitterAmount*o*t.scaleFactor,i=(Math.random()-.5)*e*l,a=(Math.random()-.5)*e*l;t.vx+=.1*i*s,t.vy+=.1*a*s}if(r.colorShift&&t.color){n.colorHue+=.01*s;const e=30*Math.sin(n.colorHue);t.color=this.shiftHue(n.baseColor,e*o)}let u=1;e<.1?u=e/.1:e>.9&&(u=(1-e)/.1),t.opacity*=u,void 0!==t.life&&(t.life=t.opacity),e>.8&&(t.vx*=.95,t.vy*=.95)},shiftHue(t,e){if(!t||!t.startsWith("#"))return t;const i=t.slice(1),s=parseInt(i.substr(0,2),16)/255,a=parseInt(i.substr(2,2),16)/255,h=parseInt(i.substr(4,2),16)/255,n=e*Math.PI/180,r=Math.cos(n),o=Math.sin(n),l=s*o+a*r,c=h,u=t=>Math.max(0,Math.min(255,Math.round(255*t))).toString(16).padStart(2,"0");return`#${u(s*r-a*o)}${u(l)}${u(c)}`},cleanup(t){if(t.gestureData?.flicker){const e=t.gestureData.flicker;t.opacity=e.baseOpacity,t.color=e.baseColor,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.flicker}},"3d":{evaluate(t,e){const i=e.config||{},s=e.strength||.7,a=t*(i.flickerRate||15),h=Math.sin(a*Math.PI*2),n=Math.floor(10*a),r=.3*h+.5*(Math.sin(123.456*n)+1)*.7,o=.6+.8*r,l=i.jitterAmount||2,c=.003*s*o,u=(Math.random()-.5)*l*c,p=(Math.random()-.5)*l*c,d=.03*(Math.random()-.5)*s*o;return{position:[u,p,0],rotation:[.5*d,0,d],scale:1+.08*(o-1),glowIntensity:o,glowBoost:1.2*r}}}},Xt={name:"heartbeat",emoji:"๐",type:"effect",description:"Rhythmic double-pump heartbeat (lub-dub)",config:{duration:1e3,musicalDuration:{musical:!0,beats:2},lubStrength:.8,dubStrength:1,lubDubGap:.15,strength:1,particleMotion:{type:"heartbeat",strength:1}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:2},timingSync:"onBeat",amplitudeSync:{onBeat:1.2,offBeat:.8}},apply(t,e,i,s,a,h){const n={...this.config,...i},r=n.strength||1,o=this.R(e,n),l=t.x-a,c=t.y-h,u=Math.sqrt(l*l+c*c)||1,p=10*o*r;t.x+=l/u*p,t.y+=c/u*p},R(t,e){const i=e.lubDubGap||.15,s=e.lubStrength||.8,a=e.dubStrength||1;let h=0;const n=Math.abs(t-.1);n<.08&&(h=Math.cos(n/.08*Math.PI*.5)*s);const r=.1+i+.05,o=Math.abs(t-r);if(o<.1){const t=Math.cos(o/.1*Math.PI*.5)*a;h=Math.max(h,t)}return h},"3d":{evaluate(t,e){const i=e.config||this.config||{},s=i.strength||1,a=i.lubDubGap||.15,h=i.lubStrength||.8,n=i.dubStrength||1;let r=0;const o=Math.abs(t-.1);o<.08&&(r=Math.cos(o/.08*Math.PI*.5)*h);const l=.1+a+.05,c=Math.abs(t-l);if(c<.1){const t=Math.cos(c/.1*Math.PI*.5)*n;r=Math.max(r,t)}return{position:[0,0,.03*r*s],rotation:[0,0,0],scale:1+.15*r*s,glowIntensity:1+.5*r*s,glowBoost:.8*r*s}}}},Yt={name:"fade",emoji:"๐ป",type:"blending",description:"Fade particle opacity",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},fadeIn:!0,fadeOut:!0,minOpacity:0,maxOpacity:1},rhythm:{enabled:!0,syncMode:"dynamic",durationSync:{mode:"bars",bars:1},opacitySync:{onBeat:.9,offBeat:.3,subdivision:"eighth",curve:"exponential"},fadePhaseSync:{verse:{fadeIn:!0,fadeOut:!1},chorus:{fadeIn:!1,fadeOut:!1},bridge:{fadeIn:!0,fadeOut:!0},outro:{fadeIn:!1,fadeOut:!0}},pulseSync:{enabled:!0,frequency:"quarter",intensity:.2,onAccent:.4},dynamics:{forte:{minOpacity:.5,maxOpacity:1},piano:{minOpacity:0,maxOpacity:.4}}},initialize(t){t.gestureData||(t.gestureData={}),t.gestureData.fade={baseOpacity:t.opacity||t.life||1}},apply(t,e,i,s,a,h){t.gestureData?.fade||this.initialize(t);const n=t.gestureData.fade,r={...this.config,...i};let o;o=r.fadeIn&&!r.fadeOut?r.minOpacity+(r.maxOpacity-r.minOpacity)*e:r.fadeOut&&!r.fadeIn?r.maxOpacity-(r.maxOpacity-r.minOpacity)*e:e<.5?r.minOpacity+(r.maxOpacity-r.minOpacity)*(2*e):r.maxOpacity-(r.maxOpacity-r.minOpacity)*(2*(e-.5)),t.opacity=n.baseOpacity*o,void 0!==t.life&&(t.life=t.opacity)},cleanup(t){t.gestureData?.fade&&(t.opacity=t.gestureData.fade.baseOpacity,void 0!==t.life&&(t.life=t.opacity),delete t.gestureData.fade)},"3d":{evaluate(t,e){const i={...this?.config||{},...e},s=i.fadeIn??!0,a=i.fadeOut??!0;let h;h=s&&!a?t:a&&!s?1-t:t<.5?1-t/.5:(t-.5)/.5;const n=h*h*(3-2*h);return{position:[0,0,0],rotation:[0,0,0],scale:.01+.99*n,glowIntensity:n,glowBoost:0}}}};const Ht={},_t=[],Lt=[],Wt=[];function Ut(t,e){Ht[t.name]=t,e.push(t.name)}[Tt,xt,vt,St,Ft,kt,Bt,Ot,Ct,{name:"sparkle",emoji:"โจ",type:"blending",description:"Bright twinkling sparkle bursts",config:{duration:800,musicalDuration:{musical:!0,beats:2}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",durationSync:{mode:"beats",beats:2},interruptible:!0,priority:5,blendable:!0},apply:(t,e,i)=>!1,blend:(t,e,i)=>!1,"3d":{evaluate(t,e){const i=e?.strength||1,s=Math.pow(Math.max(0,Math.sin(t*Math.PI*6)),3),a=Math.pow(Math.max(0,Math.sin(t*Math.PI*8+1)),3),h=Math.pow(Math.max(0,Math.sin(t*Math.PI*10+2)),3),n=Math.max(s,a,h)*Math.sin(t*Math.PI);return{position:[0,0,0],rotation:[0,0,0],scale:1+.08*n*i,glowIntensity:1+.5*n*i,glowBoost:2*n*i}}}},{name:"shimmer",emoji:"๐",type:"particle",description:"Shimmer effect with sparkling particles",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},particleMotion:"radiant"},rhythm:{enabled:!0,syncType:"beat",durationSync:{mode:"bars",bars:1},intensity:.8},override:(t,e,i)=>(t.shimmerEffect=!0,t.shimmerProgress=e,!0),blend:(t,e,i)=>!1,"3d":{evaluate(t,e){const i=e?.strength||1,s=(.4*Math.sin(t*Math.PI*4)+.35*Math.sin(t*Math.PI*6+.5)+.25*Math.sin(t*Math.PI*10+1)+1)/2;return{position:[0,0,0],rotation:[0,0,0],scale:1+.05*s*i,glowIntensity:1+.3*s*i,glowBoost:1*s*i}}}},Rt,zt].forEach(t=>Ut(t,_t)),[Pt,At,Dt].forEach(t=>Ut(t,Lt)),[jt,Et,qt,It,$t,Gt,Xt,Yt].forEach(t=>Ut(t,Wt));const Vt={blending:_t,override:Lt,effect:Wt},Nt={};function Qt(t){return Ht[t]?Ht[t]:bt(t)||null}Object.entries(Vt).forEach(([t,e])=>{e.forEach(e=>{Nt[e]=t})});class Jt{constructor(t,e,i="ambient",s=1,a=1,h=null){const n=Math.random();this.z=n<1/13?.5+.5*Math.random():.9*Math.random()-1;const r=this.z>0?(20+20*Math.random())*s:3*s,o=Math.random()*Math.PI*2;this.x=t+Math.cos(o)*r,this.y=e+Math.sin(o)*r,this.vx=0,this.vy=0,this.vz=0,this.life=0,this.maxLife=1,this.lifeDecay=.01,this.fadeInTime=.15,this.fadeOutTime=.3,this.isFadingOut=!1,this.age=0,this.scaleFactor=s,this.particleSizeMultiplier=a,this.size=(4+6*Math.random())*s*a,this.baseSize=this.size,this.emotionColors=h,this.color="#ffffff",this.opacity=1,this.hasGlow=Math.random()<.333,this.glowSizeMultiplier=this.hasGlow?1.33+.33*Math.random():0,this.isCellShaded=Math.random()<.333,this.baseOpacity=.3+.4*Math.random(),this.cachedColors=new Map,this.maxCachedColors=20,this.colorAccessOrder=[],this.lastColor=null,this.lastOpacity=-1,this.behavior=i,this.behaviorData={},this.gestureData={initialX:t,initialY:e},gt(this,i)}update(t,e,i,s=null,a=null,h=0,n=null){const r=Math.min(t,50)/q,o=a&&a.type&&h>0&&function(t){const e=Qt(t);return!!e&&"override"===e.type}(a.type),l=this.rainData||"falling"===this.gestureBehavior||this.fallingData||this.gestureData?.rain,c=o||l;if(c||(this.x+=this.vx*r,this.y+=this.vy*r),!c){let t,s;if(n)t=n.width,s=n.height;else{const a=document.getElementById("card-mascot")||document.getElementById("cherokee-guide-mascot")||document.querySelector("canvas");t=a?a.width:2*e,s=a?a.height:2*i}const a=20,h=e-t/2+a,r=e+t/2+a,o=i-s/2+a,l=i+s/2-a;this.x-this.size<h?(this.x=h+this.size,this.vx=.5*Math.abs(this.vx)):this.x+this.size>r&&(this.x=r-this.size,this.vx=.5*-Math.abs(this.vx)),this.y-this.size<o?(this.y=o+this.size,this.vy=.5*Math.abs(this.vy)):this.y+this.size>l&&(this.y=l-this.size,this.vy=.5*-Math.abs(this.vy))}this.age+=this.lifeDecay*r,this.age<this.fadeInTime?this.life=this.age/this.fadeInTime:this.age<1-this.fadeOutTime?this.life=1:(this.life=(1-this.age)/this.fadeOutTime,this.isFadingOut=!0,"popcorn"===this.behavior&&(this.size=this.baseSize*(.5+.5*this.life))),this.life=Math.max(0,Math.min(1,this.life)),"falling"===this.behavior?this.opacity=this.life:this.opacity=this.easeInOutCubic(this.life),"burst"===this.behavior&&this.behaviorData&&this.life<this.behaviorData.fadeStart&&(this.size=this.baseSize*(this.life/this.behaviorData.fadeStart))}applyUndertoneModifier(t,e){}applyGestureMotion(t,e,i,s,a){!function(t,e,i,s,a,h){if(!i||!i.type||s>=1)return;t.gestureData||(t.gestureData={originalVx:t.vx,originalVy:t.vy,initialX:t.x,initialY:t.y,startAngle:Math.atan2(t.y-h,t.x-a),startRadius:Math.sqrt(Math.pow(t.x-a,2)+Math.pow(t.y-h,2))});const n=Qt(i.type);if(!n)return;let r=i;if(Y.isEnabled()&&n.rhythm?.enabled){const a=Y.applyGestureRhythm(n,t,s,e);r={...i,amplitude:(i.amplitude||1)*(a.amplitudeMultiplier||1)*(a.accentMultiplier||1),wobbleAmount:(i.wobbleAmount||0)*(a.wobbleMultiplier||1),rhythmModulation:a}}n.apply&&n.apply(t,s,r,e,a,h),s>=.99&&n.cleanup&&(n.cleanup(t),t.gestureData=null)}(this,i,t,e,s,a)}isOutOfBounds(t,e){return this.x<-50||this.x>t+50||this.y<-50||this.y>e+50}isAlive(){return this.life>0}setOutwardVelocity(t){if(this.behaviorData&&void 0!==this.behaviorData.outwardSpeed){const e=this.behaviorData.outwardSpeed;this.vx=Math.cos(t)*e,this.vy=Math.sin(t)*e+(this.behaviorData.upwardBias||0)}}getDepthAdjustedSize(){const t=1+.2*this.z;return this.size*t}getState(){return{position:{x:this.x,y:this.y,z:this.z},velocity:{x:this.vx,y:this.vy,z:this.vz},life:this.life,behavior:this.behavior,size:this.size,opacity:this.opacity}}reset(t,e,i="ambient",s=1,a=1,h=null){const n=Math.random();this.z=n<1/13?.5+.5*Math.random():.9*Math.random()-1;const r=this.z>0?(20+20*Math.random())*s:3*s,o=Math.random()*Math.PI*2;if(this.x=t+Math.cos(o)*r,this.y=e+Math.sin(o)*r,this.vx=0,this.vy=0,this.vz=0,this.life=0,this.age=0,this.scaleFactor=s,this.particleSizeMultiplier=a,this.size=(4+6*Math.random())*s*a,this.baseSize=this.size,this.emotionColors=h,this.cachedColors.clear(),this.colorAccessOrder=[],this.opacity=0,this.isFadingOut=!1,this.baseOpacity=.3+.4*Math.random(),this.color="#ffffff",this.behavior=i,this.gestureData=null,this.behaviorData)for(const t in this.behaviorData)delete this.behaviorData[t];else this.behaviorData={};gt(this,i)}getCachedColor(t,e){const i=Math.round(100*e)/100,s=`${t}_${i}`;if(this.cachedColors.has(s)){const t=this.colorAccessOrder.indexOf(s);-1!==t&&this.colorAccessOrder.splice(t,1),this.colorAccessOrder.push(s)}else{if(this.cachedColors.size>=this.maxCachedColors){const t=this.colorAccessOrder.shift();this.cachedColors.delete(t)}this.cachedColors.set(s,this.hexToRgba(t,i)),this.colorAccessOrder.push(s)}return this.cachedColors.get(s)}hexToRgba(t,e){const i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${e})`:`rgba(255, 255, 255, ${e})`}easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}render(t,e="#ffffff"){if(this.life<=0)return;if(!isFinite(this.x)||!isFinite(this.y))return;const i=this.x,s=this.y,a=Math.max(.1,this.size),h=this.tempColor||this.color||e;if(t.save(),this.isCellShaded){t.strokeStyle=this.getCachedColor(h,.9*this.opacity),t.lineWidth=2,t.beginPath(),t.arc(i,s,a,0,2*Math.PI),t.stroke();const e=Math.floor(3*this.opacity)/3;t.fillStyle=this.getCachedColor(h,e*(this.baseOpacity||.5)*.5),t.beginPath(),t.arc(i,s,Math.max(.1,a-1),0,2*Math.PI),t.fill(),e>.5&&(t.fillStyle=this.getCachedColor("#FFFFFF",.3),t.beginPath(),t.arc(i-.3*a,s-.3*a,.3*a,0,2*Math.PI),t.fill())}else{const e=t.createRadialGradient(i,s,0,i,s,a);if(e.addColorStop(0,this.getCachedColor(h,this.opacity*(this.baseOpacity||.5))),e.addColorStop(.5,this.getCachedColor(h,this.opacity*(this.baseOpacity||.5)*.5)),e.addColorStop(1,this.getCachedColor(h,0)),t.fillStyle=e,t.beginPath(),t.arc(i,s,a,0,2*Math.PI),t.fill(),this.hasGlow&&this.glowSizeMultiplier>0){const e=a*this.glowSizeMultiplier,n=t.createRadialGradient(i,s,.5*a,i,s,e),r=.3,o=Math.max(r,this.opacity),l=Math.min(1,this.glowSizeMultiplier/3);n.addColorStop(0,this.getCachedColor(h,Math.max(.5,.8*o)*l)),n.addColorStop(.25,this.getCachedColor(h,Math.max(.3,.6*o)*l)),n.addColorStop(.5,this.getCachedColor(h,Math.max(.2,.4*o)*l)),n.addColorStop(.75,this.getCachedColor(h,Math.max(.1,.2*o)*l)),n.addColorStop(1,this.getCachedColor(h,0)),t.save(),t.globalCompositeOperation="screen",t.fillStyle=n,t.beginPath(),t.arc(i,s,e,0,2*Math.PI),t.fill(),t.restore()}}t.restore()}}class Zt{constructor(t=50){this.poolSize=Math.min(t,50),this.pool=[],this.totalParticlesCreated=0,this.totalParticlesDestroyed=0,this.poolHits=0,this.poolMisses=0}getParticle(t,e,i,s,a,h,n,r=null){let o;return this.pool.length>0?(o=this.pool.pop(),o.reset(t,e,i,s,a,h),this.poolHits++):(o=new Jt(t,e,i,s,a,h),this.poolMisses++,this.totalParticlesCreated++),o.emotion=n,r&&(o.gestureBehavior=r),o}returnParticle(t){if(this.pool.length<this.poolSize){if(t.cachedGradient=null,t.cachedGradientKey=null,t.behaviorData)for(const e in t.behaviorData)delete t.behaviorData[e];this.pool.push(t)}else this.totalParticlesDestroyed++}refreshPool(){const t=this.pool.length-this.poolSize;t>0&&(this.pool.splice(this.poolSize),this.totalParticlesDestroyed+=t)}getStats(){return{poolSize:this.pool.length,poolHits:this.poolHits,poolMisses:this.poolMisses,totalCreated:this.totalParticlesCreated,totalDestroyed:this.totalParticlesDestroyed}}clear(){this.pool=[],this.poolHits=0,this.poolMisses=0,this.totalParticlesCreated=0,this.totalParticlesDestroyed=0}}class Kt{constructor(){this.spawnAccumulator=0}getSpawnPosition(t,e,i,s,a,h=null){const n=Math.min(s,a)/12,r=2.5*n,o=1.1*r,l=Math.min(e-30,s-e-30),c=Math.min(i-30,a-i-30),u=Math.min(1.5*r,l,c);switch(t){case"ambient":case"resting":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"ascending":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"rising":{const t=Math.random()*Math.PI*2,s=o+Math.random()*(u-o);return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"falling":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"aggressive":{const t=Math.random()*Math.PI*2,s=r+Math.random()*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"scattering":default:return{x:e,y:i};case"burst":{const t=Math.random()*Math.PI*2;if("suspicion"===h){const s=1.5*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}if("surprise"===h){const s=1.2*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}return{x:e,y:i}}case"repelling":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"orbiting":{const t=Math.random()*Math.PI*2,s=1.2*r+Math.random()*r*.5;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"glitchy":{const t=Math.random()*Math.PI*2,s=3*r+Math.random()*r*4;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"spaz":{const t=Math.random()*Math.PI*2,s=2*r+Math.random()*r*3;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}}}clampToCanvas(t,e,i,s,a=30){return{x:Math.max(a,Math.min(i-a,t)),y:Math.max(a,Math.min(s-a,e))}}calculateSpawnRate(t,e){if(t<=0)return 0;const i=Math.min(e,50),s=t/1e3;this.spawnAccumulator+=s*i,this.spawnAccumulator=Math.min(this.spawnAccumulator,3);let a=0;for(;this.spawnAccumulator>=1;)a++,this.spawnAccumulator-=1;return a}resetAccumulator(){this.spawnAccumulator=0}}class te{render(t,e,i="#ffffff",s=null){const a=[];for(const t of e)t.life<=0||a.push(t);this.T(t,a,i,s)}renderLayer(t,e,i="#ffffff",s=!1,a=null){const h=[],n=t.canvas.width,r=t.canvas.height;for(const t of e)t.z>=0===s&&(t.x<-50||t.x>n+50||t.y<-50||t.y>r+50||t.life<=0||h.push(t));return h.sort((t,e)=>t.isCellShaded!==e.isCellShaded?t.isCellShaded?-1:1:t.hasGlow!==e.hasGlow?t.hasGlow?-1:1:0),this.T(t,h,i,a),h}T(t,e,i,s=null){t.save();let a=null;for(const h of e)if(h.isCellShaded)h.render(t,i),a=null;else{const e=h.color||i;if(e!==a&&(t.fillStyle=e,a=e),!isFinite(h.x)||!isFinite(h.y))continue;const n=h.getDepthAdjustedSize?h.getDepthAdjustedSize():h.size;let r=Math.max(.1,n),o=1;if(s&&s.fireflyEffect){const t=(.01*h.x+.01*h.y+.1*h.size)%(2*Math.PI),e=s.fireflyTime||.001*Date.now(),i=s.particleGlow||2;o=.3+Math.max(0,Math.sin(3*e+t))*i}if(s&&s.flickerEffect){const t=(.02*h.x+.02*h.y)%(2*Math.PI),e=s.flickerTime||.001*Date.now(),i=s.particleGlow||2;o=.5+Math.sin(12*e+t)*i*.5}if(s&&s.shimmerEffect){const e=h.x-t.canvas.width/2,i=h.y-t.canvas.height/2,a=Math.sqrt(e*e+i*i)/200,n=s.shimmerTime||.001*Date.now(),r=s.shimmerWave||0,l=s.particleGlow||1.2;o=1+.15*Math.sin(3*n-a+r)*l}if(s&&s.glowEffect){const e=s.glowProgress||0,i=s.particleGlow||2,a=h.x-t.canvas.width/2,n=h.y-t.canvas.height/2,o=Math.sqrt(a*a+n*n)/300,l=Math.min(.3*o,.5),c=Math.max(0,(e-l)/(1-l)),u=Math.sin(c*Math.PI);h.P||(h.P={hasGlow:h.hasGlow,glowSizeMultiplier:h.glowSizeMultiplier||0}),h.hasGlow=!0,h.glowSizeMultiplier=Math.max(3,h.P.glowSizeMultiplier)+u*i*3,r*=1+.3*u,e>=.99&&h.P&&(h.hasGlow=h.P.hasGlow,h.glowSizeMultiplier=h.P.glowSizeMultiplier,delete h.P)}if(h.hasGlow||o>1){const e=Math.max(.1,r*(h.glowSizeMultiplier||1.5)*o),i=t.globalCompositeOperation;t.globalCompositeOperation="screen",t.globalAlpha=.15*h.opacity*o,t.beginPath(),t.arc(h.x,h.y,e,0,2*Math.PI),t.fill(),t.globalAlpha=.25*h.opacity*o,t.beginPath(),t.arc(h.x,h.y,.6*e,0,2*Math.PI),t.fill(),t.globalCompositeOperation=i}t.globalAlpha=h.opacity*(h.baseOpacity||.5)*.6*Math.min(2,o),t.beginPath(),t.arc(h.x,h.y,r,0,2*Math.PI),t.fill()}t.restore()}}class ee{constructor(t=50,e=null){this.errorBoundary=e,this.maxParticles=t,this.absoluteMaxParticles=2*t,this.particles=[],this.particlePool=new Zt(t),this.particleSpawner=new Kt,this.particleRenderer=new te,this.containmentBounds=null,this.stateChangeCount=0,this.lastMemoryCheck=Date.now(),this.lastLeakedCount=0,this.particleCount=0,this.cleanupTimer=0,this.cleanupInterval=5e3}get pool(){return this.particlePool.pool}get poolSize(){return this.particlePool.poolSize}get poolHits(){return this.particlePool.poolHits}get poolMisses(){return this.particlePool.poolMisses}get totalParticlesCreated(){return this.particlePool.totalParticlesCreated}get totalParticlesDestroyed(){return this.particlePool.totalParticlesDestroyed}get spawnAccumulator(){return this.particleSpawner.spawnAccumulator}set spawnAccumulator(t){this.particleSpawner.spawnAccumulator=t}getParticleFromPool(t,e,i){return this.particlePool.getParticle(t,e,i,this.scaleFactor||1,this.particleSizeMultiplier||1,this.currentEmotionColors,this.currentEmotion,this.gestureBehavior)}returnParticleToPool(t){this.particlePool.returnParticle(t)}spawn(t,e,i,s,a,h,n=null,r=0,o=10,l=1,c=1,u=null,p=null){if(this.scaleFactor=l,this.particleSizeMultiplier=c,this.errorBoundary)return this.errorBoundary.wrap(()=>{this.O(t,e,i,s,a,h,n,r,o,u,p)},"particle-spawn")();this.O(t,e,i,s,a,h,n,r,o,u,p)}resetAccumulator(){this.particleSpawner.resetAccumulator()}O(t,e,i,s,a,h,n,r=0,o=10,l=null,u=null){this.currentEmotion=e,this.baseEmotionColors=l,this.currentUndertone=u,this.currentEmotionColors=l&&u?function(t,e){return t&&Array.isArray(t)&&e&&"clear"!==e?t.map(t=>"string"==typeof t?c(t,e):t&&"object"==typeof t&&t.color?{...t,color:c(t.color,e)}:t):t}(l,u):l;let p=i;if(Y.isEnabled()){const i=$&&$.isInitialized?$.getEmotion(e):P(e);if(i){const e=Y.applyParticleRhythm(i,this);if(e.emitBurst)for(let i=0;i<e.emitBurst&&this.particles.length<o;i++)this.spawnSingleParticle(t,s,a);void 0!==e.emissionRate&&(p*=e.emissionRate)}}if(null!==n){for(let e=0;e<n&&this.particles.length<this.maxParticles;e++)this.spawnSingleParticle(t,s,a);return}if(this.skipSpawnThisFrame)return;for(;this.particles.length<r&&this.particles.length<this.maxParticles;)this.spawnSingleParticle(t,s,a);if(this.particles.length>=o)return;if(p<=0)return;const d=this.particleSpawner.calculateSpawnRate(p,h);for(let e=0;e<d&&this.particles.length<o;e++)this.spawnSingleParticle(t,s,a)}getSpawnPosition(t,e,i,s,a){return this.A||(this.A=!0),this.particleSpawner.getSpawnPosition(t,e,i,s,a,this.currentEmotion)}clampToCanvas(t,e,i,s,a=30){return this.D||(this.D=!0),this.particleSpawner.clampToCanvas(t,e,i,s,a)}spawnSingleParticle(t,e,i){if(this.particles.length>=this.absoluteMaxParticles)return;const s=this.canvasWidth||2*e,a=this.canvasHeight||2*i,h=this.particleSpawner.getSpawnPosition(t,e,i,s,a,this.currentEmotion),n=this.particleSpawner.clampToCanvas(h.x,h.y,s,a);h.x=n.x,h.y=n.y;const r=this.getParticleFromPool(h.x,h.y,t);"meditation_swirl"===t&&h.palmCenter&&(r.palmCenter=h.palmCenter,r.swirlAngle=h.swirlAngle),this.particles.push(r),this.particleCount++}update(t,e,i,s=null,a=0,h=null){if(this.errorBoundary)return this.errorBoundary.wrap((t,e,i,s,a,h)=>this.I(t,e,i,s,a,h),"particle-update")(t,e,i,s,a,h);this.I(t,e,i,s,a,h)}I(t,e,i,s=null,a=0,h=null){for(let n=this.particles.length-1;n>=0;n--)this.particles[n].update(t,e,i,h,s,a,this.containmentBounds),this.particles[n].isAlive()||this.removeParticle(n);for(;this.particles.length>this.maxParticles;)this.removeParticle(0)}setGestureBehavior(t,e){this.gestureBehavior=e?t:null,e?this.particles.forEach(e=>{e.gestureBehavior=t}):this.particles.forEach(t=>{t.gestureBehavior=null})}removeParticle(t){if(t>=0&&t<this.particles.length){const e=this.particles.splice(t,1)[0];e.cachedGradient=null,e.cachedGradientKey=null,this.returnParticleToPool(e),this.particleCount=Math.max(0,this.particleCount-1)}}render(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.j(t,e,i)},"particle-render")();this.j(t,e,i)}renderBackground(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.$(t,e,!1,i)},"particle-render-bg")();this.$(t,e,!1,i)}renderForeground(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.$(t,e,!0,i)},"particle-render-fg")();this.$(t,e,!0,i)}$(t,e,i,s=null){this.particleRenderer.renderLayer(t,this.particles,e,i,s)}j(t,e,i=null){this.particleRenderer.render(t,this.particles,e,i)}onVisibilityResume(t,e=null){if(this.resetAccumulator(),t>X)this.clear();else if(t>1e4){const t=this.particles.length,i=e??t,s=Math.max(10,Math.floor(.5*i));for(;this.particles.length>s;)this.removeParticle(0)}}clear(){for(this.stateChangeCount++;this.particles.length>0;){const t=this.particles.pop();if(t.cachedColors&&t.cachedColors.clear(),t.behaviorData)for(const e in t.behaviorData)delete t.behaviorData[e];this.pool.length<this.poolSize&&!this.pool.includes(t)&&this.pool.push(t)}if(this.particles.length=0,this.particleCount=0,this.spawnAccumulator=0,this.pool.length>this.poolSize){const t=this.pool.length-this.poolSize;this.pool.splice(this.poolSize,t)}}burst(t,e,i,s){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.G(t,e,i,s)},"particle-burst")();this.G(t,e,i,s)}G(t,e,i,s){const a=Math.min(t,this.maxParticles-this.particles.length);for(let t=0;t<a;t++)this.spawnSingleParticle(e,i,s)}performCleanup(){if(this.pool.length>this.poolSize){const t=this.pool.length-this.poolSize;for(let e=0;e<t;e++){const t=this.pool.pop();t&&(t.cachedGradient=null,t.cachedGradientKey=null,t.behaviorData=null)}}for(const t of this.particles)t.cachedGradient&&t.life<.5&&(t.cachedGradient=null,t.cachedGradientKey=null)}getStats(){return{activeParticles:this.particles.length,maxParticles:this.maxParticles,poolSize:this.pool.length,poolHits:this.poolHits,poolMisses:this.poolMisses,poolEfficiency:this.poolHits/Math.max(1,this.poolHits+this.poolMisses),spawnAccumulator:this.spawnAccumulator}}setMaxParticles(t){for(this.originalMaxParticles=this.originalMaxParticles||this.maxParticles,this.maxParticles=Math.max(1,t);this.particles.length>this.maxParticles;)this.removeParticle(0)}cleanupDeadParticles(){const t=this.particles.length;this.particles=this.particles.filter(t=>t.isAlive());const e=t-this.particles.length;return this.pool.length>20&&(this.pool.length=20),e}getParticlesByBehavior(t){return this.particles.filter(e=>e.behavior===t)}validateParticles(){for(const t of this.particles)if(!t.isAlive()||t.life<0||t.life>1)return!1;return!0}cleanup(){for(let t=this.particles.length-1;t>=0;t--)this.particles[t].isAlive()||this.removeParticle(t)}refreshPool(){this.particlePool.clear();for(const t of this.particles)t.life=0}setContainmentBounds(t){this.containmentBounds=t}destroy(){this.clear(),this.particlePool.clear()}}class ie{compose(){return null}}const se=new class{constructor(){this.gestureCache=new Map,this.propertyCache=new Map,this.compositionCache=new Map,this.pluginCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0,gestureHits:0,propertyHits:0,compositionHits:0},this.isInitialized=!1,this.loadStartTime=0}q(){this.isInitialized||this.initialize()}initialize(){this.loadStartTime=performance.now();try{this.cacheCoreGestures(),this.cacheGestureProperties(),this.cacheCommonCombinations(),this.cachePluginGestures(),this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.gestureCache.size+this.propertyCache.size+this.compositionCache.size,this.isInitialized=!0}catch(t){this.isInitialized=!1}}cacheCoreGestures(){Object.values(Ht).forEach(t=>{t&&t.name&&this.gestureCache.set(t.name,{...t,cached:!0,cacheTime:performance.now()})})}cacheGestureProperties(){this.gestureCache.forEach((t,e)=>{const i={type:t.type,emoji:t.emoji,description:t.description,config:t.config,rhythm:t.rhythm,duration:this.calculateGestureDuration(t),easing:this.extractEasingFunction(t),physics:this.extractPhysicsProperties(t),timing:this.extractTimingProperties(t)};this.propertyCache.set(e,i)})}cacheCommonCombinations(){[["bounce","pulse"],["shake","vibrate"],["orbit","spin"],["morph","glow"],["breathe","fade"],["wave","drift"],["nod","sway"],["jump","stretch"]].forEach(([t,e])=>{const i=`${t}+${e}`,s=this.calculateGestureCombination(t,e);s&&this.compositionCache.set(i,s)})}cachePluginGestures(){try{const t=wt();t&&Object.entries(t).forEach(([t,e])=>{this.pluginCache.set(t,{...e,cached:!0,cacheTime:performance.now(),isPlugin:!0})})}catch(t){}}getGesture(t){return this.q(),this.gestureCache.has(t)?(this.stats.hits++,this.stats.gestureHits++,this.gestureCache.get(t)):this.pluginCache.has(t)?(this.stats.hits++,this.stats.gestureHits++,this.pluginCache.get(t)):(this.stats.misses++,null)}getGestureProperties(t){return this.q(),this.propertyCache.has(t)?(this.stats.hits++,this.stats.propertyHits++,this.propertyCache.get(t)):(this.stats.misses++,null)}getGestureCombination(t,e){this.q();const i=`${t}+${e}`;return this.compositionCache.has(i)?(this.stats.hits++,this.stats.compositionHits++,this.compositionCache.get(i)):(this.stats.misses++,null)}calculateGestureDuration(t){if(!t.config)return 1e3;const{musicalDuration:e,duration:i}=t.config;return e&&e.musical?500*(e.beats||2):i||1e3}extractEasingFunction(t){if(!t.config)return"sine";const{easing:e,particleMotion:i}=t.config;return e||i?.easing||"sine"}extractPhysicsProperties(t){if(!t.config)return{};const{amplitude:e,strength:i,size:s,rotation:a}=t.config;return{amplitude:e||20,strength:i||1,size:s||80,rotation:a||0}}extractTimingProperties(t){if(!t.config)return{};const{phases:e,timingSync:i}=t.config;return{phases:e||[],timingSync:i||{},hasPhases:!!(e&&e.length>0),hasTimingSync:!!(i&&Object.keys(i).length>0)}}calculateGestureCombination(t,e){const i=this.getGesture(t),s=this.getGesture(e);return i&&s?{gestures:[t,e],combinedDuration:Math.max(this.calculateGestureDuration(i),this.calculateGestureDuration(s)),combinedType:i.type===s.type?i.type:"mixed",combinedEasing:this.extractEasingFunction(i),combinedPhysics:this.combinePhysicsProperties(i,s),compatibility:this.calculateCompatibility(i,s)}:null}combinePhysicsProperties(t,e){const i=this.extractPhysicsProperties(t),s=this.extractPhysicsProperties(e);return{amplitude:Math.max(i.amplitude,s.amplitude),strength:(i.strength+s.strength)/2,size:Math.max(i.size,s.size),rotation:(i.rotation+s.rotation)/2}}calculateCompatibility(t,e){return t.type===e.type?"high":"blending"===t.type&&"blending"===e.type?"medium":"override"===t.type||"override"===e.type?"low":"medium"}getStats(){const t=this.stats.hits+this.stats.misses>0?(this.stats.hits/(this.stats.hits+this.stats.misses)*100).toFixed(1):0;return{...this.stats,hitRate:`${t}%`,isInitialized:this.isInitialized,cacheSize:this.stats.cacheSize,coreGestures:this.gestureCache.size,pluginGestures:this.pluginCache.size,properties:this.propertyCache.size,combinations:this.compositionCache.size}}clear(){this.gestureCache.clear(),this.propertyCache.clear(),this.compositionCache.clear(),this.pluginCache.clear(),this.stats={hits:0,misses:0,loadTime:0,cacheSize:0,gestureHits:0,propertyHits:0,compositionHits:0},this.isInitialized=!1}warmUp(t){t.forEach(t=>{this.getGesture(t),this.getGestureProperties(t)})}};function ae(t){if(se&&se.isInitialized){const e=se.getGesture(t);if(e)return e}return Qt(t)}const he=new class{toMilliseconds(t){return"number"==typeof t?t:t?.beats?500*t.beats:t?.bars?2e3*t.bars:1e3}resolve(t){return this.toMilliseconds(t)}};class ne{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyBounce(t,e){return{offsetY:-Math.abs(Math.sin(e*Math.PI*t.params.frequency))*t.params.amplitude*this.scaleFactor*(t.params.effects&&t.params.effects.includes("gravity")?.6:1)}}applyShake(t,e){t.randomAngle||(t.randomAngle=Math.random()*Math.PI*2);const i=t.params.decay?1-e:1,s=Math.sin(e*Math.PI*t.params.frequency)*t.params.amplitude*i*this.scaleFactor;return{offsetX:s*Math.cos(t.randomAngle),offsetY:s*Math.sin(t.randomAngle)}}applyJump(t,e){let i,s,a=0,h=1;if(e<.2){const i=e/.2;h=1-(1-t.params.squashAmount)*i}else if(e<.7){const i=(e-.2)/.5,s=Math.sin(i*Math.PI);a=-t.params.jumpHeight*s*this.scaleFactor,h=t.params.squashAmount+(t.params.stretchAmount-t.params.squashAmount)*s}else{const i=(e-.7)/.3;h=t.params.stretchAmount-(t.params.stretchAmount-1)*i}if(t.params.effects&&t.params.effects.includes("gravity")){const t=e<.7?(e-.2)/.5:0,a=Math.sin(t*Math.PI);i=1+.2*a,s=1-.15*a}const n={offsetY:a,scale:h};return void 0!==i&&(n.scaleX=i),void 0!==s&&(n.scaleY=s),n}applyVibrate(t,e){if(!t.vibrateAngles){t.vibrateAngles={x:2*Math.random()-1,y:2*Math.random()-1};const e=Math.sqrt(t.vibrateAngles.x**2+t.vibrateAngles.y**2);t.vibrateAngles.x/=e,t.vibrateAngles.y/=e}const i=t.params.amplitude||5,s=t.params.frequency||20,a=Math.sin(e*Math.PI*2*s)*i*this.scaleFactor;return{offsetX:a*t.vibrateAngles.x,offsetY:a*t.vibrateAngles.y}}applyWiggle(t,e){const i=(t.params?.amplitude||15)*this.scaleFactor;void 0===t.wiggleDirection&&(t.wiggleDirection=Math.random()<.5?1:-1);const s=t.wiggleDirection;let a=0,h=0;if(e<.25){const t=e/.25;a=i*s*t,h=3*s*t}else if(e<.5){const t=(e-.25)/.25;a=i*s*(1-2*t),h=3*s*(1-2*t)}else if(e<.75){const t=(e-.5)/.25;a=i*-s*(1-2*t),h=3*-s*(1-2*t)}else{const t=(e-.75)/.25;a=i*s*(1-t),h=3*s*(1-t)}return{offsetX:a,offsetY:-Math.abs(Math.sin(e*Math.PI*4))*i*.15,rotation:h}}}class re{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyFlash(t,e){const i=Math.sin(e*Math.PI);return{glow:1+((t.params.glowPeak||2)-1)*i,scale:1+((t.params.scalePeak||1.1)-1)*i}}applyGlow(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+i*(t.params.scaleAmount||.1),glow:1+i*(t.params.glowAmount||.8)}}applyFlicker(t,e){const i=t.params?.intensity||2,s=t.params?.speed||3,a=1+Math.sin(e*Math.PI*2*s)*i*.3,h=5*Math.sin(e*Math.PI*4)*this.scaleFactor,n=.001*Date.now();return{offsetX:h,glow:a,particleGlow:(.5*Math.sin(e*Math.PI*s*2)+.5)*i,flickerTime:n,flickerEffect:!0}}applySparkle(t,e){const i=t.params?.intensity||2,s=.001*Date.now();return{particleGlow:i,glow:.3*Math.sin(e*Math.PI*4)+.7,fireflyTime:s,fireflyEffect:!0}}applyShimmer(t,e){const i=.001*Date.now(),s=t.params?.intensity||.3,a=Math.sin(2*i+e*Math.PI*2);return{offsetX:0,offsetY:0,glow:1+a*s,scale:1+.01*a,particleGlow:1+.2*a,shimmerTime:i,shimmerWave:a,shimmerEffect:!0}}}class oe{constructor(t){this.renderer=t}applyBreathe(t,e){const{params:i}=t,s=i.particleMotion?.holdPercent||.1;let a;if(e<.4)a=Math.sin(e/.4*Math.PI/2);else if(e<.4+s)a=1;else if(e<.9){const t=(e-.4-s)/(.5-s);a=Math.cos(t*Math.PI/2)}else a=0;const h=1+a*(i.scaleAmount||.25),n=1+a*(i.glowAmount||.4);return t.breathPhase=a,{scale:h,glow:n,breathPhase:a}}applyBreathIn(t,e){return{scale:1+(t.params.scaleAmount-1)*Math.sin(e*Math.PI/2)}}applyBreathOut(t,e){return{scale:1-(1-t.params.scaleAmount)*Math.sin(e*Math.PI/2)}}applyBreathHold(t,e){return{scale:t.params.scaleAmount}}applyBreathHoldEmpty(t,e){return{scale:t.params.scaleAmount}}}class le{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applySpin(t,e){return{rotation:Math.min(1.05*e,1)*t.params.rotations*360,scale:1+Math.sin(e*Math.PI)*t.params.scaleAmount}}applyDrift(t,e){e<=.01&&!t.currentDriftAngle&&(t.currentDriftAngle=Math.random()*Math.PI*2);const i=t.params.distance*Math.sin(e*Math.PI)*this.scaleFactor,s=t.currentDriftAngle||0;return e>=.99&&(t.currentDriftAngle=null),{offsetX:Math.cos(s)*i,offsetY:Math.sin(s)*i}}applyWave(t,e){const i=(t.params.amplitude||40)*this.scaleFactor,s=e*Math.PI*2,a=Math.sin(s)*i,h=-Math.sin(e*Math.PI)*i*.3;return{offsetX:a,offsetY:Math.sin(2*s)*i*.2+h,rotation:5*Math.sin(s),scale:1+.05*Math.sin(e*Math.PI*2),glow:1+.2*Math.sin(e*Math.PI)}}applySway(t,e){const i=(t.params?.amplitude||30)*this.scaleFactor,s=t.params?.frequency||1;return{offsetX:Math.sin(e*Math.PI*2*s)*i,offsetY:Math.sin(e*Math.PI*4*s)*i*.1,rotation:5*Math.sin(e*Math.PI*2*s)}}applyFloat(t,e){const i=(t.params?.amplitude||20)*this.scaleFactor,s=t.params?.speed||1,a=Math.sin(e*Math.PI*2*s)*i;return{offsetX:Math.sin(e*Math.PI*3*s)*i*.3,offsetY:a,scale:1+.02*Math.sin(e*Math.PI*4*s)}}applyOrbital(t,e){return{offsetX:0,offsetY:0}}applyHula(t,e){const i=(t.params?.amplitude||40)*this.scaleFactor,s=e*Math.PI*2;return{offsetX:Math.sin(s)*i,offsetY:Math.sin(2*s)*i*.5}}applyOrbit(t,e){const i=(t.params?.radius||30)*this.scaleFactor,s=t.params?.speed||1,a=e*Math.PI*2*s;return{offsetX:Math.cos(a)*i,offsetY:Math.sin(a)*i}}}class ce{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyPulse(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+i*t.params.scaleAmount,glow:1+i*t.params.glowAmount}}applyExpand(t,e){const i=Math.max(t.params.scaleAmount||t.params.scaleTarget||1.5,1),s=Math.sin(e*Math.PI/2);return{scale:1+(i-1)*s,glow:1+Math.abs(t.params.glowAmount||.2)*s}}applyContract(t,e){const i=t.params.scaleAmount||t.params.scaleTarget||.7,s=Math.sin(e*Math.PI/2);return{scale:1+(i-1)*s,glow:1+(t.params.glowAmount||-.2)*s}}applyStretch(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+((t.params.scaleX+t.params.scaleY)/2-1)*i}}applyMorph(t,e){const i=Math.sin(e*Math.PI*2);return{scale:1+.1*i,rotation:10*i}}}class ue{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyNod(t,e){return{offsetY:Math.sin(e*Math.PI*t.params.frequency)*t.params.amplitude*this.scaleFactor}}applyTilt(t,e){t.tiltDirection||(t.tiltDirection=Math.random()<.5?-1:1);const i=t.params.frequency||2,s=(t.params.angle||15)*Math.PI/180,a=Math.sin(e*Math.PI*i)*t.tiltDirection;return{rotation:a*s,scaleX:1+.1*Math.abs(a),scaleY:1-.05*Math.abs(a),offsetX:10*a,offsetY:-5*Math.abs(a)}}applySlowBlink(t,e){let i=1;return i=e<.3?1-e/.3:e<.5?0:e<.8?(e-.5)/.3:1,{glow:i}}applyLook(t,e){if(!t.targetX){const e=t.params.lookDirection,i=50*t.params.lookDistance*this.scaleFactor;switch(e){case"left":t.targetX=-i,t.targetY=0;break;case"right":t.targetX=i,t.targetY=0;break;case"up":t.targetX=0,t.targetY=-i;break;case"down":t.targetX=0,t.targetY=i;break;default:{const e=Math.random()*Math.PI*2;t.targetX=Math.cos(e)*i,t.targetY=Math.sin(e)*i;break}}}let i=e;return i=e<.3?e/.3:e<.7?1:1-(e-.7)/.3,{offsetX:t.targetX*i,offsetY:t.targetY*i}}applySettle(t,e){const i=Math.sin(e*Math.PI*t.params.wobbleFreq)*Math.exp(3*-e)*20*this.scaleFactor;return{offsetY:i,scale:1+.01*i}}}class pe{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyPoint(t,e){void 0===t.pointDirection&&(t.pointDirection=Math.random()<.5?-1:1);const i=void 0!==t.params?.direction?t.params.direction:t.pointDirection,s=(t.params?.distance||40)*this.scaleFactor;let a,h;return e<.4?(a=1-Math.pow(1-e/.4,3),h=a):e<.6?(a=1,h=1):(a=Math.pow(1-(e-.6)/.4,3),h=a),{offsetX:i*s*a,offsetY:-Math.abs(.15*s*a),scale:1+.15*h,rotation:5*i*h}}applyLean(t,e){const i=t.params?.angle||15,s=t.params?.side||1,a=Math.sin(e*Math.PI),h=i*s*a;return{offsetX:10*s*this.scaleFactor*a,rotation:h}}applyReach(t,e){const i=void 0!==t.params?.direction?t.params.direction:-Math.PI/2,s=(t.params?.distance||40)*this.scaleFactor;let a;return a=e<.4?e/.4:e<.6?1:1-(e-.6)/.4,a=a*a*(3-2*a),{offsetX:Math.cos(i)*s*a,offsetY:Math.sin(i)*s*a,scale:1+.15*a}}}class de{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyFlashWave(t,e){t.flashWave||(t.flashWave={innerRadius:0,outerRadius:0,maxRadius:3}),t.flashWave.outerRadius=e*t.flashWave.maxRadius,t.flashWave.innerRadius=Math.max(0,(e-.1)*t.flashWave.maxRadius);const i=Math.max(0,1-.7*e);return t.flashWaveData={innerRadius:t.flashWave.innerRadius,outerRadius:t.flashWave.outerRadius,intensity:i},{glow:1+.3*i,flashWave:t.flashWaveData}}applyRain(t,e){return{offsetX:0,offsetY:0,particleEffect:"rain"}}applyGroove(t,e){const i=(t.params?.amplitude||25)*this.scaleFactor;return{offsetX:Math.sin(e*Math.PI*2)*i+Math.sin(e*Math.PI*3+.5)*i*.4,offsetY:Math.sin(e*Math.PI*4+.3)*i*.25,scale:1+.03*Math.sin(e*Math.PI*3+.7),rotation:8*Math.sin(e*Math.PI*2+.2)}}applyHeadBob(t,e){const i=(t.params?.amplitude||20)*this.scaleFactor,s=e*(t.params?.frequency||2)%1;let a;return a=s<.3?s/.3*-i:-i*(1-(s-.3)/.7),{offsetY:a,rotation:s<.3?-3:0}}applyRunningMan(t,e){const i=20*Math.sin(e*Math.PI*4)*this.scaleFactor;return{offsetX:i,offsetY:10*-Math.abs(Math.sin(e*Math.PI*8))*this.scaleFactor,rotation:.3*i,scaleY:1-.05*Math.abs(Math.sin(e*Math.PI*8))}}applyCharleston(t,e){const i=25*Math.sin(e*Math.PI*8)*this.scaleFactor;return{offsetX:i,offsetY:10*-Math.abs(Math.sin(e*Math.PI*8))*this.scaleFactor,rotation:.6*i,scaleY:1-.06*Math.abs(Math.sin(e*Math.PI*8))}}}class fe{constructor(t){this.renderer=t,this.activeGestures=new Map,this.scaleFactor=t.scaleFactor||1,this.physicalGestureAnimator=new ne(t),this.visualEffectAnimator=new re(t),this.breathGestureAnimator=new oe(t),this.movementGestureAnimator=new le(t),this.shapeTransformAnimator=new ce(t),this.expressionGestureAnimator=new ue(t),this.directionalGestureAnimator=new pe(t),this.complexAnimationAnimator=new de(t),this.gestureAnimations={bounce:{active:!1,progress:0,params:{}},pulse:{active:!1,progress:0,params:{}},shake:{active:!1,progress:0,params:{}},spin:{active:!1,progress:0,params:{}},nod:{active:!1,progress:0,params:{}},tilt:{active:!1,progress:0,params:{}},expand:{active:!1,progress:0,params:{}},contract:{active:!1,progress:0,params:{}},flash:{active:!1,progress:0,params:{}},drift:{active:!1,progress:0,params:{}},stretch:{active:!1,progress:0,params:{}},glow:{active:!1,progress:0,params:{}},flicker:{active:!1,progress:0,params:{}},vibrate:{active:!1,progress:0,params:{}},orbital:{active:!1,progress:0,params:{}},hula:{active:!1,progress:0,params:{}},wave:{active:!1,progress:0,params:{}},breathe:{active:!1,progress:0,params:{}},morph:{active:!1,progress:0,params:{}},slowBlink:{active:!1,progress:0,params:{}},look:{active:!1,progress:0,params:{}},settle:{active:!1,progress:0,params:{}},breathIn:{active:!1,progress:0,params:{}},breathOut:{active:!1,progress:0,params:{}},breathHold:{active:!1,progress:0,params:{}},breathHoldEmpty:{active:!1,progress:0,params:{}},jump:{active:!1,progress:0,params:{}},sway:{active:!1,progress:0,params:{}},float:{active:!1,progress:0,params:{}},sparkle:{active:!1,progress:0,params:{}},shimmer:{active:!1,progress:0,params:{}},wiggle:{active:!1,progress:0,params:{}},groove:{active:!1,progress:0,params:{}},point:{active:!1,progress:0,params:{}},lean:{active:!1,progress:0,params:{}},reach:{active:!1,progress:0,params:{}},headBob:{active:!1,progress:0,params:{}},orbit:{active:!1,progress:0,params:{}},rain:{active:!1,progress:0,params:{}},runningman:{active:!1,progress:0,params:{}},charleston:{active:!1,progress:0,params:{}}}}startGesture(t){const e=ae(t);if(["bounce","shake","pulse","flash","jump","slam","spin","flicker"].includes(t)&&this.renderer.specialEffects){const e={flash:1,jump:1,shake:.9,bounce:.8,pulse:.7,slam:1,spin:.8,flicker:1}[t]||.8;this.renderer.specialEffects.triggerChromaticAberration(e)}let i;i=this.renderer.gestureCompositor?this.renderer.gestureCompositor.compose(t,this.renderer.state.emotion,this.renderer.currentUndertone):e?.config||{amplitude:20,frequency:2,duration:1e3,scaleAmount:.2,glowAmount:.3,rotations:1,distance:50,angle:15,scaleTarget:1.5,glowPeak:2,scalePeak:1.1,scaleX:1.2,scaleY:.8,maxOpacity:1,minOpacity:.5,lookDirection:"random",lookDistance:1,wobbleFreq:4,squashAmount:.8,stretchAmount:1.2,jumpHeight:100,decay:!0,easing:"sine",effects:[]};let s=1e3;if(e&&e.config)if(e.config.musicalDuration)s=he.toMilliseconds(e.config.musicalDuration);else if(e.config.duration){const{duration:t}=e.config;s=t}const a=this.gestureAnimations[t];a&&(a.active=!0,a.startTime=performance.now(),a.progress=0,a.params=i,a.duration=s,"shake"===t?a.randomAngle=void 0:"drift"===t?(a.startX=void 0,a.startY=void 0,a.currentDriftAngle=void 0):"tilt"===t?a.tiltDirection=void 0:"vibrate"===t&&(a.vibrateAngles=void 0))}applyGestureAnimations(){const t=performance.now(),e={offsetX:0,offsetY:0,scale:1,rotation:0,glow:1};for(const[i,s]of Object.entries(this.gestureAnimations)){if(!s.active)continue;const a=t-s.startTime,h=s.duration||(s.params?s.params.duration:1e3);s.progress=Math.min(a/h,1);const n=this.applyEasing(s.progress,s.params.easing);let r={};switch(i){case"bounce":r=this.applyBounce(s,n);break;case"pulse":r=this.applyPulse(s,n);break;case"shake":r=this.applyShake(s,n);break;case"spin":r=this.applySpin(s,n);break;case"nod":r=this.applyNod(s,n);break;case"tilt":r=this.applyTilt(s,n);break;case"expand":r=this.applyExpand(s,n);break;case"contract":r=this.applyContract(s,n);break;case"flash":r=this.applyFlash(s,n);break;case"drift":r=this.applyDrift(s,n);break;case"stretch":r=this.applyStretch(s,n);break;case"glow":r=this.applyGlow(s,n);break;case"flicker":r=this.applyFlicker(s,n);break;case"vibrate":r=this.applyVibrate(s,n);break;case"orbital":r=this.applyOrbital(s,n);break;case"hula":r=this.applyHula(s,n);break;case"wave":r=this.applyWave(s,n);break;case"breathe":r=this.applyBreathe(s,n);break;case"morph":r=this.applyMorph(s,n);break;case"slowBlink":r=this.applySlowBlink(s,n);break;case"look":r=this.applyLook(s,n);break;case"settle":r=this.applySettle(s,n);break;case"breathIn":r=this.applyBreathIn(s,n);break;case"breathOut":r=this.applyBreathOut(s,n);break;case"breathHold":r=this.applyBreathHold(s,n);break;case"breathHoldEmpty":r=this.applyBreathHoldEmpty(s,n);break;case"jump":r=this.applyJump(s,n);break;case"sway":r=this.applySway(s,n);break;case"float":r=this.applyFloat(s,n);break;case"rain":r=this.applyRain(s,n);break;case"runningman":r=this.applyRunningMan(s,n);break;case"charleston":r=this.applyCharleston(s,n);break;case"sparkle":r=this.applySparkle(s,n);break;case"shimmer":r=this.applyShimmer(s,n);break;case"wiggle":r=this.applyWiggle(s,n);break;case"groove":r=this.applyGroove(s,n);break;case"point":r=this.applyPoint(s,n);break;case"lean":r=this.applyLean(s,n);break;case"reach":r=this.applyReach(s,n);break;case"headBob":r=this.applyHeadBob(s,n);break;case"orbit":r=this.applyOrbit(s,n)}e.offsetX+=r.offsetX||0,e.offsetY+=r.offsetY||0,e.scale*=r.scale||1,e.rotation+=r.rotation||0,e.glow=Math.max(e.glow,r.glow||1),r.flashWave&&(e.flashWave=r.flashWave),r.fireflyEffect&&(e.fireflyEffect=r.fireflyEffect,e.particleGlow=r.particleGlow,e.fireflyTime=r.fireflyTime),r.flickerEffect&&(e.flickerEffect=r.flickerEffect,e.particleGlow=r.particleGlow,e.flickerTime=r.flickerTime),r.shimmerEffect&&(e.shimmerEffect=r.shimmerEffect,e.particleGlow=r.particleGlow,e.shimmerTime=r.shimmerTime,e.shimmerWave=r.shimmerWave),r.glowEffect&&(e.glowEffect=r.glowEffect,e.particleGlow=r.particleGlow,e.glowTime=r.glowTime,e.glowProgress=r.glowProgress,e.glowEnvelope=r.glowEnvelope),s.progress>=1&&(s.active=!1,s.progress=0,s.startTime=0,"flash"===i&&(s.flashWave=null,s.flashWaveData=null),r.glowEffect&&(r.glowEffect=null,r.particleGlow=null,r.glowTime=null,r.glowProgress=null,r.glowEnvelope=null),r.fireflyEffect&&(r.fireflyEffect=null,r.particleGlow=null,r.fireflyTime=null),r.flickerEffect&&(r.flickerEffect=null,r.particleGlow=null,r.flickerTime=null),r.shimmerEffect&&(r.shimmerEffect=null,r.particleGlow=null,r.shimmerTime=null,r.shimmerWave=null))}return e}update(t){return this.applyGestureAnimations()}stopAllGestures(){Object.keys(this.gestureAnimations).forEach(t=>{const e=this.gestureAnimations[t];e.active=!1,e.startTime=0,e.progress=0,e.params=null,e.glowEffect&&(e.glowEffect=null,e.particleGlow=null,e.glowTime=null,e.glowProgress=null,e.glowEnvelope=null),e.fireflyEffect&&(e.fireflyEffect=null,e.particleGlow=null,e.fireflyTime=null),e.flickerEffect&&(e.flickerEffect=null,e.particleGlow=null,e.flickerTime=null),e.shimmerEffect&&(e.shimmerEffect=null,e.particleGlow=null,e.shimmerTime=null,e.shimmerWave=null),e.flashWave&&(e.flashWave=null,e.flashWaveData=null)}),this.activeGestures.clear()}getCurrentGesture(){const t=performance.now(),e=["orbital","hula","wave","spin"];for(const i of e){const e=this.gestureAnimations[i];if(e&&e.active){const s=ae(i),a=t-e.startTime,h=e.duration||(e.params?e.params.duration:1e3),n=Math.min(a/h,1);return{name:i,particleMotion:s?.config?.particleMotion||{type:i,strength:e.params?.strength||1},progress:n,params:e.params}}}for(const[e,i]of Object.entries(this.gestureAnimations))if(i.active){const s=ae(e),a=t-i.startTime,h=i.duration||(i.params?i.params.duration:1e3),n=Math.min(a/h,1),r={name:e,particleMotion:s?.config?.particleMotion||i.params?.particleMotion||{type:e,strength:i.params?.strength||1},progress:n,params:i.params};return"breathe"===e&&void 0!==i.breathPhase&&(r.breathPhase=i.breathPhase),r}return null}applyEasing(t,e){switch(e){case"linear":default:return t;case"quad":return t*t;case"cubic":return t*t*t;case"sine":return Math.sin(t*Math.PI/2);case"back":return t*t*(2.7*t-1.7)}}applyBounce(t,e){return this.physicalGestureAnimator.applyBounce(t,e)}applyPulse(t,e){return this.shapeTransformAnimator.applyPulse(t,e)}applyShake(t,e){return this.physicalGestureAnimator.applyShake(t,e)}applySpin(t,e){return this.movementGestureAnimator.applySpin(t,e)}applyNod(t,e){return this.expressionGestureAnimator.applyNod(t,e)}applyTilt(t,e){return this.expressionGestureAnimator.applyTilt(t,e)}applyExpand(t,e){return this.shapeTransformAnimator.applyExpand(t,e)}applyContract(t,e){return this.shapeTransformAnimator.applyContract(t,e)}applyFlash(t,e){return this.visualEffectAnimator.applyFlash(t,e)}applyDrift(t,e){return this.movementGestureAnimator.applyDrift(t,e)}applyStretch(t,e){return this.shapeTransformAnimator.applyStretch(t,e)}applyGlow(t,e){return this.visualEffectAnimator.applyGlow(t,e)}applyFlashWave(t,e){return this.complexAnimationAnimator.applyFlashWave(t,e)}applyFlicker(t,e){return this.visualEffectAnimator.applyFlicker(t,e)}applyVibrate(t,e){return this.physicalGestureAnimator.applyVibrate(t,e)}applyWave(t,e){return this.movementGestureAnimator.applyWave(t,e)}applyBreathe(t,e){return this.breathGestureAnimator.applyBreathe(t,e)}applyMorph(t,e){return this.shapeTransformAnimator.applyMorph(t,e)}applySlowBlink(t,e){return this.expressionGestureAnimator.applySlowBlink(t,e)}applyLook(t,e){return this.expressionGestureAnimator.applyLook(t,e)}applySettle(t,e){return this.expressionGestureAnimator.applySettle(t,e)}applyBreathIn(t,e){return this.breathGestureAnimator.applyBreathIn(t,e)}applyBreathOut(t,e){return this.breathGestureAnimator.applyBreathOut(t,e)}applyBreathHold(t,e){return this.breathGestureAnimator.applyBreathHold(t,e)}applyBreathHoldEmpty(t,e){return this.breathGestureAnimator.applyBreathHoldEmpty(t,e)}applyJump(t,e){return this.physicalGestureAnimator.applyJump(t,e)}applySway(t,e){return this.movementGestureAnimator.applySway(t,e)}applyRain(t,e){return this.complexAnimationAnimator.applyRain(t,e)}applyFloat(t,e){return this.movementGestureAnimator.applyFloat(t,e)}applyOrbital(t,e){return this.movementGestureAnimator.applyOrbital(t,e)}applyHula(t,e){return this.movementGestureAnimator.applyHula(t,e)}applySparkle(t,e){return this.visualEffectAnimator.applySparkle(t,e)}applyShimmer(t,e){return this.visualEffectAnimator.applyShimmer(t,e)}applyWiggle(t,e){return this.physicalGestureAnimator.applyWiggle(t,e)}applyGroove(t,e){return this.complexAnimationAnimator.applyGroove(t,e)}applyPoint(t,e){return this.directionalGestureAnimator.applyPoint(t,e)}applyLean(t,e){return this.directionalGestureAnimator.applyLean(t,e)}applyReach(t,e){return this.directionalGestureAnimator.applyReach(t,e)}applyHeadBob(t,e){return this.complexAnimationAnimator.applyHeadBob(t,e)}applyOrbit(t,e){return this.movementGestureAnimator.applyOrbit(t,e)}startBounce(){this.startGesture("bounce")}startPulse(){this.startGesture("pulse")}startShake(){this.startGesture("shake")}startSpin(){this.startGesture("spin")}startNod(){this.startGesture("nod")}startTilt(){this.startGesture("tilt")}startExpand(){this.startGesture("expand")}startContract(){this.startGesture("contract")}startFlash(){this.startGesture("flash")}startDrift(){this.startGesture("drift")}startStretch(){this.startGesture("stretch")}startGlow(){this.startGesture("glow")}startFlicker(){this.startGesture("flicker")}startVibrate(){this.startGesture("vibrate")}startOrbital(){this.startGesture("orbital")}startHula(){this.startGesture("hula")}startWave(){this.startGesture("wave")}startBreathe(){this.startGesture("breathe")}startMorph(){this.startGesture("morph")}startSlowBlink(){this.startGesture("slowBlink")}startLook(){this.startGesture("look")}startSettle(){this.startGesture("settle")}startBreathIn(){this.startGesture("breathIn")}startBreathOut(){this.startGesture("breathOut")}startBreathHold(){this.startGesture("breathHold")}startBreathHoldEmpty(){this.startGesture("breathHoldEmpty")}startJump(){this.startGesture("jump")}startSway(){this.startGesture("sway")}startFloat(){this.startGesture("float")}startRain(){this.startGesture("rain")}startRunningMan(){this.startGesture("runningman")}startCharleston(){this.startGesture("charleston")}startSparkle(){this.startGesture("sparkle")}startShimmer(){this.startGesture("shimmer")}startWiggle(){this.startGesture("wiggle")}startGroove(){this.startGesture("groove")}startPoint(){this.startGesture("point")}startLean(){this.startGesture("lean")}startReach(){this.startGesture("reach")}startHeadBob(){this.startGesture("headBob")}startOrbit(){this.startGesture("orbit")}applyRunningMan(t,e){return this.complexAnimationAnimator.applyRunningMan(t,e)}applyCharleston(t,e){return this.complexAnimationAnimator.applyCharleston(t,e)}startRunningManGesture(){this.startGesture("runningman")}startCharlestonGesture(){this.startGesture("charleston")}pauseCurrentAnimation(){const t=performance.now();for(const[,e]of Object.entries(this.gestureAnimations))e.active&&(e.pausedAt=t,e.pausedProgress=e.progress);this.isPaused=!0}resumeAnimation(){if(!this.isPaused)return;const t=performance.now();for(const[,e]of Object.entries(this.gestureAnimations))if(e.active&&e.pausedAt){const i=t-e.pausedAt;e.startTime&&(e.startTime+=i),delete e.pausedAt,delete e.pausedProgress}this.isPaused=!1}reset(){for(const[,t]of Object.entries(this.gestureAnimations))t.active=!1,t.progress=0,t.params={},delete t.startTime,delete t.pausedAt,delete t.pausedProgress;this.activeGestures.clear(),this.isPaused=!1}destroy(){this.stopAllGestures(),this.physicalGestureAnimator&&"function"==typeof this.physicalGestureAnimator.destroy&&this.physicalGestureAnimator.destroy(),this.visualEffectAnimator&&"function"==typeof this.visualEffectAnimator.destroy&&this.visualEffectAnimator.destroy(),this.breathGestureAnimator&&"function"==typeof this.breathGestureAnimator.destroy&&this.breathGestureAnimator.destroy(),this.movementGestureAnimator&&"function"==typeof this.movementGestureAnimator.destroy&&this.movementGestureAnimator.destroy(),this.shapeTransformAnimator&&"function"==typeof this.shapeTransformAnimator.destroy&&this.shapeTransformAnimator.destroy(),this.expressionGestureAnimator&&"function"==typeof this.expressionGestureAnimator.destroy&&this.expressionGestureAnimator.destroy(),this.directionalGestureAnimator&&"function"==typeof this.directionalGestureAnimator.destroy&&this.directionalGestureAnimator.destroy(),this.complexAnimationAnimator&&"function"==typeof this.complexAnimationAnimator.destroy&&this.complexAnimationAnimator.destroy(),this.physicalGestureAnimator=null,this.visualEffectAnimator=null,this.breathGestureAnimator=null,this.movementGestureAnimator=null,this.shapeTransformAnimator=null,this.expressionGestureAnimator=null,this.directionalGestureAnimator=null,this.complexAnimationAnimator=null,this.gestureAnimations=null,this.activeGestures.clear(),this.activeGestures=null,this.renderer=null,this.scaleFactor=null,this.isPaused=!1}}class me{constructor(){this.colorTransition=null}applyUndertoneModifiers(t,e){return e}applyUndertoneToColor(t,e){if(e&&"object"==typeof e&&void 0!==e.weight){const{weight:i}=e,s=e.type||"clear";if("clear"===s||0===i)return t;const a=this.applyUndertoneSaturation(t,s),h=this.hexToRgb(t),n=this.hexToRgb(a),r=Math.round(h.r+(n.r-h.r)*i),o=Math.round(h.g+(n.g-h.g)*i),l=Math.round(h.b+(n.b-h.b)*i);return this.rgbToHex(r,o,l)}return e&&"clear"!==e?this.applyUndertoneSaturation(t,e):t}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}rgbToHsl(t,e,i){t/=255,e/=255,i/=255;const s=Math.max(t,e,i),a=Math.min(t,e,i),h=(s+a)/2;let n,r;if(s===a)n=r=0;else{const o=s-a;switch(r=h>.5?o/(2-s-a):o/(s+a),s){case t:n=((e-i)/o+(e<i?6:0))/6;break;case e:n=((i-t)/o+2)/6;break;case i:n=((t-e)/o+4)/6}}return{h:360*n,s:100*r,l:100*h}}hslToHex(t,e,i){let s,a,h;if(t/=360,i/=100,0==(e/=100))s=a=h=i;else{const n=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),r=i<.5?i*(1+e):i+e-i*e,o=2*i-r;s=n(o,r,t+1/3),a=n(o,r,t),h=n(o,r,t-1/3)}const n=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e};return`#${n(s)}${n(a)}${n(h)}`}applyUndertoneSaturation(t,e){const i=this.hexToRgb(t),s=this.rgbToHsl(i.r,i.g,i.b),a={intense:1.5,confident:1.3,energetic:1.2,upbeat:1.2,nervous:1.15,mellow:.8,tired:.8,subdued:.5}[e]||1;return s.s=Math.min(100,s.s*a),this.hslToHex(s.h,s.s,s.l)}rgbToHex(t,e,i){const s=t=>{const e=Math.round(t).toString(16);return 1===e.length?`0${e}`:e};return`#${s(t)}${s(e)}${s(i)}`}startColorTransition(t,e,i=1500){this.currentColor===t&&this.currentIntensity===e||(this.colorTransition={active:!0,fromColor:this.currentColor||"#ffffff",toColor:t,fromIntensity:this.currentIntensity||1,toIntensity:e,progress:0,startTime:performance.now(),duration:i})}updateColorTransition(t){if(!this.colorTransition||!this.colorTransition.active)return null;const e=performance.now()-this.colorTransition.startTime,i=Math.min(e/this.colorTransition.duration,1),s=1-Math.pow(1-i,2),a=this.hexToRgb(this.colorTransition.fromColor),h=this.hexToRgb(this.colorTransition.toColor),n=Math.round(a.r+(h.r-a.r)*s),r=Math.round(a.g+(h.g-a.g)*s),o=Math.round(a.b+(h.b-a.b)*s),l=this.rgbToHex(n,r,o),c=this.colorTransition.fromIntensity+(this.colorTransition.toIntensity-this.colorTransition.fromIntensity)*s;return this.currentColor=l,this.currentIntensity=c,i>=1&&(this.colorTransition.active=!1),{color:l,intensity:c}}}class Me{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvasManager?.canvas||t.canvas,this.recordingActive=!1,this.sleepMode=!1,this.speakingActive=!1,this.speakingRings=[],this.ringSpawnTimer=0,this.ringSpawnInterval=300,this.maxRings=3,this.sleepZ=[],this.sparkles=[],this.chromaticAberration={active:!1,intensity:0,targetIntensity:0,fadeSpeed:.01,maxOffset:30},this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}renderRecordingGlow(t,e,i,s){const{ctx:a}=this,h=2.5*i,n=a.createRadialGradient(t,e,0,t,e,h);n.addColorStop(0,`rgba(255, 0, 0, ${.3*s})`),n.addColorStop(.5,`rgba(255, 0, 0, ${.15*s})`),n.addColorStop(1,"rgba(255, 0, 0, 0)"),a.save(),a.globalCompositeOperation="screen",a.fillStyle=n,a.fillRect(t-h,e-h,2*h,2*h),a.restore()}renderRecordingIndicator(t,e){const i=Date.now()/1e3,s=.8+.2*Math.sin(2*i);this.ctx.save(),this.ctx.translate(t,e),this.ctx.shadowBlur=this.scaleValue(15),this.ctx.shadowColor=`rgba(255, 0, 0, ${.8*s})`;const a=this.scaleValue(80);this.ctx.font=`italic 900 ${a}px "Poppins", sans-serif`,this.ctx.fillStyle=`rgba(255, 0, 0, ${s})`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText("REC",0,0),this.ctx.shadowBlur=0,this.ctx.font=`italic 900 ${a-1}px "Poppins", sans-serif`,this.ctx.fillStyle=`rgba(255, 255, 255, ${.3*s})`,this.ctx.fillText("REC",-.5,-.5),this.ctx.restore()}renderSleepIndicator(t,e,i){if(this.ringSpawnTimer+=i,this.ringSpawnTimer>=2e3&&this.sleepZ.length<3){const i=["300","500","700","900"],s=i[Math.floor(Math.random()*i.length)],a=Math.random()>.5?"Z":"z";this.sleepZ.push({x:t+Math.random()*this.scaleValue(30)-this.scaleValue(15),y:e+this.scaleValue(80),size:this.scaleValue(3*(24+8*Math.random())),opacity:1,speed:-.025,drift:Math.random()*this.scaleValue(20)-this.scaleValue(10),lifetime:0,rotation:30*Math.random()-15,text:a,weight:s}),this.ringSpawnTimer=0}this.sleepZ=this.sleepZ.filter(t=>{if(t.lifetime+=i,t.y+=t.speed*i,t.x+=Math.sin(8e-4*t.lifetime)*t.drift*.008,t.rotation+=.01*i,t.lifetime<2e3?t.opacity=1:t.lifetime<4e3?t.opacity=1-(t.lifetime-2e3)/2e3:t.opacity=0,t.opacity>.01){this.ctx.save(),this.ctx.translate(t.x,t.y),this.ctx.rotate(t.rotation*Math.PI/180);const e=this.renderer.state.glowColor||"#4a90e2";this.ctx.shadowBlur=this.scaleValue(15),this.ctx.shadowColor=this.hexToRgba(e,.5*t.opacity);const i=this.ctx.createLinearGradient(-t.size/2,-t.size/2,t.size/2,t.size/2);return i.addColorStop(0,this.hexToRgba(e,t.opacity)),i.addColorStop(.5,this.hexToRgba("#ffffff",.9*t.opacity)),i.addColorStop(1,this.hexToRgba(e,.7*t.opacity)),this.ctx.font=`italic ${t.weight||"900"} ${t.size}px 'Poppins', sans-serif`,this.ctx.fillStyle=i,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t.text||"Z",0,0),this.ctx.shadowBlur=0,this.ctx.font=`italic ${t.weight||"900"} ${.9*t.size}px 'Poppins', sans-serif`,this.ctx.fillStyle=this.hexToRgba("#ffffff",.3*t.opacity),this.ctx.fillText(t.text||"Z",-1,-1),this.ctx.restore(),!0}return!1})}renderSpeakingRings(t,e,i,s){this.ringSpawnTimer+=s,this.ringSpawnTimer>=this.ringSpawnInterval&&this.speakingRings.length<this.maxRings&&(this.speakingRings.push({radius:i,opacity:.8,speed:.15}),this.ringSpawnTimer=0),this.speakingRings=this.speakingRings.filter(a=>(a.radius+=a.speed*s,a.opacity=Math.max(0,.8*(1-(a.radius-i)/(2*i))),a.opacity>.01&&(this.ctx.strokeStyle=this.hexToRgba(this.renderer.state.glowColor,a.opacity),this.ctx.lineWidth=this.scaleValue(2),this.ctx.beginPath(),this.ctx.arc(t,e,a.radius,0,2*Math.PI),this.ctx.stroke(),!0)))}startRecording(){this.recordingActive=!0}stopRecording(){this.recordingActive=!1}enterSleepMode(){this.sleepMode=!0}wakeUp(){this.sleepMode=!1}startSpeaking(){this.speakingActive=!0}stopSpeaking(){this.speakingActive=!1}createSparkle(t,e,i={}){this.sparkles.push({x:t,y:e,vx:i.velocity?.x||0,vy:i.velocity?.y||0,size:i.size||3,color:i.color||"hsl(50, 100%, 70%)",lifetime:i.lifetime||1e3,maxLifetime:i.lifetime||1e3,rotation:Math.random()*Math.PI*2,rotationSpeed:.2*(Math.random()-.5)})}renderSparkles(){const{ctx:t}=this;this.sparkles.forEach(e=>{const i=1-e.lifetime/e.maxLifetime,s=1-i;t.save(),t.translate(e.x,e.y),t.rotate(e.rotation);const a=this.scaleValue(e.size*(1-.5*i));t.beginPath();const h=a,n=.38*a;for(let e=0;e<10;e++){const i=e*Math.PI/5-Math.PI/2,s=e%2==0?h:n;0===e?t.moveTo(Math.cos(i)*s,Math.sin(i)*s):t.lineTo(Math.cos(i)*s,Math.sin(i)*s)}t.closePath(),t.shadowBlur=this.scaleValue(10),t.shadowColor=e.color,t.fillStyle=e.color.replace("70%",70+30*i+"%").replace(")",`, ${s})`).replace("hsl","hsla"),t.fill(),t.restore()})}triggerChromaticAberration(t=.8){this.chromaticAberration.active=!0,this.chromaticAberration.targetIntensity=Math.min(1,t),this.chromaticAberration.intensity=this.chromaticAberration.targetIntensity;const e=document.getElementById("emotive-canvas")||document.querySelector("canvas")||this.canvas;if(e){if(e.style.animation="none",!document.getElementById("chromatic-styles")){const t=document.createElement("style");t.id="chromatic-styles",t.textContent="\n @keyframes chromaticGlitch {\n 0% {\n filter: none;\n transform: translateX(0);\n }\n 15% {\n filter: drop-shadow(-2px 0 0 rgba(255,0,0,0.7)) drop-shadow(2px 0 0 rgba(0,255,255,0.7));\n transform: translateX(-0.5px);\n }\n 30% {\n filter: drop-shadow(-3px 0 0 rgba(255,0,0,0.8)) drop-shadow(3px 0 0 rgba(0,255,255,0.8));\n transform: translateX(0.5px);\n }\n 45% {\n filter: drop-shadow(-2px 0 0 rgba(255,0,0,0.6)) drop-shadow(2px 0 0 rgba(0,255,255,0.6));\n transform: translateX(-0.3px);\n }\n 60% {\n filter: drop-shadow(-1px 0 0 rgba(255,0,0,0.4)) drop-shadow(1px 0 0 rgba(0,255,255,0.4));\n transform: translateX(0.2px);\n }\n 100% {\n filter: none;\n transform: translateX(0);\n }\n }\n ",document.head.appendChild(t)}e.style.animation=`chromaticGlitch ${300+200*t}ms ease-out`}}applyChromaticAberration(t,e){if(!this.chromaticAberration.active||this.chromaticAberration.intensity<=0)return;const{intensity:i}=this.chromaticAberration,s=this.scaleValue(this.chromaticAberration.maxOffset*i),a=t.globalCompositeOperation;t.save(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.globalCompositeOperation="source-over",t.filter="url(#red-channel)",t.drawImage(e,-s,0),t.globalCompositeOperation="screen",t.filter="url(#green-channel)",t.drawImage(e,0,0),t.globalCompositeOperation="screen",t.filter="url(#blue-channel)",t.drawImage(e,s,0),t.filter="none",t.globalCompositeOperation=a,t.restore()}applyChromaticAberrationSimple(t,e,i,s,a){if(!this.chromaticAberration.active||this.chromaticAberration.intensity<=0)return void a();const{intensity:h}=this.chromaticAberration,n=this.scaleValue(this.chromaticAberration.maxOffset*h);t.save(),t.globalCompositeOperation="source-over",t.translate(-n,0),t.globalAlpha=.33,t.fillStyle="#ff0000",t.filter="brightness(3)",a(),t.translate(n,0),t.globalCompositeOperation="screen",t.globalAlpha=.33,t.fillStyle="#00ff00",a(),t.translate(n,0),t.globalAlpha=.33,t.fillStyle="#0000ff",a(),t.restore()}update(t){this.sparkles=this.sparkles.filter(e=>(e.x+=e.vx,e.y+=e.vy,e.rotation+=e.rotationSpeed,e.lifetime-=t,e.vy+=.1,e.lifetime>0)),this.chromaticAberration.active&&(this.chromaticAberration.intensity-=this.chromaticAberration.fadeSpeed,this.chromaticAberration.intensity<=0&&(this.chromaticAberration.intensity=0,this.chromaticAberration.active=!1,this.chromaticAberration.targetIntensity=0))}destroy(){this.speakingRings=[],this.sleepZ=[],this.sparkles=[],this.recordingActive=!1,this.sleepMode=!1,this.speakingActive=!1,this.chromaticAberration.active=!1,this.chromaticAberration.intensity=0,this.chromaticAberration.targetIntensity=0,this.ringSpawnTimer=0,this.renderer=null,this.ctx=null,this.canvas=null}}class ge{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.blinking=!1,this.blinkingEnabled=!0,this.blinkTimer=0,this.nextBlinkTime=this.getRandomBlinkTime(),this.squintAmount=0,this.eyeClose=null,this.eyeOpen=null,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}update(t){this.blinking&&(this.blinkTimer+=t,this.blinkTimer>=150&&(this.blinking=!1,this.blinkTimer=0,this.nextBlinkTime=Date.now()+this.getRandomBlinkTime())),this.blinkingEnabled&&!this.blinking&&Date.now()>=this.nextBlinkTime&&this.startBlink()}startBlink(){this.blinkingEnabled&&(this.blinking=!0,this.blinkTimer=0)}getRandomBlinkTime(){return 3e3+4e3*Math.random()}getBlinkScale(){if(!this.blinking)return 1;const t=Math.min(this.blinkTimer/150,1);return 1-.7*Math.sin(t*Math.PI)}drawEyes(t,e,i,s,a={}){const{ctx:h}=this,n=a.eyeOpenness||1,r=a.eyeExpression||"neutral";if("neutral"===s||n<=0)return;h.save(),h.strokeStyle="rgba(0, 0, 0, 0.3)",h.lineWidth=this.scaleValue(2),h.lineCap="round";const o=.4*i,l=e-.1*i,c=.25*i;switch(r){case"happy":this.drawHappyEyes(h,t,l,o,c,n);break;case"sad":this.drawSadEyes(h,t,l,o,c,n);break;case"angry":this.drawAngryEyes(h,t,l,o,c,n);break;case"surprised":this.drawSurprisedEyes(h,t,l,o,c,n);break;case"focused":this.drawFocusedEyes(h,t,l,o,c,n);break;case"sleepy":this.drawSleepyEyes(h,t,l,o,c,n);break;case"suspicious":this.drawSuspiciousEyes(h,t,l,o,c,n)}h.restore()}drawHappyEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i,a,.2*Math.PI,.8*Math.PI,!1),t.stroke(),t.beginPath(),t.arc(e+s,i,a,.2*Math.PI,.8*Math.PI,!1),t.stroke()}drawSadEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i+.5*a,a,1.2*Math.PI,1.8*Math.PI,!1),t.stroke(),t.beginPath(),t.arc(e+s,i+.5*a,a,1.2*Math.PI,1.8*Math.PI,!1),t.stroke()}drawAngryEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i-.3*a),t.lineTo(e-s+.5*a,i+.3*a),t.stroke(),t.beginPath(),t.moveTo(e+s+a,i-.3*a),t.lineTo(e+s-.5*a,i+.3*a),t.stroke()}drawSurprisedEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i,1.2*a,0,2*Math.PI),t.stroke(),t.beginPath(),t.arc(e+s,i,1.2*a,0,2*Math.PI),t.stroke()}drawFocusedEyes(t,e,i,s,a,h){t.fillStyle="rgba(0, 0, 0, 0.4)",t.beginPath(),t.arc(e-s,i,.3*a,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e+s,i,.3*a,0,2*Math.PI),t.fill()}drawSleepyEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i),t.lineTo(e-s+a,i),t.stroke(),t.beginPath(),t.moveTo(e+s-a,i),t.lineTo(e+s+a,i),t.stroke()}drawSuspiciousEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i),t.lineTo(e-s+.7*a,i),t.stroke(),t.beginPath(),t.arc(e+s,i,.8*a,.1*Math.PI,.9*Math.PI,!1),t.stroke()}setBlinkingEnabled(t){this.blinkingEnabled=t,t||(this.blinking=!1,this.blinkTimer=0)}setSquintAmount(t){this.squintAmount=Math.max(0,Math.min(1,t))}forceBlink(){this.startBlink()}}class ye{constructor(t){this.renderer=t,this.breathingSpeed=.42,this.breathingDepth=.08,this.breathingPhase=0,this.breathRate=1,this.breathDepth=this.breathingDepth,this.breathRateMult=1,this.breathDepthMult=1,this.breathIrregular=!1,this.customScale=null,this.emotionBreathPatterns={happy:{rate:1.1,depth:1.2},sad:{rate:.8,depth:.7},angry:{rate:1.4,depth:1.3},calm:{rate:.7,depth:.9},excited:{rate:1.5,depth:1.4},focused:{rate:.9,depth:.6},neutral:{rate:1,depth:1},love:{rate:1.2,depth:1.3},surprised:{rate:1.3,depth:1.1},confused:{rate:1.1,depth:.9},amused:{rate:1.2,depth:1.1},bored:{rate:.6,depth:.8},tired:{rate:.5,depth:1.2},anxious:{rate:1.6,depth:.9},determined:{rate:1.1,depth:1},proud:{rate:.9,depth:1.3},content:{rate:.8,depth:1},hopeful:{rate:1,depth:1.1},intrigued:{rate:1.1,depth:.8},embarrassed:{rate:1.3,depth:.7},grateful:{rate:.9,depth:1.1},inspired:{rate:1,depth:1.3},silly:{rate:1.4,depth:1.2},sleepy:{rate:.3,depth:1.4}}}update(t,e,i={}){i=i||{};const s=this.emotionBreathPatterns[e]||{rate:1,depth:1},a=i?.breathRateMult||1,h=i?.breathDepthMult||1;this.breathRate=s.rate*this.breathRateMult*a,this.breathDepth=this.breathingDepth*s.depth*this.breathDepthMult*h;let n=this.breathingSpeed*this.breathRate*(t/1e3);this.breathIrregular&&i?.breathIrregular&&(n*=.8+.4*Math.sin(3e-4*Date.now())),this.breathingPhase+=n,this.breathingPhase>2*Math.PI&&(this.breathingPhase-=2*Math.PI)}getBreathingScale(){return null!==this.customScale?this.customScale:1+Math.sin(this.breathingPhase)*this.breathDepth}setCustomScale(t){this.customScale=t}setBreathingSpeed(t){this.breathingSpeed=t}setBreathingDepth(t){this.breathingDepth=Math.max(0,Math.min(1,t))}setBreathRateMultiplier(t){this.breathRateMult=t}setBreathDepthMultiplier(t){this.breathDepthMult=t}setIrregularBreathing(t){this.breathIrregular=t}reset(){this.breathingPhase=0,this.breathRate=1,this.breathDepth=this.breathingDepth,this.breathRateMult=1,this.breathDepthMult=1,this.breathIrregular=!1,this.customScale=null}holdBreath(t=!1){this.customScale=t?.92:1.08}releaseBreath(){this.customScale=null}getBreathingInfo(){return{phase:this.breathingPhase,rate:this.breathRate,depth:this.breathDepth,scale:this.getBreathingScale(),isCustom:null!==this.customScale,isIrregular:this.breathIrregular}}}const be=new class{constructor(){this.cache=new Map,this.stats={hits:0,misses:0,evictions:0},this.maxSize=100,this.ttl=6e4,this.accessOrder=[],this.cleanupInterval=setInterval(()=>{this.clearExpired()},6e4)}generateKey(t,e){if("radial"===t){const{x0:t,y0:i,r0:s,x1:a,y1:h,r1:n,stops:r}=e;return`radial:${t},${i},${s},${a},${h},${n}:${r.map(t=>`${t.offset}:${t.color}`).join("|")}`}if("linear"===t){const{x0:t,y0:i,x1:s,y1:a,stops:h}=e;return`linear:${t},${i},${s},${a}:${h.map(t=>`${t.offset}:${t.color}`).join("|")}`}return null}getRadialGradient(t,e,i,s,a,h,n,r){const o=this.generateKey("radial",{x0:e,y0:i,r0:s,x1:a,y1:h,r1:n,stops:r}),l=this.cache.get(o);if(l&&Date.now()-l.timestamp<this.ttl)return this.stats.hits++,this.updateAccessOrder(o),l.gradient;this.stats.misses++;const c=t.createRadialGradient(e,i,s,a,h,n);return r.forEach(t=>{c.addColorStop(t.offset,t.color)}),this.set(o,c),c}getLinearGradient(t,e,i,s,a,h){const n=this.generateKey("linear",{x0:e,y0:i,x1:s,y1:a,stops:h}),r=this.cache.get(n);if(r&&Date.now()-r.timestamp<this.ttl)return this.stats.hits++,this.updateAccessOrder(n),r.gradient;this.stats.misses++;const o=t.createLinearGradient(e,i,s,a);return h.forEach(t=>{o.addColorStop(t.offset,t.color)}),this.set(n,o),o}set(t,e){this.cache.size>=this.maxSize&&!this.cache.has(t)&&this.evictLRU(),this.cache.set(t,{gradient:e,timestamp:Date.now()}),this.updateAccessOrder(t)}updateAccessOrder(t){const e=this.accessOrder.indexOf(t);e>-1&&this.accessOrder.splice(e,1),this.accessOrder.push(t)}evictLRU(){if(this.accessOrder.length>0){const t=this.accessOrder.shift();this.cache.delete(t),this.stats.evictions++}}clear(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.cache.clear(),this.accessOrder=[]}clearExpired(){const t=Date.now(),e=[];for(const[i,s]of this.cache.entries())t-s.timestamp>=this.ttl&&e.push(i);e.forEach(t=>{this.cache.delete(t);const e=this.accessOrder.indexOf(t);e>-1&&this.accessOrder.splice(e,1)})}destroy(){this.clear()}getStats(){const t=this.stats.hits+this.stats.misses>0?(this.stats.hits/(this.stats.hits+this.stats.misses)*100).toFixed(2):0;return{size:this.cache.size,maxSize:this.maxSize,hits:this.stats.hits,misses:this.stats.misses,evictions:this.stats.evictions,hitRate:`${t}%`}}createHelper(t){return{radial:(e,i,s,a,h,n,r)=>this.getRadialGradient(t,e,i,s,a,h,n,r),linear:(e,i,s,a,h)=>this.getLinearGradient(t,e,i,s,a,h)}}};class we{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.glowIntensity=1,this.glowColor="#4a90e2",this.targetGlowColor="#4a90e2",this.glowColorTransition=0,this.glowColorTransitionSpeed=.05,this.offscreenCanvas=null,this.offscreenCtx=null,this.cachedGlowColor=null,this.cachedGlowRadius=0,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i),this.initOffscreenCanvas()}initOffscreenCanvas(){this.offscreenCanvas=document.createElement("canvas"),this.offscreenCtx=this.offscreenCanvas.getContext("2d")}updateOffscreenSize(t){this.offscreenCanvas.width===t&&this.offscreenCanvas.height===t||(this.offscreenCanvas.width=t,this.offscreenCanvas.height=t,this.cachedGlowColor=null)}renderGlow(t,e,i,s={}){const{ctx:a}=this,h=s.color||this.glowColor,n=void 0!==s.intensity?s.intensity:this.glowIntensity;n<.01||this.renderGlowDirect(a,t,e,i,h,n)}cacheGlowGradient(t,e){const i=this.offscreenCtx,s=e;this.updateOffscreenSize(2*e),i.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height);const a=be.getRadialGradient(i,s,s,0,s,s,e,[{offset:0,color:this.hexToRgba(t,.4)},{offset:.3,color:this.hexToRgba(t,.2)},{offset:.6,color:this.hexToRgba(t,.1)},{offset:1,color:this.hexToRgba(t,0)}]);i.fillStyle=a,i.fillRect(0,0,2*e,2*e),this.cachedGlowColor=t,this.cachedGlowRadius=e}renderGlowDirect(t,e,i,s,a,h){t.save(),t.globalCompositeOperation="screen";const n=[];for(let t=0;t<=20;t++){const e=t/20,i=.6*Math.pow(1-e,2.2),s=Math.max(0,Math.min(1,i*h));n.push({offset:e,color:this.hexToRgba(a,s)})}const r=be.getRadialGradient(t,e,i,0,e,i,s,n);t.fillStyle=r,t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.fill(),t.restore()}renderRecordingGlow(t,e,i,s){const{ctx:a}=this,h=2.5*i,n=be.getRadialGradient(a,t,e,0,t,e,h,[{offset:0,color:`rgba(255, 0, 0, ${.3*s})`},{offset:.5,color:`rgba(255, 0, 0, ${.15*s})`},{offset:1,color:"rgba(255, 0, 0, 0)"}]);a.save(),a.globalCompositeOperation="screen",a.fillStyle=n,a.fillRect(t-h,e-h,2*h,2*h),a.restore()}updateGlowColor(t,e){this.targetGlowColor!==t&&(this.targetGlowColor=t,this.glowColorTransition=0),this.glowColorTransition<1&&(this.glowColorTransition=Math.min(1,this.glowColorTransition+this.glowColorTransitionSpeed),this.glowColor=this.lerpColor(this.glowColor,this.targetGlowColor,this.glowColorTransition))}lerpColor(t,e,i){const s=this.hexToRgb(t),a=this.hexToRgb(e);return`#${((1<<24)+(Math.round(s.r+(a.r-s.r)*i)<<16)+(Math.round(s.g+(a.g-s.g)*i)<<8)+Math.round(s.b+(a.b-s.b)*i)).toString(16).slice(1)}`}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}setGlowIntensity(t){this.glowIntensity=Math.max(0,Math.min(1,t))}setGlowColor(t){this.glowColor=t,this.targetGlowColor=t,this.glowColorTransition=1}destroy(){this.offscreenCanvas&&(this.offscreenCtx&&(this.offscreenCtx.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),this.offscreenCtx=null),this.offscreenCanvas.width=0,this.offscreenCanvas.height=0,this.offscreenCanvas=null),this.cachedGlowColor=null,this.cachedGlowRadius=0}}class ve{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.coreColor="#FFFFFF",this.coreOpacity=1,this.coreBorderWidth=0,this.coreBorderColor=null,this.shapePoints=null,this.isMorphing=!1,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}renderCore(t,e,i,s={}){const{ctx:a}=this,h=s.scaleX||1,n=s.scaleY||1,r=s.rotation||0,o=void 0!==s.opacity?s.opacity:this.coreOpacity,l=s.color||this.coreColor,c=s.shapePoints||this.shapePoints;a.save(),a.translate(t,e),0!==r&&a.rotate(r),a.scale(h,n),a.fillStyle=this.hexToRgba(l,o),c&&c.length>0?this.drawMorphedShape(a,c,i):this.drawCircle(a,i),this.coreBorderWidth>0&&this.coreBorderColor&&(a.strokeStyle=this.coreBorderColor,a.lineWidth=this.scaleValue(this.coreBorderWidth),a.stroke()),a.restore()}drawDropShadow(t,e,i){t.save();const s=this.scaleValue(2);if(t.translate(0,s),i&&i.length>32)t.fillStyle="rgba(0, 0, 0, 0.15)",t.beginPath(),t.arc(0,0,1.05*e,0,2*Math.PI),t.fill();else{const s=be.getRadialGradient(t,0,0,.7*e,0,0,1.2*e,[{offset:0,color:"rgba(0, 0, 0, 0.2)"},{offset:.8,color:"rgba(0, 0, 0, 0.1)"},{offset:1,color:"rgba(0, 0, 0, 0)"}]);if(t.fillStyle=s,t.beginPath(),i){const e=1.1,s=i.length>20?2:1;t.moveTo(i[0].x*e,i[0].y*e);for(let a=s;a<i.length;a+=s)t.lineTo(i[a].x*e,i[a].y*e);t.closePath()}else t.arc(0,0,1.1*e,0,2*Math.PI);t.fill()}t.restore()}drawCircle(t,e){t.beginPath(),t.arc(0,0,e,0,2*Math.PI),t.fill()}drawMorphedShape(t,e,i){!e||e.length<3?this.drawCircle(t,i):(t.beginPath(),e.forEach((e,i)=>{0===i?t.moveTo(e.x,e.y):t.lineTo(e.x,e.y)}),t.closePath(),t.fill())}renderSleepyCore(t,e,i){const{ctx:s}=this;s.save(),s.translate(t,e),s.scale(1,.85),s.fillStyle="#FFFFFF",s.beginPath(),s.arc(0,0,i,0,2*Math.PI),s.fill(),s.restore()}renderGlitchedCore(t,e,i,s){const{ctx:a}=this;a.save(),[{x:-2,y:0,alpha:.3},{x:2,y:0,alpha:.3},{x:0,y:-1,alpha:.2}].forEach(h=>{a.fillStyle=this.hexToRgba("#FFFFFF",h.alpha*s),a.beginPath(),a.arc(t+h.x*s*this.scaleValue(5),e+h.y*s*this.scaleValue(5),i,0,2*Math.PI),a.fill()}),a.fillStyle="#FFFFFF",a.beginPath(),a.arc(t,e,i,0,2*Math.PI),a.fill(),a.restore()}setShapePoints(t){this.shapePoints=t,this.isMorphing=t&&t.length>0}clearShapePoints(){this.shapePoints=null,this.isMorphing=!1}setCoreColor(t){this.coreColor=t}setCoreOpacity(t){this.coreOpacity=Math.max(0,Math.min(1,t))}setCoreBorder(t,e){this.coreBorderWidth=t,this.coreBorderColor=e}getCoreInfo(){return{color:this.coreColor,opacity:this.coreOpacity,hasBorder:this.coreBorderWidth>0,isMorphing:this.isMorphing,shapePointCount:this.shapePoints?this.shapePoints.length:0}}}class Se{renderSunEffects(t,e,i,s,a){const h=Date.now()/100;if(t.save(),t.translate(e,i),a.texture&&(void 0===a.textureOpacity||a.textureOpacity>0)){t.save(),t.globalCompositeOperation="screen",t.globalAlpha=void 0!==a.textureOpacity?a.textureOpacity:1;const e=.05*h*(a.turbulence||.3)/.3,i=t.createRadialGradient(Math.sin(e)*s*.15,Math.cos(.7*e)*s*.15,.2*s,0,0,s);i.addColorStop(0,"rgba(255, 255, 200, 0)"),i.addColorStop(.4,"rgba(255, 200, 100, 0.1)"),i.addColorStop(.7,"rgba(255, 150, 50, 0.08)"),i.addColorStop(1,"rgba(255, 100, 30, 0.05)"),t.fillStyle=i,t.beginPath(),t.arc(0,0,s,0,2*Math.PI),t.fill(),t.restore()}const n=void 0!==a.coronaOpacity?a.coronaOpacity:1;if(n>0){t.save(),t.globalCompositeOperation="screen";const e=t.createRadialGradient(0,0,.5*s,0,0,1.1*s);e.addColorStop(0,`rgba(255, 255, 255, ${.8*n})`),e.addColorStop(.3,`rgba(255, 250, 200, ${.6*n})`),e.addColorStop(.5,`rgba(255, 200, 100, ${.4*n})`),e.addColorStop(.7,`rgba(255, 150, 50, ${.2*n})`),e.addColorStop(1,"rgba(255, 100, 20, 0)"),t.fillStyle=e,t.beginPath(),t.arc(0,0,1.1*s,0,2*Math.PI),t.fill();for(let e=0;e<2;e++){const i=1.3+.4*e,a=(.35-.15*e)*n,r=.05*Math.sin(.1*h+e),o=t.createRadialGradient(0,0,s*(.9+r),0,0,s*(i+r));o.addColorStop(0,"rgba(255, 255, 200, 0)"),o.addColorStop(.4,`rgba(255, 200, 100, ${.5*a})`),o.addColorStop(.7,`rgba(255, 150, 50, ${a})`),o.addColorStop(.9,`rgba(255, 100, 30, ${.5*a})`),o.addColorStop(1,"rgba(255, 50, 10, 0)"),t.fillStyle=o,t.beginPath(),t.arc(0,0,s*(i+r),0,2*Math.PI),t.fill()}t.restore()}if(a.flares){t.save();const e=Math.sin(.08*h),i=Math.sin(.12*h),a=Math.sin(.16*h),n=t.createLinearGradient(0,-s,0,3*-s);n.addColorStop(0,"rgba(255, 255, 230, 0.4)"),n.addColorStop(.2,"rgba(255, 220, 150, 0.25)"),n.addColorStop(.5,"rgba(255, 180, 80, 0.15)"),n.addColorStop(.8,"rgba(255, 120, 40, 0.08)"),n.addColorStop(1,"rgba(255, 60, 20, 0)"),t.fillStyle=n,t.globalCompositeOperation="screen",t.beginPath();const r=(e,i,a,h)=>{const n=Math.cos(e),r=Math.sin(e),o=n*s,l=r*s,c=n*(s+i),u=r*(s+i),p=-r*a*.5,d=n*a*.5,f=h*a*.3;t.moveTo(o-p,l-d),t.quadraticCurveTo(.5*(o+c)+p*f,.5*(l+u)+d*f,c,u),t.quadraticCurveTo(.5*(o+c)-p*f,.5*(l+u)-d*f,o+p,l+d)};for(let t=0;t<8;t++)r(t/8*Math.PI*2+.1*e,s*(1.8+.4*Math.sin(.1*h+.5*t)),.18*s,Math.sin(.15*h+t));for(let t=0;t<12;t++)r((t+.5)/12*Math.PI*2+.08*i,s*(1.2+.3*Math.sin(.13*h+.7*t)),.12*s,Math.sin(.18*h+1.2*t));for(let t=0;t<15;t++)r(t/15*Math.PI*2+.05*a,s*(.7+.25*Math.sin(.17*h+.9*t)),.08*s,Math.sin(.2*h+1.5*t));for(let e=0;e<15;e++){const i=(e+.25)/15*Math.PI*2,a=s*(.4+.2*Math.sin(.22*h+e)),n=.06*s,r=Math.cos(i),o=Math.sin(i),l=r*s,c=o*s,u=r*(s+a),p=o*(s+a),d=-o*n*.5,f=r*n*.5;t.moveTo(l-d,c-f),t.lineTo(u,p),t.lineTo(l+d,c+f)}t.fill(),t.restore()}const r=t.createRadialGradient(0,0,.95*s,0,0,1.05*s);r.addColorStop(0,"rgba(255, 255, 255, 0)"),r.addColorStop(.7,"rgba(255, 255, 200, 0.2)"),r.addColorStop(.9,"rgba(255, 200, 100, 0.5)"),r.addColorStop(1,"rgba(255, 150, 50, 0.3)"),t.fillStyle=r,t.beginPath(),t.arc(0,0,1.05*s,0,2*Math.PI),t.fill(),t.restore()}renderBaileysBeads(t,e,i,s,a,h,n,r,o,l=t=>t){if(!o)return void(this.X=null);const c=Math.abs(a)<1&&Math.abs(h)<1,u=r?30:15;if(!(Math.abs(a)<u&&Math.abs(h)<u||c))return void(this.X=null);if(!this.X){const t=Math.floor(4*Math.random())+1;this.Y=[];const e=[];for(let i=0;i<t;i++)e.push(Math.random()*Math.PI*2);const i=Array.from({length:t},(t,e)=>e);for(let t=i.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[i[t],i[e]]=[i[e],i[t]]}for(let s=0;s<t;s++)this.Y.push({angle:e[s],size:3+5*Math.random(),order:i[s],delay:200*i[s]});this.X=Date.now()}const p=Date.now()-this.X;(this.Y||[]).forEach(a=>{if(p<a.delay)return;const h=p-a.delay,n=Math.min(1,h/300),r=e+Math.cos(a.angle)*s,o=i+Math.sin(a.angle)*s;t.save(),t.translate(r,o),t.globalAlpha=n;const c=l(a.size),u=[{color:`rgba(255, 100, 100, ${.6*n})`,offset:-2},{color:`rgba(100, 255, 100, ${.6*n})`,offset:0},{color:`rgba(100, 100, 255, ${.6*n})`,offset:2}];t.globalCompositeOperation="screen",u.forEach(({color:e,offset:i})=>{const s=t.createRadialGradient(i,i,0,i,i,2*c);s.addColorStop(0,e),s.addColorStop(.2,e.replace(""+.6*n,""+.4*n)),s.addColorStop(.5,e.replace(""+.6*n,""+.2*n)),s.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=s,t.beginPath(),t.arc(i,i,2*c,0,2*Math.PI),t.fill()}),t.globalCompositeOperation="lighter";const d=t.createRadialGradient(0,0,0,0,0,c);d.addColorStop(0,`rgba(255, 255, 255, ${n})`),d.addColorStop(.3,`rgba(255, 255, 255, ${.5*n})`),d.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=d,t.beginPath(),t.arc(0,0,c,0,2*Math.PI),t.fill(),t.restore()})}renderMoonShadow(t,e,i,s,a,h,n=!1,r=0,o=null){if(t.save(),t.globalAlpha=1,t.translate(e,i),"crescent"===a.type){let e=1,i=a.offset||.7;if(o){const t=o.getProgress(),{targetShape:s}=o;"moon"===s&&void 0!==t&&t<1&&!a.shadowX&&(e=t,i=2.7*e-2)}const n=(a.angle||-30)*Math.PI/180,r=Math.cos(n)*s*i,l=Math.sin(n)*s*i;if(t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.beginPath(),h&&h.length>0){t.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)t.lineTo(h[e].x,h[e].y);t.closePath()}else t.arc(0,0,s,0,2*Math.PI);t.clip();const c=t.createRadialGradient(r,l,.9*s,r,l,1.1*s),u=void 0!==a.coverage?a.coverage:.85,p=Math.min(1,1.2*e)*(u/.85);c.addColorStop(0,`rgba(0, 0, 0, ${1*p})`),c.addColorStop(.8,`rgba(0, 0, 0, ${1*p})`),c.addColorStop(.88,`rgba(0, 0, 0, ${.98*p})`),c.addColorStop(.91,`rgba(0, 0, 0, ${.95*p})`),c.addColorStop(.93,`rgba(0, 0, 0, ${.9*p})`),c.addColorStop(.95,`rgba(0, 0, 0, ${.8*p})`),c.addColorStop(.96,`rgba(0, 0, 0, ${.65*p})`),c.addColorStop(.97,`rgba(0, 0, 0, ${.45*p})`),c.addColorStop(.98,`rgba(0, 0, 0, ${.25*p})`),c.addColorStop(.99,`rgba(0, 0, 0, ${.1*p})`),c.addColorStop(1,"rgba(0, 0, 0, 0)"),t.fillStyle=c,t.beginPath(),t.arc(r,l,1.1*s,0,2*Math.PI),t.fill()}else if("lunar"===a.type){const e=1-(void 0!==a.diffusion?a.diffusion:1);let i=0,h=0;if(o){const t=o.getProgress(),{currentShape:e,targetShape:a}=o;if(n&&"solar"===a&&void 0!==t&&t<1){const e=2.5*s;i=-e*(1-t),h=e*(1-t)}else if(n&&"solar"===e&&"solar"!==a&&null!==a&&void 0!==t&&t<1){const e=2.5*s;i=e*t,h=-e*t}}t.translate(i,h),n?(t.save(),t.beginPath(),t.arc(-i,-h,s,0,2*Math.PI),t.clip()):(t.beginPath(),t.arc(0,0,s,0,2*Math.PI),t.clip());const r=s*(1.8-.5*e),l=t.createRadialGradient(0,0,.2*s,0,0,r),c=a.coverage||.9;if(a.color&&a.color.includes("0, 0, 0")?(l.addColorStop(0,`rgba(0, 0, 0, ${c})`),l.addColorStop(.3+.2*e,`rgba(0, 0, 0, ${.95*c})`),l.addColorStop(.6+.2*e,`rgba(0, 0, 0, ${.8*c})`),l.addColorStop(.85,`rgba(0, 0, 0, ${.4*c})`),l.addColorStop(1,"rgba(0, 0, 0, 0)")):(l.addColorStop(0,`rgba(10, 2, 0, ${c})`),l.addColorStop(.3+.2*e,`rgba(20, 5, 0, ${.95*c})`),l.addColorStop(.6+.2*e,`rgba(40, 10, 5, ${.8*c})`),l.addColorStop(.85,`rgba(60, 15, 10, ${.4*c})`),l.addColorStop(1,"rgba(80, 20, 15, 0)")),t.fillStyle=l,t.beginPath(),t.arc(0,0,r,0,2*Math.PI),t.fill(),e>.3){const i=s*(.8+.3*e),h=t.createRadialGradient(0,0,0,0,0,i);a.color&&a.color.includes("0, 0, 0")?(h.addColorStop(0,`rgba(0, 0, 0, ${c})`),h.addColorStop(.5,`rgba(0, 0, 0, ${.9*c})`),h.addColorStop(.8,`rgba(0, 0, 0, ${.5*c})`),h.addColorStop(1,"rgba(0, 0, 0, 0)")):(h.addColorStop(0,`rgba(0, 0, 0, ${c})`),h.addColorStop(.5,`rgba(10, 2, 0, ${.9*c})`),h.addColorStop(.8,`rgba(20, 5, 0, ${.5*c})`),h.addColorStop(1,"rgba(30, 8, 5, 0)")),t.fillStyle=h,t.beginPath(),t.arc(0,0,i,0,2*Math.PI),t.fill()}}n&&t.restore(),t.restore()}}class Fe{constructor(t){this.renderer=t,this.episodicEffects={nervous:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:3e3+2e3*Math.random()},confident:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:4e3+2e3*Math.random()},tired:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:5e3+2e3*Math.random()},intense:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:3e3+3e3*Math.random()},subdued:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:4e3+3e3*Math.random()}}}getEpisodicEffects(){return this.episodicEffects}updateEpisodicEffects(t,e,i,s,a){if(!t||!this.episodicEffects[t])return{jitterX:e,jitterY:i,coreRadius:s,glowRadius:a};const h=this.episodicEffects[t],n=performance.now();if(!h.active&&n>=h.nextTrigger)switch(h.active=!0,h.startTime=n,t){case"nervous":h.duration=500+500*Math.random(),h.intensity=2+Math.random(),h.nextTrigger=n+3e3+2e3*Math.random();break;case"confident":h.duration=1e3+1e3*Math.random(),h.intensity=.15,h.nextTrigger=n+4e3+2e3*Math.random();break;case"tired":h.duration=1e3+2e3*Math.random(),h.intensity=.2,h.nextTrigger=n+5e3+2e3*Math.random();break;case"intense":h.duration=500+500*Math.random(),h.intensity=.5,h.nextTrigger=n+3e3+3e3*Math.random();break;case"subdued":h.duration=2e3+1e3*Math.random(),h.intensity=.3,h.nextTrigger=n+4e3+3e3*Math.random()}if(h.active){const r=n-h.startTime;if(r<h.duration){const n=r/h.duration;switch(t){case"nervous":{const t=1-n,s=15,a=Math.sin(n*Math.PI*s)*t;e=a*h.intensity,i=a*h.intensity*.7;break}case"confident":{const t=Math.sin(n*Math.PI);s*=1+h.intensity*t,a*=1+.5*h.intensity*t;break}case"tired":{const t=Math.sin(n*Math.PI*.5);s*=1-h.intensity*t,i+=5*t;break}case"intense":{const t=1-Math.cos(n*Math.PI);s*=1-.05*t,a*=1+h.intensity*t;break}case"subdued":{const t=Math.sin(n*Math.PI*.5);s*=1-.1*t,a*=1-h.intensity*t;break}}}else h.active=!1}return{jitterX:e,jitterY:i,coreRadius:s,glowRadius:a}}reset(){Object.keys(this.episodicEffects).forEach(t=>{this.episodicEffects[t].active=!1,this.episodicEffects[t].startTime=0,this.episodicEffects[t].duration=0,this.episodicEffects[t].intensity=0})}getEpisodeState(t){return this.episodicEffects[t]||null}isEpisodeActive(t){const e=this.episodicEffects[t];return!!e&&e.active}}class xe{constructor(t){this.renderer=t,this.brakeStartTime=null,this.brakeDuration=2500,this.brakeStartRotation=0,this.brakeTargetRotation=0,this.brakeStartVelocity=0,this.onComplete=null,this.onProgress=null,this.DURATION_FACTOR=14}brakeToUpright(t={}){return this.brakeToTarget(0,t)}brakeToNearest(t,e={}){const i=this.renderer.state.manualRotation||0,s=Math.round(i/t)*t;return this.brakeToTarget(s,e)}brakeToTarget(t,e={}){return new Promise(i=>{const{onProgress:s=null,onComplete:a=null}=e;this.onProgress=s,this.onComplete=a;const h=this.renderer.state.rotationSpeed||0,n=this.renderer.state.manualRotation||0;if(0===h||this.brakeStartTime)return void i();if(this.brakeStartTime=performance.now(),this.brakeStartRotation=n,this.brakeStartVelocity=h,0===t)this.brakeTargetRotation=h>0?360*(Math.floor(n/360)+1):360*Math.floor(n/360);else{const e=t%360,i=Math.floor(n/360);this.brakeTargetRotation=h>0?e>n%360?360*i+e:360*(i+1)+e:e<n%360?360*i+e:360*(i-1)+e}const r=Math.abs(this.brakeTargetRotation-this.brakeStartRotation);this.brakeDuration=Math.max(500,r/Math.abs(h)*this.DURATION_FACTOR*5),this.renderer.setRotationSpeed(0),this.resolvePromise=i})}updateBrake(t){if(!this.brakeStartTime)return null;const e=t-this.brakeStartTime,i=Math.min(e/this.brakeDuration,1),s=1-Math.pow(1-i,4),a=this.brakeStartRotation+(this.brakeTargetRotation-this.brakeStartRotation)*s,h=this.brakeStartVelocity*Math.pow(1-s,2);return this.onProgress&&this.onProgress(s,h,a),i>=1?(this.brakeStartTime=null,this.complete(),{rotation:this.brakeTargetRotation,speed:0,complete:!0}):{rotation:a,speed:h,complete:!1}}stop(){this.brakeStartTime=null}complete(){this.onComplete&&this.onComplete(),this.resolvePromise&&(this.resolvePromise(),this.resolvePromise=null)}isBraking(){return null!==this.brakeStartTime}emergencyStop(){this.stop(),this.renderer.setRotationSpeed(0),this.complete()}getProgress(){if(!this.brakeStartTime)return 0;const t=performance.now()-this.brakeStartTime;return Math.min(t/this.brakeDuration,1)}destroy(){this.stop(),this.onComplete=null,this.onProgress=null,this.resolvePromise=null,this.renderer=null,this.brakeStartTime=null,this.brakeStartRotation=0,this.brakeTargetRotation=0,this.brakeStartVelocity=0}}class ke{constructor(t){this.renderer=t,this.rotationBrake=new xe(t)}setRotationSpeed(t){this.renderer.state.rotationSpeed=t}setRotationAngle(t){this.renderer.state.manualRotation=t}getRotationAngle(){return this.renderer.state.manualRotation}getRotationSpeed(){return this.renderer.state.rotationSpeed}isBraking(){return this.rotationBrake&&this.rotationBrake.isBraking()}updateRotation(t){if(this.rotationBrake&&this.rotationBrake.isBraking()){const e=this.rotationBrake.updateBrake(t);e&&(this.renderer.state.manualRotation=e.rotation,this.renderer.state.rotationSpeed=e.complete?0:e.speed)}else 0!==this.renderer.state.rotationSpeed&&(this.renderer.state.manualRotation+=this.renderer.state.rotationSpeed);this.renderer.state.lastRotationUpdate=t}calculateTotalRotation(t=0,e=0){return(t+e+this.renderer.state.manualRotation)*Math.PI/180}applyRotation(t,e){0!==e&&t.rotate(e)}applyRotationTransform(t,e,i,s){this.updateRotation(performance.now());const a=this.calculateTotalRotation(s);return 0!==a&&(t.save(),t.translate(e,i),this.applyRotation(t,a),t.translate(-e,-i)),a}reset(){this.renderer.state.manualRotation=0,this.renderer.state.rotationSpeed=0,this.renderer.state.lastRotationUpdate=performance.now()}destroy(){this.rotationBrake&&(this.rotationBrake=null)}}let Be=class{constructor(t){this.renderer=t,this.canvas=t.canvas,this.initialized=!1,this.handleMouseMove=null,this.handleTouchMove=null}setEnabled(t){this.renderer.state.gazeTrackingEnabled=t,t?this.initialized||this.initialize():this.renderer.state.gazeTarget={x:0,y:0}}initialize(){this.initialized||(this.handleMouseMove=t=>{if(!this.renderer.state.gazeTrackingEnabled)return;const e=this.canvas.getBoundingClientRect(),i=e.width/2,s=e.height/2,a=t.clientX-e.left-i,h=t.clientY-e.top-s;this.renderer.state.gazeTarget={x:a/i,y:h/s}},this.handleTouchMove=t=>{if(this.renderer.state.gazeTrackingEnabled&&t.touches.length>0){const e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=i.width/2,a=i.height/2,h=e.clientX-i.left-s,n=e.clientY-i.top-a;this.renderer.state.gazeTarget={x:h/s,y:n/a}}},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),this.initialized=!0)}cleanup(){this.initialized&&(this.handleMouseMove&&(document.removeEventListener("mousemove",this.handleMouseMove),this.handleMouseMove=null),this.handleTouchMove&&(document.removeEventListener("touchmove",this.handleTouchMove),this.handleTouchMove=null),this.initialized=!1)}isInitialized(){return this.initialized}getGazeTarget(){return this.renderer.state.gazeTarget}isEnabled(){return this.renderer.state.gazeTrackingEnabled}};class Ce{constructor(t){this.renderer=t}setupCanvas(){this.renderer.updateOffscreenSize();const t=this.renderer.canvasManager.width||this.renderer.canvas.width||400,e=this.renderer.canvasManager.height||this.renderer.canvas.height||400,i=this.renderer.ctx;return this.renderer.ctx=this.renderer.offscreenCtx,{logicalWidth:t,logicalHeight:e,originalCtx:i}}renderBackdrop(t,e,i,s){const a=Math.min(t,e),h=this.renderer.getEffectiveCenter(),n=h.x,r=h.y-this.renderer.config.topOffset,o=a/this.renderer.config.referenceSize*this.renderer.config.baseScale*(h.coreScale||h.scale),l=this.renderer.config.referenceSize/this.renderer.config.coreSizeDivisor*o;this.renderer.backdropRenderer.update(s),this.renderer.audioAnalyzer&&this.renderer.audioAnalyzer.currentAmplitude&&this.renderer.backdropRenderer.setAudioIntensity(this.renderer.audioAnalyzer.currentAmplitude),this.renderer.backdropRenderer.render(n,r,l,i)}applyCanvasDecay(t,e,i){const s=this.renderer.particleSystem?this.renderer.particleSystem.particles.length:0,a=.12+Math.min(.08,.003*s);t.save(),t.globalCompositeOperation="destination-out",t.fillStyle=`rgba(0, 0, 0, ${a})`,t.fillRect(0,0,e,i),t.restore()}clearOffscreenCanvas(t,e){this.renderer.ctx.clearRect(0,0,t,e)}performCanvasSetup(t,e,i,s){this.renderBackdrop(t,e,i,s),this.applyCanvasDecay(i,t,e),this.clearOffscreenCanvas(t,e)}}class Re{constructor(t){this.renderer=t}markFrameStart(){return this.renderer.performanceMonitor&&this.renderer.performanceMonitor.markFrameStart(),performance.now()}handleCleanRender(){this.renderer.forceCleanRender&&(this.renderer.forceCleanRender=!1,this.renderer.canvas&&this.renderer.ctx&&this.renderer.ctx.clearRect(0,0,this.renderer.canvas.width,this.renderer.canvas.height))}initializeFrame(){const t=this.markFrameStart();return this.handleCleanRender(),t}}class Te{constructor(t){this.renderer=t}mergeTransforms(t,e){const i=this.renderer.ambientDanceAnimator.getTransform(e);return t?(t.x=(t.x||0)+(i.x||0),t.y=(t.y||0)+(i.y||0),t.rotation=(t.rotation||0)+(i.rotation||0),t.scale=(t.scale||1)*(i.scale||1),t):i}mergeAndStoreTransforms(t,e){const i=this.mergeTransforms(t,e);return this.renderer.gestureTransform=i,i}}class Pe{constructor(t){this.renderer=t}updateUndertoneModifiers(){if(this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers){const t=this.renderer.stateMachine.getWeightedUndertoneModifiers();t?this.renderer.applyUndertoneModifiers(t):this.renderer.applyUndertoneModifiers(null)}}updateColorTransition(t){this.renderer.colorTransition&&this.renderer.colorTransition.active&&this.renderer.updateColorTransition(t)}updateAnimationTimers(t){this.renderer.updateTimers(t)}updateGazeOffset(){if(this.renderer.state.gazeTrackingEnabled){const t=.15,e=50;this.renderer.state.gazeOffset.x+=(this.renderer.state.gazeTarget.x*e-this.renderer.state.gazeOffset.x)*t,this.renderer.state.gazeOffset.y+=(this.renderer.state.gazeTarget.y*e-this.renderer.state.gazeOffset.y)*t}else{const t=.1;this.renderer.state.gazeOffset.x+=(0-this.renderer.state.gazeOffset.x)*t,this.renderer.state.gazeOffset.y+=(0-this.renderer.state.gazeOffset.y)*t}}performFrameStateUpdates(t){this.updateUndertoneModifiers(),this.updateColorTransition(t),this.updateAnimationTimers(t),this.updateGazeOffset()}}class Oe{constructor(t){this.renderer=t}calculateBaseDimensions(t,e){const i=Math.min(t,e),s=this.renderer.getEffectiveCenter();return this.renderer.scaleFactor=i/this.renderer.config.referenceSize*this.renderer.config.baseScale*(s.coreScale||s.scale),this.renderer.particleScaleFactor=i/this.renderer.config.referenceSize*this.renderer.config.baseScale*(s.particleScale||s.scale),{canvasSize:i,effectiveCenter:s}}calculateCenterPosition(t,e,i){const s=t.x;let a=t.y-this.renderer.config.topOffset;return e.properties&&e.properties.verticalOffset&&(a=t.y-this.renderer.config.topOffset+i*e.properties.verticalOffset),{centerX:s,centerY:a}}applyGestureTransform(t,e,i){let s=1,a=0,h=1;return i&&(t+=i.x||0,e+=i.y||0,s=i.scale||1,a=(i.rotation||0)*Math.PI/180,h=i.glowIntensity||1),{centerX:t,centerY:e,scaleMultiplier:s,rotationAngle:a,glowMultiplier:h}}applyGestureAnimations(t,e,i,s,a){const h=this.renderer.gestureAnimator.applyGestureAnimations();return h&&(t+=h.offsetX||0,e+=h.offsetY||0,i*=h.scale||1,s+=(h.rotation||0)*Math.PI/180,a=h.glow||1),{centerX:t,centerY:e,scaleMultiplier:i,rotationAngle:s,glowMultiplier:a,gestureTransforms:h}}calculateRenderDimensions(t,e,i,s){const{canvasSize:a,effectiveCenter:h}=this.calculateBaseDimensions(t,e);let n,r,o,{centerX:l,centerY:c}=this.calculateCenterPosition(h,i,e);({centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o}=this.applyGestureTransform(l,c,s));const u=this.applyGestureAnimations(l,c,n,r,o);({centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o}=u);const{gestureTransforms:p}=u;return{canvasSize:a,effectiveCenter:h,centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o,gestureTransforms:p}}}class Ae{constructor(t){this.renderer=t}calculateSleepModifiers(){let t=1,e=1,i=1;return(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(t=void 0!==this.renderer.state.sleepDimness?this.renderer.state.sleepDimness:.3,i=.2,e=void 0!==this.renderer.state.sleepScale?this.renderer.state.sleepScale:.9,this.renderer.state.breathRate=.5,this.renderer.state.breathDepth=.15),{sleepOpacityMod:t,sleepScaleMod:e,glowOpacityMod:i}}calculateBreathingFactors(){let t,e;if(null!==this.renderer.state.customScale)t=this.renderer.state.customScale,e=1+.5*(this.renderer.state.customScale-1);else{const i=this.renderer.breathingAnimator.getBreathingScale();t=i,e=1-.5*(i-1)}return"nervous"===this.renderer.state.undertone&&this.renderer.undertoneModifiers.nervous.glowPulse&&(e*=1+Math.sin(Date.now()/200)*this.renderer.undertoneModifiers.nervous.glowPulse),{coreBreathFactor:t,glowBreathFactor:e}}calculateRadii(t,e,i){const{sleepOpacityMod:s,sleepScaleMod:a,glowOpacityMod:h}=this.calculateSleepModifiers(),{coreBreathFactor:n,glowBreathFactor:r}=this.calculateBreathingFactors(),o=this.renderer.config.referenceSize/this.renderer.config.coreSizeDivisor*this.renderer.scaleFactor,l=t.properties&&t.properties.coreSize?t.properties.coreSize:1,c=this.renderer.state.sizeMultiplier||1;return{coreRadius:o*l*n*e*a*c,glowRadius:o*this.renderer.config.glowMultiplier*r*this.renderer.state.glowIntensity*e*a*c*i,effectiveGlowIntensity:this.renderer.state.glowIntensity*i,sleepOpacityMod:s,glowOpacityMod:h}}}class De{constructor(t){this.renderer=t}applyBlinkSquish(t){return this.renderer.state.sleeping||(t*=this.renderer.eyeRenderer.getBlinkScale()),t}calculateJitter(t,e){let i=0,s=0;const a=this.renderer.state.jitterAmount||0;if(this.renderer.currentUndertone)({jitterX:i,jitterY:s,coreRadius:t,glowRadius:e}=this.renderer.episodicEffectController.updateEpisodicEffects(this.renderer.currentUndertone,i,s,t,e));else if(this.renderer.state.coreJitter||a>0){const t=Math.max(a,this.renderer.state.coreJitter?this.renderer.scaleValue(2):0);i=(Math.random()-.5)*t,s=(Math.random()-.5)*t}return{jitterX:i,jitterY:s,coreRadius:t,glowRadius:e}}calculateFinalPosition(t,e,i,s){return{coreX:t+this.renderer.state.gazeOffset.x+i,coreY:e+this.renderer.state.gazeOffset.y+s}}applyAllModifications(t,e,i,s,a){let h,n;s=this.applyBlinkSquish(s),({jitterX:h,jitterY:n,coreRadius:s,glowRadius:a}=this.calculateJitter(s,a));const{coreX:r,coreY:o}=this.calculateFinalPosition(t,e,h,n);return{coreX:r,coreY:o,rotationAngle:i,coreRadius:s,glowRadius:a}}}class ze{constructor(t){this.renderer=t}renderGlow(t,e,i,s,a,h){this.renderer.state.sleeping||"resting"===this.renderer.state.emotion?(this.renderer.ctx.save(),this.renderer.ctx.globalAlpha=a,this.renderer.glowRenderer.renderGlow(t,e,i,{intensity:s}),this.renderer.ctx.restore()):this.renderer.glowRenderer.renderGlow(t,e,i,{intensity:s})}renderFlashWave(t,e,i,s){if(t&&t.flashWave){const a=t.flashWave,{ctx:h}=this.renderer;h.save(),h.globalCompositeOperation="lighter";const n=s*a.innerRadius,r=s*a.outerRadius;if(r>n){const t=be.getRadialGradient(h,e,i,n,e,i,r,[{offset:0,color:"rgba(255, 255, 255, 0)"},{offset:.2,color:`rgba(255, 255, 255, ${.15*a.intensity})`},{offset:.5,color:`rgba(255, 255, 255, ${.25*a.intensity})`},{offset:.8,color:`rgba(255, 255, 255, ${.15*a.intensity})`},{offset:1,color:"rgba(255, 255, 255, 0)"}]);h.fillStyle=t,h.beginPath(),h.arc(e,i,r,0,2*Math.PI),h.arc(e,i,Math.max(0,n),0,2*Math.PI,!0),h.fill()}h.restore()}}renderSpeakingPulse(t,e,i,s){}renderAllEffects(t){const{coreX:e,coreY:i,glowRadius:s,effectiveGlowIntensity:a,glowOpacityMod:h,gestureTransforms:n,coreRadius:r,deltaTime:o}=t;this.renderGlow(e,i,s,a,h,o),this.renderFlashWave(n,e,i,r),this.renderSpeakingPulse(e,i,r,o)}}class Ee{constructor(t){this.renderer=t}applySleepOpacity(t){(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(this.renderer.ctx.globalAlpha=t)}updateShapeMorpher(t){let e=null,i=null;return this.renderer.shapeMorpher&&(this.renderer.shapeMorpher.update(),e=this.renderer.shapeMorpher.getCanvasPoints(0,0,t),i=this.renderer.shapeMorpher.getCurrentShadow()),{shapePoints:e,currentShadow:i}}renderSunEffects(t,e,i,s){let a=!1;return!s||"sun"!==s.type&&"solar-hybrid"!==s.type||(this.renderer.renderSunEffects(t,e,i,s),a=!0),a}renderCore(t,e,i,s,a){this.renderer.coreRenderer.renderCore(t,e,i,{scaleX:1,scaleY:1,rotation:s,shapePoints:a})}renderSparkles(t){this.renderer.specialEffects&&(this.renderer.specialEffects.update(t),this.renderer.specialEffects.renderSparkles())}renderShadowEffects(t,e,i,s,a,h){const n=this.renderer.shapeMorpher?this.renderer.shapeMorpher.currentShape:null,r=this.renderer.shapeMorpher?this.renderer.shapeMorpher.targetShape:null,o=this.renderer.shapeMorpher&&"solar"===r&&this.renderer.shapeMorpher.isTransitioning,l=this.renderer.shapeMorpher&&"solar"===n&&this.renderer.shapeMorpher.isTransitioning,c=s&&"solar-hybrid"===s.type,u=this.renderer.shapeMorpher&&this.renderer.shapeMorpher.isTransitioning&&"solar"===n&&"moon"===r,p=this.renderer.shapeMorpher&&this.renderer.shapeMorpher.isTransitioning&&"moon"===n&&"solar"===r;if(!s||"crescent"!==s.type&&"lunar"!==s.type||p||this.renderer.renderMoonShadow(t,e,i,s,a,!1,0),(c&&s.lunarOverlay||o||l)&&!u){const n=c&&s.lunarOverlay?s.lunarOverlay:{type:"lunar",coverage:1,color:"rgba(0, 0, 0, 1.0)",progression:"center"};let r=0,u=0,p=0;if(this.renderer.shapeMorpher){p=this.renderer.shapeMorpher.getProgress();const t=2.5*i;o&&p<1?(r=-t*(1-p),u=t*(1-p)):l&&p<1&&(r=t*p,u=-t*p)}if(this.renderer.renderMoonShadow(t,e,i,n,a,!0),(o||l)&&(o||h)&&(this.renderer.renderBaileysBeads(t,e,i,r,u,p,o,!0),Math.abs(r)<30&&Math.abs(u)<30&&this.renderer.specialEffects)){const t=Math.sqrt(r*r+u*u),e=Math.max(.1,.5*(1-t/30));this.renderer.specialEffects.triggerChromaticAberration(e)}}}cleanup(t){(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(this.renderer.ctx.globalAlpha=1),0!==t&&this.renderer.ctx.restore()}renderCoreAndShapes(t){const{coreX:e,coreY:i,coreRadius:s,totalRotation:a,sleepOpacityMod:h,deltaTime:n}=t;this.applySleepOpacity(h);const{shapePoints:r,currentShadow:o}=this.updateShapeMorpher(s),l=this.renderSunEffects(e,i,s,o);this.renderCore(e,i,s,a,r),this.renderSparkles(n),this.renderShadowEffects(e,i,s,o,r,l),this.cleanup(a)}}class Ie{constructor(t){this.renderer=t}renderSleepIndicator(t,e,i,s){this.renderer.state.sleeping&&this.renderer.renderSleepIndicator(t,e-i-this.renderer.scaleValue(20),s)}finalizeCanvas(t,e,i){this.renderer.ctx=t,t.drawImage(this.renderer.offscreenCanvas,0,0,e,i)}drawRecordingIndicator(t){}finalizePerformanceMetrics(t){const e=performance.now()-t;this.renderer.performanceMonitor&&(this.renderer.performanceMonitor.markFrameEnd(),this.renderer.performanceMonitor.recordFrameTime(e))}finalizeRender(t){const{centerX:e,centerY:i,glowRadius:s,deltaTime:a,originalCtx:h,logicalWidth:n,logicalHeight:r,frameStartTime:o}=t;this.renderSleepIndicator(e,i,s,a),this.finalizeCanvas(h,n,r),this.drawRecordingIndicator(h),this.finalizePerformanceMetrics(o)}}class je{constructor(t){this.renderer=t,this.animations={grooveSway:null,grooveBob:null,grooveFlow:null,groovePulse:null,grooveStep:null},this.activeAnimation=null,this.blendState={x:0,y:0,rotation:0,scale:1,opacity:1}}startAmbientAnimation(t,e={}){this.activeAnimation&&this.activeAnimation!==t&&this.stopAmbientAnimation(this.activeAnimation),this.activeAnimation=t,this.animations[t]={startTime:Date.now(),intensity:e.intensity||1,frequency:e.frequency||1,options:e}}stopAmbientAnimation(t){this.animations[t]&&(this.animations[t]=null),this.activeAnimation===t&&(this.activeAnimation=null)}updateBlendState(t){if(!t)return;const e=.2;this.blendState.x=this.lerp(this.blendState.x,t.x||0,e),this.blendState.y=this.lerp(this.blendState.y,t.y||0,e),this.blendState.rotation=this.lerp(this.blendState.rotation,t.rotation||0,e),this.blendState.scale=this.lerp(this.blendState.scale,t.scale||1,e),this.blendState.opacity=this.lerp(this.blendState.opacity,t.opacity||1,e)}getTransform(t){const e={x:this.blendState.x,y:this.blendState.y,rotation:this.blendState.rotation,scale:this.blendState.scale,opacity:this.blendState.opacity};if(this.activeAnimation){const t=this.animations[this.activeAnimation];if(t){const i=Date.now()-t.startTime;switch(this.activeAnimation){case"grooveSway":e.x+=15*Math.sin(i/500*t.frequency)*t.intensity,e.rotation+=5*Math.sin(i/500*t.frequency+Math.PI/4)*t.intensity;break;case"grooveBob":e.y+=10*Math.sin(i/400*t.frequency)*t.intensity,e.scale*=1+.03*Math.sin(i/400*t.frequency)*t.intensity;break;case"grooveFlow":{const s=i/1e3*t.frequency;e.x+=Math.sin(s)*Math.cos(2*s)*20*t.intensity,e.y+=Math.cos(s)*Math.sin(2*s)*10*t.intensity,e.rotation+=8*Math.sin(2*s)*t.intensity;break}case"groovePulse":e.scale*=1+.05*Math.sin(i/250*t.frequency)*t.intensity,e.opacity*=.9+.1*Math.sin(i/250*t.frequency)*t.intensity;break;case"grooveStep":{const s=Math.floor(i/500*t.frequency)%4,a=i/500*t.frequency%1,h=this.smoothStep(a);0===s?e.x+=25*h*t.intensity:2===s&&(e.x-=25*h*t.intensity),e.y+=5*Math.abs(Math.sin(i/250*t.frequency))*t.intensity;break}}}}return e}lerp(t,e,i){return t+(e-t)*i}smoothStep(t){return t*t*(3-2*t)}}class $e{constructor(t){this.renderer=t,this.ctx=t.ctx,this.config={enabled:!1,radius:1.5,shape:"circle",color:"rgba(0, 0, 0, 0.6)",intensity:.7,blendMode:"normal",falloff:"smooth",falloffCurve:null,edgeSoftness:.6,coreTransparency:.2,blur:0,responsive:!0,pulse:!1,offset:{x:0,y:0},type:"radial-gradient"},this.currentIntensity=0,this.targetIntensity=0,this.pulsePhase=0}setConfig(t={}){this.config={...this.config,...t},void 0!==t.enabled&&(this.targetIntensity=t.enabled?this.config.intensity:0)}update(t){this.config.enabled?(this.currentIntensity+=.1*(this.targetIntensity-this.currentIntensity),this.config.responsive&&(this.pulsePhase+=.001*t)):this.currentIntensity*=.95}setAudioIntensity(t){if(!this.config.responsive)return;const e=.2*t;this.targetIntensity=Math.min(1,this.config.intensity+e)}render(t,e,i,s=null){if(this.currentIntensity<.01)return;const a=s||this.ctx;switch(a.save(),this.config.type){case"radial-gradient":this.renderRadialGradient(t,e,i,a);break;case"vignette":this.renderVignette(t,e,i,a);break;case"glow":this.renderGlow(t,e,i,a)}a.restore()}renderRadialGradient(t,e,i,s){s=s||this.ctx;const a=i*this.config.radius,h=t+(this.config.offset.x||0),n=e+(this.config.offset.y||0);let r=a;(this.config.pulse||this.config.responsive)&&(r*=1+.05*Math.sin(this.pulsePhase));const o=s.globalCompositeOperation;this.config.blendMode&&"normal"!==this.config.blendMode&&(s.globalCompositeOperation=this.config.blendMode),this.config.blur>0&&(s.filter=`blur(${this.config.blur}px)`);const l=s.createRadialGradient(h,n,0,h,n,r),c=this.config.color,u=this.currentIntensity;this.addGradientStopsSimple(l,c,u),s.fillStyle=l,s.beginPath(),s.arc(h,n,r,0,2*Math.PI),s.fill(),this.config.blur>0&&(s.filter="none"),this.config.blendMode&&"normal"!==this.config.blendMode&&(s.globalCompositeOperation=o)}renderVignette(t,e,i,s){s=s||this.ctx;const{canvas:a}=s,h=Math.max(a.width,a.height),n=s.createRadialGradient(t,e,.5*i,t,e,h);n.addColorStop(0,"rgba(0, 0, 0, 0)"),n.addColorStop(1,this.adjustColorAlpha(this.config.color,this.currentIntensity)),s.fillStyle=n,s.fillRect(0,0,a.width,a.height)}renderGlow(t,e,i,s){s=s||this.ctx;const a=i*this.config.radius;for(let i=0;i<3;i++){const h=a*(1-.2*i),n=this.currentIntensity*(.3-.1*i),r=s.createRadialGradient(t,e,0,t,e,h);r.addColorStop(0,this.adjustColorAlpha(this.config.color,n)),r.addColorStop(1,"rgba(0, 0, 0, 0)"),s.fillStyle=r,s.beginPath(),s.arc(t,e,h,0,2*Math.PI),s.fill()}}addGradientStopsSimple(t,e,i){const{coreTransparency:s}=this.config;t.addColorStop(0,this.adjustColorAlpha(e,i)),t.addColorStop(s,this.adjustColorAlpha(e,i));for(let a=1;a<=25;a++){const h=s+a/25*(1-s),n=(h-s)/(1-s),r=1-this.easeInOutCubic(n);t.addColorStop(h,this.adjustColorAlpha(e,i*r))}t.addColorStop(1,"rgba(0, 0, 0, 0)")}addGradientStops(t,e,i,s=1){const{coreTransparency:a}=this.config;if(this.config.falloffCurve&&Array.isArray(this.config.falloffCurve))this.config.falloffCurve.forEach(({stop:s,alpha:a})=>{t.addColorStop(s,this.adjustColorAlpha(e,i*a))});else switch(this.config.falloff){case"linear":t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a,"rgba(0, 0, 0, 0)"),t.addColorStop(1,this.adjustColorAlpha(e,i));break;case"exponential":t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a,"rgba(0, 0, 0, 0)"),t.addColorStop(a+.3*(1-a),this.adjustColorAlpha(e,.05*i)),t.addColorStop(a+.5*(1-a),this.adjustColorAlpha(e,.15*i)),t.addColorStop(a+.7*(1-a),this.adjustColorAlpha(e,.4*i)),t.addColorStop(a+.85*(1-a),this.adjustColorAlpha(e,.7*i)),t.addColorStop(1,this.adjustColorAlpha(e,i));break;default:{t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a*s,"rgba(0, 0, 0, 0)");const{edgeSoftness:h}=this.config,n=s,r=a*s+(n-a*s)*h,o=25;for(let h=1;h<=o;h++){const l=h/o;let c=0;if(l<=a*s)c=0;else if(l<=n)if(l<=r){const t=(l-a*s)/(r-a*s);c=this.easeInOutCubic(t)}else{const t=(l-r)/(n-r);c=1-.05*(1-this.easeInOutCubic(t))}else{const t=(l-n)/(1-n);c=1-this.easeInOutCubic(t)}t.addColorStop(l,this.adjustColorAlpha(e,i*c))}t.addColorStop(1,"rgba(0, 0, 0, 0)");break}}}easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}adjustColorAlpha(t,e){const i=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(i){const[,t,s,a,h=1]=i;return`rgba(${t}, ${s}, ${a}, ${parseFloat(h)*e})`}return`rgba(0, 0, 0, ${.6*e})`}getConfig(){return{...this.config}}enable(){this.config.enabled=!0,this.targetIntensity=this.config.intensity}disable(){this.config.enabled=!1,this.targetIntensity=0}toggle(){this.config.enabled?this.disable():this.enable()}}class Ge{enterSleepMode(){}wakeUp(){}renderSleepIndicator(){}cleanup(){}}class qe{constructor(t){this.renderer=t}applyUndertoneModifiers(t){if(t&&"object"==typeof t&&void 0!==t.weight){const{weight:e}=t;return this.renderer.state.sizeMultiplier=1+((t.sizeMultiplier||1)-1)*e,this.renderer.state.jitterAmount=(t.jitterAmount||0)*e,this.renderer.state.episodicFlutter=e>.5&&t.episodicFlutter||!1,this.renderer.state.glowRadiusMult=1+((t.glowRadiusMult||1)-1)*e,this.renderer.state.breathRateMult=1+((t.breathRateMult||1)-1)*e,this.renderer.state.breathDepthMult=1+((t.breathDepthMult||1)-1)*e,this.renderer.state.breathIrregular=e>.5&&t.breathIrregular||!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=(t.glowPulse||0)*e,this.renderer.state.brightnessFlicker=(t.brightnessFlicker||0)*e,this.renderer.state.brightnessMult=1+((t.brightnessMult||1)-1)*e,this.renderer.state.saturationMult=1+((t.saturationMult||1)-1)*e,void(this.renderer.state.hueShift=(t.hueShift||0)*e)}if(!t||!this.renderer.undertoneModifiers[t])return this.renderer.state.sizeMultiplier=1,this.renderer.state.jitterAmount=0,this.renderer.state.episodicFlutter=!1,this.renderer.state.glowRadiusMult=1,this.renderer.state.breathRateMult=1,this.renderer.state.breathDepthMult=1,this.renderer.state.breathIrregular=!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=0,this.renderer.state.brightnessFlicker=0,this.renderer.state.brightnessMult=1,this.renderer.state.saturationMult=1,void(this.renderer.state.hueShift=0);const e=this.renderer.undertoneModifiers[t];this.renderer.state.sizeMultiplier=e.sizeMultiplier,this.renderer.state.jitterAmount=e.jitterAmount||0,this.renderer.state.episodicFlutter=e.episodicFlutter||!1,this.renderer.state.glowRadiusMult=e.glowRadiusMult,this.renderer.state.breathRateMult=e.breathRateMult,this.renderer.state.breathDepthMult=e.breathDepthMult,this.renderer.state.breathIrregular=e.breathIrregular||!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=e.glowPulse||0,this.renderer.state.brightnessFlicker=e.brightnessFlicker||0,this.renderer.state.brightnessMult=e.brightnessMult||1,this.renderer.state.saturationMult=e.saturationMult||1,this.renderer.state.hueShift=e.hueShift||0}updateUndertone(t){this.renderer.state.undertone!==t&&this.renderer.glowCache&&this.renderer.glowCache.clear(),this.renderer.state.undertone=t,this.renderer.currentUndertone=t;const e=this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers?this.renderer.stateMachine.getWeightedUndertoneModifiers():null;if(this.applyUndertoneModifiers(e||t),this.renderer.state.emotion){const i=$&&$.isInitialized?$.getEmotion(this.renderer.state.emotion):P(this.renderer.state.emotion);if(i){const s=i.glowColor||this.renderer.config.defaultGlowColor,a=this.renderer.applyUndertoneToColor(s,e||t);this.renderer.startColorTransition(a,200)}}}setEmotionalState(t,e,i=null){this.renderer.state.emotion===t&&this.renderer.state.undertone===i||!this.renderer.glowCache||this.renderer.glowCache.clear(),this.renderer.state.undertone=i,this.renderer.currentUndertone=i;const s=this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers?this.renderer.stateMachine.getWeightedUndertoneModifiers():null;this.applyUndertoneModifiers(s||i);const a=e.glowColor||this.renderer.config.defaultGlowColor;let h;h="suspicion"===t?e.glowColor||a:this.renderer.applyUndertoneToColor(a,s||i);const n=s||(i?this.renderer.undertoneModifiers[i]:null),r=e.glowIntensity||1;let o=1;if(n)if(s){const t=n.weight||0;o=void 0!==n.glowRadiusMult&&isFinite(n.glowRadiusMult)&&isFinite(t)?1+(n.glowRadiusMult-1)*t:1}else o=void 0!==n.glowRadiusMult?n.glowRadiusMult:1;const l=r*o;let c=1500;"anger"===t||"fear"===t?c=800:"sadness"!==t&&"resting"!==t||(c=2e3),this.renderer.state.emotion=t,"suspicion"===t?(this.renderer.state.isSuspicious=!0,this.renderer.state.targetSquintAmount=e&&e.coreSquint?e.coreSquint:.4,void 0===this.renderer.state.squintAmount&&(this.renderer.state.squintAmount=0),this.renderer.state.lastScanTime=Date.now(),this.renderer.state.scanPhase=0):(this.renderer.state.isSuspicious=!1,this.renderer.state.targetSquintAmount=0,void 0===this.renderer.state.squintAmount&&(this.renderer.state.squintAmount=0)),this.renderer.startColorTransition(h,l,c);const u=e.breathRate||1,p=e.breathDepth||this.renderer.config.breathingDepth;this.renderer.state.breathRate=n?u*n.breathRateMult:u,this.renderer.state.breathDepth=n?p*n.breathDepthMult:p,this.renderer.state.coreJitter=e.coreJitter||n&&n.jitterAmount>0,this.renderer.state.emotionEyeOpenness=e.eyeOpenness,this.renderer.state.emotionEyeArc=e.eyeArc}}class Xe{constructor(t){this.renderer=t}resetCanvasContext(){if(!this.renderer.canvas||!this.renderer.ctx)return;const{width:t}=this.renderer.canvas,{height:e}=this.renderer.canvas;this.resetContext(this.renderer.ctx,t,e),this.renderer.offscreenCanvas&&this.renderer.offscreenCtx&&this.resetContext(this.renderer.offscreenCtx,this.renderer.offscreenCanvas.width,this.renderer.offscreenCanvas.height),this.renderer.contextStateManager&&this.renderer.contextStateManager.reset(),this.renderer.forceCleanRender=!0}resetContext(t,e,i){t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.clearRect(0,0,e,i)}setQualityLevel(t){this.renderer.qualityLevel=Math.max(0,Math.min(1,t)),this.renderer.qualityLevel<.5?this.applyLowQuality():this.renderer.qualityLevel<.8?this.applyMediumQuality():this.applyHighQuality()}applyLowQuality(){this.renderer.ctx.imageSmoothingEnabled=!1,this.renderer.state.breathDepth*=.5}applyMediumQuality(){this.renderer.ctx.imageSmoothingEnabled=!0,this.renderer.ctx.imageSmoothingQuality="medium"}applyHighQuality(){this.renderer.ctx.imageSmoothingEnabled=!0,this.renderer.ctx.imageSmoothingQuality="high"}setQualityReduction(t){t?this.setQualityLevel(.5):this.setQualityLevel(1)}handleContextRecovery(t){this.renderer.ctx=t}}const Ye=2,He=3,_e=4,Le=new class{constructor(){this.callbacks=new Map,this.callbackIdCounter=0,this.H=new Map,this._=!0,this.frameId=null,this.isRunning=!1,this.lastFrameTime=0,this.deltaTime=0,this.fps=60,this.frameCount=0,this.targetFPS=60,this.targetFrameTime=1e3/this.targetFPS,this.frameBudget=16.67,this.prioritySkipCounters={[Ye]:0,[He]:0,[_e]:0},this.performanceMonitor=null,this.frameTimeHistory=new Array(60).fill(0),this.L=0,this.W=0,this.maxHistorySize=60,this.loop=this.loop.bind(this)}register(t,e=2,i=null){if("function"!=typeof t)throw new Error("Callback must be a function");const s=++this.callbackIdCounter;return this.callbacks.set(s,{callback:t,priority:e,context:i,lastRun:0,runCount:0,totalTime:0,enabled:!0}),this._=!0,1!==this.callbacks.size||this.isRunning||this.start(),s}unregister(t){this.callbacks.delete(t),this._=!0,0===this.callbacks.size&&this.isRunning&&this.stop()}setEnabled(t,e){const i=this.callbacks.get(t);i&&(i.enabled=e)}start(){this.isRunning||(this.isRunning=!0,this.lastFrameTime=performance.now(),this.frameId=requestAnimationFrame(this.loop))}stop(){this.isRunning&&(this.isRunning=!1,this.frameId&&(cancelAnimationFrame(this.frameId),this.frameId=null))}loop(t){if(!this.isRunning)return;this.deltaTime=t-this.lastFrameTime,this.lastFrameTime=t,this.frameCount++,this.frameCount%60==0&&(this.fps=Math.round(1e3/(this.deltaTime||16.67))),this.frameTimeHistory[this.L]=this.deltaTime,this.L=(this.L+1)%this.maxHistorySize,this.W<this.maxHistorySize&&this.W++,this._&&this.U();const e=this.H;let i=0;for(const s of[0,1,2,3,4]){if(s>0&&i>.8*this.frameBudget)break;if(this.shouldSkipPriority(s))continue;const a=e.get(s)||[];for(const e of a){if(!e.enabled)continue;const s=performance.now();try{e.context?e.callback.call(e.context,this.deltaTime,t):e.callback(this.deltaTime,t);const a=performance.now()-s;e.totalTime+=a,e.runCount++,e.lastRun=t,i+=a}catch(t){e.runCount>0&&e.totalTime/e.runCount>10&&(e.enabled=!1)}if(i>this.frameBudget)break}}this.frameId=requestAnimationFrame(this.loop)}U(){this.H.clear();for(const[,t]of this.callbacks){const{priority:e}=t;this.H.has(e)||this.H.set(e,[]),this.H.get(e).push(t)}this._=!1}shouldSkipPriority(t){if(0===t)return!1;if(this.fps<30&&t>=3)return!0;if(this.fps<45&&4===t)return!0;if(2===t){if(this.fps<50&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%2!=0))return!0}else if(3===t){if(this.fps<50&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%3!=0))return!0}else if(4===t&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%5!=0))return!0;return!1}getStats(){const t={fps:this.fps,frameCount:this.frameCount,callbackCount:this.callbacks.size,averageFrameTime:0,maxFrameTime:0,minFrameTime:1/0};if(this.W>0){let e=0;for(let i=0;i<this.W;i++){const s=this.frameTimeHistory[i];e+=s,t.maxFrameTime=Math.max(t.maxFrameTime,s),t.minFrameTime=Math.min(t.minFrameTime,s)}t.averageFrameTime=e/this.W}t.callbacksByPriority={};for(const[,e]of this.callbacks){const{priority:i}=e;t.callbacksByPriority[i]||(t.callbacksByPriority[i]={count:0,totalTime:0,enabled:0}),t.callbacksByPriority[i].count++,t.callbacksByPriority[i].totalTime+=e.totalTime,e.enabled&&t.callbacksByPriority[i].enabled++}return t}setTargetFPS(t){this.targetFPS=Math.max(15,Math.min(120,t)),this.targetFrameTime=1e3/this.targetFPS,this.frameBudget=this.targetFrameTime}setPerformanceMonitor(t){this.performanceMonitor=t}destroy(){this.stop(),this.callbacks.clear(),this.H.clear(),this._=!0,this.frameTimeHistory.fill(0),this.L=0,this.W=0}};class We{constructor(t){this.renderer=t}destroy(){this.cancelAnimationFrames(),this.unregisterLoopCallbacks(),this.cleanupManagers(),this.clearTimeouts(),this.clearAnimationStates(),this.clearOtherResources()}cancelAnimationFrames(){for(const t in this.renderer.animationFrameIds)this.renderer.animationFrameIds[t]&&(cancelAnimationFrame(this.renderer.animationFrameIds[t]),this.renderer.animationFrameIds[t]=null)}unregisterLoopCallbacks(){for(const t in this.renderer.loopCallbackIds)this.renderer.loopCallbackIds[t]&&(Le.unregister(this.renderer.loopCallbackIds[t]),this.renderer.loopCallbackIds[t]=null)}cleanupManagers(){this.renderer.sleepManager&&this.renderer.sleepManager.cleanup(),this.renderer.gazeTracker&&this.renderer.gazeTracker.cleanup()}clearTimeouts(){this.renderer.wakeJitterTimeout&&(clearTimeout(this.renderer.wakeJitterTimeout),this.renderer.wakeJitterTimeout=null)}clearAnimationStates(){this.renderer.colorTransition.active=!1}clearOtherResources(){this.renderer.cleanupGazeTracking(),this.renderer.speakingRings=[],this.renderer.gestureCompositor&&this.renderer.gestureCompositor.clearCache(),this.renderer.specialEffects&&this.renderer.specialEffects.destroy(),this.renderer.cleanupOffscreenCanvas&&this.renderer.cleanupOffscreenCanvas()}}class Ue{constructor(t){this.renderer=t}updateTimers(t){this.updateBreathing(t),this.updateBlinking(t)}updateBreathing(t){this.renderer.breathingAnimator.update(t,this.renderer.state.emotion,this.renderer.currentUndertone),this.renderer.state.sleeping?this.applySleepBreathing():this.applyNormalBreathing(),this.renderer.breathingAnimator.setIrregularBreathing(this.renderer.state.breathIrregular)}applySleepBreathing(){this.renderer.breathingAnimator.setBreathRateMultiplier(.5),this.renderer.breathingAnimator.setBreathDepthMultiplier(1.2)}applyNormalBreathing(){this.renderer.breathingAnimator.setBreathRateMultiplier(1),this.renderer.breathingAnimator.setBreathDepthMultiplier(1)}updateBlinking(t){const e=this.renderer.state.blinkingEnabled&&!this.renderer.state.sleeping;this.renderer.eyeRenderer.setBlinkingEnabled(e),this.renderer.eyeRenderer.update(t),this.renderer.state.blinking=this.renderer.eyeRenderer.blinking}}class Ve{constructor(t){this.renderer=t}setGazeOffset(t){this.processGazeData(t),this.handleGazeInteraction()}processGazeData(t){"object"==typeof t&&null!==t&&(this.isOldFormat(t)?this.renderer.state.gazeOffset=t:this.applyNewFormatData(t))}isOldFormat(t){return{}.hasOwnProperty.call(t,"x")&&{}.hasOwnProperty.call(t,"y")}applyNewFormatData(t){this.renderer.state.gazeOffset=t.offset||{x:0,y:0},this.renderer.state.gazeIntensity=t.proximity||0,this.renderer.state.gazeLocked=t.isLocked||!1}handleGazeInteraction(){this.renderer.idleTimer=0,this.renderer.isAsleep&&this.renderer.wakeUp()}getCurrentOrbPosition(){const t=this.renderer.canvasManager.width/2,e=this.renderer.canvasManager.height/2-this.renderer.config.topOffset;return{x:t+this.renderer.state.gazeOffset.x,y:e+this.renderer.state.gazeOffset.y}}}class Ne{constructor(t,e={}){this.canvasManager=t,this.ctx=t.getContext(),this.ctx||(this.o=!0),this.gestureCompositor=new ie,this.currentUndertone=null,this.gestureAnimator=new fe(this),this.colorUtilities=new me,this.specialEffects=new Me(this),this.eyeRenderer=new ge(this),this.breathingAnimator=new ye(this),this.glowRenderer=new we(this),this.coreRenderer=new ve(this),this.celestialRenderer=new Se,this.episodicEffectController=new Fe(this),this.rotationManager=new ke(this),this.gazeTracker=new Be(this),this.canvasSetupManager=new Ce(this),this.renderPerformanceManager=new Re(this),this.transformMerger=new Te(this),this.stateUpdateManager=new Pe(this),this.dimensionCalculator=new Oe(this),this.radiusCalculator=new Ae(this),this.positionJitterManager=new De(this),this.effectsRenderManager=new ze(this),this.coreShapeRenderManager=new Ee(this),this.renderFinalizationManager=new Ie(this),this.ambientDanceAnimator=new je(this),this.backdropRenderer=new $e(this),this.sleepManager=new Ge(this),this.emotionalStateManager=new qe(this),this.canvasContextManager=new Xe(this),this.resourceCleanupManager=new We(this),this.timerCoordinator=new Ue(this),this.gazeInputHandler=new Ve(this),this.config={coreColor:e.coreColor||"#FFFFFF",coreSizeDivisor:e.coreSizeDivisor||12,glowMultiplier:e.glowMultiplier||2.5,defaultGlowColor:e.defaultGlowColor||"#14B8A6",breathingSpeed:e.breathingSpeed||.42,breathingDepth:e.breathingDepth||.08,renderingStyle:e.renderingStyle||"classic",baseScale:e.baseScale||1,referenceSize:400,topOffset:e.topOffset||0,positionController:e.positionController||null};const i=Math.min(this.canvasManager.width||400,this.canvasManager.height||400);this.scaleFactor=i/this.config.referenceSize*this.config.baseScale,this.state={emotion:"neutral",glowColor:this.config.defaultGlowColor,glowIntensity:1,breathRate:1,breathDepth:this.config.breathingDepth,coreJitter:!1,speaking:!1,recording:!1,sleeping:!1,blinking:!1,blinkingEnabled:!0,gazeOffset:{x:0,y:0},gazeIntensity:0,gazeLocked:!1,gazeTrackingEnabled:!1,gazeTarget:{x:0,y:0},effectiveCenter:{x:0,y:0,scale:1},squintAmount:0,targetSquintAmount:0,scanPhase:0,lastScanTime:0,isSuspicious:!1,customScale:null,sizeMultiplier:1,jitterAmount:0,episodicFlutter:!1,glowRadiusMult:1,breathRateMult:1,breathDepthMult:1,breathIrregular:!1,particleRateMult:1,glowPulse:0,brightnessFlicker:0,brightnessMult:1,saturationMult:1,hueShift:0,manualRotation:0,rotationSpeed:0,lastRotationUpdate:performance.now()},this.animationFrameIds={colorTransition:null,eyeClose:null,eyeOpen:null},this.loopCallbackIds={eyeClose:null,eyeOpen:null},this.wakeJitterTimeout=null,this.offscreenCanvas=null,this.offscreenCtx=null,this.initOffscreenCanvas(),this.canvas=t.canvas,this.gestureAnimations={bounce:{active:!1,startTime:0,progress:0,params:null},pulse:{active:!1,startTime:0,progress:0,params:null},shake:{active:!1,startTime:0,progress:0,params:null},spin:{active:!1,startTime:0,progress:0,params:null},nod:{active:!1,startTime:0,progress:0,params:null},tilt:{active:!1,startTime:0,progress:0,params:null},expand:{active:!1,startTime:0,progress:0,params:null},contract:{active:!1,startTime:0,progress:0,params:null},flash:{active:!1,startTime:0,progress:0,params:null},drift:{active:!1,startTime:0,progress:0,params:null,startX:0,startY:0},stretch:{active:!1,startTime:0,progress:0,params:null},glow:{active:!1,startTime:0,progress:0,params:null},flicker:{active:!1,startTime:0,progress:0,params:null},vibrate:{active:!1,startTime:0,progress:0,params:null},wave:{active:!1,startTime:0,progress:0,params:null},breathe:{active:!1,startTime:0,progress:0,params:null},morph:{active:!1,startTime:0,progress:0,params:null},slowBlink:{active:!1,startTime:0,progress:0,params:null},look:{active:!1,startTime:0,progress:0,params:null,targetX:0,targetY:0},settle:{active:!1,startTime:0,progress:0,params:null},breathIn:{active:!1,startTime:0,progress:0,params:null},breathOut:{active:!1,startTime:0,progress:0,params:null},breathHold:{active:!1,startTime:0,progress:0,params:null},breathHoldEmpty:{active:!1,startTime:0,progress:0,params:null},jump:{active:!1,startTime:0,progress:0,params:null},orbital:{active:!1,startTime:0,progress:0,params:null},hula:{active:!1,startTime:0,progress:0,params:null}},Object.defineProperty(this,"episodicEffects",{get:()=>this.episodicEffectController.getEpisodicEffects(),enumerable:!0}),this.speakingRings=[],this.maxRings=5,this.ringSpawnTimer=0,this.ringSpawnInterval=200,this.recordingRings=[],this.recordingPulse=0,this.sleepZ=[],this.colorTransition={active:!1,fromColor:this.state.glowColor,toColor:this.state.glowColor,fromIntensity:this.state.glowIntensity,toIntensity:this.state.glowIntensity,progress:0,startTime:0,duration:1500},this.undertoneModifiers={nervous:{hueShift:0,saturationMult:1.05,brightnessMult:1,brightnessFlicker:.05,sizeMultiplier:1,jitterAmount:0,episodicFlutter:!0,glowRadiusMult:1,glowPulse:.05,breathRateMult:1.1,breathDepthMult:.9,breathIrregular:!0},confident:{hueShift:15,saturationMult:1.2,brightnessMult:1.1,sizeMultiplier:1,jitterAmount:0,episodicPowerPose:!0,glowRadiusMult:1.15,breathRateMult:.95,breathDepthMult:1.1,breathIrregular:!1},tired:{hueShift:-5,saturationMult:.7,brightnessMult:.85,sizeMultiplier:.95,jitterAmount:0,episodicMicroSleep:!0,glowRadiusMult:.9,breathRateMult:.8,breathDepthMult:1.2,breathIrregular:!1},intense:{hueShift:5,saturationMult:1.3,brightnessMult:1.15,sizeMultiplier:1,jitterAmount:0,episodicLaserFocus:!0,glowRadiusMult:1.2,breathRateMult:1.2,breathDepthMult:.9,breathIrregular:!1},subdued:{hueShift:-10,saturationMult:.75,brightnessMult:.9,sizeMultiplier:.95,jitterAmount:0,episodicWithdrawal:!0,glowRadiusMult:.85,breathRateMult:.9,breathDepthMult:.9,breathIrregular:!1}},this.lastFrameTime=0,this.V()}scaleValue(t){return t*this.scaleFactor}initOffscreenCanvas(){this.offscreenCanvas=document.createElement("canvas"),this.offscreenCtx=this.offscreenCanvas.getContext("2d",{alpha:!0,desynchronized:!0,willReadFrequently:!1}),this.updateOffscreenSize()}cleanupOffscreenCanvas(){this.offscreenCanvas&&(this.offscreenCtx&&(this.offscreenCtx.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),this.offscreenCtx=null),this.offscreenCanvas.width=0,this.offscreenCanvas.height=0,this.offscreenCanvas=null)}updateOffscreenSize(){if(this.offscreenCanvas&&this.canvasManager){const{width:t}=this.canvasManager.canvas,{height:e}=this.canvasManager.canvas;if(this.offscreenCanvas.width!==t||this.offscreenCanvas.height!==e){this.offscreenCanvas.width=t,this.offscreenCanvas.height=e;const i=this.canvasManager.canvas.width>this.canvasManager.width;this.offscreenCtx&&(this.offscreenCtx.setTransform(1,0,0,1,0,0),i&&this.canvasManager.dpr&&this.offscreenCtx.scale(this.canvasManager.dpr,this.canvasManager.dpr))}}}updateEffectiveCenter(t){this.state.effectiveCenter=t}getEffectiveCenter(){const t=this.canvasManager.getCenter();let e;return e=this.config.positionController?this.config.positionController.getEffectiveCenter(t.x,t.y):{x:t.x,y:t.y,scale:1},e.x+=this.state.gazeOffset.x,e.y+=this.state.gazeOffset.y,e}render(t,e,i=null){if(this.o)return;const s=this.renderPerformanceManager.initializeFrame();i=this.transformMerger.mergeAndStoreTransforms(i,e);const{logicalWidth:a,logicalHeight:h,originalCtx:n}=this.canvasSetupManager.setupCanvas();this.canvasSetupManager.performCanvasSetup(a,h,n,e),this.stateUpdateManager.performFrameStateUpdates(e);const r=this.dimensionCalculator.calculateRenderDimensions(a,h,t,i),{scaleMultiplier:o,glowMultiplier:l,gestureTransforms:c,centerX:u,centerY:p}=r;let{rotationAngle:d}=r;const f=this.radiusCalculator.calculateRadii(t,o,l);let{coreRadius:m,glowRadius:M}=f;const{effectiveGlowIntensity:g,sleepOpacityMod:y,glowOpacityMod:b}=f,w=this.positionJitterManager.applyAllModifications(u,p,d,m,M),{coreX:v,coreY:S}=w;({rotationAngle:d,coreRadius:m,glowRadius:M}=w);const F=this.rotationManager.applyRotationTransform(this.ctx,v,S,d);this.effectsRenderManager.renderAllEffects({coreX:v,coreY:S,glowRadius:M,effectiveGlowIntensity:g,glowOpacityMod:b,gestureTransforms:c,coreRadius:m,deltaTime:e}),this.coreShapeRenderManager.renderCoreAndShapes({coreX:v,coreY:S,coreRadius:m,totalRotation:F,sleepOpacityMod:y,deltaTime:e}),this.renderFinalizationManager.finalizeRender({centerX:u,centerY:p,glowRadius:M,deltaTime:e,originalCtx:n,logicalWidth:a,logicalHeight:h,frameStartTime:s})}renderRecordingGlow(t,e,i,s){const a=this.canvas?.width||600,h=this.canvas?.height||600,n=Math.min(i,t-10,e-10,a-t-10,h-e-10),r=Math.max(50,n),o=be.getRadialGradient(this.ctx,t,e,0,t,e,r,[{offset:0,color:this.hexToRgba("#FF0000",.7*s)},{offset:.3,color:this.hexToRgba("#FF0000",.5*s)},{offset:.6,color:this.hexToRgba("#FF0000",.3*s)},{offset:.85,color:this.hexToRgba("#FF0000",.1*s)},{offset:1,color:this.hexToRgba("#FF0000",0)}]);this.ctx.fillStyle=o,this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill()}renderDropShadow(t,e,i,s){const{ctx:a}=this,h=this.shapeMorpher&&this.shapeMorpher.isTransitioning;if(!(this.shapeMorpher&&(this.shapeMorpher.audioDeformation>.1||this.shapeMorpher.vocalEnergy>.1)||h&&!(this.shapeMorpher.morphProgress>.8))){a.save(),a.translate(t,e);const h=this.scaleValue(2);if(a.translate(0,h),s&&s.length>32)a.fillStyle="rgba(0, 0, 0, 0.15)",a.beginPath(),a.arc(0,0,1.05*i,0,2*Math.PI),a.fill();else{const t=a.createRadialGradient(0,0,.7*i,0,0,1.2*i);if(t.addColorStop(0,"rgba(0, 0, 0, 0.2)"),t.addColorStop(.8,"rgba(0, 0, 0, 0.1)"),t.addColorStop(1,"rgba(0, 0, 0, 0)"),a.fillStyle=t,a.beginPath(),s){const t=1.1,e=s.length>20?2:1;a.moveTo(s[0].x*t,s[0].y*t);for(let i=e;i<s.length;i+=e)a.lineTo(s[i].x*t,s[i].y*t);a.closePath()}else a.arc(0,0,1.1*i,0,2*Math.PI);a.fill()}a.restore()}}renderSunEffects(t,e,i,s){return this.celestialRenderer.renderSunEffects(this.ctx,t,e,i,s)}renderBaileysBeads(t,e,i,s,a,h,n,r){return this.celestialRenderer.renderBaileysBeads(this.ctx,t,e,i,s,a,h,n,r,this.scaleValue.bind(this))}renderMoonShadow(t,e,i,s,a,h=!1,n=0){return this.celestialRenderer.renderMoonShadow(this.ctx,t,e,i,s,a,h,n,this.shapeMorpher)}renderSpeakingRings(t,e,i,s){return this.specialEffects.renderSpeakingRings(t,e,i,s)}renderRecordingIndicator(t,e){return this.specialEffects.renderRecordingIndicator(t,e)}renderSleepIndicator(t,e,i){return this.sleepManager.renderSleepIndicator(t,e,i)}updateTimers(t){this.timerCoordinator.updateTimers(t)}applyUndertoneModifiers(t){this.emotionalStateManager.applyUndertoneModifiers(t)}applyUndertoneToColor(t,e){return this.colorUtilities.applyUndertoneToColor(t,e)}hexToRgb(t){return this.colorUtilities.hexToRgb(t)}rgbToHsl(t,e,i){return this.colorUtilities.rgbToHsl(t,e,i)}hslToHex(t,e,i){return this.colorUtilities.hslToHex(t,e,i)}hexToRgba(t,e=1){const i=this.hexToRgb(t);return i?`rgba(${i.r}, ${i.g}, ${i.b}, ${e})`:`rgba(255, 255, 255, ${e})`}startColorTransition(t,e,i=1500){this.colorUtilities.currentColor=this.state.glowColor,this.colorUtilities.currentIntensity=this.state.glowIntensity,this.colorUtilities.startColorTransition(t,e,i),this.colorTransition=this.colorUtilities.colorTransition}updateColorTransition(t){const e=this.colorUtilities.updateColorTransition(t);e&&(this.state.glowColor=e.color,this.state.glowIntensity=e.intensity,this.colorTransition=this.colorUtilities.colorTransition)}updateUndertone(t){this.emotionalStateManager.updateUndertone(t)}setEmotionalState(t,e,i=null){this.emotionalStateManager.setEmotionalState(t,e,i)}setBPM(t){}setRotationSpeed(t){this.rotationManager.setRotationSpeed(t)}setRotationAngle(t){this.rotationManager.setRotationAngle(t)}setGazeOffset(t){this.gazeInputHandler.setGazeOffset(t)}getCurrentOrbPosition(){return this.gazeInputHandler.getCurrentOrbPosition()}setCustomScale(t){this.state.customScale=t}startSpeaking(){this.state.speaking=!0,this.speakingRings=[],this.ringSpawnTimer=0}stopSpeaking(){this.state.speaking=!1,this.speakingRings=[]}enterSleepMode(){this.sleepManager.enterSleepMode()}wakeUp(){this.sleepManager.wakeUp()}startRecording(){this.state.recording=!0}stopRecording(){this.state.recording=!1}setBlinkingEnabled(t){this.state.blinkingEnabled=t,t||(this.state.blinking=!1,this.eyeRenderer.blinking=!1,this.eyeRenderer.blinkTimer=0)}setGazeTracking(t){this.gazeTracker.setEnabled(t)}initGazeTracking(){this.N||(this.N=!0),this.gazeTracker.initialize()}cleanupGazeTracking(){this.J||(this.J=!0),this.gazeTracker.cleanup()}resetCanvasContext(){this.canvasContextManager.resetCanvasContext()}setQualityLevel(t){this.canvasContextManager.setQualityLevel(t)}setQualityReduction(t){this.canvasContextManager.setQualityReduction(t)}handleContextRecovery(t){this.canvasContextManager.handleContextRecovery(t)}getUndertoneModifier(){return this.stateMachine&&this.stateMachine.getWeightedUndertoneModifiers?this.stateMachine.getWeightedUndertoneModifiers():this.currentUndertone&&this.undertoneModifiers[this.currentUndertone]?this.undertoneModifiers[this.currentUndertone]:null}applyGestureAnimations(){return this.gestureAnimator.applyGestureAnimations()}startGesture(t){return this.gestureAnimator.startGesture(t)}getCurrentGesture(){return this.gestureAnimator.getCurrentGesture()}V(){["Bounce","Pulse","Shake","Spin","Nod","Tilt","Expand","Contract","Flash","Drift","Stretch","Glow","Flicker","Vibrate","Orbital","Hula","Wave","Breathe","Morph","SlowBlink","Look","Settle","BreathIn","BreathOut","BreathHold","BreathHoldEmpty","Jump","Sway","Float","Rain","RunningMan","Charleston","Sparkle","Shimmer","Wiggle","Groove","Point","Lean","Reach","HeadBob","Orbit"].forEach(t=>{const e=`start${t}`;this[e]=()=>this.gestureAnimator[e]()})}startGrooveSway(t){this.ambientDanceAnimator.startAmbientAnimation("grooveSway",t)}startGrooveBob(t){this.ambientDanceAnimator.startAmbientAnimation("grooveBob",t)}startGrooveFlow(t){this.ambientDanceAnimator.startAmbientAnimation("grooveFlow",t)}startGroovePulse(t){this.ambientDanceAnimator.startAmbientAnimation("groovePulse",t)}startGrooveStep(t){this.ambientDanceAnimator.startAmbientAnimation("grooveStep",t)}stopAllGestures(){this.gestureAnimator.stopAllGestures(),this.currentGesture=null}isGestureActive(){return Object.values(this.gestureAnimator.gestureAnimations).some(t=>t.active)}destroy(){this.resourceCleanupManager.destroy()}}function Qe(t){const e=[];for(let i=0;i<t;i++){const s=i/t*Math.PI*2;e.push({x:.5+.5*Math.cos(s),y:.5+.5*Math.sin(s)})}return e}function Je(t,e=12){return Qe(t)}const Ze={circle:{points:Qe(64),shadow:{type:"none"}},sphere:{points:Qe(64),shadow:{type:"none"}},heart:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64*Math.PI*2,s=16*Math.pow(Math.sin(i),3),a=-(13*Math.cos(i)-5*Math.cos(2*i)-2*Math.cos(3*i)-Math.cos(4*i));t.push({x:.5+s/32,y:.5+a/32})}return t}(),shadow:{type:"none"}},star:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64,s=Math.floor(10*i),a=s%2==0,h=Math.floor(s/2);let n;n=a?(72*h-90)*Math.PI/180:(72*h+36-90)*Math.PI/180;const r=a?.5:.2;t.push({x:.5+Math.cos(n)*r,y:.5+Math.sin(n)*r})}return t}(),shadow:{type:"none"}},sun:{points:Je(64,12),shadow:{type:"sun",corona:!0,intensity:1.5,flares:!0,texture:!0,turbulence:.3}},moon:{points:Qe(64),shadow:{type:"crescent",coverage:.85,angle:-30,softness:.05,offset:.7}},lunar:{points:Qe(64),shadow:{type:"lunar",coverage:.7,color:"rgba(80, 20, 0, 0.8)",progression:"center"}},suspicion:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64*Math.PI*2;let s,a;if(i<Math.PI)s=.45*Math.cos(i),a=.45*Math.sin(i);else{const t=2*Math.PI-i;s=.25*Math.cos(t)-.1,a=.35*Math.sin(t)}t.push({x:.5+s,y:.5+a})}return t}(),shadow:{type:"none"}},eclipse:{points:Qe(64),shadow:{type:"lunar",coverage:.7,color:"rgba(80, 20, 0, 0.8)"}},square:{points:function(){const t=[],e=Math.floor(16);for(let i=0;i<4;i++)for(let s=0;s<e;s++){const a=s/e;let h,n;switch(i){case 0:h=-.5+a,n=-.5;break;case 1:h=.5,n=-.5+a;break;case 2:h=.5-a,n=.5;break;case 3:h=-.5,n=.5-a}t.push({x:.5+.8*h,y:.5+.8*n})}return t}(),shadow:{type:"none"}},triangle:{points:function(){const t=[],e=[{x:0,y:-.5},{x:-.433,y:.25},{x:.433,y:.25}],i=[Math.sqrt(Math.pow(e[1].x-e[0].x,2)+Math.pow(e[1].y-e[0].y,2)),Math.sqrt(Math.pow(e[2].x-e[1].x,2)+Math.pow(e[2].y-e[1].y,2)),Math.sqrt(Math.pow(e[0].x-e[2].x,2)+Math.pow(e[0].y-e[2].y,2))],s=i[0]+i[1]+i[2],a=i.map(t=>Math.round(64*t/s)),h=a.reduce((t,e)=>t+e,0);h<64&&(a[0]+=64-h);for(let i=0;i<3;i++){const s=e[i],h=e[(i+1)%3],n=a[i];for(let e=0;e<n;e++){if(e===n-1&&i<2)continue;const a=e/n,r=s.x+(h.x-s.x)*a,o=s.y+(h.y-s.y)*a;t.push({x:.5+.9*r,y:.5+.9*o})}}for(;t.length<64;)t.push(t[t.length-1]);for(;t.length>64;)t.pop();return t}(),shadow:{type:"none"}},solar:{points:Je(64,12),shadow:{type:"solar-hybrid",corona:!0,intensity:1.5,flares:!0,texture:!0,turbulence:.3,lunarOverlay:{type:"lunar",coverage:1,color:"rgba(0, 0, 0, 1.0)",progression:"center"}}}},Ke=new class{constructor(){this.shapeCache=new Map,this.morphCache=new Map,this.propertyCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1,this.loadStartTime=0,this.initialize()}initialize(){this.loadStartTime=performance.now();try{const t=Object.keys(Ze);t.forEach(t=>{this.cacheShape(t)}),this.cacheCommonMorphs(t),this.isInitialized=!0,this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.shapeCache.size}catch(t){this.isInitialized=!1}}cacheShape(t){try{const e=Ze[t];if(e){this.shapeCache.set(t,e);const i={pointCount:e.points?.length||64,hasShadow:"none"!==e.shadow?.type,shadowType:e.shadow?.type||"none",isRadial:this.isRadialShape(t),bounds:this.calculateBounds(e.points)};this.propertyCache.set(t,i)}}catch(t){}}cacheCommonMorphs(t){[["circle","heart"],["circle","star"],["circle","square"],["heart","star"],["star","circle"],["square","circle"],["triangle","circle"],["moon","sun"],["lunar","eclipse"]].forEach(([e,i])=>{if(t.includes(e)&&t.includes(i))try{const t=this.calculateMorphSteps(e,i),s=`${e}->${i}`;this.morphCache.set(s,t)}catch(t){}})}calculateMorphSteps(t,e){const i=this.shapeCache.get(t),s=this.shapeCache.get(e);if(!i||!s)return null;const a=[];for(let t=0;t<5;t++){const e=t/4,h=this.interpolateShapePoints(i.points,s.points,e);a.push({progress:e,points:h})}return{from:t,to:e,steps:a,isRadial:this.isRadialShape(t)||this.isRadialShape(e)}}interpolateShapePoints(t,e,i){if(!t||!e)return t||e||[];const s=Math.max(t.length,e.length),a=[];for(let h=0;h<s;h++){const s=t[h]||t[0]||{x:.5,y:.5},n=e[h]||e[0]||{x:.5,y:.5};a.push({x:s.x+(n.x-s.x)*i,y:s.y+(n.y-s.y)*i})}return a}isRadialShape(t){return["circle","star","square","triangle","sun","moon"].includes(t)}calculateBounds(t){if(!t||0===t.length)return{minX:0,minY:0,maxX:1,maxY:1,width:1,height:1};let e=1/0,i=1/0,s=-1/0,a=-1/0;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),s=Math.max(s,t.x),a=Math.max(a,t.y)}),{minX:e,minY:i,maxX:s,maxY:a,width:s-e,height:a-i}}getShape(t){if(!this.isInitialized)return Ze[t]||null;const e=this.shapeCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,Ze[t]||null)}getProperties(t){if(!this.isInitialized){const e=Ze[t];return e?{pointCount:e.points?.length||64,hasShadow:"none"!==e.shadow?.type,shadowType:e.shadow?.type||"none",isRadial:this.isRadialShape(t),bounds:this.calculateBounds(e.points)}:{}}const e=this.propertyCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,{})}getMorph(t,e){if(!this.isInitialized)return this.calculateMorphSteps(t,e);const i=`${t}->${e}`,s=this.morphCache.get(i);return s?(this.stats.hits++,s):(this.stats.misses++,this.calculateMorphSteps(t,e))}hasShape(t){return this.shapeCache.has(t)}getStats(){const t=this.stats.hits+this.stats.misses;return{...this.stats,hitRate:t>0?`${(this.stats.hits/t*100).toFixed(1)}%`:"0%",shapes:this.shapeCache.size,morphs:this.morphCache.size,properties:this.propertyCache.size}}clear(){this.shapeCache.clear(),this.morphCache.clear(),this.propertyCache.clear(),this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1}},ti=new class{constructor(){this.pools=new Map,this.inUse=new Set}acquire(t,e="array"){const i=`${e}_${t}`;this.pools.has(i)||this.pools.set(i,[]);const s=this.pools.get(i);if(s.length>0){const t=s.pop();return this.inUse.add(t),t}let a;switch(e){case"float32":a=new Float32Array(t);break;case"uint8":a=new Uint8Array(t);break;default:a=new Array(t).fill(0)}return this.inUse.add(a),a}release(t){if(!this.inUse.has(t))return;this.inUse.delete(t);let e="array";t instanceof Float32Array?e="float32":t instanceof Uint8Array&&(e="uint8");const i=`${e}_${t.length}`;t.fill(0),this.pools.has(i)||this.pools.set(i,[]);const s=this.pools.get(i);s.length<10&&s.push(t)}clear(){this.pools.clear(),this.inUse.clear()}};class ei{applyAudioDeformation(t){return t}setAudioDeformation(){}setVocalEnergy(){}}class ii{constructor(){this.detectedTimeSignature=null,this.timeSignatureConfidence=0,this.timeSignatureLocked=!1,this.forceFastDetection=!1}update(){}calculateBPM(){return 0}findTempoCandidates(){return[]}clusterIntervals(){return[]}checkHarmonicRelation(){return!1}detectTimeSignature(){return"4/4"}testWaltzPattern(){return!1}reset(){}}class si{constructor(t){this.morpher=t,this.isTransitioning=!1,this.transitionStartTime=0,this.transitionDuration=800,this.transitionProgress=0,this.easingFunction="easeInOutQuad",this.currentShape="circle",this.targetShape=null,this.previousShape=null,this.morphQueue=[],this.maxQueueSize=3,this.shadowConfig=null,this.shadowProgress=0}startTransition(t,e={}){this.isTransitioning&&this.morphQueue.length<this.maxQueueSize?this.morphQueue.push({shape:t,options:e}):(this.previousShape=this.currentShape,this.targetShape=t,this.isTransitioning=!0,this.transitionStartTime=performance.now(),this.transitionDuration=e.duration||800,this.easingFunction=e.easing||"easeInOutQuad",this.transitionProgress=0,this.shadowConfig=this.getTransitionConfig(this.currentShape,t))}update(t){if(!this.isTransitioning)return;const e=performance.now()-this.transitionStartTime,i=Math.min(1,e/this.transitionDuration);this.transitionProgress=this.applyEasing(i),this.shadowConfig&&(this.shadowProgress=this.calculateShadowProgress(i)),i>=1&&this.completeTransition()}completeTransition(){if(this.currentShape=this.targetShape,this.targetShape=null,this.isTransitioning=!1,this.transitionProgress=0,this.shadowConfig=null,this.morphQueue.length>0){const t=this.morphQueue.shift();this.startTransition(t.shape,t.options)}}getTransitionConfig(t,e){return{"circle-heart":{type:"bloom",shadowColor:"#ff69b4",shadowIntensity:.3},"heart-circle":{type:"contract",shadowColor:"#ff69b4",shadowIntensity:.2},"circle-star":{type:"burst",shadowColor:"#ffd700",shadowIntensity:.4},"star-circle":{type:"collapse",shadowColor:"#ffd700",shadowIntensity:.3}}[`${t}-${e}`]||null}calculateShadowProgress(t){if(!this.shadowConfig)return 0;switch(this.shadowConfig.type){case"bloom":return t<.5?2*t:2-2*t;case"burst":return Math.pow(1-t,2);case"contract":case"collapse":return Math.sin(t*Math.PI);default:return 0}}applyEasing(t){switch(this.easingFunction){case"linear":default:return t;case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return t<.5?2*t*t:(4-2*t)*t-1;case"easeInCubic":return t*t*t;case"easeOutCubic":return--t*t*t+1;case"easeInOutCubic":return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1}}clearQueue(){this.morphQueue=[]}hasQueuedMorphs(){return this.morphQueue.length>0}getState(){return{isTransitioning:this.isTransitioning,currentShape:this.currentShape,targetShape:this.targetShape,progress:this.transitionProgress,queueLength:this.morphQueue.length}}reset(){this.isTransitioning=!1,this.currentShape="circle",this.targetShape=null,this.transitionProgress=0,this.morphQueue=[],this.shadowConfig=null}}class ai{constructor(t){this.Z=t}getCurrentShadow(){const t=this.Z(),e=t.currentShape||"circle",i=Ke&&Ke.isInitialized?Ke.getShape(e):Ze[e],s=t.targetShape?Ke&&Ke.isInitialized?Ke.getShape(t.targetShape):Ze[t.targetShape]:null,a=i?.shadow||{type:"none"},h=s?.shadow||null;if(!t.isTransitioning||!h)return a;const n=t.morphProgress;if(t.transitionConfig&&"from_moon"===t.transitionConfig.type&&t.transitionConfig.slideOutCrescent)return this.K(n,t.transitionConfig);if(t.transitionConfig&&"moon_to_lunar"===t.transitionConfig.type)return this.tt(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_enter_lunar"===t.transitionConfig.type)return this.et(n,t.transitionConfig);if(t.transitionConfig&&"lunar_to_moon"===t.transitionConfig.type)return this.it(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_exit_lunar"===t.transitionConfig.type)return this.st(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_enter"===t.transitionConfig.type)return this.ht(n,h);if("eclipse_exit"===t.transitionConfig.type)return this.nt(n,a);if("sun_fade"===t.transitionConfig.type)return this.rt(n,a);if("sun_bloom"===t.transitionConfig.type)return this.ot(n,h);if("none"!==a.type||"none"!==h.type){const t=(a.coverage||0)+((h.coverage||0)-(a.coverage||0))*n;return{type:"none"!==h.type?h.type:a.type,coverage:t,angle:h.angle||a.angle||0,softness:h.softness||a.softness||.2,progress:n}}return a}K(t,e){const i=e.shadowSlideRatio||.4;if(t<i){const e=t/i,s=-30*Math.PI/180,a=.7,h=a+(2.5-a)*e;return{type:"crescent",coverage:e>.8?.85*(1-5*(e-.8)):.85,angle:-30,offset:h,shadowX:Math.cos(s)*h,shadowY:Math.sin(s)*h}}return{type:"none"}}tt(t,e){const i=e.startAngle*Math.PI/180,s=1-t,a=.7*Math.cos(i)*s,h=.7*Math.sin(i)*s,n=Math.pow(t,2);if(t<.6)return{type:"crescent",coverage:.85*(1-.2*n),angle:e.startAngle,offset:.7*s,shadowX:a,shadowY:h};{const e=(t-.6)/.4,i=Math.sin(e*Math.PI/2);return{type:"lunar",coverage:.85+.1*i,color:`rgba(80, 20, 0, ${.7+.2*i})`,shadowX:a*(1-i),shadowY:h*(1-i),diffusion:i,shadowProgress:t}}}et(t,e){if(t<.3)return{type:"none"};const i=(t-.3)/.7,s=Math.sin(i*Math.PI/2),a=e.startAngle*Math.PI/180,h=1-s,n=.7*Math.cos(a)*h,r=.7*Math.sin(a)*h;if(i<.7)return{type:"crescent",coverage:.85*Math.pow(i/.7,.5),angle:e.startAngle,offset:.7*h,shadowX:n,shadowY:r};{const t=(i-.7)/.3,e=Math.sin(t*Math.PI/2);return{type:"lunar",coverage:.85+.1*e,color:`rgba(80, 20, 0, ${.6+.3*e})`,shadowX:n*(1-e),shadowY:r*(1-e),diffusion:e,shadowProgress:i}}}it(t,e){const i=e.exitAngle*Math.PI/180,s=Math.sin(t*Math.PI/2),a=.7*Math.cos(i)*s,h=.7*Math.sin(i)*s;if(t<.6){const e=t/.6,i=Math.pow(e,.7);return{type:"lunar",coverage:.95-.1*i,color:`rgba(80, 20, 0, ${.9-.3*i})`,shadowX:.7*a,shadowY:.7*h,diffusion:1-i}}{const i=(t-.6)/.4;return{type:"crescent",coverage:.85*Math.sin(i*Math.PI/2)+.1,angle:e.exitAngle,offset:.7,shadowX:a,shadowY:h}}}st(t,e){if(t<.7){const i=t/.7,s=e.exitAngle*Math.PI/180;if(i<.4){const t=i/.4,e=1-t,a=.3*t;return{type:"lunar",coverage:.95-.1*t,color:`rgba(80, 20, 0, ${.9-.2*t})`,shadowX:.7*Math.cos(s)*a,shadowY:.7*Math.sin(s)*a,diffusion:e}}{const t=(i-.4)/.6,a=Math.pow(t,.8),h=.7*Math.cos(s)*a,n=.7*Math.sin(s)*a;return{type:"crescent",coverage:.85*(1-Math.pow(t,2)),angle:e.exitAngle,offset:.7*a,shadowX:h,shadowY:n}}}return{type:"none"}}ht(t,e){return{...e,shadowX:1.5-1.5*t,shadowProgress:t}}nt(t,e){const i=1.5*-t;return{...e,coverage:e.coverage*(1-t),shadowX:i,shadowProgress:1-t}}rt(t,e){const i=1-t;return{...e,intensity:(e.intensity||1)*Math.pow(i,.7),corona:e.corona,coronaOpacity:i,flares:e.flares,flaresOpacity:Math.pow(i,1.5),texture:e.texture,textureOpacity:Math.pow(i,2),turbulence:(e.turbulence||.3)*i}}ot(t,e){const i=t;return{...e,intensity:(e.intensity||1)*Math.pow(i,1.5),corona:e.corona,coronaOpacity:Math.pow(i,.8),flares:e.flares,flaresOpacity:i>.3?Math.pow((i-.3)/.7,.7):0,texture:e.texture,textureOpacity:i>.5?Math.pow((i-.5)/.5,2):0,turbulence:(e.turbulence||.3)*i}}}class hi{constructor(t={}){this.numPoints=t.numPoints||64,this.morphDuration=t.morphDuration||1e3,this.easing=t.easing||"easeInOutCubic",this.transitionManager=new si(this),this.audioDeformer=new ei(this),this.musicDetector=new ii,this.shadowEffectManager=new ai(()=>({currentShape:this.currentShape,targetShape:this.targetShape,morphProgress:this.morphProgress,isTransitioning:this.isTransitioning,transitionConfig:this.transitionConfig})),this.currentShape="circle",this.targetShape=null,this.morphProgress=0,this.visualProgress=0,this.morphStartTime=null,this.isTransitioning=!1,this.queuedMorphTimeout=null,this.shapeCache=new Map,this.currentPoints=[],this.targetPoints=[],this.musicalDuration=null,this.onBeat=!1,this.audioDeformation=0,this.vocalEnergy=0,this.lastAudioUpdate=0,this.lastVocalUpdate=0,this.audioUpdateInterval=33,this.audioAnalyzer=null,this.frequencyData=ti.acquire(32,"float32"),this.glitchPoints=[],this.undulationPhase=0,this.undulationDirection=1,this.beatGlitchIntensity=0,this.bassEnergy=0,this.vocalPresence=0,this.bassHistory=ti.acquire(60,"float32"),this.vocalHistory=ti.acquire(60,"float32"),this.historyIndex=0,this.bassEffectCooldown=0,this.vocalEffectCooldown=0,this.bassThresholdMultiplier=1.2,this.vocalThresholdMultiplier=1.1,this.bassEffectActive=!1,this.vocalEffectActive=!1,this.transientHoldTime=0,this.vocalGlowBoost=0,this.onComplete=null,this.onProgress=null,this.queuedMorph=null,this.currentPoints=this.getShapePoints("circle"),this.shapesLoaded=!0,this.prewarmCache()}prewarmCache(){["circle","heart","star","sun","moon","lunar","square","triangle"].forEach(t=>{(Ke&&Ke.isInitialized?Ke.hasShape(t):Ze[t])&&this.getShapePoints(t)}),[0,.25,.5,.75,1].forEach(t=>{this.applyEasing(t)})}getShapePoints(t){if(!this.shapeCache.has(t)){const e=Ke&&Ke.isInitialized?Ke.getShape(t):Ze[t];if(!e||!e.points){const e=Ze.circle.points;return this.shapeCache.set(t,e),e}const{points:i}=e;return this.shapeCache.set(t,i),i}return this.shapeCache.get(t)}morphTo(t,e={}){if(!this.shapesLoaded)return;if(t===this.currentShape&&!this.isTransitioning)return;if(this.isTransitioning&&!e.force)return this.queuedMorph={targetShape:t,options:e},"queued";this.isTransitioning&&e.force&&this.completeMorph(!0);const i=this.getTransitionConfig(this.currentShape,t);if(this.targetShape=t,this.targetPoints=this.getShapePoints(t),this.morphStartTime=Date.now(),this.isTransitioning=!0,this.morphProgress=0,this.visualProgress=0,"bar"===e.duration||"beat"===e.duration){const t=500;"bar"===e.duration?this.morphDuration=4*t:this.morphDuration=t,this.musicalDuration=!0,this.onBeat=!1!==e.onBeat}else this.morphDuration=i?.duration||e.duration||1e3,this.musicalDuration=null,this.onBeat=!1;this.morphMode=e.mode||"smooth",this.transitionConfig=i,this.onComplete=e.onComplete,this.onProgress=e.onProgress}update(t){if(this.audioAnalyzer&&this.audioAnalyzer.isAnalyzing){const t=this.audioAnalyzer.getShapeMorpherData();if(t&&t.frequencies)for(let e=0;e<Math.min(t.frequencies.length,this.frequencyData.length);e++)this.frequencyData[e]=t.frequencies[e]}if(this.musicDetector&&this.musicDetector.update(performance.now()),!this.isTransitioning||!this.targetShape)return;const e=Date.now()-this.morphStartTime;if(this.musicalDuration){const t=500,e=this.morphDuration>2*t;this.morphDuration=e?4*t:t}let i=Math.min(e/this.morphDuration,1);if(this.musicalDuration&&this.onBeat){const t=120;let e;e=4;const s=6e4/t,a=this.morphDuration/s,h=i*a,n=Math.round(h*e)/e,r=Math.min(1,n/a),o=(.3+.5*Math.max(.4,Math.min(1,1-(t-90)/90)))*(.3+.7*Math.sin(i*Math.PI));i+=o*o*(3-2*o)*(r-i)}this.morphProgress=this.applyEasing(i),this.visualProgress=.8*this.visualProgress+.2*this.morphProgress,Math.abs(this.visualProgress-this.morphProgress)<.001&&(this.visualProgress=this.morphProgress),this.onProgress&&this.onProgress(this.morphProgress),this.morphProgress>=1&&(this.visualProgress=1,this.completeMorph())}completeMorph(t=!1){if(this.targetShape&&(this.currentShape=this.targetShape,this.currentPoints=[...this.targetPoints]),this.targetShape=null,this.isTransitioning=!1,this.morphProgress=0,this.visualProgress=0,this.onComplete&&this.onComplete(this.currentShape),!t&&this.queuedMorph){const t=this.queuedMorph;this.queuedMorph=null,this.queuedMorphTimeout=setTimeout(()=>{this.morphTo(t.targetShape,t.options),this.queuedMorphTimeout=null},50)}}hasQueuedMorph(){return null!==this.queuedMorph}clearQueue(){this.queuedMorph=null,this.queuedMorphTimeout&&(clearTimeout(this.queuedMorphTimeout),this.queuedMorphTimeout=null)}getCanvasPoints(t,e,i){let s;try{s=this.getInterpolatedPoints()}catch{s=this.generateFallbackCircle()}this.canvasPointsCache||(this.canvasPointsCache=[]);const a=this.canvasPointsCache;if(a.length=0,!s||0===s.length){for(let s=0;s<this.numPoints;s++){const h=s/this.numPoints*Math.PI*2;a.push({x:t+Math.cos(h)*i,y:e+Math.sin(h)*i})}return a}const h=Array.isArray(s)?s:[];for(let s=0;s<h.length;s++){const n=h[s];if(n&&"number"==typeof n.x&&"number"==typeof n.y){const s=t+(n.x-.5)*i*2,h=e+(n.y-.5)*i*2;a.push({x:s,y:h})}else{const n=s/h.length*Math.PI*2;a.push({x:t+Math.cos(n)*i,y:e+Math.sin(n)*i})}}for(;a.length<this.numPoints;){const s=a.length/this.numPoints*Math.PI*2;a.push({x:t+Math.cos(s)*i,y:e+Math.sin(s)*i})}return a}getInterpolatedPoints(){if(this.currentPoints&&0!==this.currentPoints.length||(this.currentPoints=this.generateFallbackCircle()),!this.isTransitioning)return this.applyAudioDeformation(this.currentPoints);const t=[];for(let e=0;e<this.numPoints;e++){const i=this.currentPoints[e],s=this.targetPoints[e];if(!i||!s){const i=e/this.numPoints*Math.PI*2;t.push({x:.5+.5*Math.cos(i),y:.5+.5*Math.sin(i)});continue}const a=this.visualProgress;let h,n;const r=["square","circle","star","triangle"],o=r.includes(this.currentShape),l=r.includes(this.targetShape);if(o||l){const t=.5,e=.5;if(l&&!o){const r=s.x-t,o=s.y-e;if(a<.3){const s=a/.3;h=i.x+(t-i.x)*s,n=i.y+(e-i.y)*s}else{const i=(a-.3)/.7;h=t+r*i,n=e+o*i}}else if(o&&!l){const r=i.x-t,o=i.y-e;if(a<.5){const t=a/.5;h=i.x-r*t,n=i.y-o*t}else{const i=(a-.5)/.5;h=t+(s.x-t)*i,n=e+(s.y-e)*i}}else{const r=i.x-t,o=i.y-e,l=s.x-t,c=s.y-e;if(a<.5){const t=a/.5;h=i.x-r*t,n=i.y-o*t}else{const i=(a-.5)/.5;h=t+l*i,n=e+c*i}}}else if("spiral"===this.morphMode){const t=a*Math.PI*2,r=.02*Math.sin(t+.2*e)*(1-2*Math.abs(a-.5));h=i.x+(s.x-i.x)*a+r,n=i.y+(s.y-i.y)*a+r}else if("wave"===this.morphMode){const t=.01*Math.sin(.3*e+a*Math.PI*4);h=i.x+(s.x-i.x)*a+t,n=i.y+(s.y-i.y)*a+t}else h=i.x+(s.x-i.x)*a,n=i.y+(s.y-i.y)*a;t.push({x:h,y:n})}return this.applyAudioDeformation(t)}applyAudioDeformation(t){return this.audioDeformer.applyAudioDeformation(t)}setAudioDeformation(t){const e=Date.now();e-this.lastAudioUpdate>this.audioUpdateInterval&&(this.audioDeformation=Math.max(-1,Math.min(1,t)),this.lastAudioUpdate=e,this.audioDeformer&&this.audioDeformer.setAudioDeformation(Math.abs(this.audioDeformation)))}setVocalEnergy(t){const e=Date.now();e-this.lastVocalUpdate>this.audioUpdateInterval&&(this.vocalEnergy=Math.max(0,Math.min(1,t)),this.lastVocalUpdate=e,this.audioDeformer&&this.audioDeformer.setVocalEnergy(this.vocalEnergy))}getTransitionConfig(t,e){const i=Ke&&Ke.isInitialized?Ke.getShape(t):Ze[t],s=Ke&&Ke.isInitialized?Ke.getShape(e):Ze[e];return"moon"===e?{type:"to_moon",easing:"easeInOutCubic",duration:1500,glowIntensity:1.5,fadeInCrescent:!0}:"moon"===t&&"lunar"===e?{type:"moon_to_lunar",easing:"easeInOutSine",duration:2e3,slideOutCrescent:!1,description:"Crescent shadow moves to center and becomes lunar eclipse"}:"moon"===t?{type:"from_moon",easing:"easeInOutCubic",duration:1e3,slideOutCrescent:!0,shadowSlideRatio:.4,description:"Moon shadow slides away THEN morphs to target"}:"lunar"===e?{type:"eclipse_enter_lunar",startAngle:-30}:"lunar"===t&&"moon"===e?{type:"lunar_to_moon",exitAngle:-30}:"lunar"===t?{type:"eclipse_exit_lunar",exitAngle:-30}:"none"===i?.shadow?.type&&"solar"===s?.shadow?.type?{type:"eclipse_enter",direction:"right"}:"solar"===i?.shadow?.type&&"none"===s?.shadow?.type?{type:"eclipse_exit",direction:"left"}:"sun"===t&&"sun"!==e?{type:"sun_fade",fadeEffects:!0}:"sun"!==t&&"sun"===e?{type:"sun_bloom",bloomEffects:!0}:{type:"standard"}}getCurrentShadow(){return this.shadowEffectManager.getCurrentShadow()}getCurrentRenderer(){return null}applyEasing(t){switch(this.transitionConfig?.easing||this.easing||"linear"){case"linear":return t;case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return t<.5?2*t*t:(4-2*t)*t-1;case"easeInOutSine":return-(Math.cos(Math.PI*t)-1)/2;default:return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}}calculateBPM(){return this.musicDetector.calculateBPM()}findTempoCandidates(t){return this.musicDetector.findTempoCandidates(t)}clusterIntervals(t){return this.musicDetector.clusterIntervals(t)}checkHarmonicRelation(t,e){return this.musicDetector.checkHarmonicRelation(t,e)}detectTimeSignature(){this.musicDetector.forceFastDetection=this.forceFastDetection;const t=this.musicDetector.detectTimeSignature();return this.detectedTimeSignature=this.musicDetector.detectedTimeSignature,this.timeSignatureConfidence=this.musicDetector.timeSignatureConfidence,this.timeSignatureLocked=this.musicDetector.timeSignatureLocked,t}testWaltzPattern(t,e){return this.musicDetector.testWaltzPattern(t,e)}resetMusicDetection(){this.forceFastDetection=!0,this.musicDetector.reset(),this.musicDetector.forceFastDetection=!0,this.onsetThreshold=0,this.detectedBPM=0,this.bpmConfidence=0,this.onsetStrengths=[],this.detectedTimeSignature=null,this.timeSignatureConfidence=0,this.musicDetector.lastBPMCalculation=0,this.measureStartTime=0,this.timeSignatureHistory=[],this.timeSignatureLocked=!1,this.spectralHistory=[],this.spectralFluxHistory=[];const t=document.getElementById("time-sig-display");t&&(t.textContent="โ")}getCurrentMusicInfo(){return{bpm:this.detectedBPM,timeSignature:this.detectedTimeSignature,bpmLocked:this.tempoLocked,timeSigLocked:this.timeSignatureLocked}}generateFallbackCircle(){const t=[];for(let e=0;e<this.numPoints;e++){const i=e/this.numPoints*Math.PI*2;t.push({x:.5+.5*Math.cos(i),y:.5+.5*Math.sin(i)})}return t}getState(){return{currentShape:this.currentShape,targetShape:this.targetShape,isTransitioning:this.isTransitioning,progress:this.morphProgress,audioDeformation:this.audioDeformation,vocalEnergy:this.vocalEnergy}}getProgress(t=!0){return t?this.visualProgress:this.morphProgress}isInTransition(){return this.isTransitioning}destroy(){this.queuedMorphTimeout&&(clearTimeout(this.queuedMorphTimeout),this.queuedMorphTimeout=null),this.queuedMorph=null,this.shapeCache.clear(),this.canvasPointsCache=null,this.frequencyData&&(ti.release(this.frequencyData),this.frequencyData=null),this.bassHistory&&(ti.release(this.bassHistory),this.bassHistory=null),this.vocalHistory&&(ti.release(this.vocalHistory),this.vocalHistory=null),this.audioAnalyzer=null}}class ni{constructor(){this.lt=120,this.ct=new Float64Array(this.lt),this.ut=0,this.dt=0,this.fps=0,this.smoothedFPS=0,this.smoothingFactor=.9,this.lastFrameTime=0,this.frameTime=0,this.maxFrameTimeSamples=10,this.ft=new Float64Array(this.maxFrameTimeSamples),this.Mt=0,this.gt=0,this.averageFrameTime=0}update(t){this.ct[this.ut]=t,this.ut=(this.ut+1)%this.lt,this.dt<this.lt&&this.dt++;const e=t-1e3;let i=0;for(let t=0;t<this.dt;t++)this.ct[t]>e&&i++;if(this.fps=i,0===this.smoothedFPS?this.smoothedFPS=this.fps:this.smoothedFPS=this.smoothedFPS*this.smoothingFactor+this.fps*(1-this.smoothingFactor),this.lastFrameTime>0&&(this.frameTime=t-this.lastFrameTime,this.ft[this.Mt]=this.frameTime,this.Mt=(this.Mt+1)%this.maxFrameTimeSamples,this.gt<this.maxFrameTimeSamples&&this.gt++,this.gt>0)){let t=0;for(let e=0;e<this.gt;e++)t+=this.ft[e];this.averageFrameTime=t/this.gt}this.lastFrameTime=t}getFPS(){return Math.round(this.fps)}getSmoothedFPS(){return Math.round(this.smoothedFPS)}getFrameTime(){return this.frameTime}getAverageFrameTime(){return this.averageFrameTime}reset(){this.ct.fill(0),this.ut=0,this.dt=0,this.fps=0,this.smoothedFPS=0,this.lastFrameTime=0,this.frameTime=0,this.ft.fill(0),this.Mt=0,this.gt=0,this.averageFrameTime=0}getMetrics(){return{fps:this.getFPS(),smoothedFPS:this.getSmoothedFPS(),frameTime:this.getFrameTime(),averageFrameTime:this.getAverageFrameTime(),status:this.fps>=55?"good":this.fps>=30?"okay":"poor"}}}class ri{constructor(t,e={}){this.errorBoundary=t,this.config=e,this.config.targetFPS=e.targetFPS||60,this.loopManager=e.loopManager||Le,this.isRunning=!1,this.animationFrameId=null,this.loopCallbackId=null,this.lastFrameTime=0,this.deltaTime=0,this.isPaused=!1,this.speedMultiplier=1,this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.handleWindowBlur=this.handleWindowBlur.bind(this),this.handleWindowFocus=this.handleWindowFocus.bind(this),"undefined"!=typeof document&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("blur",this.handleWindowBlur),window.addEventListener("focus",this.handleWindowFocus)),this.performanceMonitor=null,this.fpsCounter=new ni,this.subsystems={},this.eventCallback=null,this.parentMascot=null}setSubsystems(t){this.subsystems={stateMachine:t.stateMachine,particleSystem:t.particleSystem,renderer:t.renderer,soundSystem:t.soundSystem,canvasManager:t.canvasManager};const e=["stateMachine","particleSystem","renderer"];for(const t of e)if(!this.subsystems[t])throw new Error(`Required subsystem '${t}' not provided`);this.performanceMonitor&&this.performanceMonitor.setSubsystems(this.subsystems)}setEventCallback(t){if("function"!=typeof t)throw new Error("Event callback must be a function");this.eventCallback=t}setParentMascot(t){this.parentMascot=t}emit(t,e=null){this.eventCallback&&this.eventCallback(t,e)}start(){return this.errorBoundary.wrap(()=>{if(this.isRunning)return!1;if(!this.subsystems.stateMachine)throw new Error("Cannot start animation without subsystems configured");return this.isRunning=!0,this.lastFrameTime=performance.now(),this.subsystems.soundSystem&&this.subsystems.soundSystem.isAvailable()&&this.subsystems.soundSystem.resumeContext(),this.loopCallbackId=this.loopManager.register((t,e)=>this.animate(t,e),0,this),this.emit("animationStarted",{targetFPS:this.targetFPS}),!0},"animation-start")()}stop(){return this.errorBoundary.wrap(()=>!!this.isRunning&&(this.isRunning=!1,this.loopCallbackId&&(this.loopManager.unregister(this.loopCallbackId),this.loopCallbackId=null),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.subsystems.renderer&&this.subsystems.renderer.stopAllGestures&&this.subsystems.renderer.stopAllGestures(),this.subsystems.soundSystem&&this.subsystems.soundSystem.isAvailable()&&this.subsystems.soundSystem.stopAmbientTone(),this.subsystems.particleSystem&&this.subsystems.particleSystem.clear(),this.emit("animationStopped"),!0),"animation-stop")()}handleWindowBlur(){document.hidden||this.handleVisibilityChange()}handleWindowFocus(){!document.hidden&&this.isPaused&&this.handleVisibilityChange()}handleVisibilityChange(){if(document.hidden)this.wasRunning=this.isRunning,this.isPaused=!0,this.pauseTime=performance.now(),this.subsystems?.particleSystem&&(this.subsystems.particleSystem.resetAccumulator(),this.pausedParticleCount=this.subsystems.particleSystem.particles?.length||0),this.subsystems?.renderer?.gestureAnimator&&this.subsystems.renderer.gestureAnimator.pauseCurrentAnimation?.(),this.parentMascot?.pause&&this.parentMascot.pause();else if(this.isPaused&&this.wasRunning){const t=performance.now(),e=t-this.pauseTime;this.lastFrameTime=t,this.frameTimeAccumulator=0,this.fpsCounter&&this.fpsCounter.reset(),this.subsystems?.particleSystem&&this.subsystems.particleSystem.onVisibilityResume(e,this.pausedParticleCount),this.renderer&&(e>X&&this.renderer.resetCanvasContext(),this.renderer.gestureAnimator&&this.renderer.gestureAnimator.resumeAnimation?.(),e>X&&(this.renderer.forceCleanRender=!0)),this.subsystems?.stateMachine&&(this.subsystems.stateMachine.lastUpdateTime=t),this.parentMascot?.resume&&this.parentMascot.resume(),this.isPaused=!1}}animate(t,e){if(!this.isRunning||this.isPaused)return;const i=e||performance.now();this.deltaTime=t||i-this.lastFrameTime,this.deltaTime>20&&(this.deltaTime=20),this.deltaTime>q&&this.deltaTime<20&&(this.deltaTime=q),this.lastFrameTime=i,this.deltaTime*=this.speedMultiplier,this.update(this.deltaTime),this.render()}update(t){if(this.subsystems.stateMachine&&this.subsystems.stateMachine.update(t),this.parentMascot?.stateCoordinator?.yt&&this.parentMascot.stateCoordinator.yt.update(t),this.parentMascot&&"function"==typeof this.parentMascot.update&&this.parentMascot.update(t),"classic"!==this.parentMascot?.config?.renderingStyle&&this.subsystems.particleSystem&&this.subsystems.stateMachine&&this.subsystems.canvasManager){const e=this.subsystems.stateMachine.getCurrentEmotionalProperties();let i;i=this.subsystems.renderer&&"function"==typeof this.subsystems.renderer.getEffectiveCenter?this.subsystems.renderer.getEffectiveCenter():this.subsystems.canvasManager.getCenter();let s=null,a=0;if(this.subsystems.renderer&&this.subsystems.renderer.getCurrentGesture){const t=this.subsystems.renderer.getCurrentGesture();t&&t.particleMotion&&(s=t.particleMotion,a=t.progress||0)}this.subsystems.particleSystem.spawn(e.particleBehavior,this.subsystems.stateMachine.getCurrentState().emotion,e.particleRate,i.x,i.y,t),this.subsystems.particleSystem.update(t,i.x,i.y,s,a)}this.performanceMonitor&&this.performanceMonitor.updateMetrics({particleCount:this.subsystems.particleSystem?.getActiveParticleCount?.()||0,audioLatency:this.subsystems.soundSystem?.getLatency?.()||0})}render(){this.parentMascot&&"function"==typeof this.parentMascot.render?this.parentMascot.render():this.subsystems.renderer&&this.subsystems.renderer.render()}getPerformanceMetrics(){const t=this.fpsCounter?this.fpsCounter.getMetrics():{};return{fps:t.fps||60,instantFps:t.smoothedFPS||60,frameTime:t.frameTime||16.67,averageFrameTime:t.averageFrameTime||16.67,isRunning:this.isRunning,deltaTime:this.deltaTime}}setTargetFPS(t){}get targetFPS(){return this.config.targetFPS||60}setSpeedMultiplier(t){this.speedMultiplier=Math.max(.1,Math.min(10,t))}getSpeedMultiplier(){return this.speedMultiplier}isAnimating(){return this.isRunning}destroy(){this.stop(),"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("blur",this.handleWindowBlur),window.removeEventListener("focus",this.handleWindowFocus)),this.performanceMonitor&&(this.performanceMonitor.destroy(),this.performanceMonitor=null),this.subsystems={},this.eventCallback=null}}class oi{constructor(t,e={}){this.canvas=t,this.config={smoothing:e.smoothing||.1,maxOffset:e.maxOffset||.3,lockDistance:e.lockDistance||30,enabled:!1!==e.enabled,boundaryPadding:e.boundaryPadding||.8},this.canvasCenter={x:0,y:0},this.mousePos={x:0,y:0},this.targetGaze={x:0,y:0},this.currentGaze={x:0,y:0},this.isLocked=!1,this.proximity=0,this.cachedRect=null,this.touches=new Map,this.primaryTouch=null,this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.onInteraction=null,this.updateCanvasCenter(),this.attachEventListeners(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{this.updateCanvasCenter()}),this.resizeObserver.observe(this.canvas))}updateCanvasCenter(){this.cachedRect=this.canvas.getBoundingClientRect(),this.canvasCenter={x:this.cachedRect.width/2,y:this.cachedRect.height/2},0===this.mousePos.x&&0===this.mousePos.y&&(this.mousePos={x:this.canvasCenter.x,y:this.canvasCenter.y})}attachEventListeners(){this.config.enabled&&(this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),this.canvas.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),this.canvas.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),this.canvas.addEventListener("touchcancel",this.handleTouchEnd,{passive:!0}))}handleMouseMove(t){const e=this.cachedRect||this.canvas.getBoundingClientRect();this.mousePos={x:t.clientX-e.left,y:t.clientY-e.top},this.updateTargetGaze(),this.onInteraction&&this.onInteraction("mouse")}handleMouseLeave(){this.targetGaze={x:0,y:0},this.isLocked=!1,this.proximity=0,this.mousePos={x:this.canvasCenter.x,y:this.canvasCenter.y}}handleTouchStart(t){for(const e of t.changedTouches)this.touches.set(e.identifier,{x:e.clientX,y:e.clientY}),this.primaryTouch||1!==this.touches.size||(this.primaryTouch=e.identifier);null!==this.primaryTouch&&this.updateTouchPosition(t.touches)}handleTouchMove(t){for(const e of t.changedTouches)this.touches.has(e.identifier)&&this.touches.set(e.identifier,{x:e.clientX,y:e.clientY});null!==this.primaryTouch&&(this.updateTouchPosition(t.touches),this.onInteraction&&this.onInteraction("touch"))}handleTouchEnd(t){for(const e of t.changedTouches)this.touches.delete(e.identifier),e.identifier===this.primaryTouch&&(this.primaryTouch=null,this.touches.size>0?this.primaryTouch=this.touches.keys().next().value:this.handleMouseLeave())}updateTouchPosition(t){for(const e of t)if(e.identifier===this.primaryTouch){const t=this.cachedRect||this.canvas.getBoundingClientRect();this.mousePos={x:e.clientX-t.left,y:e.clientY-t.top},this.updateTargetGaze();break}}updateTargetGaze(){const t=this.mousePos.x-this.canvasCenter.x,e=this.mousePos.y-this.canvasCenter.y,i=Math.sqrt(t*t+e*e),s=Math.min(this.canvasCenter.x,this.canvasCenter.y);if(this.proximity=Math.max(0,1-i/s),this.isLocked=i<this.config.lockDistance,this.isLocked)this.targetGaze={x:t*this.config.maxOffset*2,y:e*this.config.maxOffset*2};else{const a=Math.min(this.canvasCenter.x,this.canvasCenter.y)*this.config.maxOffset;if(i>0){const h=Math.min(1,i/s);this.targetGaze={x:t/i*a*h*this.config.boundaryPadding,y:e/i*a*h*this.config.boundaryPadding}}else this.targetGaze={x:0,y:0}}}update(t){if(!this.config.enabled)return;const e=1-Math.pow(1-this.config.smoothing,t/16.67);if(this.currentGaze.x+=(this.targetGaze.x-this.currentGaze.x)*e,this.currentGaze.y+=(this.targetGaze.y-this.currentGaze.y)*e,this.isLocked){const t=.5;this.currentGaze.x+=(Math.random()-.5)*t,this.currentGaze.y+=(Math.random()-.5)*t}}getGazeOffset(t){return{x:this.currentGaze.x,y:this.currentGaze.y}}getState(){return{gaze:{...this.currentGaze},target:{...this.targetGaze},proximity:this.proximity,isLocked:this.isLocked,isActive:this.config.enabled}}enable(){this.config.enabled||(this.config.enabled=!0,this.attachEventListeners())}disable(){this.config.enabled&&(this.config.enabled=!1,this.detachEventListeners(),this.targetGaze={x:0,y:0})}detachEventListeners(){this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("touchstart",this.handleTouchStart),this.canvas.removeEventListener("touchmove",this.handleTouchMove),this.canvas.removeEventListener("touchend",this.handleTouchEnd),this.canvas.removeEventListener("touchcancel",this.handleTouchEnd)}setInteractionCallback(t){this.onInteraction=t}destroy(){this.detachEventListeners(),this.resizeObserver&&this.resizeObserver.disconnect(),this.touches.clear()}}class li{constructor(t={}){this.config={blinkInterval:t.blinkInterval||{min:3e3,max:7e3},blinkDuration:t.blinkDuration||150,swayInterval:t.swayInterval||{min:2e4,max:4e4},swayDuration:t.swayDuration||4e3,swayIntensity:t.swayIntensity||1.5,sleepTimeout:void 0!==t.sleepTimeout?t.sleepTimeout:1/0,breathingSpeed:t.breathingSpeed||.25,breathingDepth:t.breathingDepth||.1,enabled:!1!==t.enabled},this.state={isBlinking:!1,isSwaying:!1,isAsleep:!1,breathingPhase:0,breathRate:1,breathDepth:this.config.breathingDepth},this.timers={idle:0,blink:0,sway:0,swayProgress:0,nextBlink:this.getRandomInterval("blink"),nextSway:this.getRandomInterval("sway")},this.swayOffset={x:0,y:0},this.swayTarget={x:0,y:0},this.swayStart={x:0,y:0},this.wakeUpTimeout=null,this.callbacks={onBlink:null,onSway:null,onSleep:null,onWake:null}}update(t){this.config.enabled&&(this.updateBreathing(t),this.timers.idle+=t,!this.state.isAsleep&&this.timers.idle>=this.config.sleepTimeout&&this.enterSleep(),this.state.isAsleep||this.updateBlinking(t),this.state.isAsleep||this.updateSwaying(t))}updateBreathing(t){const e=this.config.breathingSpeed*this.state.breathRate;this.state.breathingPhase+=e*t/1e3,this.state.breathingPhase>2*Math.PI&&(this.state.breathingPhase-=2*Math.PI)}updateBlinking(t){this.isBlinkingEnabled()&&(this.state.isBlinking?(this.timers.blink+=t,this.timers.blink>=this.config.blinkDuration&&this.endBlink()):(this.timers.blink+=t,this.timers.blink>=this.timers.nextBlink&&this.startBlink()))}updateSwaying(t){if(this.state.isSwaying){this.timers.sway+=t;const e=Math.min(this.timers.sway/this.config.swayDuration,1),i=(Math.sin((e-.5)*Math.PI)+1)/2;this.swayOffset.x=this.swayStart.x+(this.swayTarget.x-this.swayStart.x)*i,this.swayOffset.y=this.swayStart.y+(this.swayTarget.y-this.swayStart.y)*i,e>=1&&this.endSway()}else this.timers.sway+=t,this.timers.sway>=this.timers.nextSway&&this.startSway()}startBlink(){this.state.isBlinking=!0,this.timers.blink=0,this.callbacks.onBlink&&this.callbacks.onBlink({phase:"start"})}endBlink(){this.state.isBlinking=!1,this.timers.blink=0,this.timers.nextBlink=this.getRandomInterval("blink"),this.callbacks.onBlink&&this.callbacks.onBlink({phase:"end"})}startSway(){this.state.isSwaying=!0,this.timers.sway=0,this.swayStart={...this.swayOffset};const t=Math.random()*Math.PI*2,e=this.config.swayIntensity*(.5+.5*Math.random());this.swayTarget={x:Math.cos(t)*e*1.5,y:Math.sin(t)*e*.5},this.callbacks.onSway&&this.callbacks.onSway({phase:"start",offset:this.swayOffset})}endSway(){this.state.isSwaying=!1,this.timers.sway=0,this.timers.nextSway=this.getRandomInterval("sway"),this.swayStart={...this.swayOffset},this.callbacks.onSway&&this.callbacks.onSway({phase:"end",offset:this.swayOffset})}enterSleep(){this.state.isAsleep=!0,this.state.breathRate=.5,this.state.breathDepth=.15,this.state.isBlinking&&(this.state.isBlinking=!1,this.timers.blink=0,this.callbacks.onBlink&&this.callbacks.onBlink({phase:"end"})),this.callbacks.onSleep&&this.callbacks.onSleep()}wakeUp(){this.state.isAsleep&&(this.state.isAsleep=!1,this.state.breathRate=1,this.state.breathDepth=this.config.breathingDepth,this.timers.idle=0,this.callbacks.onWake&&this.callbacks.onWake(),this.performWakeAnimation())}performWakeAnimation(){const t={x:.5*this.config.swayIntensity,y:-this.config.swayIntensity};this.swayStart={...this.swayOffset},this.swayTarget=t,this.state.isSwaying=!0,this.timers.sway=0,this.callbacks.onSway&&this.callbacks.onSway({phase:"wake",offset:this.swayOffset}),this.wakeUpTimeout&&clearTimeout(this.wakeUpTimeout),this.wakeUpTimeout=setTimeout(()=>{this.swayStart={...this.swayOffset},this.swayTarget={x:0,y:0},this.timers.sway=0,this.wakeUpTimeout=null},1e3)}resetIdleTimer(){this.timers.idle=0,this.state.isAsleep&&this.wakeUp()}setBlinkingEnabled(t){this.config.blinkingEnabled=t,!t&&this.state.isBlinking&&this.endBlink()}isBlinkingEnabled(){return!1!==this.config.blinkingEnabled}getBreathingFactor(){return 1+Math.sin(this.state.breathingPhase)*this.state.breathDepth*this.state.breathRate}getBlinkProgress(){return this.state.isBlinking?Math.min(this.timers.blink/this.config.blinkDuration,1):0}getSwayOffset(){return this.swayOffset||{x:0,y:0}}getRandomInterval(t){const e=this.config[`${t}Interval`];return e.min+Math.random()*(e.max-e.min)}setCallback(t,e){({}).hasOwnProperty.call(this.callbacks,t)&&(this.callbacks[t]=e)}getState(){return{...this.state,breathingFactor:this.getBreathingFactor(),blinkProgress:this.getBlinkProgress(),swayOffset:this.getSwayOffset()}}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1,this.state.isBlinking=!1,this.state.isSwaying=!1,this.swayOffset={x:0,y:0}}destroy(){this.wakeUpTimeout&&(clearTimeout(this.wakeUpTimeout),this.wakeUpTimeout=null),this.callbacks={onBlink:null,onSway:null,onSleep:null,onWake:null}}}class ci{constructor(){this.methods=new Map}call(){}getAvailableMethods(){return[]}hasMethod(){return!1}stopAll(){}destroy(){}}class ui{moveToElement(){}moveToButton(){}moveToForm(){}moveToModal(){}moveToNavigation(){}moveToContent(){}moveToSidebar(){}moveToHeader(){}moveToFooter(){}destroy(){}}class pi{constructor(t={}){this.offsetX=t.offsetX||0,this.offsetY=t.offsetY||0,this.offsetZ=t.offsetZ||0,this.isAnimating=!1,this.animationId=null,this.animationStartTime=0,this.animationDuration=0,this.animationEasing="easeOutCubic",this.startOffset={x:0,y:0,z:0},this.targetOffset={x:0,y:0,z:0},this.onUpdate=t.onUpdate||(()=>{}),this.onAnimationComplete=t.onAnimationComplete||(()=>{}),this.minScale=t.minScale||.5,this.maxScale=t.maxScale||2,this.zScaleRange=t.zScaleRange||1e3,this.globalScale=1,this.coreScaleOverride=1,this.particleScaleOverride=1,this.positioning=new ci(this),this.elementTargeting=new ui(this)}setOffset(t,e,i=0){this.stopAnimation(),this.offsetX=t,this.offsetY=e,this.offsetZ=i,this.onUpdate(this.getEffectiveCenter())}getOffset(){return{x:this.offsetX,y:this.offsetY,z:this.offsetZ}}getPosition(t=window.innerWidth/2,e=window.innerHeight/2){return{x:t+this.offsetX,y:e+this.offsetY,z:this.offsetZ,scale:this.getZScale()}}animateOffset(t,e,i=0,s=1e3,a="easeOutCubic"){this.stopAnimation(),this.startOffset={x:this.offsetX,y:this.offsetY,z:this.offsetZ},this.targetOffset={x:t,y:e,z:i},this.animationDuration=s,this.animationEasing=a,this.animationStartTime=performance.now(),this.isAnimating=!0,this.startAnimation()}stopAnimation(){this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isAnimating=!1}startAnimation(){const t=e=>{if(!this.isAnimating)return;const i=e-this.animationStartTime,s=Math.min(i/this.animationDuration,1),a=this.applyEasing(s,this.animationEasing);this.offsetX=this.lerp(this.startOffset.x,this.targetOffset.x,a),this.offsetY=this.lerp(this.startOffset.y,this.targetOffset.y,a),this.offsetZ=this.lerp(this.startOffset.z,this.targetOffset.z,a),this.onUpdate(this.getEffectiveCenter()),s>=1?(this.isAnimating=!1,this.onAnimationComplete()):this.animationId=requestAnimationFrame(t)};this.animationId=requestAnimationFrame(t)}getEffectiveCenter(t=0,e=0){return{x:t+this.offsetX,y:e+this.offsetY,scale:this.getZScale(),coreScale:this.getCoreScale(),particleScale:this.getParticleScale()}}getZScale(){const t=-this.offsetZ/this.zScaleRange,e=Math.max(-1,Math.min(1,t));return this.lerp(this.minScale,this.maxScale,(e+1)/2)*this.globalScale}setGlobalScale(t){this.globalScale=Math.max(.1,t),this.onUpdate(this.getEffectiveCenter())}setScaleOverrides(t){"number"==typeof t?(this.globalScale=Math.max(.1,t),this.coreScaleOverride=1,this.particleScaleOverride=1):(void 0!==t.global&&(this.globalScale=Math.max(.1,t.global)),void 0!==t.core&&(this.coreScaleOverride=Math.max(.1,t.core)),void 0!==t.particles&&(this.particleScaleOverride=Math.max(.1,t.particles))),this.onUpdate(this.getEffectiveCenter())}getCoreScale(){return this.calculateBaseZScale()*this.globalScale*this.coreScaleOverride}getParticleScale(){return this.calculateBaseZScale()*this.globalScale*this.particleScaleOverride}calculateBaseZScale(){const t=-this.offsetZ/this.zScaleRange,e=Math.max(-1,Math.min(1,t));return this.lerp(this.minScale,this.maxScale,(e+1)/2)}lerp(t,e,i){return t+(e-t)*i}applyEasing(t,e){switch(e){case"linear":default:return t;case"easeInQuad":return t*t;case"easeOutQuad":return 1-(1-t)*(1-t);case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeInCubic":return t*t*t;case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeInBack":{const e=1.70158;return(e+1)*t*t*t-e*t*t}case"easeOutBack":{const e=1.70158;return 1+(e+1)*Math.pow(t-1,3)+e*Math.pow(t-1,2)}}}getPositioning(){return this.positioning}getElementTargeting(){return this.elementTargeting}callPositioning(t,...e){return this.positioning.call(t,...e)}destroy(){this.stopAnimation(),this.positioning&&(this.positioning.destroy(),this.positioning=null),this.elementTargeting&&(this.elementTargeting.destroy(),this.elementTargeting=null),this.onUpdate=null,this.onAnimationComplete=null}}class di{constructor(){if(di.bt)return this.features=di.bt,void(this.capabilities=di.wt);this.features={webAudio:this.detectWebAudio(),canvas2d:this.detectCanvas2D(),requestAnimationFrame:this.detectRequestAnimationFrame(),devicePixelRatio:this.detectDevicePixelRatio(),audioContext:this.detectAudioContext(),mediaDevices:this.detectMediaDevices(),performance:this.detectPerformance(),intersectionObserver:this.detectIntersectionObserver()},this.capabilities=this.assessCapabilities(),di.bt=this.features,di.wt=this.capabilities}detectWebAudio(){try{return!(!window.AudioContext&&!window.webkitAudioContext)}catch{return!1}}detectCanvas2D(){try{const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))}catch{return!1}}detectRequestAnimationFrame(){return!!(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame)}detectDevicePixelRatio(){return"number"==typeof window.devicePixelRatio}detectAudioContext(){try{return!(!window.AudioContext&&!window.webkitAudioContext)}catch{return!1}}detectMediaDevices(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)}detectPerformance(){return!(!window.performance||!window.performance.now)}detectIntersectionObserver(){return"function"==typeof window.IntersectionObserver}assessCapabilities(){const t=Object.values(this.features).filter(Boolean).length,e=Object.keys(this.features).length,i=t/e*100;let s="basic";return i>=90?s="full":i>=70?s="good":i>=50&&(s="limited"),{score:t,total:e,percentage:i,level:s,recommendations:this.getRecommendations(s)}}getRecommendations(t){const e=[];return this.features.webAudio||e.push("Audio features will be disabled"),this.features.requestAnimationFrame||e.push("Animation will use setTimeout fallback"),this.features.performance||e.push("Performance monitoring will be limited"),"basic"===t&&e.push("Consider using minimal build for better performance"),e}getFeatures(){return{...this.features}}getCapabilities(){return{...this.capabilities}}}class fi{constructor(){this.polyfills=new Map,this.applied=new Set}register(t,e){this.polyfills.set(t,e)}apply(t){if(this.applied.has(t))return!0;const e=this.polyfills.get(t);if(!e)return!1;try{return e(),this.applied.add(t),!0}catch{return!1}}applyAll(){const t=[];for(const e of this.polyfills.keys())this.apply(e)&&t.push(e);return t}isApplied(t){return this.applied.has(t)}}function mi(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(()=>{t(Date.now())},1e3/60)},window.cancelAnimationFrame=window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){window.clearTimeout(t)})}function Mi(){if(window.performance&&window.performance.now)return;window.performance||(window.performance={});const t=Date.now();window.performance.now=function(){return Date.now()-t}}function gi(){window.AudioContext||window.webkitAudioContext||(window.AudioContext=function(){this.state="suspended",this.sampleRate=44100,this.currentTime=0,this.destination={connect(){},disconnect(){}},this.createGain=function(){return{gain:{value:1},connect(){},disconnect(){}}},this.createOscillator=function(){return{frequency:{value:440},type:"sine",start(){},stop(){},connect(){},disconnect(){}}},this.createAnalyser=function(){return{fftSize:2048,frequencyBinCount:1024,getByteFrequencyData(t){for(let e=0;e<t.length;e++)t[e]=0},connect(){},disconnect(){}}},this.resume=function(){return this.state="running",Promise.resolve()},this.suspend=function(){return this.state="suspended",Promise.resolve()},this.close=function(){return this.state="closed",Promise.resolve()}})}class yi{constructor(t){this.canvas=t,this.context=null,this.isContextLost=!1,this.recoveryCallbacks=[],this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),this.setupContextLossHandling()}handleContextLost(t){t.preventDefault(),this.isContextLost=!0}handleContextRestored(){this.isContextLost=!1,this.context=this.canvas.getContext("2d"),this.recoveryCallbacks.forEach(t=>{try{t(this.context)}catch{}})}setupContextLossHandling(){this.canvas.addEventListener("webglcontextlost",this.handleContextLost),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored)}getContext(){if(this.isContextLost)return null;if(!this.context)try{this.context=this.canvas.getContext("2d")}catch{return null}return this.context}onRecovery(t){this.recoveryCallbacks.push(t)}isLost(){return this.isContextLost}recover(){if(!this.isContextLost)return!0;try{if(this.context=this.canvas.getContext("2d"),this.context)return this.isContextLost=!1,!0}catch{}return!1}destroy(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.handleContextLost),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored),this.canvas=null),this.context=null,this.recoveryCallbacks=[]}}class bi{constructor(){if(bi.vt)return this.browser=bi.vt,void(this.optimizations=bi.St);this.browser=this.detectBrowser(),this.optimizations=new Map,this.setupOptimizations(),bi.vt=this.browser,bi.St=this.optimizations}detectBrowser(){const{userAgent:t}=navigator;let e="unknown",i="unknown";if(t.includes("Chrome")){e="chrome";const s=t.match(/Chrome\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Firefox")){e="firefox";const s=t.match(/Firefox\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Safari")&&!t.includes("Chrome")){e="safari";const s=t.match(/Version\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Edge")){e="edge";const s=t.match(/Edge\/(\d+)/);i=s?s[1]:"unknown"}return{name:e,version:i,userAgent:t}}setupOptimizations(){this.optimizations.set("chrome",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"interactive"},canvasOptimizations:["willReadFrequently"],particleLimit:50}),this.optimizations.set("firefox",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"balanced"},canvasOptimizations:[],particleLimit:40}),this.optimizations.set("safari",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"playback"},canvasOptimizations:[],particleLimit:30}),this.optimizations.set("edge",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"interactive"},canvasOptimizations:["willReadFrequently"],particleLimit:45})}getOptimizations(){return this.optimizations.get(this.browser.name)||this.optimizations.get("chrome")}getBrowser(){return{...this.browser}}applyCanvasOptimizations(t,e){if(this.getOptimizations().canvasOptimizations.includes("willReadFrequently"))try{t.getContext("2d",{willReadFrequently:!0})}catch{}}getRecommendedParticleLimit(){return this.getOptimizations().particleLimit}getAudioContextOptions(){return this.getOptimizations().audioContextOptions}}let wi=null,vi=null;const Si=(vi||(vi=function(){if(wi)return wi;const t=new di,e=new fi,i=new bi;e.register("requestAnimationFrame",mi),e.register("performanceNow",Mi),e.register("webAudio",gi);const s=[];return t.features.requestAnimationFrame||e.apply("requestAnimationFrame")&&s.push("requestAnimationFrame"),t.features.performance||e.apply("performanceNow")&&s.push("performanceNow"),t.features.webAudio||e.apply("webAudio")&&s.push("webAudio"),wi={featureDetection:t,polyfillManager:e,browserOptimizations:i,appliedPolyfills:s,capabilities:t.getCapabilities(),browser:i.getBrowser()},wi}()),vi);class Fi{areCompatible(){return!0}canChain(){return!0}getCompatibilityInfo(){return{compatible:!0,reason:"minimal"}}getIncompatibleGestures(){return[]}getTimingClass(){return"medium"}getChordInfo(){return null}getChainInfo(){return null}}const xi=new Fi;var ki=Object.freeze({__proto__:null,GestureCompatibility:Fi,default:xi});class Bi{constructor(t={}){const e=t.initialState||{};this.Ft=e.isRunning??!1,this.xt=e.debugMode??!1,this.kt=e.speaking??!1,this.Bt=e.recording??!1,this.Ct=e.audioLevel??0,this.Rt=e.sleeping??!1,this.Tt=e.rhythmEnabled??!1,this.Pt=e.currentModularGesture??null,this.Ot=e.breathePhase??"idle",this.At=e.breatheStartTime??0,this.Dt=e.orbScale??1,this.zt=e.warningTimestamps??{},this.Et=e.warningThrottle??5e3,this.It=t.emit||(()=>{})}get isRunning(){return this.Ft}set isRunning(t){const e=this.Ft!==t;this.Ft=t,e&&this.It("stateChange",{property:"isRunning",value:t})}get debugMode(){return this.xt}set debugMode(t){const e=this.xt!==t;this.xt=t,e&&this.It("stateChange",{property:"debugMode",value:t})}get speaking(){return this.kt}set speaking(t){const e=this.kt!==t;this.kt=t,e&&this.It("stateChange",{property:"speaking",value:t})}get recording(){return this.Bt}set recording(t){const e=this.Bt!==t;this.Bt=t,e&&this.It("stateChange",{property:"recording",value:t})}get audioLevel(){return this.Ct}set audioLevel(t){this.Ct=t}get sleeping(){return this.Rt}set sleeping(t){const e=this.Rt!==t;this.Rt=t,e&&this.It("stateChange",{property:"sleeping",value:t})}get rhythmEnabled(){return this.Tt}set rhythmEnabled(t){this.Tt=t}get currentModularGesture(){return this.Pt}set currentModularGesture(t){this.Pt=t}get breathePhase(){return this.Ot}set breathePhase(t){this.Ot=t}get breatheStartTime(){return this.At}set breatheStartTime(t){this.At=t}get orbScale(){return this.Dt}set orbScale(t){this.Dt=t}get warningTimestamps(){return this.zt}set warningTimestamps(t){this.zt=t}get warningThrottle(){return this.Et}set warningThrottle(t){this.Et=t}getSnapshot(){return{isRunning:this.Ft,debugMode:this.xt,speaking:this.kt,recording:this.Bt,audioLevel:this.Ct,sleeping:this.Rt,rhythmEnabled:this.Tt,currentModularGesture:this.Pt,breathePhase:this.Ot,breatheStartTime:this.At,orbScale:this.Dt}}reset(){this.Ft=!1,this.xt=!1,this.kt=!1,this.Bt=!1,this.Ct=0,this.Rt=!1,this.Tt=!1,this.Pt=null,this.Ot="idle",this.At=0,this.Dt=1,this.zt={}}}class Ci{constructor(t){if(!t.errorBoundary)throw new Error("GestureController: errorBoundary required");if(!t.config)throw new Error("GestureController: config required");if(!t.state)throw new Error("GestureController: state required");if(!t.throttledWarn)throw new Error("GestureController: throttledWarn required");this.errorBoundary=t.errorBoundary,this.renderer=t.renderer||null,this.performanceMonitor=t.performanceMonitor||null,this.soundSystem=t.soundSystem||null,this.config=t.config,this.jt=t.state,this.$t=t.throttledWarn,this.Gt=t.chainTarget||this,this.currentGesture=null,this.gestureCompatibility=null,this.rendererMethods={bounce:"startBounce",pulse:"startPulse",shake:"startShake",spin:"startSpin",nod:"startNod",tilt:"startTilt",expand:"startExpand",contract:"startContract",flash:"startFlash",drift:"startDrift",stretch:"startStretch",glow:"startGlow",sparkle:"startSparkle",shimmer:"startShimmer",wiggle:"startWiggle",groove:"startGroove",point:"startPoint",lean:"startLean",reach:"startReach",headBob:"startHeadBob",orbit:"startOrbit",flicker:"startFlicker",vibrate:"startVibrate",wave:"startWave",breathe:"startBreathe",morph:"startMorph",slowBlink:"startSlowBlink",look:"startLook",settle:"startSettle",orbital:"startOrbital",hula:"startHula",sway:"startSway",breathIn:"startBreathIn",breathOut:"startBreathOut",breathHold:"startBreathHold",breathHoldEmpty:"startBreathHoldEmpty",jump:"startJump",rain:"startRain",runningman:"startRunningMan",charleston:"startCharleston",grooveSway:"startGrooveSway",grooveBob:"startGrooveBob",grooveFlow:"startGrooveFlow",groovePulse:"startGroovePulse",grooveStep:"startGrooveStep",float:"startFloat",twist:"startTwist"}}init(){this.gestureCompatibility||Promise.resolve().then(function(){return ki}).then(t=>{this.gestureCompatibility=t.default}).catch(t=>{})}express(t,e={}){return this.errorBoundary.wrap(()=>{if(!t)return this.Gt;const i=performance.now(),s=Array.isArray(t)||"object"==typeof t&&"chord"===t.type?"chord":t;if(this.performanceMonitor&&this.performanceMonitor.markGestureStart(s),Array.isArray(t))return this.expressChord(t,e);if("object"==typeof t&&"chord"===t.type)return this.expressChord(t.gestures,e);const a=this.rendererMethods[t];if(a&&this.renderer&&this.renderer[a]){if(this.renderer[a](e),this.config.soundEnabled&&this.soundSystem&&this.soundSystem.isAvailable()&&this.soundSystem.playGestureSound(t),this.performanceMonitor){const t=performance.now();this.performanceMonitor.markGestureEnd(s),this.performanceMonitor.recordGestureTime(s,t-i)}return this.Gt}const h=Qt(t);if(h){if(Y.registerConfig("gesture",t,h),this.jt.currentModularGesture={type:t,config:h,startTime:performance.now(),duration:h.defaultParams?.duration||1e3,progress:0},this.config.soundEnabled&&this.soundSystem&&this.soundSystem.isAvailable()&&this.soundSystem.playGestureSound(t),this.performanceMonitor){const t=performance.now();this.performanceMonitor.markGestureEnd(s),this.performanceMonitor.recordGestureTime(s,t-i)}return this.Gt}return this.$t(`Unknown gesture: ${t}`,`gesture_${t}`),this.performanceMonitor&&this.performanceMonitor.markGestureEnd(s),this.Gt},"gesture-express",this.Gt)()}expressChord(t,e={}){return this.errorBoundary.wrap(()=>{if(!t||!Array.isArray(t)||0===t.length)return this.Gt;this.gestureCompatibility||Promise.resolve().then(function(){return ki}).then(t=>{this.gestureCompatibility=t.default}).catch(t=>{});const i=this.gestureCompatibility?this.gestureCompatibility.getCompatibleGestures(t):t;return i.forEach(t=>{const i="string"==typeof t?t:t.gestureName;this.executeGestureDirectly(i,e)}),this.gestureCompatibility?.isEnhancingCombination?.(i)&&this.renderer?.specialEffects?.addSparkle?.(),this.Gt},"gesture-chord",this.Gt)()}executeGestureDirectly(t,e={}){const i=this.rendererMethods[t];i&&this.renderer&&"function"==typeof this.renderer[i]&&this.renderer[i](e)}chain(...t){if(this.gestureCompatibility){const e=t.join(">"),i=this.gestureCompatibility.parseChain(e);this.executeChainSequence(i)}else t.length>0&&this.express(t[0]);return this.Gt}executeChainSequence(t){if(!t||0===t.length)return;let e=0;const i=()=>{if(e>=t.length)return;const s=t[e];1===s.length?this.express(s[0]):this.expressChord(s),e++,e<t.length&&setTimeout(i,800)};i()}destroy(){this.currentGesture=null,this.gestureCompatibility=null}}class Ri{constructor(t){this.animationController=t.animationController||null,this.audioLevelProcessor=t.audioLevelProcessor||null,this.gazeTracker=t.gazeTracker||null,this.particleSystem=t.particleSystem,this.stateMachine=t.stateMachine,this.jt=t.state||{debugMode:!1,speaking:!1}}buildRenderState(){return{renderStart:this.jt.debugMode?performance.now():0,deltaTime:this.getDeltaTime(),renderState:this.createRenderState()}}getDeltaTime(){return this.animationController?this.animationController.deltaTime:16.67}createRenderState(){return{properties:this.stateMachine.getCurrentEmotionalProperties(),emotion:this.stateMachine.getCurrentState().emotion,undertone:this.stateMachine.getCurrentState().undertone,particleSystem:this.particleSystem,speaking:this.jt.speaking,audioLevel:this.audioLevelProcessor?this.audioLevelProcessor.getCurrentLevel():0,gazeOffset:this.getGazeOffset()}}getGazeOffset(){return this.gazeTracker?this.gazeTracker.currentGaze:{x:0,y:0}}}class Ti{constructor(t){this.renderer=t.renderer,this.stateMachine=t.stateMachine,this.canvasManager=t.canvasManager,this.config=t.config}calculateParticleConfig(t,e){const{orbX:i,orbY:s}=this.calculateOrbPosition(t),{particleBehavior:a,particleRate:h,minParticles:n,maxParticles:r}=this.calculateParticleBehavior(t,e);return{orbX:i,orbY:s,particleBehavior:a,particleRate:h,minParticles:n,maxParticles:r,emotionParams:e}}calculateOrbPosition(t){const e=this.renderer.getEffectiveCenter(),i=e.x;let s=e.y-this.config.topOffset;const a=this.stateMachine.getCurrentEmotionalProperties();return a.verticalOffset&&(s=e.y-this.config.topOffset+this.canvasManager.height*a.verticalOffset),{orbX:i,orbY:s}}calculateParticleBehavior(t,e){let i=e.particleBehavior||"ambient",s=e.particleRate||15;const a=this.stateMachine.getCurrentEmotionalProperties(),h=void 0!==e.minParticles?e.minParticles:a.minParticles||0;let n=void 0!==e.maxParticles?e.maxParticles:a.maxParticles||10;return({particleBehavior:i,particleRate:s,maxParticles:n}=this.applyRendererOverrides(i,s,n)),{particleBehavior:i,particleRate:s,minParticles:h,maxParticles:n}}applyRendererOverrides(t,e,i){return this.renderer.state&&this.renderer.state.particleBehaviorOverride&&(t=this.renderer.state.particleBehaviorOverride),this.renderer.state&&this.renderer.state.particleRateMult&&(e=Math.floor(e*this.renderer.state.particleRateMult),i=Math.floor(i*this.renderer.state.particleRateMult)),{particleBehavior:t,particleRate:e,maxParticles:i}}getParticleModifier(t){return this.renderer.getUndertoneModifier?this.renderer.getUndertoneModifier():null}}class Pi{constructor(t){this.renderer=t.renderer,this.jt=t.state}getGestureMotion(){let t=null,e=0;const i=this.jt.currentModularGesture;return i?({gestureMotion:t,gestureProgress:e}=this.processModularGesture(i)):this.renderer&&this.renderer.getCurrentGesture&&({gestureMotion:t,gestureProgress:e}=this.processRendererGesture()),{gestureMotion:t,gestureProgress:e}}processModularGesture(t){const e=performance.now()-t.startTime,i=Math.min(e/t.duration,1),s={type:t.type,amplitude:1,frequency:1,intensity:1};return i>=1&&this.handleGestureCleanup(t),{gestureMotion:s,gestureProgress:i}}handleGestureCleanup(t){t.cleanupPending?this.jt.currentModularGesture=null:t.cleanupPending=!0}processRendererGesture(){const t=this.renderer.getCurrentGesture();return t&&t.particleMotion?{gestureMotion:t.particleMotion,gestureProgress:t.progress||0}:{gestureMotion:null,gestureProgress:0}}getGestureTransform(){return this.renderer?.gestureAnimator?.applyGestureAnimations()??null}}const Oi=new class{constructor(){this.logs=[],this.errors=[]}log(){}warn(){}error(){}info(){}debug(){}trace(){}profile(){}endProfile(){}getProfiles(){return[]}getErrors(){return[]}clearErrors(){}getMemorySnapshot(){return null}};class Ai{constructor(t){this.canvasManager=t.canvasManager,this.config=t.config,this.particleSystem=t.particleSystem,this.pluginSystem=t.pluginSystem||null,this.renderer=t.renderer,this.stateMachine=t.stateMachine,this.jt=t.state||{debugMode:!1},this.qt=t.renderDebugInfo||(()=>{})}renderAllLayers(t){const{renderState:e,deltaTime:i,emotionParams:s,gestureTransform:a,renderStart:h}=t;this.renderBackgroundParticles(s.glowColor,a),this.renderOrb(e,i,a),this.renderForegroundParticles(s.glowColor,a),this.renderPlugins(),this.renderDebugIfEnabled(i),this.logPerformanceIfDebug(h,i)}renderBackgroundParticles(t,e){this.particleSystem.renderBackground(this.canvasManager.getContext(),t,e)}renderOrb(t,e,i){this.renderer.render(t,e,i)}renderForegroundParticles(t,e){this.particleSystem.renderForeground(this.canvasManager.getContext(),t,e)}renderPlugins(){if(this.pluginSystem){const t=this.stateMachine.getCurrentState();this.pluginSystem.render(this.canvasManager.getContext(),t)}}renderDebugIfEnabled(t){(this.config.showFPS||this.config.showDebug)&&this.qt(t)}logPerformanceIfDebug(t,e){if(!this.jt.debugMode)return;const i=performance.now()-t;i>16.67&&Oi.log("WARN","Slow render frame detected",{renderTime:i,deltaTime:e,particleCount:this.particleSystem.getStats().activeParticles})}}class Di{constructor(t={}){this.Xt=t,this.Yt=!1}init(t){if(this.Yt)return this;this.errorBoundary=new e,this.eventManager=new i({maxListeners:100,enableMonitoring:!1}),this.Ht();const a=Si.browserOptimizations.getOptimizations();if(this.config={canvasId:t,targetFPS:60,maxParticles:a.particleLimit,defaultEmotion:"neutral",renderingStyle:"classic",enableGazeTracking:!0,enableIdleBehaviors:!0,topOffset:0,offsetX:0,offsetY:0,offsetZ:0,classicConfig:{coreColor:"#FFFFFF",coreSizeDivisor:12,glowMultiplier:2.5,defaultGlowColor:"#14B8A6"},...this.Xt},this.stateManager=new Bi({initialState:{debugMode:!1},emit:(t,e)=>this.emit(t,e)}),this._t(),this.canvas="string"==typeof t?document.getElementById(t):t,!this.canvas)throw new Error(`Canvas '${t}' not found`);this.canvasManager=new s(this.canvas),this.positionController=new pi({offsetX:this.config.offsetX,offsetY:this.config.offsetY,offsetZ:this.config.offsetZ,onUpdate:t=>{this.renderer&&this.renderer.updateEffectiveCenter(t)}}),this.config.renderSize?.width&&this.config.renderSize?.height&&this.canvasManager.setRenderSize(this.config.renderSize.width,this.config.renderSize.height),this.contextRecovery=new yi(this.canvas),this.contextRecovery.onRecovery(t=>{this.renderer&&this.renderer.handleContextRecovery(t)}),Si.browserOptimizations.applyCanvasOptimizations(this.canvas,this.canvasManager.getContext()),this.stateMachine=new G(this.errorBoundary),this.particleSystem=new ee(this.config.maxParticles,this.errorBoundary),this.particleSystem.canvasWidth=this.canvasManager.width,this.particleSystem.canvasHeight=this.canvasManager.height,this.renderer=new Ne(this.canvasManager,{...this.config.classicConfig,topOffset:this.config.topOffset||0,positionController:this.positionController}),this.renderer.stateMachine=this.stateMachine,this.stateMachine.renderer=this.renderer,this.shapeMorpher=new hi,this.renderer.shapeMorpher=this.shapeMorpher,this.gestureController=new Ci({errorBoundary:this.errorBoundary,renderer:this.renderer,soundSystem:null,config:this.config,state:{get currentModularGesture(){return h.currentModularGesture},set currentModularGesture(t){h.currentModularGesture=t}},throttledWarn:this.$t.bind(this),chainTarget:this});const h=this;this.gestureController.gestureCompatibility=xi,this.gestureController.init(),this.config.enableGazeTracking&&(this.gazeTracker=new oi(this.canvas,{smoothing:.1,maxOffset:.15,enabled:!0}),this.gazeTracker.setInteractionCallback(()=>{this.sleeping||this.idleBehavior&&this.idleBehavior.resetIdleTimer()})),this.config.enableIdleBehaviors&&(this.idleBehavior=new li({enabled:!0,sleepTimeout:1/0}),this.idleBehavior.setCallback("onBlink",t=>{this.renderer?.state&&(this.renderer.state.blinking="start"===t.phase)}));try{this.animationController=new ri(this.errorBoundary,{targetFPS:this.config.targetFPS})}catch(t){this.animationController=this.Lt()}return this.animationController.setSubsystems({stateMachine:this.stateMachine,particleSystem:this.particleSystem,renderer:this.renderer,soundSystem:null,canvasManager:this.canvasManager}),this.animationController.setEventCallback((t,e)=>{this.emit(t,e)}),this.animationController.setParentMascot(this),this.renderStateBuilder=new Ri({animationController:this.animationController,gazeTracker:this.gazeTracker||null,particleSystem:this.particleSystem,stateMachine:this.stateMachine,state:{debugMode:!1,speaking:!1}}),this.particleConfigCalculator=new Ti({renderer:this.renderer,stateMachine:this.stateMachine,canvasManager:this.canvasManager,config:this.config}),this.gestureMotionProvider=new Pi({renderer:this.renderer,state:{get currentModularGesture(){return h.currentModularGesture},set currentModularGesture(t){h.currentModularGesture=t}}}),this.renderLayerOrchestrator=new Ai({canvasManager:this.canvasManager,config:this.config,particleSystem:this.particleSystem,renderer:this.renderer,stateMachine:this.stateMachine,state:{debugMode:!1}}),this.stateMachine.setEmotion(this.config.defaultEmotion),this.canvasManager.onResize((t,e,i)=>{this.particleSystem.canvasWidth=t,this.particleSystem.canvasHeight=e,this.renderer?.handleResize&&this.renderer.handleResize(t,e,i)}),this.Yt=!0,this}start(){if(!this.Yt||this.animationController.isAnimating())return this;if(this.animationController.start()){if(this.isRunning=!0,"classic"===this.config.renderingStyle){const{emotion:t}=this.stateMachine.getCurrentState(),e=O(t),i=this.renderer.getEffectiveCenter?.()||this.canvasManager.getCenter();if(this.particleSystem.clear(),e.particleRate>0){const t=Math.min(3,Math.floor(e.particleRate/4));t>0&&this.particleSystem.burst(t,e.particleBehavior,i.x,i.y)}}this.emit("started")}return this}stop(){return this.Yt&&this.animationController.isAnimating()?(this.animationController.stop()&&(this.isRunning=!1,this.emit("stopped")),this):this}setEmotion(t,e=null){if(!this.Yt)return this;const i={happy:"joy",curious:"surprise",frustrated:"anger",sad:"sadness"}[t]||t;let s=null,a=500,h=1;if("string"==typeof e?s=e:e&&"object"==typeof e&&(s=e.undertone||null,a=e.duration||500,h=e.intensity??1),this.stateMachine.setEmotion(i,{undertone:s,duration:a,intensity:h})&&this.particleSystem){this.particleSystem.clear();const t=this.stateMachine.getCurrentEmotionalProperties();let e;if(e="neutral"===i?1:"resting"===i?4:Math.min(3,Math.floor(t.particleRate/4)),e>0){const i=this.renderer.getEffectiveCenter?.()||{x:this.canvasManager.width/2,y:this.canvasManager.height/2};this.particleSystem.burst(e,t.particleBehavior,i.x,i.y)}this.emit("emotionChanged",{emotion:i,undertone:s,intensity:h})}return this}express(t,e={}){return this.Yt&&this.gestureController?this.gestureController.express(t,e):this}setShape(t){return this.Yt&&this.shapeMorpher?(this.shapeMorpher.morphTo(t),this):this}setPosition(t,e,i=0){return this.positionController&&this.positionController.setOffset(t,e,i),this}resize(t,e){return this.canvasManager&&this.canvasManager.setRenderSize(t,e),this}getState(){if(!this.Yt)return{emotion:"neutral",shape:"circle",isRunning:!1};const{emotion:t,undertone:e}=this.stateMachine.getCurrentState();return{emotion:t,undertone:e,shape:this.shapeMorpher?.currentShape||"circle",isRunning:this.stateManager?.isRunning??!1}}on(t,e){return this.eventManager&&this.eventManager.on(t,e),this}off(t,e){return this.eventManager&&this.eventManager.off(t,e),this}destroy(){this.Yt&&(this.stop(),this.animationController?.destroy&&this.animationController.destroy(),this.particleSystem?.destroy&&this.particleSystem.destroy(),this.renderer?.destroy&&this.renderer.destroy(),this.canvasManager?.destroy&&this.canvasManager.destroy(),this.shapeMorpher?.destroy&&this.shapeMorpher.destroy(),this.positionController?.destroy&&this.positionController.destroy(),this.gazeTracker?.destroy&&this.gazeTracker.destroy(),this.contextRecovery?.destroy&&this.contextRecovery.destroy(),this.Yt=!1)}update(t){}render(){try{const{deltaTime:t,renderState:e}=this.renderStateBuilder.buildRenderState();this.canvasManager.clear(),this.gazeTracker&&this.gazeTracker.update(t);const i=O(e.emotion);this.renderer.setEmotionalState(e.emotion,i,e.undertone);const s=this.particleConfigCalculator.calculateParticleConfig(e,i),{orbX:a,orbY:h,particleBehavior:n,particleRate:r,minParticles:o,maxParticles:l}=s;this.particleSystem.spawn(n,e.emotion,r,a,h,t,null,o,l,this.renderer.particleScaleFactor||this.renderer.scaleFactor||1,this.config.classicConfig?.particleSizeMultiplier||1,i.particleColors||null,e.undertone);const c=this.particleConfigCalculator.getParticleModifier(e),{gestureMotion:u,gestureProgress:p}=this.gestureMotionProvider.getGestureMotion();this.particleSystem.update(t,a,h,u,p,c);const d=this.gestureMotionProvider.getGestureTransform();this.renderLayerOrchestrator.renderAllLayers({renderState:e,deltaTime:t,emotionParams:i,gestureTransform:d,renderStart:0})}catch(t){this.errorBoundary.logError(t,"minimal-render")}}emit(t,e=null){this.eventManager?.emit&&this.eventManager.emit(t,e)}Ht(){this.eventManager.emit||(this.eventManager.t={},this.eventManager.emit=(t,e)=>{const i=this.eventManager.t[t];i&&i.forEach(t=>t(e))},this.eventManager.on=(t,e)=>{this.eventManager.t[t]||(this.eventManager.t[t]=[]),this.eventManager.t[t].push(e)},this.eventManager.off=(t,e)=>{const i=this.eventManager.t[t];if(i){const t=i.indexOf(e);t>-1&&i.splice(t,1)}})}$t(t,e){const i=Date.now();this.Wt||(this.Wt={}),(!this.Wt[t]||i-this.Wt[t]>5e3)&&(this.Wt[t]=i)}_t(){const t=this.stateManager,e=["speaking","recording","sleeping","isRunning","debugMode","audioLevel","rhythmEnabled","currentModularGesture","breathePhase","breatheStartTime","orbScale","warningTimestamps","warningThrottle"],i={};for(const s of e)i[s]={get:()=>t[s],set(e){t[s]=e},enumerable:!0,configurable:!0};Object.defineProperties(this,i)}Lt(){const t=this;return{isAnimating:()=>t.isRunning,start:()=>(t.isRunning=!0,!0),stop:()=>(t.isRunning=!1,!0),setTargetFPS:()=>{},getPerformanceMetrics:()=>({fps:0,isRunning:t.isRunning}),setSubsystems:()=>{},setEventCallback:()=>{},setParentMascot:()=>{},destroy:()=>{},deltaTime:16}}}t.BUILD_TYPE="minimal",t.ENGINE_NAME="Emotive Engine Minimal",t.EmotiveRenderer=Ne,t.EventManager=i,t.FEATURES={rhythmSync:!1,grooveTemplates:!1,gestureBlending:!0,audioReactive:!1,particleSystem:!0,accessibility:!1,mobileOptimization:!1,performanceMonitoring:!1},t.GESTURE_TYPES=Vt,t.MinimalMascot=Di,t.ParticleSystem=ee,t.VERSION="3.4.0-minimal",t.applyGesture=function(t,e,i,s,a,h,n){const r=Qt(e);return!!r&&(r.apply&&r.apply(t,i,s,a,h,n),i>=1&&r.cleanup&&r.cleanup(t),!0)},t.default=Di,t.getEmotion=P,t.getEmotionVisualParams=O,t.getGesture=Qt,t.hasEmotion=z,t.listEmotions=D,t.listGestures=function(){const t=[];return Object.values(Ht).forEach(e=>{t.push({name:e.name,emoji:e.emoji||"๐ญ",type:e.type,category:Nt[e.name]||"atmosphere",description:e.description||"No description",source:"core"})}),wt().forEach(e=>{const i=bt(e);t.push({name:i.name,emoji:i.emoji||"๐",type:i.type,category:i.category||"effect",description:i.description||"Plugin gesture",source:"plugin"})}),t},Object.defineProperty(t,"Ut",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EmotiveMascotMinimal={})}(this,function(t){"use strict";class e{constructor(){this.errors=[],this.maxErrors=10,this.errorCounts=new Map,this.defaults={emotion:"neutral",gesture:null,audioLevel:0,particleCount:0,glowIntensity:.7,coreSize:1,breathRate:1,color:"#B0B0B0"}}wrap(t,e,i=null){return(...s)=>{try{const a=t(...s);return a&&"function"==typeof a.then?a.catch(t=>(this.logError(t,e),null!==i?i:this.getDefault(e))):a}catch(t){return this.logError(t,e),null!==i?i:this.getDefault(e)}}}logError(t,e){const i={timestamp:(new Date).toISOString(),context:e,message:t.message,stack:t.stack};this.errors.push(i);const s=this.errorCounts.get(e)||0;this.errorCounts.set(e,s+1),this.errors.length>this.maxErrors&&this.errors.shift()}getDefault(t){const e={"emotion-transition":this.defaults.emotion,"gesture-execution":this.defaults.gesture,"audio-processing":this.defaults.audioLevel,"particle-system":this.defaults.particleCount,rendering:{glowIntensity:this.defaults.glowIntensity,coreSize:this.defaults.coreSize,color:this.defaults.color},"canvas-operations":null,"state-management":this.defaults.emotion};return{}.hasOwnProperty.call(e,t)?e[t]:null}validateInput(t,e,i){try{switch(e){case"emotion":return["neutral","joy","sadness","anger","fear","surprise","disgust","love","euphoria"].includes(t)?t:i;case"undertone":return null===t||["nervous","confident","tired","intense","subdued"].includes(t)?t:null;case"gesture":return["bounce","pulse","shake","spin","nod","tilt","expand","contract","flash","drift"].includes(t)?t:i;case"number":return"number"!=typeof t||isNaN(t)?i:t;case"string":return"string"==typeof t?t:i;case"boolean":return"boolean"==typeof t?t:i;default:return null!=t?t:i}}catch(t){return this.logError(t,"input-validation"),i}}hasExceededThreshold(t,e=5){return(this.errorCounts.get(t)||0)>=e}getErrorStats(){return{totalErrors:this.errors.length,errorsByContext:Object.fromEntries(this.errorCounts),recentErrors:this.errors.slice(-5)}}clearErrors(){this.errors=[],this.errorCounts.clear()}async attemptRecovery(t,e,i=3){let s=0;for(;s<i;)try{return await e()}catch(e){if(s++,this.logError(e,`recovery-${t}-attempt-${s}`),s>=i)throw new Error(`Recovery failed for ${t} after ${i} attempts`);await new Promise(t=>setTimeout(t,100*Math.pow(2,s)))}}}class i{constructor(){this.listeners=new Map,this.groups=new Map,this.stats={registered:0,removed:0,active:0},this.t={},this.i=new Map}addEventListener(t,e,i,s={},a="default"){const h=this.generateId(),n={id:h,target:t,eventType:e,handler:i,options:s,group:a,active:!0};return this.listeners.set(h,n),this.groups.has(a)||this.groups.set(a,new Set),this.groups.get(a).add(h),t.addEventListener(e,i,s),this.stats.registered++,this.stats.active++,h}removeEventListener(t){const e=this.listeners.get(t);if(!e||!e.active)return!1;e.target.removeEventListener(e.eventType,e.handler,e.options),e.active=!1;const i=this.groups.get(e.group);return i&&(i.delete(t),0===i.size&&this.groups.delete(e.group)),this.listeners.delete(t),this.stats.removed++,this.stats.active--,!0}removeGroup(t){const e=this.groups.get(t);if(!e)return 0;let i=0;for(const t of e)this.removeEventListener(t)&&i++;return i}removeAllForTarget(t){let e=0;for(const[i,s]of this.listeners.entries())s.target===t&&s.active&&this.removeEventListener(i)&&e++;return e}removeAllOfType(t){let e=0;for(const[i,s]of this.listeners.entries())s.eventType===t&&s.active&&this.removeEventListener(i)&&e++;return e}removeAll(){let t=0;for(const[e,i]of this.listeners.entries())i.active&&this.removeEventListener(e)&&t++;return t}createAutoRemove(t,e,i,s={}){const a=this.addEventListener(t,e,i,s);return{id:a,remove:()=>this.removeEventListener(a)}}once(t,e,i,s={}){const a=this.addEventListener(t,e,t=>{i(t),this.removeEventListener(a)},s);return a}debounced(t,e,i,s=250,a={}){let h;return this.addEventListener(t,e,t=>{clearTimeout(h),h=setTimeout(()=>i(t),s)},a)}throttled(t,e,i,s=100,a={}){let h=!1;return this.addEventListener(t,e,t=>{h||(i(t),h=!0,setTimeout(()=>{h=!1},s))},a)}on(t,e){this.i.has(t)||this.i.set(t,[]),this.i.get(t).push(e)}off(t,e){const i=this.i.get(t);if(!i)return;const s=i.indexOf(e);-1!==s&&i.splice(s,1),0===i.length&&this.i.delete(t)}emit(t,e=null){const i=this.i.get(t);if(i)for(let t=0;t<i.length;t++)try{i[t](e)}catch(t){}}removeAllListeners(t=null){if(t){const e=this.i.get(t),i=e?e.length:0;return this.i.delete(t),i}let e=0;for(const t of this.i.values())e+=t.length;return this.i.clear(),e}listenerCount(t){const e=this.i.get(t);return e?e.length:0}getEventNames(){return Array.from(this.i.keys())}getEventStats(){let t=0;for(const e of this.i.values())t+=e.length;return{domListeners:this.stats.active,emitterEvents:this.i.size,emitterListeners:t}}getDebugInfo(){const t={};for(const[e,i]of this.i)t[e]=i.length;return{domStats:this.getStats(),emitterEvents:t,activeListeners:this.getActiveListeners()}}generateId(){return`listener_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{...this.stats,groups:this.groups.size,listeners:this.listeners.size}}getActiveListeners(){const t=[];for(const[e,i]of this.listeners.entries())i.active&&t.push({id:e,eventType:i.eventType,group:i.group,target:i.target.constructor.name});return t}analyzeLeaks(){const t={totalListeners:this.listeners.size,activeListeners:this.stats.active,inactiveButNotRemoved:0,byTarget:new Map,byType:new Map,potentialLeaks:[]};for(const[e,i]of this.listeners.entries()){const s=i.target.constructor.name;t.byTarget.set(s,(t.byTarget.get(s)||0)+1),t.byType.set(i.eventType,(t.byType.get(i.eventType)||0)+1),i.active||(t.inactiveButNotRemoved++,t.potentialLeaks.push({id:e,eventType:i.eventType,target:s}))}return t.byTarget=Object.fromEntries(t.byTarget),t.byType=Object.fromEntries(t.byType),t}cleanup(){let t=0;for(const[e,i]of this.listeners.entries())i.active||(this.listeners.delete(e),t++);return t}destroy(){const t=this.removeAll();return this.listeners.clear(),this.groups.clear(),this.i.clear(),this.t=null,this.stats={registered:0,removed:0,active:0},t}}class s{constructor(t){this.canvas=t,this.ctx=t.getContext("2d",{alpha:!0,desynchronized:!1,willReadFrequently:!1}),this.ctx||(this.o=!0),this.dpr=window.devicePixelRatio||1,this.width=0,this.height=0,this.centerX=0,this.centerY=0,this.renderSize=null,this.resizeCallbacks=[],this.handleResize=this.handleResize.bind(this),window.addEventListener("resize",this.handleResize),this.resize()}resize(){if(!this.o){if(this.renderSize&&this.renderSize.width&&this.renderSize.height)this.width=this.renderSize.width,this.height=this.renderSize.height,this.canvas.width=this.width,this.canvas.height=this.height;else if(this.canvas.hasAttribute("width")&&this.canvas.hasAttribute("height")){const t=parseInt(this.canvas.getAttribute("width"),10),e=parseInt(this.canvas.getAttribute("height"),10),i=this.canvas.getBoundingClientRect(),s=i.width,a=i.height;t>1.5*s||e>1.5*a?(this.width=s,this.height=a,this.canvas.width=t,this.canvas.height=e,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.dpr,this.dpr)):(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e)}else{const t=this.canvas.getBoundingClientRect();this.width=t.width,this.height=t.height,this.canvas.width=this.width*this.dpr,this.canvas.height=this.height*this.dpr,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(this.dpr,this.dpr)}this.centerX=this.width/2,this.centerY=this.height/2,this.resizeCallbacks.forEach(t=>{try{t(this.width,this.height,this.dpr)}catch{}})}}onResize(t){"function"==typeof t&&this.resizeCallbacks.push(t)}handleResize(){clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.renderSize&&this.renderSize.width&&this.renderSize.height||this.resize()},100)}setRenderSize(t,e){this.renderSize={width:t,height:e},this.resize()}clear(){this.o||this.ctx.clearRect(0,0,this.width,this.height)}getCenter(){return{x:this.centerX,y:this.centerY}}setTransform(t=0,e=0,i=1,s=0){this.o||(this.ctx.save(),this.ctx.translate(t,e),this.ctx.rotate(s),this.ctx.scale(i,i))}restoreTransform(){this.o||this.ctx.restore()}getContext(){return this.ctx}getDimensions(){return{width:this.width,height:this.height}}destroy(){window.removeEventListener("resize",this.handleResize),clearTimeout(this.resizeTimeout),this.ctx&&(this.ctx.clearRect(0,0,this.width,this.height),this.ctx=null),this.canvas&&(this.canvas.width=0,this.canvas.height=0,this.canvas=null),this.resizeCallbacks=[],this.resizeTimeout=null}}function a(t){return 3===(t=t.replace("#","")).length&&(t=t.split("").map(t=>t+t).join("")),{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16)}}function h(t,e,i){const s=t=>{const e=Math.round(Math.max(0,Math.min(255,t))).toString(16);return 1===e.length?`0${e}`:e};return`#${s(t)}${s(e)}${s(i)}`}function n(t,e,i){t/=255,e/=255,i/=255;const s=Math.max(t,e,i),a=Math.min(t,e,i),h=(s+a)/2;let n,r;if(s===a)n=r=0;else{const o=s-a;switch(r=h>.5?o/(2-s-a):o/(s+a),s){case t:n=(e-i)/o+(e<i?6:0);break;case e:n=(i-t)/o+2;break;case i:n=(t-e)/o+4}n/=6}return{h:360*n,s:100*r,l:100*h}}function r(t,e,i){t/=360,i/=100;const s=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t);let a,h,n;if(0==(e/=100))a=h=n=i;else{const r=i<.5?i*(1+e):i+e-i*e,o=2*i-r;a=s(o,r,t+1/3),h=s(o,r,t),n=s(o,r,t-1/3)}return{r:Math.round(255*a),g:Math.round(255*h),b:Math.round(255*n)}}function o(t,e,i){const s=a(t),o=a(e),l=n(s.r,s.g,s.b),c=n(o.r,o.g,o.b),u=l.h;let p=c.h;const d=p-u;d>180?p-=360:d<-180&&(p+=360);const f=r(((u+(p-u)*i)%360+360)%360,l.s+(c.s-l.s)*i,l.l+(c.l-l.l)*i);return h(f.r,f.g,f.b)}const l={intense:1.6,confident:1.3,nervous:1.15,clear:1,tired:.8,subdued:.5};function c(t,e){if(!e||"clear"===e)return t;const i=l[e.toLowerCase()];return i&&1!==i?function(t,e){const i=a(t),s=n(i.r,i.g,i.b);s.s=Math.max(0,Math.min(100,s.s*e));const o=r(s.h,s.s,s.l);return h(o.r,o.g,o.b)}(t,i):t}function u(t){return t}function p(t){return t*(2-t)}function d(t){return t*t}function f(t){return t<.5?2*t*t:(4-2*t)*t-1}function m(t){return 1-Math.pow(1-t,3)}function M(t){return t*t*t}function g(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function y(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin((10*t-.75)*e)+1}function b(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375}function w(t){const e=2.5949095;return t<.5?Math.pow(2*t,2)*(7.189819*t-e)/2:(Math.pow(2*t-2,2)*((e+1)*(2*t-2)+e)+2)/2}function v(t){return Math.sin(t*Math.PI/2)}function S(t){return-(Math.cos(Math.PI*t)-1)/2}function F(t,e,i,s="linear"){return e+(i-e)*("string"==typeof s?{linear:u,easeOutQuad:p,easeInQuad:d,easeInOutQuad:f,easeOutCubic:m,easeInCubic:M,easeInOutCubic:g,easeOutElastic:y,easeOutBounce:b,easeInOutBack:w,easeOutSine:v,easeInOutSine:S}[s]||u:s)(Math.max(0,Math.min(1,t)))}Object.fromEntries(Object.entries({neutral:"#B0B0B0",joy:"#FFD700",sadness:"#4169E1",anger:"#DC143C",fear:"#8B008B",surprise:"#FF8C00",disgust:"#9ACD32",love:"#FF69B4"}).map(([t,e])=>{const i=a(e);return[t,`${i.r}, ${i.g}, ${i.b}`]}));const x=new Map;var k=function(t){return x.get(t)||null},B={name:"suspicion",emoji:"๐คจ",description:"Paranoid watchfulness with surveillance scanning",visual:{glowColor:"#6B46C1",particleRate:4,minParticles:6,maxParticles:12,particleBehavior:"surveillance",particleSpeed:.2,breathRate:.6,breathDepth:.04,coreJitter:.02,blinkRate:1.1,blinkSpeed:1,particleColors:[{color:"#6B46C1",weight:30},{color:"#4A5568",weight:25},{color:"#8B4789",weight:20},{color:"#9F7AEA",weight:15},{color:"#2D3748",weight:10}],threatLevel:0,getGlowIntensity(){return.3+.7*this.threatLevel},getParticleSpeed(){return.2+.8*this.threatLevel},getGlowColor(){const t=this.threatLevel||0,e=Math.round(107+113*t),i=Math.round(70+-32*t),s=Math.round(193+-66*t),a=t=>t.toString(16).padStart(2,"0");return`#${a(e)}${a(i)}${a(s)}`}},modifiers:{speed:.4,amplitude:.6,intensity:1.2,smoothness:.3,regularity:.2,focus:1.5,addWobble:!0},typicalGestures:["scan","twitch","peek","tilt","hold"],transitions:{duration:500,easing:"linear",priority:4},special:{coreSquint:.6,scanInterval:2e3,scanDuration:1200,scanAngle:60,twitchChance:.02,peekInterval:4e3,maxThreatDistance:300,alertThreshold:.7},"3d":{rotation:{type:"suspicious",speed:1,axes:[0,0,0],musicSync:!1},glow:{color:"#6B46C1",intensity:.85,pulse:{speed:.6,range:[.7,1]}},scale:{base:1,breathe:{enabled:!0,depth:.04,rate:.6}}},soulAnimation:{driftSpeed:.9,shimmerSpeed:1.8,turbulence:.4},rhythmModifiers:{windowMultiplier:.9,visualNoise:.3,inputDelay:0,tempoShift:0}},C={name:"calm",emoji:"๐",description:"Serene, peaceful state with gentle movements",visual:{glowColor:"#66D9CC",particleRate:6,minParticles:10,maxParticles:50,particleBehavior:"ascending",breathRate:.4,breathDepth:.12,coreJitter:!1,blinkRate:.8,blinkSpeed:1,particleColors:[{color:"#66D9CC",weight:35},{color:"#99E6D9",weight:25},{color:"#40BFB3",weight:20},{color:"#B3F2E6",weight:15},{color:"#339980",weight:5}]},modifiers:{speed:.5,amplitude:.3,intensity:.4,smoothness:2,regularity:1.5,addWeight:!1,floatHeight:.2,swayAmount:.15,duration:1.5},typicalGestures:["breathe","float","drift","idle"],transitions:{duration:800,easing:"easeInOutSine",priority:1},movement:{floatPattern:"sine_slow",floatPeriod:6e3,floatAmplitude:8,swayPattern:"gentle",swayPeriod:8e3,swayAmplitude:5,microMovements:!1},getCoreParams(t){const e=t.time||Date.now(),i=.5*Math.sin(6e-4*e)+.5;return{scaleX:1-.02*i,scaleY:1-.02*i,eyeOpenness:.85,eyeExpression:"serene",pupilOffset:{x:2*Math.sin(3e-4*e),y:1*Math.cos(4e-4*e)},glowPulse:.95+.05*i}},updateParticle(t,e){t.x+=.1*Math.sin(.001*t.life),t.y-=.02*e,t.opacity=.3*Math.sin(.002*t.life)+.2,t.size=t.baseSize*(1+.2*Math.sin(.001*t.life))},renderCore:(t,e,i,s)=>!1,"3d":{rotation:{type:"gentle",speed:.5,axes:[0,.3,0],musicSync:!0},glow:{color:"#66D9CC",intensity:.6,pulse:{speed:.4,range:[.5,.7]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.4}}},soulAnimation:{driftSpeed:.3,shimmerSpeed:.4,turbulence:.1},rhythmModifiers:{windowMultiplier:1.2,visualNoise:0,inputDelay:0,tempoShift:0}};const R=new Map,T={happy:"joy",peaceful:"calm",curious:"surprise",frustrated:"anger",sad:"sadness",excitement:"excited"};function P(t){const e=T[t]||t,i=R.get(e);return i||(k(e)||null)}function O(t){const e=P(t);if(!e)return P("neutral").visual;if(!e.visual)return{};const{visual:i}=e,s={};for(const t in i)"function"!=typeof i[t]&&(s[t]=i[t]);return"function"==typeof i.getGlowIntensity&&(s.glowIntensity=i.getGlowIntensity()),"function"==typeof i.getParticleSpeed&&(s.particleSpeed=i.getParticleSpeed()),"function"==typeof i.getParticleRate&&(s.particleRate=i.getParticleRate()),"function"==typeof i.getGlowColor&&(s.glowColor=i.getGlowColor()),s}function A(t){const e=P(t);return e?e.modifiers:P("neutral").modifiers}function D(){return[...Array.from(R.keys()),...Array.from(x.keys())]}function z(t){const e=T[t]||t;return R.has(e)||null!==k(e)}function E(t,e){const i=P(t),s=P(e);return i&&s?s.transitions&&s.transitions[t]?s.transitions[t]:{duration:1e3,easing:"ease-in-out",gesture:s.transitions?.defaultGesture||null}:{duration:1e3,easing:"ease-in-out"}}function I(t){const e=P(t);return e?.rhythmModifiers??{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0}}function j(t){if(!t||0===t.length)return{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0};if(1===t.length){const e=I(t[0].emotion),i=t[0].intensity;return{windowMultiplier:1+(e.windowMultiplier-1)*i,visualNoise:e.visualNoise*i,inputDelay:e.inputDelay*i,tempoShift:e.tempoShift*i}}let e=0;for(let i=1;i<t.length;i++)t[i].intensity>t[e].intensity&&(e=i);const i={windowMultiplier:0,visualNoise:0,inputDelay:0,tempoShift:0},s=t.filter((t,i)=>i!==e),a=s.length>0?.25/s.length:0,h=I(t[e].emotion),n=t[e].intensity;i.windowMultiplier+=.75*(1+(h.windowMultiplier-1)*n),i.visualNoise+=h.visualNoise*n*.75,i.inputDelay+=h.inputDelay*n*.75,i.tempoShift+=h.tempoShift*n*.75;for(const t of s){const e=I(t.emotion),s=t.intensity;i.windowMultiplier+=(1+(e.windowMultiplier-1)*s)*a,i.visualNoise+=e.visualNoise*s*a,i.inputDelay+=e.inputDelay*s*a,i.tempoShift+=e.tempoShift*s*a}return i}[{name:"neutral",emoji:"๐",description:"Calm, balanced emotional state",visual:{glowColor:"#00BCD4",particleRate:2,minParticles:8,maxParticles:10,particleBehavior:"ambient",breathRate:1,breathDepth:.08,coreJitter:!1,blinkRate:1,blinkSpeed:1,particleColors:[{color:"#00BCD4",weight:25},{color:"#00ACC1",weight:20},{color:"#26C6DA",weight:15},{color:"#B2EBF2",weight:15},{color:"#0097A7",weight:10},{color:"#80DEEA",weight:10},{color:"#E0F7FA",weight:5}]},modifiers:{speed:1,amplitude:1,intensity:1,smoothness:1,regularity:1},typicalGestures:["breathe","float","idle","blink"],transitions:{duration:500,easing:"easeInOut",priority:0},getCoreParams:t=>({scaleX:1,scaleY:1,eyeOpenness:1,eyeExpression:"neutral",pupilOffset:{x:0,y:0}}),renderCore:(t,e,i,s)=>!1,"3d":{rotation:{type:"gentle",speed:1,axes:[0,.3,0],musicSync:!1},glow:{color:"#00BCD4",intensity:.9,pulse:{speed:1,range:[.8,1]}},scale:{base:1,breathe:{enabled:!0,depth:.08,rate:1}}},soulAnimation:{driftSpeed:.5,shimmerSpeed:.5,turbulence:.2},rhythmModifiers:{windowMultiplier:1,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"joy",emoji:"๐",description:"Playful happiness and celebration",visual:{glowColor:"#FFEB3B",particleRate:8,minParticles:0,maxParticles:50,particleBehavior:"popcorn",breathRate:1.5,breathDepth:.1,coreJitter:!1,blinkRate:1.3,blinkSpeed:1.1,particleColors:[{color:"#FFEB3B",weight:25},{color:"#FFC107",weight:20},{color:"#FFFF00",weight:15},{color:"#FFD700",weight:15},{color:"#FFF59D",weight:10},{color:"#FF9800",weight:10},{color:"#FFFDE7",weight:5}]},modifiers:{speed:1.8,amplitude:1.9,intensity:1.1,smoothness:1,regularity:.9,addBounce:!0},typicalGestures:["bounce","spin","wave","expand","shake","float"],transitions:{duration:400,easing:"easeOutBack",priority:5,burstOnEntry:!0},getCoreParams:t=>({scaleX:1,scaleY:1,eyeOpenness:1,eyeExpression:"happy",pupilOffset:{x:0,y:-.1},sparkle:!0}),"3d":{rotation:{type:"rhythmic",speed:1.8,axes:[0,.3,0],musicSync:!0},glow:{color:"#FFEB3B",intensity:1.6,pulse:{speed:1.5,range:[1.2,1.8]}},scale:{base:1,breathe:{enabled:!0,depth:.1,rate:1.5}}},soulAnimation:{driftSpeed:1.2,shimmerSpeed:1.5,turbulence:.3},rhythmModifiers:{windowMultiplier:1.3,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"sadness",emoji:"๐ข",description:"Deep melancholic sorrow",visual:{glowColor:"#4169E1",particleRate:6,minParticles:0,maxParticles:50,particleBehavior:"falling",breathRate:.6,breathDepth:.12,coreJitter:!1,blinkRate:.6,blinkSpeed:.8,particleColors:[{color:"#4169E1",weight:25},{color:"#1E90FF",weight:20},{color:"#6495ED",weight:15},{color:"#B0C4DE",weight:15},{color:"#191970",weight:10},{color:"#87CEEB",weight:10},{color:"#2F4F4F",weight:5}]},modifiers:{speed:.7,amplitude:.6,intensity:.8,smoothness:1.3,regularity:1.1,addGravity:!0},typicalGestures:["droop","sway","contract","drift","sink"],transitions:{duration:800,easing:"easeInOut",priority:3},"3d":{rotation:{type:"gentle",speed:.7,axes:[0,.2,0],musicSync:!1},glow:{color:"#4169E1",intensity:.65,pulse:{speed:.6,range:[.5,.8]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.6}}},soulAnimation:{driftSpeed:.2,shimmerSpeed:.3,turbulence:.1},rhythmModifiers:{windowMultiplier:1,visualNoise:0,inputDelay:45,tempoShift:0}},{name:"anger",emoji:"๐ ",description:"Intense rage and aggression",visual:{glowColor:"#DC143C",particleRate:8,minParticles:8,maxParticles:50,particleBehavior:"aggressive",breathRate:2.2,breathDepth:.15,coreJitter:!0,blinkRate:1.6,blinkSpeed:1.3,particleColors:[{color:"#DC143C",weight:25},{color:"#FF0000",weight:20},{color:"#B22222",weight:15},{color:"#FF4500",weight:15},{color:"#8B0000",weight:10},{color:"#FF6347",weight:10},{color:"#660000",weight:5}]},modifiers:{speed:1.5,amplitude:1.4,intensity:1.3,smoothness:.3,regularity:.7,addShake:!0},typicalGestures:["shake","vibrate","expand","pulse","flicker","strike"],transitions:{duration:300,easing:"easeOutExpo",priority:8,shakeOnEntry:!0},special:{screenShake:!0,particleTrails:"fire",glowPulse:!0,temperatureEffect:"hot"},"3d":{rotation:{type:"unstable",speed:1.5,axes:[0,.3,0],shake:{amplitude:.02,frequency:7},eruption:{enabled:!0,interval:3e3,speedMultiplier:3.5,duration:400},musicSync:!1},glow:{color:"#DC143C",intensity:1.8,pulse:{speed:2.2,range:[.8,2]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:2.2}}},soulAnimation:{driftSpeed:2,shimmerSpeed:.8,turbulence:.8},rhythmModifiers:{windowMultiplier:.75,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"fear",emoji:"๐จ",description:"Anxious state with fleeing particles",visual:{glowColor:"#8A2BE2",particleRate:8,minParticles:8,maxParticles:50,particleBehavior:"scattering",breathRate:2.5,breathDepth:.06,coreJitter:!0,blinkRate:1.7,blinkSpeed:1.4,particleColors:[{color:"#8A2BE2",weight:25},{color:"#4B0082",weight:20},{color:"#9400D3",weight:15},{color:"#6B46C1",weight:15},{color:"#9932CC",weight:10},{color:"#E6E6FA",weight:8},{color:"#301934",weight:7}]},modifiers:{speed:1.4,amplitude:.8,intensity:1.2,smoothness:.5,regularity:.5,addJitter:!0},typicalGestures:["shake","vibrate","contract","flicker","retreat"],transitions:{duration:400,easing:"easeOut",priority:7},"3d":{rotation:{type:"unstable",speed:1.4,axes:[0,.3,0],shake:{amplitude:.015,frequency:3.5},musicSync:!1},glow:{color:"#8A2BE2",intensity:.9,pulse:{speed:2.5,range:[.6,1.2]}},scale:{base:1,breathe:{enabled:!0,depth:.06,rate:2.5}}},soulAnimation:{driftSpeed:1.8,shimmerSpeed:2.5,turbulence:.6},rhythmModifiers:{windowMultiplier:1,visualNoise:.6,inputDelay:0,tempoShift:0}},{name:"surprise",emoji:"๐ฒ",description:"Sudden shock with explosive particles",visual:{glowColor:"#FFD700",particleRate:5,minParticles:0,maxParticles:15,particleBehavior:"burst",breathRate:.3,breathDepth:.18,coreJitter:!1,blinkRate:1.4,blinkSpeed:1.2,particleColors:[{color:"#FFD700",weight:25},{color:"#FFA500",weight:20},{color:"#FFFF00",weight:15},{color:"#FF6347",weight:15},{color:"#FFE4B5",weight:10},{color:"#FF4500",weight:10},{color:"#FFFACD",weight:5}]},modifiers:{speed:1.6,amplitude:1.5,intensity:1.4,smoothness:.7,regularity:.8,addPop:!0},typicalGestures:["expand","bounce","flash","pulse","pop"],transitions:{duration:200,easing:"easeOutBack",priority:6},"3d":{rotation:{type:"unstable",speed:1.6,axes:[0,.45,0],shake:{amplitude:.01,frequency:3},musicSync:!1},glow:{color:"#FFD700",intensity:1.8,pulse:{speed:.3,range:[1,2.2]}},scale:{base:1,breathe:{enabled:!0,depth:.18,rate:.3}}},soulAnimation:{driftSpeed:1.5,shimmerSpeed:2,turbulence:.5},rhythmModifiers:{windowMultiplier:2,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"disgust",emoji:"๐คข",description:"Revulsion with repelling particles",visual:{glowColor:"#9ACD32",particleRate:4,minParticles:5,maxParticles:12,particleBehavior:"repelling",breathRate:.7,breathDepth:.04,coreJitter:!1,blinkRate:.9,blinkSpeed:.9,particleColors:[{color:"#9ACD32",weight:25},{color:"#ADFF2F",weight:20},{color:"#7FFF00",weight:15},{color:"#BDB76B",weight:15},{color:"#6B8E23",weight:10},{color:"#CCFF00",weight:8},{color:"#556B2F",weight:7}]},modifiers:{speed:.9,amplitude:.7,intensity:.9,smoothness:.8,regularity:1,addRecoil:!0},typicalGestures:["contract","shake","recoil","wobble"],transitions:{duration:600,easing:"easeIn",priority:4},"3d":{rotation:{type:"gentle",speed:.9,axes:[0,.25,0],musicSync:!1},glow:{color:"#9ACD32",intensity:1,pulse:{speed:.7,range:[.7,1.2]}},scale:{base:1,breathe:{enabled:!0,depth:.04,rate:.7}}},soulAnimation:{driftSpeed:.4,shimmerSpeed:.6,turbulence:.35},rhythmModifiers:{windowMultiplier:.85,visualNoise:.2,inputDelay:0,tempoShift:0}},{name:"love",emoji:"๐",description:"Warm affection with orbiting particles",visual:{glowColor:"#FF1493",particleRate:6,minParticles:15,maxParticles:50,particleBehavior:"orbiting",breathRate:.75,breathDepth:.15,coreJitter:!1,blinkRate:1.2,blinkSpeed:1,particleColors:[{color:"#FF1493",weight:30},{color:"#FF69B4",weight:25},{color:"#FF007F",weight:15},{color:"#FFB6C1",weight:10},{color:"#FF45A0",weight:10},{color:"#E91E63",weight:5},{color:"#FFC0CB",weight:5}]},modifiers:{speed:.9,amplitude:1.1,intensity:1.2,smoothness:1.4,regularity:1.2,addWarmth:!0},typicalGestures:["pulse","sway","orbit","glow","breathe","float"],transitions:{duration:700,easing:"easeInOut",priority:5},"3d":{rotation:{type:"gentle",speed:.9,axes:[0,.28,0],musicSync:!0},glow:{color:"#FF1493",intensity:1.8,pulse:{speed:.75,range:[1.3,2]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:.75}}},soulAnimation:{driftSpeed:.8,shimmerSpeed:1.2,turbulence:.2},rhythmModifiers:{windowMultiplier:1.15,visualNoise:0,inputDelay:0,tempoShift:0}},B,{name:"excited",emoji:"๐คฉ",description:"High energy with rapid particles",visual:{glowColor:"#FF6B35",particleRate:8,minParticles:10,maxParticles:50,particleBehavior:"burst",breathRate:2,breathDepth:.14,coreJitter:!0,blinkRate:1.5,blinkSpeed:1.2,particleColors:[{color:"#FF6B35",weight:25},{color:"#FF1744",weight:20},{color:"#FFC107",weight:15},{color:"#FF9100",weight:15},{color:"#FFEB3B",weight:10},{color:"#FF5722",weight:10},{color:"#FFF59D",weight:5}]},modifiers:{speed:1.4,amplitude:1.3,intensity:1.3,smoothness:.8,regularity:.7,addVibration:!0},typicalGestures:["bounce","spin","vibrate","expand","shake","pulse"],transitions:{duration:300,easing:"easeOutElastic",priority:6},"3d":{rotation:{type:"unstable",speed:1.4,axes:[0,.4,0],shake:{amplitude:.01,frequency:4},musicSync:!1},glow:{color:"#FF6B35",intensity:1.5,pulse:{speed:2,range:[1,1.8]}},scale:{base:1,breathe:{enabled:!0,depth:.14,rate:2}}},soulAnimation:{driftSpeed:1.5,shimmerSpeed:2,turbulence:.5},rhythmModifiers:{windowMultiplier:1.2,visualNoise:.1,inputDelay:0,tempoShift:0}},{name:"resting",emoji:"๐ด",description:"Deep relaxation with slow drift",visual:{glowColor:"#9370DB",particleRate:1,minParticles:3,maxParticles:5,particleBehavior:"resting",breathRate:.8,breathDepth:.12,coreJitter:!1,blinkRate:.4,blinkSpeed:.7,particleColors:[{color:"#9370DB",weight:30},{color:"#A591C4",weight:20},{color:"#B366FF",weight:20},{color:"#B8A1E6",weight:15},{color:"#674D9B",weight:15}]},modifiers:{speed:.5,amplitude:.4,intensity:.5,smoothness:1.4,regularity:.9,addWeight:!0},typicalGestures:["breathe","drift","sway","float"],transitions:{duration:1e3,easing:"easeInOut",priority:2},"3d":{rotation:{type:"gentle",speed:.5,axes:[0,.15,0],musicSync:!1},glow:{color:"#9370DB",intensity:.8,pulse:{speed:.8,range:[.6,1]}},scale:{base:1,breathe:{enabled:!0,depth:.12,rate:.8}}},soulAnimation:{driftSpeed:.15,shimmerSpeed:.1,turbulence:.05},rhythmModifiers:{windowMultiplier:1.1,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"euphoria",emoji:"๐",description:"Radiant hope and new beginnings",visual:{glowColor:"#FFB6C1",particleRate:6,minParticles:15,maxParticles:30,particleBehavior:"radiant",breathRate:1.3,breathDepth:.25,coreJitter:!1,blinkRate:1.4,blinkSpeed:1.1,particleColors:[{color:"#FFB6C1",weight:20},{color:"#FFD700",weight:18},{color:"#87CEEB",weight:15},{color:"#DDA0DD",weight:15},{color:"#98FB98",weight:12},{color:"#FFA07A",weight:10},{color:"#E6E6FA",weight:8},{color:"#FFFFFF",weight:2}]},modifiers:{speed:1.4,amplitude:1.5,intensity:1.6,smoothness:1.3,regularity:.8,addWarmth:!0,addLift:!0},typicalGestures:["expand","radiate","pulse","glow","float","bloom"],transitions:{duration:600,easing:"easeOutExpo",priority:8},"3d":{rotation:{type:"rhythmic",speed:1.4,axes:[0,.35,0],musicSync:!0},glow:{color:"#FFB6C1",intensity:1.2,pulse:{speed:1.3,range:[.9,1.5]}},scale:{base:1,breathe:{enabled:!0,depth:.25,rate:1.3}}},soulAnimation:{driftSpeed:1.8,shimmerSpeed:2.5,turbulence:.7},rhythmModifiers:{windowMultiplier:1.5,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"focused",emoji:"๐ฏ",description:"Intense concentration with directed flow",visual:{glowColor:"#00CED1",particleRate:4,minParticles:5,maxParticles:12,particleBehavior:"directed",breathRate:1.2,breathDepth:.08,coreJitter:!0,blinkRate:.7,blinkSpeed:1,particleColors:[{color:"#00CED1",weight:30},{color:"#4A9FA0",weight:20},{color:"#00FFFF",weight:20},{color:"#5FE5E7",weight:15},{color:"#006B6D",weight:15}],eyeOpenness:.7,microAdjustments:!0},modifiers:{speed:1,amplitude:.9,intensity:1.1,smoothness:1.1,regularity:1.2,addPrecision:!0},typicalGestures:["track","lock","scan","pulse","vibrate"],transitions:{duration:400,easing:"easeIn",priority:5},getCoreParams:t=>({scaleX:1.1,scaleY:.7,eyeOpenness:.7,eyeExpression:"focused",pupilOffset:{x:0,y:0},microAdjustments:!0}),"3d":{rotation:{type:"still",speed:.5,axes:[0,.1,0],musicSync:!1},glow:{color:"#00CED1",intensity:1.2,pulse:{speed:1.2,range:[1,1.3]}},scale:{base:1,breathe:{enabled:!0,depth:.08,rate:1.2}}},soulAnimation:{driftSpeed:.6,shimmerSpeed:.2,turbulence:.1},rhythmModifiers:{windowMultiplier:.85,visualNoise:0,inputDelay:0,tempoShift:0}},{name:"glitch",emoji:"๐",description:"Surprised sadness with rainbow colors and glitch wiggle",visual:{primaryColor:"#FF6B9D",glowColor:"#4169E1",glowIntensity:1.2,particleRate:5,minParticles:5,maxParticles:15,particleBehavior:"burst",particleSpeed:1,breathRate:.4,breathDepth:.15,coreJitter:!1,coreSize:1,eyeOpenness:.8,blinkRate:1.3,blinkSpeed:1.2,particleColors:[{color:"#FF0080",weight:18},{color:"#00FF80",weight:18},{color:"#8000FF",weight:18},{color:"#FF8000",weight:15},{color:"#0080FF",weight:15},{color:"#FFFF00",weight:10},{color:"#FF6B9D",weight:6}],particleGlitchWiggle:!0,glitchWiggleIntensity:.3,glitchWiggleFrequency:.1},modifiers:{speed:1.1,amplitude:1,intensity:1.1,smoothness:.8,regularity:.7,focus:.6},typicalGestures:["bounce","sway","pulse","drift","flash"],transitions:{duration:300,easing:"easeInOut",priority:5},"3d":{rotation:{type:"unstable",speed:1.1,axes:[0,.35,0],shake:{amplitude:.02,frequency:5},musicSync:!1},glow:{color:"#FF6B9D",intensity:1.2,pulse:{speed:.4,range:[.8,1.6]}},scale:{base:1,breathe:{enabled:!0,depth:.15,rate:.4}}},rhythmModifiers:{windowMultiplier:1,visualNoise:.8,inputDelay:20,tempoShift:0}},C].forEach(t=>{t&&t.name&&R.set(t.name,t)});const $=new class{constructor(){this.emotionCache=new Map,this.visualParamsCache=new Map,this.modifiersCache=new Map,this.transitionCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1,this.loadStartTime=0,this.initialize()}initialize(){this.loadStartTime=performance.now();try{const t=D();t.forEach(t=>{this.cacheEmotion(t)}),this.cacheCommonTransitions(t),this.isInitialized=!0,this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.emotionCache.size}catch(t){this.isInitialized=!1}}cacheEmotion(t){try{const e=P(t);e&&this.emotionCache.set(t,e);const i=O(t);this.visualParamsCache.set(t,i);const s=A(t);this.modifiersCache.set(t,s)}catch(t){}}cacheCommonTransitions(t){[["neutral","joy"],["neutral","sadness"],["neutral","anger"],["joy","sadness"],["sadness","joy"],["anger","calm"],["calm","anger"]].forEach(([e,i])=>{if(t.includes(e)&&t.includes(i))try{const t=E(e,i),s=`${e}->${i}`;this.transitionCache.set(s,t)}catch(t){}})}getEmotion(t){if(!this.isInitialized)return P(t);const e=this.emotionCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,P(t))}getVisualParams(t){if(!this.isInitialized)return O(t);const e=this.visualParamsCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,O(t))}getModifiers(t){if(!this.isInitialized)return A(t);const e=this.modifiersCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,A(t))}getTransitionParams(t,e){if(!this.isInitialized)return E(t,e);const i=`${t}->${e}`,s=this.transitionCache.get(i);return s?(this.stats.hits++,s):(this.stats.misses++,E(t,e))}hasEmotion(t){return this.emotionCache.has(t)}getStats(){const t=this.stats.hits+this.stats.misses,e=t>0?(this.stats.hits/t*100).toFixed(2):0;return{isInitialized:this.isInitialized,loadTime:this.stats.loadTime,cacheSize:this.stats.cacheSize,hits:this.stats.hits,misses:this.stats.misses,hitRate:`${e}%`,emotions:this.emotionCache.size,visualParams:this.visualParamsCache.size,modifiers:this.modifiersCache.size,transitions:this.transitionCache.size}}clear(){this.emotionCache.clear(),this.visualParamsCache.clear(),this.modifiersCache.clear(),this.transitionCache.clear(),this.isInitialized=!1,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0}}reinitialize(){this.clear(),this.initialize()}};class G{constructor(t){this.errorBoundary=t,this.state={emotion:"neutral",undertone:null,intensity:1,gesture:null,speaking:!1,audioLevel:0},this.slots=[],this.maxSlots=3,this.u=null,this.p=null,this.m=0,this.M=new Set(["anger","fear","sadness","disgust","suspicion"]),this.transitions={emotional:{current:"neutral",target:null,progress:0,duration:500,startTime:0,isActive:!1},intensity:{from:1,to:1,progress:1,duration:500,startTime:0,isActive:!1},undertone:{current:null,target:null,progress:0,duration:300,startTime:0,isActive:!1,currentWeight:0,targetWeight:0}},this.interpolationCache={lastUpdate:0,cacheInterval:100,cachedProperties:null,cachedRenderState:null},this.initializeEmotionalStates(),this.initializeUndertoneModifiers()}initializeEmotionalStates(){this.emotionalStates=this.loadEmotionalStatesFromCache()}loadEmotionalStatesFromCache(){const t={};return["neutral","joy","sadness","anger","fear","surprise","disgust","love","suspicion","excited","resting","euphoria","focused","glitch","calm"].forEach(e=>{const i=$.getVisualParams(e);i&&(t[e]={primaryColor:i.primaryColor||"#B0B0B0",glowIntensity:i.glowIntensity||.7,particleRate:i.particleRate||1,minParticles:i.minParticles||3,maxParticles:i.maxParticles||4,particleBehavior:i.particleBehavior||"ambient",coreSize:i.coreSize||1,breathRate:i.breathRate||1,breathDepth:i.breathDepth||.1})}),t}initializeUndertoneModifiers(){this.undertoneModifiers={nervous:{jitterAmount:.3,breathRateMultiplier:1.2,glowIntensityMultiplier:.9,particleRateMultiplier:1.1},confident:{coreSizeMultiplier:1.1,glowIntensityMultiplier:1.2,breathRateMultiplier:.9,particleRateMultiplier:1},tired:{breathRateMultiplier:.7,particleRateMultiplier:.5,glowIntensityMultiplier:.8,coreSizeMultiplier:.95},intense:{amplificationFactor:1.3},subdued:{dampeningFactor:.7}}}setEmotion(t,e=null,i=500){return this.errorBoundary.wrap(()=>{let s=null,a=1;if("string"==typeof e?s=e:e&&"object"==typeof e&&(s=e.undertone??null,i=e.duration??i,a=e.intensity??1),this.interpolationCache.cachedProperties=null,this.interpolationCache.cachedRenderState=null,!z(t)&&!{}.hasOwnProperty.call(this.emotionalStates,t)){const e=[...Object.keys(this.emotionalStates),...D()],i=[...new Set(e)];throw new Error(`Invalid emotion: ${t}. Valid emotions: ${i.join(", ")}`)}if(null!==s&&!{}.hasOwnProperty.call(this.undertoneModifiers,s))throw new Error(`Invalid undertone: ${s}. Valid undertones: ${Object.keys(this.undertoneModifiers).join(", ")}`);return a=Math.max(0,Math.min(1,a)),this.slots=[{emotion:t,intensity:a}],this.p=t,this.state.emotion===t&&this.state.undertone===s&&this.state.intensity===a||(this.state.emotion!==t&&(i>0?(this.transitions.emotional={current:this.state.emotion,target:t,progress:0,duration:Math.max(100,i),startTime:performance.now(),isActive:!0},void 0!==this.v&&(this.v=0)):this.transitions.emotional={current:t,target:null,progress:1,duration:0,startTime:performance.now(),isActive:!1},this.state.emotion=t),this.state.intensity!==a&&(this.transitions.intensity={from:this.state.intensity,to:a,progress:0,duration:Math.max(100,i),startTime:performance.now(),isActive:!0},this.state.intensity=a),this.state.undertone!==s&&(this.transitions.undertone={current:this.state.undertone,target:s,progress:0,duration:300,startTime:performance.now(),isActive:!0,currentWeight:this.state.undertone?1:0,targetWeight:s?1:0},this.state.undertone=s)),!0},"emotion-setting",!1)()}setEventCallback(t){this.u=t}S(t,e){this.u&&this.u(t,e)}F(){const t=this.getDominant(),e=t?t.emotion:null,i=this.p;e!==i&&(this.p=e,this.S("dominantChanged",{previous:i,current:e,intensity:t?t.intensity:0}))}setEmotionDampening(t){this.m=Math.max(0,Math.min(1,t))}getEmotionDampening(){return this.m}setNegativeEmotions(t){this.M=new Set(t)}pushEmotion(t,e=.5){return this.errorBoundary.wrap(()=>{if(!z(t)&&!{}.hasOwnProperty.call(this.emotionalStates,t))return!1;e=Math.max(0,Math.min(1,e)),this.interpolationCache.cachedProperties=null;const i=this.slots.find(e=>e.emotion===t);if(i){const s=i.intensity;i.intensity=Math.min(1,i.intensity+e),this.S("slotChanged",{emotion:t,intensity:i.intensity,action:"push"}),i.intensity>=1&&s<1&&this.S("emotionPeaked",{emotion:t,intensity:i.intensity})}else if(this.slots.length<this.maxSlots)this.slots.push({emotion:t,intensity:e}),this.S("slotChanged",{emotion:t,intensity:e,action:"push"}),e>=1&&this.S("emotionPeaked",{emotion:t,intensity:e});else{let i=0;for(let t=1;t<this.slots.length;t++)this.slots[t].intensity<this.slots[i].intensity&&(i=t);const s=this.slots[i];this.S("slotChanged",{emotion:s.emotion,intensity:0,action:"replaced"}),this.slots[i]={emotion:t,intensity:e},this.S("slotChanged",{emotion:t,intensity:e,action:"push"})}return this.k(),this.F(),!0},"push-emotion",!1)()}nudgeEmotion(t,e,i=1){e>0&&this.m>0&&this.M.has(t)&&(e*=1-this.m),this.interpolationCache.cachedProperties=null;const s=this.slots.find(e=>e.emotion===t);if(s){const a=s.intensity;s.intensity=Math.max(0,Math.min(i,s.intensity+e)),s.intensity<=0?(this.slots=this.slots.filter(t=>t!==s),this.S("slotChanged",{emotion:t,intensity:0,action:"removed"})):(this.S("slotChanged",{emotion:t,intensity:s.intensity,action:"nudge"}),s.intensity>=i&&a<i&&this.S("emotionPeaked",{emotion:t,intensity:s.intensity}))}else if(e>0)return void this.pushEmotion(t,Math.min(i,e));this.k(),this.F()}clearEmotions(){const t=this.slots.length>0;this.slots=[],this.interpolationCache.cachedProperties=null,this.state.emotion="neutral",this.state.intensity=1,t&&(this.S("slotChanged",{emotion:null,intensity:0,action:"cleared"}),this.p=null,this.S("dominantChanged",{previous:this.p,current:null,intensity:0}))}getSlots(){return this.slots}pruneEmptySlots(){const t=this.slots.length,e=this.slots.filter(t=>t.intensity<=0);if(this.slots=this.slots.filter(t=>t.intensity>0),this.slots.length!==t){this.interpolationCache.cachedProperties=null;for(const t of e)this.S("emotionDecayed",{emotion:t.emotion,intensity:0,removed:!0});this.k(),this.F()}}getDominant(){return this.slots.length?this.slots.reduce((t,e)=>e.intensity>t.intensity?e:t):null}getUndercurrents(){const t=this.getDominant();return t?this.slots.filter(e=>e!==t):[]}getEmotionalState(){const t=this.getDominant();return{dominant:t?{...t}:null,undercurrents:this.getUndercurrents().map(t=>({...t})),slots:this.slots.map(t=>({...t}))}}getCurrentRhythmModifiers(){return this.slots.length>0?j(this.slots):j([{emotion:this.state.emotion,intensity:this.state.intensity}])}k(){const t=this.getDominant();t?(this.state.emotion!==t.emotion&&(this.transitions.emotional={current:this.state.emotion,target:t.emotion,progress:0,duration:300,startTime:performance.now(),isActive:!0},this.state.emotion=t.emotion),this.state.intensity=t.intensity):(this.state.emotion="neutral",this.state.intensity=1)}applyUndertone(t,e){if(!e||!{}.hasOwnProperty.call(this.undertoneModifiers,e))return{...t};const i=this.undertoneModifiers[e],s={...t};if(void 0!==i.glowIntensityMultiplier&&(s.glowIntensity*=i.glowIntensityMultiplier),void 0!==i.breathRateMultiplier&&(s.breathRate*=i.breathRateMultiplier),void 0!==i.particleRateMultiplier&&(s.particleRate=Math.round(s.particleRate*i.particleRateMultiplier)),void 0!==i.coreSizeMultiplier&&(s.coreSize*=i.coreSizeMultiplier),void 0!==i.amplificationFactor){const t=i.amplificationFactor;s.glowIntensity*=t,s.breathRate*=t,s.particleRate=Math.round(s.particleRate*t),s.coreSize*=t}if(void 0!==i.dampeningFactor){const t=i.dampeningFactor;s.glowIntensity*=t,s.breathRate*=t,s.particleRate=Math.round(s.particleRate*t),s.coreSize*=t}return void 0!==i.jitterAmount&&(s.jitterAmount=i.jitterAmount),s}update(t){this.errorBoundary.wrap(()=>{this.transitions.emotional.isActive&&this.updateEmotionalTransition(t),this.transitions.intensity.isActive&&this.updateIntensityTransition(t),this.transitions.undertone.isActive&&this.updateUndertoneTransition(t)},"state-machine-update")()}updateUndertoneTransition(t){const e=this.transitions.undertone,i=performance.now()-e.startTime,s=Math.min(i/e.duration,1),a=g(s);e.current&&e.target?(e.currentWeight=1-a,e.targetWeight=a):e.current&&!e.target?(e.currentWeight=1-a,e.targetWeight=0):!e.current&&e.target&&(e.currentWeight=0,e.targetWeight=a),e.progress=s,s>=1&&(e.isActive=!1,e.current=e.target,e.currentWeight=e.target?1:0,e.targetWeight=0)}updateIntensityTransition(t){const e=this.transitions.intensity,i=performance.now()-e.startTime;e.progress=Math.min(1,i/e.duration),e.progress>=1&&(e.isActive=!1,e.from=e.to,e.progress=1)}getEffectiveIntensity(){const t=this.transitions.intensity;if(!t.isActive)return this.state.intensity;const e=g(t.progress);return t.from+(t.to-t.from)*e}updateEmotionalTransition(t){const e=this.transitions.emotional;let i;void 0!==this.v?(this.v+=t,i=this.v):i=performance.now()-e.startTime,e.progress=Math.min(1,i/e.duration),e.progress>=1&&(e.isActive=!1,e.current=e.target,e.target=null,e.progress=1)}getCurrentEmotionalProperties(){return this.errorBoundary.wrap(()=>{const t=performance.now();if(this.interpolationCache.cachedProperties&&t-this.interpolationCache.lastUpdate<this.interpolationCache.cacheInterval)return this.interpolationCache.cachedProperties;let e;if(this.slots.length>1)e=this.B();else{const t=this.transitions.emotional;e=t.isActive&&t.target?this.interpolateEmotionalProperties(t.current,t.target,t.progress):{...this.emotionalStates[this.state.emotion]||this.emotionalStates.neutral};const i=this.getEffectiveIntensity();i<1&&(e.glowIntensity=this.C(.7,e.glowIntensity,i),e.particleRate=Math.round(this.C(1,e.particleRate,i)),e.breathRate=this.C(1,e.breathRate,i),e.breathDepth=e.breathDepth*i,e.coreSize=this.C(1,e.coreSize,i))}return e=this.applyUndertone(e,this.state.undertone),this.interpolationCache.cachedProperties=e,this.interpolationCache.lastUpdate=t,e},"emotional-properties",()=>this.emotionalStates.neutral)()}B(){const t=this.getDominant(),e=this.getUndercurrents(),i=this.emotionalStates[t.emotion]||this.emotionalStates.neutral,s={...i},a=t.intensity;s.glowIntensity=.75*this.C(.7,i.glowIntensity,a),s.particleRate=i.particleRate*a*.75,s.breathRate=.75*this.C(1,i.breathRate,a),s.breathDepth=i.breathDepth*a*.75,s.coreSize=.75*this.C(1,i.coreSize,a);const h=e.length>0?.25/e.length:0;for(const t of e){const e=this.emotionalStates[t.emotion]||this.emotionalStates.neutral,i=t.intensity;s.glowIntensity+=this.C(.7,e.glowIntensity,i)*h,s.particleRate+=e.particleRate*i*h,s.breathRate+=this.C(1,e.breathRate,i)*h,s.breathDepth+=e.breathDepth*i*h,s.coreSize+=this.C(1,e.coreSize,i)*h}if(s.particleRate=Math.round(s.particleRate),e.length>0){const t=this.slots.reduce((t,e)=>t+e.intensity,0);let a=i.primaryColor;for(const i of e){const e=this.emotionalStates[i.emotion]||this.emotionalStates.neutral,s=i.intensity/t;a=o(a,e.primaryColor,s)}s.primaryColor=a}return s.particleBehavior=i.particleBehavior,s}C(t,e,i){return t+(e-t)*i}interpolateEmotionalProperties(t,e,i){const s=this.emotionalStates[t]||this.emotionalStates.neutral,a=this.emotionalStates[e]||this.emotionalStates.neutral,h=F(i,0,1,"easeOutCubic");return{primaryColor:o(s.primaryColor,a.primaryColor,h),glowIntensity:s.glowIntensity+(a.glowIntensity-s.glowIntensity)*h,particleRate:Math.round(s.particleRate+(a.particleRate-s.particleRate)*h),coreSize:s.coreSize+(a.coreSize-s.coreSize)*h,breathRate:s.breathRate+(a.breathRate-s.breathRate)*h,breathDepth:s.breathDepth+(a.breathDepth-s.breathDepth)*h,particleBehavior:h>.5?a.particleBehavior:s.particleBehavior}}getCurrentState(){return{emotion:this.state.emotion,undertone:this.state.undertone,intensity:this.state.intensity,isTransitioning:this.transitions.emotional.isActive,transitionProgress:this.transitions.emotional.progress,properties:this.getCurrentEmotionalProperties()}}applyUndertoneModifier(t){return this.errorBoundary.wrap(()=>{if(null!==t&&!{}.hasOwnProperty.call(this.undertoneModifiers,t))throw new Error(`Invalid undertone: ${t}. Valid undertones: ${Object.keys(this.undertoneModifiers).join(", ")}`);return this.state.undertone=t,!0},"undertone-application",!1)()}clearUndertone(){this.state.undertone=null}getUndertoneModifier(t){return this.errorBoundary.wrap(()=>{if(this.renderer&&this.renderer.undertoneModifiers&&this.renderer.undertoneModifiers[t])return{...this.renderer.undertoneModifiers[t]};if(!t||!{}.hasOwnProperty.call(this.undertoneModifiers,t))return null;const e={...this.undertoneModifiers[t]};return e.glowRadiusMult||(e.glowRadiusMult=1),e},"undertone-retrieval",null)()}getWeightedUndertoneModifiers(){const t=this.transitions.undertone;if(!t.isActive){if(this.state.undertone){const t=this.getUndertoneModifier(this.state.undertone);if(t)return{...t,weight:1,type:this.state.undertone}}return null}if(t.target){const e=this.getUndertoneModifier(t.target);if(e)return{...e,weight:t.targetWeight,type:t.target}}if(t.current&&t.currentWeight>0){const e=this.getUndertoneModifier(t.current);if(e)return{...e,weight:t.currentWeight,type:t.current}}return null}reset(t=500){this.slots=[],this.setEmotion("neutral",null,t)}isValidEmotion(t){return{}.hasOwnProperty.call(this.emotionalStates,t)}isValidUndertone(t){return null===t||{}.hasOwnProperty.call(this.undertoneModifiers,t)}getAvailableEmotions(){return Object.keys(this.emotionalStates)}getAvailableUndertones(){return Object.keys(this.undertoneModifiers)}isTransitioning(){return this.transitions.emotional.isActive}getTransitionProgress(){return this.transitions.emotional.isActive?this.transitions.emotional.progress:1}completeTransition(){this.transitions.emotional.isActive&&(this.transitions.emotional.progress=1,this.transitions.emotional.isActive=!1,this.transitions.emotional.current=this.transitions.emotional.target,this.transitions.emotional.target=null)}interpolateProperty(t,e,i,s="easeOutCubic"){return t+(e-t)*F(i,0,1,s)}serialize(){return{version:1,emotion:this.state.emotion,undertone:this.state.undertone,intensity:this.state.intensity,slots:this.slots.map(t=>({...t})),dampening:this.m,negativeEmotions:[...this.M]}}deserialize(t){t&&1===t.version&&(this.slots=(t.slots||[]).map(t=>({emotion:t.emotion,intensity:t.intensity})),this.m=t.dampening??0,t.negativeEmotions&&(this.M=new Set(t.negativeEmotions)),this.state.emotion=t.emotion||"neutral",this.state.undertone=t.undertone||null,this.state.intensity=t.intensity??1,this.p=t.emotion||null,this.transitions.emotional.isActive=!1,this.transitions.intensity.isActive=!1,this.transitions.undertone.isActive=!1,this.interpolationCache.cachedProperties=null)}enableSimulatedTime(t=!0){t?this.v=0:delete this.v}}const q=16.67,X=3e4,Y=new class{constructor(){this.enabled=!1}registerConfig(){}getConfig(){return null}initialize(){}update(){}destroy(){}};function H(t){if(!t||0===t.length)return"#FFFFFF";let e=0,i=0;const s=[];for(const a of t)"string"==typeof a?(s.push({color:a,weight:null}),i++):a&&"object"==typeof a&&a.color&&(s.push({color:a.color,weight:a.weight||null}),a.weight?e+=a.weight:i++);const a=Math.max(0,100-e),h=i>0?a/i:0,n=[];let r=0;for(const t of s)r+=null!==t.weight?t.weight:h,n.push({color:t.color,threshold:r});const o=Math.random()*r;for(const t of n)if(o<=t.threshold)return t.color;return s[s.length-1].color}var _={name:"ambient",emoji:"โ๏ธ",description:"Gentle upward drift like smoke",initialize:function(t){t.vx=0,t.vy=-.04-.02*Math.random(),t.lifeDecay=.002,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={upwardSpeed:5e-4,waviness:0,friction:.998}},update:function(t,e,i,s){const a=t.behaviorData;t.vy*=Math.pow(a.friction,e),t.vy-=a.upwardSpeed*e,t.vx=0}};const L=2*Math.PI;var W={name:"orbiting",emoji:"๐",description:"Romantic firefly dance around the orb",initialize:function(t){t.lifeDecay=.001+.002*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.isSparkle="#FFE4E1"===t.color||"#FFCCCB"===t.color||"#FFC0CB"===t.color;const e=40*(t.scaleFactor||1)*(1.3+.9*Math.random());t.blinkPhase=Math.random()*L,t.blinkSpeed=.3+1.2*Math.random(),t.blinkIntensity=.6+.4*Math.random(),t.fadePhase=Math.random()*L,t.fadeSpeed=.1+.3*Math.random(),t.minOpacity=.2+.2*Math.random(),t.maxOpacity=.8+.2*Math.random(),t.isSparkle&&(t.blinkSpeed*=2,t.blinkIntensity=1,t.minOpacity=0,t.maxOpacity=1),t.behaviorData={angle:Math.random()*L,radius:e,baseRadius:e,angularVelocity:8e-4+.0017*Math.random(),swayAmount:3+7*Math.random(),swaySpeed:.2+.5*Math.random(),floatOffset:Math.random()*L,floatSpeed:.3+.7*Math.random(),floatAmount:2+6*Math.random(),twinklePhase:Math.random()*L,twinkleSpeed:2+3*Math.random()}},update:function(t,e,i,s){const a=t.behaviorData;a.angle+=a.angularVelocity*e;const h=Math.sin(a.angle*a.swaySpeed)*a.swayAmount,n=6*Math.sin(1.5*a.angle),r=(a.radius||a.baseRadius)+n+.2*h,o=i+Math.cos(a.angle)*r,l=s+Math.sin(a.angle)*r;a.floatOffset+=a.floatSpeed*e*.001;const c=Math.sin(a.floatOffset)*a.floatAmount;t.vx=.1*(o-t.x),t.vy=.1*(l+c-t.y),t.fadePhase+=t.fadeSpeed*e*.001;const u=.5*Math.sin(t.fadePhase)+.5,p=t.minOpacity+(t.maxOpacity-t.minOpacity)*u;let d;t.blinkPhase+=t.blinkSpeed*e*.002,t.isSparkle?(a.twinklePhase+=a.twinkleSpeed*e*.001,d=.7*Math.pow(Math.sin(a.twinklePhase),16)+.2*Math.sin(5*t.blinkPhase)+.1):d=.4*Math.sin(t.blinkPhase)+.3*Math.sin(3*t.blinkPhase)+.2*Math.sin(7*t.blinkPhase)+.1*Math.sin(11*t.blinkPhase);const f=.5*(d+1),m=.2+f*t.blinkIntensity*.8;t.opacity=t.baseOpacity*p*m,t.isSparkle?t.size=t.baseSize*(.5+1*f):t.size=t.baseSize*(.8+.3*f),t.isSparkle&&(t.tempColor=f>.85?"#FFFFFF":t.color)}},U={name:"rising",emoji:"๐",description:"Buoyant upward movement like balloons",initialize:function(t){t.vx=.02*(Math.random()-.5),t.vy=-.05-.03*Math.random(),t.lifeDecay=.002,t.baseOpacity=.7+.3*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={buoyancy:.001,driftAmount:.005}},update:function(t,e,i,s){const a=t.behaviorData;t.vy-=a.buoyancy*e,t.vx+=(Math.random()-.5)*a.driftAmount*e,t.vx*=Math.pow(.995,e),t.vy*=Math.pow(.998,e)}};function V(t){t.fallingData||(t.fallingData={originalX:t.x,originalY:t.y,originalOpacity:t.opacity??t.life??1,wobblePhase:Math.random()*Math.PI*2,wobbleSpeed:.3+.4*Math.random(),fallProgress:0}),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors));const e=Math.random(),i=Math.random(),s=e*Math.PI*2,a=2*i-1,h=Math.sqrt(1-a*a);t.behaviorData={fallSpeed:8,fallDistance:400,wobbleAmount:1.5,fallingDir:{x:h*Math.cos(s),y:a,z:h*Math.sin(s)},orbitDistanceRatio:.7+.4*Math.random()}}var N={name:"falling",emoji:"๐ง",description:"Heavy downward drift like tears",initialize:V,update:function(t,e,i,s){const a=t.behaviorData;let h=t.fallingData;h||(V(t),h=t.fallingData),h.fallProgress+=.02*e;const n=Math.min(h.fallProgress,1),r=a.fallDistance*n;h.wobblePhase+=h.wobbleSpeed*e*.1;const o=Math.sin(h.wobblePhase)*a.wobbleAmount;if(t.x=h.originalX+o,t.y=h.originalY+r,t.vx=.3*o,t.vy=10*a.fallSpeed,n>.6){const e=(n-.6)/.4;t.opacity=h.originalOpacity*(1-e),void 0!==t.life&&(t.life=h.originalOpacity*(1-e))}}};var Q={name:"popcorn",emoji:"๐ฟ",description:"Spontaneous popping with gravity and bounces",initialize:function(t){if(t.vx=.1*(Math.random()-.5),t.vy=.1*(Math.random()-.5),t.lifeDecay=.008+.012*Math.random(),t.emotionColors&&t.emotionColors.length>0)t.color=H(t.emotionColors);else{const e=["#FFFFFF","#FFFACD","#FFF8DC","#FFFFE0","#FAFAD2"];t.color=H(e)}t.size=Math.random()<.3?(8+4*Math.random())*t.scaleFactor*t.particleSizeMultiplier:(2+4*Math.random())*t.scaleFactor*t.particleSizeMultiplier,t.baseSize=t.size,t.hasGlow=Math.random()<.2,t.glowSizeMultiplier=t.hasGlow?1.2:0,t.behaviorData={popDelay:2e3*Math.random(),hasPopped:!1,popStrength:3+5*Math.random(),gravity:.098,bounceDamping:.7,bounceCount:0,maxBounces:2+Math.floor(2*Math.random()),spinRate:10*(Math.random()-.5),lifetime:0}},update:function(t,e,i,s){const a=t.behaviorData;if(a.lifetime+=16.67*e,!a.hasPopped&&a.lifetime>a.popDelay){a.hasPopped=!0;const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*a.popStrength*1.5,t.vy=Math.sin(e)*a.popStrength-.3,t.size=1.25*t.baseSize}if(a.hasPopped){t.vy+=a.gravity*e;const i=s+100*t.scaleFactor;t.y>i&&a.bounceCount<a.maxBounces&&(t.y=i,t.vy=-Math.abs(t.vy)*a.bounceDamping,t.vx*=.9,a.bounceCount++,t.size=t.baseSize*(1.5-.1*a.bounceCount)),a.bounceCount>=a.maxBounces&&(t.lifeDecay=.03+.02*Math.random(),t.size*=.95),Math.sqrt(t.vx*t.vx+t.vy*t.vy)<.5&&(t.lifeDecay*=1.5)}}},J={name:"burst",emoji:"๐ฅ",description:"Explosive expansion from center",initialize:function(t){const e="suspicion"===t.emotion,i="surprise"===t.emotion,s="glitch"===t.emotion,a=Math.random()*L,h=e?1+.8*Math.random():i?7+5*Math.random():s?2+1.5*Math.random():3.5+2.5*Math.random();t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h,t.lifeDecay=e?.01:i?.006+.008*Math.random():s?.012:.015,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),e&&(t.size=(6+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.opacity=1,t.baseOpacity=t.opacity),t.behaviorData={isSuspicion:e,isSurprise:i,isGlitch:s,age:0,fadeStart:e?.3:.2,glitchPhase:Math.random()*Math.PI*2,glitchIntensity:s?.3:0,glitchFrequency:s?.1:0}},update:function(t,e,i,s){const a=t.behaviorData;if(a.isSurprise)if(a.age+=.016*e,a.age<.15){const i=.98;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}else if(a.age<.25){const i=.85;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}else{const i=.99;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e),t.vx+=.01*(Math.random()-.5)*e,t.vy+=.01*(Math.random()-.5)*e}else{const i=a.isSuspicion?.99:a.isGlitch?.97:.95;t.vx*=Math.pow(i,e),t.vy*=Math.pow(i,e)}if(a.isSuspicion){const i=.001*Date.now();t.vx+=.01*Math.sin(2*i+t.id)*e}if(a.isGlitch){a.age+=.016*e,a.glitchPhase+=a.glitchFrequency*e;const i=Math.sin(a.glitchPhase)*a.glitchIntensity*e,s=Math.cos(1.3*a.glitchPhase)*a.glitchIntensity*e;if(t.vx+=i,t.vy+=s,Math.random()<.02){const e=Math.random()*Math.PI*2,i=.5+.5*Math.random();t.vx+=Math.cos(e)*i,t.vy+=Math.sin(e)*i}}}},Z={name:"aggressive",emoji:"โก",description:"Sharp, chaotic movement with violent bursts",initialize:function(t){const e=Math.random()*L,i=1.5+2*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.015,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={acceleration:.05,jitter:.3,speedDecay:.95}},update:function(t,e,i,s){const a=t.behaviorData;if(t.vx+=(Math.random()-.5)*a.jitter*e,t.vy+=(Math.random()-.5)*a.jitter*e,t.vx*=Math.pow(a.speedDecay,e),t.vy*=Math.pow(a.speedDecay,e),Math.random()<Math.min(.05*e,.5)){const e=Math.random()*L;t.vx+=Math.cos(e)*a.acceleration,t.vy+=Math.sin(e)*a.acceleration}}},K={name:"scattering",emoji:"๐จ",description:"Particles flee from center in panic",initialize:function(t){t.vx=0,t.vy=0,t.lifeDecay=.008,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={fleeSpeed:2,panicFactor:1.2,initialized:!1}},update:function(t,e,i,s){const a=t.behaviorData;if(!a.initialized){const e=t.x-i,h=t.y-s,n=Math.sqrt(e*e+h*h);if(n>0)t.vx=e/n*a.fleeSpeed,t.vy=h/n*a.fleeSpeed;else{const e=Math.random()*L;t.vx=Math.cos(e)*a.fleeSpeed,t.vy=Math.sin(e)*a.fleeSpeed}a.initialized=!0}const h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);r>0&&(t.vx+=h/r*a.panicFactor*.01*e,t.vy+=n/r*a.panicFactor*.01*e),t.vx+=.1*(Math.random()-.5)*e,t.vy+=.1*(Math.random()-.5)*e,t.vx*=Math.pow(.98,e),t.vy*=Math.pow(.98,e)}},tt={name:"repelling",emoji:"๐ซ",description:"Particles pushed away from center, maintaining distance",initialize:function(t){t.vx=0,t.vy=0,t.lifeDecay=.01,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={repelStrength:.8,minDistance:50,initialized:!1}},update:function(t,e,i,s){const a=t.behaviorData,h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(!a.initialized||r<a.minDistance){if(r>0){const i=a.repelStrength/Math.max(r,5);t.vx+=h/r*i*e,t.vy+=n/r*i*e}a.initialized=!0}t.vx*=Math.pow(.99,e),t.vy*=Math.pow(.99,e)}},et={name:"connecting",emoji:"๐",description:"Chaotic movement with center attraction for social states",initialize:function(t){const e=Math.random()*L,i=2+5*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.012,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={attractionForce:.008,chaosFactor:1,friction:.95}},update:function(t,e,i,s){const a=t.behaviorData;t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e);const h=(i-t.x)*a.attractionForce,n=(s-t.y)*a.attractionForce,r=(Math.random()-.5)*a.chaosFactor,o=(Math.random()-.5)*a.chaosFactor;t.vx+=h+r,t.vy+=n+o}},it={name:"resting",emoji:"๐ด",description:"Ultra-slow vertical drift for deep rest states",initialize:function(t){t.vx=0,t.vy=-.01,t.lifeDecay=.001,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={upwardSpeed:2e-5,friction:.999}},update:function(t,e,i,s){const a=t.behaviorData;t.vy*=Math.pow(a.friction,e),t.vy-=a.upwardSpeed*e,t.vx=0}},st={name:"radiant",emoji:"โ๏ธ",description:"Particles radiate outward like sunbeams",initialize:function(t){const e=Math.random()*L,i=.8+.4*Math.random();if(t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.006,t.emotionColors&&t.emotionColors.length>0)t.color=H(t.emotionColors);else{const e=["#FFD700","#FFB347","#FFA500","#FF69B4"];t.color=H(e)}t.hasGlow=Math.random()<.7,t.glowSizeMultiplier=t.hasGlow?1.5+.5*Math.random():0,t.behaviorData={radialSpeed:.02,shimmer:Math.random()*L,shimmerSpeed:.1,friction:.99}},update:function(t,e,i,s){const a=t.behaviorData,h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(r>0){const i=h/r,s=n/r;t.vx+=i*a.radialSpeed*e,t.vy+=s*a.radialSpeed*e}a.shimmer+=a.shimmerSpeed*e;const o=Math.sin(a.shimmer);t.size=t.baseSize*(1+.2*o),t.opacity=t.baseOpacity*(1+.3*o),t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e)}};function at(t){t.vx=.02*(Math.random()-.5),t.vy=-.03-.02*Math.random(),t.lifeDecay=8e-4,t.size=(6+6*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1)*1.33,t.baseSize=t.size,t.baseOpacity=.2+.2*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={ascensionSpeed:3e-4,waveFactor:.5,waveFrequency:.001,friction:.998,fadeStartDistance:100}}var ht={name:"ascending",emoji:"๐ง",description:"Slow steady upward float like incense smoke",initialize:at,update:function(t,e,i,s){const a=t.behaviorData;if(!a)return void at(t);t.vx*=Math.pow(a.friction,e),t.vy*=Math.pow(a.friction,e),t.vy-=a.ascensionSpeed*e;const h=Math.sin(t.age*a.waveFrequency*1e3)*a.waveFactor;t.vx+=.001*h*e,void 0===t.initialY&&(t.initialY=t.y);const n=t.initialY-t.y;if(n>a.fadeStartDistance){const e=(n-a.fadeStartDistance)/100,i=Math.max(0,1-e);t.baseOpacity*=.995,i<.5&&(t.lifeDecay*=1.02)}Math.abs(t.vx)>.05&&(t.vx*=Math.pow(.95,e)),t.vy<-.1&&(t.vy=-.1)}},nt={name:"erratic",emoji:"๐ฐ",description:"Nervous jittery movement for anxious states",initialize:function(t){const e=Math.random()*L,i=.1+.15*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.004,t.size=(2+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.baseOpacity=.4+.3*Math.random(),t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={jitterStrength:.02,directionChangeRate:.1,speedVariation:.3,spinRate:.05+.1*Math.random()}},update:function(t,e){const i=t.behaviorData;if(t.vx+=(Math.random()-.5)*i.jitterStrength*e,t.vy+=(Math.random()-.5)*i.jitterStrength*e,Math.random()<Math.min(i.directionChangeRate*e,.5)){const e=Math.random()*L,i=Math.sqrt(t.vx*t.vx+t.vy*t.vy);t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i}const s=1+(Math.random()-.5)*i.speedVariation*e;t.vx*=s,t.vy*=s;const a=t.age*i.spinRate*1e3;t.size=t.baseSize*(1+.2*Math.sin(a)),t.opacity=t.baseOpacity*(.8+.4*Math.random()),t.vx*=Math.pow(.98,e),t.vy*=Math.pow(.98,e);const h=Math.sqrt(t.vx*t.vx+t.vy*t.vy);h>.5&&(t.vx=t.vx/h*.5,t.vy=t.vy/h*.5)}},rt={name:"cautious",emoji:"๐คจ",description:"Slow careful movement with watchful pauses",initialize:function(t){const e=Math.random()*L,i=.02+.03*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,t.lifeDecay=.001,t.life=1,t.size=(4+4*Math.random())*(t.scaleFactor||1)*(t.particleSizeMultiplier||1),t.baseSize=t.size,t.baseOpacity=.8+.2*Math.random(),t.opacity=t.baseOpacity,t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorData={pauseTimer:2*Math.random(),pauseDuration:.5+.5*Math.random(),moveDuration:1+.5*Math.random(),isMoving:Math.random()>.5,moveTimer:0,originalVx:t.vx,originalVy:t.vy,watchRadius:50+30*Math.random()}},update:function(t,e,i,s){const a=t.behaviorData;if(a.moveTimer+=e,a.isMoving)a.moveTimer>a.moveDuration?(a.isMoving=!1,a.moveTimer=0,t.vx=0,t.vy=0):(t.vx=a.originalVx,t.vy=a.originalVy);else if(a.moveTimer>a.pauseDuration){a.isMoving=!0,a.moveTimer=0;const e=Math.random()*L,i=.02+.03*Math.random();t.vx=Math.cos(e)*i,t.vy=Math.sin(e)*i,a.originalVx=t.vx,a.originalVy=t.vy}const h=t.x-i,n=t.y-s,r=Math.sqrt(h*h+n*n);if(r>a.watchRadius){const i=.02;t.vx-=h/r*i*e,t.vy-=n/r*i*e}t.vx*=Math.pow(.995,e),t.vy*=Math.pow(.995,e),a.isMoving?t.opacity=t.baseOpacity:t.opacity=t.baseOpacity*(.9+.1*Math.sin(5*t.age))}},ot={name:"surveillance",emoji:"๐๏ธ",description:"Searchlight scanning with paranoid watchfulness",initialize(t,e){t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorState={scanAngle:Math.random()*Math.PI-Math.PI/2,scanDirection:Math.random()<.5?1:-1,scanSpeed:.3+.2*Math.random(),scanRange:Math.PI/3+Math.random()*Math.PI/4,scanCenter:Math.random()*Math.PI*2,pauseTimer:0,pauseDuration:500+500*Math.random(),mode:"scanning",modeTimer:0,nextModeChange:2e3+3e3*Math.random(),dartTarget:{x:0,y:0},dartSpeed:0,patrolRadius:150+100*Math.random(),patrolAngle:Math.random()*Math.PI*2,alertLevel:0,lastPosition:{x:t.x,y:t.y}};const i=Math.random();i<.7?t.behaviorState.primaryRole="scanner":i<.9?(t.behaviorState.primaryRole="patroller",t.behaviorState.mode="patrolling"):(t.behaviorState.primaryRole="watcher",t.behaviorState.mode="frozen")},update(t,e,i){const s=t.behaviorState;if(s){switch(s.modeTimer+=16*e,s.modeTimer>s.nextModeChange&&(this.changeMode(t,s,i),s.modeTimer=0,s.nextModeChange=2e3+4e3*Math.random()),s.mode){case"scanning":this.updateScanning(t,e,s,i);break;case"darting":this.updateDarting(t,e,s,i);break;case"frozen":this.updateFrozen(t,e,s,i);break;case"patrolling":this.updatePatrolling(t,e,s,i)}t.vy+=.05*e,t.x+=t.vx*e,t.y+=t.vy*e,s.lastPosition.x=t.x,s.lastPosition.y=t.y}},updateScanning(t,e,i,s){i.pauseTimer>0?(i.pauseTimer-=16*e,t.vx*=.9,t.vy*=.9):(i.scanAngle+=i.scanDirection*i.scanSpeed*e*.02,Math.abs(i.scanAngle)>i.scanRange/2&&(i.scanDirection*=-1,i.pauseTimer=i.pauseDuration,i.scanAngle=Math.sign(i.scanAngle)*i.scanRange/2));const a=i.scanCenter+i.scanAngle,h=.8+.5*i.alertLevel;t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h*.3},updateDarting(t,e,i,s){const a=i.dartTarget.x-t.x,h=i.dartTarget.y-t.y,n=Math.sqrt(a*a+h*h);n>5?(t.vx=a/n*i.dartSpeed,t.vy=h/n*i.dartSpeed):(i.mode="scanning",i.modeTimer=0)},updateFrozen(t,e,i,s){t.vx*=.95,t.vy*=.95,Math.random()<.01&&(t.vx+=.5*(Math.random()-.5),t.vy+=.5*(Math.random()-.5))},updatePatrolling(t,e,i,s){i.patrolAngle+=.01*e;const a=s.corePosition?.x??s.canvasWidth/2,h=s.corePosition?.y??s.canvasHeight/2,n=a+Math.cos(i.patrolAngle)*i.patrolRadius,r=h+Math.sin(i.patrolAngle)*i.patrolRadius,o=n-t.x,l=r-t.y;t.vx=.02*o,t.vy=.02*l},changeMode(t,e,i){const s=Math.random(),a=i?.corePosition?.x??(i?.canvasWidth/2||t.x),h=i?.corePosition?.y??(i?.canvasHeight/2||t.y);"scanner"===e.primaryRole?s<.1?(e.mode="darting",e.dartTarget={x:a+200*(Math.random()-.5),y:h+200*(Math.random()-.5)},e.dartSpeed=3+2*Math.random()):e.mode=s<.2?"frozen":"scanning":"patroller"===e.primaryRole?e.mode=s<.1?"frozen":"patrolling":e.mode=s<.3?"scanning":"frozen"}},lt={name:"glitchy",emoji:"โก",description:"Digital glitch with stuttering orbits and corruption",rhythm:{enabled:!0,glitchTiming:{mode:"subdivision",subdivision:"sixteenth",probability:.3,intensityOnBeat:2,intensityOffBeat:.5},stutterSync:{mode:"pattern",patterns:{dubstep:{freezeOnDrop:!0,dropDuration:100},breakbeat:{randomFreeze:.1,duration:50}}},orbitRhythm:{baseSpeed:"tempo",wobbleSync:"eighth",beatAcceleration:1.5,barReset:!0},rgbSync:{enabled:!0,amount:"intensity",direction:"beat",maxSplit:10},noiseRhythm:{trigger:"accent",duration:50,intensity:"drop"}},initialize(t,e,i,s){t.emotionColors&&t.emotionColors.length>0&&(t.color=H(t.emotionColors)),t.behaviorState={orbitAngle:Math.random()*Math.PI*2,orbitRadius:300+400*Math.random(),orbitSpeed:.01+.02*Math.random(),glitchTimer:0,nextGlitch:500*Math.random()+100,isGlitching:!1,glitchDuration:0,glitchOffset:{x:0,y:0},stutterTimer:0,nextStutter:200*Math.random()+50,isFrozen:!1,frozenPosition:{x:0,y:0},frozenVelocity:{x:0,y:0},hasGhost:Math.random()<.3,ghostOffset:20*Math.random()+10,ghostAngle:Math.random()*Math.PI*2,rgbSplit:Math.random()<.4,rgbPhase:Math.random()*Math.PI*2,noiseLevel:0,noiseBurst:!1,beatPhase:Math.random()*Math.PI*2,beatFrequency:.05+.03*Math.random(),dropIntensity:0},t.lifeDecay=.0015,t.hasGlow=!0,t.glowSizeMultiplier=3+2*Math.random()},update(t,e,i,s){const a=t.behaviorState;if(!a)return;a.glitchTimer+=16*e,a.stutterTimer+=16*e,a.stutterTimer>a.nextStutter&&(a.isFrozen?(a.isFrozen=!1,a.stutterTimer=0,a.nextStutter=100+300*Math.random(),Math.random()<.3&&(t.x+=60*(Math.random()-.5),t.y+=60*(Math.random()-.5))):(a.isFrozen=!0,a.frozenPosition={x:t.x,y:t.y},a.frozenVelocity={x:t.vx,y:t.vy},a.stutterTimer=0,a.nextStutter=20+40*Math.random())),a.glitchTimer>a.nextGlitch&&!a.isGlitching&&(a.isGlitching=!0,a.glitchDuration=50+100*Math.random(),a.glitchOffset={x:80*(Math.random()-.5),y:80*(Math.random()-.5)},a.glitchTimer=0,Math.random()<.5&&t.emotionColors&&(t.color=H(t.emotionColors))),a.isGlitching&&a.glitchTimer>a.glitchDuration&&(a.isGlitching=!1,a.glitchTimer=0,a.nextGlitch=200+800*Math.random(),a.glitchOffset={x:0,y:0}),a.beatPhase+=a.beatFrequency*e;const h=.5*Math.sin(a.beatPhase)+.5;if(a.beatPhase%(4*Math.PI)<.5*Math.PI?a.dropIntensity=Math.min(1,a.dropIntensity+.1*e):a.dropIntensity=Math.max(0,a.dropIntensity-.05*e),a.isFrozen)t.vx=.5*(Math.random()-.5),t.vy=.5*(Math.random()-.5);else{a.orbitAngle+=a.orbitSpeed*e*(1+.5*h);const n=a.orbitRadius*(1+.3*a.dropIntensity*Math.sin(4*a.beatPhase));let r=i+Math.cos(a.orbitAngle)*n,o=s+Math.sin(a.orbitAngle)*n*.6;if(a.isGlitching&&(r+=a.glitchOffset.x*Math.random()*.8,o+=a.glitchOffset.y*Math.random()*.8),a.rgbSplit){const t=3*(1+a.dropIntensity);r+=Math.sin(a.rgbPhase)*t,o+=Math.cos(a.rgbPhase)*t,a.rgbPhase+=.1*e}a.dropIntensity>.8&&Math.random()<.1&&(r+=30*(Math.random()-.5),o+=30*(Math.random()-.5));const l=a.isGlitching?.02:.03;t.vx=(r-t.x)*l,t.vy=(o-t.y)*l,t.vx+=(Math.random()-.5)*h*2,t.vy+=(Math.random()-.5)*h*2}t.x+=t.vx*e,t.y+=t.vy*e,Math.random()<.02&&(t.opacity=.1+.9*Math.random()),t.size=t.baseSize*(1+.3*h+.5*a.dropIntensity)}},ct={name:"spaz",description:"Ultra-aggressive particles with explosive spread and chaotic motion",initialize(t,e,i,s){t.x=i,t.y=s,t.life=1,t.size=3+4*Math.random();const a=Math.random()*Math.PI*2,h=200+300*Math.random();t.vx=Math.cos(a)*h,t.vy=Math.sin(a)*h,t.behaviorState={explosionPhase:0,explosionTimer:0,explosionDuration:1e3+2e3*Math.random(),chaosTimer:0,nextChaosChange:100+200*Math.random(),chaosAngle:a,chaosSpeed:50+100*Math.random(),spazIntensity:.8+.4*Math.random(),zigzagPattern:Math.random()<.5,spiralPattern:Math.random()<.3,teleportChance:.02,sizePulse:!0,sizePulseSpeed:.1+.05*Math.random(),sizePulsePhase:Math.random()*Math.PI*2,colorShift:Math.random()<.3,colorShiftSpeed:.05+.03*Math.random()},t.lifeDecay=8e-4,t.hasGlow=!0,t.glowSizeMultiplier=4+3*Math.random(),t.glowIntensity=1.5+.5*Math.random()},update(t,e,i,s){const a=t.behaviorState;if(a.explosionTimer+=e,a.chaosTimer+=e,0===a.explosionPhase&&a.explosionTimer<500)t.vx*=.98,t.vy*=.98,Math.random()<.1&&(t.vx+=100*(Math.random()-.5),t.vy+=100*(Math.random()-.5));else if(0===a.explosionPhase&&a.explosionTimer>=500)a.explosionPhase=1,a.chaosAngle=Math.random()*Math.PI*2,a.chaosSpeed=30+70*Math.random();else if(1===a.explosionPhase){a.chaosTimer>=a.nextChaosChange&&(a.chaosAngle=Math.random()*Math.PI*2,a.chaosSpeed=20+80*Math.random(),a.nextChaosChange=50+150*Math.random(),a.chaosTimer=0);const e=Math.cos(a.chaosAngle)*a.chaosSpeed,i=Math.sin(a.chaosAngle)*a.chaosSpeed;if(t.vx=.7*t.vx+.3*e,t.vy=.7*t.vy+.3*i,a.zigzagPattern){const e=.01*a.chaosTimer;t.vx+=20*Math.sin(e),t.vy+=20*Math.cos(e)}if(a.spiralPattern){const e=.005*a.chaosTimer,i=50+30*Math.sin(.003*a.chaosTimer);t.vx+=Math.cos(e)*i*.1,t.vy+=Math.sin(e)*i*.1}}if(Math.random()<a.teleportChance){const e=Math.random()*Math.PI*2,a=200+400*Math.random();t.x=i+Math.cos(e)*a,t.y=s+Math.sin(e)*a,t.vx=200*(Math.random()-.5),t.vy=200*(Math.random()-.5)}if(t.x+=t.vx*(e/1e3),t.y+=t.vy*(e/1e3),a.sizePulse){a.sizePulsePhase+=a.sizePulseSpeed*e;const i=1+.5*Math.sin(a.sizePulsePhase);t.size=(3+4*Math.random())*i}a.colorShift&&(a.colorShiftPhase=(a.colorShiftPhase||0)+a.colorShiftSpeed*e),t.vx*=.995,t.vy*=.995,t.life-=t.lifeDecay*e,(t.life<=0||Math.abs(t.x-i)>2e3||Math.abs(t.y-s)>2e3)&&(t.life=0)},getSpawnPosition(t,e){const i=Math.random()*Math.PI*2,s=100+200*Math.random();return{x:t+Math.cos(i)*s,y:e+Math.sin(i)*s}},getVisualProperties:()=>({glowColor:"#FF00AA",glowIntensity:2,particleColors:[{color:"#FF00AA",weight:30},{color:"#00FFAA",weight:25},{color:"#FFAA00",weight:20},{color:"#AA00FF",weight:15},{color:"#00AAFF",weight:10}]})},ut={name:"directed",emoji:"๐ฏ",description:"Focused, straight-line movement toward target",config:{speed:3,acceleration:.15,focusStrength:.8,randomness:.1,edgeBuffer:50},initialize(t,e,i,s,a){const h=e-t.x,n=i-t.y,r=Math.sqrt(h*h+n*n);if(r>0)t.vx=h/r*this.config.speed,t.vy=n/r*this.config.speed;else{const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*this.config.speed,t.vy=Math.sin(e)*this.config.speed}t.targetX=e,t.targetY=i,t.directedPhase=0},update(t,e,i,s,a,h){t.directedPhase+=.05*e;const n=t.targetX-t.x,r=t.targetY-t.y,o=Math.sqrt(n*n+r*r);if(o>10){const i=n/o*this.config.speed,s=r/o*this.config.speed;t.vx+=(i-t.vx)*this.config.acceleration*e,t.vy+=(s-t.vy)*this.config.acceleration*e,t.vx+=(Math.random()-.5)*this.config.randomness,t.vy+=(Math.random()-.5)*this.config.randomness}else{const e=Math.random()*Math.PI*2,n=100+200*Math.random();t.targetX=i+Math.cos(e)*n,t.targetY=s+Math.sin(e)*n,t.targetX=Math.max(this.config.edgeBuffer,Math.min(a-this.config.edgeBuffer,t.targetX)),t.targetY=Math.max(this.config.edgeBuffer,Math.min(h-this.config.edgeBuffer,t.targetY))}t.x+=t.vx*e,t.y+=t.vy*e,(t.x<=0||t.x>=a)&&(t.vx*=-.8,t.x=Math.max(0,Math.min(a,t.x)),t.targetX=i+300*(Math.random()-.5)),(t.y<=0||t.y>=h)&&(t.vy*=-.8,t.y=Math.max(0,Math.min(h,t.y)),t.targetY=s+300*(Math.random()-.5))},visuals:{trailLength:"medium",opacity:.9,sizeMultiplier:1,blurAmount:.2}},pt={name:"fizzy",emoji:"๐ซง",description:"Bubbly, effervescent movement like carbonation",config:{baseRiseSpeed:2.5,wobbleAmplitude:30,wobbleFrequency:.15,popChance:.002,popForce:8,fizziness:.3,gravity:-.05},initialize(t,e,i,s,a){t.vx=2*(Math.random()-.5),t.vy=-this.config.baseRiseSpeed-2*Math.random(),t.wobblePhase=Math.random()*Math.PI*2,t.wobbleSpeed=this.config.wobbleFrequency*(.8+.4*Math.random()),t.bubbleSize=.5+.5*Math.random(),t.popTimer=0,t.isFizzing=!0},update(t,e,i,s,a,h){t.wobblePhase+=t.wobbleSpeed*e;const n=Math.sin(t.wobblePhase)*this.config.wobbleAmplitude;if(t.vx=.05*n+(Math.random()-.5)*this.config.fizziness,t.vy+=this.config.gravity*e,t.vy+=(Math.random()-.5)*this.config.fizziness,Math.random()<this.config.popChance){const e=Math.random()*Math.PI*2;t.vx=Math.cos(e)*this.config.popForce,t.vy=Math.sin(e)*this.config.popForce*.7,t.popTimer=1,t.bubbleSize=.3+.7*Math.random()}t.popTimer>0&&(t.popTimer-=.05*e,t.vx*=.95,t.vy*=.95),t.x+=t.vx*e,t.y+=t.vy*e,t.y<-50&&(t.y=h+50,t.x=i+300*(Math.random()-.5),t.vy=-this.config.baseRiseSpeed-2*Math.random(),t.bubbleSize=.5+.5*Math.random()),(t.x<=0||t.x>=a)&&(t.vx*=-.5,t.x=Math.max(0,Math.min(a,t.x))),t.y>h+50&&(t.y=h,t.vy=1.5*-this.config.baseRiseSpeed),t.size=t.baseSize*t.bubbleSize*(1+.1*Math.sin(2*t.wobblePhase))},visuals:{trailLength:"short",opacity:.6,sizeMultiplier:1.2,blurAmount:.5,sparkle:!0}};const dt=new Map;var ft=function(t){return dt.get(t)||null};const mt={};function Mt(t){return mt[t]?mt[t]:ft(t)||null}function gt(t,e){const i=Mt(e);return i&&i.initialize?(i.initialize(t),!0):"ambient"!==e&>(t,"ambient")}[_,ut,pt,W,U,N,Q,J,Z,K,tt,et,it,st,ht,nt,rt,ot,lt,ct].forEach(t=>{mt[t.name]=t}),"undefined"!=typeof window&&window.DEBUG_PARTICLES&&(window.ParticleBehaviors={registry:mt,list:function(){return[...Object.values(mt).map(t=>({name:t.name,emoji:t.emoji||"๐ฏ",description:t.description||"No description",type:"core"})),...Array.from(dt.keys()).map(t=>{const e=ft(t);return{name:e.name,emoji:e.emoji||"๐",description:e.description||"Plugin behavior",type:"plugin"}})]},get:Mt});const yt=new Map;var bt=function(t){return yt.get(t)||null},wt=function(){return Array.from(yt.keys())},vt={name:"breathe",emoji:"๐ซ",type:"blending",description:"Breathing rhythm with inhale and exhale",config:{musicalDuration:{musical:!0,bars:1,minBeats:2,maxBeats:16},phases:[{name:"inhale",beats:1.5},{name:"hold_in",beats:.5},{name:"exhale",beats:1.5},{name:"hold_out",beats:.5}],inhaleRadius:1.5,exhaleRadius:.3,breathRate:.3,spiralStrength:.002,scaleAmount:.25,glowAmount:.4,frequency:1,easing:"sine",strength:.8,particleMotion:{type:"breathe",strength:.8,inhaleRadius:1.5,exhaleRadius:.3}},rhythm:{enabled:!0,syncMode:"phrase",breathRateSync:{mode:"tempo",bpm:"auto",subdivision:"whole",curve:"sine"},radiusSync:{inhale:{onUpbeat:1.8,onDownbeat:1.4,curve:"ease-in"},exhale:{onUpbeat:.2,onDownbeat:.4,curve:"ease-out"}},durationSync:{mode:"phrases",phrases:2,hold:"fermata"},accentResponse:{enabled:!0,multiplier:1.5,type:"expansion"},patternOverrides:{ballad:{breathRateSync:{subdivision:"double-whole"},radiusSync:{inhale:{onUpbeat:2.2,onDownbeat:1.8},exhale:{onUpbeat:.1,onDownbeat:.2}}},uptempo:{breathRateSync:{subdivision:"half"},radiusSync:{inhale:{onUpbeat:1.4,onDownbeat:1.2},exhale:{onUpbeat:.3,onDownbeat:.4}}},ambient:{breathRateSync:{subdivision:"whole",curve:"ease"},radiusSync:{inhale:{onUpbeat:1.6,onDownbeat:1.6},exhale:{onUpbeat:.2,onDownbeat:.2}}}},dynamics:{forte:{radiusSync:{inhale:{multiplier:1.8},exhale:{multiplier:.5}},spiralStrength:.004,scaleAmount:.4},piano:{radiusSync:{inhale:{multiplier:1.2},exhale:{multiplier:.8}},spiralStrength:.001,scaleAmount:.1}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.breathe={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),phaseOffset:.2*Math.random()-.1}},apply(t,e,i,s,a,h){t.gestureData?.breathe||this.initialize(t,i,a,h);const n={...this.config,...i},r=(Math.sin(e*Math.PI*2*n.breathRate)+1)/2,o=100*(t.scaleFactor||1),l=n.inhaleRadius*o,c=n.exhaleRadius*o,u=c+(l-c)*r,p=t.x-a,d=t.y-h,f=Math.sqrt(p*p+d*d),m=u-f,M=.05*(i.strength||.8)*s;if(f>0){const e=p/f*m*M,a=d/f*m*M;t.vx+=e,t.vy+=a;const h=n.spiralStrength*s*(i.strength||1),o=-d/f,l=p/f;t.vx+=o*h*r,t.vy+=l*h*r}t.vx*=.98,t.vy*=.98},cleanup(t){t.gestureData?.breathe&&delete t.gestureData.breathe},"3d":{evaluate(t,e){const i=(e.config||{}).breathRate||.3,s=Math.sin(t*Math.PI*2*i);let a=1;if(t>.8){const e=(t-.8)/(1-.8);a=1-e*e*e}const h=.2*s*a;return{position:[0,.05*s*a,0],rotation:[0,0,0],scale:1+.35*s*a,glowIntensity:1+h,glowBoost:Math.max(0,2*h)}}}},St={name:"expand",emoji:"๐ซ",type:"blending",description:"Radial expansion from center",config:{duration:600,scaleAmount:3,scaleTarget:3,glowAmount:.5,easing:"back",strength:3,particleMotion:{type:"pulse",strength:3,direction:"outward",persist:!0}},rhythm:{enabled:!0,syncMode:"crescendo",strengthSync:{pianissimo:1.5,fortissimo:5,crescendo:"build",sforzando:"burst"},scaleTargetSync:{verse:2,chorus:4.5,climax:6,curve:"exponential"},durationSync:{mode:"phrases",build:1.2,release:.8,sustain:"hold"},accentResponse:{enabled:!0,multiplier:2.8,type:"strength"},patternOverrides:{orchestral:{strengthSync:{pianissimo:2,fortissimo:6.5,crescendo:"dramatic"},scaleTargetSync:{climax:8}},rock:{strengthSync:{pianissimo:1.8,fortissimo:5.5,curve:"power"},accentResponse:{multiplier:3.2}},ambient:{strengthSync:{pianissimo:1.2,fortissimo:3.5,crescendo:"organic"},durationSync:{build:1.8,release:1.2}},electronic:{strengthSync:{pianissimo:1.6,fortissimo:4.8,curve:"digital"},scaleTargetSync:{curve:"linear"}}},dynamics:{forte:{strengthSync:{pianissimo:{multiplier:1.4},fortissimo:{multiplier:1.8}},scaleTargetSync:{multiplier:1.6},accentResponse:{multiplier:3.5}},piano:{strengthSync:{pianissimo:{multiplier:.8},fortissimo:{multiplier:1.2}},scaleTargetSync:{multiplier:.7},accentResponse:{multiplier:2}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.expand={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.expand?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.expand,r={...this.config,...i},o=r.strength||1,l=1+(r.scaleTarget-1)*e*o,c=n.baseRadius*l,u=a+Math.cos(n.angle)*c,p=h+Math.sin(n.angle)*c,d=u-t.x,f=p-t.y;t.vx+=.8*d*s,t.vy+=.8*f*s,t.vx*=.95,t.vy*=.95},cleanup(t){t.gestureData?.expand&&delete t.gestureData.expand},"3d":{evaluate(t,e){const i={...this.config,...e},s=i.strength||3;return{position:[0,0,0],rotation:[0,0,0],scale:1+t*(i.scaleAmount||3)*(s/3),glowIntensity:1+.25*t,glowBoost:.8*t}}}},Ft={name:"contract",emoji:"๐",type:"blending",description:"Radial contraction toward center",config:{duration:600,scaleAmount:.2,scaleTarget:.2,glowAmount:-.2,easing:"cubic",strength:2.5,particleMotion:{type:"pulse",strength:2.5,direction:"inward",persist:!0}},rhythm:{enabled:!0,syncMode:"tension",strengthSync:{onTension:4,onRelease:1.5,curve:"magnetic"},scaleTargetSync:{forte:.1,piano:.4,crescendo:"gradual",diminuendo:"ease"},durationSync:{mode:"phrases",shortPhrase:.8,longPhrase:1.5,hold:"sustain"},accentResponse:{enabled:!0,multiplier:2.2,type:"strength"},patternOverrides:{classical:{strengthSync:{onTension:3.5,onRelease:1.8},scaleTargetSync:{forte:.15,piano:.35}},metal:{strengthSync:{onTension:5,onRelease:2,curve:"sharp"},scaleTargetSync:{forte:.05,piano:.25}},ambient:{strengthSync:{onTension:2.8,onRelease:1.2,curve:"ease"},durationSync:{shortPhrase:1.2,longPhrase:2}},trap:{strengthSync:{onTension:4.5,onRelease:1,dropBeat:6},scaleTargetSync:{forte:.08,piano:.3}}},dynamics:{forte:{strengthSync:{onTension:{multiplier:1.8},onRelease:{multiplier:1.4}},scaleTargetSync:{multiplier:.6},accentResponse:{multiplier:2.8}},piano:{strengthSync:{onTension:{multiplier:.7},onRelease:{multiplier:.8}},scaleTargetSync:{multiplier:1.4},accentResponse:{multiplier:1.6}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.contract={startX:t.x,startY:t.y,angle:Math.atan2(h,a),baseRadius:Math.sqrt(a*a+h*h),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.contract?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.contract,r={...this.config,...i},o=r.strength||1,l=1-(1-r.scaleTarget)*e*o,c=n.baseRadius*l,u=a+Math.cos(n.angle)*c,p=h+Math.sin(n.angle)*c,d=u-t.x,f=p-t.y;t.vx+=.5*d*s,t.vy+=.5*f*s,t.vx*=.95,t.vy*=.95},cleanup(t){t.gestureData?.contract&&delete t.gestureData.contract},"3d":{evaluate(t,e){const i={...this.config,...e},s=i.strength||2.5,a=i.scaleTarget||.2,h=1-t*(1-a)*(s/2.5),n=1-.15*t;return{position:[0,0,0],rotation:[0,0,0],scale:Math.max(a,h),glowIntensity:n}}}},xt={name:"pulse",emoji:"๐",type:"blending",description:"Radial expansion and contraction from center",config:{duration:600,amplitude:30,frequency:1,holdPeak:.1,easing:"sine",scaleAmount:.2,glowAmount:.3,strength:.15,direction:"outward",particleMotion:{type:"pulse",strength:.15,direction:"outward",frequency:1}},rhythm:{enabled:!0,syncMode:"beat",amplitudeSync:{onBeat:1.6,offBeat:.8,curve:"pulse"},frequencySync:{mode:"locked",subdivision:"quarter"},durationSync:{mode:"beats",beats:1},accentResponse:{enabled:!0,multiplier:2},patternOverrides:{waltz:{amplitudeSync:{onBeat:2,offBeat:.5},durationSync:{beats:3}},swing:{amplitudeSync:{onBeat:1.8,offBeat:.6,curve:"ease"},frequencySync:{subdivision:"swing"}},dubstep:{amplitudeSync:{onBeat:1.2,dropBeat:4,curve:"pulse"}},breakbeat:{frequencySync:{mode:"random",range:[.5,2]},amplitudeSync:{onBeat:2.5,offBeat:.3}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s,n=Math.sqrt(a*a+h*h),r=Math.atan2(h,a);t.gestureData.pulse={baseDistance:n,angle:r,startX:t.x,startY:t.y,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.pulse?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.pulse,r={...this.config,...i},o=i.strength||1,l=this.easeInOutSine(e);let c,{frequency:u}=r,{amplitude:p}=r;i.rhythmModulation&&(p*=i.rhythmModulation.amplitudeMultiplier||1,p*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(u*=i.rhythmModulation.frequencyMultiplier));const d=l*u*2%2;c=r.holdPeak>0&&d>1-r.holdPeak&&d<1+r.holdPeak?1:Math.sin(l*Math.PI*2*u);const f=c*p*o*t.scaleFactor,m=n.baseDistance+f,M=a+Math.cos(n.angle)*m,g=h+Math.sin(n.angle)*m,y=.15*s;if(t.vx+=(M-t.x)*y*.1,t.vy+=(g-t.y)*y*.1,e>.9){const i=1-10*(e-.9);t.vx*=.9+.1*i,t.vy*=.9+.1*i}},cleanup(t){t.gestureData?.pulse&&delete t.gestureData.pulse},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i=e||{},s=i.frequency||1,a=i.strength||.15,h=i.scaleAmount||.2,n=i.glowAmount||.3,r=-(Math.cos(Math.PI*t)-1)/2,o=Math.sin(r*Math.PI*2*s);return{position:[0,0,0],rotation:[0,0,0],scale:1+o*h*a,glowIntensity:1+Math.max(-.3,Math.min(.3,o*n*a*2)),glowBoost:Math.max(0,.8*o)}}}},kt={name:"sway",type:"blending",emoji:"๐",description:"Gentle side-to-side swaying motion",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},amplitude:20,frequency:1,strength:.5},rhythm:{enabled:!0,syncMode:"bar",amplitudeSync:{onBeat:1.2,offBeat:.9,curve:"ease"},durationSync:{mode:"bars",bars:1},patternOverrides:{waltz:{durationSync:{bars:1},amplitudeSync:{onBeat:1.5,curve:"ease"}},swing:{amplitudeSync:{onBeat:1.3,offBeat:.7,curve:"bounce"}}}},apply(t,e,i,s,a,h){const n={...this.config,...i},r=n.amplitude||this.config.amplitude,o=n.frequency||this.config.frequency,l=n.strength||this.config.strength,c=Math.sin(e*Math.PI*2*o)*r;t.vx+=.01*c*s*l,t.vy+=.5*Math.cos(e*Math.PI*4)*s*l},cleanup(t){},"3d":{evaluate(t,e){const i={...this.config,...e};let s=i.amplitude||this.config.amplitude;const a=i.frequency||this.config.frequency,h=i.strength||this.config.strength;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1);const n=Math.sin(t*Math.PI*2*a),r=s*h*.3*.01,o=.15*n*h,l=.08*n*h;return{position:[n*r,.3*Math.cos(t*Math.PI*4)*r,Math.sin(t*Math.PI*a)*r*.5],rotation:[0,l,o],scale:1}}}},Bt={name:"float",type:"blending",emoji:"๐",description:"Gentle floating upward motion",config:{duration:2e3,musicalDuration:{musical:!0,bars:2},amplitude:80,wobbleAmount:20,strength:1},rhythm:{enabled:!0,syncMode:"beat",amplitudeSync:{onBeat:1.5,offBeat:.8,curve:"bounce"},wobbleSync:{subdivision:"eighth",intensity:.7},durationSync:{mode:"bars",bars:2},accentResponse:{enabled:!0,multiplier:1.3},patternOverrides:{waltz:{wobbleSync:{subdivision:"quarter",intensity:.9}},dubstep:{amplitudeSync:{onBeat:2,curve:"pulse"}}}},apply(t,e,i,s,a,h){t.gestureData||(t.gestureData={}),t.gestureData.float||(t.gestureData.float={originalSize:t.size,originalOpacity:t.opacity||1});const n={...this.config,...i};let r=n.amplitude||this.config.amplitude,o=n.wobbleAmount||this.config.wobbleAmount;const l=n.strength||this.config.strength;i.rhythmModulation&&(r*=i.rhythmModulation.amplitudeMultiplier||1,r*=i.rhythmModulation.accentMultiplier||1,o*=i.rhythmModulation.wobbleMultiplier||1);const c=Math.sin(e*Math.PI*4)*o;t.vy-=.01*r*s*l*(1-.5*e),t.vx+=.01*c*s*l,t.size=t.baseSize*(1+.1*e),t.opacity=1-.3*e},cleanup(t){t.gestureData?.float?(t.opacity=t.gestureData.float.originalOpacity,t.size=t.gestureData.float.originalSize,delete t.gestureData.float):(t.opacity=1,t.size=t.baseSize),t.vx*=.5,t.vy*=.5},"3d":{evaluate(t,e){const i={...this.config,...e};let s=i.amplitude||this.config.amplitude,a=i.wobbleAmount||this.config.wobbleAmount;const h=i.strength||this.config.strength;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1,a*=e.rhythmModulation.wobbleMultiplier||1);const n=Math.sin(t*Math.PI),r=s*n*h*.005,o=Math.sin(t*Math.PI*4)*a*.3*.005,l=Math.sin(t*Math.PI)*Math.PI*.5*h,c=Math.sin(t*Math.PI);return{position:[o,r,0],rotation:[c*Math.sin(t*Math.PI*2)*.1,l,c*Math.cos(t*Math.PI*3)*.08],scale:1+.1*n}}}},Ct={name:"shake",emoji:"๐ซจ",type:"blending",description:"Random jitter movement for vibration effects",config:{duration:400,amplitude:15,frequency:15,decay:.9,smoothing:.1,axes:"both",easing:"linear",strength:3,particleMotion:{type:"shake",strength:3,frequency:15,decay:!1}},rhythm:{enabled:!0,syncMode:"subdivision",amplitudeSync:{subdivision:"sixteenth",onBeat:2.5,offBeat:.7,curve:"pulse"},frequencySync:{mode:"tempo",baseFrequency:15,scaling:"linear"},durationSync:{mode:"beats",beats:2},patternOverrides:{breakbeat:{amplitudeSync:{onBeat:3,offBeat:.2},frequencySync:{mode:"random",range:[8,20]}},dubstep:{amplitudeSync:{subdivision:"eighth",onBeat:4,dropBeat:6,curve:"pulse"}},swing:{amplitudeSync:{onBeat:1.8,offBeat:1,curve:"ease"}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.shake={originalX:t.x,originalY:t.y,randomAngle:Math.random()*Math.PI*2,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.shake?.initialized||this.initialize(t,i);const n=t.gestureData.shake,r={...this.config,...i},o=r.strength||this.config.strength||1;let{amplitude:l}=r,{frequency:c}=r;i.rhythmModulation&&(l*=i.rhythmModulation.amplitudeMultiplier||1,l*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(c*=i.rhythmModulation.frequencyMultiplier));const u=r.decay?1-e:1,p=Math.sin(e*Math.PI*c)*l*u*o*t.scaleFactor,d=p*Math.cos(n.randomAngle),f=p*Math.sin(n.randomAngle);t.x=n.originalX+d,t.y=n.originalY+f},pseudoRandom(t){const e=1e4*Math.sin(t);return e-Math.floor(e)},cleanup(t){t.gestureData?.shake&&(t.x=t.gestureData.shake.originalX,t.y=t.gestureData.shake.originalY,delete t.gestureData.shake)},"3d":{evaluate(t,e){const i=e||{},s=.003*(i.amplitude||15),a=i.frequency||15,h=.5*(i.strength||1),n=i.decay?1-t:1,r=Math.sin(t*Math.PI*a)*s*n*h,o=Math.floor(t*a);return{position:[r*(1e4*Math.sin(o)%1-.5)*2,0,r*(1e4*Math.sin(1.3*o)%1-.5)*2],rotation:[0,0,r*(1e4*Math.sin(1.7*o)%1-.5)*.2],scale:1}}}},Rt={name:"wiggle",emoji:"ใฐ๏ธ",type:"additive",description:"Rapid side-to-side oscillation",config:{duration:600,musicalDuration:{musical:!0,beats:1},amplitude:15,frequency:6,strength:1,damping:.3,easing:"linear",particleMotion:{type:"wiggle",strength:1,amplitude:15,frequency:6}},rhythm:{enabled:!0,syncMode:"beat",frequencySync:{subdivision:"sixteenth",wigglePerBeat:4},amplitudeSync:{onBeat:1.5,offBeat:.8,curve:"bounce"},durationSync:{mode:"beats",beats:1}},apply(t,e,i,s,a,h,n){const r=(i.amplitude||this.config.amplitude)*a,o=i.frequency||this.config.frequency,l=1-s*(i.damping||this.config.damping),c=Math.sin(s*Math.PI*o)*r*l;t.vx+=.5*c;const u=Math.cos(s*Math.PI*o*2)*r*.1*l;t.vy+=.3*u},"3d":{evaluate(t,e){const i=e.config||{},s=e.strength||1,a=i.amplitude||15,h=Math.pow(1-t,.5),n=Math.sin(t*Math.PI*14)*h,r=Math.cos(t*Math.PI*14*.7)*h*.4,o=a/15*s,l=.15*n*s;return{cameraRelativePosition:[.08*n*o,.02*Math.abs(r)*o,0],cameraRelativeRotation:[0,0,l],scale:1+.05*Math.abs(n),glowIntensity:1+.2*Math.abs(n)}}}},Tt={name:"bounce",emoji:"โฌ๏ธ",type:"blending",description:"Vertical oscillation with smooth easing",config:{duration:800,musicalDuration:{musical:!0,beats:2},amplitude:30,frequency:2,axis:"vertical",damping:!0,easing:"sine",strength:.6,particleMotion:{type:"bounce",axis:"vertical",strength:.6,frequency:2}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",interruptible:!0,priority:3,blendable:!0,crossfadePoint:"anyBeat",amplitudeSync:{onBeat:1.8,offBeat:.6,curve:"bounce"},frequencySync:{mode:"tempo",multiplier:1},durationSync:{mode:"beats",beats:4},accentResponse:{enabled:!0,multiplier:1.5},patternOverrides:{waltz:{frequencySync:{multiplier:.75},durationSync:{beats:3}},swing:{amplitudeSync:{onBeat:2,offBeat:.4,curve:"ease"}},dubstep:{amplitudeSync:{onBeat:1.5,dropBeat:3,curve:"pulse"}},breakbeat:{frequencySync:{multiplier:1.5},amplitudeSync:{onBeat:2.2,offBeat:.3}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.bounce={startY:t.y,startX:t.x,startVx:t.vx,startVy:t.vy,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.bounce?.initialized||this.initialize(t,i);const n={...this.config,...i},r=n.strength||this.config.strength||1,o=this.easeInOutCubic(e);let{frequency:l}=n;const c=i.phase||0;let u=n.amplitude*r*t.scaleFactor;i.rhythmModulation&&(u*=i.rhythmModulation.amplitudeMultiplier||1,u*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(l*=i.rhythmModulation.frequencyMultiplier));const p=Math.sin((o+c)*Math.PI*2*l);if(n.damping&&e>.7&&(u*=1-(e-.7)/.3*.8),"vertical"===n.axis?(t.vy+=p*u*.01*s,e>.9&&(t.vx*=.98)):"horizontal"===n.axis&&(t.vx+=p*u*.01*s,e>.9&&(t.vy*=.98)),e>.9){const i=1-10*(e-.9);t.vx=t.vx*(.95+.05*i),t.vy=t.vy*(.95+.05*i)}},cleanup(t){t.gestureData?.bounce&&delete t.gestureData.bounce},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,"3d":{evaluate(t,e){const i=e||{},s=i.amplitude||30,a=i.frequency||2,h=.003*s*(i.strength||.6),n=(t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2)*Math.PI*a,r=Math.abs(Math.sin(n));let o=h;return t>.7&&(o*=1-(t-.7)/.3*.8),{position:[0,r*o,0],rotation:[0,0,0],scale:1+.08*r}}}},Pt={name:"spin",emoji:"๐",type:"override",description:"Orbital rotation around center point",config:{duration:600,musicalDuration:{musical:!0,beats:1},rotations:1,direction:"random",radiusMultiplier:1,spiralOut:!1,accelerate:!0,maintainDistance:!0,scaleAmount:.1,easing:"linear",strength:.7,particleMotion:{type:"spin",strength:.7,rotations:1,radius:1}},rhythm:{enabled:!0,syncMode:"bar",rotationSync:{mode:"bars",rotationsPerBar:1,accelerateOnBeat:!0},radiusSync:{subdivision:"quarter",expandOnBeat:1.2,contractOffBeat:.9,curve:"bounce"},durationSync:{mode:"beats",beats:4},patternOverrides:{waltz:{rotationSync:{rotationsPerBar:.75},radiusSync:{curve:"ease"}},swing:{rotationSync:{accelerateOnBeat:!1},direction:"alternating"},dubstep:{radiusSync:{subdivision:"eighth",expandOnBeat:1.5,dropMultiplier:2},spiralOut:!0},breakbeat:{rotationSync:{mode:"random",range:[.5,2]},direction:"random"}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;let n=e.direction||this.config.direction;"random"===n&&(n=Math.random()<.5?"clockwise":"counter-clockwise"),t.gestureData.spin={startAngle:Math.atan2(h,a),startRadius:Math.sqrt(a*a+h*h)||30,originalX:t.x,originalY:t.y,originalVx:t.vx,originalVy:t.vy,direction:n,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.spin?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.spin,r={...this.config,...i},o=i.strength||1;let{rotations:l}=r,{radiusMultiplier:c}=r;i.rhythmModulation&&(i.rhythmModulation.rotationMultiplier&&(l*=i.rhythmModulation.rotationMultiplier),i.rhythmModulation.radiusMultiplier&&(c*=i.rhythmModulation.radiusMultiplier));let u=e;r.accelerate&&(u=e<.5?.5*this.easeInQuad(2*e):.5+.5*this.easeOutQuad(2*(e-.5)));const p=l*Math.PI*2*o,d="counter-clockwise"===n.direction?-1:1,f=n.startAngle+p*u*d;let m=n.startRadius;r.spiralOut&&(m*=1+.5*e),1!==c&&(m*=1+(c-1)*Math.sin(e*Math.PI));const M=a+Math.cos(f)*m,g=h+Math.sin(f)*m;if(t.x+=.25*(M-t.x),t.y+=.25*(g-t.y),t.vx=.5*(M-t.x),t.vy=.5*(g-t.y),e>.9){const i=10*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i)}},cleanup(t){if(t.gestureData?.spin){const e=t.gestureData.spin;t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.spin}},easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),"3d":{evaluate(t,e){const i=e?.config||e||{},s=e?.strength||1,a=e?.particle;let h=1;a?.gestureData?.spin?h="counter-clockwise"===a.gestureData.spin.direction?-1:1:"counter-clockwise"!==i.direction&&"left"!==i.direction||(h=-1);let n=t;return!1!==i.accelerate&&(n=t<.5?t*t*4*.5:.5+(t-.5)*(2-(t-.5))*.5),{position:[0,0,0],rotation:[0,(i.rotations||1)*Math.PI*2*s*n*h,0],scale:1+(i.scaleAmount||.1)*Math.sin(t*Math.PI)*s}}}},Ot={name:"nod",emoji:"๐",type:"blending",description:"Vertical nodding motion",config:{duration:500,amplitude:15,frequency:2,easing:"sine",strength:.4,particleMotion:{type:"bounce",axis:"vertical",strength:.4,frequency:2,phase:0}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",interruptible:!1,priority:5,blendable:!1,minDuration:"halfBar",frequencySync:{mode:"subdivision",subdivision:"half",multiplier:1},amplitudeSync:{onBeat:1.4,offBeat:.8,curve:"ease"},durationSync:{mode:"beats",beats:2},patternOverrides:{waltz:{frequencySync:{subdivision:"quarter"},amplitudeSync:{onBeat:1.6,curve:"ease"}},swing:{amplitudeSync:{onBeat:1.5,offBeat:.9}},dubstep:{amplitudeSync:{onBeat:1.2,dropBeat:3,curve:"pulse"}}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.nod={startY:t.y,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.nod?.initialized||this.initialize(t,i);const n={...this.config,...i},r=n.strength||this.config.strength||1;let{frequency:o}=n,{amplitude:l}=n;i.rhythmModulation&&(l*=i.rhythmModulation.amplitudeMultiplier||1,l*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(o*=i.rhythmModulation.frequencyMultiplier));const c=Math.sin(e*Math.PI*2*o);l=l*r*t.scaleFactor,t.vy+=c*l*.01*s,e>.9&&(t.vy*=.95)},cleanup(t){t.gestureData?.nod&&delete t.gestureData.nod},"3d":{evaluate(t,e){const i={...this.config,...e};let{amplitude:s}=i;e.rhythmModulation&&(s*=e.rhythmModulation.amplitudeMultiplier||1,s*=e.rhythmModulation.accentMultiplier||1);let a=0;if(t<.4){const e=t/.4;a=.12*Math.sin(e*Math.PI)}else if(t<.8){const e=(t-.4)/.4;a=.07*Math.sin(e*Math.PI)}return a*=s/15,{cameraRelativePosition:[0,0,a],scale:1-.3*Math.abs(a),glowIntensity:1+.5*Math.abs(a)}}}},At={name:"jump",emoji:"๐ฆ",type:"override",description:"Squash, leap, and land with classic animation principles",config:{duration:800,musicalDuration:{musical:!0,beats:2},jumpHeight:60,squashAmount:.8,stretchAmount:1.2,anticipation:.2,hangTime:.1,landingImpact:!0,driftOutward:!0,easing:"quad",particleMotion:{type:"jump",strength:.9,jumpHeight:60,squash:.8,stretch:1.2}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:2},phaseSync:{anticipation:"eighth",jump:"beat",landing:"sixteenth"},heightSync:{onBeat:1.5,offBeat:.8,accent:2,curve:"exponential"},deformationSync:{squashOnBeat:.6,stretchOnBeat:1.4,timing:"anticipatory"},hangTimeSync:{mode:"tempo",baseDuration:.1,scaling:"inverse"},dynamics:{forte:{jumpHeight:80,stretch:1.3},piano:{jumpHeight:30,stretch:1.1}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={}),t.gestureData.jump={startX:t.x,startY:t.y,startSize:t.size,originalVx:t.vx,originalVy:t.vy,driftDirection:.1*(t.x-i),initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.jump?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.jump,r={...this.config,...i},o=i.strength||1,l=r.jumpHeight*o*t.scaleFactor,c=r.squashAmount,u=r.stretchAmount,p=r.anticipation,d=1-.5*r.anticipation;if(e<p){const i=e/p,s=this.easeOutQuad(i);t.size=n.startSize*(1-(1-c)*s),t.y=n.startY+5*s*t.scaleFactor,t.vx=0,t.vy=0}else if(e<d){const i=(e-p)/(d-p);let s=Math.sin(i*Math.PI);if(r.hangTime>0&&i>.4&&i<.6){const t=(i-.4)/.2;s=.95+.05*this.easeInOutCubic(t)}if(t.y=n.startY-s*l,r.driftOutward&&(t.x=n.startX+s*n.driftDirection),i<.5){const e=2*i;t.size=n.startSize*(c+(u-c)*e)}else{const e=2*(i-.5);t.size=n.startSize*(u-(u-1)*e*.8)}t.vx=.5*n.driftDirection,t.vy=-Math.cos(i*Math.PI)*l*.1}else{const i=(e-d)/(1-d),s=this.easeOutBounce(i);if(t.y=n.startY,r.landingImpact)if(i<.3){const e=i/.3;t.size=n.startSize*(1-(1-.8*c)*(1-e))}else{const e=(i-.3)/.7;t.size=n.startSize*(.8*c+(1-.8*c)*e)}else t.size=n.startSize*(c+(1-c)*s);t.vx=n.originalVx*s,t.vy=n.originalVy*s}},cleanup(t){if(t.gestureData?.jump){const e=t.gestureData.jump;t.size=e.startSize,t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.jump}},easeOutQuad:t=>t*(2-t),easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},"3d":{evaluate(t,e){const i=e.config||e||{},s=e.strength||1,a=.004*(i.jumpHeight||60)*s,h=i.squashAmount||.8,n=i.stretchAmount||1.2,r=i.anticipation||.2,o=1-.5*r;let l=0,c=1,u=0;if(t<r){const e=t/r,i=e*(2-e);c=1-(1-h)*i,l=.02*-i}else if(t<o){const e=(t-r)/(o-r);l=Math.sin(e*Math.PI)*a,c=e<.5?h+2*e*(n-h):n-2*(e-.5)*(n-1)*.8,u=.05*Math.sin(e*Math.PI)}else{const e=(t-o)/(1-o);if(e<.5){const t=2*e;l=-Math.sin(t*Math.PI)*a*.15}else l=0;c=!1!==i.landingImpact?e<.3?1-(1-.8*h)*(1-e/.3):.8*h+(e-.3)/.7*(1-.8*h):h+(1-h)*e}return{position:[0,l,0],rotation:[u,0,0],scale:c}}}},Dt={name:"stretch",emoji:"โ๏ธ",type:"override",description:"Scale particles along X and Y axes",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},scaleX:1.3,scaleY:.9,alternate:!1,elastic:!0,overshoot:.1,frequency:1,easing:"sine",strength:1,particleMotion:{type:"stretch",scaleX:1.8,scaleY:.6,strength:1},centerBased:!0,preserveArea:!1},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"bars",bars:1},scaleSync:{onBeat:{x:1.5,y:.7},offBeat:{x:.8,y:1.3},subdivision:"eighth",curve:"elastic"},alternateSync:{pattern:"XYXY",beatsPerChange:1,overlap:.1},overshootSync:{normal:.1,accent:.3,downbeat:.2,curve:"spring"},preservationSync:{verse:!0,chorus:!1,bridge:!0},dynamics:{forte:{scaleX:2,scaleY:.5,overshoot:.4},piano:{scaleX:1.1,scaleY:.95,overshoot:.05}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;t.gestureData.stretch={offsetX:a,offsetY:h,startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.stretch?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.stretch,r={...this.config,...i},o=i.strength||1;let l,c,{scaleX:u}=r,{scaleY:p}=r;if(r.preserveArea&&1!==u&&1!==p){const t=u*p,e=Math.sqrt(1/t);u*=e,p*=e}if(r.alternate)if(e<.5){const t=2*e;u=1+(u-1)*this.getElasticProgress(t,r),p=1+(1/u-1)*(r.preserveArea?1:0)}else{const t=2*(e-.5);u+=(1-u)*this.getElasticProgress(t,r),p=1+(p-1)*this.getElasticProgress(t,r)}else{const t=this.getElasticProgress(e,r);u=1+(u-1)*t*o,p=1+(p-1)*t*o}if(r.centerBased?(l=a+n.offsetX*u,c=h+n.offsetY*p):(l=n.startX*u,c=n.startY*p),t.x=l,t.y=c,t.vx=n.offsetX*(u-1)*o*.1,t.vy=n.offsetY*(p-1)*o*.1,e>.9){const i=10*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i)}},getElasticProgress(t,e){if(!e.elastic)return this.easeInOutCubic(t);if(0===t)return 0;if(1===t)return 1;const i=e.overshoot||.1;if(t<.5){const e=2*t;return.5*this.easeInElastic(e,i)}{const e=2*(t-.5);return.5+.5*this.easeOutElastic(e,i)}},cleanup(t){if(t.gestureData?.stretch){const e=t.gestureData.stretch;t.vx=e.originalVx,t.vy=e.originalVy,delete t.gestureData.stretch}},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeInElastic:(t,e)=>0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin((t-1-.075)*(2*Math.PI)/.3)*(1+e),easeOutElastic:(t,e)=>0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin((t-.075)*(2*Math.PI)/.3)*(1+e)+1,"3d":{evaluate(t,e){const{particle:i}=e;if(!i||!i.gestureData?.stretch)return{position:[0,0,0],rotation:[0,0,0],scale:1};const s=e.config||{},a=e.strength||1;let h;if(s.elastic){const e=s.overshoot||.1;if(t<.5){const i=2*t,s=.3,a=s/4;h=-Math.pow(2,10*(i-1))*Math.sin((i-1-a)*(2*Math.PI)/s)*(1+e)*.5}else{const i=2*(t-.5),s=.3,a=s/4;h=.5+.5*(Math.pow(2,-10*i)*Math.sin((i-a)*(2*Math.PI)/s)*(1+e)+1)}}else h=t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;let n,r=1;if(t>.8){const e=(t-.8)/(1-.8);r=1-e*e*e}n=s.alternate?t<.5?2*t*.8:.8-2*(t-.5)*1.4:1*h*a;const o=1+n*r;return{position:[0,0,0],rotation:[0,0,.1*Math.sin(t*Math.PI*4)*h*r],scale:o}}}},zt={name:"wobble",emoji:"๐ฅด",type:"override",description:"Unsteady circular wobbling motion",config:{duration:1500,musicalDuration:{musical:!0,beats:4},wobbleRadius:.08,wobbleAngle:.2,rotations:2,decay:.5,strength:1,particleMotion:{type:"wobble",strength:1}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:4},timingSync:"onBeat"},"3d":{evaluate(t,e){const i=e.config||this.config||{},s=i.strength||1,a=i.wobbleRadius||.08,h=i.wobbleAngle||.2,n=i.rotations||2,r=i.decay||.5,o=t*n*Math.PI*2,l=1-r*t,c=Math.sin(o)*a*l*s,u=Math.cos(o)*a*l*s,p=Math.cos(o)*h*l*s,d=Math.sin(o)*h*l*s;return{position:[c,.02*Math.sin(2*o)*l*s,u],rotation:[p,0,d],scale:1+.05*Math.sin(2*o)*l,glowIntensity:1+.2*Math.sin(o)*l,glowBoost:0}}}},Et={name:"drift",emoji:"โ๏ธ",type:"override",description:"Controlled floating with fade effects",config:{duration:800,musicalDuration:{musical:!0,beats:2},distance:50,angle:45,returnToOrigin:!0,fadeOut:!1,holdTime:.2,turbulence:.1,angleSpread:45,smoothness:.08,easing:"ease",strength:1,particleMotion:{type:"drift",strength:1,distance:60}},rhythm:{enabled:!0,syncMode:"ambient",durationSync:{mode:"beats",beats:2},distanceSync:{quiet:30,loud:80,crescendo:"expand",diminuendo:"contract"},angleSync:{major:45,minor:225,modulation:"smooth",cadence:"return"},holdSync:{shortPhrase:.1,longPhrase:.4,fermata:"sustain"},accentResponse:{enabled:!0,multiplier:1.3,type:"distance"},patternOverrides:{ambient:{distanceSync:{quiet:40,loud:100},holdSync:{shortPhrase:.3,longPhrase:.6}},classical:{angleSync:{major:30,minor:210},distanceSync:{quiet:25,loud:60}},jazz:{angleSync:{major:60,minor:240,swing:!0,syncopated:!0}},new_age:{distanceSync:{quiet:35,loud:70},holdSync:{shortPhrase:.4,longPhrase:.8},angleSync:{modulation:"gradual"}}},dynamics:{forte:{distanceSync:{quiet:{multiplier:1.5},loud:{multiplier:1.8}},holdSync:{multiplier:1.2},accentResponse:{multiplier:1.6}},piano:{distanceSync:{quiet:{multiplier:.6},loud:{multiplier:.8}},holdSync:{multiplier:.8},accentResponse:{multiplier:1.1}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s;let n=Math.atan2(h,a);const r={...this.config,...e}.angleSpread*Math.PI/180,o=(Math.random()-.5)*r;n+=o;const l=30+30*Math.random();t.gestureData.drift={startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,baseOpacity:t.opacity||t.life||1,driftAngle:n,angleOffset:o,homeRadius:l*t.scaleFactor,homeX:i+Math.cos(n)*l,homeY:s+Math.sin(n)*l,role:Math.random(),turbulencePhase:Math.random()*Math.PI*2,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.drift?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.drift,r={...this.config,...i},o=i.strength||1,l=this.easeInOutCubic(e),c=Math.max(0,l-.1*n.role);let u,p,d;if(r.returnToOrigin)if(c<.4){const t=c/.4,e=this.easeOutQuad(t);u=n.startX+(n.homeX-n.startX)*e,p=n.startY+(n.homeY-n.startY)*e}else if(c<.6+r.holdTime){const e=(c-.4)/(.2+r.holdTime);d=n.homeRadius+Math.sin(e*Math.PI*.5)*r.distance*o*t.scaleFactor}else{const e=(c-.6-r.holdTime)/(.4-r.holdTime);d=n.homeRadius+Math.cos(e*Math.PI*.5)*r.distance*o*t.scaleFactor}else{const e=c;d=n.homeRadius+e*r.distance*o*t.scaleFactor}if(void 0!==d){n.turbulencePhase+=r.turbulence*s;const t=Math.sin(n.turbulencePhase)*r.turbulence*10,e=Math.cos(1.3*n.turbulencePhase)*r.turbulence*10,i=n.driftAngle+n.angleOffset;u=a+Math.cos(i)*d+t,p=h+Math.sin(i)*d+e}const f=r.smoothness+.08*n.role;if(t.x+=(u-t.x)*f,t.y+=(p-t.y)*f,t.vx=.25*(u-t.x),t.vy=.25*(p-t.y),r.fadeOut){let i;i=e<.25?.3+e/.25*.7:e<.75?.7+.3*Math.sin((e-.25)*Math.PI/.5):4*(1-e),t.opacity=n.baseOpacity*i,void 0!==t.life&&(t.life=t.opacity)}e>=.99&&(t.vx=.1*n.originalVx,t.vy=.1*n.originalVy,r.fadeOut&&(t.opacity=n.baseOpacity,void 0!==t.life&&(t.life=n.baseOpacity)))},cleanup(t){if(t.gestureData?.drift){const e=t.gestureData.drift;t.vx=e.originalVx,t.vy=e.originalVy,t.opacity=e.baseOpacity,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.drift}},easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,easeOutQuad:t=>t*(2-t),"3d":{evaluate(t,e){const i={...this.config,...e},s=e.strength||1,a=(i.angle||45)*Math.PI/180,h=i.returnToOrigin?t<.5?2*t:2*(1-t):t;return{position:[Math.cos(a)*h*.3*s,Math.sin(a)*h*.3*s,.15*Math.sin(t*Math.PI)*s],rotation:[0,10*h*s,0],scale:1+.03*Math.sin(t*Math.PI),glowIntensity:1-.1*h}}}},It={name:"burst",emoji:"๐ฅ",type:"blending",description:"Explosive outward burst from center",config:{decay:.5,strength:2},rhythm:{enabled:!0,syncMode:"beat",strengthSync:{onBeat:3.5,offBeat:1,curve:"explosion"},decaySync:{mode:"tempo",fast:.8,slow:.3,curve:"exponential"},durationSync:{mode:"beats",beats:.5,sustain:!1},accentResponse:{enabled:!0,multiplier:2.5,type:"strength"},patternOverrides:{rock:{strengthSync:{onBeat:4,offBeat:1.5},decaySync:{fast:.6,slow:.4}},electronic:{strengthSync:{onBeat:3.8,offBeat:.8,curve:"sharp"},decaySync:{fast:.9,slow:.7}},jazz:{strengthSync:{onBeat:2.8,offBeat:1.8,swing:!0},decaySync:{fast:.5,slow:.2}},orchestral:{strengthSync:{onBeat:3.2,offBeat:.5},accentResponse:{multiplier:3}}},dynamics:{forte:{strengthSync:{onBeat:{multiplier:2},offBeat:{multiplier:1.5}},decaySync:{multiplier:.7},accentResponse:{multiplier:3.5}},piano:{strengthSync:{onBeat:{multiplier:.6},offBeat:{multiplier:.3}},decaySync:{multiplier:1.3},accentResponse:{multiplier:1.8}}}},apply(t,e,i,s,a,h){const n=i.decay||this.config.decay,r=(i.strength||this.config.strength)*(1-e*n),o=t.x-a,l=t.y-h,c=Math.sqrt(o*o+l*l);c>1&&(t.vx+=o/c*r*2*s,t.vy+=l/c*r*2*s)},"3d":{evaluate(t,e){const i=e.strength||2;let s=0,a=1,h=1,n=0;if(t<.15){const e=t/.15,r=1-Math.pow(1-e,3);s=.15*r*i,a=1+.2*r*i,h=1+.5*r,n=.4*r}else if(t<.35){const e=(t-.15)/.2;s=.15*(1-1.5*e)*i,a=1+.2*(1-e)*i-.1*Math.sin(e*Math.PI),h=1+.4*(1-e),n=.2*(1-e)}else{const e=(t-.35)/.65,n=Math.pow(1-e,2),r=Math.sin(e*Math.PI*2)*n;s=.03*r*i,a=1+.05*r,h=1+.15*Math.abs(r)}return{cameraRelativePosition:[0,0,s],position:[0,0,0],rotation:[0,0,0],scale:a,glowIntensity:h,glowBoost:n}}}},jt={name:"wave",emoji:"๐",type:"override",description:"Infinity pattern flow with phasing",config:{musicalDuration:{musical:!0,bars:1,minBeats:4,maxBeats:16},phases:[{name:"gather",beats:.5},{name:"rise",beats:.5},{name:"waveLeft",beats:1},{name:"waveRight",beats:1},{name:"settle",beats:1}],amplitude:40,frequency:1,phaseShift:.3,liftHeight:20,fadeInOut:!0,smoothness:.1,easing:"sine",strength:1,particleMotion:{type:"wave",strength:1,amplitude:50}},rhythm:{enabled:!0,syncMode:"wave",amplitudeSync:{onWave:65,onStatic:25,curve:"flowing"},frequencySync:{mode:"phrase",slow:.7,fast:1.8,curve:"melodic"},durationSync:{mode:"bars",adaptToPhrase:!0,sustain:!0},phaseSync:{enabled:!0,multiplier:.5,type:"ensemble"},melodicResponse:{enabled:!0,multiplier:1.4,type:"amplitude"},patternOverrides:{ambient:{amplitudeSync:{onWave:80,onStatic:40,curve:"hypnotic"},frequencySync:{slow:.5,fast:1.2},durationSync:{minBeats:16,maxBeats:64}},ocean:{amplitudeSync:{onWave:90,onStatic:20,curve:"natural"},phaseSync:{multiplier:.8},melodicResponse:{multiplier:1.8}},electronic:{amplitudeSync:{onWave:70,onStatic:30,curve:"digital"},frequencySync:{slow:.8,fast:2.5,curve:"precise"}},orchestral:{amplitudeSync:{onWave:75,onStatic:35},phaseSync:{multiplier:.7},melodicResponse:{multiplier:2}}},dynamics:{forte:{amplitudeSync:{onWave:{multiplier:1.8},onStatic:{multiplier:1.4}},frequencySync:{multiplier:1.3},melodicResponse:{multiplier:2.2}},piano:{amplitudeSync:{onWave:{multiplier:.6},onStatic:{multiplier:.4}},frequencySync:{multiplier:.7},melodicResponse:{multiplier:1.1}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={});const a=t.x-i,h=t.y-s,n=Math.atan2(h,a),r=Math.sqrt(a*a+h*h),o=Math.random()<.5?1:-1;t.gestureData.wave={startX:t.x,startY:t.y,originalVx:t.vx,originalVy:t.vy,baseOpacity:t.opacity||t.life||1,angle:n,radius:r,offset:Math.random()*Math.PI*2,role:Math.random(),direction:o,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.wave?.initialized||this.initialize(t,i,a,h);const n=t.gestureData.wave,r={...this.config,...i},o=i.strength||1,l=this.easeInOutSine(e),c=n.role*r.phaseShift,u=Math.max(0,l-c),p=u*Math.PI*2*r.frequency*n.direction+n.offset,d=.5+n.radius/100*.5,f=r.amplitude*d*o*t.scaleFactor,m=a+Math.sin(p)*f,M=h+Math.sin(2*p)*f*.3+-Math.abs(Math.sin(l*Math.PI))*r.liftHeight*t.scaleFactor,g=r.smoothness+.12*n.role;if(t.x+=(m-t.x)*g,t.y+=(M-t.y)*g,t.vx=.3*(m-t.x),t.vy=.3*(M-t.y),r.fadeInOut){let e;e=u<.1?u/.1:u>.9?(1-u)/.1:.5+.5*Math.sin(u*Math.PI),t.opacity=n.baseOpacity*(.3+.7*e),void 0!==t.life&&(t.life=t.opacity)}if(e>=.95){const i=20*(1-e);t.vx=t.vx*i+n.originalVx*(1-i),t.vy=t.vy*i+n.originalVy*(1-i),r.fadeInOut&&(t.opacity=n.baseOpacity*i,void 0!==t.life&&(t.life=t.opacity))}},cleanup(t){if(t.gestureData?.wave){const e=t.gestureData.wave;t.vx=e.originalVx,t.vy=e.originalVy,t.opacity=e.baseOpacity,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.wave}},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i=e?.strength||1,s=e?.frequency||1,a=-(Math.cos(Math.PI*t)-1)/2,h=a*Math.PI*2*s,n=.12*Math.sin(h)*i,r=.06*Math.sin(2*h)*i,o=.03*Math.sin(h)*i,l=.08*Math.sin(2*h)*i,c=.05*Math.sin(h)*i,u=1+.08*Math.abs(Math.sin(a*Math.PI))*i,p=Math.abs(Math.sin(h));return{position:[n,r,o],rotation:[l,0,c],scale:u,glowIntensity:1+.3*p*i,glowBoost:.6*p*i}}}},$t={name:"flash",emoji:"โก",type:"blending",description:"Bright flash burst effect",config:{duration:400,glowAmount:2.5,glowPeak:3,scalePeak:1.1,easing:"cubic",strength:1,particleMotion:{type:"burst",strength:1,decay:.3}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"immediate",interruptible:!0,priority:8,blendable:!0,intensitySync:{onBeat:3.5,offBeat:1,accent:5,subdivision:"quarter",curve:"exponential"},durationSync:{mode:"tempo",baseDuration:400,scaling:"inverse"},scaleSync:{onBeat:1.2,offBeat:1,accent:1.4,curve:"elastic"},strobeSync:{enabled:!1,pattern:"XXOX",subdivision:"sixteenth"},dynamics:{forte:{glowPeak:4,scalePeak:1.3,duration:300},piano:{glowPeak:2,scalePeak:1.05,duration:500}}},initialize(t,e){t.gestureData||(t.gestureData={}),t.gestureData.flash={originalOpacity:t.opacity,originalSize:t.size,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.flash?.initialized||this.initialize(t,i);const n=t.gestureData.flash,r={...this.config,...i},o=r.strength||1;let l;if(l=e<.3?e/.3*r.glowPeak:r.glowPeak*(1-(e-.3)/.7),t.opacity=Math.min(1,n.originalOpacity*(1+l*o)),t.size=n.originalSize*(1+(r.scalePeak-1)*l*o*.1),e<.2){const i=(1-e/.2)*o,n=Math.atan2(t.y-h,t.x-a);t.vx+=Math.cos(n)*i*2*s,t.vy+=Math.sin(n)*i*2*s}t.vx*=1-.1*r.particleMotion.decay,t.vy*=1-.1*r.particleMotion.decay},cleanup(t){t.gestureData?.flash&&(t.opacity=t.gestureData.flash.originalOpacity,t.size=t.gestureData.flash.originalSize,delete t.gestureData.flash)},"3d":{evaluate(t,e){let i;i=t<.3?t/.3:1-(t-.3)/.7;const s=1+.4*i;return{position:[0,0,0],rotation:[0,0,0],scale:1+i*(({...this.config,...e}.scalePeak||1.1)-1),glowIntensity:s,glowBoost:2*i}}}},Gt={name:"glow",emoji:"โจ",type:"blending",description:"Pure luminous glow without movement",config:{duration:1500,amplitude:0,frequency:1,holdPeak:.3,easing:"sine",scaleAmount:.1,glowAmount:.8,strength:0,direction:"none",particleMotion:{type:"glow",strength:0,direction:"none",frequency:1}},rhythm:{enabled:!0,syncMode:"phrase",amplitudeSync:{onBeat:2,offBeat:1.2,curve:"smooth"},frequencySync:{mode:"phrase",subdivision:"bar"},durationSync:{mode:"bars",bars:2},accentResponse:{enabled:!0,multiplier:2.5},patternOverrides:{ambient:{amplitudeSync:{onBeat:2.5,offBeat:1.8},durationSync:{bars:4}},electronic:{amplitudeSync:{onBeat:3,offBeat:.5,curve:"sharp"},frequencySync:{subdivision:"quarter"}}}},initialize(t,e,i,s){t.gestureData||(t.gestureData={}),t.gestureData.glow={startOpacity:t.opacity,startGlow:t.glowSizeMultiplier||0,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.glow?.initialized||this.initialize(t,i,a,h);const n={...this.config,...i},r=this.easeInOutSine(e);let o,{frequency:l}=n,{glowAmount:c}=n;i.rhythmModulation&&(c*=i.rhythmModulation.amplitudeMultiplier||1,c*=i.rhythmModulation.accentMultiplier||1,i.rhythmModulation.frequencyMultiplier&&(l*=i.rhythmModulation.frequencyMultiplier));const u=r*l*2%2;o=n.holdPeak>0&&u>1-n.holdPeak&&u<1+n.holdPeak?1:Math.sin(r*Math.PI*2*l);let p=1;e>.9&&(p=.5+.5*(1-10*(e-.9))),t.glowIntensity=1+o*c*p},cleanup(t){t.gestureData?.glow&&(t.glowIntensity=1,delete t.gestureData.glow)},easeInOutSine:t=>-(Math.cos(Math.PI*t)-1)/2,"3d":{evaluate(t,e){const i={...this.config,...e},s=-(Math.cos(Math.PI*t)-1)/2,a=Math.sin(s*Math.PI);let h=i.glowAmount||.8;e.rhythmModulation&&(h*=e.rhythmModulation.amplitudeMultiplier||1,h*=e.rhythmModulation.accentMultiplier||1);const n=1+a*h;return{position:[0,0,0],rotation:[0,0,0],scale:1+a*(i.scaleAmount||.1)*.5,glowIntensity:n,glowBoost:1.5*a}}}},qt={name:"flicker",emoji:"โก",type:"blending",description:"Rapid opacity changes with motion jitter",config:{duration:800,musicalDuration:{musical:!0,beats:2},flickerRate:15,frequency:6,minOpacity:.3,maxOpacity:1,jitterAmount:2,colorShift:!1,strobe:!1,pulseMode:!1,groupFlicker:.3,easing:"linear",strength:.7,particleMotion:{type:"flicker",strength:.7,frequency:6}},rhythm:{enabled:!0,syncMode:"subdivision",durationSync:{mode:"beats",beats:2},rateSync:{subdivision:"sixteenth",onBeat:30,offBeat:10,triplet:20,curve:"step"},opacitySync:{pattern:"HLMH",subdivision:"eighth",onAccent:.1,regular:.5},jitterSync:{onBeat:5,offBeat:1,accent:10,curve:"random"},strobeSync:{verse:!1,chorus:!0,drop:"intense",pattern:"XOXO"},dynamics:{forte:{flickerRate:25,jitterAmount:5,minOpacity:.1},piano:{flickerRate:8,jitterAmount:1,minOpacity:.5}}},initialize(t,e){t.gestureData||(t.gestureData={});const i={...this.config,...e},s=Math.random()<i.groupFlicker;t.gestureData.flicker={baseOpacity:t.opacity||t.life||1,baseColor:t.color,baseX:t.x,baseY:t.y,flickerTimer:0,lastFlicker:0,flickerState:!0,isGrouped:s,groupId:s?Math.floor(3*Math.random()):-1,phase:Math.random()*Math.PI*2,colorHue:0,initialized:!0}},apply(t,e,i,s,a,h){t.gestureData?.flicker?.initialized||this.initialize(t,i);const n=t.gestureData.flicker,r={...this.config,...i},o=i.strength||1;let l;if(n.flickerTimer+=s*r.flickerRate,r.strobe)l=(n.flickerTimer+n.phase)%1<.5?1:r.minOpacity;else if(r.pulseMode){const t=n.flickerTimer+n.phase;l=r.minOpacity+(r.maxOpacity-r.minOpacity)*(.5*Math.sin(t)+.5)}else{if(n.flickerTimer-n.lastFlicker>1)if(n.lastFlicker=n.flickerTimer,n.isGrouped){const t=Math.floor(n.flickerTimer)%3;n.flickerState=t===n.groupId}else n.flickerState=Math.random()>.3;const e=n.flickerState?r.maxOpacity:r.minOpacity+.3*Math.random(),i=t.opacity/n.baseOpacity;l=i+.3*(e-i)}const c=n.baseOpacity*(1+(l-1)*o);if(t.opacity=Math.max(0,Math.min(1,c)),void 0!==t.life&&(t.life=t.opacity),r.jitterAmount>0&&l>r.minOpacity){const e=r.jitterAmount*o*t.scaleFactor,i=(Math.random()-.5)*e*l,a=(Math.random()-.5)*e*l;t.vx+=.1*i*s,t.vy+=.1*a*s}if(r.colorShift&&t.color){n.colorHue+=.01*s;const e=30*Math.sin(n.colorHue);t.color=this.shiftHue(n.baseColor,e*o)}let u=1;e<.1?u=e/.1:e>.9&&(u=(1-e)/.1),t.opacity*=u,void 0!==t.life&&(t.life=t.opacity),e>.8&&(t.vx*=.95,t.vy*=.95)},shiftHue(t,e){if(!t||!t.startsWith("#"))return t;const i=t.slice(1),s=parseInt(i.substr(0,2),16)/255,a=parseInt(i.substr(2,2),16)/255,h=parseInt(i.substr(4,2),16)/255,n=e*Math.PI/180,r=Math.cos(n),o=Math.sin(n),l=s*o+a*r,c=h,u=t=>Math.max(0,Math.min(255,Math.round(255*t))).toString(16).padStart(2,"0");return`#${u(s*r-a*o)}${u(l)}${u(c)}`},cleanup(t){if(t.gestureData?.flicker){const e=t.gestureData.flicker;t.opacity=e.baseOpacity,t.color=e.baseColor,void 0!==t.life&&(t.life=e.baseOpacity),delete t.gestureData.flicker}},"3d":{evaluate(t,e){const i=e.config||{},s=e.strength||.7,a=t*(i.flickerRate||15),h=Math.sin(a*Math.PI*2),n=Math.floor(10*a),r=.3*h+.5*(Math.sin(123.456*n)+1)*.7,o=.6+.8*r,l=i.jitterAmount||2,c=.003*s*o,u=(Math.random()-.5)*l*c,p=(Math.random()-.5)*l*c,d=.03*(Math.random()-.5)*s*o;return{position:[u,p,0],rotation:[.5*d,0,d],scale:1+.08*(o-1),glowIntensity:o,glowBoost:1.2*r}}}},Xt={name:"heartbeat",emoji:"๐",type:"effect",description:"Rhythmic double-pump heartbeat (lub-dub)",config:{duration:1e3,musicalDuration:{musical:!0,beats:2},lubStrength:.8,dubStrength:1,lubDubGap:.15,strength:1,particleMotion:{type:"heartbeat",strength:1}},rhythm:{enabled:!0,syncMode:"beat",durationSync:{mode:"beats",beats:2},timingSync:"onBeat",amplitudeSync:{onBeat:1.2,offBeat:.8}},apply(t,e,i,s,a,h){const n={...this.config,...i},r=n.strength||1,o=this.R(e,n),l=t.x-a,c=t.y-h,u=Math.sqrt(l*l+c*c)||1,p=10*o*r;t.x+=l/u*p,t.y+=c/u*p},R(t,e){const i=e.lubDubGap||.15,s=e.lubStrength||.8,a=e.dubStrength||1;let h=0;const n=Math.abs(t-.1);n<.08&&(h=Math.cos(n/.08*Math.PI*.5)*s);const r=.1+i+.05,o=Math.abs(t-r);if(o<.1){const t=Math.cos(o/.1*Math.PI*.5)*a;h=Math.max(h,t)}return h},"3d":{evaluate(t,e){const i=e.config||this.config||{},s=i.strength||1,a=i.lubDubGap||.15,h=i.lubStrength||.8,n=i.dubStrength||1;let r=0;const o=Math.abs(t-.1);o<.08&&(r=Math.cos(o/.08*Math.PI*.5)*h);const l=.1+a+.05,c=Math.abs(t-l);if(c<.1){const t=Math.cos(c/.1*Math.PI*.5)*n;r=Math.max(r,t)}return{position:[0,0,.03*r*s],rotation:[0,0,0],scale:1+.15*r*s,glowIntensity:1+.5*r*s,glowBoost:.8*r*s}}}},Yt={name:"fade",emoji:"๐ป",type:"blending",description:"Fade particle opacity",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},fadeIn:!0,fadeOut:!0,minOpacity:0,maxOpacity:1},rhythm:{enabled:!0,syncMode:"dynamic",durationSync:{mode:"bars",bars:1},opacitySync:{onBeat:.9,offBeat:.3,subdivision:"eighth",curve:"exponential"},fadePhaseSync:{verse:{fadeIn:!0,fadeOut:!1},chorus:{fadeIn:!1,fadeOut:!1},bridge:{fadeIn:!0,fadeOut:!0},outro:{fadeIn:!1,fadeOut:!0}},pulseSync:{enabled:!0,frequency:"quarter",intensity:.2,onAccent:.4},dynamics:{forte:{minOpacity:.5,maxOpacity:1},piano:{minOpacity:0,maxOpacity:.4}}},initialize(t){t.gestureData||(t.gestureData={}),t.gestureData.fade={baseOpacity:t.opacity||t.life||1}},apply(t,e,i,s,a,h){t.gestureData?.fade||this.initialize(t);const n=t.gestureData.fade,r={...this.config,...i};let o;o=r.fadeIn&&!r.fadeOut?r.minOpacity+(r.maxOpacity-r.minOpacity)*e:r.fadeOut&&!r.fadeIn?r.maxOpacity-(r.maxOpacity-r.minOpacity)*e:e<.5?r.minOpacity+(r.maxOpacity-r.minOpacity)*(2*e):r.maxOpacity-(r.maxOpacity-r.minOpacity)*(2*(e-.5)),t.opacity=n.baseOpacity*o,void 0!==t.life&&(t.life=t.opacity)},cleanup(t){t.gestureData?.fade&&(t.opacity=t.gestureData.fade.baseOpacity,void 0!==t.life&&(t.life=t.opacity),delete t.gestureData.fade)},"3d":{evaluate(t,e){const i={...this?.config||{},...e},s=i.fadeIn??!0,a=i.fadeOut??!0;let h;h=s&&!a?t:a&&!s?1-t:t<.5?1-t/.5:(t-.5)/.5;const n=h*h*(3-2*h);return{position:[0,0,0],rotation:[0,0,0],scale:.01+.99*n,glowIntensity:n,glowBoost:0}}}};const Ht={},_t=[],Lt=[],Wt=[];function Ut(t,e){Ht[t.name]=t,e.push(t.name)}[Tt,xt,vt,St,Ft,kt,Bt,Ot,Ct,{name:"sparkle",emoji:"โจ",type:"blending",description:"Bright twinkling sparkle bursts",config:{duration:800,musicalDuration:{musical:!0,beats:2}},rhythm:{enabled:!0,syncMode:"beat",timingSync:"nextBeat",durationSync:{mode:"beats",beats:2},interruptible:!0,priority:5,blendable:!0},apply:(t,e,i)=>!1,blend:(t,e,i)=>!1,"3d":{evaluate(t,e){const i=e?.strength||1,s=Math.pow(Math.max(0,Math.sin(t*Math.PI*6)),3),a=Math.pow(Math.max(0,Math.sin(t*Math.PI*8+1)),3),h=Math.pow(Math.max(0,Math.sin(t*Math.PI*10+2)),3),n=Math.max(s,a,h)*Math.sin(t*Math.PI);return{position:[0,0,0],rotation:[0,0,0],scale:1+.08*n*i,glowIntensity:1+.5*n*i,glowBoost:2*n*i}}}},{name:"shimmer",emoji:"๐",type:"particle",description:"Shimmer effect with sparkling particles",config:{duration:2e3,musicalDuration:{musical:!0,bars:1},particleMotion:"radiant"},rhythm:{enabled:!0,syncType:"beat",durationSync:{mode:"bars",bars:1},intensity:.8},override:(t,e,i)=>(t.shimmerEffect=!0,t.shimmerProgress=e,!0),blend:(t,e,i)=>!1,"3d":{evaluate(t,e){const i=e?.strength||1,s=(.4*Math.sin(t*Math.PI*4)+.35*Math.sin(t*Math.PI*6+.5)+.25*Math.sin(t*Math.PI*10+1)+1)/2;return{position:[0,0,0],rotation:[0,0,0],scale:1+.05*s*i,glowIntensity:1+.3*s*i,glowBoost:1*s*i}}}},Rt,zt].forEach(t=>Ut(t,_t)),[Pt,At,Dt].forEach(t=>Ut(t,Lt)),[jt,Et,qt,It,$t,Gt,Xt,Yt].forEach(t=>Ut(t,Wt));const Vt={blending:_t,override:Lt,effect:Wt},Nt={};function Qt(t){return Ht[t]?Ht[t]:bt(t)||null}Object.entries(Vt).forEach(([t,e])=>{e.forEach(e=>{Nt[e]=t})});class Jt{constructor(t,e,i="ambient",s=1,a=1,h=null){const n=Math.random();this.z=n<1/13?.5+.5*Math.random():.9*Math.random()-1;const r=this.z>0?(20+20*Math.random())*s:3*s,o=Math.random()*Math.PI*2;this.x=t+Math.cos(o)*r,this.y=e+Math.sin(o)*r,this.vx=0,this.vy=0,this.vz=0,this.life=0,this.maxLife=1,this.lifeDecay=.01,this.fadeInTime=.15,this.fadeOutTime=.3,this.isFadingOut=!1,this.age=0,this.scaleFactor=s,this.particleSizeMultiplier=a,this.size=(4+6*Math.random())*s*a,this.baseSize=this.size,this.emotionColors=h,this.color="#ffffff",this.opacity=1,this.hasGlow=Math.random()<.333,this.glowSizeMultiplier=this.hasGlow?1.33+.33*Math.random():0,this.isCellShaded=Math.random()<.333,this.baseOpacity=.3+.4*Math.random(),this.cachedColors=new Map,this.maxCachedColors=20,this.colorAccessOrder=[],this.lastColor=null,this.lastOpacity=-1,this.behavior=i,this.behaviorData={},this.gestureData={initialX:t,initialY:e},gt(this,i)}update(t,e,i,s=null,a=null,h=0,n=null){const r=Math.min(t,50)/q,o=a&&a.type&&h>0&&function(t){const e=Qt(t);return!!e&&"override"===e.type}(a.type),l=this.rainData||"falling"===this.gestureBehavior||this.fallingData||this.gestureData?.rain,c=o||l;if(c||(this.x+=this.vx*r,this.y+=this.vy*r),!c){let t,s;if(n)t=n.width,s=n.height;else{const a=document.getElementById("card-mascot")||document.getElementById("cherokee-guide-mascot")||document.querySelector("canvas");t=a?a.width:2*e,s=a?a.height:2*i}const a=20,h=e-t/2+a,r=e+t/2+a,o=i-s/2+a,l=i+s/2-a;this.x-this.size<h?(this.x=h+this.size,this.vx=.5*Math.abs(this.vx)):this.x+this.size>r&&(this.x=r-this.size,this.vx=.5*-Math.abs(this.vx)),this.y-this.size<o?(this.y=o+this.size,this.vy=.5*Math.abs(this.vy)):this.y+this.size>l&&(this.y=l-this.size,this.vy=.5*-Math.abs(this.vy))}this.age+=this.lifeDecay*r,this.age<this.fadeInTime?this.life=this.age/this.fadeInTime:this.age<1-this.fadeOutTime?this.life=1:(this.life=(1-this.age)/this.fadeOutTime,this.isFadingOut=!0,"popcorn"===this.behavior&&(this.size=this.baseSize*(.5+.5*this.life))),this.life=Math.max(0,Math.min(1,this.life)),"falling"===this.behavior?this.opacity=this.life:this.opacity=this.easeInOutCubic(this.life),"burst"===this.behavior&&this.behaviorData&&this.life<this.behaviorData.fadeStart&&(this.size=this.baseSize*(this.life/this.behaviorData.fadeStart))}applyUndertoneModifier(t,e){}applyGestureMotion(t,e,i,s,a){!function(t,e,i,s,a,h){if(!i||!i.type||s>=1)return;t.gestureData||(t.gestureData={originalVx:t.vx,originalVy:t.vy,initialX:t.x,initialY:t.y,startAngle:Math.atan2(t.y-h,t.x-a),startRadius:Math.sqrt(Math.pow(t.x-a,2)+Math.pow(t.y-h,2))});const n=Qt(i.type);if(!n)return;let r=i;if(Y.isEnabled()&&n.rhythm?.enabled){const a=Y.applyGestureRhythm(n,t,s,e);r={...i,amplitude:(i.amplitude||1)*(a.amplitudeMultiplier||1)*(a.accentMultiplier||1),wobbleAmount:(i.wobbleAmount||0)*(a.wobbleMultiplier||1),rhythmModulation:a}}n.apply&&n.apply(t,s,r,e,a,h),s>=.99&&n.cleanup&&(n.cleanup(t),t.gestureData=null)}(this,i,t,e,s,a)}isOutOfBounds(t,e){return this.x<-50||this.x>t+50||this.y<-50||this.y>e+50}isAlive(){return this.life>0}setOutwardVelocity(t){if(this.behaviorData&&void 0!==this.behaviorData.outwardSpeed){const e=this.behaviorData.outwardSpeed;this.vx=Math.cos(t)*e,this.vy=Math.sin(t)*e+(this.behaviorData.upwardBias||0)}}getDepthAdjustedSize(){const t=1+.2*this.z;return this.size*t}getState(){return{position:{x:this.x,y:this.y,z:this.z},velocity:{x:this.vx,y:this.vy,z:this.vz},life:this.life,behavior:this.behavior,size:this.size,opacity:this.opacity}}reset(t,e,i="ambient",s=1,a=1,h=null){const n=Math.random();this.z=n<1/13?.5+.5*Math.random():.9*Math.random()-1;const r=this.z>0?(20+20*Math.random())*s:3*s,o=Math.random()*Math.PI*2;if(this.x=t+Math.cos(o)*r,this.y=e+Math.sin(o)*r,this.vx=0,this.vy=0,this.vz=0,this.life=0,this.age=0,this.scaleFactor=s,this.particleSizeMultiplier=a,this.size=(4+6*Math.random())*s*a,this.baseSize=this.size,this.emotionColors=h,this.cachedColors.clear(),this.colorAccessOrder=[],this.opacity=0,this.isFadingOut=!1,this.baseOpacity=.3+.4*Math.random(),this.color="#ffffff",this.behavior=i,this.gestureData=null,this.behaviorData)for(const t in this.behaviorData)delete this.behaviorData[t];else this.behaviorData={};gt(this,i)}getCachedColor(t,e){const i=Math.round(100*e)/100,s=`${t}_${i}`;if(this.cachedColors.has(s)){const t=this.colorAccessOrder.indexOf(s);-1!==t&&this.colorAccessOrder.splice(t,1),this.colorAccessOrder.push(s)}else{if(this.cachedColors.size>=this.maxCachedColors){const t=this.colorAccessOrder.shift();this.cachedColors.delete(t)}this.cachedColors.set(s,this.hexToRgba(t,i)),this.colorAccessOrder.push(s)}return this.cachedColors.get(s)}hexToRgba(t,e){const i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${e})`:`rgba(255, 255, 255, ${e})`}easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}render(t,e="#ffffff"){if(this.life<=0)return;if(!isFinite(this.x)||!isFinite(this.y))return;const i=this.x,s=this.y,a=Math.max(.1,this.size),h=this.tempColor||this.color||e;if(t.save(),this.isCellShaded){t.strokeStyle=this.getCachedColor(h,.9*this.opacity),t.lineWidth=2,t.beginPath(),t.arc(i,s,a,0,2*Math.PI),t.stroke();const e=Math.floor(3*this.opacity)/3;t.fillStyle=this.getCachedColor(h,e*(this.baseOpacity||.5)*.5),t.beginPath(),t.arc(i,s,Math.max(.1,a-1),0,2*Math.PI),t.fill(),e>.5&&(t.fillStyle=this.getCachedColor("#FFFFFF",.3),t.beginPath(),t.arc(i-.3*a,s-.3*a,.3*a,0,2*Math.PI),t.fill())}else{const e=t.createRadialGradient(i,s,0,i,s,a);if(e.addColorStop(0,this.getCachedColor(h,this.opacity*(this.baseOpacity||.5))),e.addColorStop(.5,this.getCachedColor(h,this.opacity*(this.baseOpacity||.5)*.5)),e.addColorStop(1,this.getCachedColor(h,0)),t.fillStyle=e,t.beginPath(),t.arc(i,s,a,0,2*Math.PI),t.fill(),this.hasGlow&&this.glowSizeMultiplier>0){const e=a*this.glowSizeMultiplier,n=t.createRadialGradient(i,s,.5*a,i,s,e),r=.3,o=Math.max(r,this.opacity),l=Math.min(1,this.glowSizeMultiplier/3);n.addColorStop(0,this.getCachedColor(h,Math.max(.5,.8*o)*l)),n.addColorStop(.25,this.getCachedColor(h,Math.max(.3,.6*o)*l)),n.addColorStop(.5,this.getCachedColor(h,Math.max(.2,.4*o)*l)),n.addColorStop(.75,this.getCachedColor(h,Math.max(.1,.2*o)*l)),n.addColorStop(1,this.getCachedColor(h,0)),t.save(),t.globalCompositeOperation="screen",t.fillStyle=n,t.beginPath(),t.arc(i,s,e,0,2*Math.PI),t.fill(),t.restore()}}t.restore()}}class Zt{constructor(t=50){this.poolSize=Math.min(t,50),this.pool=[],this.totalParticlesCreated=0,this.totalParticlesDestroyed=0,this.poolHits=0,this.poolMisses=0}getParticle(t,e,i,s,a,h,n,r=null){let o;return this.pool.length>0?(o=this.pool.pop(),o.reset(t,e,i,s,a,h),this.poolHits++):(o=new Jt(t,e,i,s,a,h),this.poolMisses++,this.totalParticlesCreated++),o.emotion=n,r&&(o.gestureBehavior=r),o}returnParticle(t){if(this.pool.length<this.poolSize){if(t.cachedGradient=null,t.cachedGradientKey=null,t.behaviorData)for(const e in t.behaviorData)delete t.behaviorData[e];this.pool.push(t)}else this.totalParticlesDestroyed++}refreshPool(){const t=this.pool.length-this.poolSize;t>0&&(this.pool.splice(this.poolSize),this.totalParticlesDestroyed+=t)}getStats(){return{poolSize:this.pool.length,poolHits:this.poolHits,poolMisses:this.poolMisses,totalCreated:this.totalParticlesCreated,totalDestroyed:this.totalParticlesDestroyed}}clear(){this.pool=[],this.poolHits=0,this.poolMisses=0,this.totalParticlesCreated=0,this.totalParticlesDestroyed=0}}class Kt{constructor(){this.spawnAccumulator=0}getSpawnPosition(t,e,i,s,a,h=null){const n=Math.min(s,a)/12,r=2.5*n,o=1.1*r,l=Math.min(e-30,s-e-30),c=Math.min(i-30,a-i-30),u=Math.min(1.5*r,l,c);switch(t){case"ambient":case"resting":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"ascending":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"rising":{const t=Math.random()*Math.PI*2,s=o+Math.random()*(u-o);return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"falling":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s,angle:t}}case"aggressive":{const t=Math.random()*Math.PI*2,s=r+Math.random()*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"scattering":default:return{x:e,y:i};case"burst":{const t=Math.random()*Math.PI*2;if("suspicion"===h){const s=1.5*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}if("surprise"===h){const s=1.2*n;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}return{x:e,y:i}}case"repelling":{const t=Math.random()*Math.PI*2,s=.9*r;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"orbiting":{const t=Math.random()*Math.PI*2,s=1.2*r+Math.random()*r*.5;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"glitchy":{const t=Math.random()*Math.PI*2,s=3*r+Math.random()*r*4;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}case"spaz":{const t=Math.random()*Math.PI*2,s=2*r+Math.random()*r*3;return{x:e+Math.cos(t)*s,y:i+Math.sin(t)*s}}}}clampToCanvas(t,e,i,s,a=30){return{x:Math.max(a,Math.min(i-a,t)),y:Math.max(a,Math.min(s-a,e))}}calculateSpawnRate(t,e){if(t<=0)return 0;const i=Math.min(e,50),s=t/1e3;this.spawnAccumulator+=s*i,this.spawnAccumulator=Math.min(this.spawnAccumulator,3);let a=0;for(;this.spawnAccumulator>=1;)a++,this.spawnAccumulator-=1;return a}resetAccumulator(){this.spawnAccumulator=0}}class te{render(t,e,i="#ffffff",s=null){const a=[];for(const t of e)t.life<=0||a.push(t);this.T(t,a,i,s)}renderLayer(t,e,i="#ffffff",s=!1,a=null){const h=[],n=t.canvas.width,r=t.canvas.height;for(const t of e)t.z>=0===s&&(t.x<-50||t.x>n+50||t.y<-50||t.y>r+50||t.life<=0||h.push(t));return h.sort((t,e)=>t.isCellShaded!==e.isCellShaded?t.isCellShaded?-1:1:t.hasGlow!==e.hasGlow?t.hasGlow?-1:1:0),this.T(t,h,i,a),h}T(t,e,i,s=null){t.save();let a=null;for(const h of e)if(h.isCellShaded)h.render(t,i),a=null;else{const e=h.color||i;if(e!==a&&(t.fillStyle=e,a=e),!isFinite(h.x)||!isFinite(h.y))continue;const n=h.getDepthAdjustedSize?h.getDepthAdjustedSize():h.size;let r=Math.max(.1,n),o=1;if(s&&s.fireflyEffect){const t=(.01*h.x+.01*h.y+.1*h.size)%(2*Math.PI),e=s.fireflyTime||.001*Date.now(),i=s.particleGlow||2;o=.3+Math.max(0,Math.sin(3*e+t))*i}if(s&&s.flickerEffect){const t=(.02*h.x+.02*h.y)%(2*Math.PI),e=s.flickerTime||.001*Date.now(),i=s.particleGlow||2;o=.5+Math.sin(12*e+t)*i*.5}if(s&&s.shimmerEffect){const e=h.x-t.canvas.width/2,i=h.y-t.canvas.height/2,a=Math.sqrt(e*e+i*i)/200,n=s.shimmerTime||.001*Date.now(),r=s.shimmerWave||0,l=s.particleGlow||1.2;o=1+.15*Math.sin(3*n-a+r)*l}if(s&&s.glowEffect){const e=s.glowProgress||0,i=s.particleGlow||2,a=h.x-t.canvas.width/2,n=h.y-t.canvas.height/2,o=Math.sqrt(a*a+n*n)/300,l=Math.min(.3*o,.5),c=Math.max(0,(e-l)/(1-l)),u=Math.sin(c*Math.PI);h.P||(h.P={hasGlow:h.hasGlow,glowSizeMultiplier:h.glowSizeMultiplier||0}),h.hasGlow=!0,h.glowSizeMultiplier=Math.max(3,h.P.glowSizeMultiplier)+u*i*3,r*=1+.3*u,e>=.99&&h.P&&(h.hasGlow=h.P.hasGlow,h.glowSizeMultiplier=h.P.glowSizeMultiplier,delete h.P)}if(h.hasGlow||o>1){const e=Math.max(.1,r*(h.glowSizeMultiplier||1.5)*o),i=t.globalCompositeOperation;t.globalCompositeOperation="screen",t.globalAlpha=.15*h.opacity*o,t.beginPath(),t.arc(h.x,h.y,e,0,2*Math.PI),t.fill(),t.globalAlpha=.25*h.opacity*o,t.beginPath(),t.arc(h.x,h.y,.6*e,0,2*Math.PI),t.fill(),t.globalCompositeOperation=i}t.globalAlpha=h.opacity*(h.baseOpacity||.5)*.6*Math.min(2,o),t.beginPath(),t.arc(h.x,h.y,r,0,2*Math.PI),t.fill()}t.restore()}}class ee{constructor(t=50,e=null){this.errorBoundary=e,this.maxParticles=t,this.absoluteMaxParticles=2*t,this.particles=[],this.particlePool=new Zt(t),this.particleSpawner=new Kt,this.particleRenderer=new te,this.containmentBounds=null,this.stateChangeCount=0,this.lastMemoryCheck=Date.now(),this.lastLeakedCount=0,this.particleCount=0,this.cleanupTimer=0,this.cleanupInterval=5e3}get pool(){return this.particlePool.pool}get poolSize(){return this.particlePool.poolSize}get poolHits(){return this.particlePool.poolHits}get poolMisses(){return this.particlePool.poolMisses}get totalParticlesCreated(){return this.particlePool.totalParticlesCreated}get totalParticlesDestroyed(){return this.particlePool.totalParticlesDestroyed}get spawnAccumulator(){return this.particleSpawner.spawnAccumulator}set spawnAccumulator(t){this.particleSpawner.spawnAccumulator=t}getParticleFromPool(t,e,i){return this.particlePool.getParticle(t,e,i,this.scaleFactor||1,this.particleSizeMultiplier||1,this.currentEmotionColors,this.currentEmotion,this.gestureBehavior)}returnParticleToPool(t){this.particlePool.returnParticle(t)}spawn(t,e,i,s,a,h,n=null,r=0,o=10,l=1,c=1,u=null,p=null){if(this.scaleFactor=l,this.particleSizeMultiplier=c,this.errorBoundary)return this.errorBoundary.wrap(()=>{this.O(t,e,i,s,a,h,n,r,o,u,p)},"particle-spawn")();this.O(t,e,i,s,a,h,n,r,o,u,p)}resetAccumulator(){this.particleSpawner.resetAccumulator()}O(t,e,i,s,a,h,n,r=0,o=10,l=null,u=null){this.currentEmotion=e,this.baseEmotionColors=l,this.currentUndertone=u,this.currentEmotionColors=l&&u?function(t,e){return t&&Array.isArray(t)&&e&&"clear"!==e?t.map(t=>"string"==typeof t?c(t,e):t&&"object"==typeof t&&t.color?{...t,color:c(t.color,e)}:t):t}(l,u):l;let p=i;if(Y.isEnabled()){const i=$&&$.isInitialized?$.getEmotion(e):P(e);if(i){const e=Y.applyParticleRhythm(i,this);if(e.emitBurst)for(let i=0;i<e.emitBurst&&this.particles.length<o;i++)this.spawnSingleParticle(t,s,a);void 0!==e.emissionRate&&(p*=e.emissionRate)}}if(null!==n){for(let e=0;e<n&&this.particles.length<this.maxParticles;e++)this.spawnSingleParticle(t,s,a);return}if(this.skipSpawnThisFrame)return;for(;this.particles.length<r&&this.particles.length<this.maxParticles;)this.spawnSingleParticle(t,s,a);if(this.particles.length>=o)return;if(p<=0)return;const d=this.particleSpawner.calculateSpawnRate(p,h);for(let e=0;e<d&&this.particles.length<o;e++)this.spawnSingleParticle(t,s,a)}getSpawnPosition(t,e,i,s,a){return this.A||(this.A=!0),this.particleSpawner.getSpawnPosition(t,e,i,s,a,this.currentEmotion)}clampToCanvas(t,e,i,s,a=30){return this.D||(this.D=!0),this.particleSpawner.clampToCanvas(t,e,i,s,a)}spawnSingleParticle(t,e,i){if(this.particles.length>=this.absoluteMaxParticles)return;const s=this.canvasWidth||2*e,a=this.canvasHeight||2*i,h=this.particleSpawner.getSpawnPosition(t,e,i,s,a,this.currentEmotion),n=this.particleSpawner.clampToCanvas(h.x,h.y,s,a);h.x=n.x,h.y=n.y;const r=this.getParticleFromPool(h.x,h.y,t);"meditation_swirl"===t&&h.palmCenter&&(r.palmCenter=h.palmCenter,r.swirlAngle=h.swirlAngle),this.particles.push(r),this.particleCount++}update(t,e,i,s=null,a=0,h=null){if(this.errorBoundary)return this.errorBoundary.wrap((t,e,i,s,a,h)=>this.I(t,e,i,s,a,h),"particle-update")(t,e,i,s,a,h);this.I(t,e,i,s,a,h)}I(t,e,i,s=null,a=0,h=null){for(let n=this.particles.length-1;n>=0;n--)this.particles[n].update(t,e,i,h,s,a,this.containmentBounds),this.particles[n].isAlive()||this.removeParticle(n);for(;this.particles.length>this.maxParticles;)this.removeParticle(0)}setGestureBehavior(t,e){this.gestureBehavior=e?t:null,e?this.particles.forEach(e=>{e.gestureBehavior=t}):this.particles.forEach(t=>{t.gestureBehavior=null})}removeParticle(t){if(t>=0&&t<this.particles.length){const e=this.particles.splice(t,1)[0];e.cachedGradient=null,e.cachedGradientKey=null,this.returnParticleToPool(e),this.particleCount=Math.max(0,this.particleCount-1)}}render(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.j(t,e,i)},"particle-render")();this.j(t,e,i)}renderBackground(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.$(t,e,!1,i)},"particle-render-bg")();this.$(t,e,!1,i)}renderForeground(t,e="#ffffff",i=null){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.$(t,e,!0,i)},"particle-render-fg")();this.$(t,e,!0,i)}$(t,e,i,s=null){this.particleRenderer.renderLayer(t,this.particles,e,i,s)}j(t,e,i=null){this.particleRenderer.render(t,this.particles,e,i)}onVisibilityResume(t,e=null){if(this.resetAccumulator(),t>X)this.clear();else if(t>1e4){const t=this.particles.length,i=e??t,s=Math.max(10,Math.floor(.5*i));for(;this.particles.length>s;)this.removeParticle(0)}}clear(){for(this.stateChangeCount++;this.particles.length>0;){const t=this.particles.pop();if(t.cachedColors&&t.cachedColors.clear(),t.behaviorData)for(const e in t.behaviorData)delete t.behaviorData[e];this.pool.length<this.poolSize&&!this.pool.includes(t)&&this.pool.push(t)}if(this.particles.length=0,this.particleCount=0,this.spawnAccumulator=0,this.pool.length>this.poolSize){const t=this.pool.length-this.poolSize;this.pool.splice(this.poolSize,t)}}burst(t,e,i,s){if(this.errorBoundary)return this.errorBoundary.wrap(()=>{this.G(t,e,i,s)},"particle-burst")();this.G(t,e,i,s)}G(t,e,i,s){const a=Math.min(t,this.maxParticles-this.particles.length);for(let t=0;t<a;t++)this.spawnSingleParticle(e,i,s)}performCleanup(){if(this.pool.length>this.poolSize){const t=this.pool.length-this.poolSize;for(let e=0;e<t;e++){const t=this.pool.pop();t&&(t.cachedGradient=null,t.cachedGradientKey=null,t.behaviorData=null)}}for(const t of this.particles)t.cachedGradient&&t.life<.5&&(t.cachedGradient=null,t.cachedGradientKey=null)}getStats(){return{activeParticles:this.particles.length,maxParticles:this.maxParticles,poolSize:this.pool.length,poolHits:this.poolHits,poolMisses:this.poolMisses,poolEfficiency:this.poolHits/Math.max(1,this.poolHits+this.poolMisses),spawnAccumulator:this.spawnAccumulator}}setMaxParticles(t){for(this.originalMaxParticles=this.originalMaxParticles||this.maxParticles,this.maxParticles=Math.max(1,t);this.particles.length>this.maxParticles;)this.removeParticle(0)}cleanupDeadParticles(){const t=this.particles.length;this.particles=this.particles.filter(t=>t.isAlive());const e=t-this.particles.length;return this.pool.length>20&&(this.pool.length=20),e}getParticlesByBehavior(t){return this.particles.filter(e=>e.behavior===t)}validateParticles(){for(const t of this.particles)if(!t.isAlive()||t.life<0||t.life>1)return!1;return!0}cleanup(){for(let t=this.particles.length-1;t>=0;t--)this.particles[t].isAlive()||this.removeParticle(t)}refreshPool(){this.particlePool.clear();for(const t of this.particles)t.life=0}setContainmentBounds(t){this.containmentBounds=t}destroy(){this.clear(),this.particlePool.clear()}}class ie{compose(){return null}}const se=new class{constructor(){this.gestureCache=new Map,this.propertyCache=new Map,this.compositionCache=new Map,this.pluginCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0,gestureHits:0,propertyHits:0,compositionHits:0},this.isInitialized=!1,this.loadStartTime=0}q(){this.isInitialized||this.initialize()}initialize(){this.loadStartTime=performance.now();try{this.cacheCoreGestures(),this.cacheGestureProperties(),this.cacheCommonCombinations(),this.cachePluginGestures(),this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.gestureCache.size+this.propertyCache.size+this.compositionCache.size,this.isInitialized=!0}catch(t){this.isInitialized=!1}}cacheCoreGestures(){Object.values(Ht).forEach(t=>{t&&t.name&&this.gestureCache.set(t.name,{...t,cached:!0,cacheTime:performance.now()})})}cacheGestureProperties(){this.gestureCache.forEach((t,e)=>{const i={type:t.type,emoji:t.emoji,description:t.description,config:t.config,rhythm:t.rhythm,duration:this.calculateGestureDuration(t),easing:this.extractEasingFunction(t),physics:this.extractPhysicsProperties(t),timing:this.extractTimingProperties(t)};this.propertyCache.set(e,i)})}cacheCommonCombinations(){[["bounce","pulse"],["shake","vibrate"],["orbit","spin"],["morph","glow"],["breathe","fade"],["wave","drift"],["nod","sway"],["jump","stretch"]].forEach(([t,e])=>{const i=`${t}+${e}`,s=this.calculateGestureCombination(t,e);s&&this.compositionCache.set(i,s)})}cachePluginGestures(){try{const t=wt();t&&Object.entries(t).forEach(([t,e])=>{this.pluginCache.set(t,{...e,cached:!0,cacheTime:performance.now(),isPlugin:!0})})}catch(t){}}getGesture(t){return this.q(),this.gestureCache.has(t)?(this.stats.hits++,this.stats.gestureHits++,this.gestureCache.get(t)):this.pluginCache.has(t)?(this.stats.hits++,this.stats.gestureHits++,this.pluginCache.get(t)):(this.stats.misses++,null)}getGestureProperties(t){return this.q(),this.propertyCache.has(t)?(this.stats.hits++,this.stats.propertyHits++,this.propertyCache.get(t)):(this.stats.misses++,null)}getGestureCombination(t,e){this.q();const i=`${t}+${e}`;return this.compositionCache.has(i)?(this.stats.hits++,this.stats.compositionHits++,this.compositionCache.get(i)):(this.stats.misses++,null)}calculateGestureDuration(t){if(!t.config)return 1e3;const{musicalDuration:e,duration:i}=t.config;return e&&e.musical?500*(e.beats||2):i||1e3}extractEasingFunction(t){if(!t.config)return"sine";const{easing:e,particleMotion:i}=t.config;return e||i?.easing||"sine"}extractPhysicsProperties(t){if(!t.config)return{};const{amplitude:e,strength:i,size:s,rotation:a}=t.config;return{amplitude:e||20,strength:i||1,size:s||80,rotation:a||0}}extractTimingProperties(t){if(!t.config)return{};const{phases:e,timingSync:i}=t.config;return{phases:e||[],timingSync:i||{},hasPhases:!!(e&&e.length>0),hasTimingSync:!!(i&&Object.keys(i).length>0)}}calculateGestureCombination(t,e){const i=this.getGesture(t),s=this.getGesture(e);return i&&s?{gestures:[t,e],combinedDuration:Math.max(this.calculateGestureDuration(i),this.calculateGestureDuration(s)),combinedType:i.type===s.type?i.type:"mixed",combinedEasing:this.extractEasingFunction(i),combinedPhysics:this.combinePhysicsProperties(i,s),compatibility:this.calculateCompatibility(i,s)}:null}combinePhysicsProperties(t,e){const i=this.extractPhysicsProperties(t),s=this.extractPhysicsProperties(e);return{amplitude:Math.max(i.amplitude,s.amplitude),strength:(i.strength+s.strength)/2,size:Math.max(i.size,s.size),rotation:(i.rotation+s.rotation)/2}}calculateCompatibility(t,e){return t.type===e.type?"high":"blending"===t.type&&"blending"===e.type?"medium":"override"===t.type||"override"===e.type?"low":"medium"}getStats(){const t=this.stats.hits+this.stats.misses>0?(this.stats.hits/(this.stats.hits+this.stats.misses)*100).toFixed(1):0;return{...this.stats,hitRate:`${t}%`,isInitialized:this.isInitialized,cacheSize:this.stats.cacheSize,coreGestures:this.gestureCache.size,pluginGestures:this.pluginCache.size,properties:this.propertyCache.size,combinations:this.compositionCache.size}}clear(){this.gestureCache.clear(),this.propertyCache.clear(),this.compositionCache.clear(),this.pluginCache.clear(),this.stats={hits:0,misses:0,loadTime:0,cacheSize:0,gestureHits:0,propertyHits:0,compositionHits:0},this.isInitialized=!1}warmUp(t){t.forEach(t=>{this.getGesture(t),this.getGestureProperties(t)})}};function ae(t){if(se&&se.isInitialized){const e=se.getGesture(t);if(e)return e}return Qt(t)}const he=new class{toMilliseconds(t){return"number"==typeof t?t:t?.beats?500*t.beats:t?.bars?2e3*t.bars:1e3}resolve(t){return this.toMilliseconds(t)}};class ne{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyBounce(t,e){return{offsetY:-Math.abs(Math.sin(e*Math.PI*t.params.frequency))*t.params.amplitude*this.scaleFactor*(t.params.effects&&t.params.effects.includes("gravity")?.6:1)}}applyShake(t,e){t.randomAngle||(t.randomAngle=Math.random()*Math.PI*2);const i=t.params.decay?1-e:1,s=Math.sin(e*Math.PI*t.params.frequency)*t.params.amplitude*i*this.scaleFactor;return{offsetX:s*Math.cos(t.randomAngle),offsetY:s*Math.sin(t.randomAngle)}}applyJump(t,e){let i,s,a=0,h=1;if(e<.2){const i=e/.2;h=1-(1-t.params.squashAmount)*i}else if(e<.7){const i=(e-.2)/.5,s=Math.sin(i*Math.PI);a=-t.params.jumpHeight*s*this.scaleFactor,h=t.params.squashAmount+(t.params.stretchAmount-t.params.squashAmount)*s}else{const i=(e-.7)/.3;h=t.params.stretchAmount-(t.params.stretchAmount-1)*i}if(t.params.effects&&t.params.effects.includes("gravity")){const t=e<.7?(e-.2)/.5:0,a=Math.sin(t*Math.PI);i=1+.2*a,s=1-.15*a}const n={offsetY:a,scale:h};return void 0!==i&&(n.scaleX=i),void 0!==s&&(n.scaleY=s),n}applyVibrate(t,e){if(!t.vibrateAngles){t.vibrateAngles={x:2*Math.random()-1,y:2*Math.random()-1};const e=Math.sqrt(t.vibrateAngles.x**2+t.vibrateAngles.y**2);t.vibrateAngles.x/=e,t.vibrateAngles.y/=e}const i=t.params.amplitude||5,s=t.params.frequency||20,a=Math.sin(e*Math.PI*2*s)*i*this.scaleFactor;return{offsetX:a*t.vibrateAngles.x,offsetY:a*t.vibrateAngles.y}}applyWiggle(t,e){const i=(t.params?.amplitude||15)*this.scaleFactor;void 0===t.wiggleDirection&&(t.wiggleDirection=Math.random()<.5?1:-1);const s=t.wiggleDirection;let a=0,h=0;if(e<.25){const t=e/.25;a=i*s*t,h=3*s*t}else if(e<.5){const t=(e-.25)/.25;a=i*s*(1-2*t),h=3*s*(1-2*t)}else if(e<.75){const t=(e-.5)/.25;a=i*-s*(1-2*t),h=3*-s*(1-2*t)}else{const t=(e-.75)/.25;a=i*s*(1-t),h=3*s*(1-t)}return{offsetX:a,offsetY:-Math.abs(Math.sin(e*Math.PI*4))*i*.15,rotation:h}}}class re{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyFlash(t,e){const i=Math.sin(e*Math.PI);return{glow:1+((t.params.glowPeak||2)-1)*i,scale:1+((t.params.scalePeak||1.1)-1)*i}}applyGlow(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+i*(t.params.scaleAmount||.1),glow:1+i*(t.params.glowAmount||.8)}}applyFlicker(t,e){const i=t.params?.intensity||2,s=t.params?.speed||3,a=1+Math.sin(e*Math.PI*2*s)*i*.3,h=5*Math.sin(e*Math.PI*4)*this.scaleFactor,n=.001*Date.now();return{offsetX:h,glow:a,particleGlow:(.5*Math.sin(e*Math.PI*s*2)+.5)*i,flickerTime:n,flickerEffect:!0}}applySparkle(t,e){const i=t.params?.intensity||2,s=.001*Date.now();return{particleGlow:i,glow:.3*Math.sin(e*Math.PI*4)+.7,fireflyTime:s,fireflyEffect:!0}}applyShimmer(t,e){const i=.001*Date.now(),s=t.params?.intensity||.3,a=Math.sin(2*i+e*Math.PI*2);return{offsetX:0,offsetY:0,glow:1+a*s,scale:1+.01*a,particleGlow:1+.2*a,shimmerTime:i,shimmerWave:a,shimmerEffect:!0}}}class oe{constructor(t){this.renderer=t}applyBreathe(t,e){const{params:i}=t,s=i.particleMotion?.holdPercent||.1;let a;if(e<.4)a=Math.sin(e/.4*Math.PI/2);else if(e<.4+s)a=1;else if(e<.9){const t=(e-.4-s)/(.5-s);a=Math.cos(t*Math.PI/2)}else a=0;const h=1+a*(i.scaleAmount||.25),n=1+a*(i.glowAmount||.4);return t.breathPhase=a,{scale:h,glow:n,breathPhase:a}}applyBreathIn(t,e){return{scale:1+(t.params.scaleAmount-1)*Math.sin(e*Math.PI/2)}}applyBreathOut(t,e){return{scale:1-(1-t.params.scaleAmount)*Math.sin(e*Math.PI/2)}}applyBreathHold(t,e){return{scale:t.params.scaleAmount}}applyBreathHoldEmpty(t,e){return{scale:t.params.scaleAmount}}}class le{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applySpin(t,e){return{rotation:Math.min(1.05*e,1)*t.params.rotations*360,scale:1+Math.sin(e*Math.PI)*t.params.scaleAmount}}applyDrift(t,e){e<=.01&&!t.currentDriftAngle&&(t.currentDriftAngle=Math.random()*Math.PI*2);const i=t.params.distance*Math.sin(e*Math.PI)*this.scaleFactor,s=t.currentDriftAngle||0;return e>=.99&&(t.currentDriftAngle=null),{offsetX:Math.cos(s)*i,offsetY:Math.sin(s)*i}}applyWave(t,e){const i=(t.params.amplitude||40)*this.scaleFactor,s=e*Math.PI*2,a=Math.sin(s)*i,h=-Math.sin(e*Math.PI)*i*.3;return{offsetX:a,offsetY:Math.sin(2*s)*i*.2+h,rotation:5*Math.sin(s),scale:1+.05*Math.sin(e*Math.PI*2),glow:1+.2*Math.sin(e*Math.PI)}}applySway(t,e){const i=(t.params?.amplitude||30)*this.scaleFactor,s=t.params?.frequency||1;return{offsetX:Math.sin(e*Math.PI*2*s)*i,offsetY:Math.sin(e*Math.PI*4*s)*i*.1,rotation:5*Math.sin(e*Math.PI*2*s)}}applyFloat(t,e){const i=(t.params?.amplitude||20)*this.scaleFactor,s=t.params?.speed||1,a=Math.sin(e*Math.PI*2*s)*i;return{offsetX:Math.sin(e*Math.PI*3*s)*i*.3,offsetY:a,scale:1+.02*Math.sin(e*Math.PI*4*s)}}applyOrbital(t,e){return{offsetX:0,offsetY:0}}applyHula(t,e){const i=(t.params?.amplitude||40)*this.scaleFactor,s=e*Math.PI*2;return{offsetX:Math.sin(s)*i,offsetY:Math.sin(2*s)*i*.5}}applyOrbit(t,e){const i=(t.params?.radius||30)*this.scaleFactor,s=t.params?.speed||1,a=e*Math.PI*2*s;return{offsetX:Math.cos(a)*i,offsetY:Math.sin(a)*i}}}class ce{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyPulse(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+i*t.params.scaleAmount,glow:1+i*t.params.glowAmount}}applyExpand(t,e){const i=Math.max(t.params.scaleAmount||t.params.scaleTarget||1.5,1),s=Math.sin(e*Math.PI/2);return{scale:1+(i-1)*s,glow:1+Math.abs(t.params.glowAmount||.2)*s}}applyContract(t,e){const i=t.params.scaleAmount||t.params.scaleTarget||.7,s=Math.sin(e*Math.PI/2);return{scale:1+(i-1)*s,glow:1+(t.params.glowAmount||-.2)*s}}applyStretch(t,e){const i=Math.sin(e*Math.PI*t.params.frequency);return{scale:1+((t.params.scaleX+t.params.scaleY)/2-1)*i}}applyMorph(t,e){const i=Math.sin(e*Math.PI*2);return{scale:1+.1*i,rotation:10*i}}}class ue{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyNod(t,e){return{offsetY:Math.sin(e*Math.PI*t.params.frequency)*t.params.amplitude*this.scaleFactor}}applyTilt(t,e){t.tiltDirection||(t.tiltDirection=Math.random()<.5?-1:1);const i=t.params.frequency||2,s=(t.params.angle||15)*Math.PI/180,a=Math.sin(e*Math.PI*i)*t.tiltDirection;return{rotation:a*s,scaleX:1+.1*Math.abs(a),scaleY:1-.05*Math.abs(a),offsetX:10*a,offsetY:-5*Math.abs(a)}}applySlowBlink(t,e){let i=1;return i=e<.3?1-e/.3:e<.5?0:e<.8?(e-.5)/.3:1,{glow:i}}applyLook(t,e){if(!t.targetX){const e=t.params.lookDirection,i=50*t.params.lookDistance*this.scaleFactor;switch(e){case"left":t.targetX=-i,t.targetY=0;break;case"right":t.targetX=i,t.targetY=0;break;case"up":t.targetX=0,t.targetY=-i;break;case"down":t.targetX=0,t.targetY=i;break;default:{const e=Math.random()*Math.PI*2;t.targetX=Math.cos(e)*i,t.targetY=Math.sin(e)*i;break}}}let i=e;return i=e<.3?e/.3:e<.7?1:1-(e-.7)/.3,{offsetX:t.targetX*i,offsetY:t.targetY*i}}applySettle(t,e){const i=Math.sin(e*Math.PI*t.params.wobbleFreq)*Math.exp(3*-e)*20*this.scaleFactor;return{offsetY:i,scale:1+.01*i}}}class pe{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyPoint(t,e){void 0===t.pointDirection&&(t.pointDirection=Math.random()<.5?-1:1);const i=void 0!==t.params?.direction?t.params.direction:t.pointDirection,s=(t.params?.distance||40)*this.scaleFactor;let a,h;return e<.4?(a=1-Math.pow(1-e/.4,3),h=a):e<.6?(a=1,h=1):(a=Math.pow(1-(e-.6)/.4,3),h=a),{offsetX:i*s*a,offsetY:-Math.abs(.15*s*a),scale:1+.15*h,rotation:5*i*h}}applyLean(t,e){const i=t.params?.angle||15,s=t.params?.side||1,a=Math.sin(e*Math.PI),h=i*s*a;return{offsetX:10*s*this.scaleFactor*a,rotation:h}}applyReach(t,e){const i=void 0!==t.params?.direction?t.params.direction:-Math.PI/2,s=(t.params?.distance||40)*this.scaleFactor;let a;return a=e<.4?e/.4:e<.6?1:1-(e-.6)/.4,a=a*a*(3-2*a),{offsetX:Math.cos(i)*s*a,offsetY:Math.sin(i)*s*a,scale:1+.15*a}}}class de{constructor(t){this.renderer=t,this.scaleFactor=t.scaleFactor||1}applyFlashWave(t,e){t.flashWave||(t.flashWave={innerRadius:0,outerRadius:0,maxRadius:3}),t.flashWave.outerRadius=e*t.flashWave.maxRadius,t.flashWave.innerRadius=Math.max(0,(e-.1)*t.flashWave.maxRadius);const i=Math.max(0,1-.7*e);return t.flashWaveData={innerRadius:t.flashWave.innerRadius,outerRadius:t.flashWave.outerRadius,intensity:i},{glow:1+.3*i,flashWave:t.flashWaveData}}applyRain(t,e){return{offsetX:0,offsetY:0,particleEffect:"rain"}}applyGroove(t,e){const i=(t.params?.amplitude||25)*this.scaleFactor;return{offsetX:Math.sin(e*Math.PI*2)*i+Math.sin(e*Math.PI*3+.5)*i*.4,offsetY:Math.sin(e*Math.PI*4+.3)*i*.25,scale:1+.03*Math.sin(e*Math.PI*3+.7),rotation:8*Math.sin(e*Math.PI*2+.2)}}applyHeadBob(t,e){const i=(t.params?.amplitude||20)*this.scaleFactor,s=e*(t.params?.frequency||2)%1;let a;return a=s<.3?s/.3*-i:-i*(1-(s-.3)/.7),{offsetY:a,rotation:s<.3?-3:0}}applyRunningMan(t,e){const i=20*Math.sin(e*Math.PI*4)*this.scaleFactor;return{offsetX:i,offsetY:10*-Math.abs(Math.sin(e*Math.PI*8))*this.scaleFactor,rotation:.3*i,scaleY:1-.05*Math.abs(Math.sin(e*Math.PI*8))}}applyCharleston(t,e){const i=25*Math.sin(e*Math.PI*8)*this.scaleFactor;return{offsetX:i,offsetY:10*-Math.abs(Math.sin(e*Math.PI*8))*this.scaleFactor,rotation:.6*i,scaleY:1-.06*Math.abs(Math.sin(e*Math.PI*8))}}}class fe{constructor(t){this.renderer=t,this.activeGestures=new Map,this.scaleFactor=t.scaleFactor||1,this.physicalGestureAnimator=new ne(t),this.visualEffectAnimator=new re(t),this.breathGestureAnimator=new oe(t),this.movementGestureAnimator=new le(t),this.shapeTransformAnimator=new ce(t),this.expressionGestureAnimator=new ue(t),this.directionalGestureAnimator=new pe(t),this.complexAnimationAnimator=new de(t),this.gestureAnimations={bounce:{active:!1,progress:0,params:{}},pulse:{active:!1,progress:0,params:{}},shake:{active:!1,progress:0,params:{}},spin:{active:!1,progress:0,params:{}},nod:{active:!1,progress:0,params:{}},tilt:{active:!1,progress:0,params:{}},expand:{active:!1,progress:0,params:{}},contract:{active:!1,progress:0,params:{}},flash:{active:!1,progress:0,params:{}},drift:{active:!1,progress:0,params:{}},stretch:{active:!1,progress:0,params:{}},glow:{active:!1,progress:0,params:{}},flicker:{active:!1,progress:0,params:{}},vibrate:{active:!1,progress:0,params:{}},orbital:{active:!1,progress:0,params:{}},hula:{active:!1,progress:0,params:{}},wave:{active:!1,progress:0,params:{}},breathe:{active:!1,progress:0,params:{}},morph:{active:!1,progress:0,params:{}},slowBlink:{active:!1,progress:0,params:{}},look:{active:!1,progress:0,params:{}},settle:{active:!1,progress:0,params:{}},breathIn:{active:!1,progress:0,params:{}},breathOut:{active:!1,progress:0,params:{}},breathHold:{active:!1,progress:0,params:{}},breathHoldEmpty:{active:!1,progress:0,params:{}},jump:{active:!1,progress:0,params:{}},sway:{active:!1,progress:0,params:{}},float:{active:!1,progress:0,params:{}},sparkle:{active:!1,progress:0,params:{}},shimmer:{active:!1,progress:0,params:{}},wiggle:{active:!1,progress:0,params:{}},groove:{active:!1,progress:0,params:{}},point:{active:!1,progress:0,params:{}},lean:{active:!1,progress:0,params:{}},reach:{active:!1,progress:0,params:{}},headBob:{active:!1,progress:0,params:{}},orbit:{active:!1,progress:0,params:{}},rain:{active:!1,progress:0,params:{}},runningman:{active:!1,progress:0,params:{}},charleston:{active:!1,progress:0,params:{}}}}startGesture(t){const e=ae(t);if(["bounce","shake","pulse","flash","jump","slam","spin","flicker"].includes(t)&&this.renderer.specialEffects){const e={flash:1,jump:1,shake:.9,bounce:.8,pulse:.7,slam:1,spin:.8,flicker:1}[t]||.8;this.renderer.specialEffects.triggerChromaticAberration(e)}let i;i=this.renderer.gestureCompositor?this.renderer.gestureCompositor.compose(t,this.renderer.state.emotion,this.renderer.currentUndertone):e?.config||{amplitude:20,frequency:2,duration:1e3,scaleAmount:.2,glowAmount:.3,rotations:1,distance:50,angle:15,scaleTarget:1.5,glowPeak:2,scalePeak:1.1,scaleX:1.2,scaleY:.8,maxOpacity:1,minOpacity:.5,lookDirection:"random",lookDistance:1,wobbleFreq:4,squashAmount:.8,stretchAmount:1.2,jumpHeight:100,decay:!0,easing:"sine",effects:[]};let s=1e3;if(e&&e.config)if(e.config.musicalDuration)s=he.toMilliseconds(e.config.musicalDuration);else if(e.config.duration){const{duration:t}=e.config;s=t}const a=this.gestureAnimations[t];a&&(a.active=!0,a.startTime=performance.now(),a.progress=0,a.params=i,a.duration=s,"shake"===t?a.randomAngle=void 0:"drift"===t?(a.startX=void 0,a.startY=void 0,a.currentDriftAngle=void 0):"tilt"===t?a.tiltDirection=void 0:"vibrate"===t&&(a.vibrateAngles=void 0))}applyGestureAnimations(){const t=performance.now(),e={offsetX:0,offsetY:0,scale:1,rotation:0,glow:1};for(const[i,s]of Object.entries(this.gestureAnimations)){if(!s.active)continue;const a=t-s.startTime,h=s.duration||(s.params?s.params.duration:1e3);s.progress=Math.min(a/h,1);const n=this.applyEasing(s.progress,s.params.easing);let r={};switch(i){case"bounce":r=this.applyBounce(s,n);break;case"pulse":r=this.applyPulse(s,n);break;case"shake":r=this.applyShake(s,n);break;case"spin":r=this.applySpin(s,n);break;case"nod":r=this.applyNod(s,n);break;case"tilt":r=this.applyTilt(s,n);break;case"expand":r=this.applyExpand(s,n);break;case"contract":r=this.applyContract(s,n);break;case"flash":r=this.applyFlash(s,n);break;case"drift":r=this.applyDrift(s,n);break;case"stretch":r=this.applyStretch(s,n);break;case"glow":r=this.applyGlow(s,n);break;case"flicker":r=this.applyFlicker(s,n);break;case"vibrate":r=this.applyVibrate(s,n);break;case"orbital":r=this.applyOrbital(s,n);break;case"hula":r=this.applyHula(s,n);break;case"wave":r=this.applyWave(s,n);break;case"breathe":r=this.applyBreathe(s,n);break;case"morph":r=this.applyMorph(s,n);break;case"slowBlink":r=this.applySlowBlink(s,n);break;case"look":r=this.applyLook(s,n);break;case"settle":r=this.applySettle(s,n);break;case"breathIn":r=this.applyBreathIn(s,n);break;case"breathOut":r=this.applyBreathOut(s,n);break;case"breathHold":r=this.applyBreathHold(s,n);break;case"breathHoldEmpty":r=this.applyBreathHoldEmpty(s,n);break;case"jump":r=this.applyJump(s,n);break;case"sway":r=this.applySway(s,n);break;case"float":r=this.applyFloat(s,n);break;case"rain":r=this.applyRain(s,n);break;case"runningman":r=this.applyRunningMan(s,n);break;case"charleston":r=this.applyCharleston(s,n);break;case"sparkle":r=this.applySparkle(s,n);break;case"shimmer":r=this.applyShimmer(s,n);break;case"wiggle":r=this.applyWiggle(s,n);break;case"groove":r=this.applyGroove(s,n);break;case"point":r=this.applyPoint(s,n);break;case"lean":r=this.applyLean(s,n);break;case"reach":r=this.applyReach(s,n);break;case"headBob":r=this.applyHeadBob(s,n);break;case"orbit":r=this.applyOrbit(s,n)}e.offsetX+=r.offsetX||0,e.offsetY+=r.offsetY||0,e.scale*=r.scale||1,e.rotation+=r.rotation||0,e.glow=Math.max(e.glow,r.glow||1),r.flashWave&&(e.flashWave=r.flashWave),r.fireflyEffect&&(e.fireflyEffect=r.fireflyEffect,e.particleGlow=r.particleGlow,e.fireflyTime=r.fireflyTime),r.flickerEffect&&(e.flickerEffect=r.flickerEffect,e.particleGlow=r.particleGlow,e.flickerTime=r.flickerTime),r.shimmerEffect&&(e.shimmerEffect=r.shimmerEffect,e.particleGlow=r.particleGlow,e.shimmerTime=r.shimmerTime,e.shimmerWave=r.shimmerWave),r.glowEffect&&(e.glowEffect=r.glowEffect,e.particleGlow=r.particleGlow,e.glowTime=r.glowTime,e.glowProgress=r.glowProgress,e.glowEnvelope=r.glowEnvelope),s.progress>=1&&(s.active=!1,s.progress=0,s.startTime=0,"flash"===i&&(s.flashWave=null,s.flashWaveData=null),r.glowEffect&&(r.glowEffect=null,r.particleGlow=null,r.glowTime=null,r.glowProgress=null,r.glowEnvelope=null),r.fireflyEffect&&(r.fireflyEffect=null,r.particleGlow=null,r.fireflyTime=null),r.flickerEffect&&(r.flickerEffect=null,r.particleGlow=null,r.flickerTime=null),r.shimmerEffect&&(r.shimmerEffect=null,r.particleGlow=null,r.shimmerTime=null,r.shimmerWave=null))}return e}update(t){return this.applyGestureAnimations()}stopAllGestures(){Object.keys(this.gestureAnimations).forEach(t=>{const e=this.gestureAnimations[t];e.active=!1,e.startTime=0,e.progress=0,e.params=null,e.glowEffect&&(e.glowEffect=null,e.particleGlow=null,e.glowTime=null,e.glowProgress=null,e.glowEnvelope=null),e.fireflyEffect&&(e.fireflyEffect=null,e.particleGlow=null,e.fireflyTime=null),e.flickerEffect&&(e.flickerEffect=null,e.particleGlow=null,e.flickerTime=null),e.shimmerEffect&&(e.shimmerEffect=null,e.particleGlow=null,e.shimmerTime=null,e.shimmerWave=null),e.flashWave&&(e.flashWave=null,e.flashWaveData=null)}),this.activeGestures.clear()}getCurrentGesture(){const t=performance.now(),e=["orbital","hula","wave","spin"];for(const i of e){const e=this.gestureAnimations[i];if(e&&e.active){const s=ae(i),a=t-e.startTime,h=e.duration||(e.params?e.params.duration:1e3),n=Math.min(a/h,1);return{name:i,particleMotion:s?.config?.particleMotion||{type:i,strength:e.params?.strength||1},progress:n,params:e.params}}}for(const[e,i]of Object.entries(this.gestureAnimations))if(i.active){const s=ae(e),a=t-i.startTime,h=i.duration||(i.params?i.params.duration:1e3),n=Math.min(a/h,1),r={name:e,particleMotion:s?.config?.particleMotion||i.params?.particleMotion||{type:e,strength:i.params?.strength||1},progress:n,params:i.params};return"breathe"===e&&void 0!==i.breathPhase&&(r.breathPhase=i.breathPhase),r}return null}applyEasing(t,e){switch(e){case"linear":default:return t;case"quad":return t*t;case"cubic":return t*t*t;case"sine":return Math.sin(t*Math.PI/2);case"back":return t*t*(2.7*t-1.7)}}applyBounce(t,e){return this.physicalGestureAnimator.applyBounce(t,e)}applyPulse(t,e){return this.shapeTransformAnimator.applyPulse(t,e)}applyShake(t,e){return this.physicalGestureAnimator.applyShake(t,e)}applySpin(t,e){return this.movementGestureAnimator.applySpin(t,e)}applyNod(t,e){return this.expressionGestureAnimator.applyNod(t,e)}applyTilt(t,e){return this.expressionGestureAnimator.applyTilt(t,e)}applyExpand(t,e){return this.shapeTransformAnimator.applyExpand(t,e)}applyContract(t,e){return this.shapeTransformAnimator.applyContract(t,e)}applyFlash(t,e){return this.visualEffectAnimator.applyFlash(t,e)}applyDrift(t,e){return this.movementGestureAnimator.applyDrift(t,e)}applyStretch(t,e){return this.shapeTransformAnimator.applyStretch(t,e)}applyGlow(t,e){return this.visualEffectAnimator.applyGlow(t,e)}applyFlashWave(t,e){return this.complexAnimationAnimator.applyFlashWave(t,e)}applyFlicker(t,e){return this.visualEffectAnimator.applyFlicker(t,e)}applyVibrate(t,e){return this.physicalGestureAnimator.applyVibrate(t,e)}applyWave(t,e){return this.movementGestureAnimator.applyWave(t,e)}applyBreathe(t,e){return this.breathGestureAnimator.applyBreathe(t,e)}applyMorph(t,e){return this.shapeTransformAnimator.applyMorph(t,e)}applySlowBlink(t,e){return this.expressionGestureAnimator.applySlowBlink(t,e)}applyLook(t,e){return this.expressionGestureAnimator.applyLook(t,e)}applySettle(t,e){return this.expressionGestureAnimator.applySettle(t,e)}applyBreathIn(t,e){return this.breathGestureAnimator.applyBreathIn(t,e)}applyBreathOut(t,e){return this.breathGestureAnimator.applyBreathOut(t,e)}applyBreathHold(t,e){return this.breathGestureAnimator.applyBreathHold(t,e)}applyBreathHoldEmpty(t,e){return this.breathGestureAnimator.applyBreathHoldEmpty(t,e)}applyJump(t,e){return this.physicalGestureAnimator.applyJump(t,e)}applySway(t,e){return this.movementGestureAnimator.applySway(t,e)}applyRain(t,e){return this.complexAnimationAnimator.applyRain(t,e)}applyFloat(t,e){return this.movementGestureAnimator.applyFloat(t,e)}applyOrbital(t,e){return this.movementGestureAnimator.applyOrbital(t,e)}applyHula(t,e){return this.movementGestureAnimator.applyHula(t,e)}applySparkle(t,e){return this.visualEffectAnimator.applySparkle(t,e)}applyShimmer(t,e){return this.visualEffectAnimator.applyShimmer(t,e)}applyWiggle(t,e){return this.physicalGestureAnimator.applyWiggle(t,e)}applyGroove(t,e){return this.complexAnimationAnimator.applyGroove(t,e)}applyPoint(t,e){return this.directionalGestureAnimator.applyPoint(t,e)}applyLean(t,e){return this.directionalGestureAnimator.applyLean(t,e)}applyReach(t,e){return this.directionalGestureAnimator.applyReach(t,e)}applyHeadBob(t,e){return this.complexAnimationAnimator.applyHeadBob(t,e)}applyOrbit(t,e){return this.movementGestureAnimator.applyOrbit(t,e)}startBounce(){this.startGesture("bounce")}startPulse(){this.startGesture("pulse")}startShake(){this.startGesture("shake")}startSpin(){this.startGesture("spin")}startNod(){this.startGesture("nod")}startTilt(){this.startGesture("tilt")}startExpand(){this.startGesture("expand")}startContract(){this.startGesture("contract")}startFlash(){this.startGesture("flash")}startDrift(){this.startGesture("drift")}startStretch(){this.startGesture("stretch")}startGlow(){this.startGesture("glow")}startFlicker(){this.startGesture("flicker")}startVibrate(){this.startGesture("vibrate")}startOrbital(){this.startGesture("orbital")}startHula(){this.startGesture("hula")}startWave(){this.startGesture("wave")}startBreathe(){this.startGesture("breathe")}startMorph(){this.startGesture("morph")}startSlowBlink(){this.startGesture("slowBlink")}startLook(){this.startGesture("look")}startSettle(){this.startGesture("settle")}startBreathIn(){this.startGesture("breathIn")}startBreathOut(){this.startGesture("breathOut")}startBreathHold(){this.startGesture("breathHold")}startBreathHoldEmpty(){this.startGesture("breathHoldEmpty")}startJump(){this.startGesture("jump")}startSway(){this.startGesture("sway")}startFloat(){this.startGesture("float")}startRain(){this.startGesture("rain")}startRunningMan(){this.startGesture("runningman")}startCharleston(){this.startGesture("charleston")}startSparkle(){this.startGesture("sparkle")}startShimmer(){this.startGesture("shimmer")}startWiggle(){this.startGesture("wiggle")}startGroove(){this.startGesture("groove")}startPoint(){this.startGesture("point")}startLean(){this.startGesture("lean")}startReach(){this.startGesture("reach")}startHeadBob(){this.startGesture("headBob")}startOrbit(){this.startGesture("orbit")}applyRunningMan(t,e){return this.complexAnimationAnimator.applyRunningMan(t,e)}applyCharleston(t,e){return this.complexAnimationAnimator.applyCharleston(t,e)}startRunningManGesture(){this.startGesture("runningman")}startCharlestonGesture(){this.startGesture("charleston")}pauseCurrentAnimation(){const t=performance.now();for(const[,e]of Object.entries(this.gestureAnimations))e.active&&(e.pausedAt=t,e.pausedProgress=e.progress);this.isPaused=!0}resumeAnimation(){if(!this.isPaused)return;const t=performance.now();for(const[,e]of Object.entries(this.gestureAnimations))if(e.active&&e.pausedAt){const i=t-e.pausedAt;e.startTime&&(e.startTime+=i),delete e.pausedAt,delete e.pausedProgress}this.isPaused=!1}reset(){for(const[,t]of Object.entries(this.gestureAnimations))t.active=!1,t.progress=0,t.params={},delete t.startTime,delete t.pausedAt,delete t.pausedProgress;this.activeGestures.clear(),this.isPaused=!1}destroy(){this.stopAllGestures(),this.physicalGestureAnimator&&"function"==typeof this.physicalGestureAnimator.destroy&&this.physicalGestureAnimator.destroy(),this.visualEffectAnimator&&"function"==typeof this.visualEffectAnimator.destroy&&this.visualEffectAnimator.destroy(),this.breathGestureAnimator&&"function"==typeof this.breathGestureAnimator.destroy&&this.breathGestureAnimator.destroy(),this.movementGestureAnimator&&"function"==typeof this.movementGestureAnimator.destroy&&this.movementGestureAnimator.destroy(),this.shapeTransformAnimator&&"function"==typeof this.shapeTransformAnimator.destroy&&this.shapeTransformAnimator.destroy(),this.expressionGestureAnimator&&"function"==typeof this.expressionGestureAnimator.destroy&&this.expressionGestureAnimator.destroy(),this.directionalGestureAnimator&&"function"==typeof this.directionalGestureAnimator.destroy&&this.directionalGestureAnimator.destroy(),this.complexAnimationAnimator&&"function"==typeof this.complexAnimationAnimator.destroy&&this.complexAnimationAnimator.destroy(),this.physicalGestureAnimator=null,this.visualEffectAnimator=null,this.breathGestureAnimator=null,this.movementGestureAnimator=null,this.shapeTransformAnimator=null,this.expressionGestureAnimator=null,this.directionalGestureAnimator=null,this.complexAnimationAnimator=null,this.gestureAnimations=null,this.activeGestures.clear(),this.activeGestures=null,this.renderer=null,this.scaleFactor=null,this.isPaused=!1}}class me{constructor(){this.colorTransition=null}applyUndertoneModifiers(t,e){return e}applyUndertoneToColor(t,e){if(e&&"object"==typeof e&&void 0!==e.weight){const{weight:i}=e,s=e.type||"clear";if("clear"===s||0===i)return t;const a=this.applyUndertoneSaturation(t,s),h=this.hexToRgb(t),n=this.hexToRgb(a),r=Math.round(h.r+(n.r-h.r)*i),o=Math.round(h.g+(n.g-h.g)*i),l=Math.round(h.b+(n.b-h.b)*i);return this.rgbToHex(r,o,l)}return e&&"clear"!==e?this.applyUndertoneSaturation(t,e):t}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}rgbToHsl(t,e,i){t/=255,e/=255,i/=255;const s=Math.max(t,e,i),a=Math.min(t,e,i),h=(s+a)/2;let n,r;if(s===a)n=r=0;else{const o=s-a;switch(r=h>.5?o/(2-s-a):o/(s+a),s){case t:n=((e-i)/o+(e<i?6:0))/6;break;case e:n=((i-t)/o+2)/6;break;case i:n=((t-e)/o+4)/6}}return{h:360*n,s:100*r,l:100*h}}hslToHex(t,e,i){let s,a,h;if(t/=360,i/=100,0==(e/=100))s=a=h=i;else{const n=(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),r=i<.5?i*(1+e):i+e-i*e,o=2*i-r;s=n(o,r,t+1/3),a=n(o,r,t),h=n(o,r,t-1/3)}const n=t=>{const e=Math.round(255*t).toString(16);return 1===e.length?`0${e}`:e};return`#${n(s)}${n(a)}${n(h)}`}applyUndertoneSaturation(t,e){const i=this.hexToRgb(t),s=this.rgbToHsl(i.r,i.g,i.b),a={intense:1.5,confident:1.3,energetic:1.2,upbeat:1.2,nervous:1.15,mellow:.8,tired:.8,subdued:.5}[e]||1;return s.s=Math.min(100,s.s*a),this.hslToHex(s.h,s.s,s.l)}rgbToHex(t,e,i){const s=t=>{const e=Math.round(t).toString(16);return 1===e.length?`0${e}`:e};return`#${s(t)}${s(e)}${s(i)}`}startColorTransition(t,e,i=1500){this.currentColor===t&&this.currentIntensity===e||(this.colorTransition={active:!0,fromColor:this.currentColor||"#ffffff",toColor:t,fromIntensity:this.currentIntensity||1,toIntensity:e,progress:0,startTime:performance.now(),duration:i})}updateColorTransition(t){if(!this.colorTransition||!this.colorTransition.active)return null;const e=performance.now()-this.colorTransition.startTime,i=Math.min(e/this.colorTransition.duration,1),s=1-Math.pow(1-i,2),a=this.hexToRgb(this.colorTransition.fromColor),h=this.hexToRgb(this.colorTransition.toColor),n=Math.round(a.r+(h.r-a.r)*s),r=Math.round(a.g+(h.g-a.g)*s),o=Math.round(a.b+(h.b-a.b)*s),l=this.rgbToHex(n,r,o),c=this.colorTransition.fromIntensity+(this.colorTransition.toIntensity-this.colorTransition.fromIntensity)*s;return this.currentColor=l,this.currentIntensity=c,i>=1&&(this.colorTransition.active=!1),{color:l,intensity:c}}}class Me{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvasManager?.canvas||t.canvas,this.recordingActive=!1,this.sleepMode=!1,this.speakingActive=!1,this.speakingRings=[],this.ringSpawnTimer=0,this.ringSpawnInterval=300,this.maxRings=3,this.sleepZ=[],this.sparkles=[],this.chromaticAberration={active:!1,intensity:0,targetIntensity:0,fadeSpeed:.01,maxOffset:30},this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}renderRecordingGlow(t,e,i,s){const{ctx:a}=this,h=2.5*i,n=a.createRadialGradient(t,e,0,t,e,h);n.addColorStop(0,`rgba(255, 0, 0, ${.3*s})`),n.addColorStop(.5,`rgba(255, 0, 0, ${.15*s})`),n.addColorStop(1,"rgba(255, 0, 0, 0)"),a.save(),a.globalCompositeOperation="screen",a.fillStyle=n,a.fillRect(t-h,e-h,2*h,2*h),a.restore()}renderRecordingIndicator(t,e){const i=Date.now()/1e3,s=.8+.2*Math.sin(2*i);this.ctx.save(),this.ctx.translate(t,e),this.ctx.shadowBlur=this.scaleValue(15),this.ctx.shadowColor=`rgba(255, 0, 0, ${.8*s})`;const a=this.scaleValue(80);this.ctx.font=`italic 900 ${a}px "Poppins", sans-serif`,this.ctx.fillStyle=`rgba(255, 0, 0, ${s})`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText("REC",0,0),this.ctx.shadowBlur=0,this.ctx.font=`italic 900 ${a-1}px "Poppins", sans-serif`,this.ctx.fillStyle=`rgba(255, 255, 255, ${.3*s})`,this.ctx.fillText("REC",-.5,-.5),this.ctx.restore()}renderSleepIndicator(t,e,i){if(this.ringSpawnTimer+=i,this.ringSpawnTimer>=2e3&&this.sleepZ.length<3){const i=["300","500","700","900"],s=i[Math.floor(Math.random()*i.length)],a=Math.random()>.5?"Z":"z";this.sleepZ.push({x:t+Math.random()*this.scaleValue(30)-this.scaleValue(15),y:e+this.scaleValue(80),size:this.scaleValue(3*(24+8*Math.random())),opacity:1,speed:-.025,drift:Math.random()*this.scaleValue(20)-this.scaleValue(10),lifetime:0,rotation:30*Math.random()-15,text:a,weight:s}),this.ringSpawnTimer=0}this.sleepZ=this.sleepZ.filter(t=>{if(t.lifetime+=i,t.y+=t.speed*i,t.x+=Math.sin(8e-4*t.lifetime)*t.drift*.008,t.rotation+=.01*i,t.lifetime<2e3?t.opacity=1:t.lifetime<4e3?t.opacity=1-(t.lifetime-2e3)/2e3:t.opacity=0,t.opacity>.01){this.ctx.save(),this.ctx.translate(t.x,t.y),this.ctx.rotate(t.rotation*Math.PI/180);const e=this.renderer.state.glowColor||"#4a90e2";this.ctx.shadowBlur=this.scaleValue(15),this.ctx.shadowColor=this.hexToRgba(e,.5*t.opacity);const i=this.ctx.createLinearGradient(-t.size/2,-t.size/2,t.size/2,t.size/2);return i.addColorStop(0,this.hexToRgba(e,t.opacity)),i.addColorStop(.5,this.hexToRgba("#ffffff",.9*t.opacity)),i.addColorStop(1,this.hexToRgba(e,.7*t.opacity)),this.ctx.font=`italic ${t.weight||"900"} ${t.size}px 'Poppins', sans-serif`,this.ctx.fillStyle=i,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t.text||"Z",0,0),this.ctx.shadowBlur=0,this.ctx.font=`italic ${t.weight||"900"} ${.9*t.size}px 'Poppins', sans-serif`,this.ctx.fillStyle=this.hexToRgba("#ffffff",.3*t.opacity),this.ctx.fillText(t.text||"Z",-1,-1),this.ctx.restore(),!0}return!1})}renderSpeakingRings(t,e,i,s){this.ringSpawnTimer+=s,this.ringSpawnTimer>=this.ringSpawnInterval&&this.speakingRings.length<this.maxRings&&(this.speakingRings.push({radius:i,opacity:.8,speed:.15}),this.ringSpawnTimer=0),this.speakingRings=this.speakingRings.filter(a=>(a.radius+=a.speed*s,a.opacity=Math.max(0,.8*(1-(a.radius-i)/(2*i))),a.opacity>.01&&(this.ctx.strokeStyle=this.hexToRgba(this.renderer.state.glowColor,a.opacity),this.ctx.lineWidth=this.scaleValue(2),this.ctx.beginPath(),this.ctx.arc(t,e,a.radius,0,2*Math.PI),this.ctx.stroke(),!0)))}startRecording(){this.recordingActive=!0}stopRecording(){this.recordingActive=!1}enterSleepMode(){this.sleepMode=!0}wakeUp(){this.sleepMode=!1}startSpeaking(){this.speakingActive=!0}stopSpeaking(){this.speakingActive=!1}createSparkle(t,e,i={}){this.sparkles.push({x:t,y:e,vx:i.velocity?.x||0,vy:i.velocity?.y||0,size:i.size||3,color:i.color||"hsl(50, 100%, 70%)",lifetime:i.lifetime||1e3,maxLifetime:i.lifetime||1e3,rotation:Math.random()*Math.PI*2,rotationSpeed:.2*(Math.random()-.5)})}renderSparkles(){const{ctx:t}=this;this.sparkles.forEach(e=>{const i=1-e.lifetime/e.maxLifetime,s=1-i;t.save(),t.translate(e.x,e.y),t.rotate(e.rotation);const a=this.scaleValue(e.size*(1-.5*i));t.beginPath();const h=a,n=.38*a;for(let e=0;e<10;e++){const i=e*Math.PI/5-Math.PI/2,s=e%2==0?h:n;0===e?t.moveTo(Math.cos(i)*s,Math.sin(i)*s):t.lineTo(Math.cos(i)*s,Math.sin(i)*s)}t.closePath(),t.shadowBlur=this.scaleValue(10),t.shadowColor=e.color,t.fillStyle=e.color.replace("70%",70+30*i+"%").replace(")",`, ${s})`).replace("hsl","hsla"),t.fill(),t.restore()})}triggerChromaticAberration(t=.8){this.chromaticAberration.active=!0,this.chromaticAberration.targetIntensity=Math.min(1,t),this.chromaticAberration.intensity=this.chromaticAberration.targetIntensity;const e=document.getElementById("emotive-canvas")||document.querySelector("canvas")||this.canvas;if(e){if(e.style.animation="none",!document.getElementById("chromatic-styles")){const t=document.createElement("style");t.id="chromatic-styles",t.textContent="\n @keyframes chromaticGlitch {\n 0% {\n filter: none;\n transform: translateX(0);\n }\n 15% {\n filter: drop-shadow(-2px 0 0 rgba(255,0,0,0.7)) drop-shadow(2px 0 0 rgba(0,255,255,0.7));\n transform: translateX(-0.5px);\n }\n 30% {\n filter: drop-shadow(-3px 0 0 rgba(255,0,0,0.8)) drop-shadow(3px 0 0 rgba(0,255,255,0.8));\n transform: translateX(0.5px);\n }\n 45% {\n filter: drop-shadow(-2px 0 0 rgba(255,0,0,0.6)) drop-shadow(2px 0 0 rgba(0,255,255,0.6));\n transform: translateX(-0.3px);\n }\n 60% {\n filter: drop-shadow(-1px 0 0 rgba(255,0,0,0.4)) drop-shadow(1px 0 0 rgba(0,255,255,0.4));\n transform: translateX(0.2px);\n }\n 100% {\n filter: none;\n transform: translateX(0);\n }\n }\n ",document.head.appendChild(t)}e.style.animation=`chromaticGlitch ${300+200*t}ms ease-out`}}applyChromaticAberration(t,e){if(!this.chromaticAberration.active||this.chromaticAberration.intensity<=0)return;const{intensity:i}=this.chromaticAberration,s=this.scaleValue(this.chromaticAberration.maxOffset*i),a=t.globalCompositeOperation;t.save(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.globalCompositeOperation="source-over",t.filter="url(#red-channel)",t.drawImage(e,-s,0),t.globalCompositeOperation="screen",t.filter="url(#green-channel)",t.drawImage(e,0,0),t.globalCompositeOperation="screen",t.filter="url(#blue-channel)",t.drawImage(e,s,0),t.filter="none",t.globalCompositeOperation=a,t.restore()}applyChromaticAberrationSimple(t,e,i,s,a){if(!this.chromaticAberration.active||this.chromaticAberration.intensity<=0)return void a();const{intensity:h}=this.chromaticAberration,n=this.scaleValue(this.chromaticAberration.maxOffset*h);t.save(),t.globalCompositeOperation="source-over",t.translate(-n,0),t.globalAlpha=.33,t.fillStyle="#ff0000",t.filter="brightness(3)",a(),t.translate(n,0),t.globalCompositeOperation="screen",t.globalAlpha=.33,t.fillStyle="#00ff00",a(),t.translate(n,0),t.globalAlpha=.33,t.fillStyle="#0000ff",a(),t.restore()}update(t){this.sparkles=this.sparkles.filter(e=>(e.x+=e.vx,e.y+=e.vy,e.rotation+=e.rotationSpeed,e.lifetime-=t,e.vy+=.1,e.lifetime>0)),this.chromaticAberration.active&&(this.chromaticAberration.intensity-=this.chromaticAberration.fadeSpeed,this.chromaticAberration.intensity<=0&&(this.chromaticAberration.intensity=0,this.chromaticAberration.active=!1,this.chromaticAberration.targetIntensity=0))}destroy(){this.speakingRings=[],this.sleepZ=[],this.sparkles=[],this.recordingActive=!1,this.sleepMode=!1,this.speakingActive=!1,this.chromaticAberration.active=!1,this.chromaticAberration.intensity=0,this.chromaticAberration.targetIntensity=0,this.ringSpawnTimer=0,this.renderer=null,this.ctx=null,this.canvas=null}}class ge{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.blinking=!1,this.blinkingEnabled=!0,this.blinkTimer=0,this.nextBlinkTime=this.getRandomBlinkTime(),this.squintAmount=0,this.eyeClose=null,this.eyeOpen=null,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}update(t){this.blinking&&(this.blinkTimer+=t,this.blinkTimer>=150&&(this.blinking=!1,this.blinkTimer=0,this.nextBlinkTime=Date.now()+this.getRandomBlinkTime())),this.blinkingEnabled&&!this.blinking&&Date.now()>=this.nextBlinkTime&&this.startBlink()}startBlink(){this.blinkingEnabled&&(this.blinking=!0,this.blinkTimer=0)}getRandomBlinkTime(){return 3e3+4e3*Math.random()}getBlinkScale(){if(!this.blinking)return 1;const t=Math.min(this.blinkTimer/150,1);return 1-.7*Math.sin(t*Math.PI)}drawEyes(t,e,i,s,a={}){const{ctx:h}=this,n=a.eyeOpenness||1,r=a.eyeExpression||"neutral";if("neutral"===s||n<=0)return;h.save(),h.strokeStyle="rgba(0, 0, 0, 0.3)",h.lineWidth=this.scaleValue(2),h.lineCap="round";const o=.4*i,l=e-.1*i,c=.25*i;switch(r){case"happy":this.drawHappyEyes(h,t,l,o,c,n);break;case"sad":this.drawSadEyes(h,t,l,o,c,n);break;case"angry":this.drawAngryEyes(h,t,l,o,c,n);break;case"surprised":this.drawSurprisedEyes(h,t,l,o,c,n);break;case"focused":this.drawFocusedEyes(h,t,l,o,c,n);break;case"sleepy":this.drawSleepyEyes(h,t,l,o,c,n);break;case"suspicious":this.drawSuspiciousEyes(h,t,l,o,c,n)}h.restore()}drawHappyEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i,a,.2*Math.PI,.8*Math.PI,!1),t.stroke(),t.beginPath(),t.arc(e+s,i,a,.2*Math.PI,.8*Math.PI,!1),t.stroke()}drawSadEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i+.5*a,a,1.2*Math.PI,1.8*Math.PI,!1),t.stroke(),t.beginPath(),t.arc(e+s,i+.5*a,a,1.2*Math.PI,1.8*Math.PI,!1),t.stroke()}drawAngryEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i-.3*a),t.lineTo(e-s+.5*a,i+.3*a),t.stroke(),t.beginPath(),t.moveTo(e+s+a,i-.3*a),t.lineTo(e+s-.5*a,i+.3*a),t.stroke()}drawSurprisedEyes(t,e,i,s,a,h){t.beginPath(),t.arc(e-s,i,1.2*a,0,2*Math.PI),t.stroke(),t.beginPath(),t.arc(e+s,i,1.2*a,0,2*Math.PI),t.stroke()}drawFocusedEyes(t,e,i,s,a,h){t.fillStyle="rgba(0, 0, 0, 0.4)",t.beginPath(),t.arc(e-s,i,.3*a,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e+s,i,.3*a,0,2*Math.PI),t.fill()}drawSleepyEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i),t.lineTo(e-s+a,i),t.stroke(),t.beginPath(),t.moveTo(e+s-a,i),t.lineTo(e+s+a,i),t.stroke()}drawSuspiciousEyes(t,e,i,s,a,h){t.beginPath(),t.moveTo(e-s-a,i),t.lineTo(e-s+.7*a,i),t.stroke(),t.beginPath(),t.arc(e+s,i,.8*a,.1*Math.PI,.9*Math.PI,!1),t.stroke()}setBlinkingEnabled(t){this.blinkingEnabled=t,t||(this.blinking=!1,this.blinkTimer=0)}setSquintAmount(t){this.squintAmount=Math.max(0,Math.min(1,t))}forceBlink(){this.startBlink()}}class ye{constructor(t){this.renderer=t,this.breathingSpeed=.42,this.breathingDepth=.08,this.breathingPhase=0,this.breathRate=1,this.breathDepth=this.breathingDepth,this.breathRateMult=1,this.breathDepthMult=1,this.breathIrregular=!1,this.customScale=null,this.emotionBreathPatterns={happy:{rate:1.1,depth:1.2},sad:{rate:.8,depth:.7},angry:{rate:1.4,depth:1.3},calm:{rate:.7,depth:.9},excited:{rate:1.5,depth:1.4},focused:{rate:.9,depth:.6},neutral:{rate:1,depth:1},love:{rate:1.2,depth:1.3},surprised:{rate:1.3,depth:1.1},confused:{rate:1.1,depth:.9},amused:{rate:1.2,depth:1.1},bored:{rate:.6,depth:.8},tired:{rate:.5,depth:1.2},anxious:{rate:1.6,depth:.9},determined:{rate:1.1,depth:1},proud:{rate:.9,depth:1.3},content:{rate:.8,depth:1},hopeful:{rate:1,depth:1.1},intrigued:{rate:1.1,depth:.8},embarrassed:{rate:1.3,depth:.7},grateful:{rate:.9,depth:1.1},inspired:{rate:1,depth:1.3},silly:{rate:1.4,depth:1.2},sleepy:{rate:.3,depth:1.4}}}update(t,e,i={}){i=i||{};const s=this.emotionBreathPatterns[e]||{rate:1,depth:1},a=i?.breathRateMult||1,h=i?.breathDepthMult||1;this.breathRate=s.rate*this.breathRateMult*a,this.breathDepth=this.breathingDepth*s.depth*this.breathDepthMult*h;let n=this.breathingSpeed*this.breathRate*(t/1e3);this.breathIrregular&&i?.breathIrregular&&(n*=.8+.4*Math.sin(3e-4*Date.now())),this.breathingPhase+=n,this.breathingPhase>2*Math.PI&&(this.breathingPhase-=2*Math.PI)}getBreathingScale(){return null!==this.customScale?this.customScale:1+Math.sin(this.breathingPhase)*this.breathDepth}setCustomScale(t){this.customScale=t}setBreathingSpeed(t){this.breathingSpeed=t}setBreathingDepth(t){this.breathingDepth=Math.max(0,Math.min(1,t))}setBreathRateMultiplier(t){this.breathRateMult=t}setBreathDepthMultiplier(t){this.breathDepthMult=t}setIrregularBreathing(t){this.breathIrregular=t}reset(){this.breathingPhase=0,this.breathRate=1,this.breathDepth=this.breathingDepth,this.breathRateMult=1,this.breathDepthMult=1,this.breathIrregular=!1,this.customScale=null}holdBreath(t=!1){this.customScale=t?.92:1.08}releaseBreath(){this.customScale=null}getBreathingInfo(){return{phase:this.breathingPhase,rate:this.breathRate,depth:this.breathDepth,scale:this.getBreathingScale(),isCustom:null!==this.customScale,isIrregular:this.breathIrregular}}}const be=new class{constructor(){this.cache=new Map,this.stats={hits:0,misses:0,evictions:0},this.maxSize=100,this.ttl=6e4,this.accessOrder=[],this.cleanupInterval=setInterval(()=>{this.clearExpired()},6e4)}generateKey(t,e){if("radial"===t){const{x0:t,y0:i,r0:s,x1:a,y1:h,r1:n,stops:r}=e;return`radial:${t},${i},${s},${a},${h},${n}:${r.map(t=>`${t.offset}:${t.color}`).join("|")}`}if("linear"===t){const{x0:t,y0:i,x1:s,y1:a,stops:h}=e;return`linear:${t},${i},${s},${a}:${h.map(t=>`${t.offset}:${t.color}`).join("|")}`}return null}getRadialGradient(t,e,i,s,a,h,n,r){const o=this.generateKey("radial",{x0:e,y0:i,r0:s,x1:a,y1:h,r1:n,stops:r}),l=this.cache.get(o);if(l&&Date.now()-l.timestamp<this.ttl)return this.stats.hits++,this.updateAccessOrder(o),l.gradient;this.stats.misses++;const c=t.createRadialGradient(e,i,s,a,h,n);return r.forEach(t=>{c.addColorStop(t.offset,t.color)}),this.set(o,c),c}getLinearGradient(t,e,i,s,a,h){const n=this.generateKey("linear",{x0:e,y0:i,x1:s,y1:a,stops:h}),r=this.cache.get(n);if(r&&Date.now()-r.timestamp<this.ttl)return this.stats.hits++,this.updateAccessOrder(n),r.gradient;this.stats.misses++;const o=t.createLinearGradient(e,i,s,a);return h.forEach(t=>{o.addColorStop(t.offset,t.color)}),this.set(n,o),o}set(t,e){this.cache.size>=this.maxSize&&!this.cache.has(t)&&this.evictLRU(),this.cache.set(t,{gradient:e,timestamp:Date.now()}),this.updateAccessOrder(t)}updateAccessOrder(t){const e=this.accessOrder.indexOf(t);e>-1&&this.accessOrder.splice(e,1),this.accessOrder.push(t)}evictLRU(){if(this.accessOrder.length>0){const t=this.accessOrder.shift();this.cache.delete(t),this.stats.evictions++}}clear(){this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.cache.clear(),this.accessOrder=[]}clearExpired(){const t=Date.now(),e=[];for(const[i,s]of this.cache.entries())t-s.timestamp>=this.ttl&&e.push(i);e.forEach(t=>{this.cache.delete(t);const e=this.accessOrder.indexOf(t);e>-1&&this.accessOrder.splice(e,1)})}destroy(){this.clear()}getStats(){const t=this.stats.hits+this.stats.misses>0?(this.stats.hits/(this.stats.hits+this.stats.misses)*100).toFixed(2):0;return{size:this.cache.size,maxSize:this.maxSize,hits:this.stats.hits,misses:this.stats.misses,evictions:this.stats.evictions,hitRate:`${t}%`}}createHelper(t){return{radial:(e,i,s,a,h,n,r)=>this.getRadialGradient(t,e,i,s,a,h,n,r),linear:(e,i,s,a,h)=>this.getLinearGradient(t,e,i,s,a,h)}}};class we{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.glowIntensity=1,this.glowColor="#4a90e2",this.targetGlowColor="#4a90e2",this.glowColorTransition=0,this.glowColorTransitionSpeed=.05,this.offscreenCanvas=null,this.offscreenCtx=null,this.cachedGlowColor=null,this.cachedGlowRadius=0,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i),this.initOffscreenCanvas()}initOffscreenCanvas(){this.offscreenCanvas=document.createElement("canvas"),this.offscreenCtx=this.offscreenCanvas.getContext("2d")}updateOffscreenSize(t){this.offscreenCanvas.width===t&&this.offscreenCanvas.height===t||(this.offscreenCanvas.width=t,this.offscreenCanvas.height=t,this.cachedGlowColor=null)}renderGlow(t,e,i,s={}){const{ctx:a}=this,h=s.color||this.glowColor,n=void 0!==s.intensity?s.intensity:this.glowIntensity;n<.01||this.renderGlowDirect(a,t,e,i,h,n)}cacheGlowGradient(t,e){const i=this.offscreenCtx,s=e;this.updateOffscreenSize(2*e),i.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height);const a=be.getRadialGradient(i,s,s,0,s,s,e,[{offset:0,color:this.hexToRgba(t,.4)},{offset:.3,color:this.hexToRgba(t,.2)},{offset:.6,color:this.hexToRgba(t,.1)},{offset:1,color:this.hexToRgba(t,0)}]);i.fillStyle=a,i.fillRect(0,0,2*e,2*e),this.cachedGlowColor=t,this.cachedGlowRadius=e}renderGlowDirect(t,e,i,s,a,h){t.save(),t.globalCompositeOperation="screen";const n=[];for(let t=0;t<=20;t++){const e=t/20,i=.6*Math.pow(1-e,2.2),s=Math.max(0,Math.min(1,i*h));n.push({offset:e,color:this.hexToRgba(a,s)})}const r=be.getRadialGradient(t,e,i,0,e,i,s,n);t.fillStyle=r,t.beginPath(),t.arc(e,i,s,0,2*Math.PI),t.fill(),t.restore()}renderRecordingGlow(t,e,i,s){const{ctx:a}=this,h=2.5*i,n=be.getRadialGradient(a,t,e,0,t,e,h,[{offset:0,color:`rgba(255, 0, 0, ${.3*s})`},{offset:.5,color:`rgba(255, 0, 0, ${.15*s})`},{offset:1,color:"rgba(255, 0, 0, 0)"}]);a.save(),a.globalCompositeOperation="screen",a.fillStyle=n,a.fillRect(t-h,e-h,2*h,2*h),a.restore()}updateGlowColor(t,e){this.targetGlowColor!==t&&(this.targetGlowColor=t,this.glowColorTransition=0),this.glowColorTransition<1&&(this.glowColorTransition=Math.min(1,this.glowColorTransition+this.glowColorTransitionSpeed),this.glowColor=this.lerpColor(this.glowColor,this.targetGlowColor,this.glowColorTransition))}lerpColor(t,e,i){const s=this.hexToRgb(t),a=this.hexToRgb(e);return`#${((1<<24)+(Math.round(s.r+(a.r-s.r)*i)<<16)+(Math.round(s.g+(a.g-s.g)*i)<<8)+Math.round(s.b+(a.b-s.b)*i)).toString(16).slice(1)}`}hexToRgb(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:0,g:0,b:0}}setGlowIntensity(t){this.glowIntensity=Math.max(0,Math.min(1,t))}setGlowColor(t){this.glowColor=t,this.targetGlowColor=t,this.glowColorTransition=1}destroy(){this.offscreenCanvas&&(this.offscreenCtx&&(this.offscreenCtx.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),this.offscreenCtx=null),this.offscreenCanvas.width=0,this.offscreenCanvas.height=0,this.offscreenCanvas=null),this.cachedGlowColor=null,this.cachedGlowRadius=0}}class ve{constructor(t){this.renderer=t,this.ctx=t.ctx,this.canvas=t.canvas,this.coreColor="#FFFFFF",this.coreOpacity=1,this.coreBorderWidth=0,this.coreBorderColor=null,this.shapePoints=null,this.isMorphing=!1,this.scaleValue=e=>t.scaleValue(e),this.hexToRgba=(e,i)=>t.hexToRgba(e,i)}renderCore(t,e,i,s={}){const{ctx:a}=this,h=s.scaleX||1,n=s.scaleY||1,r=s.rotation||0,o=void 0!==s.opacity?s.opacity:this.coreOpacity,l=s.color||this.coreColor,c=s.shapePoints||this.shapePoints;a.save(),a.translate(t,e),0!==r&&a.rotate(r),a.scale(h,n),a.fillStyle=this.hexToRgba(l,o),c&&c.length>0?this.drawMorphedShape(a,c,i):this.drawCircle(a,i),this.coreBorderWidth>0&&this.coreBorderColor&&(a.strokeStyle=this.coreBorderColor,a.lineWidth=this.scaleValue(this.coreBorderWidth),a.stroke()),a.restore()}drawDropShadow(t,e,i){t.save();const s=this.scaleValue(2);if(t.translate(0,s),i&&i.length>32)t.fillStyle="rgba(0, 0, 0, 0.15)",t.beginPath(),t.arc(0,0,1.05*e,0,2*Math.PI),t.fill();else{const s=be.getRadialGradient(t,0,0,.7*e,0,0,1.2*e,[{offset:0,color:"rgba(0, 0, 0, 0.2)"},{offset:.8,color:"rgba(0, 0, 0, 0.1)"},{offset:1,color:"rgba(0, 0, 0, 0)"}]);if(t.fillStyle=s,t.beginPath(),i){const e=1.1,s=i.length>20?2:1;t.moveTo(i[0].x*e,i[0].y*e);for(let a=s;a<i.length;a+=s)t.lineTo(i[a].x*e,i[a].y*e);t.closePath()}else t.arc(0,0,1.1*e,0,2*Math.PI);t.fill()}t.restore()}drawCircle(t,e){t.beginPath(),t.arc(0,0,e,0,2*Math.PI),t.fill()}drawMorphedShape(t,e,i){!e||e.length<3?this.drawCircle(t,i):(t.beginPath(),e.forEach((e,i)=>{0===i?t.moveTo(e.x,e.y):t.lineTo(e.x,e.y)}),t.closePath(),t.fill())}renderSleepyCore(t,e,i){const{ctx:s}=this;s.save(),s.translate(t,e),s.scale(1,.85),s.fillStyle="#FFFFFF",s.beginPath(),s.arc(0,0,i,0,2*Math.PI),s.fill(),s.restore()}renderGlitchedCore(t,e,i,s){const{ctx:a}=this;a.save(),[{x:-2,y:0,alpha:.3},{x:2,y:0,alpha:.3},{x:0,y:-1,alpha:.2}].forEach(h=>{a.fillStyle=this.hexToRgba("#FFFFFF",h.alpha*s),a.beginPath(),a.arc(t+h.x*s*this.scaleValue(5),e+h.y*s*this.scaleValue(5),i,0,2*Math.PI),a.fill()}),a.fillStyle="#FFFFFF",a.beginPath(),a.arc(t,e,i,0,2*Math.PI),a.fill(),a.restore()}setShapePoints(t){this.shapePoints=t,this.isMorphing=t&&t.length>0}clearShapePoints(){this.shapePoints=null,this.isMorphing=!1}setCoreColor(t){this.coreColor=t}setCoreOpacity(t){this.coreOpacity=Math.max(0,Math.min(1,t))}setCoreBorder(t,e){this.coreBorderWidth=t,this.coreBorderColor=e}getCoreInfo(){return{color:this.coreColor,opacity:this.coreOpacity,hasBorder:this.coreBorderWidth>0,isMorphing:this.isMorphing,shapePointCount:this.shapePoints?this.shapePoints.length:0}}}class Se{renderSunEffects(t,e,i,s,a){const h=Date.now()/100;if(t.save(),t.translate(e,i),a.texture&&(void 0===a.textureOpacity||a.textureOpacity>0)){t.save(),t.globalCompositeOperation="screen",t.globalAlpha=void 0!==a.textureOpacity?a.textureOpacity:1;const e=.05*h*(a.turbulence||.3)/.3,i=t.createRadialGradient(Math.sin(e)*s*.15,Math.cos(.7*e)*s*.15,.2*s,0,0,s);i.addColorStop(0,"rgba(255, 255, 200, 0)"),i.addColorStop(.4,"rgba(255, 200, 100, 0.1)"),i.addColorStop(.7,"rgba(255, 150, 50, 0.08)"),i.addColorStop(1,"rgba(255, 100, 30, 0.05)"),t.fillStyle=i,t.beginPath(),t.arc(0,0,s,0,2*Math.PI),t.fill(),t.restore()}const n=void 0!==a.coronaOpacity?a.coronaOpacity:1;if(n>0){t.save(),t.globalCompositeOperation="screen";const e=t.createRadialGradient(0,0,.5*s,0,0,1.1*s);e.addColorStop(0,`rgba(255, 255, 255, ${.8*n})`),e.addColorStop(.3,`rgba(255, 250, 200, ${.6*n})`),e.addColorStop(.5,`rgba(255, 200, 100, ${.4*n})`),e.addColorStop(.7,`rgba(255, 150, 50, ${.2*n})`),e.addColorStop(1,"rgba(255, 100, 20, 0)"),t.fillStyle=e,t.beginPath(),t.arc(0,0,1.1*s,0,2*Math.PI),t.fill();for(let e=0;e<2;e++){const i=1.3+.4*e,a=(.35-.15*e)*n,r=.05*Math.sin(.1*h+e),o=t.createRadialGradient(0,0,s*(.9+r),0,0,s*(i+r));o.addColorStop(0,"rgba(255, 255, 200, 0)"),o.addColorStop(.4,`rgba(255, 200, 100, ${.5*a})`),o.addColorStop(.7,`rgba(255, 150, 50, ${a})`),o.addColorStop(.9,`rgba(255, 100, 30, ${.5*a})`),o.addColorStop(1,"rgba(255, 50, 10, 0)"),t.fillStyle=o,t.beginPath(),t.arc(0,0,s*(i+r),0,2*Math.PI),t.fill()}t.restore()}if(a.flares){t.save();const e=Math.sin(.08*h),i=Math.sin(.12*h),a=Math.sin(.16*h),n=t.createLinearGradient(0,-s,0,3*-s);n.addColorStop(0,"rgba(255, 255, 230, 0.4)"),n.addColorStop(.2,"rgba(255, 220, 150, 0.25)"),n.addColorStop(.5,"rgba(255, 180, 80, 0.15)"),n.addColorStop(.8,"rgba(255, 120, 40, 0.08)"),n.addColorStop(1,"rgba(255, 60, 20, 0)"),t.fillStyle=n,t.globalCompositeOperation="screen",t.beginPath();const r=(e,i,a,h)=>{const n=Math.cos(e),r=Math.sin(e),o=n*s,l=r*s,c=n*(s+i),u=r*(s+i),p=-r*a*.5,d=n*a*.5,f=h*a*.3;t.moveTo(o-p,l-d),t.quadraticCurveTo(.5*(o+c)+p*f,.5*(l+u)+d*f,c,u),t.quadraticCurveTo(.5*(o+c)-p*f,.5*(l+u)-d*f,o+p,l+d)};for(let t=0;t<8;t++)r(t/8*Math.PI*2+.1*e,s*(1.8+.4*Math.sin(.1*h+.5*t)),.18*s,Math.sin(.15*h+t));for(let t=0;t<12;t++)r((t+.5)/12*Math.PI*2+.08*i,s*(1.2+.3*Math.sin(.13*h+.7*t)),.12*s,Math.sin(.18*h+1.2*t));for(let t=0;t<15;t++)r(t/15*Math.PI*2+.05*a,s*(.7+.25*Math.sin(.17*h+.9*t)),.08*s,Math.sin(.2*h+1.5*t));for(let e=0;e<15;e++){const i=(e+.25)/15*Math.PI*2,a=s*(.4+.2*Math.sin(.22*h+e)),n=.06*s,r=Math.cos(i),o=Math.sin(i),l=r*s,c=o*s,u=r*(s+a),p=o*(s+a),d=-o*n*.5,f=r*n*.5;t.moveTo(l-d,c-f),t.lineTo(u,p),t.lineTo(l+d,c+f)}t.fill(),t.restore()}const r=t.createRadialGradient(0,0,.95*s,0,0,1.05*s);r.addColorStop(0,"rgba(255, 255, 255, 0)"),r.addColorStop(.7,"rgba(255, 255, 200, 0.2)"),r.addColorStop(.9,"rgba(255, 200, 100, 0.5)"),r.addColorStop(1,"rgba(255, 150, 50, 0.3)"),t.fillStyle=r,t.beginPath(),t.arc(0,0,1.05*s,0,2*Math.PI),t.fill(),t.restore()}renderBaileysBeads(t,e,i,s,a,h,n,r,o,l=t=>t){if(!o)return void(this.X=null);const c=Math.abs(a)<1&&Math.abs(h)<1,u=r?30:15;if(!(Math.abs(a)<u&&Math.abs(h)<u||c))return void(this.X=null);if(!this.X){const t=Math.floor(4*Math.random())+1;this.Y=[];const e=[];for(let i=0;i<t;i++)e.push(Math.random()*Math.PI*2);const i=Array.from({length:t},(t,e)=>e);for(let t=i.length-1;t>0;t--){const e=Math.floor(Math.random()*(t+1));[i[t],i[e]]=[i[e],i[t]]}for(let s=0;s<t;s++)this.Y.push({angle:e[s],size:3+5*Math.random(),order:i[s],delay:200*i[s]});this.X=Date.now()}const p=Date.now()-this.X;(this.Y||[]).forEach(a=>{if(p<a.delay)return;const h=p-a.delay,n=Math.min(1,h/300),r=e+Math.cos(a.angle)*s,o=i+Math.sin(a.angle)*s;t.save(),t.translate(r,o),t.globalAlpha=n;const c=l(a.size),u=[{color:`rgba(255, 100, 100, ${.6*n})`,offset:-2},{color:`rgba(100, 255, 100, ${.6*n})`,offset:0},{color:`rgba(100, 100, 255, ${.6*n})`,offset:2}];t.globalCompositeOperation="screen",u.forEach(({color:e,offset:i})=>{const s=t.createRadialGradient(i,i,0,i,i,2*c);s.addColorStop(0,e),s.addColorStop(.2,e.replace(""+.6*n,""+.4*n)),s.addColorStop(.5,e.replace(""+.6*n,""+.2*n)),s.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=s,t.beginPath(),t.arc(i,i,2*c,0,2*Math.PI),t.fill()}),t.globalCompositeOperation="lighter";const d=t.createRadialGradient(0,0,0,0,0,c);d.addColorStop(0,`rgba(255, 255, 255, ${n})`),d.addColorStop(.3,`rgba(255, 255, 255, ${.5*n})`),d.addColorStop(1,"rgba(255, 255, 255, 0)"),t.fillStyle=d,t.beginPath(),t.arc(0,0,c,0,2*Math.PI),t.fill(),t.restore()})}renderMoonShadow(t,e,i,s,a,h,n=!1,r=0,o=null){if(t.save(),t.globalAlpha=1,t.translate(e,i),"crescent"===a.type){let e=1,i=a.offset||.7;if(o){const t=o.getProgress(),{targetShape:s}=o;"moon"===s&&void 0!==t&&t<1&&!a.shadowX&&(e=t,i=2.7*e-2)}const n=(a.angle||-30)*Math.PI/180,r=Math.cos(n)*s*i,l=Math.sin(n)*s*i;if(t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.beginPath(),h&&h.length>0){t.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)t.lineTo(h[e].x,h[e].y);t.closePath()}else t.arc(0,0,s,0,2*Math.PI);t.clip();const c=t.createRadialGradient(r,l,.9*s,r,l,1.1*s),u=void 0!==a.coverage?a.coverage:.85,p=Math.min(1,1.2*e)*(u/.85);c.addColorStop(0,`rgba(0, 0, 0, ${1*p})`),c.addColorStop(.8,`rgba(0, 0, 0, ${1*p})`),c.addColorStop(.88,`rgba(0, 0, 0, ${.98*p})`),c.addColorStop(.91,`rgba(0, 0, 0, ${.95*p})`),c.addColorStop(.93,`rgba(0, 0, 0, ${.9*p})`),c.addColorStop(.95,`rgba(0, 0, 0, ${.8*p})`),c.addColorStop(.96,`rgba(0, 0, 0, ${.65*p})`),c.addColorStop(.97,`rgba(0, 0, 0, ${.45*p})`),c.addColorStop(.98,`rgba(0, 0, 0, ${.25*p})`),c.addColorStop(.99,`rgba(0, 0, 0, ${.1*p})`),c.addColorStop(1,"rgba(0, 0, 0, 0)"),t.fillStyle=c,t.beginPath(),t.arc(r,l,1.1*s,0,2*Math.PI),t.fill()}else if("lunar"===a.type){const e=1-(void 0!==a.diffusion?a.diffusion:1);let i=0,h=0;if(o){const t=o.getProgress(),{currentShape:e,targetShape:a}=o;if(n&&"solar"===a&&void 0!==t&&t<1){const e=2.5*s;i=-e*(1-t),h=e*(1-t)}else if(n&&"solar"===e&&"solar"!==a&&null!==a&&void 0!==t&&t<1){const e=2.5*s;i=e*t,h=-e*t}}t.translate(i,h),n?(t.save(),t.beginPath(),t.arc(-i,-h,s,0,2*Math.PI),t.clip()):(t.beginPath(),t.arc(0,0,s,0,2*Math.PI),t.clip());const r=s*(1.8-.5*e),l=t.createRadialGradient(0,0,.2*s,0,0,r),c=a.coverage||.9;if(a.color&&a.color.includes("0, 0, 0")?(l.addColorStop(0,`rgba(0, 0, 0, ${c})`),l.addColorStop(.3+.2*e,`rgba(0, 0, 0, ${.95*c})`),l.addColorStop(.6+.2*e,`rgba(0, 0, 0, ${.8*c})`),l.addColorStop(.85,`rgba(0, 0, 0, ${.4*c})`),l.addColorStop(1,"rgba(0, 0, 0, 0)")):(l.addColorStop(0,`rgba(10, 2, 0, ${c})`),l.addColorStop(.3+.2*e,`rgba(20, 5, 0, ${.95*c})`),l.addColorStop(.6+.2*e,`rgba(40, 10, 5, ${.8*c})`),l.addColorStop(.85,`rgba(60, 15, 10, ${.4*c})`),l.addColorStop(1,"rgba(80, 20, 15, 0)")),t.fillStyle=l,t.beginPath(),t.arc(0,0,r,0,2*Math.PI),t.fill(),e>.3){const i=s*(.8+.3*e),h=t.createRadialGradient(0,0,0,0,0,i);a.color&&a.color.includes("0, 0, 0")?(h.addColorStop(0,`rgba(0, 0, 0, ${c})`),h.addColorStop(.5,`rgba(0, 0, 0, ${.9*c})`),h.addColorStop(.8,`rgba(0, 0, 0, ${.5*c})`),h.addColorStop(1,"rgba(0, 0, 0, 0)")):(h.addColorStop(0,`rgba(0, 0, 0, ${c})`),h.addColorStop(.5,`rgba(10, 2, 0, ${.9*c})`),h.addColorStop(.8,`rgba(20, 5, 0, ${.5*c})`),h.addColorStop(1,"rgba(30, 8, 5, 0)")),t.fillStyle=h,t.beginPath(),t.arc(0,0,i,0,2*Math.PI),t.fill()}}n&&t.restore(),t.restore()}}class Fe{constructor(t){this.renderer=t,this.episodicEffects={nervous:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:3e3+2e3*Math.random()},confident:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:4e3+2e3*Math.random()},tired:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:5e3+2e3*Math.random()},intense:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:3e3+3e3*Math.random()},subdued:{active:!1,startTime:0,duration:0,intensity:0,nextTrigger:4e3+3e3*Math.random()}}}getEpisodicEffects(){return this.episodicEffects}updateEpisodicEffects(t,e,i,s,a){if(!t||!this.episodicEffects[t])return{jitterX:e,jitterY:i,coreRadius:s,glowRadius:a};const h=this.episodicEffects[t],n=performance.now();if(!h.active&&n>=h.nextTrigger)switch(h.active=!0,h.startTime=n,t){case"nervous":h.duration=500+500*Math.random(),h.intensity=2+Math.random(),h.nextTrigger=n+3e3+2e3*Math.random();break;case"confident":h.duration=1e3+1e3*Math.random(),h.intensity=.15,h.nextTrigger=n+4e3+2e3*Math.random();break;case"tired":h.duration=1e3+2e3*Math.random(),h.intensity=.2,h.nextTrigger=n+5e3+2e3*Math.random();break;case"intense":h.duration=500+500*Math.random(),h.intensity=.5,h.nextTrigger=n+3e3+3e3*Math.random();break;case"subdued":h.duration=2e3+1e3*Math.random(),h.intensity=.3,h.nextTrigger=n+4e3+3e3*Math.random()}if(h.active){const r=n-h.startTime;if(r<h.duration){const n=r/h.duration;switch(t){case"nervous":{const t=1-n,s=15,a=Math.sin(n*Math.PI*s)*t;e=a*h.intensity,i=a*h.intensity*.7;break}case"confident":{const t=Math.sin(n*Math.PI);s*=1+h.intensity*t,a*=1+.5*h.intensity*t;break}case"tired":{const t=Math.sin(n*Math.PI*.5);s*=1-h.intensity*t,i+=5*t;break}case"intense":{const t=1-Math.cos(n*Math.PI);s*=1-.05*t,a*=1+h.intensity*t;break}case"subdued":{const t=Math.sin(n*Math.PI*.5);s*=1-.1*t,a*=1-h.intensity*t;break}}}else h.active=!1}return{jitterX:e,jitterY:i,coreRadius:s,glowRadius:a}}reset(){Object.keys(this.episodicEffects).forEach(t=>{this.episodicEffects[t].active=!1,this.episodicEffects[t].startTime=0,this.episodicEffects[t].duration=0,this.episodicEffects[t].intensity=0})}getEpisodeState(t){return this.episodicEffects[t]||null}isEpisodeActive(t){const e=this.episodicEffects[t];return!!e&&e.active}}class xe{constructor(t){this.renderer=t,this.brakeStartTime=null,this.brakeDuration=2500,this.brakeStartRotation=0,this.brakeTargetRotation=0,this.brakeStartVelocity=0,this.onComplete=null,this.onProgress=null,this.DURATION_FACTOR=14}brakeToUpright(t={}){return this.brakeToTarget(0,t)}brakeToNearest(t,e={}){const i=this.renderer.state.manualRotation||0,s=Math.round(i/t)*t;return this.brakeToTarget(s,e)}brakeToTarget(t,e={}){return new Promise(i=>{const{onProgress:s=null,onComplete:a=null}=e;this.onProgress=s,this.onComplete=a;const h=this.renderer.state.rotationSpeed||0,n=this.renderer.state.manualRotation||0;if(0===h||this.brakeStartTime)return void i();if(this.brakeStartTime=performance.now(),this.brakeStartRotation=n,this.brakeStartVelocity=h,0===t)this.brakeTargetRotation=h>0?360*(Math.floor(n/360)+1):360*Math.floor(n/360);else{const e=t%360,i=Math.floor(n/360);this.brakeTargetRotation=h>0?e>n%360?360*i+e:360*(i+1)+e:e<n%360?360*i+e:360*(i-1)+e}const r=Math.abs(this.brakeTargetRotation-this.brakeStartRotation);this.brakeDuration=Math.max(500,r/Math.abs(h)*this.DURATION_FACTOR*5),this.renderer.setRotationSpeed(0),this.resolvePromise=i})}updateBrake(t){if(!this.brakeStartTime)return null;const e=t-this.brakeStartTime,i=Math.min(e/this.brakeDuration,1),s=1-Math.pow(1-i,4),a=this.brakeStartRotation+(this.brakeTargetRotation-this.brakeStartRotation)*s,h=this.brakeStartVelocity*Math.pow(1-s,2);return this.onProgress&&this.onProgress(s,h,a),i>=1?(this.brakeStartTime=null,this.complete(),{rotation:this.brakeTargetRotation,speed:0,complete:!0}):{rotation:a,speed:h,complete:!1}}stop(){this.brakeStartTime=null}complete(){this.onComplete&&this.onComplete(),this.resolvePromise&&(this.resolvePromise(),this.resolvePromise=null)}isBraking(){return null!==this.brakeStartTime}emergencyStop(){this.stop(),this.renderer.setRotationSpeed(0),this.complete()}getProgress(){if(!this.brakeStartTime)return 0;const t=performance.now()-this.brakeStartTime;return Math.min(t/this.brakeDuration,1)}destroy(){this.stop(),this.onComplete=null,this.onProgress=null,this.resolvePromise=null,this.renderer=null,this.brakeStartTime=null,this.brakeStartRotation=0,this.brakeTargetRotation=0,this.brakeStartVelocity=0}}class ke{constructor(t){this.renderer=t,this.rotationBrake=new xe(t)}setRotationSpeed(t){this.renderer.state.rotationSpeed=t}setRotationAngle(t){this.renderer.state.manualRotation=t}getRotationAngle(){return this.renderer.state.manualRotation}getRotationSpeed(){return this.renderer.state.rotationSpeed}isBraking(){return this.rotationBrake&&this.rotationBrake.isBraking()}updateRotation(t){if(this.rotationBrake&&this.rotationBrake.isBraking()){const e=this.rotationBrake.updateBrake(t);e&&(this.renderer.state.manualRotation=e.rotation,this.renderer.state.rotationSpeed=e.complete?0:e.speed)}else 0!==this.renderer.state.rotationSpeed&&(this.renderer.state.manualRotation+=this.renderer.state.rotationSpeed);this.renderer.state.lastRotationUpdate=t}calculateTotalRotation(t=0,e=0){return(t+e+this.renderer.state.manualRotation)*Math.PI/180}applyRotation(t,e){0!==e&&t.rotate(e)}applyRotationTransform(t,e,i,s){this.updateRotation(performance.now());const a=this.calculateTotalRotation(s);return 0!==a&&(t.save(),t.translate(e,i),this.applyRotation(t,a),t.translate(-e,-i)),a}reset(){this.renderer.state.manualRotation=0,this.renderer.state.rotationSpeed=0,this.renderer.state.lastRotationUpdate=performance.now()}destroy(){this.rotationBrake&&(this.rotationBrake=null)}}let Be=class{constructor(t){this.renderer=t,this.canvas=t.canvas,this.initialized=!1,this.handleMouseMove=null,this.handleTouchMove=null}setEnabled(t){this.renderer.state.gazeTrackingEnabled=t,t?this.initialized||this.initialize():this.renderer.state.gazeTarget={x:0,y:0}}initialize(){this.initialized||(this.handleMouseMove=t=>{if(!this.renderer.state.gazeTrackingEnabled)return;const e=this.canvas.getBoundingClientRect(),i=e.width/2,s=e.height/2,a=t.clientX-e.left-i,h=t.clientY-e.top-s;this.renderer.state.gazeTarget={x:a/i,y:h/s}},this.handleTouchMove=t=>{if(this.renderer.state.gazeTrackingEnabled&&t.touches.length>0){const e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=i.width/2,a=i.height/2,h=e.clientX-i.left-s,n=e.clientY-i.top-a;this.renderer.state.gazeTarget={x:h/s,y:n/a}}},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),this.initialized=!0)}cleanup(){this.initialized&&(this.handleMouseMove&&(document.removeEventListener("mousemove",this.handleMouseMove),this.handleMouseMove=null),this.handleTouchMove&&(document.removeEventListener("touchmove",this.handleTouchMove),this.handleTouchMove=null),this.initialized=!1)}isInitialized(){return this.initialized}getGazeTarget(){return this.renderer.state.gazeTarget}isEnabled(){return this.renderer.state.gazeTrackingEnabled}};class Ce{constructor(t){this.renderer=t}setupCanvas(){this.renderer.updateOffscreenSize();const t=this.renderer.canvasManager.width||this.renderer.canvas.width||400,e=this.renderer.canvasManager.height||this.renderer.canvas.height||400,i=this.renderer.ctx;return this.renderer.ctx=this.renderer.offscreenCtx,{logicalWidth:t,logicalHeight:e,originalCtx:i}}renderBackdrop(t,e,i,s){const a=Math.min(t,e),h=this.renderer.getEffectiveCenter(),n=h.x,r=h.y-this.renderer.config.topOffset,o=a/this.renderer.config.referenceSize*this.renderer.config.baseScale*(h.coreScale||h.scale),l=this.renderer.config.referenceSize/this.renderer.config.coreSizeDivisor*o;this.renderer.backdropRenderer.update(s),this.renderer.audioAnalyzer&&this.renderer.audioAnalyzer.currentAmplitude&&this.renderer.backdropRenderer.setAudioIntensity(this.renderer.audioAnalyzer.currentAmplitude),this.renderer.backdropRenderer.render(n,r,l,i)}applyCanvasDecay(t,e,i){const s=this.renderer.particleSystem?this.renderer.particleSystem.particles.length:0,a=.12+Math.min(.08,.003*s);t.save(),t.globalCompositeOperation="destination-out",t.fillStyle=`rgba(0, 0, 0, ${a})`,t.fillRect(0,0,e,i),t.restore()}clearOffscreenCanvas(t,e){this.renderer.ctx.clearRect(0,0,t,e)}performCanvasSetup(t,e,i,s){this.renderBackdrop(t,e,i,s),this.applyCanvasDecay(i,t,e),this.clearOffscreenCanvas(t,e)}}class Re{constructor(t){this.renderer=t}markFrameStart(){return this.renderer.performanceMonitor&&this.renderer.performanceMonitor.markFrameStart(),performance.now()}handleCleanRender(){this.renderer.forceCleanRender&&(this.renderer.forceCleanRender=!1,this.renderer.canvas&&this.renderer.ctx&&this.renderer.ctx.clearRect(0,0,this.renderer.canvas.width,this.renderer.canvas.height))}initializeFrame(){const t=this.markFrameStart();return this.handleCleanRender(),t}}class Te{constructor(t){this.renderer=t}mergeTransforms(t,e){const i=this.renderer.ambientDanceAnimator.getTransform(e);return t?(t.x=(t.x||0)+(i.x||0),t.y=(t.y||0)+(i.y||0),t.rotation=(t.rotation||0)+(i.rotation||0),t.scale=(t.scale||1)*(i.scale||1),t):i}mergeAndStoreTransforms(t,e){const i=this.mergeTransforms(t,e);return this.renderer.gestureTransform=i,i}}class Pe{constructor(t){this.renderer=t}updateUndertoneModifiers(){if(this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers){const t=this.renderer.stateMachine.getWeightedUndertoneModifiers();t?this.renderer.applyUndertoneModifiers(t):this.renderer.applyUndertoneModifiers(null)}}updateColorTransition(t){this.renderer.colorTransition&&this.renderer.colorTransition.active&&this.renderer.updateColorTransition(t)}updateAnimationTimers(t){this.renderer.updateTimers(t)}updateGazeOffset(){if(this.renderer.state.gazeTrackingEnabled){const t=.15,e=50;this.renderer.state.gazeOffset.x+=(this.renderer.state.gazeTarget.x*e-this.renderer.state.gazeOffset.x)*t,this.renderer.state.gazeOffset.y+=(this.renderer.state.gazeTarget.y*e-this.renderer.state.gazeOffset.y)*t}else{const t=.1;this.renderer.state.gazeOffset.x+=(0-this.renderer.state.gazeOffset.x)*t,this.renderer.state.gazeOffset.y+=(0-this.renderer.state.gazeOffset.y)*t}}performFrameStateUpdates(t){this.updateUndertoneModifiers(),this.updateColorTransition(t),this.updateAnimationTimers(t),this.updateGazeOffset()}}class Oe{constructor(t){this.renderer=t}calculateBaseDimensions(t,e){const i=Math.min(t,e),s=this.renderer.getEffectiveCenter();return this.renderer.scaleFactor=i/this.renderer.config.referenceSize*this.renderer.config.baseScale*(s.coreScale||s.scale),this.renderer.particleScaleFactor=i/this.renderer.config.referenceSize*this.renderer.config.baseScale*(s.particleScale||s.scale),{canvasSize:i,effectiveCenter:s}}calculateCenterPosition(t,e,i){const s=t.x;let a=t.y-this.renderer.config.topOffset;return e.properties&&e.properties.verticalOffset&&(a=t.y-this.renderer.config.topOffset+i*e.properties.verticalOffset),{centerX:s,centerY:a}}applyGestureTransform(t,e,i){let s=1,a=0,h=1;return i&&(t+=i.x||0,e+=i.y||0,s=i.scale||1,a=(i.rotation||0)*Math.PI/180,h=i.glowIntensity||1),{centerX:t,centerY:e,scaleMultiplier:s,rotationAngle:a,glowMultiplier:h}}applyGestureAnimations(t,e,i,s,a){const h=this.renderer.gestureAnimator.applyGestureAnimations();return h&&(t+=h.offsetX||0,e+=h.offsetY||0,i*=h.scale||1,s+=(h.rotation||0)*Math.PI/180,a=h.glow||1),{centerX:t,centerY:e,scaleMultiplier:i,rotationAngle:s,glowMultiplier:a,gestureTransforms:h}}calculateRenderDimensions(t,e,i,s){const{canvasSize:a,effectiveCenter:h}=this.calculateBaseDimensions(t,e);let n,r,o,{centerX:l,centerY:c}=this.calculateCenterPosition(h,i,e);({centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o}=this.applyGestureTransform(l,c,s));const u=this.applyGestureAnimations(l,c,n,r,o);({centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o}=u);const{gestureTransforms:p}=u;return{canvasSize:a,effectiveCenter:h,centerX:l,centerY:c,scaleMultiplier:n,rotationAngle:r,glowMultiplier:o,gestureTransforms:p}}}class Ae{constructor(t){this.renderer=t}calculateSleepModifiers(){let t=1,e=1,i=1;return(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(t=void 0!==this.renderer.state.sleepDimness?this.renderer.state.sleepDimness:.3,i=.2,e=void 0!==this.renderer.state.sleepScale?this.renderer.state.sleepScale:.9,this.renderer.state.breathRate=.5,this.renderer.state.breathDepth=.15),{sleepOpacityMod:t,sleepScaleMod:e,glowOpacityMod:i}}calculateBreathingFactors(){let t,e;if(null!==this.renderer.state.customScale)t=this.renderer.state.customScale,e=1+.5*(this.renderer.state.customScale-1);else{const i=this.renderer.breathingAnimator.getBreathingScale();t=i,e=1-.5*(i-1)}return"nervous"===this.renderer.state.undertone&&this.renderer.undertoneModifiers.nervous.glowPulse&&(e*=1+Math.sin(Date.now()/200)*this.renderer.undertoneModifiers.nervous.glowPulse),{coreBreathFactor:t,glowBreathFactor:e}}calculateRadii(t,e,i){const{sleepOpacityMod:s,sleepScaleMod:a,glowOpacityMod:h}=this.calculateSleepModifiers(),{coreBreathFactor:n,glowBreathFactor:r}=this.calculateBreathingFactors(),o=this.renderer.config.referenceSize/this.renderer.config.coreSizeDivisor*this.renderer.scaleFactor,l=t.properties&&t.properties.coreSize?t.properties.coreSize:1,c=this.renderer.state.sizeMultiplier||1;return{coreRadius:o*l*n*e*a*c,glowRadius:o*this.renderer.config.glowMultiplier*r*this.renderer.state.glowIntensity*e*a*c*i,effectiveGlowIntensity:this.renderer.state.glowIntensity*i,sleepOpacityMod:s,glowOpacityMod:h}}}class De{constructor(t){this.renderer=t}applyBlinkSquish(t){return this.renderer.state.sleeping||(t*=this.renderer.eyeRenderer.getBlinkScale()),t}calculateJitter(t,e){let i=0,s=0;const a=this.renderer.state.jitterAmount||0;if(this.renderer.currentUndertone)({jitterX:i,jitterY:s,coreRadius:t,glowRadius:e}=this.renderer.episodicEffectController.updateEpisodicEffects(this.renderer.currentUndertone,i,s,t,e));else if(this.renderer.state.coreJitter||a>0){const t=Math.max(a,this.renderer.state.coreJitter?this.renderer.scaleValue(2):0);i=(Math.random()-.5)*t,s=(Math.random()-.5)*t}return{jitterX:i,jitterY:s,coreRadius:t,glowRadius:e}}calculateFinalPosition(t,e,i,s){return{coreX:t+this.renderer.state.gazeOffset.x+i,coreY:e+this.renderer.state.gazeOffset.y+s}}applyAllModifications(t,e,i,s,a){let h,n;s=this.applyBlinkSquish(s),({jitterX:h,jitterY:n,coreRadius:s,glowRadius:a}=this.calculateJitter(s,a));const{coreX:r,coreY:o}=this.calculateFinalPosition(t,e,h,n);return{coreX:r,coreY:o,rotationAngle:i,coreRadius:s,glowRadius:a}}}class ze{constructor(t){this.renderer=t}renderGlow(t,e,i,s,a,h){this.renderer.state.sleeping||"resting"===this.renderer.state.emotion?(this.renderer.ctx.save(),this.renderer.ctx.globalAlpha=a,this.renderer.glowRenderer.renderGlow(t,e,i,{intensity:s}),this.renderer.ctx.restore()):this.renderer.glowRenderer.renderGlow(t,e,i,{intensity:s})}renderFlashWave(t,e,i,s){if(t&&t.flashWave){const a=t.flashWave,{ctx:h}=this.renderer;h.save(),h.globalCompositeOperation="lighter";const n=s*a.innerRadius,r=s*a.outerRadius;if(r>n){const t=be.getRadialGradient(h,e,i,n,e,i,r,[{offset:0,color:"rgba(255, 255, 255, 0)"},{offset:.2,color:`rgba(255, 255, 255, ${.15*a.intensity})`},{offset:.5,color:`rgba(255, 255, 255, ${.25*a.intensity})`},{offset:.8,color:`rgba(255, 255, 255, ${.15*a.intensity})`},{offset:1,color:"rgba(255, 255, 255, 0)"}]);h.fillStyle=t,h.beginPath(),h.arc(e,i,r,0,2*Math.PI),h.arc(e,i,Math.max(0,n),0,2*Math.PI,!0),h.fill()}h.restore()}}renderSpeakingPulse(t,e,i,s){}renderAllEffects(t){const{coreX:e,coreY:i,glowRadius:s,effectiveGlowIntensity:a,glowOpacityMod:h,gestureTransforms:n,coreRadius:r,deltaTime:o}=t;this.renderGlow(e,i,s,a,h,o),this.renderFlashWave(n,e,i,r),this.renderSpeakingPulse(e,i,r,o)}}class Ee{constructor(t){this.renderer=t}applySleepOpacity(t){(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(this.renderer.ctx.globalAlpha=t)}updateShapeMorpher(t){let e=null,i=null;return this.renderer.shapeMorpher&&(this.renderer.shapeMorpher.update(),e=this.renderer.shapeMorpher.getCanvasPoints(0,0,t),i=this.renderer.shapeMorpher.getCurrentShadow()),{shapePoints:e,currentShadow:i}}renderSunEffects(t,e,i,s){let a=!1;return!s||"sun"!==s.type&&"solar-hybrid"!==s.type||(this.renderer.renderSunEffects(t,e,i,s),a=!0),a}renderCore(t,e,i,s,a){this.renderer.coreRenderer.renderCore(t,e,i,{scaleX:1,scaleY:1,rotation:s,shapePoints:a})}renderSparkles(t){this.renderer.specialEffects&&(this.renderer.specialEffects.update(t),this.renderer.specialEffects.renderSparkles())}renderShadowEffects(t,e,i,s,a,h){const n=this.renderer.shapeMorpher?this.renderer.shapeMorpher.currentShape:null,r=this.renderer.shapeMorpher?this.renderer.shapeMorpher.targetShape:null,o=this.renderer.shapeMorpher&&"solar"===r&&this.renderer.shapeMorpher.isTransitioning,l=this.renderer.shapeMorpher&&"solar"===n&&this.renderer.shapeMorpher.isTransitioning,c=s&&"solar-hybrid"===s.type,u=this.renderer.shapeMorpher&&this.renderer.shapeMorpher.isTransitioning&&"solar"===n&&"moon"===r,p=this.renderer.shapeMorpher&&this.renderer.shapeMorpher.isTransitioning&&"moon"===n&&"solar"===r;if(!s||"crescent"!==s.type&&"lunar"!==s.type||p||this.renderer.renderMoonShadow(t,e,i,s,a,!1,0),(c&&s.lunarOverlay||o||l)&&!u){const n=c&&s.lunarOverlay?s.lunarOverlay:{type:"lunar",coverage:1,color:"rgba(0, 0, 0, 1.0)",progression:"center"};let r=0,u=0,p=0;if(this.renderer.shapeMorpher){p=this.renderer.shapeMorpher.getProgress();const t=2.5*i;o&&p<1?(r=-t*(1-p),u=t*(1-p)):l&&p<1&&(r=t*p,u=-t*p)}if(this.renderer.renderMoonShadow(t,e,i,n,a,!0),(o||l)&&(o||h)&&(this.renderer.renderBaileysBeads(t,e,i,r,u,p,o,!0),Math.abs(r)<30&&Math.abs(u)<30&&this.renderer.specialEffects)){const t=Math.sqrt(r*r+u*u),e=Math.max(.1,.5*(1-t/30));this.renderer.specialEffects.triggerChromaticAberration(e)}}}cleanup(t){(this.renderer.state.sleeping||"resting"===this.renderer.state.emotion)&&(this.renderer.ctx.globalAlpha=1),0!==t&&this.renderer.ctx.restore()}renderCoreAndShapes(t){const{coreX:e,coreY:i,coreRadius:s,totalRotation:a,sleepOpacityMod:h,deltaTime:n}=t;this.applySleepOpacity(h);const{shapePoints:r,currentShadow:o}=this.updateShapeMorpher(s),l=this.renderSunEffects(e,i,s,o);this.renderCore(e,i,s,a,r),this.renderSparkles(n),this.renderShadowEffects(e,i,s,o,r,l),this.cleanup(a)}}class Ie{constructor(t){this.renderer=t}renderSleepIndicator(t,e,i,s){this.renderer.state.sleeping&&this.renderer.renderSleepIndicator(t,e-i-this.renderer.scaleValue(20),s)}finalizeCanvas(t,e,i){this.renderer.ctx=t,t.drawImage(this.renderer.offscreenCanvas,0,0,e,i)}drawRecordingIndicator(t){}finalizePerformanceMetrics(t){const e=performance.now()-t;this.renderer.performanceMonitor&&(this.renderer.performanceMonitor.markFrameEnd(),this.renderer.performanceMonitor.recordFrameTime(e))}finalizeRender(t){const{centerX:e,centerY:i,glowRadius:s,deltaTime:a,originalCtx:h,logicalWidth:n,logicalHeight:r,frameStartTime:o}=t;this.renderSleepIndicator(e,i,s,a),this.finalizeCanvas(h,n,r),this.drawRecordingIndicator(h),this.finalizePerformanceMetrics(o)}}class je{constructor(t){this.renderer=t,this.animations={grooveSway:null,grooveBob:null,grooveFlow:null,groovePulse:null,grooveStep:null},this.activeAnimation=null,this.blendState={x:0,y:0,rotation:0,scale:1,opacity:1}}startAmbientAnimation(t,e={}){this.activeAnimation&&this.activeAnimation!==t&&this.stopAmbientAnimation(this.activeAnimation),this.activeAnimation=t,this.animations[t]={startTime:Date.now(),intensity:e.intensity||1,frequency:e.frequency||1,options:e}}stopAmbientAnimation(t){this.animations[t]&&(this.animations[t]=null),this.activeAnimation===t&&(this.activeAnimation=null)}updateBlendState(t){if(!t)return;const e=.2;this.blendState.x=this.lerp(this.blendState.x,t.x||0,e),this.blendState.y=this.lerp(this.blendState.y,t.y||0,e),this.blendState.rotation=this.lerp(this.blendState.rotation,t.rotation||0,e),this.blendState.scale=this.lerp(this.blendState.scale,t.scale||1,e),this.blendState.opacity=this.lerp(this.blendState.opacity,t.opacity||1,e)}getTransform(t){const e={x:this.blendState.x,y:this.blendState.y,rotation:this.blendState.rotation,scale:this.blendState.scale,opacity:this.blendState.opacity};if(this.activeAnimation){const t=this.animations[this.activeAnimation];if(t){const i=Date.now()-t.startTime;switch(this.activeAnimation){case"grooveSway":e.x+=15*Math.sin(i/500*t.frequency)*t.intensity,e.rotation+=5*Math.sin(i/500*t.frequency+Math.PI/4)*t.intensity;break;case"grooveBob":e.y+=10*Math.sin(i/400*t.frequency)*t.intensity,e.scale*=1+.03*Math.sin(i/400*t.frequency)*t.intensity;break;case"grooveFlow":{const s=i/1e3*t.frequency;e.x+=Math.sin(s)*Math.cos(2*s)*20*t.intensity,e.y+=Math.cos(s)*Math.sin(2*s)*10*t.intensity,e.rotation+=8*Math.sin(2*s)*t.intensity;break}case"groovePulse":e.scale*=1+.05*Math.sin(i/250*t.frequency)*t.intensity,e.opacity*=.9+.1*Math.sin(i/250*t.frequency)*t.intensity;break;case"grooveStep":{const s=Math.floor(i/500*t.frequency)%4,a=i/500*t.frequency%1,h=this.smoothStep(a);0===s?e.x+=25*h*t.intensity:2===s&&(e.x-=25*h*t.intensity),e.y+=5*Math.abs(Math.sin(i/250*t.frequency))*t.intensity;break}}}}return e}lerp(t,e,i){return t+(e-t)*i}smoothStep(t){return t*t*(3-2*t)}}class $e{constructor(t){this.renderer=t,this.ctx=t.ctx,this.config={enabled:!1,radius:1.5,shape:"circle",color:"rgba(0, 0, 0, 0.6)",intensity:.7,blendMode:"normal",falloff:"smooth",falloffCurve:null,edgeSoftness:.6,coreTransparency:.2,blur:0,responsive:!0,pulse:!1,offset:{x:0,y:0},type:"radial-gradient"},this.currentIntensity=0,this.targetIntensity=0,this.pulsePhase=0}setConfig(t={}){this.config={...this.config,...t},void 0!==t.enabled&&(this.targetIntensity=t.enabled?this.config.intensity:0)}update(t){this.config.enabled?(this.currentIntensity+=.1*(this.targetIntensity-this.currentIntensity),this.config.responsive&&(this.pulsePhase+=.001*t)):this.currentIntensity*=.95}setAudioIntensity(t){if(!this.config.responsive)return;const e=.2*t;this.targetIntensity=Math.min(1,this.config.intensity+e)}render(t,e,i,s=null){if(this.currentIntensity<.01)return;const a=s||this.ctx;switch(a.save(),this.config.type){case"radial-gradient":this.renderRadialGradient(t,e,i,a);break;case"vignette":this.renderVignette(t,e,i,a);break;case"glow":this.renderGlow(t,e,i,a)}a.restore()}renderRadialGradient(t,e,i,s){s=s||this.ctx;const a=i*this.config.radius,h=t+(this.config.offset.x||0),n=e+(this.config.offset.y||0);let r=a;(this.config.pulse||this.config.responsive)&&(r*=1+.05*Math.sin(this.pulsePhase));const o=s.globalCompositeOperation;this.config.blendMode&&"normal"!==this.config.blendMode&&(s.globalCompositeOperation=this.config.blendMode),this.config.blur>0&&(s.filter=`blur(${this.config.blur}px)`);const l=s.createRadialGradient(h,n,0,h,n,r),c=this.config.color,u=this.currentIntensity;this.addGradientStopsSimple(l,c,u),s.fillStyle=l,s.beginPath(),s.arc(h,n,r,0,2*Math.PI),s.fill(),this.config.blur>0&&(s.filter="none"),this.config.blendMode&&"normal"!==this.config.blendMode&&(s.globalCompositeOperation=o)}renderVignette(t,e,i,s){s=s||this.ctx;const{canvas:a}=s,h=Math.max(a.width,a.height),n=s.createRadialGradient(t,e,.5*i,t,e,h);n.addColorStop(0,"rgba(0, 0, 0, 0)"),n.addColorStop(1,this.adjustColorAlpha(this.config.color,this.currentIntensity)),s.fillStyle=n,s.fillRect(0,0,a.width,a.height)}renderGlow(t,e,i,s){s=s||this.ctx;const a=i*this.config.radius;for(let i=0;i<3;i++){const h=a*(1-.2*i),n=this.currentIntensity*(.3-.1*i),r=s.createRadialGradient(t,e,0,t,e,h);r.addColorStop(0,this.adjustColorAlpha(this.config.color,n)),r.addColorStop(1,"rgba(0, 0, 0, 0)"),s.fillStyle=r,s.beginPath(),s.arc(t,e,h,0,2*Math.PI),s.fill()}}addGradientStopsSimple(t,e,i){const{coreTransparency:s}=this.config;t.addColorStop(0,this.adjustColorAlpha(e,i)),t.addColorStop(s,this.adjustColorAlpha(e,i));for(let a=1;a<=25;a++){const h=s+a/25*(1-s),n=(h-s)/(1-s),r=1-this.easeInOutCubic(n);t.addColorStop(h,this.adjustColorAlpha(e,i*r))}t.addColorStop(1,"rgba(0, 0, 0, 0)")}addGradientStops(t,e,i,s=1){const{coreTransparency:a}=this.config;if(this.config.falloffCurve&&Array.isArray(this.config.falloffCurve))this.config.falloffCurve.forEach(({stop:s,alpha:a})=>{t.addColorStop(s,this.adjustColorAlpha(e,i*a))});else switch(this.config.falloff){case"linear":t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a,"rgba(0, 0, 0, 0)"),t.addColorStop(1,this.adjustColorAlpha(e,i));break;case"exponential":t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a,"rgba(0, 0, 0, 0)"),t.addColorStop(a+.3*(1-a),this.adjustColorAlpha(e,.05*i)),t.addColorStop(a+.5*(1-a),this.adjustColorAlpha(e,.15*i)),t.addColorStop(a+.7*(1-a),this.adjustColorAlpha(e,.4*i)),t.addColorStop(a+.85*(1-a),this.adjustColorAlpha(e,.7*i)),t.addColorStop(1,this.adjustColorAlpha(e,i));break;default:{t.addColorStop(0,"rgba(0, 0, 0, 0)"),t.addColorStop(a*s,"rgba(0, 0, 0, 0)");const{edgeSoftness:h}=this.config,n=s,r=a*s+(n-a*s)*h,o=25;for(let h=1;h<=o;h++){const l=h/o;let c=0;if(l<=a*s)c=0;else if(l<=n)if(l<=r){const t=(l-a*s)/(r-a*s);c=this.easeInOutCubic(t)}else{const t=(l-r)/(n-r);c=1-.05*(1-this.easeInOutCubic(t))}else{const t=(l-n)/(1-n);c=1-this.easeInOutCubic(t)}t.addColorStop(l,this.adjustColorAlpha(e,i*c))}t.addColorStop(1,"rgba(0, 0, 0, 0)");break}}}easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}adjustColorAlpha(t,e){const i=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(i){const[,t,s,a,h=1]=i;return`rgba(${t}, ${s}, ${a}, ${parseFloat(h)*e})`}return`rgba(0, 0, 0, ${.6*e})`}getConfig(){return{...this.config}}enable(){this.config.enabled=!0,this.targetIntensity=this.config.intensity}disable(){this.config.enabled=!1,this.targetIntensity=0}toggle(){this.config.enabled?this.disable():this.enable()}}class Ge{enterSleepMode(){}wakeUp(){}renderSleepIndicator(){}cleanup(){}}class qe{constructor(t){this.renderer=t}applyUndertoneModifiers(t){if(t&&"object"==typeof t&&void 0!==t.weight){const{weight:e}=t;return this.renderer.state.sizeMultiplier=1+((t.sizeMultiplier||1)-1)*e,this.renderer.state.jitterAmount=(t.jitterAmount||0)*e,this.renderer.state.episodicFlutter=e>.5&&t.episodicFlutter||!1,this.renderer.state.glowRadiusMult=1+((t.glowRadiusMult||1)-1)*e,this.renderer.state.breathRateMult=1+((t.breathRateMult||1)-1)*e,this.renderer.state.breathDepthMult=1+((t.breathDepthMult||1)-1)*e,this.renderer.state.breathIrregular=e>.5&&t.breathIrregular||!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=(t.glowPulse||0)*e,this.renderer.state.brightnessFlicker=(t.brightnessFlicker||0)*e,this.renderer.state.brightnessMult=1+((t.brightnessMult||1)-1)*e,this.renderer.state.saturationMult=1+((t.saturationMult||1)-1)*e,void(this.renderer.state.hueShift=(t.hueShift||0)*e)}if(!t||!this.renderer.undertoneModifiers[t])return this.renderer.state.sizeMultiplier=1,this.renderer.state.jitterAmount=0,this.renderer.state.episodicFlutter=!1,this.renderer.state.glowRadiusMult=1,this.renderer.state.breathRateMult=1,this.renderer.state.breathDepthMult=1,this.renderer.state.breathIrregular=!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=0,this.renderer.state.brightnessFlicker=0,this.renderer.state.brightnessMult=1,this.renderer.state.saturationMult=1,void(this.renderer.state.hueShift=0);const e=this.renderer.undertoneModifiers[t];this.renderer.state.sizeMultiplier=e.sizeMultiplier,this.renderer.state.jitterAmount=e.jitterAmount||0,this.renderer.state.episodicFlutter=e.episodicFlutter||!1,this.renderer.state.glowRadiusMult=e.glowRadiusMult,this.renderer.state.breathRateMult=e.breathRateMult,this.renderer.state.breathDepthMult=e.breathDepthMult,this.renderer.state.breathIrregular=e.breathIrregular||!1,this.renderer.state.particleRateMult=1,this.renderer.state.glowPulse=e.glowPulse||0,this.renderer.state.brightnessFlicker=e.brightnessFlicker||0,this.renderer.state.brightnessMult=e.brightnessMult||1,this.renderer.state.saturationMult=e.saturationMult||1,this.renderer.state.hueShift=e.hueShift||0}updateUndertone(t){this.renderer.state.undertone!==t&&this.renderer.glowCache&&this.renderer.glowCache.clear(),this.renderer.state.undertone=t,this.renderer.currentUndertone=t;const e=this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers?this.renderer.stateMachine.getWeightedUndertoneModifiers():null;if(this.applyUndertoneModifiers(e||t),this.renderer.state.emotion){const i=$&&$.isInitialized?$.getEmotion(this.renderer.state.emotion):P(this.renderer.state.emotion);if(i){const s=i.glowColor||this.renderer.config.defaultGlowColor,a=this.renderer.applyUndertoneToColor(s,e||t);this.renderer.startColorTransition(a,200)}}}setEmotionalState(t,e,i=null){this.renderer.state.emotion===t&&this.renderer.state.undertone===i||!this.renderer.glowCache||this.renderer.glowCache.clear(),this.renderer.state.undertone=i,this.renderer.currentUndertone=i;const s=this.renderer.stateMachine&&this.renderer.stateMachine.getWeightedUndertoneModifiers?this.renderer.stateMachine.getWeightedUndertoneModifiers():null;this.applyUndertoneModifiers(s||i);const a=e.glowColor||this.renderer.config.defaultGlowColor;let h;h="suspicion"===t?e.glowColor||a:this.renderer.applyUndertoneToColor(a,s||i);const n=s||(i?this.renderer.undertoneModifiers[i]:null),r=e.glowIntensity||1;let o=1;if(n)if(s){const t=n.weight||0;o=void 0!==n.glowRadiusMult&&isFinite(n.glowRadiusMult)&&isFinite(t)?1+(n.glowRadiusMult-1)*t:1}else o=void 0!==n.glowRadiusMult?n.glowRadiusMult:1;const l=r*o;let c=1500;"anger"===t||"fear"===t?c=800:"sadness"!==t&&"resting"!==t||(c=2e3),this.renderer.state.emotion=t,"suspicion"===t?(this.renderer.state.isSuspicious=!0,this.renderer.state.targetSquintAmount=e&&e.coreSquint?e.coreSquint:.4,void 0===this.renderer.state.squintAmount&&(this.renderer.state.squintAmount=0),this.renderer.state.lastScanTime=Date.now(),this.renderer.state.scanPhase=0):(this.renderer.state.isSuspicious=!1,this.renderer.state.targetSquintAmount=0,void 0===this.renderer.state.squintAmount&&(this.renderer.state.squintAmount=0)),this.renderer.startColorTransition(h,l,c);const u=e.breathRate||1,p=e.breathDepth||this.renderer.config.breathingDepth;this.renderer.state.breathRate=n?u*n.breathRateMult:u,this.renderer.state.breathDepth=n?p*n.breathDepthMult:p,this.renderer.state.coreJitter=e.coreJitter||n&&n.jitterAmount>0,this.renderer.state.emotionEyeOpenness=e.eyeOpenness,this.renderer.state.emotionEyeArc=e.eyeArc}}class Xe{constructor(t){this.renderer=t}resetCanvasContext(){if(!this.renderer.canvas||!this.renderer.ctx)return;const{width:t}=this.renderer.canvas,{height:e}=this.renderer.canvas;this.resetContext(this.renderer.ctx,t,e),this.renderer.offscreenCanvas&&this.renderer.offscreenCtx&&this.resetContext(this.renderer.offscreenCtx,this.renderer.offscreenCanvas.width,this.renderer.offscreenCanvas.height),this.renderer.contextStateManager&&this.renderer.contextStateManager.reset(),this.renderer.forceCleanRender=!0}resetContext(t,e,i){t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.clearRect(0,0,e,i)}setQualityLevel(t){this.renderer.qualityLevel=Math.max(0,Math.min(1,t)),this.renderer.qualityLevel<.5?this.applyLowQuality():this.renderer.qualityLevel<.8?this.applyMediumQuality():this.applyHighQuality()}applyLowQuality(){this.renderer.ctx.imageSmoothingEnabled=!1,this.renderer.state.breathDepth*=.5}applyMediumQuality(){this.renderer.ctx.imageSmoothingEnabled=!0,this.renderer.ctx.imageSmoothingQuality="medium"}applyHighQuality(){this.renderer.ctx.imageSmoothingEnabled=!0,this.renderer.ctx.imageSmoothingQuality="high"}setQualityReduction(t){t?this.setQualityLevel(.5):this.setQualityLevel(1)}handleContextRecovery(t){this.renderer.ctx=t}}const Ye=2,He=3,_e=4,Le=new class{constructor(){this.callbacks=new Map,this.callbackIdCounter=0,this.H=new Map,this._=!0,this.frameId=null,this.isRunning=!1,this.lastFrameTime=0,this.deltaTime=0,this.fps=60,this.frameCount=0,this.targetFPS=60,this.targetFrameTime=1e3/this.targetFPS,this.frameBudget=16.67,this.prioritySkipCounters={[Ye]:0,[He]:0,[_e]:0},this.performanceMonitor=null,this.frameTimeHistory=new Array(60).fill(0),this.L=0,this.W=0,this.maxHistorySize=60,this.loop=this.loop.bind(this)}register(t,e=2,i=null){if("function"!=typeof t)throw new Error("Callback must be a function");const s=++this.callbackIdCounter;return this.callbacks.set(s,{callback:t,priority:e,context:i,lastRun:0,runCount:0,totalTime:0,enabled:!0}),this._=!0,1!==this.callbacks.size||this.isRunning||this.start(),s}unregister(t){this.callbacks.delete(t),this._=!0,0===this.callbacks.size&&this.isRunning&&this.stop()}setEnabled(t,e){const i=this.callbacks.get(t);i&&(i.enabled=e)}start(){this.isRunning||(this.isRunning=!0,this.lastFrameTime=performance.now(),this.frameId=requestAnimationFrame(this.loop))}stop(){this.isRunning&&(this.isRunning=!1,this.frameId&&(cancelAnimationFrame(this.frameId),this.frameId=null))}loop(t){if(!this.isRunning)return;this.deltaTime=t-this.lastFrameTime,this.lastFrameTime=t,this.frameCount++,this.frameCount%60==0&&(this.fps=Math.round(1e3/(this.deltaTime||16.67))),this.frameTimeHistory[this.L]=this.deltaTime,this.L=(this.L+1)%this.maxHistorySize,this.W<this.maxHistorySize&&this.W++,this._&&this.U();const e=this.H;let i=0;for(const s of[0,1,2,3,4]){if(s>0&&i>.8*this.frameBudget)break;if(this.shouldSkipPriority(s))continue;const a=e.get(s)||[];for(const e of a){if(!e.enabled)continue;const s=performance.now();try{e.context?e.callback.call(e.context,this.deltaTime,t):e.callback(this.deltaTime,t);const a=performance.now()-s;e.totalTime+=a,e.runCount++,e.lastRun=t,i+=a}catch(t){e.runCount>0&&e.totalTime/e.runCount>10&&(e.enabled=!1)}if(i>this.frameBudget)break}}this.frameId=requestAnimationFrame(this.loop)}U(){this.H.clear();for(const[,t]of this.callbacks){const{priority:e}=t;this.H.has(e)||this.H.set(e,[]),this.H.get(e).push(t)}this._=!1}shouldSkipPriority(t){if(0===t)return!1;if(this.fps<30&&t>=3)return!0;if(this.fps<45&&4===t)return!0;if(2===t){if(this.fps<50&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%2!=0))return!0}else if(3===t){if(this.fps<50&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%3!=0))return!0}else if(4===t&&(this.prioritySkipCounters[t]++,this.prioritySkipCounters[t]%5!=0))return!0;return!1}getStats(){const t={fps:this.fps,frameCount:this.frameCount,callbackCount:this.callbacks.size,averageFrameTime:0,maxFrameTime:0,minFrameTime:1/0};if(this.W>0){let e=0;for(let i=0;i<this.W;i++){const s=this.frameTimeHistory[i];e+=s,t.maxFrameTime=Math.max(t.maxFrameTime,s),t.minFrameTime=Math.min(t.minFrameTime,s)}t.averageFrameTime=e/this.W}t.callbacksByPriority={};for(const[,e]of this.callbacks){const{priority:i}=e;t.callbacksByPriority[i]||(t.callbacksByPriority[i]={count:0,totalTime:0,enabled:0}),t.callbacksByPriority[i].count++,t.callbacksByPriority[i].totalTime+=e.totalTime,e.enabled&&t.callbacksByPriority[i].enabled++}return t}setTargetFPS(t){this.targetFPS=Math.max(15,Math.min(120,t)),this.targetFrameTime=1e3/this.targetFPS,this.frameBudget=this.targetFrameTime}setPerformanceMonitor(t){this.performanceMonitor=t}destroy(){this.stop(),this.callbacks.clear(),this.H.clear(),this._=!0,this.frameTimeHistory.fill(0),this.L=0,this.W=0}};class We{constructor(t){this.renderer=t}destroy(){this.cancelAnimationFrames(),this.unregisterLoopCallbacks(),this.cleanupManagers(),this.clearTimeouts(),this.clearAnimationStates(),this.clearOtherResources()}cancelAnimationFrames(){for(const t in this.renderer.animationFrameIds)this.renderer.animationFrameIds[t]&&(cancelAnimationFrame(this.renderer.animationFrameIds[t]),this.renderer.animationFrameIds[t]=null)}unregisterLoopCallbacks(){for(const t in this.renderer.loopCallbackIds)this.renderer.loopCallbackIds[t]&&(Le.unregister(this.renderer.loopCallbackIds[t]),this.renderer.loopCallbackIds[t]=null)}cleanupManagers(){this.renderer.sleepManager&&this.renderer.sleepManager.cleanup(),this.renderer.gazeTracker&&this.renderer.gazeTracker.cleanup()}clearTimeouts(){this.renderer.wakeJitterTimeout&&(clearTimeout(this.renderer.wakeJitterTimeout),this.renderer.wakeJitterTimeout=null)}clearAnimationStates(){this.renderer.colorTransition.active=!1}clearOtherResources(){this.renderer.cleanupGazeTracking(),this.renderer.speakingRings=[],this.renderer.gestureCompositor&&this.renderer.gestureCompositor.clearCache(),this.renderer.specialEffects&&this.renderer.specialEffects.destroy(),this.renderer.cleanupOffscreenCanvas&&this.renderer.cleanupOffscreenCanvas()}}class Ue{constructor(t){this.renderer=t}updateTimers(t){this.updateBreathing(t),this.updateBlinking(t)}updateBreathing(t){this.renderer.breathingAnimator.update(t,this.renderer.state.emotion,this.renderer.currentUndertone),this.renderer.state.sleeping?this.applySleepBreathing():this.applyNormalBreathing(),this.renderer.breathingAnimator.setIrregularBreathing(this.renderer.state.breathIrregular)}applySleepBreathing(){this.renderer.breathingAnimator.setBreathRateMultiplier(.5),this.renderer.breathingAnimator.setBreathDepthMultiplier(1.2)}applyNormalBreathing(){this.renderer.breathingAnimator.setBreathRateMultiplier(1),this.renderer.breathingAnimator.setBreathDepthMultiplier(1)}updateBlinking(t){const e=this.renderer.state.blinkingEnabled&&!this.renderer.state.sleeping;this.renderer.eyeRenderer.setBlinkingEnabled(e),this.renderer.eyeRenderer.update(t),this.renderer.state.blinking=this.renderer.eyeRenderer.blinking}}class Ve{constructor(t){this.renderer=t}setGazeOffset(t){this.processGazeData(t),this.handleGazeInteraction()}processGazeData(t){"object"==typeof t&&null!==t&&(this.isOldFormat(t)?this.renderer.state.gazeOffset=t:this.applyNewFormatData(t))}isOldFormat(t){return{}.hasOwnProperty.call(t,"x")&&{}.hasOwnProperty.call(t,"y")}applyNewFormatData(t){this.renderer.state.gazeOffset=t.offset||{x:0,y:0},this.renderer.state.gazeIntensity=t.proximity||0,this.renderer.state.gazeLocked=t.isLocked||!1}handleGazeInteraction(){this.renderer.idleTimer=0,this.renderer.isAsleep&&this.renderer.wakeUp()}getCurrentOrbPosition(){const t=this.renderer.canvasManager.width/2,e=this.renderer.canvasManager.height/2-this.renderer.config.topOffset;return{x:t+this.renderer.state.gazeOffset.x,y:e+this.renderer.state.gazeOffset.y}}}class Ne{constructor(t,e={}){this.canvasManager=t,this.ctx=t.getContext(),this.ctx||(this.o=!0),this.gestureCompositor=new ie,this.currentUndertone=null,this.gestureAnimator=new fe(this),this.colorUtilities=new me,this.specialEffects=new Me(this),this.eyeRenderer=new ge(this),this.breathingAnimator=new ye(this),this.glowRenderer=new we(this),this.coreRenderer=new ve(this),this.celestialRenderer=new Se,this.episodicEffectController=new Fe(this),this.rotationManager=new ke(this),this.gazeTracker=new Be(this),this.canvasSetupManager=new Ce(this),this.renderPerformanceManager=new Re(this),this.transformMerger=new Te(this),this.stateUpdateManager=new Pe(this),this.dimensionCalculator=new Oe(this),this.radiusCalculator=new Ae(this),this.positionJitterManager=new De(this),this.effectsRenderManager=new ze(this),this.coreShapeRenderManager=new Ee(this),this.renderFinalizationManager=new Ie(this),this.ambientDanceAnimator=new je(this),this.backdropRenderer=new $e(this),this.sleepManager=new Ge(this),this.emotionalStateManager=new qe(this),this.canvasContextManager=new Xe(this),this.resourceCleanupManager=new We(this),this.timerCoordinator=new Ue(this),this.gazeInputHandler=new Ve(this),this.config={coreColor:e.coreColor||"#FFFFFF",coreSizeDivisor:e.coreSizeDivisor||12,glowMultiplier:e.glowMultiplier||2.5,defaultGlowColor:e.defaultGlowColor||"#14B8A6",breathingSpeed:e.breathingSpeed||.42,breathingDepth:e.breathingDepth||.08,renderingStyle:e.renderingStyle||"classic",baseScale:e.baseScale||1,referenceSize:400,topOffset:e.topOffset||0,positionController:e.positionController||null};const i=Math.min(this.canvasManager.width||400,this.canvasManager.height||400);this.scaleFactor=i/this.config.referenceSize*this.config.baseScale,this.state={emotion:"neutral",glowColor:this.config.defaultGlowColor,glowIntensity:1,breathRate:1,breathDepth:this.config.breathingDepth,coreJitter:!1,speaking:!1,recording:!1,sleeping:!1,blinking:!1,blinkingEnabled:!0,gazeOffset:{x:0,y:0},gazeIntensity:0,gazeLocked:!1,gazeTrackingEnabled:!1,gazeTarget:{x:0,y:0},effectiveCenter:{x:0,y:0,scale:1},squintAmount:0,targetSquintAmount:0,scanPhase:0,lastScanTime:0,isSuspicious:!1,customScale:null,sizeMultiplier:1,jitterAmount:0,episodicFlutter:!1,glowRadiusMult:1,breathRateMult:1,breathDepthMult:1,breathIrregular:!1,particleRateMult:1,glowPulse:0,brightnessFlicker:0,brightnessMult:1,saturationMult:1,hueShift:0,manualRotation:0,rotationSpeed:0,lastRotationUpdate:performance.now()},this.animationFrameIds={colorTransition:null,eyeClose:null,eyeOpen:null},this.loopCallbackIds={eyeClose:null,eyeOpen:null},this.wakeJitterTimeout=null,this.offscreenCanvas=null,this.offscreenCtx=null,this.initOffscreenCanvas(),this.canvas=t.canvas,this.gestureAnimations={bounce:{active:!1,startTime:0,progress:0,params:null},pulse:{active:!1,startTime:0,progress:0,params:null},shake:{active:!1,startTime:0,progress:0,params:null},spin:{active:!1,startTime:0,progress:0,params:null},nod:{active:!1,startTime:0,progress:0,params:null},tilt:{active:!1,startTime:0,progress:0,params:null},expand:{active:!1,startTime:0,progress:0,params:null},contract:{active:!1,startTime:0,progress:0,params:null},flash:{active:!1,startTime:0,progress:0,params:null},drift:{active:!1,startTime:0,progress:0,params:null,startX:0,startY:0},stretch:{active:!1,startTime:0,progress:0,params:null},glow:{active:!1,startTime:0,progress:0,params:null},flicker:{active:!1,startTime:0,progress:0,params:null},vibrate:{active:!1,startTime:0,progress:0,params:null},wave:{active:!1,startTime:0,progress:0,params:null},breathe:{active:!1,startTime:0,progress:0,params:null},morph:{active:!1,startTime:0,progress:0,params:null},slowBlink:{active:!1,startTime:0,progress:0,params:null},look:{active:!1,startTime:0,progress:0,params:null,targetX:0,targetY:0},settle:{active:!1,startTime:0,progress:0,params:null},breathIn:{active:!1,startTime:0,progress:0,params:null},breathOut:{active:!1,startTime:0,progress:0,params:null},breathHold:{active:!1,startTime:0,progress:0,params:null},breathHoldEmpty:{active:!1,startTime:0,progress:0,params:null},jump:{active:!1,startTime:0,progress:0,params:null},orbital:{active:!1,startTime:0,progress:0,params:null},hula:{active:!1,startTime:0,progress:0,params:null}},Object.defineProperty(this,"episodicEffects",{get:()=>this.episodicEffectController.getEpisodicEffects(),enumerable:!0}),this.speakingRings=[],this.maxRings=5,this.ringSpawnTimer=0,this.ringSpawnInterval=200,this.recordingRings=[],this.recordingPulse=0,this.sleepZ=[],this.colorTransition={active:!1,fromColor:this.state.glowColor,toColor:this.state.glowColor,fromIntensity:this.state.glowIntensity,toIntensity:this.state.glowIntensity,progress:0,startTime:0,duration:1500},this.undertoneModifiers={nervous:{hueShift:0,saturationMult:1.05,brightnessMult:1,brightnessFlicker:.05,sizeMultiplier:1,jitterAmount:0,episodicFlutter:!0,glowRadiusMult:1,glowPulse:.05,breathRateMult:1.1,breathDepthMult:.9,breathIrregular:!0},confident:{hueShift:15,saturationMult:1.2,brightnessMult:1.1,sizeMultiplier:1,jitterAmount:0,episodicPowerPose:!0,glowRadiusMult:1.15,breathRateMult:.95,breathDepthMult:1.1,breathIrregular:!1},tired:{hueShift:-5,saturationMult:.7,brightnessMult:.85,sizeMultiplier:.95,jitterAmount:0,episodicMicroSleep:!0,glowRadiusMult:.9,breathRateMult:.8,breathDepthMult:1.2,breathIrregular:!1},intense:{hueShift:5,saturationMult:1.3,brightnessMult:1.15,sizeMultiplier:1,jitterAmount:0,episodicLaserFocus:!0,glowRadiusMult:1.2,breathRateMult:1.2,breathDepthMult:.9,breathIrregular:!1},subdued:{hueShift:-10,saturationMult:.75,brightnessMult:.9,sizeMultiplier:.95,jitterAmount:0,episodicWithdrawal:!0,glowRadiusMult:.85,breathRateMult:.9,breathDepthMult:.9,breathIrregular:!1}},this.lastFrameTime=0,this.V()}scaleValue(t){return t*this.scaleFactor}initOffscreenCanvas(){this.offscreenCanvas=document.createElement("canvas"),this.offscreenCtx=this.offscreenCanvas.getContext("2d",{alpha:!0,desynchronized:!0,willReadFrequently:!1}),this.updateOffscreenSize()}cleanupOffscreenCanvas(){this.offscreenCanvas&&(this.offscreenCtx&&(this.offscreenCtx.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),this.offscreenCtx=null),this.offscreenCanvas.width=0,this.offscreenCanvas.height=0,this.offscreenCanvas=null)}updateOffscreenSize(){if(this.offscreenCanvas&&this.canvasManager){const{width:t}=this.canvasManager.canvas,{height:e}=this.canvasManager.canvas;if(this.offscreenCanvas.width!==t||this.offscreenCanvas.height!==e){this.offscreenCanvas.width=t,this.offscreenCanvas.height=e;const i=this.canvasManager.canvas.width>this.canvasManager.width;this.offscreenCtx&&(this.offscreenCtx.setTransform(1,0,0,1,0,0),i&&this.canvasManager.dpr&&this.offscreenCtx.scale(this.canvasManager.dpr,this.canvasManager.dpr))}}}updateEffectiveCenter(t){this.state.effectiveCenter=t}getEffectiveCenter(){const t=this.canvasManager.getCenter();let e;return e=this.config.positionController?this.config.positionController.getEffectiveCenter(t.x,t.y):{x:t.x,y:t.y,scale:1},e.x+=this.state.gazeOffset.x,e.y+=this.state.gazeOffset.y,e}render(t,e,i=null){if(this.o)return;const s=this.renderPerformanceManager.initializeFrame();i=this.transformMerger.mergeAndStoreTransforms(i,e);const{logicalWidth:a,logicalHeight:h,originalCtx:n}=this.canvasSetupManager.setupCanvas();this.canvasSetupManager.performCanvasSetup(a,h,n,e),this.stateUpdateManager.performFrameStateUpdates(e);const r=this.dimensionCalculator.calculateRenderDimensions(a,h,t,i),{scaleMultiplier:o,glowMultiplier:l,gestureTransforms:c,centerX:u,centerY:p}=r;let{rotationAngle:d}=r;const f=this.radiusCalculator.calculateRadii(t,o,l);let{coreRadius:m,glowRadius:M}=f;const{effectiveGlowIntensity:g,sleepOpacityMod:y,glowOpacityMod:b}=f,w=this.positionJitterManager.applyAllModifications(u,p,d,m,M),{coreX:v,coreY:S}=w;({rotationAngle:d,coreRadius:m,glowRadius:M}=w);const F=this.rotationManager.applyRotationTransform(this.ctx,v,S,d);this.effectsRenderManager.renderAllEffects({coreX:v,coreY:S,glowRadius:M,effectiveGlowIntensity:g,glowOpacityMod:b,gestureTransforms:c,coreRadius:m,deltaTime:e}),this.coreShapeRenderManager.renderCoreAndShapes({coreX:v,coreY:S,coreRadius:m,totalRotation:F,sleepOpacityMod:y,deltaTime:e}),this.renderFinalizationManager.finalizeRender({centerX:u,centerY:p,glowRadius:M,deltaTime:e,originalCtx:n,logicalWidth:a,logicalHeight:h,frameStartTime:s})}renderRecordingGlow(t,e,i,s){const a=this.canvas?.width||600,h=this.canvas?.height||600,n=Math.min(i,t-10,e-10,a-t-10,h-e-10),r=Math.max(50,n),o=be.getRadialGradient(this.ctx,t,e,0,t,e,r,[{offset:0,color:this.hexToRgba("#FF0000",.7*s)},{offset:.3,color:this.hexToRgba("#FF0000",.5*s)},{offset:.6,color:this.hexToRgba("#FF0000",.3*s)},{offset:.85,color:this.hexToRgba("#FF0000",.1*s)},{offset:1,color:this.hexToRgba("#FF0000",0)}]);this.ctx.fillStyle=o,this.ctx.beginPath(),this.ctx.arc(t,e,r,0,2*Math.PI),this.ctx.fill()}renderDropShadow(t,e,i,s){const{ctx:a}=this,h=this.shapeMorpher&&this.shapeMorpher.isTransitioning;if(!(this.shapeMorpher&&(this.shapeMorpher.audioDeformation>.1||this.shapeMorpher.vocalEnergy>.1)||h&&!(this.shapeMorpher.morphProgress>.8))){a.save(),a.translate(t,e);const h=this.scaleValue(2);if(a.translate(0,h),s&&s.length>32)a.fillStyle="rgba(0, 0, 0, 0.15)",a.beginPath(),a.arc(0,0,1.05*i,0,2*Math.PI),a.fill();else{const t=a.createRadialGradient(0,0,.7*i,0,0,1.2*i);if(t.addColorStop(0,"rgba(0, 0, 0, 0.2)"),t.addColorStop(.8,"rgba(0, 0, 0, 0.1)"),t.addColorStop(1,"rgba(0, 0, 0, 0)"),a.fillStyle=t,a.beginPath(),s){const t=1.1,e=s.length>20?2:1;a.moveTo(s[0].x*t,s[0].y*t);for(let i=e;i<s.length;i+=e)a.lineTo(s[i].x*t,s[i].y*t);a.closePath()}else a.arc(0,0,1.1*i,0,2*Math.PI);a.fill()}a.restore()}}renderSunEffects(t,e,i,s){return this.celestialRenderer.renderSunEffects(this.ctx,t,e,i,s)}renderBaileysBeads(t,e,i,s,a,h,n,r){return this.celestialRenderer.renderBaileysBeads(this.ctx,t,e,i,s,a,h,n,r,this.scaleValue.bind(this))}renderMoonShadow(t,e,i,s,a,h=!1,n=0){return this.celestialRenderer.renderMoonShadow(this.ctx,t,e,i,s,a,h,n,this.shapeMorpher)}renderSpeakingRings(t,e,i,s){return this.specialEffects.renderSpeakingRings(t,e,i,s)}renderRecordingIndicator(t,e){return this.specialEffects.renderRecordingIndicator(t,e)}renderSleepIndicator(t,e,i){return this.sleepManager.renderSleepIndicator(t,e,i)}updateTimers(t){this.timerCoordinator.updateTimers(t)}applyUndertoneModifiers(t){this.emotionalStateManager.applyUndertoneModifiers(t)}applyUndertoneToColor(t,e){return this.colorUtilities.applyUndertoneToColor(t,e)}hexToRgb(t){return this.colorUtilities.hexToRgb(t)}rgbToHsl(t,e,i){return this.colorUtilities.rgbToHsl(t,e,i)}hslToHex(t,e,i){return this.colorUtilities.hslToHex(t,e,i)}hexToRgba(t,e=1){const i=this.hexToRgb(t);return i?`rgba(${i.r}, ${i.g}, ${i.b}, ${e})`:`rgba(255, 255, 255, ${e})`}startColorTransition(t,e,i=1500){this.colorUtilities.currentColor=this.state.glowColor,this.colorUtilities.currentIntensity=this.state.glowIntensity,this.colorUtilities.startColorTransition(t,e,i),this.colorTransition=this.colorUtilities.colorTransition}updateColorTransition(t){const e=this.colorUtilities.updateColorTransition(t);e&&(this.state.glowColor=e.color,this.state.glowIntensity=e.intensity,this.colorTransition=this.colorUtilities.colorTransition)}updateUndertone(t){this.emotionalStateManager.updateUndertone(t)}setEmotionalState(t,e,i=null){this.emotionalStateManager.setEmotionalState(t,e,i)}setBPM(t){}setRotationSpeed(t){this.rotationManager.setRotationSpeed(t)}setRotationAngle(t){this.rotationManager.setRotationAngle(t)}setGazeOffset(t){this.gazeInputHandler.setGazeOffset(t)}getCurrentOrbPosition(){return this.gazeInputHandler.getCurrentOrbPosition()}setCustomScale(t){this.state.customScale=t}startSpeaking(){this.state.speaking=!0,this.speakingRings=[],this.ringSpawnTimer=0}stopSpeaking(){this.state.speaking=!1,this.speakingRings=[]}enterSleepMode(){this.sleepManager.enterSleepMode()}wakeUp(){this.sleepManager.wakeUp()}startRecording(){this.state.recording=!0}stopRecording(){this.state.recording=!1}setBlinkingEnabled(t){this.state.blinkingEnabled=t,t||(this.state.blinking=!1,this.eyeRenderer.blinking=!1,this.eyeRenderer.blinkTimer=0)}setGazeTracking(t){this.gazeTracker.setEnabled(t)}initGazeTracking(){this.N||(this.N=!0),this.gazeTracker.initialize()}cleanupGazeTracking(){this.J||(this.J=!0),this.gazeTracker.cleanup()}resetCanvasContext(){this.canvasContextManager.resetCanvasContext()}setQualityLevel(t){this.canvasContextManager.setQualityLevel(t)}setQualityReduction(t){this.canvasContextManager.setQualityReduction(t)}handleContextRecovery(t){this.canvasContextManager.handleContextRecovery(t)}getUndertoneModifier(){return this.stateMachine&&this.stateMachine.getWeightedUndertoneModifiers?this.stateMachine.getWeightedUndertoneModifiers():this.currentUndertone&&this.undertoneModifiers[this.currentUndertone]?this.undertoneModifiers[this.currentUndertone]:null}applyGestureAnimations(){return this.gestureAnimator.applyGestureAnimations()}startGesture(t){return this.gestureAnimator.startGesture(t)}getCurrentGesture(){return this.gestureAnimator.getCurrentGesture()}V(){["Bounce","Pulse","Shake","Spin","Nod","Tilt","Expand","Contract","Flash","Drift","Stretch","Glow","Flicker","Vibrate","Orbital","Hula","Wave","Breathe","Morph","SlowBlink","Look","Settle","BreathIn","BreathOut","BreathHold","BreathHoldEmpty","Jump","Sway","Float","Rain","RunningMan","Charleston","Sparkle","Shimmer","Wiggle","Groove","Point","Lean","Reach","HeadBob","Orbit"].forEach(t=>{const e=`start${t}`;this[e]=()=>this.gestureAnimator[e]()})}startGrooveSway(t){this.ambientDanceAnimator.startAmbientAnimation("grooveSway",t)}startGrooveBob(t){this.ambientDanceAnimator.startAmbientAnimation("grooveBob",t)}startGrooveFlow(t){this.ambientDanceAnimator.startAmbientAnimation("grooveFlow",t)}startGroovePulse(t){this.ambientDanceAnimator.startAmbientAnimation("groovePulse",t)}startGrooveStep(t){this.ambientDanceAnimator.startAmbientAnimation("grooveStep",t)}stopAllGestures(){this.gestureAnimator.stopAllGestures(),this.currentGesture=null}isGestureActive(){return Object.values(this.gestureAnimator.gestureAnimations).some(t=>t.active)}destroy(){this.resourceCleanupManager.destroy()}}function Qe(t){const e=[];for(let i=0;i<t;i++){const s=i/t*Math.PI*2;e.push({x:.5+.5*Math.cos(s),y:.5+.5*Math.sin(s)})}return e}function Je(t,e=12){return Qe(t)}const Ze={circle:{points:Qe(64),shadow:{type:"none"}},sphere:{points:Qe(64),shadow:{type:"none"}},heart:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64*Math.PI*2,s=16*Math.pow(Math.sin(i),3),a=-(13*Math.cos(i)-5*Math.cos(2*i)-2*Math.cos(3*i)-Math.cos(4*i));t.push({x:.5+s/32,y:.5+a/32})}return t}(),shadow:{type:"none"}},star:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64,s=Math.floor(10*i),a=s%2==0,h=Math.floor(s/2);let n;n=a?(72*h-90)*Math.PI/180:(72*h+36-90)*Math.PI/180;const r=a?.5:.2;t.push({x:.5+Math.cos(n)*r,y:.5+Math.sin(n)*r})}return t}(),shadow:{type:"none"}},sun:{points:Je(64,12),shadow:{type:"sun",corona:!0,intensity:1.5,flares:!0,texture:!0,turbulence:.3}},moon:{points:Qe(64),shadow:{type:"crescent",coverage:.85,angle:-30,softness:.05,offset:.7}},lunar:{points:Qe(64),shadow:{type:"lunar",coverage:.7,color:"rgba(80, 20, 0, 0.8)",progression:"center"}},suspicion:{points:function(){const t=[];for(let e=0;e<64;e++){const i=e/64*Math.PI*2;let s,a;if(i<Math.PI)s=.45*Math.cos(i),a=.45*Math.sin(i);else{const t=2*Math.PI-i;s=.25*Math.cos(t)-.1,a=.35*Math.sin(t)}t.push({x:.5+s,y:.5+a})}return t}(),shadow:{type:"none"}},eclipse:{points:Qe(64),shadow:{type:"lunar",coverage:.7,color:"rgba(80, 20, 0, 0.8)"}},square:{points:function(){const t=[],e=Math.floor(16);for(let i=0;i<4;i++)for(let s=0;s<e;s++){const a=s/e;let h,n;switch(i){case 0:h=-.5+a,n=-.5;break;case 1:h=.5,n=-.5+a;break;case 2:h=.5-a,n=.5;break;case 3:h=-.5,n=.5-a}t.push({x:.5+.8*h,y:.5+.8*n})}return t}(),shadow:{type:"none"}},triangle:{points:function(){const t=[],e=[{x:0,y:-.5},{x:-.433,y:.25},{x:.433,y:.25}],i=[Math.sqrt(Math.pow(e[1].x-e[0].x,2)+Math.pow(e[1].y-e[0].y,2)),Math.sqrt(Math.pow(e[2].x-e[1].x,2)+Math.pow(e[2].y-e[1].y,2)),Math.sqrt(Math.pow(e[0].x-e[2].x,2)+Math.pow(e[0].y-e[2].y,2))],s=i[0]+i[1]+i[2],a=i.map(t=>Math.round(64*t/s)),h=a.reduce((t,e)=>t+e,0);h<64&&(a[0]+=64-h);for(let i=0;i<3;i++){const s=e[i],h=e[(i+1)%3],n=a[i];for(let e=0;e<n;e++){if(e===n-1&&i<2)continue;const a=e/n,r=s.x+(h.x-s.x)*a,o=s.y+(h.y-s.y)*a;t.push({x:.5+.9*r,y:.5+.9*o})}}for(;t.length<64;)t.push(t[t.length-1]);for(;t.length>64;)t.pop();return t}(),shadow:{type:"none"}},solar:{points:Je(64,12),shadow:{type:"solar-hybrid",corona:!0,intensity:1.5,flares:!0,texture:!0,turbulence:.3,lunarOverlay:{type:"lunar",coverage:1,color:"rgba(0, 0, 0, 1.0)",progression:"center"}}}},Ke=new class{constructor(){this.shapeCache=new Map,this.morphCache=new Map,this.propertyCache=new Map,this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1,this.loadStartTime=0,this.initialize()}initialize(){this.loadStartTime=performance.now();try{const t=Object.keys(Ze);t.forEach(t=>{this.cacheShape(t)}),this.cacheCommonMorphs(t),this.isInitialized=!0,this.stats.loadTime=performance.now()-this.loadStartTime,this.stats.cacheSize=this.shapeCache.size}catch(t){this.isInitialized=!1}}cacheShape(t){try{const e=Ze[t];if(e){this.shapeCache.set(t,e);const i={pointCount:e.points?.length||64,hasShadow:"none"!==e.shadow?.type,shadowType:e.shadow?.type||"none",isRadial:this.isRadialShape(t),bounds:this.calculateBounds(e.points)};this.propertyCache.set(t,i)}}catch(t){}}cacheCommonMorphs(t){[["circle","heart"],["circle","star"],["circle","square"],["heart","star"],["star","circle"],["square","circle"],["triangle","circle"],["moon","sun"],["lunar","eclipse"]].forEach(([e,i])=>{if(t.includes(e)&&t.includes(i))try{const t=this.calculateMorphSteps(e,i),s=`${e}->${i}`;this.morphCache.set(s,t)}catch(t){}})}calculateMorphSteps(t,e){const i=this.shapeCache.get(t),s=this.shapeCache.get(e);if(!i||!s)return null;const a=[];for(let t=0;t<5;t++){const e=t/4,h=this.interpolateShapePoints(i.points,s.points,e);a.push({progress:e,points:h})}return{from:t,to:e,steps:a,isRadial:this.isRadialShape(t)||this.isRadialShape(e)}}interpolateShapePoints(t,e,i){if(!t||!e)return t||e||[];const s=Math.max(t.length,e.length),a=[];for(let h=0;h<s;h++){const s=t[h]||t[0]||{x:.5,y:.5},n=e[h]||e[0]||{x:.5,y:.5};a.push({x:s.x+(n.x-s.x)*i,y:s.y+(n.y-s.y)*i})}return a}isRadialShape(t){return["circle","star","square","triangle","sun","moon"].includes(t)}calculateBounds(t){if(!t||0===t.length)return{minX:0,minY:0,maxX:1,maxY:1,width:1,height:1};let e=1/0,i=1/0,s=-1/0,a=-1/0;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),s=Math.max(s,t.x),a=Math.max(a,t.y)}),{minX:e,minY:i,maxX:s,maxY:a,width:s-e,height:a-i}}getShape(t){if(!this.isInitialized)return Ze[t]||null;const e=this.shapeCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,Ze[t]||null)}getProperties(t){if(!this.isInitialized){const e=Ze[t];return e?{pointCount:e.points?.length||64,hasShadow:"none"!==e.shadow?.type,shadowType:e.shadow?.type||"none",isRadial:this.isRadialShape(t),bounds:this.calculateBounds(e.points)}:{}}const e=this.propertyCache.get(t);return e?(this.stats.hits++,e):(this.stats.misses++,{})}getMorph(t,e){if(!this.isInitialized)return this.calculateMorphSteps(t,e);const i=`${t}->${e}`,s=this.morphCache.get(i);return s?(this.stats.hits++,s):(this.stats.misses++,this.calculateMorphSteps(t,e))}hasShape(t){return this.shapeCache.has(t)}getStats(){const t=this.stats.hits+this.stats.misses;return{...this.stats,hitRate:t>0?`${(this.stats.hits/t*100).toFixed(1)}%`:"0%",shapes:this.shapeCache.size,morphs:this.morphCache.size,properties:this.propertyCache.size}}clear(){this.shapeCache.clear(),this.morphCache.clear(),this.propertyCache.clear(),this.stats={hits:0,misses:0,loadTime:0,cacheSize:0},this.isInitialized=!1}},ti=new class{constructor(){this.pools=new Map,this.inUse=new Set}acquire(t,e="array"){const i=`${e}_${t}`;this.pools.has(i)||this.pools.set(i,[]);const s=this.pools.get(i);if(s.length>0){const t=s.pop();return this.inUse.add(t),t}let a;switch(e){case"float32":a=new Float32Array(t);break;case"uint8":a=new Uint8Array(t);break;default:a=new Array(t).fill(0)}return this.inUse.add(a),a}release(t){if(!this.inUse.has(t))return;this.inUse.delete(t);let e="array";t instanceof Float32Array?e="float32":t instanceof Uint8Array&&(e="uint8");const i=`${e}_${t.length}`;t.fill(0),this.pools.has(i)||this.pools.set(i,[]);const s=this.pools.get(i);s.length<10&&s.push(t)}clear(){this.pools.clear(),this.inUse.clear()}};class ei{applyAudioDeformation(t){return t}setAudioDeformation(){}setVocalEnergy(){}}class ii{constructor(){this.detectedTimeSignature=null,this.timeSignatureConfidence=0,this.timeSignatureLocked=!1,this.forceFastDetection=!1}update(){}calculateBPM(){return 0}findTempoCandidates(){return[]}clusterIntervals(){return[]}checkHarmonicRelation(){return!1}detectTimeSignature(){return"4/4"}testWaltzPattern(){return!1}reset(){}}class si{constructor(t){this.morpher=t,this.isTransitioning=!1,this.transitionStartTime=0,this.transitionDuration=800,this.transitionProgress=0,this.easingFunction="easeInOutQuad",this.currentShape="circle",this.targetShape=null,this.previousShape=null,this.morphQueue=[],this.maxQueueSize=3,this.shadowConfig=null,this.shadowProgress=0}startTransition(t,e={}){this.isTransitioning&&this.morphQueue.length<this.maxQueueSize?this.morphQueue.push({shape:t,options:e}):(this.previousShape=this.currentShape,this.targetShape=t,this.isTransitioning=!0,this.transitionStartTime=performance.now(),this.transitionDuration=e.duration||800,this.easingFunction=e.easing||"easeInOutQuad",this.transitionProgress=0,this.shadowConfig=this.getTransitionConfig(this.currentShape,t))}update(t){if(!this.isTransitioning)return;const e=performance.now()-this.transitionStartTime,i=Math.min(1,e/this.transitionDuration);this.transitionProgress=this.applyEasing(i),this.shadowConfig&&(this.shadowProgress=this.calculateShadowProgress(i)),i>=1&&this.completeTransition()}completeTransition(){if(this.currentShape=this.targetShape,this.targetShape=null,this.isTransitioning=!1,this.transitionProgress=0,this.shadowConfig=null,this.morphQueue.length>0){const t=this.morphQueue.shift();this.startTransition(t.shape,t.options)}}getTransitionConfig(t,e){return{"circle-heart":{type:"bloom",shadowColor:"#ff69b4",shadowIntensity:.3},"heart-circle":{type:"contract",shadowColor:"#ff69b4",shadowIntensity:.2},"circle-star":{type:"burst",shadowColor:"#ffd700",shadowIntensity:.4},"star-circle":{type:"collapse",shadowColor:"#ffd700",shadowIntensity:.3}}[`${t}-${e}`]||null}calculateShadowProgress(t){if(!this.shadowConfig)return 0;switch(this.shadowConfig.type){case"bloom":return t<.5?2*t:2-2*t;case"burst":return Math.pow(1-t,2);case"contract":case"collapse":return Math.sin(t*Math.PI);default:return 0}}applyEasing(t){switch(this.easingFunction){case"linear":default:return t;case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return t<.5?2*t*t:(4-2*t)*t-1;case"easeInCubic":return t*t*t;case"easeOutCubic":return--t*t*t+1;case"easeInOutCubic":return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1}}clearQueue(){this.morphQueue=[]}hasQueuedMorphs(){return this.morphQueue.length>0}getState(){return{isTransitioning:this.isTransitioning,currentShape:this.currentShape,targetShape:this.targetShape,progress:this.transitionProgress,queueLength:this.morphQueue.length}}reset(){this.isTransitioning=!1,this.currentShape="circle",this.targetShape=null,this.transitionProgress=0,this.morphQueue=[],this.shadowConfig=null}}class ai{constructor(t){this.Z=t}getCurrentShadow(){const t=this.Z(),e=t.currentShape||"circle",i=Ke&&Ke.isInitialized?Ke.getShape(e):Ze[e],s=t.targetShape?Ke&&Ke.isInitialized?Ke.getShape(t.targetShape):Ze[t.targetShape]:null,a=i?.shadow||{type:"none"},h=s?.shadow||null;if(!t.isTransitioning||!h)return a;const n=t.morphProgress;if(t.transitionConfig&&"from_moon"===t.transitionConfig.type&&t.transitionConfig.slideOutCrescent)return this.K(n,t.transitionConfig);if(t.transitionConfig&&"moon_to_lunar"===t.transitionConfig.type)return this.tt(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_enter_lunar"===t.transitionConfig.type)return this.et(n,t.transitionConfig);if(t.transitionConfig&&"lunar_to_moon"===t.transitionConfig.type)return this.it(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_exit_lunar"===t.transitionConfig.type)return this.st(n,t.transitionConfig);if(t.transitionConfig&&"eclipse_enter"===t.transitionConfig.type)return this.ht(n,h);if("eclipse_exit"===t.transitionConfig.type)return this.nt(n,a);if("sun_fade"===t.transitionConfig.type)return this.rt(n,a);if("sun_bloom"===t.transitionConfig.type)return this.ot(n,h);if("none"!==a.type||"none"!==h.type){const t=(a.coverage||0)+((h.coverage||0)-(a.coverage||0))*n;return{type:"none"!==h.type?h.type:a.type,coverage:t,angle:h.angle||a.angle||0,softness:h.softness||a.softness||.2,progress:n}}return a}K(t,e){const i=e.shadowSlideRatio||.4;if(t<i){const e=t/i,s=-30*Math.PI/180,a=.7,h=a+(2.5-a)*e;return{type:"crescent",coverage:e>.8?.85*(1-5*(e-.8)):.85,angle:-30,offset:h,shadowX:Math.cos(s)*h,shadowY:Math.sin(s)*h}}return{type:"none"}}tt(t,e){const i=e.startAngle*Math.PI/180,s=1-t,a=.7*Math.cos(i)*s,h=.7*Math.sin(i)*s,n=Math.pow(t,2);if(t<.6)return{type:"crescent",coverage:.85*(1-.2*n),angle:e.startAngle,offset:.7*s,shadowX:a,shadowY:h};{const e=(t-.6)/.4,i=Math.sin(e*Math.PI/2);return{type:"lunar",coverage:.85+.1*i,color:`rgba(80, 20, 0, ${.7+.2*i})`,shadowX:a*(1-i),shadowY:h*(1-i),diffusion:i,shadowProgress:t}}}et(t,e){if(t<.3)return{type:"none"};const i=(t-.3)/.7,s=Math.sin(i*Math.PI/2),a=e.startAngle*Math.PI/180,h=1-s,n=.7*Math.cos(a)*h,r=.7*Math.sin(a)*h;if(i<.7)return{type:"crescent",coverage:.85*Math.pow(i/.7,.5),angle:e.startAngle,offset:.7*h,shadowX:n,shadowY:r};{const t=(i-.7)/.3,e=Math.sin(t*Math.PI/2);return{type:"lunar",coverage:.85+.1*e,color:`rgba(80, 20, 0, ${.6+.3*e})`,shadowX:n*(1-e),shadowY:r*(1-e),diffusion:e,shadowProgress:i}}}it(t,e){const i=e.exitAngle*Math.PI/180,s=Math.sin(t*Math.PI/2),a=.7*Math.cos(i)*s,h=.7*Math.sin(i)*s;if(t<.6){const e=t/.6,i=Math.pow(e,.7);return{type:"lunar",coverage:.95-.1*i,color:`rgba(80, 20, 0, ${.9-.3*i})`,shadowX:.7*a,shadowY:.7*h,diffusion:1-i}}{const i=(t-.6)/.4;return{type:"crescent",coverage:.85*Math.sin(i*Math.PI/2)+.1,angle:e.exitAngle,offset:.7,shadowX:a,shadowY:h}}}st(t,e){if(t<.7){const i=t/.7,s=e.exitAngle*Math.PI/180;if(i<.4){const t=i/.4,e=1-t,a=.3*t;return{type:"lunar",coverage:.95-.1*t,color:`rgba(80, 20, 0, ${.9-.2*t})`,shadowX:.7*Math.cos(s)*a,shadowY:.7*Math.sin(s)*a,diffusion:e}}{const t=(i-.4)/.6,a=Math.pow(t,.8),h=.7*Math.cos(s)*a,n=.7*Math.sin(s)*a;return{type:"crescent",coverage:.85*(1-Math.pow(t,2)),angle:e.exitAngle,offset:.7*a,shadowX:h,shadowY:n}}}return{type:"none"}}ht(t,e){return{...e,shadowX:1.5-1.5*t,shadowProgress:t}}nt(t,e){const i=1.5*-t;return{...e,coverage:e.coverage*(1-t),shadowX:i,shadowProgress:1-t}}rt(t,e){const i=1-t;return{...e,intensity:(e.intensity||1)*Math.pow(i,.7),corona:e.corona,coronaOpacity:i,flares:e.flares,flaresOpacity:Math.pow(i,1.5),texture:e.texture,textureOpacity:Math.pow(i,2),turbulence:(e.turbulence||.3)*i}}ot(t,e){const i=t;return{...e,intensity:(e.intensity||1)*Math.pow(i,1.5),corona:e.corona,coronaOpacity:Math.pow(i,.8),flares:e.flares,flaresOpacity:i>.3?Math.pow((i-.3)/.7,.7):0,texture:e.texture,textureOpacity:i>.5?Math.pow((i-.5)/.5,2):0,turbulence:(e.turbulence||.3)*i}}}class hi{constructor(t={}){this.numPoints=t.numPoints||64,this.morphDuration=t.morphDuration||1e3,this.easing=t.easing||"easeInOutCubic",this.transitionManager=new si(this),this.audioDeformer=new ei(this),this.musicDetector=new ii,this.shadowEffectManager=new ai(()=>({currentShape:this.currentShape,targetShape:this.targetShape,morphProgress:this.morphProgress,isTransitioning:this.isTransitioning,transitionConfig:this.transitionConfig})),this.currentShape="circle",this.targetShape=null,this.morphProgress=0,this.visualProgress=0,this.morphStartTime=null,this.isTransitioning=!1,this.queuedMorphTimeout=null,this.shapeCache=new Map,this.currentPoints=[],this.targetPoints=[],this.musicalDuration=null,this.onBeat=!1,this.audioDeformation=0,this.vocalEnergy=0,this.lastAudioUpdate=0,this.lastVocalUpdate=0,this.audioUpdateInterval=33,this.audioAnalyzer=null,this.frequencyData=ti.acquire(32,"float32"),this.glitchPoints=[],this.undulationPhase=0,this.undulationDirection=1,this.beatGlitchIntensity=0,this.bassEnergy=0,this.vocalPresence=0,this.bassHistory=ti.acquire(60,"float32"),this.vocalHistory=ti.acquire(60,"float32"),this.historyIndex=0,this.bassEffectCooldown=0,this.vocalEffectCooldown=0,this.bassThresholdMultiplier=1.2,this.vocalThresholdMultiplier=1.1,this.bassEffectActive=!1,this.vocalEffectActive=!1,this.transientHoldTime=0,this.vocalGlowBoost=0,this.onComplete=null,this.onProgress=null,this.queuedMorph=null,this.currentPoints=this.getShapePoints("circle"),this.shapesLoaded=!0,this.prewarmCache()}prewarmCache(){["circle","heart","star","sun","moon","lunar","square","triangle"].forEach(t=>{(Ke&&Ke.isInitialized?Ke.hasShape(t):Ze[t])&&this.getShapePoints(t)}),[0,.25,.5,.75,1].forEach(t=>{this.applyEasing(t)})}getShapePoints(t){if(!this.shapeCache.has(t)){const e=Ke&&Ke.isInitialized?Ke.getShape(t):Ze[t];if(!e||!e.points){const e=Ze.circle.points;return this.shapeCache.set(t,e),e}const{points:i}=e;return this.shapeCache.set(t,i),i}return this.shapeCache.get(t)}morphTo(t,e={}){if(!this.shapesLoaded)return;if(t===this.currentShape&&!this.isTransitioning)return;if(this.isTransitioning&&!e.force)return this.queuedMorph={targetShape:t,options:e},"queued";this.isTransitioning&&e.force&&this.completeMorph(!0);const i=this.getTransitionConfig(this.currentShape,t);if(this.targetShape=t,this.targetPoints=this.getShapePoints(t),this.morphStartTime=Date.now(),this.isTransitioning=!0,this.morphProgress=0,this.visualProgress=0,"bar"===e.duration||"beat"===e.duration){const t=500;"bar"===e.duration?this.morphDuration=4*t:this.morphDuration=t,this.musicalDuration=!0,this.onBeat=!1!==e.onBeat}else this.morphDuration=i?.duration||e.duration||1e3,this.musicalDuration=null,this.onBeat=!1;this.morphMode=e.mode||"smooth",this.transitionConfig=i,this.onComplete=e.onComplete,this.onProgress=e.onProgress}update(t){if(this.audioAnalyzer&&this.audioAnalyzer.isAnalyzing){const t=this.audioAnalyzer.getShapeMorpherData();if(t&&t.frequencies)for(let e=0;e<Math.min(t.frequencies.length,this.frequencyData.length);e++)this.frequencyData[e]=t.frequencies[e]}if(this.musicDetector&&this.musicDetector.update(performance.now()),!this.isTransitioning||!this.targetShape)return;const e=Date.now()-this.morphStartTime;if(this.musicalDuration){const t=500,e=this.morphDuration>2*t;this.morphDuration=e?4*t:t}let i=Math.min(e/this.morphDuration,1);if(this.musicalDuration&&this.onBeat){const t=120;let e;e=4;const s=6e4/t,a=this.morphDuration/s,h=i*a,n=Math.round(h*e)/e,r=Math.min(1,n/a),o=(.3+.5*Math.max(.4,Math.min(1,1-(t-90)/90)))*(.3+.7*Math.sin(i*Math.PI));i+=o*o*(3-2*o)*(r-i)}this.morphProgress=this.applyEasing(i),this.visualProgress=.8*this.visualProgress+.2*this.morphProgress,Math.abs(this.visualProgress-this.morphProgress)<.001&&(this.visualProgress=this.morphProgress),this.onProgress&&this.onProgress(this.morphProgress),this.morphProgress>=1&&(this.visualProgress=1,this.completeMorph())}completeMorph(t=!1){if(this.targetShape&&(this.currentShape=this.targetShape,this.currentPoints=[...this.targetPoints]),this.targetShape=null,this.isTransitioning=!1,this.morphProgress=0,this.visualProgress=0,this.onComplete&&this.onComplete(this.currentShape),!t&&this.queuedMorph){const t=this.queuedMorph;this.queuedMorph=null,this.queuedMorphTimeout=setTimeout(()=>{this.morphTo(t.targetShape,t.options),this.queuedMorphTimeout=null},50)}}hasQueuedMorph(){return null!==this.queuedMorph}clearQueue(){this.queuedMorph=null,this.queuedMorphTimeout&&(clearTimeout(this.queuedMorphTimeout),this.queuedMorphTimeout=null)}getCanvasPoints(t,e,i){let s;try{s=this.getInterpolatedPoints()}catch{s=this.generateFallbackCircle()}this.canvasPointsCache||(this.canvasPointsCache=[]);const a=this.canvasPointsCache;if(a.length=0,!s||0===s.length){for(let s=0;s<this.numPoints;s++){const h=s/this.numPoints*Math.PI*2;a.push({x:t+Math.cos(h)*i,y:e+Math.sin(h)*i})}return a}const h=Array.isArray(s)?s:[];for(let s=0;s<h.length;s++){const n=h[s];if(n&&"number"==typeof n.x&&"number"==typeof n.y){const s=t+(n.x-.5)*i*2,h=e+(n.y-.5)*i*2;a.push({x:s,y:h})}else{const n=s/h.length*Math.PI*2;a.push({x:t+Math.cos(n)*i,y:e+Math.sin(n)*i})}}for(;a.length<this.numPoints;){const s=a.length/this.numPoints*Math.PI*2;a.push({x:t+Math.cos(s)*i,y:e+Math.sin(s)*i})}return a}getInterpolatedPoints(){if(this.currentPoints&&0!==this.currentPoints.length||(this.currentPoints=this.generateFallbackCircle()),!this.isTransitioning)return this.applyAudioDeformation(this.currentPoints);const t=[];for(let e=0;e<this.numPoints;e++){const i=this.currentPoints[e],s=this.targetPoints[e];if(!i||!s){const i=e/this.numPoints*Math.PI*2;t.push({x:.5+.5*Math.cos(i),y:.5+.5*Math.sin(i)});continue}const a=this.visualProgress;let h,n;const r=["square","circle","star","triangle"],o=r.includes(this.currentShape),l=r.includes(this.targetShape);if(o||l){const t=.5,e=.5;if(l&&!o){const r=s.x-t,o=s.y-e;if(a<.3){const s=a/.3;h=i.x+(t-i.x)*s,n=i.y+(e-i.y)*s}else{const i=(a-.3)/.7;h=t+r*i,n=e+o*i}}else if(o&&!l){const r=i.x-t,o=i.y-e;if(a<.5){const t=a/.5;h=i.x-r*t,n=i.y-o*t}else{const i=(a-.5)/.5;h=t+(s.x-t)*i,n=e+(s.y-e)*i}}else{const r=i.x-t,o=i.y-e,l=s.x-t,c=s.y-e;if(a<.5){const t=a/.5;h=i.x-r*t,n=i.y-o*t}else{const i=(a-.5)/.5;h=t+l*i,n=e+c*i}}}else if("spiral"===this.morphMode){const t=a*Math.PI*2,r=.02*Math.sin(t+.2*e)*(1-2*Math.abs(a-.5));h=i.x+(s.x-i.x)*a+r,n=i.y+(s.y-i.y)*a+r}else if("wave"===this.morphMode){const t=.01*Math.sin(.3*e+a*Math.PI*4);h=i.x+(s.x-i.x)*a+t,n=i.y+(s.y-i.y)*a+t}else h=i.x+(s.x-i.x)*a,n=i.y+(s.y-i.y)*a;t.push({x:h,y:n})}return this.applyAudioDeformation(t)}applyAudioDeformation(t){return this.audioDeformer.applyAudioDeformation(t)}setAudioDeformation(t){const e=Date.now();e-this.lastAudioUpdate>this.audioUpdateInterval&&(this.audioDeformation=Math.max(-1,Math.min(1,t)),this.lastAudioUpdate=e,this.audioDeformer&&this.audioDeformer.setAudioDeformation(Math.abs(this.audioDeformation)))}setVocalEnergy(t){const e=Date.now();e-this.lastVocalUpdate>this.audioUpdateInterval&&(this.vocalEnergy=Math.max(0,Math.min(1,t)),this.lastVocalUpdate=e,this.audioDeformer&&this.audioDeformer.setVocalEnergy(this.vocalEnergy))}getTransitionConfig(t,e){const i=Ke&&Ke.isInitialized?Ke.getShape(t):Ze[t],s=Ke&&Ke.isInitialized?Ke.getShape(e):Ze[e];return"moon"===e?{type:"to_moon",easing:"easeInOutCubic",duration:1500,glowIntensity:1.5,fadeInCrescent:!0}:"moon"===t&&"lunar"===e?{type:"moon_to_lunar",easing:"easeInOutSine",duration:2e3,slideOutCrescent:!1,description:"Crescent shadow moves to center and becomes lunar eclipse"}:"moon"===t?{type:"from_moon",easing:"easeInOutCubic",duration:1e3,slideOutCrescent:!0,shadowSlideRatio:.4,description:"Moon shadow slides away THEN morphs to target"}:"lunar"===e?{type:"eclipse_enter_lunar",startAngle:-30}:"lunar"===t&&"moon"===e?{type:"lunar_to_moon",exitAngle:-30}:"lunar"===t?{type:"eclipse_exit_lunar",exitAngle:-30}:"none"===i?.shadow?.type&&"solar"===s?.shadow?.type?{type:"eclipse_enter",direction:"right"}:"solar"===i?.shadow?.type&&"none"===s?.shadow?.type?{type:"eclipse_exit",direction:"left"}:"sun"===t&&"sun"!==e?{type:"sun_fade",fadeEffects:!0}:"sun"!==t&&"sun"===e?{type:"sun_bloom",bloomEffects:!0}:{type:"standard"}}getCurrentShadow(){return this.shadowEffectManager.getCurrentShadow()}getCurrentRenderer(){return null}applyEasing(t){switch(this.transitionConfig?.easing||this.easing||"linear"){case"linear":return t;case"easeInQuad":return t*t;case"easeOutQuad":return t*(2-t);case"easeInOutQuad":return t<.5?2*t*t:(4-2*t)*t-1;case"easeInOutSine":return-(Math.cos(Math.PI*t)-1)/2;default:return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}}calculateBPM(){return this.musicDetector.calculateBPM()}findTempoCandidates(t){return this.musicDetector.findTempoCandidates(t)}clusterIntervals(t){return this.musicDetector.clusterIntervals(t)}checkHarmonicRelation(t,e){return this.musicDetector.checkHarmonicRelation(t,e)}detectTimeSignature(){this.musicDetector.forceFastDetection=this.forceFastDetection;const t=this.musicDetector.detectTimeSignature();return this.detectedTimeSignature=this.musicDetector.detectedTimeSignature,this.timeSignatureConfidence=this.musicDetector.timeSignatureConfidence,this.timeSignatureLocked=this.musicDetector.timeSignatureLocked,t}testWaltzPattern(t,e){return this.musicDetector.testWaltzPattern(t,e)}resetMusicDetection(){this.forceFastDetection=!0,this.musicDetector.reset(),this.musicDetector.forceFastDetection=!0,this.onsetThreshold=0,this.detectedBPM=0,this.bpmConfidence=0,this.onsetStrengths=[],this.detectedTimeSignature=null,this.timeSignatureConfidence=0,this.musicDetector.lastBPMCalculation=0,this.measureStartTime=0,this.timeSignatureHistory=[],this.timeSignatureLocked=!1,this.spectralHistory=[],this.spectralFluxHistory=[];const t=document.getElementById("time-sig-display");t&&(t.textContent="โ")}getCurrentMusicInfo(){return{bpm:this.detectedBPM,timeSignature:this.detectedTimeSignature,bpmLocked:this.tempoLocked,timeSigLocked:this.timeSignatureLocked}}generateFallbackCircle(){const t=[];for(let e=0;e<this.numPoints;e++){const i=e/this.numPoints*Math.PI*2;t.push({x:.5+.5*Math.cos(i),y:.5+.5*Math.sin(i)})}return t}getState(){return{currentShape:this.currentShape,targetShape:this.targetShape,isTransitioning:this.isTransitioning,progress:this.morphProgress,audioDeformation:this.audioDeformation,vocalEnergy:this.vocalEnergy}}getProgress(t=!0){return t?this.visualProgress:this.morphProgress}isInTransition(){return this.isTransitioning}destroy(){this.queuedMorphTimeout&&(clearTimeout(this.queuedMorphTimeout),this.queuedMorphTimeout=null),this.queuedMorph=null,this.shapeCache.clear(),this.canvasPointsCache=null,this.frequencyData&&(ti.release(this.frequencyData),this.frequencyData=null),this.bassHistory&&(ti.release(this.bassHistory),this.bassHistory=null),this.vocalHistory&&(ti.release(this.vocalHistory),this.vocalHistory=null),this.audioAnalyzer=null}}class ni{constructor(){this.lt=120,this.ct=new Float64Array(this.lt),this.ut=0,this.dt=0,this.fps=0,this.smoothedFPS=0,this.smoothingFactor=.9,this.lastFrameTime=0,this.frameTime=0,this.maxFrameTimeSamples=10,this.ft=new Float64Array(this.maxFrameTimeSamples),this.Mt=0,this.gt=0,this.averageFrameTime=0}update(t){this.ct[this.ut]=t,this.ut=(this.ut+1)%this.lt,this.dt<this.lt&&this.dt++;const e=t-1e3;let i=0;for(let t=0;t<this.dt;t++)this.ct[t]>e&&i++;if(this.fps=i,0===this.smoothedFPS?this.smoothedFPS=this.fps:this.smoothedFPS=this.smoothedFPS*this.smoothingFactor+this.fps*(1-this.smoothingFactor),this.lastFrameTime>0&&(this.frameTime=t-this.lastFrameTime,this.ft[this.Mt]=this.frameTime,this.Mt=(this.Mt+1)%this.maxFrameTimeSamples,this.gt<this.maxFrameTimeSamples&&this.gt++,this.gt>0)){let t=0;for(let e=0;e<this.gt;e++)t+=this.ft[e];this.averageFrameTime=t/this.gt}this.lastFrameTime=t}getFPS(){return Math.round(this.fps)}getSmoothedFPS(){return Math.round(this.smoothedFPS)}getFrameTime(){return this.frameTime}getAverageFrameTime(){return this.averageFrameTime}reset(){this.ct.fill(0),this.ut=0,this.dt=0,this.fps=0,this.smoothedFPS=0,this.lastFrameTime=0,this.frameTime=0,this.ft.fill(0),this.Mt=0,this.gt=0,this.averageFrameTime=0}getMetrics(){return{fps:this.getFPS(),smoothedFPS:this.getSmoothedFPS(),frameTime:this.getFrameTime(),averageFrameTime:this.getAverageFrameTime(),status:this.fps>=55?"good":this.fps>=30?"okay":"poor"}}}class ri{constructor(t,e={}){this.errorBoundary=t,this.config=e,this.config.targetFPS=e.targetFPS||60,this.loopManager=e.loopManager||Le,this.isRunning=!1,this.animationFrameId=null,this.loopCallbackId=null,this.lastFrameTime=0,this.deltaTime=0,this.isPaused=!1,this.speedMultiplier=1,this.handleVisibilityChange=this.handleVisibilityChange.bind(this),this.handleWindowBlur=this.handleWindowBlur.bind(this),this.handleWindowFocus=this.handleWindowFocus.bind(this),"undefined"!=typeof document&&(document.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("blur",this.handleWindowBlur),window.addEventListener("focus",this.handleWindowFocus)),this.performanceMonitor=null,this.fpsCounter=new ni,this.subsystems={},this.eventCallback=null,this.parentMascot=null}setSubsystems(t){this.subsystems={stateMachine:t.stateMachine,particleSystem:t.particleSystem,renderer:t.renderer,soundSystem:t.soundSystem,canvasManager:t.canvasManager};const e=["stateMachine","particleSystem","renderer"];for(const t of e)if(!this.subsystems[t])throw new Error(`Required subsystem '${t}' not provided`);this.performanceMonitor&&this.performanceMonitor.setSubsystems(this.subsystems)}setEventCallback(t){if("function"!=typeof t)throw new Error("Event callback must be a function");this.eventCallback=t}setParentMascot(t){this.parentMascot=t}emit(t,e=null){this.eventCallback&&this.eventCallback(t,e)}start(){return this.errorBoundary.wrap(()=>{if(this.isRunning)return!1;if(!this.subsystems.stateMachine)throw new Error("Cannot start animation without subsystems configured");return this.isRunning=!0,this.lastFrameTime=performance.now(),this.subsystems.soundSystem&&this.subsystems.soundSystem.isAvailable()&&this.subsystems.soundSystem.resumeContext(),this.loopCallbackId=this.loopManager.register((t,e)=>this.animate(t,e),0,this),this.emit("animationStarted",{targetFPS:this.targetFPS}),!0},"animation-start")()}stop(){return this.errorBoundary.wrap(()=>!!this.isRunning&&(this.isRunning=!1,this.loopCallbackId&&(this.loopManager.unregister(this.loopCallbackId),this.loopCallbackId=null),this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.subsystems.renderer&&this.subsystems.renderer.stopAllGestures&&this.subsystems.renderer.stopAllGestures(),this.subsystems.soundSystem&&this.subsystems.soundSystem.isAvailable()&&this.subsystems.soundSystem.stopAmbientTone(),this.subsystems.particleSystem&&this.subsystems.particleSystem.clear(),this.emit("animationStopped"),!0),"animation-stop")()}handleWindowBlur(){document.hidden||this.handleVisibilityChange()}handleWindowFocus(){!document.hidden&&this.isPaused&&this.handleVisibilityChange()}handleVisibilityChange(){if(document.hidden)this.wasRunning=this.isRunning,this.isPaused=!0,this.pauseTime=performance.now(),this.subsystems?.particleSystem&&(this.subsystems.particleSystem.resetAccumulator(),this.pausedParticleCount=this.subsystems.particleSystem.particles?.length||0),this.subsystems?.renderer?.gestureAnimator&&this.subsystems.renderer.gestureAnimator.pauseCurrentAnimation?.(),this.parentMascot?.pause&&this.parentMascot.pause();else if(this.isPaused&&this.wasRunning){const t=performance.now(),e=t-this.pauseTime;this.lastFrameTime=t,this.frameTimeAccumulator=0,this.fpsCounter&&this.fpsCounter.reset(),this.subsystems?.particleSystem&&this.subsystems.particleSystem.onVisibilityResume(e,this.pausedParticleCount),this.renderer&&(e>X&&this.renderer.resetCanvasContext(),this.renderer.gestureAnimator&&this.renderer.gestureAnimator.resumeAnimation?.(),e>X&&(this.renderer.forceCleanRender=!0)),this.subsystems?.stateMachine&&(this.subsystems.stateMachine.lastUpdateTime=t),this.parentMascot?.resume&&this.parentMascot.resume(),this.isPaused=!1}}animate(t,e){if(!this.isRunning||this.isPaused)return;const i=e||performance.now();this.deltaTime=t||i-this.lastFrameTime,this.deltaTime>20&&(this.deltaTime=20),this.deltaTime>q&&this.deltaTime<20&&(this.deltaTime=q),this.lastFrameTime=i,this.deltaTime*=this.speedMultiplier,this.update(this.deltaTime),this.render()}update(t){if(this.subsystems.stateMachine&&this.subsystems.stateMachine.update(t),this.parentMascot?.stateCoordinator?.yt&&this.parentMascot.stateCoordinator.yt.update(t),this.parentMascot&&"function"==typeof this.parentMascot.update&&this.parentMascot.update(t),"classic"!==this.parentMascot?.config?.renderingStyle&&this.subsystems.particleSystem&&this.subsystems.stateMachine&&this.subsystems.canvasManager){const e=this.subsystems.stateMachine.getCurrentEmotionalProperties();let i;i=this.subsystems.renderer&&"function"==typeof this.subsystems.renderer.getEffectiveCenter?this.subsystems.renderer.getEffectiveCenter():this.subsystems.canvasManager.getCenter();let s=null,a=0;if(this.subsystems.renderer&&this.subsystems.renderer.getCurrentGesture){const t=this.subsystems.renderer.getCurrentGesture();t&&t.particleMotion&&(s=t.particleMotion,a=t.progress||0)}this.subsystems.particleSystem.spawn(e.particleBehavior,this.subsystems.stateMachine.getCurrentState().emotion,e.particleRate,i.x,i.y,t),this.subsystems.particleSystem.update(t,i.x,i.y,s,a)}this.performanceMonitor&&this.performanceMonitor.updateMetrics({particleCount:this.subsystems.particleSystem?.getActiveParticleCount?.()||0,audioLatency:this.subsystems.soundSystem?.getLatency?.()||0})}render(){this.parentMascot&&"function"==typeof this.parentMascot.render?this.parentMascot.render():this.subsystems.renderer&&this.subsystems.renderer.render()}getPerformanceMetrics(){const t=this.fpsCounter?this.fpsCounter.getMetrics():{};return{fps:t.fps||60,instantFps:t.smoothedFPS||60,frameTime:t.frameTime||16.67,averageFrameTime:t.averageFrameTime||16.67,isRunning:this.isRunning,deltaTime:this.deltaTime}}setTargetFPS(t){}get targetFPS(){return this.config.targetFPS||60}setSpeedMultiplier(t){this.speedMultiplier=Math.max(.1,Math.min(10,t))}getSpeedMultiplier(){return this.speedMultiplier}isAnimating(){return this.isRunning}destroy(){this.stop(),"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("blur",this.handleWindowBlur),window.removeEventListener("focus",this.handleWindowFocus)),this.performanceMonitor&&(this.performanceMonitor.destroy(),this.performanceMonitor=null),this.subsystems={},this.eventCallback=null}}class oi{constructor(t,e={}){this.canvas=t,this.config={smoothing:e.smoothing||.1,maxOffset:e.maxOffset||.3,lockDistance:e.lockDistance||30,enabled:!1!==e.enabled,boundaryPadding:e.boundaryPadding||.8},this.canvasCenter={x:0,y:0},this.mousePos={x:0,y:0},this.targetGaze={x:0,y:0},this.currentGaze={x:0,y:0},this.isLocked=!1,this.proximity=0,this.cachedRect=null,this.touches=new Map,this.primaryTouch=null,this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.onInteraction=null,this.updateCanvasCenter(),this.attachEventListeners(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver(()=>{this.updateCanvasCenter()}),this.resizeObserver.observe(this.canvas))}updateCanvasCenter(){this.cachedRect=this.canvas.getBoundingClientRect(),this.canvasCenter={x:this.cachedRect.width/2,y:this.cachedRect.height/2},0===this.mousePos.x&&0===this.mousePos.y&&(this.mousePos={x:this.canvasCenter.x,y:this.canvasCenter.y})}attachEventListeners(){this.config.enabled&&(this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),this.canvas.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),this.canvas.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),this.canvas.addEventListener("touchcancel",this.handleTouchEnd,{passive:!0}))}handleMouseMove(t){const e=this.cachedRect||this.canvas.getBoundingClientRect();this.mousePos={x:t.clientX-e.left,y:t.clientY-e.top},this.updateTargetGaze(),this.onInteraction&&this.onInteraction("mouse")}handleMouseLeave(){this.targetGaze={x:0,y:0},this.isLocked=!1,this.proximity=0,this.mousePos={x:this.canvasCenter.x,y:this.canvasCenter.y}}handleTouchStart(t){for(const e of t.changedTouches)this.touches.set(e.identifier,{x:e.clientX,y:e.clientY}),this.primaryTouch||1!==this.touches.size||(this.primaryTouch=e.identifier);null!==this.primaryTouch&&this.updateTouchPosition(t.touches)}handleTouchMove(t){for(const e of t.changedTouches)this.touches.has(e.identifier)&&this.touches.set(e.identifier,{x:e.clientX,y:e.clientY});null!==this.primaryTouch&&(this.updateTouchPosition(t.touches),this.onInteraction&&this.onInteraction("touch"))}handleTouchEnd(t){for(const e of t.changedTouches)this.touches.delete(e.identifier),e.identifier===this.primaryTouch&&(this.primaryTouch=null,this.touches.size>0?this.primaryTouch=this.touches.keys().next().value:this.handleMouseLeave())}updateTouchPosition(t){for(const e of t)if(e.identifier===this.primaryTouch){const t=this.cachedRect||this.canvas.getBoundingClientRect();this.mousePos={x:e.clientX-t.left,y:e.clientY-t.top},this.updateTargetGaze();break}}updateTargetGaze(){const t=this.mousePos.x-this.canvasCenter.x,e=this.mousePos.y-this.canvasCenter.y,i=Math.sqrt(t*t+e*e),s=Math.min(this.canvasCenter.x,this.canvasCenter.y);if(this.proximity=Math.max(0,1-i/s),this.isLocked=i<this.config.lockDistance,this.isLocked)this.targetGaze={x:t*this.config.maxOffset*2,y:e*this.config.maxOffset*2};else{const a=Math.min(this.canvasCenter.x,this.canvasCenter.y)*this.config.maxOffset;if(i>0){const h=Math.min(1,i/s);this.targetGaze={x:t/i*a*h*this.config.boundaryPadding,y:e/i*a*h*this.config.boundaryPadding}}else this.targetGaze={x:0,y:0}}}update(t){if(!this.config.enabled)return;const e=1-Math.pow(1-this.config.smoothing,t/16.67);if(this.currentGaze.x+=(this.targetGaze.x-this.currentGaze.x)*e,this.currentGaze.y+=(this.targetGaze.y-this.currentGaze.y)*e,this.isLocked){const t=.5;this.currentGaze.x+=(Math.random()-.5)*t,this.currentGaze.y+=(Math.random()-.5)*t}}getGazeOffset(t){return{x:this.currentGaze.x,y:this.currentGaze.y}}getState(){return{gaze:{...this.currentGaze},target:{...this.targetGaze},proximity:this.proximity,isLocked:this.isLocked,isActive:this.config.enabled}}enable(){this.config.enabled||(this.config.enabled=!0,this.attachEventListeners())}disable(){this.config.enabled&&(this.config.enabled=!1,this.detachEventListeners(),this.targetGaze={x:0,y:0})}detachEventListeners(){this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("touchstart",this.handleTouchStart),this.canvas.removeEventListener("touchmove",this.handleTouchMove),this.canvas.removeEventListener("touchend",this.handleTouchEnd),this.canvas.removeEventListener("touchcancel",this.handleTouchEnd)}setInteractionCallback(t){this.onInteraction=t}destroy(){this.detachEventListeners(),this.resizeObserver&&this.resizeObserver.disconnect(),this.touches.clear()}}class li{constructor(t={}){this.config={blinkInterval:t.blinkInterval||{min:3e3,max:7e3},blinkDuration:t.blinkDuration||150,swayInterval:t.swayInterval||{min:2e4,max:4e4},swayDuration:t.swayDuration||4e3,swayIntensity:t.swayIntensity||1.5,sleepTimeout:void 0!==t.sleepTimeout?t.sleepTimeout:1/0,breathingSpeed:t.breathingSpeed||.25,breathingDepth:t.breathingDepth||.1,enabled:!1!==t.enabled},this.state={isBlinking:!1,isSwaying:!1,isAsleep:!1,breathingPhase:0,breathRate:1,breathDepth:this.config.breathingDepth},this.timers={idle:0,blink:0,sway:0,swayProgress:0,nextBlink:this.getRandomInterval("blink"),nextSway:this.getRandomInterval("sway")},this.swayOffset={x:0,y:0},this.swayTarget={x:0,y:0},this.swayStart={x:0,y:0},this.wakeUpTimeout=null,this.callbacks={onBlink:null,onSway:null,onSleep:null,onWake:null}}update(t){this.config.enabled&&(this.updateBreathing(t),this.timers.idle+=t,!this.state.isAsleep&&this.timers.idle>=this.config.sleepTimeout&&this.enterSleep(),this.state.isAsleep||this.updateBlinking(t),this.state.isAsleep||this.updateSwaying(t))}updateBreathing(t){const e=this.config.breathingSpeed*this.state.breathRate;this.state.breathingPhase+=e*t/1e3,this.state.breathingPhase>2*Math.PI&&(this.state.breathingPhase-=2*Math.PI)}updateBlinking(t){this.isBlinkingEnabled()&&(this.state.isBlinking?(this.timers.blink+=t,this.timers.blink>=this.config.blinkDuration&&this.endBlink()):(this.timers.blink+=t,this.timers.blink>=this.timers.nextBlink&&this.startBlink()))}updateSwaying(t){if(this.state.isSwaying){this.timers.sway+=t;const e=Math.min(this.timers.sway/this.config.swayDuration,1),i=(Math.sin((e-.5)*Math.PI)+1)/2;this.swayOffset.x=this.swayStart.x+(this.swayTarget.x-this.swayStart.x)*i,this.swayOffset.y=this.swayStart.y+(this.swayTarget.y-this.swayStart.y)*i,e>=1&&this.endSway()}else this.timers.sway+=t,this.timers.sway>=this.timers.nextSway&&this.startSway()}startBlink(){this.state.isBlinking=!0,this.timers.blink=0,this.callbacks.onBlink&&this.callbacks.onBlink({phase:"start"})}endBlink(){this.state.isBlinking=!1,this.timers.blink=0,this.timers.nextBlink=this.getRandomInterval("blink"),this.callbacks.onBlink&&this.callbacks.onBlink({phase:"end"})}startSway(){this.state.isSwaying=!0,this.timers.sway=0,this.swayStart={...this.swayOffset};const t=Math.random()*Math.PI*2,e=this.config.swayIntensity*(.5+.5*Math.random());this.swayTarget={x:Math.cos(t)*e*1.5,y:Math.sin(t)*e*.5},this.callbacks.onSway&&this.callbacks.onSway({phase:"start",offset:this.swayOffset})}endSway(){this.state.isSwaying=!1,this.timers.sway=0,this.timers.nextSway=this.getRandomInterval("sway"),this.swayStart={...this.swayOffset},this.callbacks.onSway&&this.callbacks.onSway({phase:"end",offset:this.swayOffset})}enterSleep(){this.state.isAsleep=!0,this.state.breathRate=.5,this.state.breathDepth=.15,this.state.isBlinking&&(this.state.isBlinking=!1,this.timers.blink=0,this.callbacks.onBlink&&this.callbacks.onBlink({phase:"end"})),this.callbacks.onSleep&&this.callbacks.onSleep()}wakeUp(){this.state.isAsleep&&(this.state.isAsleep=!1,this.state.breathRate=1,this.state.breathDepth=this.config.breathingDepth,this.timers.idle=0,this.callbacks.onWake&&this.callbacks.onWake(),this.performWakeAnimation())}performWakeAnimation(){const t={x:.5*this.config.swayIntensity,y:-this.config.swayIntensity};this.swayStart={...this.swayOffset},this.swayTarget=t,this.state.isSwaying=!0,this.timers.sway=0,this.callbacks.onSway&&this.callbacks.onSway({phase:"wake",offset:this.swayOffset}),this.wakeUpTimeout&&clearTimeout(this.wakeUpTimeout),this.wakeUpTimeout=setTimeout(()=>{this.swayStart={...this.swayOffset},this.swayTarget={x:0,y:0},this.timers.sway=0,this.wakeUpTimeout=null},1e3)}resetIdleTimer(){this.timers.idle=0,this.state.isAsleep&&this.wakeUp()}setBlinkingEnabled(t){this.config.blinkingEnabled=t,!t&&this.state.isBlinking&&this.endBlink()}isBlinkingEnabled(){return!1!==this.config.blinkingEnabled}getBreathingFactor(){return 1+Math.sin(this.state.breathingPhase)*this.state.breathDepth*this.state.breathRate}getBlinkProgress(){return this.state.isBlinking?Math.min(this.timers.blink/this.config.blinkDuration,1):0}getSwayOffset(){return this.swayOffset||{x:0,y:0}}getRandomInterval(t){const e=this.config[`${t}Interval`];return e.min+Math.random()*(e.max-e.min)}setCallback(t,e){({}).hasOwnProperty.call(this.callbacks,t)&&(this.callbacks[t]=e)}getState(){return{...this.state,breathingFactor:this.getBreathingFactor(),blinkProgress:this.getBlinkProgress(),swayOffset:this.getSwayOffset()}}enable(){this.config.enabled=!0}disable(){this.config.enabled=!1,this.state.isBlinking=!1,this.state.isSwaying=!1,this.swayOffset={x:0,y:0}}destroy(){this.wakeUpTimeout&&(clearTimeout(this.wakeUpTimeout),this.wakeUpTimeout=null),this.callbacks={onBlink:null,onSway:null,onSleep:null,onWake:null}}}class ci{constructor(){this.methods=new Map}call(){}getAvailableMethods(){return[]}hasMethod(){return!1}stopAll(){}destroy(){}}class ui{moveToElement(){}moveToButton(){}moveToForm(){}moveToModal(){}moveToNavigation(){}moveToContent(){}moveToSidebar(){}moveToHeader(){}moveToFooter(){}destroy(){}}class pi{constructor(t={}){this.offsetX=t.offsetX||0,this.offsetY=t.offsetY||0,this.offsetZ=t.offsetZ||0,this.isAnimating=!1,this.animationId=null,this.animationStartTime=0,this.animationDuration=0,this.animationEasing="easeOutCubic",this.startOffset={x:0,y:0,z:0},this.targetOffset={x:0,y:0,z:0},this.onUpdate=t.onUpdate||(()=>{}),this.onAnimationComplete=t.onAnimationComplete||(()=>{}),this.minScale=t.minScale||.5,this.maxScale=t.maxScale||2,this.zScaleRange=t.zScaleRange||1e3,this.globalScale=1,this.coreScaleOverride=1,this.particleScaleOverride=1,this.positioning=new ci(this),this.elementTargeting=new ui(this)}setOffset(t,e,i=0){this.stopAnimation(),this.offsetX=t,this.offsetY=e,this.offsetZ=i,this.onUpdate(this.getEffectiveCenter())}getOffset(){return{x:this.offsetX,y:this.offsetY,z:this.offsetZ}}getPosition(t=window.innerWidth/2,e=window.innerHeight/2){return{x:t+this.offsetX,y:e+this.offsetY,z:this.offsetZ,scale:this.getZScale()}}animateOffset(t,e,i=0,s=1e3,a="easeOutCubic"){this.stopAnimation(),this.startOffset={x:this.offsetX,y:this.offsetY,z:this.offsetZ},this.targetOffset={x:t,y:e,z:i},this.animationDuration=s,this.animationEasing=a,this.animationStartTime=performance.now(),this.isAnimating=!0,this.startAnimation()}stopAnimation(){this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isAnimating=!1}startAnimation(){const t=e=>{if(!this.isAnimating)return;const i=e-this.animationStartTime,s=Math.min(i/this.animationDuration,1),a=this.applyEasing(s,this.animationEasing);this.offsetX=this.lerp(this.startOffset.x,this.targetOffset.x,a),this.offsetY=this.lerp(this.startOffset.y,this.targetOffset.y,a),this.offsetZ=this.lerp(this.startOffset.z,this.targetOffset.z,a),this.onUpdate(this.getEffectiveCenter()),s>=1?(this.isAnimating=!1,this.onAnimationComplete()):this.animationId=requestAnimationFrame(t)};this.animationId=requestAnimationFrame(t)}getEffectiveCenter(t=0,e=0){return{x:t+this.offsetX,y:e+this.offsetY,scale:this.getZScale(),coreScale:this.getCoreScale(),particleScale:this.getParticleScale()}}getZScale(){const t=-this.offsetZ/this.zScaleRange,e=Math.max(-1,Math.min(1,t));return this.lerp(this.minScale,this.maxScale,(e+1)/2)*this.globalScale}setGlobalScale(t){this.globalScale=Math.max(.1,t),this.onUpdate(this.getEffectiveCenter())}setScaleOverrides(t){"number"==typeof t?(this.globalScale=Math.max(.1,t),this.coreScaleOverride=1,this.particleScaleOverride=1):(void 0!==t.global&&(this.globalScale=Math.max(.1,t.global)),void 0!==t.core&&(this.coreScaleOverride=Math.max(.1,t.core)),void 0!==t.particles&&(this.particleScaleOverride=Math.max(.1,t.particles))),this.onUpdate(this.getEffectiveCenter())}getCoreScale(){return this.calculateBaseZScale()*this.globalScale*this.coreScaleOverride}getParticleScale(){return this.calculateBaseZScale()*this.globalScale*this.particleScaleOverride}calculateBaseZScale(){const t=-this.offsetZ/this.zScaleRange,e=Math.max(-1,Math.min(1,t));return this.lerp(this.minScale,this.maxScale,(e+1)/2)}lerp(t,e,i){return t+(e-t)*i}applyEasing(t,e){switch(e){case"linear":default:return t;case"easeInQuad":return t*t;case"easeOutQuad":return 1-(1-t)*(1-t);case"easeInOutQuad":return t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;case"easeInCubic":return t*t*t;case"easeOutCubic":return 1-Math.pow(1-t,3);case"easeInOutCubic":return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;case"easeInBack":{const e=1.70158;return(e+1)*t*t*t-e*t*t}case"easeOutBack":{const e=1.70158;return 1+(e+1)*Math.pow(t-1,3)+e*Math.pow(t-1,2)}}}getPositioning(){return this.positioning}getElementTargeting(){return this.elementTargeting}callPositioning(t,...e){return this.positioning.call(t,...e)}destroy(){this.stopAnimation(),this.positioning&&(this.positioning.destroy(),this.positioning=null),this.elementTargeting&&(this.elementTargeting.destroy(),this.elementTargeting=null),this.onUpdate=null,this.onAnimationComplete=null}}class di{constructor(){if(di.bt)return this.features=di.bt,void(this.capabilities=di.wt);this.features={webAudio:this.detectWebAudio(),canvas2d:this.detectCanvas2D(),requestAnimationFrame:this.detectRequestAnimationFrame(),devicePixelRatio:this.detectDevicePixelRatio(),audioContext:this.detectAudioContext(),mediaDevices:this.detectMediaDevices(),performance:this.detectPerformance(),intersectionObserver:this.detectIntersectionObserver()},this.capabilities=this.assessCapabilities(),di.bt=this.features,di.wt=this.capabilities}detectWebAudio(){try{return!(!window.AudioContext&&!window.webkitAudioContext)}catch{return!1}}detectCanvas2D(){try{const t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))}catch{return!1}}detectRequestAnimationFrame(){return!!(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame)}detectDevicePixelRatio(){return"number"==typeof window.devicePixelRatio}detectAudioContext(){try{return!(!window.AudioContext&&!window.webkitAudioContext)}catch{return!1}}detectMediaDevices(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)}detectPerformance(){return!(!window.performance||!window.performance.now)}detectIntersectionObserver(){return"function"==typeof window.IntersectionObserver}assessCapabilities(){const t=Object.values(this.features).filter(Boolean).length,e=Object.keys(this.features).length,i=t/e*100;let s="basic";return i>=90?s="full":i>=70?s="good":i>=50&&(s="limited"),{score:t,total:e,percentage:i,level:s,recommendations:this.getRecommendations(s)}}getRecommendations(t){const e=[];return this.features.webAudio||e.push("Audio features will be disabled"),this.features.requestAnimationFrame||e.push("Animation will use setTimeout fallback"),this.features.performance||e.push("Performance monitoring will be limited"),"basic"===t&&e.push("Consider using minimal build for better performance"),e}getFeatures(){return{...this.features}}getCapabilities(){return{...this.capabilities}}}class fi{constructor(){this.polyfills=new Map,this.applied=new Set}register(t,e){this.polyfills.set(t,e)}apply(t){if(this.applied.has(t))return!0;const e=this.polyfills.get(t);if(!e)return!1;try{return e(),this.applied.add(t),!0}catch{return!1}}applyAll(){const t=[];for(const e of this.polyfills.keys())this.apply(e)&&t.push(e);return t}isApplied(t){return this.applied.has(t)}}function mi(){window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(()=>{t(Date.now())},1e3/60)},window.cancelAnimationFrame=window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){window.clearTimeout(t)})}function Mi(){if(window.performance&&window.performance.now)return;window.performance||(window.performance={});const t=Date.now();window.performance.now=function(){return Date.now()-t}}function gi(){window.AudioContext||window.webkitAudioContext||(window.AudioContext=function(){this.state="suspended",this.sampleRate=44100,this.currentTime=0,this.destination={connect(){},disconnect(){}},this.createGain=function(){return{gain:{value:1},connect(){},disconnect(){}}},this.createOscillator=function(){return{frequency:{value:440},type:"sine",start(){},stop(){},connect(){},disconnect(){}}},this.createAnalyser=function(){return{fftSize:2048,frequencyBinCount:1024,getByteFrequencyData(t){for(let e=0;e<t.length;e++)t[e]=0},connect(){},disconnect(){}}},this.resume=function(){return this.state="running",Promise.resolve()},this.suspend=function(){return this.state="suspended",Promise.resolve()},this.close=function(){return this.state="closed",Promise.resolve()}})}class yi{constructor(t){this.canvas=t,this.context=null,this.isContextLost=!1,this.recoveryCallbacks=[],this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),this.setupContextLossHandling()}handleContextLost(t){t.preventDefault(),this.isContextLost=!0}handleContextRestored(){this.isContextLost=!1,this.context=this.canvas.getContext("2d"),this.recoveryCallbacks.forEach(t=>{try{t(this.context)}catch{}})}setupContextLossHandling(){this.canvas.addEventListener("webglcontextlost",this.handleContextLost),this.canvas.addEventListener("webglcontextrestored",this.handleContextRestored)}getContext(){if(this.isContextLost)return null;if(!this.context)try{this.context=this.canvas.getContext("2d")}catch{return null}return this.context}onRecovery(t){this.recoveryCallbacks.push(t)}isLost(){return this.isContextLost}recover(){if(!this.isContextLost)return!0;try{if(this.context=this.canvas.getContext("2d"),this.context)return this.isContextLost=!1,!0}catch{}return!1}destroy(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.handleContextLost),this.canvas.removeEventListener("webglcontextrestored",this.handleContextRestored),this.canvas=null),this.context=null,this.recoveryCallbacks=[]}}class bi{constructor(){if(bi.vt)return this.browser=bi.vt,void(this.optimizations=bi.St);this.browser=this.detectBrowser(),this.optimizations=new Map,this.setupOptimizations(),bi.vt=this.browser,bi.St=this.optimizations}detectBrowser(){const{userAgent:t}=navigator;let e="unknown",i="unknown";if(t.includes("Chrome")){e="chrome";const s=t.match(/Chrome\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Firefox")){e="firefox";const s=t.match(/Firefox\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Safari")&&!t.includes("Chrome")){e="safari";const s=t.match(/Version\/(\d+)/);i=s?s[1]:"unknown"}else if(t.includes("Edge")){e="edge";const s=t.match(/Edge\/(\d+)/);i=s?s[1]:"unknown"}return{name:e,version:i,userAgent:t}}setupOptimizations(){this.optimizations.set("chrome",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"interactive"},canvasOptimizations:["willReadFrequently"],particleLimit:50}),this.optimizations.set("firefox",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"balanced"},canvasOptimizations:[],particleLimit:40}),this.optimizations.set("safari",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"playback"},canvasOptimizations:[],particleLimit:30}),this.optimizations.set("edge",{preferredAnimationMethod:"requestAnimationFrame",audioContextOptions:{latencyHint:"interactive"},canvasOptimizations:["willReadFrequently"],particleLimit:45})}getOptimizations(){return this.optimizations.get(this.browser.name)||this.optimizations.get("chrome")}getBrowser(){return{...this.browser}}applyCanvasOptimizations(t,e){if(this.getOptimizations().canvasOptimizations.includes("willReadFrequently"))try{t.getContext("2d",{willReadFrequently:!0})}catch{}}getRecommendedParticleLimit(){return this.getOptimizations().particleLimit}getAudioContextOptions(){return this.getOptimizations().audioContextOptions}}let wi=null,vi=null;const Si=(vi||(vi=function(){if(wi)return wi;const t=new di,e=new fi,i=new bi;e.register("requestAnimationFrame",mi),e.register("performanceNow",Mi),e.register("webAudio",gi);const s=[];return t.features.requestAnimationFrame||e.apply("requestAnimationFrame")&&s.push("requestAnimationFrame"),t.features.performance||e.apply("performanceNow")&&s.push("performanceNow"),t.features.webAudio||e.apply("webAudio")&&s.push("webAudio"),wi={featureDetection:t,polyfillManager:e,browserOptimizations:i,appliedPolyfills:s,capabilities:t.getCapabilities(),browser:i.getBrowser()},wi}()),vi);class Fi{areCompatible(){return!0}canChain(){return!0}getCompatibilityInfo(){return{compatible:!0,reason:"minimal"}}getIncompatibleGestures(){return[]}getTimingClass(){return"medium"}getChordInfo(){return null}getChainInfo(){return null}}const xi=new Fi;var ki=Object.freeze({__proto__:null,GestureCompatibility:Fi,default:xi});class Bi{constructor(t={}){const e=t.initialState||{};this.Ft=e.isRunning??!1,this.xt=e.debugMode??!1,this.kt=e.speaking??!1,this.Bt=e.recording??!1,this.Ct=e.audioLevel??0,this.Rt=e.sleeping??!1,this.Tt=e.rhythmEnabled??!1,this.Pt=e.currentModularGesture??null,this.Ot=e.breathePhase??"idle",this.At=e.breatheStartTime??0,this.Dt=e.orbScale??1,this.zt=e.warningTimestamps??{},this.Et=e.warningThrottle??5e3,this.It=t.emit||(()=>{})}get isRunning(){return this.Ft}set isRunning(t){const e=this.Ft!==t;this.Ft=t,e&&this.It("stateChange",{property:"isRunning",value:t})}get debugMode(){return this.xt}set debugMode(t){const e=this.xt!==t;this.xt=t,e&&this.It("stateChange",{property:"debugMode",value:t})}get speaking(){return this.kt}set speaking(t){const e=this.kt!==t;this.kt=t,e&&this.It("stateChange",{property:"speaking",value:t})}get recording(){return this.Bt}set recording(t){const e=this.Bt!==t;this.Bt=t,e&&this.It("stateChange",{property:"recording",value:t})}get audioLevel(){return this.Ct}set audioLevel(t){this.Ct=t}get sleeping(){return this.Rt}set sleeping(t){const e=this.Rt!==t;this.Rt=t,e&&this.It("stateChange",{property:"sleeping",value:t})}get rhythmEnabled(){return this.Tt}set rhythmEnabled(t){this.Tt=t}get currentModularGesture(){return this.Pt}set currentModularGesture(t){this.Pt=t}get breathePhase(){return this.Ot}set breathePhase(t){this.Ot=t}get breatheStartTime(){return this.At}set breatheStartTime(t){this.At=t}get orbScale(){return this.Dt}set orbScale(t){this.Dt=t}get warningTimestamps(){return this.zt}set warningTimestamps(t){this.zt=t}get warningThrottle(){return this.Et}set warningThrottle(t){this.Et=t}getSnapshot(){return{isRunning:this.Ft,debugMode:this.xt,speaking:this.kt,recording:this.Bt,audioLevel:this.Ct,sleeping:this.Rt,rhythmEnabled:this.Tt,currentModularGesture:this.Pt,breathePhase:this.Ot,breatheStartTime:this.At,orbScale:this.Dt}}reset(){this.Ft=!1,this.xt=!1,this.kt=!1,this.Bt=!1,this.Ct=0,this.Rt=!1,this.Tt=!1,this.Pt=null,this.Ot="idle",this.At=0,this.Dt=1,this.zt={}}}class Ci{constructor(t){if(!t.errorBoundary)throw new Error("GestureController: errorBoundary required");if(!t.config)throw new Error("GestureController: config required");if(!t.state)throw new Error("GestureController: state required");if(!t.throttledWarn)throw new Error("GestureController: throttledWarn required");this.errorBoundary=t.errorBoundary,this.renderer=t.renderer||null,this.performanceMonitor=t.performanceMonitor||null,this.soundSystem=t.soundSystem||null,this.config=t.config,this.jt=t.state,this.$t=t.throttledWarn,this.Gt=t.chainTarget||this,this.currentGesture=null,this.gestureCompatibility=null,this.rendererMethods={bounce:"startBounce",pulse:"startPulse",shake:"startShake",spin:"startSpin",nod:"startNod",tilt:"startTilt",expand:"startExpand",contract:"startContract",flash:"startFlash",drift:"startDrift",stretch:"startStretch",glow:"startGlow",sparkle:"startSparkle",shimmer:"startShimmer",wiggle:"startWiggle",groove:"startGroove",point:"startPoint",lean:"startLean",reach:"startReach",headBob:"startHeadBob",orbit:"startOrbit",flicker:"startFlicker",vibrate:"startVibrate",wave:"startWave",breathe:"startBreathe",morph:"startMorph",slowBlink:"startSlowBlink",look:"startLook",settle:"startSettle",orbital:"startOrbital",hula:"startHula",sway:"startSway",breathIn:"startBreathIn",breathOut:"startBreathOut",breathHold:"startBreathHold",breathHoldEmpty:"startBreathHoldEmpty",jump:"startJump",rain:"startRain",runningman:"startRunningMan",charleston:"startCharleston",grooveSway:"startGrooveSway",grooveBob:"startGrooveBob",grooveFlow:"startGrooveFlow",groovePulse:"startGroovePulse",grooveStep:"startGrooveStep",float:"startFloat",twist:"startTwist"}}init(){this.gestureCompatibility||Promise.resolve().then(function(){return ki}).then(t=>{this.gestureCompatibility=t.default}).catch(t=>{})}express(t,e={}){return this.errorBoundary.wrap(()=>{if(!t)return this.Gt;const i=performance.now(),s=Array.isArray(t)||"object"==typeof t&&"chord"===t.type?"chord":t;if(this.performanceMonitor&&this.performanceMonitor.markGestureStart(s),Array.isArray(t))return this.expressChord(t,e);if("object"==typeof t&&"chord"===t.type)return this.expressChord(t.gestures,e);const a=this.rendererMethods[t];if(a&&this.renderer&&this.renderer[a]){if(this.renderer[a](e),this.config.soundEnabled&&this.soundSystem&&this.soundSystem.isAvailable()&&this.soundSystem.playGestureSound(t),this.performanceMonitor){const t=performance.now();this.performanceMonitor.markGestureEnd(s),this.performanceMonitor.recordGestureTime(s,t-i)}return this.Gt}const h=Qt(t);if(h){if(Y.registerConfig("gesture",t,h),this.jt.currentModularGesture={type:t,config:h,startTime:performance.now(),duration:h.defaultParams?.duration||1e3,progress:0},this.config.soundEnabled&&this.soundSystem&&this.soundSystem.isAvailable()&&this.soundSystem.playGestureSound(t),this.performanceMonitor){const t=performance.now();this.performanceMonitor.markGestureEnd(s),this.performanceMonitor.recordGestureTime(s,t-i)}return this.Gt}return this.$t(`Unknown gesture: ${t}`,`gesture_${t}`),this.performanceMonitor&&this.performanceMonitor.markGestureEnd(s),this.Gt},"gesture-express",this.Gt)()}expressChord(t,e={}){return this.errorBoundary.wrap(()=>{if(!t||!Array.isArray(t)||0===t.length)return this.Gt;this.gestureCompatibility||Promise.resolve().then(function(){return ki}).then(t=>{this.gestureCompatibility=t.default}).catch(t=>{});const i=this.gestureCompatibility?this.gestureCompatibility.getCompatibleGestures(t):t;return i.forEach(t=>{const i="string"==typeof t?t:t.gestureName;this.executeGestureDirectly(i,e)}),this.gestureCompatibility?.isEnhancingCombination?.(i)&&this.renderer?.specialEffects?.addSparkle?.(),this.Gt},"gesture-chord",this.Gt)()}executeGestureDirectly(t,e={}){const i=this.rendererMethods[t];i&&this.renderer&&"function"==typeof this.renderer[i]&&this.renderer[i](e)}chain(...t){if(this.gestureCompatibility){const e=t.join(">"),i=this.gestureCompatibility.parseChain(e);this.executeChainSequence(i)}else t.length>0&&this.express(t[0]);return this.Gt}executeChainSequence(t){if(!t||0===t.length)return;let e=0;const i=()=>{if(e>=t.length)return;const s=t[e];1===s.length?this.express(s[0]):this.expressChord(s),e++,e<t.length&&setTimeout(i,800)};i()}destroy(){this.currentGesture=null,this.gestureCompatibility=null}}class Ri{constructor(t){this.animationController=t.animationController||null,this.audioLevelProcessor=t.audioLevelProcessor||null,this.gazeTracker=t.gazeTracker||null,this.particleSystem=t.particleSystem,this.stateMachine=t.stateMachine,this.jt=t.state||{debugMode:!1,speaking:!1}}buildRenderState(){return{renderStart:this.jt.debugMode?performance.now():0,deltaTime:this.getDeltaTime(),renderState:this.createRenderState()}}getDeltaTime(){return this.animationController?this.animationController.deltaTime:16.67}createRenderState(){return{properties:this.stateMachine.getCurrentEmotionalProperties(),emotion:this.stateMachine.getCurrentState().emotion,undertone:this.stateMachine.getCurrentState().undertone,particleSystem:this.particleSystem,speaking:this.jt.speaking,audioLevel:this.audioLevelProcessor?this.audioLevelProcessor.getCurrentLevel():0,gazeOffset:this.getGazeOffset()}}getGazeOffset(){return this.gazeTracker?this.gazeTracker.currentGaze:{x:0,y:0}}}class Ti{constructor(t){this.renderer=t.renderer,this.stateMachine=t.stateMachine,this.canvasManager=t.canvasManager,this.config=t.config}calculateParticleConfig(t,e){const{orbX:i,orbY:s}=this.calculateOrbPosition(t),{particleBehavior:a,particleRate:h,minParticles:n,maxParticles:r}=this.calculateParticleBehavior(t,e);return{orbX:i,orbY:s,particleBehavior:a,particleRate:h,minParticles:n,maxParticles:r,emotionParams:e}}calculateOrbPosition(t){const e=this.renderer.getEffectiveCenter(),i=e.x;let s=e.y-this.config.topOffset;const a=this.stateMachine.getCurrentEmotionalProperties();return a.verticalOffset&&(s=e.y-this.config.topOffset+this.canvasManager.height*a.verticalOffset),{orbX:i,orbY:s}}calculateParticleBehavior(t,e){let i=e.particleBehavior||"ambient",s=e.particleRate||15;const a=this.stateMachine.getCurrentEmotionalProperties(),h=void 0!==e.minParticles?e.minParticles:a.minParticles||0;let n=void 0!==e.maxParticles?e.maxParticles:a.maxParticles||10;return({particleBehavior:i,particleRate:s,maxParticles:n}=this.applyRendererOverrides(i,s,n)),{particleBehavior:i,particleRate:s,minParticles:h,maxParticles:n}}applyRendererOverrides(t,e,i){return this.renderer.state&&this.renderer.state.particleBehaviorOverride&&(t=this.renderer.state.particleBehaviorOverride),this.renderer.state&&this.renderer.state.particleRateMult&&(e=Math.floor(e*this.renderer.state.particleRateMult),i=Math.floor(i*this.renderer.state.particleRateMult)),{particleBehavior:t,particleRate:e,maxParticles:i}}getParticleModifier(t){return this.renderer.getUndertoneModifier?this.renderer.getUndertoneModifier():null}}class Pi{constructor(t){this.renderer=t.renderer,this.jt=t.state}getGestureMotion(){let t=null,e=0;const i=this.jt.currentModularGesture;return i?({gestureMotion:t,gestureProgress:e}=this.processModularGesture(i)):this.renderer&&this.renderer.getCurrentGesture&&({gestureMotion:t,gestureProgress:e}=this.processRendererGesture()),{gestureMotion:t,gestureProgress:e}}processModularGesture(t){const e=performance.now()-t.startTime,i=Math.min(e/t.duration,1),s={type:t.type,amplitude:1,frequency:1,intensity:1};return i>=1&&this.handleGestureCleanup(t),{gestureMotion:s,gestureProgress:i}}handleGestureCleanup(t){t.cleanupPending?this.jt.currentModularGesture=null:t.cleanupPending=!0}processRendererGesture(){const t=this.renderer.getCurrentGesture();return t&&t.particleMotion?{gestureMotion:t.particleMotion,gestureProgress:t.progress||0}:{gestureMotion:null,gestureProgress:0}}getGestureTransform(){return this.renderer?.gestureAnimator?.applyGestureAnimations()??null}}const Oi=new class{constructor(){this.logs=[],this.errors=[]}log(){}warn(){}error(){}info(){}debug(){}trace(){}profile(){}endProfile(){}getProfiles(){return[]}getErrors(){return[]}clearErrors(){}getMemorySnapshot(){return null}};class Ai{constructor(t){this.canvasManager=t.canvasManager,this.config=t.config,this.particleSystem=t.particleSystem,this.pluginSystem=t.pluginSystem||null,this.renderer=t.renderer,this.stateMachine=t.stateMachine,this.jt=t.state||{debugMode:!1},this.qt=t.renderDebugInfo||(()=>{})}renderAllLayers(t){const{renderState:e,deltaTime:i,emotionParams:s,gestureTransform:a,renderStart:h}=t;this.renderBackgroundParticles(s.glowColor,a),this.renderOrb(e,i,a),this.renderForegroundParticles(s.glowColor,a),this.renderPlugins(),this.renderDebugIfEnabled(i),this.logPerformanceIfDebug(h,i)}renderBackgroundParticles(t,e){this.particleSystem.renderBackground(this.canvasManager.getContext(),t,e)}renderOrb(t,e,i){this.renderer.render(t,e,i)}renderForegroundParticles(t,e){this.particleSystem.renderForeground(this.canvasManager.getContext(),t,e)}renderPlugins(){if(this.pluginSystem){const t=this.stateMachine.getCurrentState();this.pluginSystem.render(this.canvasManager.getContext(),t)}}renderDebugIfEnabled(t){(this.config.showFPS||this.config.showDebug)&&this.qt(t)}logPerformanceIfDebug(t,e){if(!this.jt.debugMode)return;const i=performance.now()-t;i>16.67&&Oi.log("WARN","Slow render frame detected",{renderTime:i,deltaTime:e,particleCount:this.particleSystem.getStats().activeParticles})}}class Di{constructor(t={}){this.Xt=t,this.Yt=!1}init(t){if(this.Yt)return this;this.errorBoundary=new e,this.eventManager=new i({maxListeners:100,enableMonitoring:!1}),this.Ht();const a=Si.browserOptimizations.getOptimizations();if(this.config={canvasId:t,targetFPS:60,maxParticles:a.particleLimit,defaultEmotion:"neutral",renderingStyle:"classic",enableGazeTracking:!0,enableIdleBehaviors:!0,topOffset:0,offsetX:0,offsetY:0,offsetZ:0,classicConfig:{coreColor:"#FFFFFF",coreSizeDivisor:12,glowMultiplier:2.5,defaultGlowColor:"#14B8A6"},...this.Xt},this.stateManager=new Bi({initialState:{debugMode:!1},emit:(t,e)=>this.emit(t,e)}),this._t(),this.canvas="string"==typeof t?document.getElementById(t):t,!this.canvas)throw new Error(`Canvas '${t}' not found`);this.canvasManager=new s(this.canvas),this.positionController=new pi({offsetX:this.config.offsetX,offsetY:this.config.offsetY,offsetZ:this.config.offsetZ,onUpdate:t=>{this.renderer&&this.renderer.updateEffectiveCenter(t)}}),this.config.renderSize?.width&&this.config.renderSize?.height&&this.canvasManager.setRenderSize(this.config.renderSize.width,this.config.renderSize.height),this.contextRecovery=new yi(this.canvas),this.contextRecovery.onRecovery(t=>{this.renderer&&this.renderer.handleContextRecovery(t)}),Si.browserOptimizations.applyCanvasOptimizations(this.canvas,this.canvasManager.getContext()),this.stateMachine=new G(this.errorBoundary),this.particleSystem=new ee(this.config.maxParticles,this.errorBoundary),this.particleSystem.canvasWidth=this.canvasManager.width,this.particleSystem.canvasHeight=this.canvasManager.height,this.renderer=new Ne(this.canvasManager,{...this.config.classicConfig,topOffset:this.config.topOffset||0,positionController:this.positionController}),this.renderer.stateMachine=this.stateMachine,this.stateMachine.renderer=this.renderer,this.shapeMorpher=new hi,this.renderer.shapeMorpher=this.shapeMorpher,this.gestureController=new Ci({errorBoundary:this.errorBoundary,renderer:this.renderer,soundSystem:null,config:this.config,state:{get currentModularGesture(){return h.currentModularGesture},set currentModularGesture(t){h.currentModularGesture=t}},throttledWarn:this.$t.bind(this),chainTarget:this});const h=this;this.gestureController.gestureCompatibility=xi,this.gestureController.init(),this.config.enableGazeTracking&&(this.gazeTracker=new oi(this.canvas,{smoothing:.1,maxOffset:.15,enabled:!0}),this.gazeTracker.setInteractionCallback(()=>{this.sleeping||this.idleBehavior&&this.idleBehavior.resetIdleTimer()})),this.config.enableIdleBehaviors&&(this.idleBehavior=new li({enabled:!0,sleepTimeout:1/0}),this.idleBehavior.setCallback("onBlink",t=>{this.renderer?.state&&(this.renderer.state.blinking="start"===t.phase)}));try{this.animationController=new ri(this.errorBoundary,{targetFPS:this.config.targetFPS})}catch(t){this.animationController=this.Lt()}return this.animationController.setSubsystems({stateMachine:this.stateMachine,particleSystem:this.particleSystem,renderer:this.renderer,soundSystem:null,canvasManager:this.canvasManager}),this.animationController.setEventCallback((t,e)=>{this.emit(t,e)}),this.animationController.setParentMascot(this),this.renderStateBuilder=new Ri({animationController:this.animationController,gazeTracker:this.gazeTracker||null,particleSystem:this.particleSystem,stateMachine:this.stateMachine,state:{debugMode:!1,speaking:!1}}),this.particleConfigCalculator=new Ti({renderer:this.renderer,stateMachine:this.stateMachine,canvasManager:this.canvasManager,config:this.config}),this.gestureMotionProvider=new Pi({renderer:this.renderer,state:{get currentModularGesture(){return h.currentModularGesture},set currentModularGesture(t){h.currentModularGesture=t}}}),this.renderLayerOrchestrator=new Ai({canvasManager:this.canvasManager,config:this.config,particleSystem:this.particleSystem,renderer:this.renderer,stateMachine:this.stateMachine,state:{debugMode:!1}}),this.stateMachine.setEmotion(this.config.defaultEmotion),this.canvasManager.onResize((t,e,i)=>{this.particleSystem.canvasWidth=t,this.particleSystem.canvasHeight=e,this.renderer?.handleResize&&this.renderer.handleResize(t,e,i)}),this.Yt=!0,this}start(){if(!this.Yt||this.animationController.isAnimating())return this;if(this.animationController.start()){if(this.isRunning=!0,"classic"===this.config.renderingStyle){const{emotion:t}=this.stateMachine.getCurrentState(),e=O(t),i=this.renderer.getEffectiveCenter?.()||this.canvasManager.getCenter();if(this.particleSystem.clear(),e.particleRate>0){const t=Math.min(3,Math.floor(e.particleRate/4));t>0&&this.particleSystem.burst(t,e.particleBehavior,i.x,i.y)}}this.emit("started")}return this}stop(){return this.Yt&&this.animationController.isAnimating()?(this.animationController.stop()&&(this.isRunning=!1,this.emit("stopped")),this):this}setEmotion(t,e=null){if(!this.Yt)return this;const i={happy:"joy",curious:"surprise",frustrated:"anger",sad:"sadness"}[t]||t;let s=null,a=500,h=1;if("string"==typeof e?s=e:e&&"object"==typeof e&&(s=e.undertone||null,a=e.duration||500,h=e.intensity??1),this.stateMachine.setEmotion(i,{undertone:s,duration:a,intensity:h})&&this.particleSystem){this.particleSystem.clear();const t=this.stateMachine.getCurrentEmotionalProperties();let e;if(e="neutral"===i?1:"resting"===i?4:Math.min(3,Math.floor(t.particleRate/4)),e>0){const i=this.renderer.getEffectiveCenter?.()||{x:this.canvasManager.width/2,y:this.canvasManager.height/2};this.particleSystem.burst(e,t.particleBehavior,i.x,i.y)}this.emit("emotionChanged",{emotion:i,undertone:s,intensity:h})}return this}express(t,e={}){return this.Yt&&this.gestureController?this.gestureController.express(t,e):this}setShape(t){return this.Yt&&this.shapeMorpher?(this.shapeMorpher.morphTo(t),this):this}setPosition(t,e,i=0){return this.positionController&&this.positionController.setOffset(t,e,i),this}resize(t,e){return this.canvasManager&&this.canvasManager.setRenderSize(t,e),this}getState(){if(!this.Yt)return{emotion:"neutral",shape:"circle",isRunning:!1};const{emotion:t,undertone:e}=this.stateMachine.getCurrentState();return{emotion:t,undertone:e,shape:this.shapeMorpher?.currentShape||"circle",isRunning:this.stateManager?.isRunning??!1}}on(t,e){return this.eventManager&&this.eventManager.on(t,e),this}off(t,e){return this.eventManager&&this.eventManager.off(t,e),this}destroy(){this.Yt&&(this.stop(),this.animationController?.destroy&&this.animationController.destroy(),this.particleSystem?.destroy&&this.particleSystem.destroy(),this.renderer?.destroy&&this.renderer.destroy(),this.canvasManager?.destroy&&this.canvasManager.destroy(),this.shapeMorpher?.destroy&&this.shapeMorpher.destroy(),this.positionController?.destroy&&this.positionController.destroy(),this.gazeTracker?.destroy&&this.gazeTracker.destroy(),this.contextRecovery?.destroy&&this.contextRecovery.destroy(),this.Yt=!1)}update(t){}render(){try{const{deltaTime:t,renderState:e}=this.renderStateBuilder.buildRenderState();this.canvasManager.clear(),this.gazeTracker&&this.gazeTracker.update(t);const i=O(e.emotion);this.renderer.setEmotionalState(e.emotion,i,e.undertone);const s=this.particleConfigCalculator.calculateParticleConfig(e,i),{orbX:a,orbY:h,particleBehavior:n,particleRate:r,minParticles:o,maxParticles:l}=s;this.particleSystem.spawn(n,e.emotion,r,a,h,t,null,o,l,this.renderer.particleScaleFactor||this.renderer.scaleFactor||1,this.config.classicConfig?.particleSizeMultiplier||1,i.particleColors||null,e.undertone);const c=this.particleConfigCalculator.getParticleModifier(e),{gestureMotion:u,gestureProgress:p}=this.gestureMotionProvider.getGestureMotion();this.particleSystem.update(t,a,h,u,p,c);const d=this.gestureMotionProvider.getGestureTransform();this.renderLayerOrchestrator.renderAllLayers({renderState:e,deltaTime:t,emotionParams:i,gestureTransform:d,renderStart:0})}catch(t){this.errorBoundary.logError(t,"minimal-render")}}emit(t,e=null){this.eventManager?.emit&&this.eventManager.emit(t,e)}Ht(){this.eventManager.emit||(this.eventManager.t={},this.eventManager.emit=(t,e)=>{const i=this.eventManager.t[t];i&&i.forEach(t=>t(e))},this.eventManager.on=(t,e)=>{this.eventManager.t[t]||(this.eventManager.t[t]=[]),this.eventManager.t[t].push(e)},this.eventManager.off=(t,e)=>{const i=this.eventManager.t[t];if(i){const t=i.indexOf(e);t>-1&&i.splice(t,1)}})}$t(t,e){const i=Date.now();this.Wt||(this.Wt={}),(!this.Wt[t]||i-this.Wt[t]>5e3)&&(this.Wt[t]=i)}_t(){const t=this.stateManager,e=["speaking","recording","sleeping","isRunning","debugMode","audioLevel","rhythmEnabled","currentModularGesture","breathePhase","breatheStartTime","orbScale","warningTimestamps","warningThrottle"],i={};for(const s of e)i[s]={get:()=>t[s],set(e){t[s]=e},enumerable:!0,configurable:!0};Object.defineProperties(this,i)}Lt(){const t=this;return{isAnimating:()=>t.isRunning,start:()=>(t.isRunning=!0,!0),stop:()=>(t.isRunning=!1,!0),setTargetFPS:()=>{},getPerformanceMetrics:()=>({fps:0,isRunning:t.isRunning}),setSubsystems:()=>{},setEventCallback:()=>{},setParentMascot:()=>{},destroy:()=>{},deltaTime:16}}}t.BUILD_TYPE="minimal",t.ENGINE_NAME="Emotive Engine Minimal",t.EmotiveRenderer=Ne,t.EventManager=i,t.FEATURES={rhythmSync:!1,grooveTemplates:!1,gestureBlending:!0,audioReactive:!1,particleSystem:!0,accessibility:!1,mobileOptimization:!1,performanceMonitoring:!1},t.GESTURE_TYPES=Vt,t.MinimalMascot=Di,t.ParticleSystem=ee,t.VERSION="3.4.0-minimal",t.applyGesture=function(t,e,i,s,a,h,n){const r=Qt(e);return!!r&&(r.apply&&r.apply(t,i,s,a,h,n),i>=1&&r.cleanup&&r.cleanup(t),!0)},t.default=Di,t.getEmotion=P,t.getEmotionVisualParams=O,t.getGesture=Qt,t.hasEmotion=z,t.listEmotions=D,t.listGestures=function(){const t=[];return Object.values(Ht).forEach(e=>{t.push({name:e.name,emoji:e.emoji||"๐ญ",type:e.type,category:Nt[e.name]||"atmosphere",description:e.description||"No description",source:"core"})}),wt().forEach(e=>{const i=bt(e);t.push({name:i.name,emoji:i.emoji||"๐",type:i.type,category:i.category||"effect",description:i.description||"Plugin gesture",source:"plugin"})}),t},Object.defineProperty(t,"Ut",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=emotive-mascot.minimal.umd.js.map
|