"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 fields_1 = require("../../utils/fields.js");
const Base_1 = tslib_1.__importDefault(require("../Base/Base.js"));
const BaseInput_1 = tslib_1.__importDefault(require("../BaseInput/BaseInput.js"));
const Select = ({ title, name, options, when, content, onUpdate, hasClear, defaultValue, }) => {
    const selected = (0, fields_1.getValueByPath)(content, name) ?? defaultValue;
    const value = selected ? [selected] : [];
    return ((0, jsx_runtime_1.jsx)(Base_1.default, { when: when, content: content, name: name, onUpdate: onUpdate, defaultValue: defaultValue, children: (0, jsx_runtime_1.jsx)(BaseInput_1.default, { title: title, children: (0, jsx_runtime_1.jsx)(uikit_1.Select, { name: name, options: options.map((option) => ({
                    value: option.value,
                    content: option.content || option.value,
                })), placeholder: "Not selected", onUpdate: (v) => onUpdate(name, v[0]), value: value, hasClear: hasClear }) }) }));
};
exports.default = Select;
//# sourceMappingURL=Select.js.map
