{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-toast",
  "title": "Alert Toast",
  "description": "A polished toast/alert notification, 5 tones, stacked or inline layout, icons, primary/secondary actions, dismiss and auto-dismiss, light/dark theme, plus a showcase mode rendering every variant side by side.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/alert-toast/alert-toast.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type AlertTone = \"neutral\" | \"info\" | \"warning\" | \"success\" | \"error\";\nexport type AlertIconType = \"none\" | \"info\" | \"success\" | \"error\" | \"custom\";\nexport type AlertLayout = \"stacked\" | \"inline\";\nexport type AlertBackground = \"subtle\" | \"tinted\";\nexport type AlertTheme = \"light\" | \"dark\";\n\nexport interface AlertContent {\n  title?: string;\n  description?: string;\n  layout?: AlertLayout;\n}\n\nexport interface AlertAppearance {\n  tone?: AlertTone;\n  background?: AlertBackground;\n  accentBar?: boolean;\n  icon?: AlertIconType;\n  customIcon?: string;\n  theme?: AlertTheme;\n  radius?: number;\n}\n\nexport interface AlertActions {\n  showPrimary?: boolean;\n  primaryLabel?: string;\n  primaryExternal?: boolean;\n  showSecondary?: boolean;\n  secondaryLabel?: string;\n  secondaryEmphasis?: boolean;\n}\n\nexport interface AlertDismiss {\n  dismissible?: boolean;\n  autoDismiss?: boolean;\n  duration?: number;\n}\n\nconst TONE_PALETTES: Record<AlertTone, Record<AlertTheme, { tintedBg: string; text: string; accent: string }>> = {\n  neutral: {\n    light: { tintedBg: \"#F4F4F6\", text: \"#3F3F46\", accent: \"#71717A\" },\n    dark: { tintedBg: \"#202024\", text: \"#D4D4D8\", accent: \"#A1A1AA\" },\n  },\n  info: {\n    light: { tintedBg: \"#EEF2FF\", text: \"#4F46E5\", accent: \"#6366F1\" },\n    dark: { tintedBg: \"#171B33\", text: \"#A5B4FC\", accent: \"#818CF8\" },\n  },\n  warning: {\n    light: { tintedBg: \"#FFF8E6\", text: \"#B45309\", accent: \"#F59E0B\" },\n    dark: { tintedBg: \"#2E2410\", text: \"#FCD34D\", accent: \"#FBBF24\" },\n  },\n  success: {\n    light: { tintedBg: \"#EEFBF2\", text: \"#15803D\", accent: \"#22C55E\" },\n    dark: { tintedBg: \"#0F2A1C\", text: \"#6EE7B7\", accent: \"#34D399\" },\n  },\n  error: {\n    light: { tintedBg: \"#FDF1F4\", text: \"#D6336C\", accent: \"#E8447A\" },\n    dark: { tintedBg: \"#321019\", text: \"#FB91B5\", accent: \"#F43F5E\" },\n  },\n};\n\nconst SUBTLE: Record<AlertTheme, { bg: string; strong: string; muted: string }> = {\n  light: { bg: \"#F7F7F8\", strong: \"#27272A\", muted: \"#71717A\" },\n  dark: { bg: \"#1C1C1F\", strong: \"#FAFAFA\", muted: \"#A1A1AA\" },\n};\n\nconst SURFACE: Record<AlertTheme, { bg: string; border: string; text: string }> = {\n  light: { bg: \"#FFFFFF\", border: \"#E4E4E7\", text: \"#27272A\" },\n  dark: { bg: \"#2A2A2E\", border: \"#3F3F46\", text: \"#FAFAFA\" },\n};\n\nfunction ToastIcon({ type, customIcon, accent, size }: { type: AlertIconType; customIcon?: string; accent: string; size: number }) {\n  if (type === \"none\") return null;\n\n  if (type === \"custom\") {\n    return (\n      <span className=\"flex shrink-0 items-center justify-center leading-none\" style={{ fontSize: size * 0.82, width: size, height: size }}>\n        {customIcon}\n      </span>\n    );\n  }\n\n  if (type === \"success\") {\n    return (\n      <svg width={size} height={size} viewBox=\"0 0 22 22\" fill=\"none\" className=\"shrink-0\">\n        <path d=\"M5 11.5L9.2 15.5L17 6.5\" stroke={accent} strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      </svg>\n    );\n  }\n\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 22 22\" fill=\"none\" className=\"shrink-0\">\n      <circle cx=\"11\" cy=\"11\" r=\"11\" fill={accent} />\n      {type === \"info\" ? (\n        <>\n          <circle cx=\"11\" cy=\"6.5\" r=\"1.25\" fill=\"#fff\" />\n          <line x1=\"11\" y1=\"9.75\" x2=\"11\" y2=\"15.5\" stroke=\"#fff\" strokeWidth={2} strokeLinecap=\"round\" />\n        </>\n      ) : (\n        <>\n          <line x1=\"7.2\" y1=\"7.2\" x2=\"14.8\" y2=\"14.8\" stroke=\"#fff\" strokeWidth={2} strokeLinecap=\"round\" />\n          <line x1=\"14.8\" y1=\"7.2\" x2=\"7.2\" y2=\"14.8\" stroke=\"#fff\" strokeWidth={2} strokeLinecap=\"round\" />\n        </>\n      )}\n    </svg>\n  );\n}\n\nfunction ExternalIcon({ color }: { color: string }) {\n  return (\n    <svg width={12} height={12} viewBox=\"0 0 12 12\" fill=\"none\" className=\"shrink-0\">\n      <path d=\"M3.5 8.5L8.5 3.5M5 3.5H8.5V7\" stroke={color} strokeWidth={1.4} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nfunction CloseIcon({ color }: { color: string }) {\n  return (\n    <svg width={10} height={10} viewBox=\"0 0 10 10\" fill=\"none\">\n      <path d=\"M1 1L9 9M9 1L1 9\" stroke={color} strokeWidth={1.4} strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction PrimaryButton({ label, external, surface, onClick }: { label: string; external?: boolean; surface: { bg: string; border: string; text: string }; onClick?: () => void }) {\n  return (\n    <button\n      onClick={onClick}\n      className=\"inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg px-3.5 text-[13px] font-medium whitespace-nowrap\"\n      style={{ border: `1px solid ${surface.border}`, backgroundColor: surface.bg, color: surface.text, fontFamily: \"Inter, sans-serif\" }}\n    >\n      {label}\n      {external && <ExternalIcon color={surface.text} />}\n    </button>\n  );\n}\n\nfunction SecondaryLink({ label, emphasis, accent, muted, onClick }: { label: string; emphasis?: boolean; accent: string; muted: string; onClick?: () => void }) {\n  return (\n    <span\n      onClick={onClick}\n      className=\"shrink-0 cursor-pointer text-[13px] whitespace-nowrap underline decoration-solid underline-offset-2\"\n      style={{ fontWeight: emphasis ? 700 : 500, color: emphasis ? accent : muted, fontFamily: \"Inter, sans-serif\" }}\n    >\n      {label}\n    </span>\n  );\n}\n\nfunction DismissButton({ onClick, color }: { onClick: () => void; color: string }) {\n  return (\n    <button onClick={onClick} aria-label=\"Dismiss\" className=\"flex h-[22px] w-[22px] shrink-0 cursor-pointer items-center justify-center rounded-md border-none bg-transparent p-0\">\n      <CloseIcon color={color} />\n    </button>\n  );\n}\n\nexport interface AlertToastProps {\n  content?: AlertContent;\n  appearance?: AlertAppearance;\n  actions?: AlertActions;\n  dismiss?: AlertDismiss;\n  onDismiss?: () => void;\n  onPrimaryClick?: () => void;\n  onSecondaryClick?: () => void;\n  spacing?: number;\n  enterDelay?: number;\n  className?: string;\n}\n\nexport function AlertToast({\n  content = { title: \"New update available\", description: \"A new version of the app is ready to install.\", layout: \"stacked\" },\n  appearance = { tone: \"info\", background: \"tinted\", accentBar: true, icon: \"info\", customIcon: \"🙁\", theme: \"light\", radius: 12 },\n  actions = { showPrimary: false, primaryLabel: \"Update now\", primaryExternal: false, showSecondary: false, secondaryLabel: \"Later\", secondaryEmphasis: false },\n  dismiss = { dismissible: true, autoDismiss: false, duration: 4 },\n  onDismiss,\n  onPrimaryClick,\n  onSecondaryClick,\n  spacing = 0,\n  enterDelay = 0,\n  className,\n}: AlertToastProps) {\n  const [visible, setVisible] = React.useState(true);\n\n  const theme = appearance.theme ?? \"light\";\n  const tone = TONE_PALETTES[appearance.tone ?? \"info\"][theme];\n  const subtle = SUBTLE[theme];\n  const surface = SURFACE[theme];\n\n  const isTinted = (appearance.background ?? \"tinted\") === \"tinted\";\n  const bg = isTinted ? tone.tintedBg : subtle.bg;\n  const titleColor = isTinted ? tone.text : subtle.strong;\n  const descColor = isTinted ? tone.text : subtle.muted;\n  const closeColor = theme === \"light\" ? \"rgba(24,24,27,0.35)\" : \"rgba(255,255,255,0.4)\";\n  const radius = appearance.radius ?? 12;\n  const icon = appearance.icon ?? \"info\";\n  const customIcon = appearance.customIcon ?? \"🙁\";\n  const accentBar = appearance.accentBar ?? true;\n  const layout = content.layout ?? \"stacked\";\n  const showPrimary = actions.showPrimary ?? false;\n  const primaryLabel = actions.primaryLabel ?? \"Update now\";\n  const showSecondary = actions.showSecondary ?? false;\n  const secondaryLabel = actions.secondaryLabel ?? \"Later\";\n  const dismissible = dismiss.dismissible ?? true;\n\n  const handleClose = () => {\n    setVisible(false);\n    onDismiss?.();\n  };\n\n  React.useEffect(() => {\n    if (!dismiss.autoDismiss) return;\n    const timer = setTimeout(() => {\n      setVisible(false);\n      onDismiss?.();\n    }, Math.max(dismiss.duration ?? 4, 0.5) * 1000);\n    return () => clearTimeout(timer);\n  }, [dismiss.autoDismiss, dismiss.duration, onDismiss]);\n\n  const hasIcon = icon !== \"none\";\n  const iconSize = 22;\n  const iconOffset = hasIcon ? iconSize + 10 : 0;\n  const isInline = layout === \"inline\";\n\n  const descLines = (content.description ?? \"\")\n    .split(\"\\n\")\n    .map((line) => line.trim())\n    .filter(Boolean);\n\n  const hasRow2 = !isInline && descLines.length > 0;\n  const hasRow3 = showPrimary || (!isInline && showSecondary);\n\n  return (\n    <AnimatePresence>\n      {visible && (\n        <motion.div\n          initial={{ opacity: 0, y: -10 }}\n          animate={{ opacity: 1, y: 0, transition: { duration: 0.35, delay: enterDelay, ease: [0.16, 1, 0.3, 1] } }}\n          exit={{ opacity: 0, height: 0, marginBottom: 0, transition: { duration: 0.25, ease: \"easeInOut\" } }}\n          className=\"w-full shrink-0 overflow-hidden\"\n          style={{ marginBottom: spacing }}\n        >\n          <div className={cn(\"relative box-border w-full overflow-hidden\", className)} style={{ borderRadius: radius, backgroundColor: bg }}>\n            {accentBar && <div className=\"absolute top-0 bottom-0 left-0 w-[3px]\" style={{ backgroundColor: tone.accent }} />}\n            <div\n              className=\"box-border flex flex-col px-4 py-3.5\"\n              style={{ gap: hasRow2 || hasRow3 ? 10 : 0, paddingLeft: accentBar ? 20 : 16, fontFamily: \"Inter, sans-serif\" }}\n            >\n              <div className=\"flex items-center gap-2.5\">\n                {hasIcon && <ToastIcon type={icon} customIcon={customIcon} accent={tone.accent} size={iconSize} />}\n                <div className=\"flex min-w-0 flex-1 flex-wrap items-baseline gap-1.5\">\n                  {content.title && (\n                    <span className=\"text-sm leading-[1.45] font-semibold\" style={{ color: titleColor }}>\n                      {content.title}\n                    </span>\n                  )}\n                  {isInline && descLines.length > 0 && (\n                    <span className=\"text-sm leading-[1.45] font-normal\" style={{ color: descColor }}>\n                      {descLines.join(\" \")}\n                    </span>\n                  )}\n                </div>\n                {isInline && showSecondary && (\n                  <SecondaryLink label={secondaryLabel} emphasis={actions.secondaryEmphasis} accent={tone.accent} muted={subtle.muted} onClick={onSecondaryClick} />\n                )}\n                {dismissible && <DismissButton onClick={handleClose} color={closeColor} />}\n              </div>\n\n              {hasRow2 && (\n                <div className=\"flex flex-col gap-1\" style={{ paddingLeft: iconOffset }}>\n                  {descLines.map((line, i) => (\n                    <span key={i} className=\"text-[13px] leading-[1.55]\" style={{ color: descColor }}>\n                      {line}\n                    </span>\n                  ))}\n                </div>\n              )}\n\n              {hasRow3 && (\n                <div className=\"flex items-center gap-3.5\" style={{ paddingLeft: iconOffset }}>\n                  {showPrimary && <PrimaryButton label={primaryLabel} external={actions.primaryExternal} surface={surface} onClick={onPrimaryClick} />}\n                  {!isInline && showSecondary && (\n                    <SecondaryLink label={secondaryLabel} emphasis={actions.secondaryEmphasis} accent={tone.accent} muted={subtle.muted} onClick={onSecondaryClick} />\n                  )}\n                </div>\n              )}\n            </div>\n          </div>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}