{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-sonner",
  "title": "RetroToaster",
  "description": "Toasts rendered as Mac OS 9 alert windows: striped title bar, close box, per-type alert icons, OS9 action/cancel buttons and act-then-Undo. Exports RetroToaster and a sonner-style toast() function. Built on UI SDK Toast.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.1",
    "@ui-sdk/react@0.1.0-beta.1"
  ],
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-button.json",
    "https://nostalgia-ui.com/r/retro-icons.json",
    "https://nostalgia-ui.com/r/retro-spinner.json"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/retro-sonner.tsx",
      "content": "\"use client\"\n\n/*\n * RetroToaster: notifications as Mac OS 9 alert windows, on UI SDK's Toast.\n * Mount one <RetroToaster /> near the root, then call toast() from anywhere,\n * with the same calls as sonner: toast(), toast.success/info/warning/error/\n * loading, toast.promise(), toast.dismiss(), and `action` / `cancel` buttons\n * with `onClick`.\n *\n * Crafted moment: act, then Undo. Don't ask \"Are you sure?\" for something\n * that can be undone: do it, then offer Undo in an alert that slides in from\n * the corner (modern) or simply appears (classic). Newer alerts stack in\n * front with the older ones peeking out behind; hovering or focusing the\n * stack fans it out, and an alert swipes away toward its edge. F6 reaches\n * the newest alert from the keyboard.\n */\n\nimport * as React from \"react\"\nimport {\n  Toast as ToastPrimitive,\n  ToastAction as ToastActionPrimitive,\n  ToastClose as ToastClosePrimitive,\n  ToastDescription as ToastDescriptionPrimitive,\n  ToastRegion as ToastRegionPrimitive,\n  ToastTitle as ToastTitlePrimitive,\n  createToaster,\n  type ToastData,\n  type ToastDismissDetails,\n  type ToastOptions,\n  type ToastType,\n  type Toaster,\n} from \"@ui-sdk/react/toast\"\n\nimport { cn } from \"@/lib/utils\"\nimport { retroButtonVariants } from \"@/registry/new-york/ui/retro-button\"\nimport {\n  RetroIconAlert,\n  RetroIconInfo,\n  RetroIconStop,\n} from \"@/registry/new-york/ui/retro-icons\"\nimport { RetroSpinner } from \"@/registry/new-york/ui/retro-spinner\"\n\n/* ------------------------------------------------------------------ */\n/*  Success glyph                                                      */\n/*  retro-icons has no \"OK\" icon, so draw one in the same visual       */\n/*  language as RetroIconInfo (azul disc, white pixel glyph).          */\n/* ------------------------------------------------------------------ */\n\nfunction RetroSonnerSuccessIcon() {\n  return (\n    <svg\n      width={32}\n      height={32}\n      viewBox=\"0 0 32 32\"\n      fill=\"none\"\n      xmlns=\"http://www.w3.org/2000/svg\"\n      aria-hidden\n      className=\"h-8 w-8 shrink-0\"\n    >\n      <circle cx=\"16\" cy=\"16\" r=\"13\" fill=\"var(--os9-azul)\" stroke=\"var(--os9-black)\" strokeWidth=\"1\" />\n      <path d=\"M8 9 A13 13 0 0 1 24 8\" stroke=\"var(--os9-focus)\" strokeWidth=\"1\" fill=\"none\" />\n      <path\n        d=\"M9.5 16.5L14 21L22.5 11.5\"\n        stroke=\"var(--os9-white)\"\n        strokeWidth=\"3.5\"\n        strokeLinecap=\"square\"\n        strokeLinejoin=\"miter\"\n      />\n    </svg>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  toast(): sonner's call shape on a UI SDK toaster                   */\n/* ------------------------------------------------------------------ */\n\ntype RetroToastAction = {\n  label: React.ReactNode\n  /** sonner's name for the handler. Return a Promise to keep the toast open, pending, until it settles. */\n  onClick?: (event: Event | undefined) => unknown\n  /** UI SDK's name for the handler; wins over `onClick`. */\n  onAction?: (event: Event | undefined) => unknown\n  /** Makes the action a link. */\n  href?: string\n  /** Whether pressing it dismisses the toast. Default true. */\n  dismiss?: boolean\n}\n\ntype RetroToastCancel = {\n  label: React.ReactNode\n  onClick?: (event: Event | undefined) => void\n  onCancel?: (event: Event | undefined) => void\n}\n\ntype RetroToastOptions = Omit<ToastOptions<React.ReactNode>, \"action\" | \"cancel\"> & {\n  action?: RetroToastAction\n  cancel?: RetroToastCancel\n  /** Replaces the type's icon for this toast. */\n  icon?: React.ReactNode\n  /** Runs when the toast times out (sonner). */\n  onAutoClose?: () => void\n}\n\ntype ToastMessage = React.ReactNode\n\n/** The queue <RetroToaster /> shows by default. */\nconst retroToaster: Toaster<React.ReactNode> = createToaster<React.ReactNode>()\n\n/* <RetroToaster duration> sets this; a toast's own duration wins */\nlet toasterDuration: number | undefined\n\nfunction adapt(options?: RetroToastOptions): ToastOptions<React.ReactNode> | undefined {\n  if (!options) return toasterDuration !== undefined ? { duration: toasterDuration } : undefined\n  const { action, cancel, icon, onAutoClose, onDismiss, data, duration, ...rest } = options\n  return {\n    ...rest,\n    duration: duration ?? toasterDuration,\n    data: icon !== undefined ? { ...(data as object | undefined), icon } : data,\n    action: action && {\n      label: action.label,\n      href: action.href,\n      dismiss: action.dismiss,\n      onAction: action.onAction ?? action.onClick,\n    },\n    cancel: cancel && {\n      label: cancel.label,\n      onCancel: cancel.onCancel ?? cancel.onClick,\n    },\n    onDismiss:\n      onDismiss || onAutoClose\n        ? (details: ToastDismissDetails) => {\n            onDismiss?.(details)\n            if (details.reason === \"timeout\") onAutoClose?.()\n          }\n        : undefined,\n  }\n}\n\ntype PromiseMessages<Value> = {\n  loading: ToastMessage\n  success?: ToastMessage | ((value: Value) => ToastMessage)\n  error?: ToastMessage | ((error: unknown) => ToastMessage)\n}\n\nfunction show(type: ToastType | undefined, message: ToastMessage, options?: RetroToastOptions) {\n  return retroToaster(message, { ...adapt(options), ...(type ? { type } : {}) })\n}\n\nconst toast = Object.assign(\n  (message: ToastMessage, options?: RetroToastOptions) => show(undefined, message, options),\n  {\n    message: (message: ToastMessage, options?: RetroToastOptions) => show(undefined, message, options),\n    success: (message: ToastMessage, options?: RetroToastOptions) => show(\"success\", message, options),\n    info: (message: ToastMessage, options?: RetroToastOptions) => show(\"info\", message, options),\n    warning: (message: ToastMessage, options?: RetroToastOptions) => show(\"warning\", message, options),\n    error: (message: ToastMessage, options?: RetroToastOptions) => show(\"error\", message, options),\n    loading: (message: ToastMessage, options?: RetroToastOptions) => show(\"loading\", message, options),\n    /** A loading toast that turns into success or error when the promise settles. */\n    promise: <Value,>(\n      promise: Promise<Value> | (() => Promise<Value>),\n      messages: PromiseMessages<Value>,\n      options?: RetroToastOptions\n    ) => retroToaster.promise(promise, messages, adapt(options)),\n    /** Changes a toast that's still showing. Returns whether it was. */\n    update: (id: string, options: RetroToastOptions) =>\n      retroToaster.update(id, adapt(options) ?? {}),\n    /** Closes one toast, or every toast without an id. */\n    dismiss: (id?: string) => retroToaster.dismiss(id),\n  }\n)\n\n/* ------------------------------------------------------------------ */\n/*  The stack                                                          */\n/* ------------------------------------------------------------------ */\n\nconst CSS = `\n.os9-toaster {\n  position: fixed; inset: auto; z-index: 60; margin: 0; padding: 0;\n  border: 0; background: transparent; overflow: visible;\n  width: var(--os9-toaster-width, 356px); max-width: calc(100vw - 32px);\n  height: var(--toast-front-height);\n  transition: height 320ms cubic-bezier(0.23, 1, 0.32, 1);\n}\n.os9-toaster[data-side=\"bottom\"] { bottom: 20px; }\n.os9-toaster[data-side=\"top\"] { top: 20px; }\n.os9-toaster[data-align=\"end\"] { right: 20px; }\n.os9-toaster[data-align=\"start\"] { left: 20px; }\n.os9-toaster[data-align=\"center\"] { left: 50%; translate: -50% 0; }\n.os9-toaster[data-expanded] {\n  height: calc(var(--toast-stack-height) + (var(--toast-count) - 1) * 8px);\n}\n\n.os9-toast {\n  --dir: -1;\n  --y: calc(var(--dir) * var(--toast-index) * 6px);\n  position: absolute; inset-inline: 0; bottom: 0;\n  z-index: calc(100 - var(--toast-index));\n  height: var(--toast-height);\n  overflow: hidden;\n  translate: var(--toast-swipe-x, 0px) calc(var(--y) + var(--toast-swipe-y, 0px));\n  transition:\n    translate 320ms cubic-bezier(0.23, 1, 0.32, 1),\n    height 320ms cubic-bezier(0.23, 1, 0.32, 1),\n    opacity 200ms;\n  user-select: none;\n}\n.os9-toaster[data-side=\"top\"] .os9-toast { --dir: 1; bottom: auto; top: 0; }\n.os9-toast:not([data-front]):not([data-expanded]) { height: var(--toast-front-height); }\n.os9-toast:not([data-front]):not([data-expanded]) > * { opacity: 0; }\n.os9-toast[data-expanded] {\n  --y: calc(var(--dir) * (var(--toast-offset) + var(--toast-index) * 8px));\n}\n/* slides in from its corner; centered stacks rise from their edge */\n.os9-toaster[data-align=\"end\"] .os9-toast[data-starting-style] { translate: calc(100% + 24px) var(--y); }\n.os9-toaster[data-align=\"start\"] .os9-toast[data-starting-style] { translate: calc(-100% - 24px) var(--y); }\n.os9-toaster[data-align=\"center\"] .os9-toast[data-starting-style] {\n  translate: 0 calc(var(--dir) * -1 * (100% + 24px));\n}\n.os9-toast[data-ending-style] { opacity: 0; transition-duration: 160ms; }\n.os9-toast[data-swiping] { transition: none; }\n\n[data-flair=\"classic\"] .os9-toaster,\n[data-flair=\"classic\"] .os9-toast { transition: none; }\n@media (prefers-reduced-motion: reduce) {\n  .os9-toaster { transition: none; }\n  .os9-toast { transition: opacity 150ms; }\n  .os9-toaster .os9-toast[data-starting-style] { translate: 0 var(--y); opacity: 0; }\n}\n`\n\n/**\n * Title stripe painted as a background layer, so the close box can sit in\n * it without an extra element.\n */\nconst STRIPE_BG =\n  \"[background:repeating-linear-gradient(to_bottom,var(--os9-gray-600)_0_1px,transparent_1px_2px)_22px_4px/calc(100%-44px)_7px_no-repeat,var(--os9-gray-200)]\"\n\nconst DEFAULT_ICONS: Partial<Record<ToastType, React.ReactNode>> = {\n  success: <RetroSonnerSuccessIcon />,\n  info: <RetroIconInfo />,\n  warning: <RetroIconAlert />,\n  error: <RetroIconStop />,\n  loading: <RetroSpinner size=\"lg\" aria-label=\"Loading\" />,\n}\n\n/* ------------------------------------------------------------------ */\n/*  RetroToaster                                                       */\n/* ------------------------------------------------------------------ */\n\ntype ToasterPosition =\n  | \"top-left\"\n  | \"top-center\"\n  | \"top-right\"\n  | \"bottom-left\"\n  | \"bottom-center\"\n  | \"bottom-right\"\n\ntype RetroToasterProps = {\n  /** Which corner or edge the alerts stack in. */\n  position?: ToasterPosition\n  /** Keep the stack fanned out instead of only on hover and focus. */\n  expand?: boolean\n  /** How many alerts show at once; the rest wait their turn. */\n  visibleToasts?: number\n  /** How long toasts show by default, in ms. */\n  duration?: number\n  /** Paint the striped title bar across the top of each toast. */\n  titleStripe?: boolean\n  /** Show the close box in the title bar. */\n  closeButton?: boolean\n  /** Replace the icon for a type, like `{ success: <MyIcon /> }`. */\n  icons?: Partial<Record<ToastType, React.ReactNode>>\n  /** The keyboard shortcut that focuses the newest alert, or `null` for none. */\n  hotkey?: string | null\n  /** Show another queue than the one `toast()` adds to (from `createToaster()`). */\n  toaster?: Toaster<React.ReactNode>\n  /** Accessible name of the notifications region. */\n  \"aria-label\"?: string\n  className?: string\n  /** Class names for every toast. */\n  toastClassName?: string\n}\n\nfunction RetroToaster({\n  position = \"bottom-right\",\n  expand,\n  visibleToasts = 3,\n  duration,\n  titleStripe = true,\n  closeButton = true,\n  icons,\n  hotkey,\n  toaster = retroToaster,\n  \"aria-label\": ariaLabel = \"Notifications\",\n  className,\n  toastClassName,\n}: RetroToasterProps) {\n  const [side, edge] = position.split(\"-\") as [\"top\" | \"bottom\", \"left\" | \"center\" | \"right\"]\n  const align = edge === \"left\" ? \"start\" : edge === \"right\" ? \"end\" : \"center\"\n\n  React.useEffect(() => {\n    toasterDuration = duration\n    return () => {\n      toasterDuration = undefined\n    }\n  }, [duration])\n\n  return (\n    <>\n      <style href=\"os9-toaster\" precedence=\"default\">\n        {CSS}\n      </style>\n      <ToastRegionPrimitive\n        toaster={toaster}\n        side={side}\n        align={align}\n        maxVisible={visibleToasts}\n        expanded={expand}\n        {...(hotkey !== undefined ? { shortcut: hotkey } : {})}\n        aria-label={ariaLabel}\n        className={cn(\"os9-toaster\", className)}\n      >\n        {(item: ToastData<React.ReactNode>) => {\n          const custom = (item.data as { icon?: React.ReactNode } | undefined)?.icon\n          const icon = custom !== undefined ? custom : { ...DEFAULT_ICONS, ...icons }[item.type]\n          return (\n            <ToastPrimitive\n              className={cn(\n                \"os9-toast text-os9-black\",\n                \"border border-os9-black bg-os9-gray-200\",\n                \"shadow-[2px_2px_0_var(--os9-black),inset_2px_2px_0_rgba(255,255,255,0.6),inset_-2px_-2px_0_rgba(38,38,38,0.4)]\",\n                \"font-[family-name:var(--os9-font-sans)] text-[10px]\",\n                \"outline-none focus-visible:os9-focus-ring\",\n                titleStripe && STRIPE_BG,\n                toastClassName\n              )}\n            >\n              <div\n                className={cn(\n                  \"grid grid-cols-[auto_1fr_auto_auto] items-start gap-y-[10px] p-[10px]\",\n                  titleStripe && \"pt-[18px]\"\n                )}\n              >\n                {icon && (\n                  <div className=\"col-start-1 row-start-1 mr-[10px] flex size-[32px] shrink-0 items-center justify-center [&>svg]:size-[32px]\">\n                    {icon}\n                  </div>\n                )}\n                <div className=\"col-span-3 col-start-2 row-start-1 flex min-w-0 flex-col gap-[3px] self-center\">\n                  <ToastTitlePrimitive className=\"font-[family-name:var(--os9-font-heading)] text-[12px] font-bold leading-[1.2] tracking-[0.42px]\" />\n                  <ToastDescriptionPrimitive className=\"font-[family-name:var(--os9-font-sans)] text-[10px] leading-[1.4] text-os9-black\" />\n                </div>\n                {item.cancel && (\n                  <ToastClosePrimitive\n                    action={item.cancel.onCancel}\n                    className={cn(\n                      retroButtonVariants({ variant: \"default\", size: \"sm\" }),\n                      \"col-start-3 row-start-2 mr-[8px] min-w-[58px]\"\n                    )}\n                  >\n                    {item.cancel.label}\n                  </ToastClosePrimitive>\n                )}\n                {item.action && (\n                  <ToastActionPrimitive\n                    className={cn(\n                      retroButtonVariants({ variant: \"primary\", size: \"sm\" }),\n                      \"col-start-4 row-start-2 min-w-[58px] data-pending:cursor-progress data-pending:opacity-70\"\n                    )}\n                  />\n                )}\n              </div>\n              {/* OS9 close box: small raised square, knocked out of the title stripe. */}\n              {closeButton && item.dismissible !== false && (\n                <ToastClosePrimitive\n                  aria-label=\"Close\"\n                  className={cn(\n                    \"absolute left-[8px] top-[2px] size-[11px] cursor-default p-0\",\n                    \"border border-os9-black bg-os9-gray-300\",\n                    \"shadow-[0_0_0_2px_var(--os9-gray-200),inset_1px_1px_0_var(--os9-white),inset_-1px_-1px_0_var(--os9-gray-700)]\",\n                    \"active:bg-os9-gray-700\",\n                    \"active:shadow-[0_0_0_2px_var(--os9-gray-200),inset_1px_1px_0_var(--os9-gray-800),inset_-1px_-1px_0_var(--os9-gray-500)]\",\n                    \"outline-none focus-visible:os9-focus-ring\"\n                  )}\n                />\n              )}\n            </ToastPrimitive>\n          )\n        }}\n      </ToastRegionPrimitive>\n    </>\n  )\n}\n\nexport { RetroToaster, toast, retroToaster }\nexport type { RetroToasterProps, RetroToastOptions, RetroToastAction, RetroToastCancel }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}