"use client";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useListboxContext } from "../form/ListboxProvider.js";
import { Option } from "../form/Option.js";
/**
 * NOTE: This was moved to a second component to improve performance so
 * that the availableOptions aren't looped until the listbox is visible
 *
 * @since 6.0.0
 * @internal
 */ export function AutocompleteListboxChildren(props) {
    const { children, query, options: availableOptions, noOptionsChildren, getOptionLabel, getOptionProps } = props;
    const { isOptionSelected } = useListboxContext();
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            children,
            !availableOptions.length && noOptionsChildren,
            availableOptions.map((option, index)=>{
                const label = getOptionLabel(option);
                const optionProps = getOptionProps({
                    index,
                    query,
                    option,
                    selected: isOptionSelected(option),
                    extractor: getOptionLabel
                });
                return /*#__PURE__*/ _jsx(Option, {
                    value: option,
                    ...optionProps,
                    children: optionProps?.children ?? label
                }, label);
            })
        ]
    });
}

//# sourceMappingURL=AutocompleteListboxChildren.js.map