import React, { useMemo } from "react";
import { IconStarloader, IconLoading } from "@greenatom/icons";
import { Filler, Label, PreloaderBase, ProgressBarStyle } from "./style";
var Preloader = function (_a) {
    var progress = _a.progress, _b = _a.type, type = _b === void 0 ? "circular" : _b, isShowLabel = _a.isShowLabel, width = _a.width, height = _a.height, className = _a.className, children = _a.children;
    var getPreloader = useMemo(function () {
        if (type === "star") {
            return React.createElement(IconStarloader, { width: 24, height: 24 });
        }
        else if (type === "circular") {
            return React.createElement(IconLoading, { width: 24, height: 24 });
        }
        else {
            return children ? children : "Идет загрузка";
        }
    }, [type, isShowLabel]);
    return (React.createElement(PreloaderBase, { isShowLabel: isShowLabel, className: className, width: width, height: height },
        getPreloader,
        progress !== undefined && (React.createElement("div", { className: "progressbar" },
            isShowLabel && React.createElement(Label, null, String(progress) + "%"),
            React.createElement(ProgressBarStyle, null,
                React.createElement(Filler, { progress: progress }))))));
};
export default Preloader;
