import { forwardRef, useEffect } from 'react';
import { useEffectEvent } from '../../../../common/hooks/useEffectEvent.mjs';
import { jsx } from 'react/jsx-runtime';

const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInputOptionsContainer({
  'aria-orientation': ariaOrientation,
  'aria-activedescendant': ariaActiveDescendant,
  role,
  tabIndex,
  onAriaActiveDescendantChange,
  onKeyDown,
  ...restProps
}, ref) {
  const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);
  useEffect(() => {
    handleAriaActiveDescendantChange(ariaActiveDescendant);
  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
  return /*#__PURE__*/jsx("div", {
    ref: ref,
    role: "none",
    onKeyDown: event => {
      // Prevent confirmation close without an active item
      if (event.key === 'Enter' && ariaActiveDescendant == null) {
        return;
      }
      // Required to make ListBox focusable
      if (event.key === 'Tab') {
        return;
      }
      // Prevent absorbing Escape early
      if (event.key === 'Escape') {
        onKeyDown?.({
          ...event,
          preventDefault: () => {},
          stopPropagation: () => {}
        });
        return;
      }
      onKeyDown?.(event);
    },
    ...restProps
  });
});

export { SelectInputOptionsContainer };
//# sourceMappingURL=SelectInputOptionsContainer.mjs.map
