import { __assign, __rest } from "tslib";
import React, { useContext } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var SelectOptGroup = function (props) {
    var customisedCls = props.prefixCls, label = props.label, className = props.className, children = props.children, otherProps = __rest(props, ["prefixCls", "label", "className", "children"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('select-group', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className);
    return (React.createElement("li", __assign({}, otherProps, { key: label, className: cls }),
        React.createElement("div", { className: prefixCls + "__title" }, label),
        React.createElement("ul", { className: prefixCls + "__list" }, React.Children.map(children, function (child) {
            var childElement = child;
            if (childElement.type.displayName === 'SelectOption') {
                var childProps = __assign({}, childElement.props);
                return React.cloneElement(childElement, childProps);
            }
            else {
                console.warn('Select has a child that is not neither SelectOption nor SelectOptGroup component.');
                return null;
            }
        }))));
};
SelectOptGroup.displayName = 'SelectOptGroup';
export default SelectOptGroup;
//# sourceMappingURL=opt-group.js.map