import { Children, isValidElement } from "react";
/**
 * @internal
 * @remarks \@since 6.0.0
 */ function getLabelFromChildren(children) {
    if (!children) {
        return "";
    }
    if (typeof children === "string" || typeof children === "number") {
        return `${children}`;
    }
    if (isValidElement(children)) {
        if (children.props.hidden) {
            return "";
        }
        return getLabelFromChildren(children.props.children);
    }
    const childList = Children.toArray(children);
    for (const child of childList){
        if (typeof child === "string" || typeof child === "number") {
            return `${child}`[0].toUpperCase();
        }
        if (isValidElement(child) && !child.props.hidden) {
            return getLabelFromChildren(child.props.children);
        }
    }
    return "";
}
/**
 * @internal
 * @remarks \@since 6.0.0
 */ export function extractOptionsFromChildren(children, currentValue) {
    let currentOption;
    const options = [];
    const searchValues = [];
    Children.forEach(children, (child)=>{
        if (!isValidElement(child)) {
            return;
        }
        const { value, disabled, children } = child.props;
        if (typeof value !== "undefined") {
            if (value === currentValue || !currentOption && typeof currentValue === "undefined") {
                currentOption = child.props;
            }
            if (!disabled) {
                options.push(child.props.value);
                searchValues.push(getLabelFromChildren(children));
            }
        } else if (children) {
            const result = extractOptionsFromChildren(children, currentValue);
            if (!currentOption) {
                ({ currentOption } = result);
            }
            options.push(...result.options);
        }
    });
    return {
        options,
        currentOption
    };
}

//# sourceMappingURL=selectUtils.js.map