/** Planificación de movimientos idle: no repetir inmediatamente el último. */ export function elegirAccionIdle({acciones=[],anterior='',random=Math.random}={}) { const disponibles=[...new Set(acciones)].filter(x=>typeof x==='string'&&x.trim()); if(!disponibles.length)return null; const candidatas=disponibles.length>1?disponibles.filter(x=>x!==anterior):disponibles; const indice=Math.max(0,Math.min(candidatas.length-1,Math.floor(Number(random())*candidatas.length)||0)); return candidatas[indice]; } export function puedeMoverseIdle({now=Date.now(),lastInteractionAt=0,lastSpeechAt=0,quietMs=12000,busy=false,pending=0}={}) { return !busy && pending===0 && now-Math.max(lastInteractionAt,lastSpeechAt)>=quietMs; }