/* @oracle/oraclejet-preact: undefined */
'use strict';

var jsxRuntime = require('preact/jsx-runtime');
var preact = require('preact');
var compat = require('preact/compat');
var hooks = require('preact/hooks');
var BaseButton = require('./BaseButton-590432e4.js');
var useTooltip = require('./useTooltip-cf4a15f3.js');
var mergeProps = require('./mergeProps-e3da7237.js');
require('./logger-2b636482.js');
require('./LayerHost-8ec73638.js');


require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');
require('./tooltipUtils-d461919d.js');
var useButtonSetContext = require('./useButtonSetContext-a2f31c8e.js');
var ToggleButtonLabel = require('./ToggleButtonLabel-6ff96ee4.js');
var toggleButtonUtils = require('./toggleButtonUtils-245111a7.js');
var buttonUtils = require('./buttonUtils-1f339a8e.js');

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

exports.ButtonSetIconButton = ButtonSetIconButton;
//# sourceMappingURL=ButtonSetIconButton-c632a294.js.map
