"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DragOverlayPreview = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../utils/cn.js");
const fieldMeta_1 = require("../../utils/fieldMeta.js");
const b = (0, cn_1.formBuilderV2Cn)('drag-overlay');
const getFieldTitle = (f) => {
    if (!f)
        return '';
    if ('title' in f)
        return f.title ?? '';
    if ('text' in f)
        return f.text ?? '';
    return '';
};
const DragOverlayPreview = ({ type, field }) => {
    const name = field && 'name' in field ? field.name : '';
    const title = getFieldTitle(field);
    return ((0, jsx_runtime_1.jsxs)(uikit_1.Card, { className: b(), view: "raised", children: [(0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: fieldMeta_1.TYPE_ICONS[type], size: 14 }), (0, jsx_runtime_1.jsxs)("div", { className: b('text'), children: [(0, jsx_runtime_1.jsx)(uikit_1.Text, { variant: "body-2", children: fieldMeta_1.TYPE_LABELS[type] }), (name || title) && ((0, jsx_runtime_1.jsx)(uikit_1.Label, { theme: "unknown", size: "s", children: name || title }))] })] }));
};
exports.DragOverlayPreview = DragOverlayPreview;
//# sourceMappingURL=DragOverlayPreview.js.map
