{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "subscription-calendar-base",
  "type": "registry:component",
  "title": "Subscription Calendar (base)",
  "description": "Theme-ready base variant of Calendar card showing subscription cycles, renewals, and upcoming billing dates..",
  "dependencies": [
    "lucide-react",
    "motion",
    "react-icons"
  ],
  "files": [
    {
      "path": "components/watermelon/subscription-calendar.tsx",
      "type": "registry:component",
      "content": "'use client';\n\nimport React, { useState } from 'react';\nimport {\n  ChevronLeft,\n  ChevronRight,\n  Plus,\n  Search,\n  Download,\n  X,\n  Loader2,\n  Check,\n} from 'lucide-react';\nimport { AnimatePresence, motion } from 'motion/react';\nimport { TbCube } from 'react-icons/tb';\n\n/* ---------- Types ---------- */\nexport interface SubscriptionDay {\n  date: number;\n  isMuted?: boolean;\n  isLogo?: React.ReactNode[];\n  indicators?: React.ReactNode[];\n}\n\nexport interface SubscriptionCalendarProps {\n  month: string;\n  year: number;\n  days: SubscriptionDay[];\n  monthlyTotal: number;\n  subscriptionsCount: number;\n  newCount: number;\n  onPrevMonth?: () => void;\n  onNextMonth?: () => void;\n}\n\n/* ---------- Motion ---------- */\nconst spring = {\n  type: 'spring',\n  stiffness: 420,\n  damping: 28,\n  mass: 0.6,\n} as const;\n\n/* ---------- Main Component ---------- */\nexport const SubscriptionCalendar: React.FC<SubscriptionCalendarProps> = ({\n  month,\n  year,\n  days,\n  monthlyTotal,\n  subscriptionsCount,\n  newCount,\n  onPrevMonth,\n  onNextMonth,\n}) => {\n  const [selectedId, setSelectedId] = useState<string | null>('day-28');\n  const [isAdding, setIsAdding] = useState(false);\n  const [isSearching, setIsSearching] = useState(false);\n  const [isSummaryOpen, setIsSummaryOpen] = useState(false);\n  const [isDownloading, setIsDownloading] = useState(false);\n\n  const handleDownload = () => {\n    setIsDownloading(true);\n    setTimeout(() => setIsDownloading(false), 2000);\n  };\n\n  return (\n    <motion.div\n      initial={{ scale: 0.96, opacity: 0 }}\n      animate={{ scale: 1, opacity: 1 }}\n      transition={spring}\n      className=\"theme-injected bg-card border-border relative w-full max-w-105 rounded-3xl border p-4 shadow-2xl transition-all duration-500 sm:p-5\"\n    >\n      <div className=\"mb-4 flex items-center justify-between gap-2\">\n        <div className=\"flex items-center gap-2 overflow-hidden sm:gap-3\">\n          <h2 className=\"text-foreground truncate text-xs font-medium sm:text-sm\">\n            {month}, {year}\n          </h2>\n          <span className=\"xs:inline-block border-input text-muted-foreground hidden cursor-default rounded-full border bg-transparent px-3 py-1 text-[10px] whitespace-nowrap\">\n            Today\n          </span>\n          <div className=\"ml-1 flex items-center gap-1 sm:gap-2\">\n            <button\n              title=\"backward\"\n              onClick={onPrevMonth}\n              className=\"hover:bg-muted text-muted-foreground hover:text-foreground shrink-0 rounded-md p-1 transition-colors\"\n            >\n              <ChevronLeft size={18} />\n            </button>\n            <button\n              title=\"forward\"\n              onClick={onNextMonth}\n              className=\"hover:bg-muted text-muted-foreground hover:text-foreground shrink-0 rounded-md p-1 transition-colors\"\n            >\n              <ChevronRight size={18} />\n            </button>\n          </div>\n        </div>\n        <button\n          title=\"add event\"\n          onClick={() => setIsAdding(true)}\n          className=\"bg-primary text-primary-foreground flex h-7 w-10 shrink-0 items-center justify-center rounded-full shadow-lg transition-transform hover:scale-105 active:scale-95 sm:h-7 sm:w-11\"\n        >\n          <Plus size={16} />\n        </button>\n      </div>\n\n      <div className=\"\">\n        <AnimatePresence>\n          {isAdding && (\n            <motion.div\n              initial={{ opacity: 0, scale: 0.9, y: 10 }}\n              animate={{ opacity: 1, scale: 1, y: 0 }}\n              exit={{ opacity: 0, scale: 0.9, y: 10 }}\n              className=\"bg-card/95 absolute inset-0 z-50 flex flex-col items-center justify-center rounded-[23px] p-4 backdrop-blur-md sm:p-6\"\n            >\n              <button\n                onClick={() => setIsAdding(false)}\n                className=\"text-muted-foreground hover:text-foreground absolute top-4 right-4\"\n              >\n                <X size={20} />\n              </button>\n              <div className=\"bg-primary/10 text-primary mb-4 flex h-12 w-12 items-center justify-center rounded-full\">\n                <Plus size={24} />\n              </div>\n              <h3 className=\"text-foreground mb-1 text-sm font-bold\">\n                Quick Add Subscription\n              </h3>\n              <p className=\"text-muted-foreground mb-6 text-center text-[10px]\">\n                Enter the details of your new recurring payment.\n              </p>\n              <div className=\"flex w-full flex-col gap-2\">\n                <input\n                  type=\"text\"\n                  placeholder=\"Service Name (e.g. Netflix)\"\n                  className=\"border-input bg-transparent w-full rounded-lg border px-3 py-2 text-[11px] outline-none focus:ring-1 focus:ring-primary\"\n                />\n                <div className=\"flex flex-col gap-2 xs:flex-row\">\n                  <input\n                    type=\"text\"\n                    placeholder=\"Amount\"\n                    className=\"border-input bg-transparent flex-1 rounded-lg border px-3 py-2 text-[11px] outline-none focus:ring-1 focus:ring-primary\"\n                  />\n                  <input\n                    type=\"text\"\n                    placeholder=\"Date\"\n                    className=\"border-input bg-transparent w-full rounded-lg border px-3 py-2 text-[11px] outline-none focus:ring-1 focus:ring-primary xs:w-20\"\n                  />\n                </div>\n                <button\n                  onClick={() => setIsAdding(false)}\n                  className=\"bg-primary text-primary-foreground mt-2 flex w-full items-center justify-center gap-2 rounded-lg py-2 text-[11px] font-bold transition-opacity hover:opacity-90\"\n                >\n                  <Check size={14} /> Add Subscription\n                </button>\n              </div>\n            </motion.div>\n          )}\n\n          {isSearching && (\n            <motion.div\n              initial={{ opacity: 0, scale: 0.9, y: 10 }}\n              animate={{ opacity: 1, scale: 1, y: 0 }}\n              exit={{ opacity: 0, scale: 0.9, y: 10 }}\n              className=\"bg-card/95 absolute inset-0 z-50 flex flex-col items-center justify-center rounded-[23px] p-4 backdrop-blur-md sm:p-6\"\n            >\n              <button\n                onClick={() => setIsSearching(false)}\n                className=\"text-muted-foreground hover:text-foreground absolute top-4 right-4\"\n              >\n                <X size={20} />\n              </button>\n              <div className=\"bg-muted text-muted-foreground mb-4 flex h-12 w-12 items-center justify-center rounded-full\">\n                <Search size={24} />\n              </div>\n              <h3 className=\"text-foreground mb-1 text-sm font-bold\">\n                Search Subscriptions\n              </h3>\n              <div className=\"mt-4 w-full\">\n                <input\n                  autoFocus\n                  type=\"text\"\n                  placeholder=\"Type to search...\"\n                  className=\"border-input bg-transparent w-full rounded-lg border px-3 py-2 text-[11px] outline-none focus:ring-1 focus:ring-primary\"\n                />\n              </div>\n              <div className=\"mt-4 w-full text-center\">\n                <p className=\"text-muted-foreground text-[10px]\">Start typing to see results</p>\n              </div>\n            </motion.div>\n          )}\n\n          {isSummaryOpen && (\n            <motion.div\n              initial={{ opacity: 0, scale: 0.9, y: 10 }}\n              animate={{ opacity: 1, scale: 1, y: 0 }}\n              exit={{ opacity: 0, scale: 0.9, y: 10 }}\n              className=\"bg-card/95 absolute inset-0 z-50 flex flex-col items-center justify-center rounded-[23px] p-4 backdrop-blur-md sm:p-6\"\n            >\n              <button\n                onClick={() => setIsSummaryOpen(false)}\n                className=\"text-muted-foreground hover:text-foreground absolute top-4 right-4\"\n              >\n                <X size={20} />\n              </button>\n              <div className=\"bg-chart-2/10 text-chart-2 mb-4 flex h-12 w-12 items-center justify-center rounded-full\">\n                <TbCube size={24} />\n              </div>\n              <h3 className=\"text-foreground mb-1 text-sm font-bold\">\n                Monthly Summary\n              </h3>\n              <div className=\"mt-4 grid w-full grid-cols-2 gap-3\">\n                <div className=\"bg-muted/50 rounded-lg p-3\">\n                  <div className=\"text-muted-foreground text-[9px]\">Active</div>\n                  <div className=\"text-foreground text-sm font-bold\">{subscriptionsCount}</div>\n                </div>\n                <div className=\"bg-muted/50 rounded-lg p-3\">\n                  <div className=\"text-muted-foreground text-[9px]\">New</div>\n                  <div className=\"text-foreground text-sm font-bold\">{newCount}</div>\n                </div>\n                <div className=\"bg-primary/10 border-primary/20 col-span-2 rounded-lg border p-3 text-center\">\n                  <div className=\"text-primary text-[9px] font-medium\">Total Spend</div>\n                  <div className=\"text-primary text-base font-bold\">${monthlyTotal.toFixed(2)}</div>\n                </div>\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n\n        <div className=\"text-muted-foreground mb-2 grid grid-cols-7 gap-1 text-[8px] font-semibold tracking-wider sm:text-[9px]\">\n        {['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'].map((d) => (\n          <div\n            key={d}\n            className=\"bg-muted/60 border-border rounded-full border py-1.5 text-center\"\n          >\n            {d}\n          </div>\n        ))}\n      </div>\n      <div className=\"grid grid-cols-7 gap-1 sm:gap-1.5\">\n        {days.map((day, idx) => {\n          const uniqueId = `day-${day.date}-${idx}`;\n          const isActive = selectedId === uniqueId;\n\n          return (\n            <motion.button\n              key={uniqueId}\n              layout\n              whileTap={{ scale: 0.95 }}\n              onClick={() => setSelectedId(uniqueId)}\n              transition={spring}\n              className={`relative flex aspect-square flex-col items-center justify-center rounded-xl border text-[10px] font-medium transition-colors sm:h-12 sm:text-[11px] ${\n                day.isMuted\n                  ? 'bg-muted/40 border-border text-muted-foreground/60'\n                  : 'bg-muted/60 border-border text-foreground hover:border-input'\n              }`}\n            >\n              {isActive && (\n                <motion.div\n                  layoutId=\"activeGlow\"\n                  className=\"border-primary/50 bg-primary/10 absolute inset-0 z-0 rounded-xl border\"\n                  transition={spring}\n                />\n              )}\n\n              <div className=\"relative z-10 flex flex-col items-center justify-start gap-0.5 sm:gap-1\">\n                <span>{day.date}</span>\n                <span className=\"scale-75 sm:scale-100\">{day.isLogo}</span>\n              </div>\n\n              {day.indicators && (\n                <div className=\"absolute top-1 right-1 flex gap-0.5 sm:top-1.5 sm:right-1.5\">\n                  {day.indicators}\n                </div>\n              )}\n            </motion.button>\n          );\n        })}\n      </div>\n      </div>\n      {/* Footer Info*/}\n      <div className=\"text-muted-foreground mt-5 flex items-center justify-between gap-2 text-[8px] font-semibold tracking-widest sm:text-[9px]\">\n        <div className=\"flex items-center gap-2 sm:gap-4\">\n          <span className=\"hover:text-chart-2 flex cursor-default items-center gap-1.5 transition-colors\">\n            <span className=\"bg-chart-2 h-1 w-1 rounded-full sm:h-1.5 sm:w-1.5\" />\n            MONTHLY\n          </span>\n          <span className=\"hover:text-chart-4 flex cursor-default items-center gap-1.5 transition-colors\">\n            <span className=\"bg-chart-4 h-1 w-1 rounded-full sm:h-1.5 sm:w-1.5\" />\n            YEARLY\n          </span>\n        </div>\n\n        <span className=\"text-muted-foreground whitespace-nowrap\">\n          <span className=\"text-foreground\">{subscriptionsCount}</span> SUBS /{' '}\n          <span className=\"text-foreground\">{newCount}</span> NEW\n        </span>\n      </div>\n\n      {/* Bottom Bar*/}\n      <div className=\"border-border mt-4 flex items-center justify-between gap-2 border-t pt-4\">\n        <div className=\"text-muted-foreground flex gap-3 sm:gap-4\">\n          <Search\n            size={16}\n            onClick={() => setIsSearching(true)}\n            className=\"hover:text-foreground shrink-0 cursor-pointer transition-colors\"\n          />\n          <button\n            onClick={handleDownload}\n            disabled={isDownloading}\n            className=\"hover:text-foreground flex items-center justify-center transition-colors\"\n          >\n            {isDownloading ? (\n              <Loader2 size={16} className=\"text-primary animate-spin\" />\n            ) : (\n              <Download size={16} className=\"shrink-0 cursor-pointer\" />\n            )}\n          </button>\n          <TbCube\n            size={16}\n            onClick={() => setIsSummaryOpen(true)}\n            className=\"hover:text-foreground shrink-0 cursor-pointer transition-colors\"\n          />\n        </div>\n\n        <div className=\"text-muted-foreground truncate text-[9px] font-medium sm:text-[10px]\">\n          MONTHLY TOTAL :{' '}\n          <span className=\"text-foreground ml-1 text-[11px] font-bold sm:text-[12px]\">\n            ${monthlyTotal.toFixed(2)}\n          </span>\n        </div>\n      </div>\n    </motion.div>\n  );\n};\n"
    }
  ]
}
