{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "undo-toast",
  "type": "registry:ui",
  "title": "Undo Toast",
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "files": [
    {
      "path": "components/ui/undo-toast.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useState } from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { RotateCcw, Trash2, Undo2, X } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface UndoToastProps {\n  durationMs?: number;\n  className?: string;\n}\n\nexport function UndoToast({\n  durationMs = 5000,\n  className,\n}: UndoToastProps) {\n  const [open, setOpen] = useState(true);\n  const [paused, setPaused] = useState(false);\n  const [remaining, setRemaining] = useState(durationMs);\n  const [status, setStatus] = useState<\"idle\" | \"undone\" | \"dismissed\">(\"idle\");\n\n  useEffect(() => {\n    if (!open || paused) return;\n    const step = 50;\n    const id = setInterval(() => {\n      setRemaining((prev) => {\n        if (prev <= step) {\n          setOpen(false);\n          setStatus(\"dismissed\");\n          return 0;\n        }\n        return prev - step;\n      });\n    }, step);\n    return () => clearInterval(id);\n  }, [open, paused]);\n\n  const progress = Math.max(0, Math.min(1, remaining / durationMs));\n\n  const trigger = () => {\n    setRemaining(durationMs);\n    setStatus(\"idle\");\n    setOpen(true);\n  };\n\n  const handleUndo = () => {\n    setOpen(false);\n    setStatus(\"undone\");\n  };\n\n  return (\n    <div className={cn(\"w-full max-w-sm space-y-3\", className)}>\n      <AnimatePresence mode=\"wait\">\n        {open ? (\n          <motion.div\n            key=\"toast\"\n            initial={{ opacity: 0, y: 12, scale: 0.96 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: 8, scale: 0.96 }}\n            transition={{ type: \"spring\", stiffness: 380, damping: 28 }}\n            onMouseEnter={() => setPaused(true)}\n            onMouseLeave={() => setPaused(false)}\n            className=\"relative overflow-hidden rounded-2xl border border-white/12 bg-[#121216] p-3.5 shadow-2xl\"\n          >\n            <div className=\"flex items-center justify-between gap-3\">\n              <div className=\"flex items-center gap-2.5\">\n                <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-rose-500/15 text-rose-400\">\n                  <Trash2 className=\"h-4 w-4\" />\n                </div>\n                <div>\n                  <div className=\"text-xs font-semibold text-zinc-100\">\n                    Archived &quot;Q4 Launch&quot;\n                  </div>\n                  <div className=\"text-[11px] text-zinc-500\">\n                    {paused\n                      ? \"Countdown paused\"\n                      : `Auto-closing in ${Math.ceil(remaining / 1000)}s`}\n                  </div>\n                </div>\n              </div>\n\n              <div className=\"flex items-center gap-1.5\">\n                <button\n                  type=\"button\"\n                  onClick={handleUndo}\n                  className=\"inline-flex items-center gap-1 rounded-lg bg-white px-2.5 py-1 text-[11px] font-semibold text-zinc-950 hover:bg-zinc-200 cursor-pointer transition-colors\"\n                >\n                  <Undo2 className=\"h-3 w-3\" />\n                  Undo\n                </button>\n                <button\n                  type=\"button\"\n                  onClick={() => {\n                    setOpen(false);\n                    setStatus(\"dismissed\");\n                  }}\n                  aria-label=\"Dismiss notification\"\n                  className=\"rounded-lg p-1 text-zinc-500 hover:bg-white/5 hover:text-zinc-200 cursor-pointer\"\n                >\n                  <X className=\"h-3.5 w-3.5\" />\n                </button>\n              </div>\n            </div>\n\n            {/* Countdown Progress Bar */}\n            <div className=\"mt-3 h-1 w-full overflow-hidden rounded-full bg-white/[0.06]\">\n              <div\n                className=\"h-full rounded-full bg-blue-500 transition-[width] duration-75 ease-linear\"\n                style={{ width: `${progress * 100}%` }}\n              />\n            </div>\n          </motion.div>\n        ) : (\n          <motion.div\n            key=\"restore\"\n            initial={{ opacity: 0, y: 6 }}\n            animate={{ opacity: 1, y: 0 }}\n            className=\"flex items-center justify-between rounded-2xl border border-dashed border-white/15 bg-zinc-900/50 px-4 py-3 text-xs text-zinc-400\"\n          >\n            <span>\n              {status === \"undone\"\n                ? \"Action reverted — project restored.\"\n                : \"Toast dismissed.\"}\n            </span>\n            <button\n              type=\"button\"\n              onClick={trigger}\n              className=\"inline-flex items-center gap-1 rounded-lg border border-white/10 bg-zinc-900 px-2.5 py-1 text-[11px] text-zinc-200 hover:bg-zinc-800 cursor-pointer\"\n            >\n              <RotateCcw className=\"h-3 w-3\" />\n              Trigger Again\n            </button>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\n",
      "type": "registry:ui"
    }
  ]
}