"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var VIIRIBF3 = require('../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/@ariakit/react-core/esm/__chunks/VIIRIBF3.cjs');
var menu = require('../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/@ariakit/react-core/esm/menu/menu.cjs');
var combobox = require('../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/@ariakit/react-core/esm/combobox/combobox.cjs');
var MAXQOH4L = require('../../node_modules/.pnpm/@ariakit_react-core@0.4.16_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/@ariakit/react-core/esm/__chunks/MAXQOH4L.cjs');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var dropdownMenuRoot = require('./dropdown-menu-root.cjs');
var dropdownMenu_module = require('./dropdown-menu.module.css.cjs');
var index = require('../../node_modules/.pnpm/@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.1.7_@types_react@19.1.9__@types_rea_nas2f5v5xqlignvaay23ejie7a/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs');
var index$2 = require('../../node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.1.9_react@19.1.1/node_modules/@radix-ui/react-slot/dist/index.cjs');

const DropdownMenuContent = React.forwardRef(({ className, children, asChild, searchPlaceholder = 'Search...', ...props }, ref) => {
    const menu$1 = VIIRIBF3.useMenuContext();
    const { autocomplete } = dropdownMenuRoot.useDropdownContext();
    const isSubMenu = !!menu$1?.parent;
    const comboboxRef = React.useRef(null);
    const visuallyHiddenRef = React.useRef(null);
    const [isInsideRadixDialog, setIsInsideRadixDialog] = React.useState(false);
    /*
     * This is a workaround to fix focus lock issue when the dropdown menu is inside a Radix Dialog.
     * TODO: Use Radix.Popover for the dropdown popover
     */
    React.useEffect(() => {
        setIsInsideRadixDialog(!!visuallyHiddenRef.current?.closest("[role='dialog']"));
    }, []);
    return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(index.Root, { ref: visuallyHiddenRef, "aria-hidden": 'true' }), jsxRuntime.jsx(menu.Menu, { ref: ref, modal: !isInsideRadixDialog, portal: !isInsideRadixDialog, portalElement: typeof window === 'undefined' || isInsideRadixDialog
                    ? null
                    : window?.document?.body, unmountOnHide: true, gutter: isSubMenu ? 2 : 4, className: index$1.cx(dropdownMenu_module.default.content, autocomplete && dropdownMenu_module.default.comboboxContainer, className), render: asChild ? jsxRuntime.jsx(index$2.Root, {}) : undefined, ...props, children: autocomplete ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(combobox.Combobox, { ref: comboboxRef, placeholder: searchPlaceholder, className: dropdownMenu_module.default.comboboxInput, autoSelect: true, onPointerEnter: e => {
                                if (document &&
                                    document.activeElement !== comboboxRef.current)
                                    comboboxRef.current?.focus();
                            } }), jsxRuntime.jsx(MAXQOH4L.ComboboxList, { className: dropdownMenu_module.default.comboboxContent, children: children })] })) : (children) })] }));
});

exports.DropdownMenuContent = DropdownMenuContent;
//# sourceMappingURL=dropdown-menu-content.cjs.map
