import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_CollectionFieldProvider_mjs__ from "../../../data-source/collection-field/CollectionFieldProvider.mjs";
const Radio = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.connect)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio, (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapProps)({
    value: 'checked',
    onInput: 'onChange'
}));
Radio.__ANT_RADIO = true;
Radio.Group = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.connect)(__WEBPACK_EXTERNAL_MODULE_antd__.Radio.Group, (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapProps)({
    dataSource: 'options'
}, (props, field)=>{
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        var _field_dataSource;
        const defaultOption = null === (_field_dataSource = field.dataSource) || void 0 === _field_dataSource ? void 0 : _field_dataSource.find((option)=>option.value == props.value);
        if (defaultOption) field.setValue(defaultOption.value);
    }, [
        props.value,
        field.dataSource
    ]);
    return {
        ...props
    };
}), (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapReadPretty)((props)=>{
    if (!(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.isValid)(props.value)) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {});
    const { value } = props;
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const collectionField = (0, __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_CollectionFieldProvider_mjs__.useCollectionField)();
    const dataSource = field.dataSource || (null == collectionField ? void 0 : collectionField.uiSchema.enum) || [];
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        children: dataSource.filter((option)=>option.value == value).map((option, key)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Tag, {
                color: option.color,
                icon: option.icon,
                children: option.label
            }, key))
    });
}));
const Radio_rslib_entry_ = Radio;
export { Radio, Radio_rslib_entry_ as default };
