{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notification-badge",
  "title": "Notification Badge",
  "description": "A counter or dot on an icon or avatar, cut out with CSS shape() so it reads on any background",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/notification-badge.tsx",
      "content": "\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { createContext, use, useMemo } from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst NotificationBadgeContext = createContext<{\n  value?: number | string;\n  visible: boolean;\n}>({ visible: false });\n\nconst notificationBadgeVariants = cva(\n  \"group/notification-badge relative inline-flex [--hole-arc-left:calc(100%_+_var(--hole-right)_-_var(--hole-w)_+_var(--hole-h)/2)] [--hole-arc-radius:calc(var(--hole-h)/2_+_var(--hole-gap))] [--hole-arc-right:calc(100%_+_var(--hole-right)_-_var(--hole-h)/2)] [--hole-center-y:calc(var(--hole-h)/2_+_var(--hole-top))] [--hole-gap:1.5px] [--hole-top:calc(0.125rem_-_var(--hole-h)/2_+_var(--hole-radius,0px)_*_0.293)]\",\n  {\n    defaultVariants: { variant: \"default\" },\n    variants: {\n      variant: {\n        default:\n          \"[--hole-h:1rem] [--hole-right:calc(var(--hole-w)/2_-_var(--hole-radius,0px)_*_0.293)] [--hole-w:calc(var(--hole-h)_+_(var(--hole-chars,1)_-_1)_*_0.5rem)]\",\n        dot: \"[--hole-h:0.5rem] [--hole-right:calc(var(--hole-w)/2_-_0.125rem_-_var(--hole-radius,0px)_*_0.293)] [--hole-w:0.5rem]\",\n      },\n    },\n  }\n);\n\nfunction NotificationBadge({\n  className,\n  style,\n  value,\n  variant,\n  ...props\n}: React.ComponentProps<\"span\"> &\n  VariantProps<typeof notificationBadgeVariants> & {\n    value: number | string;\n  }) {\n  const isDot = variant === \"dot\";\n  const visible = typeof value === \"number\" ? value > 0 : value !== \"\";\n  const context = useMemo(\n    () => ({ value: isDot ? undefined : value, visible }),\n    [isDot, value, visible]\n  );\n\n  return (\n    <NotificationBadgeContext value={context}>\n      <span\n        className={cn(notificationBadgeVariants({ variant }), className)}\n        data-slot=\"notification-badge\"\n        data-visible={visible || undefined}\n        style={\n          {\n            \"--hole-chars\": String(value).length,\n            ...style,\n          } as React.CSSProperties\n        }\n        {...props}\n      />\n    </NotificationBadgeContext>\n  );\n}\n\nfunction NotificationBadgeContent({\n  className,\n  ...props\n}: React.ComponentProps<\"span\">) {\n  return (\n    <span\n      className={cn(\n        \"inline-flex\",\n        \"group-data-visible/notification-badge:[clip-path:shape(evenodd_from_-9999px_-9999px,hline_to_calc(100%_+_9999px),vline_to_calc(100%_+_9999px),hline_to_-9999px,close,move_to_var(--hole-arc-right)_calc(var(--hole-center-y)_-_var(--hole-arc-radius)),arc_to_var(--hole-arc-right)_calc(var(--hole-center-y)_+_var(--hole-arc-radius))_of_var(--hole-arc-radius)_cw,hline_to_var(--hole-arc-left),arc_to_var(--hole-arc-left)_calc(var(--hole-center-y)_-_var(--hole-arc-radius))_of_var(--hole-arc-radius)_cw,close)]\",\n        className\n      )}\n      data-slot=\"notification-badge-content\"\n      {...props}\n    />\n  );\n}\n\nfunction NotificationBadgeIndicator({\n  className,\n  ...props\n}: Omit<React.ComponentProps<\"span\">, \"children\">) {\n  const { value, visible } = use(NotificationBadgeContext);\n  if (!visible) {\n    return null;\n  }\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        \"bg-destructive absolute top-(--hole-top) -right-(--hole-right) inline-flex h-(--hole-h) w-(--hole-w) items-center justify-center rounded-full text-xs font-medium whitespace-nowrap text-white forced-colors:bg-[CanvasText] forced-colors:text-[Canvas]\",\n        className\n      )}\n      data-slot=\"notification-badge-indicator\"\n      {...props}\n    >\n      {value}\n    </span>\n  );\n}\n\nexport {\n  NotificationBadge,\n  NotificationBadgeContent,\n  NotificationBadgeIndicator,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}