/* @oracle/oraclejet-preact: undefined */
import { jsx } from 'preact/jsx-runtime';
import { forwardRef } from 'preact/compat';
import { B as BaseButton } from './BaseButton-61f6baa8.js';
import { m as mergeProps } from './mergeProps-88ea8306.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';

/**
 * Toggle buttons allow users to switch between states when pressed.
 */
const ButtonSetButton = forwardRef(({ startIcon, endIcon, isSelected = false, onToggle, position, autofocus, testId, label, value, 'aria-label': accessibleLabel, 'aria-describedby': ariaDescribedBy, width, ...props }, ref) => {
    const buttonSetProps = useButtonSetContext();
    const { inputProps: baseInputProps, buttonSetButtonProps, globalEventProps, isDisabled } = processSetButtonProps(props, buttonSetProps);
    const inputProps = {
        ...baseInputProps,
        display: buttonSetProps.display ?? props.display ?? 'all'
    };
    const styling = toggleStyling(buttonSetButtonProps.layoutWidth, isSelected, false, // switch
    true, // label
    buttonSetButtonProps.variant === 'outlined', position, true, // hasLabel
    false // iconOnly
    );
    return (jsx(BaseButton, { ...mergeProps(globalEventProps, buttonSetButtonProps), ref: ref, onAction: () => {
            onToggle?.({ value: isSelected });
        }, elementDetails: { type: 'span', isFocusable: false, isLabel: true }, width: buttonSetProps.width ? '100%' : width, autofocus: autofocus, styling: styling, "aria-describedby": ariaDescribedBy, testId: testId, children: jsx(ToggleButtonLabel, { label: label, isSelected: isSelected, isDisabled: isDisabled, startIcon: startIcon, endIcon: endIcon, value: value, ...inputProps }) }));
});
ButtonSetButton.displayName = 'ButtonSetButton';

export { ButtonSetButton as B };
//# sourceMappingURL=ButtonSetButton-974fc462.js.map
