/* @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 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 { u as useButtonSetContext } from './useButtonSetContext-6a483d7f.js';
import { T as ToggleButtonLabel } from './ToggleButtonLabel-bd186454.js';
import { a as toggleStyling } from './toggleButtonUtils-75e3d781.js';
import { a as processSetButtonProps } from './buttonUtils-be059939.js';

/**
 * A ButtonSetIconButton is an icon button that allows users to switch
 * between states when pressed.
 */
const ButtonSetIconButton = forwardRef(({ children, tooltip, value, accessibleLabel, isSelected = false, onToggle, position, testId, width, 'aria-describedby': ariaDescribedBy, ...props }, ref) => {
    const buttonSetProps = useButtonSetContext();
    const { inputProps, buttonSetButtonProps, isDisabled } = processSetButtonProps(props, buttonSetProps);
    const buttonRef = useRef(null);
    useImperativeHandle(ref, () => buttonRef.current, [buttonRef]);
    const { tooltipContent, tooltipProps } = useTooltip({
        text: tooltip ?? accessibleLabel,
        isDisabled: isDisabled
    });
    const styling = toggleStyling(buttonSetButtonProps.layoutWidth, isSelected, false, true, buttonSetButtonProps.variant === 'outlined', position, undefined, true);
    const ariaProps = { 'aria-describedby': ariaDescribedBy };
    return (jsxs(Fragment, { children: [jsx(BaseButton, { ...mergeProps(buttonSetButtonProps, ariaProps, tooltipProps), elementDetails: { type: 'span', isFocusable: false, isLabel: true }, onAction: () => onToggle?.({ value: isSelected }), styling: styling, width: buttonSetProps.width ? '100%' : width, ref: buttonRef, testId: testId, children: jsx(ToggleButtonLabel, { label: accessibleLabel ?? tooltip, display: 'icons', isSelected: isSelected, ...inputProps, value: value, startIcon: children }) }), tooltipContent] }));
});
ButtonSetIconButton.displayName = 'ButtonSetIconButton';

export { ButtonSetIconButton as B };
//# sourceMappingURL=ButtonSetIconButton-0081167a.js.map
