import figlet from 'figlet';
import chalk from 'chalk';

const fonts = [
    'Standard', 'Big', 'Slant', 'Banner', 'Block', 'Bubble',
    'Digital', 'Doom', 'Lean', 'Mini', 'Script', 'Shadow',
    'Small', 'Star Wars'
];

const colorfulText = (text) => {
    const colors = [
        chalk.red,
        chalk.green,
        chalk.yellow,
        chalk.blue,
        chalk.magenta,
        chalk.cyan,
    ];
    return text.split('').map((char, i) => colors[i % colors.length](char)).join('');
};

const chosenFont = fonts[Math.floor(Math.random() * fonts.length)];

figlet.text('Nile Elements', {
    font: chosenFont,
    horizontalLayout: 'default',
    verticalLayout: 'default',
    width: 80,
    whitespaceBreak: true
}, (err, data) => {
    if (err) {
        console.error('Something went wrong...');
        console.error(err);
        return;
    }

    const coloredData = data.split('\n').map(line => colorfulText(line)).join('\n');
    console.log(coloredData);
    console.log(chalk.green('Whoooohooooo! Nile has been installed!'));
});
