import { jsx as _jsx } from "react/jsx-runtime";
import { useEffect, useState } from 'react';
import { Text, Box } from 'ink';
import { theme } from '../semantic-colors.js';
import process from 'node:process';
import { formatBytes } from '../utils/formatters.js';
export const MemoryUsageDisplay = ({ color = theme.text.primary, }) => {
    const [memoryUsage, setMemoryUsage] = useState('');
    const [memoryUsageColor, setMemoryUsageColor] = useState(color);
    useEffect(() => {
        const updateMemory = () => {
            const usage = process.memoryUsage().rss;
            setMemoryUsage(formatBytes(usage));
            setMemoryUsageColor(usage >= 2 * 1024 * 1024 * 1024 ? theme.status.error : color);
        };
        const intervalId = setInterval(updateMemory, 2000);
        updateMemory(); // Initial update
        return () => clearInterval(intervalId);
    }, [color]);
    return (_jsx(Box, { children: _jsx(Text, { color: memoryUsageColor, children: memoryUsage }) }));
};
//# sourceMappingURL=MemoryUsageDisplay.js.map