{"version":3,"sources":["../src/react/index.ts"],"names":["useRobotToast","coreToast","useToastOnMount","options","idRef","useRef","useEffect"],"mappings":"oGA+BO,SAASA,GAAkC,CAChD,OAAOC,KACT,CAOO,SAASC,CAAAA,CAAgBC,CAAAA,CAAkC,CAChE,IAAMC,EAAQC,MAAAA,CAAsB,IAAI,EAExCC,SAAAA,CAAU,KACRF,EAAM,OAAA,CAAUH,KAAAA,CAAUE,CAAO,CAAA,CAC1B,IAAM,CACPC,EAAM,OAAA,EAAW,IAAA,EAAMH,MAAU,SAAA,CAAUG,CAAAA,CAAM,OAAO,EAC9D,CAAA,CAAA,CAGC,EAAE,EACP","file":"react.mjs","sourcesContent":["/**\n * robot-toast — React bindings\n * ─────────────────────────────────────────────────────────────────────────────\n * Thin React wrapper around the framework-agnostic core. The toast manager is\n * already a module-level singleton, so there's no Provider / Context needed —\n * just a hook that hands you the `toast` function with a stable reference.\n *\n *   import { useRobotToast } from 'robot-toast/react';\n *\n *   function SaveButton() {\n *     const toast = useRobotToast();\n *     return <button onClick={() => toast.success('Saved!')}>Save</button>;\n *   }\n *\n * For mount-scoped toasts (fire on mount, auto-close on unmount), use\n * `useToastOnMount`. Typical case: surfacing a persistent loading/status toast\n * while a component is on screen.\n */\n\nimport { useEffect, useRef } from 'react';\n// Self-reference via the package name so tsup treats it as external and the\n// React bundle doesn't duplicate the core. Node resolves this back to the\n// package's own `.` export at runtime via the `exports` field.\nimport { toast as coreToast } from 'robot-toast';\nimport type { RobotToastOptions } from 'robot-toast';\n\n/**\n * Returns the `toast` function. Stable across re-renders.\n * Equivalent to `import { toast } from 'robot-toast'`, but follows the\n * idiomatic React hook shape some teams prefer.\n */\nexport function useRobotToast(): typeof coreToast {\n  return coreToast;\n}\n\n/**\n * Fire a toast when the component mounts, close it when the component unmounts.\n * `options` is read once (on mount) — subsequent changes do not update the toast.\n * To show a new toast, remount the component (e.g. via `key`).\n */\nexport function useToastOnMount(options: RobotToastOptions): void {\n  const idRef = useRef<number | null>(null);\n\n  useEffect(() => {\n    idRef.current = coreToast(options);\n    return () => {\n      if (idRef.current != null) coreToast.closeById(idRef.current);\n    };\n    // options deliberately excluded — toast is fire-once per mount.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n}\n\n// Re-export the core function for people who want everything from one place.\nexport { toast } from 'robot-toast';\n\nexport type {\n  RobotToastOptions,\n  RobotToastAPI,\n  ToastPosition,\n  ToastType,\n  ToastTheme,\n  TransitionType,\n} from 'robot-toast';\n"]}