"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { cnb } from "cnbuilder";
import { forwardRef } from "react";
import { Button } from "../button/Button.js";
import { getIcon } from "../icon/config.js";
import { bem } from "../utils/bem.js";
import { useCurrentToastActions } from "./useCurrentToastActions.js";
const styles = bem("rmd-toast-x");
const noop = ()=>{
// do nothing
};
/**
 * **Client Component**
 *
 * This button will automatically close the toast when clicked unless
 * `event.stopPropagation()` is called from the `onClick` prop.
 *
 * @see {@link https://react-md.dev/components/snackbar | Snackbar Demos}
 * @since 6.0.0
 */ export const ToastCloseButton = /*#__PURE__*/ forwardRef(function ToastCloseButton(props, ref) {
    const { buttonType = "icon-square", "aria-labelledby": ariaLabelledBy, "aria-label": ariaLabel = buttonType !== "text" && !ariaLabelledBy ? "Close" : undefined, children: propChildren, className, onClick = noop, reordered, ...remaining } = props;
    const children = getIcon("close", propChildren);
    const { removeToast } = useCurrentToastActions();
    return /*#__PURE__*/ _jsx(Button, {
        ...remaining,
        "aria-label": ariaLabel,
        "aria-labelledby": ariaLabelledBy,
        ref: ref,
        onClick: (event)=>{
            onClick(event);
            if (event.isPropagationStopped()) {
                return;
            }
            removeToast(true);
        },
        className: cnb(styles({
            reordered
        }), className),
        buttonType: buttonType,
        children: children
    });
});

//# sourceMappingURL=ToastCloseButton.js.map