"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const FieldBase_1 = tslib_1.__importDefault(require("../../FieldBase/FieldBase.js"));
const b = (0, cn_1.formGeneratorCn)('editor-select-field');
const SelectDynamicField = ({ input, value, onUpdate, className }) => {
    const inputView = input.view || 'radiobutton';
    const isMultiple = input.mode === 'multiple';
    const currentValue = Array.isArray(value) ? value : [value];
    return ((0, jsx_runtime_1.jsxs)(FieldBase_1.default, { title: input.title, className: b(null, className), onRefresh: onUpdate, children: [(inputView === 'select' || isMultiple) && ((0, jsx_runtime_1.jsx)(uikit_1.Select, { placeholder: 'Value', value: value ? currentValue : [], onUpdate: (selectValues) => isMultiple ? onUpdate(selectValues) : onUpdate(selectValues[0]), options: input.enum, className: b('select'), multiple: isMultiple })), inputView === 'radiobutton' && !isMultiple && ((0, jsx_runtime_1.jsx)(uikit_1.SegmentedRadioGroup, { options: input.enum, value: Array.isArray(value) ? value[0] : value, onUpdate: onUpdate }))] }));
};
exports.default = SelectDynamicField;
//# sourceMappingURL=Select.js.map
