{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast",
  "title": "Ninaero toast",
  "dependencies": [
    "@base-ui/react@^1.9.0",
    "cn@^0.4.0"
  ],
  "registryDependencies": [
    "https://ninaero.pages.dev/r/theme.json",
    "https://ninaero.pages.dev/r/button.json",
    "https://ninaero.pages.dev/r/icons.json",
    "https://ninaero.pages.dev/r/sound-provider.json"
  ],
  "files": [
    {
      "path": "registry/ninaero/ui/toast.tsx",
      "content": "\"use client\";\n\nimport { Toast as ToastPrimitive } from \"@base-ui/react/toast\";\nimport { cn } from \"cn\";\nimport * as React from \"react\";\n\nimport {\n  CircleCheckIcon,\n  InfoIcon,\n  Loader2Icon,\n  OctagonXIcon,\n  TriangleAlertIcon,\n  XIcon,\n} from \"@/lib/icons\";\nimport { Button } from \"@/registry/ninaero/ui/button\";\n\nimport { useControlSound, HoverSound } from \"./sound-feedback\";\nimport type { SoundCue } from \"./sound-provider\";\n\nconst toast = ToastPrimitive.createToastManager();\n\nconst ToastSoundContext = React.createContext(true);\n\nfunction ToastProvider({\n  sound = true,\n  ...props\n}: ToastPrimitive.Provider.Props & { sound?: boolean }) {\n  const inherited = React.useContext(ToastSoundContext);\n  return (\n    <ToastSoundContext.Provider value={sound && inherited}>\n      <ToastPrimitive.Provider {...props} />\n    </ToastSoundContext.Provider>\n  );\n}\n\nfunction ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {\n  return <ToastPrimitive.Portal data-slot=\"toast-portal\" {...props} />;\n}\n\nfunction ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {\n  return (\n    <ToastPrimitive.Viewport\n      data-slot=\"toast-viewport\"\n      className={cn(\n        \"pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nconst toastSounds: Partial<Record<string, SoundCue>> = {\n  info: \"ping\",\n  success: \"success\",\n  error: \"error\",\n  warning: \"warning\",\n  loading: \"loading\",\n};\n\nfunction Toast({\n  className,\n  toast,\n  sound = true,\n  ...props\n}: ToastPrimitive.Root.Props & { sound?: boolean }) {\n  const toastSound = React.useContext(ToastSoundContext);\n  const { play } = useControlSound(sound && toastSound);\n  const previous = React.useRef<{ id: string; type: string | undefined } | null>(null);\n  React.useEffect(() => {\n    const changed = previous.current?.id !== toast.id || previous.current?.type !== toast.type;\n    previous.current = { id: toast.id, type: toast.type };\n    if (changed && !toast.limited && toast.transitionStatus !== \"ending\") {\n      play(toastSounds[toast.type ?? \"info\"] ?? \"ping\");\n    }\n  }, [toast.id, toast.type, toast.limited, toast.transitionStatus, play]);\n  return (\n    <ToastPrimitive.Root\n      data-slot=\"toast\"\n      toast={toast}\n      className={cn(\n        \"group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50\",\n        \"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]\",\n        \"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]\",\n        \"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']\",\n        \"data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]\",\n        \"data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]\",\n        \"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]\",\n        \"data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]\",\n        \"data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]\",\n        \"data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]\",\n        \"data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]\",\n        \"data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]\",\n        \"data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]\",\n        \"data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]\",\n        \"data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToastContent({ className, ...props }: ToastPrimitive.Content.Props) {\n  return (\n    <ToastPrimitive.Content\n      data-slot=\"toast-content\"\n      className={cn(\n        \"flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {\n  return (\n    <ToastPrimitive.Title\n      data-slot=\"toast-title\"\n      className={cn(\"text-sm type-title tracking-normal\", className)}\n      {...props}\n    />\n  );\n}\n\nfunction ToastDescription({ className, ...props }: ToastPrimitive.Description.Props) {\n  return (\n    <ToastPrimitive.Description\n      data-slot=\"toast-description\"\n      className={cn(\"text-sm type-body text-muted-foreground\", className)}\n      {...props}\n    />\n  );\n}\n\nfunction ToastAction({\n  className,\n  render = <Button variant=\"outline\" size=\"sm\" />,\n  ...props\n}: ToastPrimitive.Action.Props) {\n  return (\n    <ToastPrimitive.Action\n      data-slot=\"toast-action\"\n      render={render}\n      className={cn(\"shrink-0\", className)}\n      {...props}\n    />\n  );\n}\n\nfunction ToastClose({\n  className,\n  children,\n  render = <Button variant=\"ghost\" size=\"icon-sm\" />,\n  sound = true,\n  ...props\n}: ToastPrimitive.Close.Props & { sound?: boolean }) {\n  return (\n    <HoverSound sound={sound}>\n      <ToastPrimitive.Close\n        data-slot=\"toast-close\"\n        aria-label=\"Close toast\"\n        render={render}\n        className={cn(\n          \"relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground\",\n          className,\n        )}\n        {...props}\n      >\n        {children ?? <XIcon aria-hidden=\"true\" />}\n      </ToastPrimitive.Close>\n    </HoverSound>\n  );\n}\n\nfunction ToastIcon({ type }: { type: string | undefined }) {\n  let icon: React.ReactNode = null;\n\n  if (type === \"success\") {\n    icon = <CircleCheckIcon aria-hidden=\"true\" />;\n  }\n\n  if (type === \"info\") {\n    icon = <InfoIcon aria-hidden=\"true\" />;\n  }\n\n  if (type === \"warning\") {\n    icon = <TriangleAlertIcon aria-hidden=\"true\" />;\n  }\n\n  if (type === \"error\") {\n    icon = <OctagonXIcon className=\"text-destructive\" aria-hidden=\"true\" />;\n  }\n\n  if (type === \"loading\") {\n    icon = <Loader2Icon className=\"animate-spin\" aria-hidden=\"true\" />;\n  }\n\n  if (!icon) {\n    return null;\n  }\n\n  return (\n    <span\n      data-slot=\"toast-icon\"\n      className=\"shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4\"\n    >\n      {icon}\n    </span>\n  );\n}\n\nfunction ToastList() {\n  const { toasts } = ToastPrimitive.useToastManager();\n\n  return toasts.map((toastItem) => (\n    <Toast key={toastItem.id} toast={toastItem}>\n      <ToastContent>\n        <ToastIcon type={toastItem.type} />\n        <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n          <ToastTitle />\n          <ToastDescription />\n        </div>\n        <ToastAction />\n        <ToastClose />\n      </ToastContent>\n    </Toast>\n  ));\n}\n\nfunction Toaster({\n  children,\n  toastManager = toast,\n  ...props\n}: React.ComponentProps<typeof ToastProvider>) {\n  return (\n    <ToastProvider toastManager={toastManager} {...props}>\n      {children}\n      <ToastPortal>\n        <ToastViewport>\n          <ToastList />\n        </ToastViewport>\n      </ToastPortal>\n    </ToastProvider>\n  );\n}\n\nconst createToastManager = ToastPrimitive.createToastManager;\nconst useToastManager = ToastPrimitive.useToastManager;\n\nexport {\n  Toaster,\n  Toast,\n  ToastAction,\n  ToastClose,\n  ToastContent,\n  ToastDescription,\n  ToastPortal,\n  ToastProvider,\n  ToastTitle,\n  ToastViewport,\n  createToastManager,\n  toast,\n  useToastManager,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}