"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderWidget = renderWidget;
exports.UploadLabel = UploadLabel;
const jsx_runtime_1 = require("react/jsx-runtime");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const icons_2 = require("../../../bundle/config/icons.js");
const classname_1 = require("../../../classname.js");
require("./widget.css");
function renderWidget(container, props) {
    return ((0, jsx_runtime_1.jsx)(uikit_1.Portal, { container: container, children: (0, jsx_runtime_1.jsx)(UploadLabel, { ...props }) }));
}
const cnLabel = (0, classname_1.cn)('upload-label');
function UploadLabel({ fileName, fileType, status, errorText, onReUploadClick, }) {
    const icon = fileType === 'image' ? icons_2.icons.image : icons_2.icons.file;
    if (status === 'uploading') {
        return ((0, jsx_runtime_1.jsx)(uikit_1.Label, { size: "xs", theme: "info", icon: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { ...icon }), className: cnLabel({ status }), children: (0, jsx_runtime_1.jsxs)("div", { className: cnLabel('content'), children: [(0, jsx_runtime_1.jsx)("span", { title: fileName, className: cnLabel('filename'), children: fileName }), (0, jsx_runtime_1.jsx)(uikit_1.Spin, { size: "xs" })] }) }));
    }
    if (status === 'success') {
        return ((0, jsx_runtime_1.jsx)(uikit_1.Label, { size: "xs", theme: "success", icon: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { ...icon }), className: cnLabel({ status }), children: (0, jsx_runtime_1.jsx)("div", { className: cnLabel('content'), children: (0, jsx_runtime_1.jsx)("span", { title: fileName, className: cnLabel('filename'), children: fileName }) }) }));
    }
    if (status === 'error') {
        return ((0, jsx_runtime_1.jsx)(uikit_1.Tooltip, { content: errorText, children: (0, jsx_runtime_1.jsx)(uikit_1.Label, { size: "xs", interactive: true, theme: "danger", icon: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { ...icon }), onClick: onReUploadClick, className: cnLabel({ status }), children: (0, jsx_runtime_1.jsxs)("div", { className: cnLabel('content'), children: [(0, jsx_runtime_1.jsx)("span", { className: cnLabel('filename'), children: fileName }), (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.ArrowsRotateRight, size: 16 })] }) }) }));
    }
    return null;
}
//# sourceMappingURL=widget.js.map
