/* @oracle/oraclejet-preact: undefined */
import { jsxs, jsx } from 'preact/jsx-runtime';
import { Fragment } from 'preact';
import { forwardRef } from 'preact/compat';
import { useRef, useImperativeHandle } from 'preact/hooks';
import { B as BaseButton } from './BaseButton-61f6baa8.js';
import { u as useToggleAction } from './useToggleAction-fc0f5399.js';
import { u as useTooltip } from './useTooltip-89ca3f3e.js';
import { m as mergeProps } from './mergeProps-88ea8306.js';
import './logger-c92f309c.js';
import './LayerHost-e6402730.js';
import './TooltipContentStyles.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js';
import './tooltipUtils-768450a7.js';
import { a as toggleStyling } from './toggleButtonUtils-75e3d781.js';
import { p as processGlobals } from './buttonUtils-be059939.js';
import { T as ToggleButtonLabel } from './ToggleButtonLabel-bd186454.js';

/**
 * IconToggleButtons direct users to toggle a state with
 * a single tap, click, or keystroke.
 */
const IconToggleButton = forwardRef(({ children, variant = 'outlined', size = 'md', isDisabled = false, tooltip, accessibleLabel, isSelected = false, onToggle, testId, 'aria-describedby': ariaDescribedBy, width, ...props }, ref) => {
    const { globalEventProps } = processGlobals(props);
    const buttonRef = useRef(null);
    useImperativeHandle(ref, () => buttonRef.current, [buttonRef]);
    const { triggerProps } = useToggleAction({
        isDisabled: isDisabled,
        onToggle: onToggle
    });
    const { tooltipContent, tooltipProps } = useTooltip({
        text: tooltip ?? accessibleLabel,
        isDisabled: isDisabled
    });
    const styling = toggleStyling('auto', isSelected, false, false, variant === 'outlined', undefined, undefined, true, true);
    const ariaProps = { 'aria-describedby': ariaDescribedBy };
    return (jsxs(Fragment, { children: [jsx(BaseButton, { ...mergeProps(tooltipProps, triggerProps, globalEventProps, ariaProps), variant: variant, isDisabled: isDisabled, size: size, width: width, "aria-pressed": isSelected, styling: styling, ref: buttonRef, "aria-label": accessibleLabel ?? tooltip, testId: testId, children: jsx(ToggleButtonLabel, { onAction: () => onToggle?.({ value: isSelected }), isDisabled: isDisabled, display: 'icons', startIcon: children }) }), tooltipContent] }));
});
IconToggleButton.displayName = 'IconToggleButton';

export { IconToggleButton as I };
//# sourceMappingURL=IconToggleButton-94cbea2b.js.map
