import { jsx as _jsx } from "react/jsx-runtime";
/**
 * BrailleSpinner — compact animated spinner using braille characters.
 */
import { Text } from 'ink';
import { useState, useEffect } from 'react';
import { SPINNER_FRAMES, SPINNER_INTERVAL, Colors } from '../styles.js';
export const BrailleSpinner = ({ color = Colors.active, frame: frameProp, }) => {
    const [internalFrame, setInternalFrame] = useState(0);
    useEffect(() => {
        if (frameProp !== undefined)
            return;
        const id = setInterval(() => setInternalFrame((f) => (f + 1) % SPINNER_FRAMES.length), SPINNER_INTERVAL);
        return () => clearInterval(id);
    }, [frameProp]);
    const frame = frameProp !== undefined ? frameProp % SPINNER_FRAMES.length : internalFrame;
    return _jsx(Text, { color: color, children: SPINNER_FRAMES[frame] });
};
