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_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__context_index_mjs__ from "../context/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__SchemaInitializerItem_mjs__ from "./SchemaInitializerItem.mjs";
const SchemaInitializerSelect = (props)=>{
    const { title, options, value, onChange, openOnHover, onClick: _onClick, ...others } = props;
    const [open, setOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
    const onClick = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(function() {
        for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++)args[_key] = arguments[_key];
        setOpen(false);
        null == _onClick || _onClick(...args);
    }, [
        setOpen,
        _onClick
    ]);
    const onMouseEnter = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>setOpen(true), []);
    const moreProps = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>openOnHover ? {
            onMouseEnter,
            open
        } : {}, [
        onMouseEnter,
        open,
        openOnHover
    ]);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__SchemaInitializerItem_mjs__.SchemaInitializerItem, {
        ...others,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
            style: {
                alignItems: 'center',
                display: 'flex',
                justifyContent: 'space-between'
            },
            children: [
                title,
                /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
                    "data-testid": "antd-select",
                    popupMatchSelectWidth: false,
                    bordered: false,
                    defaultValue: value,
                    onChange: function() {
                        for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++)arg[_key] = arguments[_key];
                        return setOpen(false), onChange(...arg);
                    },
                    options: options,
                    style: {
                        textAlign: 'right',
                        minWidth: 100
                    },
                    onClick: onClick,
                    ...moreProps
                })
            ]
        })
    });
};
const SchemaInitializerSelectInternal = ()=>{
    const itemConfig = (0, __WEBPACK_EXTERNAL_MODULE__context_index_mjs__.useSchemaInitializerItem)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(SchemaInitializerSelect, {
        ...itemConfig
    });
};
export { SchemaInitializerSelect, SchemaInitializerSelectInternal };
