import {
  Icon
} from "./chunk-TKIP5Q5H.js";
import {
  toastState
} from "./chunk-D3PPAC3Z.js";

// src/components/Toast/Toast.tsx
import {
  circleCheck,
  circleExclamation,
  circleInfo,
  cross,
  triangleExclamation
} from "@simplybusiness/icons";
import classNames from "classnames/dedupe";
import { toast as sonnerToast } from "sonner";
import "@simplybusiness/mobius/src/components/Toast/Toast.css";
import { jsx, jsxs } from "react/jsx-runtime";
var variantIcons = {
  info: circleInfo,
  success: circleCheck,
  warning: triangleExclamation,
  error: circleExclamation
};
var variantColors = {
  info: "var(--color-info)",
  success: "var(--color-valid)",
  warning: "var(--color-warning)",
  error: "var(--color-error)"
};
var ToastIcon = ({ variant }) => /* @__PURE__ */ jsx("span", { className: "mobius-toast__icon", children: /* @__PURE__ */ jsx(Icon, { icon: variantIcons[variant], color: variantColors[variant] }) });
var CloseIcon = () => /* @__PURE__ */ jsx("span", { className: "mobius-toast__close-icon", children: /* @__PURE__ */ jsx(Icon, { icon: cross }) });
var ToastContent = ({
  toastId,
  variant,
  title,
  description,
  action,
  cancel,
  showCloseButton = toastState.showCloseButton
}) => /* @__PURE__ */ jsxs("div", { className: classNames("mobius", "mobius-toast", `--${variant}`), children: [
  /* @__PURE__ */ jsx(ToastIcon, { variant }),
  /* @__PURE__ */ jsxs("div", { className: "mobius-toast__body", children: [
    /* @__PURE__ */ jsxs("div", { className: "mobius-toast__content", children: [
      title && /* @__PURE__ */ jsx("div", { className: "mobius-toast__title", children: title }),
      description && /* @__PURE__ */ jsx("div", { className: "mobius-toast__description", children: description })
    ] }),
    (action || cancel) && /* @__PURE__ */ jsxs("div", { className: "mobius-toast__actions", children: [
      cancel && /* @__PURE__ */ jsx(
        "button",
        {
          type: "button",
          className: "mobius-toast__cancel",
          onClick: () => {
            cancel.onClick?.();
            sonnerToast.dismiss(toastId);
          },
          children: cancel.label
        }
      ),
      action && /* @__PURE__ */ jsx(
        "button",
        {
          type: "button",
          className: "mobius-toast__action",
          onClick: () => {
            action.onClick();
            sonnerToast.dismiss(toastId);
          },
          children: action.label
        }
      )
    ] })
  ] }),
  showCloseButton && /* @__PURE__ */ jsx(
    "button",
    {
      type: "button",
      className: "mobius-toast__close",
      onClick: () => sonnerToast.dismiss(toastId),
      "aria-label": "Close",
      children: /* @__PURE__ */ jsx(CloseIcon, {})
    }
  )
] });
var createCustomToast = (message, variant, options) => sonnerToast.custom(
  (id) => /* @__PURE__ */ jsx(
    ToastContent,
    {
      toastId: id,
      variant,
      title: options?.title,
      description: options?.description ?? message,
      action: options?.action,
      cancel: options?.cancel,
      showCloseButton: options?.showCloseButton
    }
  ),
  {
    duration: options?.duration,
    onDismiss: options?.onDismiss,
    onAutoClose: options?.onAutoClose
  }
);
var toast = {
  /** Show an info toast */
  info: (message, options) => createCustomToast(message, "info", options),
  /** Show a success toast */
  success: (message, options) => createCustomToast(message, "success", options),
  /** Show a warning toast */
  warning: (message, options) => createCustomToast(message, "warning", options),
  /** Show an error toast */
  error: (message, options) => createCustomToast(message, "error", options),
  /** Dismiss a specific toast by ID or all toasts */
  dismiss: (toastId) => sonnerToast.dismiss(toastId)
};

export {
  toast
};
//# sourceMappingURL=chunk-MDQAUT5X.js.map
