{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timeline",
  "title": "Timeline",
  "description": "A vertical timeline with status markers (done, active, pending, error), a connecting line, an alternating layout option, collapsible per-item detail and a scroll-triggered staggered reveal.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/timeline/timeline.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 TimelineStatus = \"done\" | \"active\" | \"pending\" | \"error\";\nexport type TimelineAlign = \"left\" | \"alternate\";\nexport type TimelineSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface TimelineItem {\n  id: string;\n  title: React.ReactNode;\n  description?: React.ReactNode;\n  date?: string;\n  icon?: React.ReactNode;\n  status?: TimelineStatus;\n  /** Extra detail hidden behind a \"Show more\" toggle. */\n  content?: React.ReactNode;\n}\n\nexport interface TimelineProps {\n  items: TimelineItem[];\n  align?: TimelineAlign;\n  size?: TimelineSize;\n  theme?: \"dark\" | \"light\";\n  accentColor?: string;\n  lineStyle?: \"solid\" | \"dashed\";\n  /** Fade + slide each row in as it scrolls into view, staggered. */\n  animateOnView?: boolean;\n  width?: number;\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", faint: \"rgba(245,244,241,0.35)\", line: \"rgba(255,255,255,0.14)\", markerBg: \"#0E0E0E\", pending: \"rgba(255,255,255,0.14)\", error: \"#FF7A6B\", hover: \"rgba(255,255,255,0.06)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", faint: \"rgba(10,10,10,0.35)\", line: \"rgba(10,10,10,0.12)\", markerBg: \"#FFFFFF\", pending: \"rgba(10,10,10,0.14)\", error: \"#E5484D\", hover: \"rgba(10,10,10,0.05)\" },\n};\n\nconst SIZES: Record<TimelineSize, { marker: number; icon: number; font: number; desc: number; date: number; gap: number }> = {\n  sm: { marker: 22, icon: 11, font: 13, desc: 12, date: 11, gap: 20 },\n  md: { marker: 26, icon: 13, font: 14.5, desc: 13, date: 11.5, gap: 26 },\n  lg: { marker: 30, icon: 15, font: 16, desc: 14, date: 12.5, gap: 32 },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\ntype Size = (typeof SIZES)[\"md\"];\n\nfunction readableTextOn(hex: string): string {\n  const h = hex.replace(\"#\", \"\");\n  const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\n  const r = parseInt(full.slice(0, 2), 16);\n  const g = parseInt(full.slice(2, 4), 16);\n  const b = parseInt(full.slice(4, 6), 16);\n  return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? \"#0A0A0A\" : \"#FFFFFF\";\n}\n\nfunction CheckGlyph({ size, color }: { size: number; color: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M2.3 6.3L4.7 8.7L9.7 3.3\" stroke={color} strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nfunction XGlyph({ size, color }: { size: number; color: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M3 3L9 9M9 3L3 9\" stroke={color} strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\ninterface MarkerProps {\n  item: TimelineItem;\n  s: Size;\n  p: Palette;\n  accent: string;\n}\n\nfunction Marker({ item, s, p, accent }: MarkerProps) {\n  const status = item.status;\n  const onAccent = readableTextOn(accent);\n  const filled = status === \"done\" || status === \"active\" || status === \"error\";\n  const bg = status === \"error\" ? p.error : status === \"pending\" ? \"transparent\" : status ? accent : p.markerBg;\n  const border = status === \"pending\" ? p.pending : status ? \"transparent\" : p.faint;\n  const fg = status === \"pending\" || !status ? p.muted : onAccent;\n\n  return (\n    <span className=\"relative flex shrink-0 items-center justify-center rounded-full\" style={{ width: s.marker, height: s.marker, background: bg, border: `1.5px solid ${border}`, color: fg }}>\n      {status === \"active\" && (\n        <motion.span\n          aria-hidden=\"true\"\n          className=\"absolute rounded-full\"\n          style={{ inset: -4, border: `1.5px solid ${accent}` }}\n          animate={{ scale: [1, 1.35, 1], opacity: [0.6, 0, 0.6] }}\n          transition={{ duration: 1.8, repeat: Infinity, ease: \"easeInOut\" }}\n        />\n      )}\n      {item.icon ? (\n        <span className=\"flex items-center justify-center\" style={{ width: s.icon, height: s.icon }}>\n          {item.icon}\n        </span>\n      ) : status === \"done\" ? (\n        <CheckGlyph size={s.icon - 2} color={fg} />\n      ) : status === \"error\" ? (\n        <XGlyph size={s.icon - 2} color={fg} />\n      ) : filled || !status ? (\n        <span className=\"rounded-full\" style={{ width: s.icon * 0.4, height: s.icon * 0.4, background: fg }} />\n      ) : null}\n    </span>\n  );\n}\n\ninterface RowProps {\n  item: TimelineItem;\n  s: Size;\n  p: Palette;\n  accent: string;\n  side: \"left\" | \"right\";\n  align: TimelineAlign;\n  showLine: boolean;\n  lineStyle: \"solid\" | \"dashed\";\n  animateOnView: boolean;\n  index: number;\n}\n\nfunction Row({ item, s, p, accent, side, align, showLine, lineStyle, animateOnView, index }: RowProps) {\n  const [expanded, setExpanded] = React.useState(false);\n  const flip = align === \"alternate\" && side === \"right\";\n  const textAlign = align === \"alternate\" ? (flip ? \"left\" : \"right\") : \"left\";\n\n  const body = (\n    <div className=\"flex min-w-0 flex-1 flex-col\" style={{ gap: 3, textAlign, alignItems: align === \"alternate\" ? (flip ? \"flex-start\" : \"flex-end\") : \"stretch\" }}>\n      {item.date && (\n        <span className=\"font-medium tabular-nums uppercase\" style={{ color: p.faint, fontSize: s.date, letterSpacing: \"0.05em\" }}>\n          {item.date}\n        </span>\n      )}\n      <span className=\"font-semibold tracking-[-0.01em]\" style={{ color: p.text, fontSize: s.font, lineHeight: 1.4 }}>\n        {item.title}\n      </span>\n      {item.description && (\n        <span style={{ color: p.muted, fontSize: s.desc, lineHeight: 1.55 }}>{item.description}</span>\n      )}\n      {item.content && (\n        <>\n          <button\n            type=\"button\"\n            onClick={() => setExpanded((v) => !v)}\n            aria-expanded={expanded}\n            className=\"mt-1 inline-flex w-fit cursor-pointer items-center border-none bg-transparent p-0 font-semibold outline-none focus-visible:ring-2\"\n            style={{ gap: 4, color: accent, fontSize: s.desc - 0.5, flexDirection: flip ? \"row\" : align === \"alternate\" ? \"row-reverse\" : \"row\", [\"--tw-ring-color\" as string]: accent }}\n          >\n            <motion.svg width=\"11\" height=\"11\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" animate={{ rotate: expanded ? 90 : 0 }} transition={{ duration: 0.18 }} aria-hidden=\"true\">\n              <path d=\"M6 3.5L10.5 8L6 12.5\" />\n            </motion.svg>\n            {expanded ? \"Show less\" : \"Show more\"}\n          </button>\n          <AnimatePresence initial={false}>\n            {expanded && (\n              <motion.div initial={{ opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={{ opacity: 0, height: 0 }} transition={{ duration: 0.22, ease: [0.16, 1, 0.3, 1] }} className=\"w-full overflow-hidden\">\n                <div style={{ marginTop: 4, padding: 12, borderRadius: 12, background: p.hover, color: p.muted, fontSize: s.desc, lineHeight: 1.55, textAlign: \"left\" }}>{item.content}</div>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </>\n      )}\n    </div>\n  );\n\n  // The marker column needs a *real* height to hang the connector line\n  // from — relying on flex's default stretch (rather than items-start) so\n  // it matches its tallest sibling (the body text), then the line is\n  // absolutely positioned within it and extended past its own bottom edge\n  // by the row gap, reaching exactly where the next marker starts.\n  const markerCol = (\n    <div className=\"relative flex shrink-0 flex-col items-center\" style={{ width: s.marker }}>\n      <Marker item={item} s={s} p={p} accent={accent} />\n      {showLine && (\n        <div\n          className=\"absolute left-1/2\"\n          style={{\n            width: lineStyle === \"dashed\" ? 0 : 1.5,\n            top: s.marker + 2,\n            bottom: -s.gap,\n            borderLeft: lineStyle === \"dashed\" ? `1.5px dashed ${p.line}` : undefined,\n            background: lineStyle === \"dashed\" ? undefined : p.line,\n            transform: \"translateX(-50%)\",\n          }}\n        />\n      )}\n    </div>\n  );\n\n  const content =\n    align === \"alternate\" ? (\n      <div className=\"grid w-full\" style={{ gridTemplateColumns: `1fr ${s.marker}px 1fr`, columnGap: 20 }}>\n        <div style={{ gridColumn: 1 }}>{side === \"left\" ? body : null}</div>\n        <div style={{ gridColumn: 2 }}>{markerCol}</div>\n        <div style={{ gridColumn: 3 }}>{side === \"right\" ? body : null}</div>\n      </div>\n    ) : (\n      <div className=\"flex w-full\" style={{ gap: 16 }}>\n        {markerCol}\n        <div style={{ paddingTop: (s.marker - s.font * 1.4) / 2 }} className=\"min-w-0 flex-1\">\n          {body}\n        </div>\n      </div>\n    );\n\n  if (!animateOnView) return content;\n\n  return (\n    <motion.div\n      className=\"w-full\"\n      initial={{ opacity: 0, y: 14 }}\n      whileInView={{ opacity: 1, y: 0 }}\n      viewport={{ once: true, margin: \"-40px\" }}\n      transition={{ duration: 0.4, delay: Math.min(index * 0.07, 0.4), ease: [0.16, 1, 0.3, 1] }}\n    >\n      {content}\n    </motion.div>\n  );\n}\n\nexport function Timeline({ items, align = \"left\", size = \"md\", theme = \"dark\", accentColor = \"#F2A841\", lineStyle = \"solid\", animateOnView = true, width, className }: TimelineProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n\n  return (\n    <div className={cn(\"flex flex-col\", className)} style={{ width, maxWidth: \"100%\", fontFamily: \"Inter, sans-serif\" }} role=\"list\">\n      {items.map((item, i) => (\n        <div key={item.id} role=\"listitem\" style={{ paddingBottom: i === items.length - 1 ? 0 : s.gap }}>\n          <Row item={item} s={s} p={p} accent={accentColor} side={i % 2 === 0 ? \"left\" : \"right\"} align={align} showLine={i < items.length - 1} lineStyle={lineStyle} animateOnView={animateOnView} index={i} />\n        </div>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}