'use strict';

var React = require('react');
var useEffectEvent = require('../../../../common/hooks/useEffectEvent.js');
var jsxRuntime = require('react/jsx-runtime');

const SelectInputOptionsContainer = /*#__PURE__*/React.forwardRef(function SelectInputOptionsContainer({
  'aria-orientation': ariaOrientation,
  'aria-activedescendant': ariaActiveDescendant,
  role,
  tabIndex,
  onAriaActiveDescendantChange,
  onKeyDown,
  ...restProps
}, ref) {
  const handleAriaActiveDescendantChange = useEffectEvent.useEffectEvent(onAriaActiveDescendantChange);
  React.useEffect(() => {
    handleAriaActiveDescendantChange(ariaActiveDescendant);
  }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
  return /*#__PURE__*/jsxRuntime.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
  });
});

exports.SelectInputOptionsContainer = SelectInputOptionsContainer;
//# sourceMappingURL=SelectInputOptionsContainer.js.map
