{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "polar-subscription-badge",
  "title": "Polar Subscription Badge",
  "description": "Subscription tier badge with status indicators and automatic tier-based coloring.",
  "dependencies": [
    "@polar-sh/sdk"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/blocks/polar/polar-subscription-badge/components/elements/polar-subscription-badge.tsx",
      "content": "\"use client\";\n\nimport { useMemo } from \"react\";\n\nfunction cn(...classes: (string | boolean | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nexport type SubscriptionStatus = \"active\" | \"trialing\" | \"past_due\" | \"canceled\" | \"incomplete\";\n\nexport interface PolarSubscriptionBadgeProps {\n  tier: string;\n  status?: SubscriptionStatus;\n  showStatus?: boolean;\n  size?: \"sm\" | \"md\" | \"lg\";\n  variant?: \"default\" | \"outline\" | \"solid\";\n  className?: string;\n}\n\nconst TIER_COLORS: Record<string, { bg: string; text: string; border: string }> = {\n  free: {\n    bg: \"bg-slate-100 dark:bg-slate-800\",\n    text: \"text-slate-700 dark:text-slate-300\",\n    border: \"border-slate-300 dark:border-slate-600\",\n  },\n  starter: {\n    bg: \"bg-blue-100 dark:bg-blue-900/30\",\n    text: \"text-blue-700 dark:text-blue-300\",\n    border: \"border-blue-300 dark:border-blue-700\",\n  },\n  pro: {\n    bg: \"bg-violet-100 dark:bg-violet-900/30\",\n    text: \"text-violet-700 dark:text-violet-300\",\n    border: \"border-violet-300 dark:border-violet-700\",\n  },\n  business: {\n    bg: \"bg-amber-100 dark:bg-amber-900/30\",\n    text: \"text-amber-700 dark:text-amber-300\",\n    border: \"border-amber-300 dark:border-amber-700\",\n  },\n  enterprise: {\n    bg: \"bg-gradient-to-r from-violet-100 to-fuchsia-100 dark:from-violet-900/30 dark:to-fuchsia-900/30\",\n    text: \"text-violet-700 dark:text-violet-300\",\n    border: \"border-violet-300 dark:border-violet-700\",\n  },\n};\n\nconst STATUS_INDICATORS: Record<SubscriptionStatus, { color: string; label: string }> = {\n  active: { color: \"bg-green-500\", label: \"Active\" },\n  trialing: { color: \"bg-blue-500\", label: \"Trial\" },\n  past_due: { color: \"bg-amber-500\", label: \"Past Due\" },\n  canceled: { color: \"bg-red-500\", label: \"Canceled\" },\n  incomplete: { color: \"bg-gray-400\", label: \"Incomplete\" },\n};\n\nconst SIZE_CLASSES = {\n  sm: \"px-2 py-0.5 text-xs gap-1\",\n  md: \"px-2.5 py-1 text-sm gap-1.5\",\n  lg: \"px-3 py-1.5 text-base gap-2\",\n};\n\nfunction CrownIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"currentColor\"\n    >\n      <path d=\"M2.5 19h19v2h-19zm19.57-9.36c-.21-.8-1.04-1.28-1.84-1.06L14.92 10l-2.29-6.87a1.5 1.5 0 0 0-2.83-.04L7.37 9.93l-5.2-1.48a1.5 1.5 0 0 0-1.77 2.05L4 18h16l3.57-7.02c.28-.55.27-1.14.5-1.34z\" />\n    </svg>\n  );\n}\n\nfunction StarIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      className={className}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 24 24\"\n      fill=\"currentColor\"\n    >\n      <polygon points=\"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2\" />\n    </svg>\n  );\n}\n\nexport function PolarSubscriptionBadge({\n  tier,\n  status = \"active\",\n  showStatus = false,\n  size = \"md\",\n  variant = \"default\",\n  className,\n}: PolarSubscriptionBadgeProps) {\n  const tierKey = tier.toLowerCase();\n  const colors = TIER_COLORS[tierKey] || TIER_COLORS.starter;\n  const statusInfo = STATUS_INDICATORS[status];\n\n  const isPremium = useMemo(() => {\n    const premiumTiers = [\"pro\", \"business\", \"enterprise\"];\n    return premiumTiers.includes(tierKey);\n  }, [tierKey]);\n\n  const Icon = tierKey === \"enterprise\" ? CrownIcon : isPremium ? StarIcon : null;\n\n  return (\n    <span\n      data-slot=\"polar-subscription-badge\"\n      className={cn(\n        \"inline-flex items-center rounded-full font-medium transition-colors\",\n        SIZE_CLASSES[size],\n        variant === \"outline\" && cn(\"border\", colors.border, colors.text, \"bg-transparent\"),\n        variant === \"solid\" && cn(colors.bg, colors.text),\n        variant === \"default\" && cn(colors.bg, colors.text),\n        className\n      )}\n    >\n      {Icon && (\n        <Icon\n          className={cn(\n            size === \"sm\" && \"h-3 w-3\",\n            size === \"md\" && \"h-3.5 w-3.5\",\n            size === \"lg\" && \"h-4 w-4\"\n          )}\n        />\n      )}\n      <span data-slot=\"tier-name\">{tier}</span>\n      {showStatus && (\n        <span\n          data-slot=\"status-indicator\"\n          className=\"flex items-center gap-1\"\n          title={statusInfo.label}\n        >\n          <span\n            className={cn(\n              \"rounded-full\",\n              statusInfo.color,\n              size === \"sm\" && \"h-1.5 w-1.5\",\n              size === \"md\" && \"h-2 w-2\",\n              size === \"lg\" && \"h-2.5 w-2.5\"\n            )}\n          />\n        </span>\n      )}\n    </span>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Compact badge for displaying subscription tiers. Supports status indicators, multiple sizes, and outline variant.",
  "categories": [
    "polar"
  ],
  "type": "registry:block"
}