import { jsx } from "react/jsx-runtime";
import "react";
import { connect, mapProps, mapReadPretty } from "@tachybase/schema";
import { LoadingOutlined } from "@ant-design/icons";
import { Select, Tag } from "antd";
import { useCompile } from "../../hooks/useCompile.mjs";
const colors = {
    red: '{{t("Red")}}',
    magenta: '{{t("Magenta")}}',
    volcano: '{{t("Volcano")}}',
    orange: '{{t("Orange")}}',
    gold: '{{t("Gold")}}',
    lime: '{{t("Lime")}}',
    green: '{{t("Green")}}',
    cyan: '{{t("Cyan")}}',
    blue: '{{t("Blue")}}',
    geekblue: '{{t("Geek blue")}}',
    purple: '{{t("Purple")}}',
    default: '{{t("Default")}}'
};
const ColorSelect = connect((props)=>{
    const compile = useCompile();
    return /*#__PURE__*/ jsx(Select, {
        ...props,
        children: Object.keys(colors).map((color)=>/*#__PURE__*/ jsx(Select.Option, {
                value: color,
                children: /*#__PURE__*/ jsx(Tag, {
                    color: color,
                    children: compile(colors[color] || colors.default)
                })
            }, color))
    });
}, mapProps((props, field)=>({
        ...props,
        suffix: /*#__PURE__*/ jsx("span", {
            children: (null == field ? void 0 : field['loading']) || (null == field ? void 0 : field['validating']) ? /*#__PURE__*/ jsx(LoadingOutlined, {}) : props.suffix
        })
    })), mapReadPretty((props)=>{
    const compile = useCompile();
    const { value } = props;
    if (!colors[value]) return null;
    return /*#__PURE__*/ jsx(Tag, {
        color: value,
        children: compile(colors[value] || colors.default)
    });
}));
const color_select_ColorSelect = ColorSelect;
export { ColorSelect, color_select_ColorSelect as default };
