{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "organization-chart",
  "title": "Organization Chart",
  "description": "An org chart of people cards joined by rounded connector lines: teams open and close from a count chip under each manager, and picking someone lights up their reporting line all the way to the top.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/organization-chart/organization-chart.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } 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 interface OrgNode {\n  id: string;\n  name: string;\n  title?: string;\n  /** Photo URL; initials are used when it's missing. */\n  image?: string;\n  children?: OrgNode[];\n}\n\nexport interface OrganizationChartProps {\n  data?: OrgNode;\n  /** Levels open at first (0 = only the top person). */\n  defaultDepth?: number;\n  /** Called when a person is picked; their chain up to the top is highlighted. */\n  onSelect?: (node: OrgNode) => void;\n  defaultSelected?: string;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", card: \"#131313\", border: \"rgba(255,255,255,0.1)\", borderOn: \"#F5F4F1\", line: \"rgba(255,255,255,0.16)\", lineOn: \"rgba(245,244,241,0.8)\", avatar: \"rgba(255,255,255,0.08)\", chip: \"#1C1C1C\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", card: \"#FFFFFF\", border: \"rgba(10,10,10,0.12)\", borderOn: \"#0A0A0A\", line: \"rgba(10,10,10,0.18)\", lineOn: \"rgba(10,10,10,0.75)\", avatar: \"rgba(10,10,10,0.06)\", chip: \"#FFFFFF\", focus: \"rgba(10,10,10,0.85)\" },\n};\n\nconst DEFAULT_DATA: OrgNode = {\n  id: \"maya\",\n  name: \"Maya Chen\",\n  title: \"CEO\",\n  children: [\n    {\n      id: \"leo\",\n      name: \"Leo Fischer\",\n      title: \"VP Engineering\",\n      children: [\n        { id: \"amara\", name: \"Amara Okafor\", title: \"Platform lead\", children: [{ id: \"jun\", name: \"Jun Park\", title: \"Engineer\" }, { id: \"sofia\", name: \"Sofia Rossi\", title: \"Engineer\" }] },\n        { id: \"noah\", name: \"Noah Berg\", title: \"Mobile lead\" },\n      ],\n    },\n    { id: \"iris\", name: \"Iris Novak\", title: \"VP Design\", children: [{ id: \"tom\", name: \"Tom Silva\", title: \"Product designer\" }, { id: \"lena\", name: \"Lena Moreau\", title: \"Brand designer\" }] },\n    { id: \"omar\", name: \"Omar Haddad\", title: \"VP Sales\", children: [{ id: \"ella\", name: \"Ella Smith\", title: \"Account executive\" }] },\n  ],\n};\n\nconst initials = (name: string) =>\n  name\n    .split(/\\s+/)\n    .map((w) => w[0])\n    .slice(0, 2)\n    .join(\"\")\n    .toUpperCase();\n\nfunction pathTo(node: OrgNode, id: string, trail: string[] = []): string[] | null {\n  const here = [...trail, node.id];\n  if (node.id === id) return here;\n  for (const c of node.children ?? []) {\n    const found = pathTo(c, id, here);\n    if (found) return found;\n  }\n  return null;\n}\n\nfunction collectOpen(node: OrgNode, depth: number, out: Set<string>) {\n  if (depth <= 0 || !node.children?.length) return out;\n  out.add(node.id);\n  node.children.forEach((c) => collectOpen(c, depth - 1, out));\n  return out;\n}\n\nconst V = 22; // height of each connector drop\nconst GAP = 20; // space between sibling subtrees; the connector bar spans it\n\nexport function OrganizationChart({ data = DEFAULT_DATA, defaultDepth = 2, onSelect, defaultSelected, theme = \"dark\", className }: OrganizationChartProps) {\n  const p = PALETTES[theme];\n  const reduce = Boolean(useReducedMotion());\n  const [open, setOpen] = React.useState<Set<string>>(() => collectOpen(data, defaultDepth, new Set()));\n  const [selected, setSelected] = React.useState<string | null>(defaultSelected ?? null);\n  const chain = React.useMemo(() => new Set(selected ? (pathTo(data, selected) ?? []) : []), [data, selected]);\n\n  const toggle = (id: string) =>\n    setOpen((prev) => {\n      const next = new Set(prev);\n      if (next.has(id)) next.delete(id);\n      else next.add(id);\n      return next;\n    });\n\n  const renderNode = (node: OrgNode, depth: number): React.ReactNode => {\n    const kids = node.children ?? [];\n    const isOpen = open.has(node.id) && kids.length > 0;\n    const on = chain.has(node.id);\n    const isSel = selected === node.id;\n    return (\n      <div className=\"flex flex-col items-center\">\n        <div className=\"relative flex flex-col items-center\">\n          <button\n            type=\"button\"\n            onClick={() => {\n              setSelected(isSel ? null : node.id);\n              if (!isSel) onSelect?.(node);\n            }}\n            aria-pressed={isSel}\n            className=\"flex cursor-pointer items-center rounded-2xl text-left outline-none focus-visible:ring-2\"\n            style={{ gap: 10, width: 188, padding: \"10px 12px\", background: p.card, border: `1px solid ${isSel ? p.borderOn : on ? p.lineOn : p.border}`, boxShadow: isSel ? `0 0 0 3px color-mix(in srgb, ${p.borderOn} 14%, transparent)` : \"none\", transition: \"border-color 0.2s ease, box-shadow 0.2s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n          >\n            <span className=\"flex shrink-0 items-center justify-center overflow-hidden rounded-full text-[12px] font-semibold\" style={{ width: 34, height: 34, background: p.avatar, color: p.text }}>\n              {node.image ? (\n                // eslint-disable-next-line @next/next/no-img-element\n                <img src={node.image} alt=\"\" className=\"h-full w-full object-cover\" />\n              ) : (\n                initials(node.name)\n              )}\n            </span>\n            <span className=\"flex min-w-0 flex-col\">\n              <span className=\"truncate text-[13.5px] font-semibold\" style={{ color: p.text }}>\n                {node.name}\n              </span>\n              {node.title && (\n                <span className=\"truncate text-[12px]\" style={{ color: p.muted }}>\n                  {node.title}\n                </span>\n              )}\n            </span>\n          </button>\n          {kids.length > 0 && (\n            <button\n              type=\"button\"\n              onClick={() => toggle(node.id)}\n              aria-expanded={isOpen}\n              aria-label={`${isOpen ? \"Hide\" : \"Show\"} ${kids.length} ${kids.length === 1 ? \"report\" : \"reports\"} of ${node.name}`}\n              className=\"absolute -bottom-[11px] z-10 flex cursor-pointer items-center justify-center rounded-full text-[11px] font-semibold tabular-nums outline-none focus-visible:ring-2\"\n              style={{ minWidth: 22, height: 22, padding: \"0 6px\", gap: 3, background: p.chip, border: `1px solid ${isOpen ? p.line : p.border}`, color: p.muted, [\"--tw-ring-color\" as string]: p.focus }}\n            >\n              {isOpen ? (\n                <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" aria-hidden=\"true\">\n                  <path d=\"M6 12h12\" />\n                </svg>\n              ) : (\n                kids.length\n              )}\n            </button>\n          )}\n        </div>\n\n        <AnimatePresence initial={false}>\n          {isOpen && (\n            <motion.div key=\"kids\" className=\"flex flex-col items-center\" initial={{ opacity: 0, y: -10 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -10, transition: { duration: reduce ? 0 : 0.15 } }} transition={{ duration: reduce ? 0 : 0.28, ease: [0.22, 1, 0.36, 1] }}>\n              {/* Drop from the parent to the bar. */}\n              <motion.span aria-hidden=\"true\" className=\"block origin-top\" style={{ width: 1, height: V, background: kids.some((k) => chain.has(k.id)) ? p.lineOn : p.line }} initial={{ scaleY: 0 }} animate={{ scaleY: 1 }} transition={{ duration: reduce ? 0 : 0.2 }} />\n              <div className=\"flex items-start\" style={{ gap: GAP }} role=\"group\" aria-label={`Reports of ${node.name}`}>\n                {kids.map((kid, i) => {\n                  const first = i === 0;\n                  const last = i === kids.length - 1;\n                  const lit = chain.has(kid.id);\n                  const line = (onPath: boolean) => (onPath ? p.lineOn : p.line);\n                  return (\n                    <div key={kid.id} className=\"relative flex flex-col items-center\" style={{ paddingTop: V }}>\n                      {/* Bar halves to the siblings on each side, with rounded elbows at the ends. */}\n                      {kids.length > 1 && !first && <span aria-hidden=\"true\" className=\"absolute top-0\" style={{ left: -GAP / 2, width: `calc(50% + ${GAP / 2}px)`, height: V, borderTop: `1px solid ${line(false)}`, borderRight: last ? `1px solid ${line(lit)}` : undefined, borderTopRightRadius: last ? 12 : 0 }} />}\n                      {kids.length > 1 && !last && <span aria-hidden=\"true\" className=\"absolute top-0\" style={{ right: -GAP / 2, width: `calc(50% + ${GAP / 2}px)`, height: V, borderTop: `1px solid ${line(false)}`, borderLeft: first ? `1px solid ${line(lit)}` : undefined, borderTopLeftRadius: first ? 12 : 0 }} />}\n                      {(kids.length === 1 || (!first && !last)) && <span aria-hidden=\"true\" className=\"absolute top-0 left-1/2\" style={{ width: 1, height: V, background: line(lit) }} />}\n                      {renderNode(kid, depth + 1)}\n                    </div>\n                  );\n                })}\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    );\n  };\n\n  return (\n    <div className={cn(\"w-full overflow-x-auto\", className)} style={{ fontFamily: \"Inter, sans-serif\", padding: \"4px 0 16px\" }} role=\"region\" aria-label={`Organization chart for ${data.name}`}>\n      <div className=\"mx-auto w-max px-2\">{renderNode(data, 0)}</div>\n    </div>\n  );\n}\n\nexport default OrganizationChart;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}