"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rocketAnimation = exports.archivingAnimation = exports.renderBar = exports.colorize = void 0;
const chalk_1 = require("chalk");
function range(len) {
    const arr = [];
    for (let i = 0; i < len; i += 1) {
        arr.push(i);
    }
    return arr;
}
function colorize(color) {
    if (color[0] === '#') {
        return chalk_1.default.hex(color);
    }
    return chalk_1.default[color] || chalk_1.default.keyword(color);
}
exports.colorize = colorize;
function renderBar(progress, color) {
    const BLOCK_CHAR = '█';
    const BLOCK_CHAR2 = '█';
    const PRECENTS_PER_STEP = 4;
    const BAR_LENGTH = 100 / PRECENTS_PER_STEP;
    const width = progress * (BAR_LENGTH / 100);
    const background = chalk_1.default.white(BLOCK_CHAR);
    const foreground = colorize(color)(BLOCK_CHAR2);
    return range(BAR_LENGTH)
        .map(i => (i < width ? foreground : background))
        .join('');
}
exports.renderBar = renderBar;
function archivingAnimation(task) {
    let dotsString = '📁.....';
    let currentIndex = 0;
    const archiveDrawer = setInterval(() => {
        const positionCount = dotsString.length - 1;
        if (currentIndex >= positionCount) {
            currentIndex = 0;
        }
        else {
            currentIndex += 1;
        }
        dotsString = '......';
        dotsString = `${dotsString.substring(0, currentIndex)}📁${dotsString.substring(currentIndex)}`;
        task.title = `Archiving project..${dotsString}🗃️`;
    }, 400);
    return archiveDrawer;
}
exports.archivingAnimation = archivingAnimation;
function rocketAnimation(task) {
    const maxDotsCount = 6;
    let dotsString = '';
    const rocketDrawer = setInterval(() => {
        if (dotsString.split('').length < maxDotsCount) {
            dotsString += '.';
        }
        else {
            dotsString = '.';
        }
        task.title = `Uploading project..${dotsString}🚀`;
    }, 400);
    return rocketDrawer;
}
exports.rocketAnimation = rocketAnimation;
//# sourceMappingURL=cli-customize.js.map