export type ToastSeverity = 'success' | 'error' | 'warning' | 'info';

/**
 * Fire a toast notification from anywhere — including non-React code like fetch services.
 * The ToastBridge component (inside SnackbarProvider) picks up this event and calls
 * notistack's enqueueSnackbar.
 */
export function dispatchToast(message: string, severity: ToastSeverity): void {
  if (typeof window === 'undefined') return;
  window.dispatchEvent(new CustomEvent('app:toast', { detail: { message, severity } }));
}
