{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "task-relay-card",
  "title": "Task Relay Card",
  "description": "Follow a task as it passes between bots and people: who has it now, what each one did, and the note they left for the next.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/task-relay-card/task-relay-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface RelayLeg {\n  id: string;\n  runner: string;\n  /** \"Bot\" or \"Person\", or a short role. */\n  role: string;\n  /** Time spent on this leg, in minutes. */\n  minutes: number;\n  /** What they did. */\n  done: string;\n  /** What they're passing on. */\n  handover: string;\n  /** Things that travel with the task. */\n  items?: string[];\n}\n\nexport interface TaskRelayCardProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  /** In running order. */\n  legs?: RelayLeg[];\n  /** Which leg holds the task at the start, from 0. */\n  defaultHolder?: number;\n  onPass?: (from: RelayLeg, to: RelayLeg) => void;\n  onTakeBack?: (to: RelayLeg) => void;\n  onFinish?: () => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst GREEN = \"#27A644\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst TRACK_H = 104;\nconst LINE_Y = 44;\nconst NODE_R = 15;\nconst EDGE = 44;\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    node: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    track: \"rgba(255,255,255,0.1)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    node: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.08)\",\n    track: \"rgba(8,9,10,0.12)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n  },\n};\n\nconst DEFAULT_LEGS: RelayLeg[] = [\n  {\n    id: \"scout\",\n    runner: \"Scout\",\n    role: \"Bot\",\n    minutes: 12,\n    done: \"Read 214 refund tickets and grouped them into five reasons.\",\n    handover:\n      \"Damaged items are the biggest group. Start the new policy there.\",\n    items: [\"Ticket summary\", \"Five reasons\"],\n  },\n  {\n    id: \"aria\",\n    runner: \"Aria\",\n    role: \"Bot\",\n    minutes: 26,\n    done: \"Drafted the new refund policy and a short customer email.\",\n    handover: \"Section 3 changes the time limit, so it needs a legal check.\",\n    items: [\"Policy draft\", \"Customer email\"],\n  },\n  {\n    id: \"mira\",\n    runner: \"Mira\",\n    role: \"Legal\",\n    minutes: 74,\n    done: \"Approved the policy and rewrote the section on time limits.\",\n    handover: \"Good to publish. The new wording has to go live with the email.\",\n    items: [\"Approved draft\"],\n  },\n  {\n    id: \"you\",\n    runner: \"You\",\n    role: \"Support lead\",\n    minutes: 9,\n    done: \"Published the policy and scheduled the customer email.\",\n    handover: \"Nothing left to pass on.\",\n    items: [\"Live policy\"],\n  },\n];\n\nconst clock = (minutes: number) => {\n  const h = Math.floor(minutes / 60);\n  const m = minutes % 60;\n  return h ? `${h}h ${m}m` : `${m}m`;\n};\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\nfunction useWidth<T extends HTMLElement>(fallback: number) {\n  const ref = React.useRef<T>(null);\n  const [width, setWidth] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      setWidth(Math.round(entry.contentRect.width));\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, width] as const;\n}\n\nexport function TaskRelayCard({\n  theme = \"dark\",\n  title = \"Update the refund policy\",\n  legs = DEFAULT_LEGS,\n  defaultHolder = 1,\n  onPass,\n  onTakeBack,\n  onFinish,\n  className,\n  style,\n  ...rest\n}: TaskRelayCardProps) {\n  const c = PALETTES[theme];\n  const last = legs.length - 1;\n  const [holder, setHolder] = React.useState(defaultHolder);\n  const [finished, setFinished] = React.useState(false);\n  const [trackRef, width] = useWidth<HTMLDivElement>(620);\n\n  const x = (i: number) =>\n    Math.round(EDGE + (last > 0 ? i / last : 0) * (width - EDGE * 2));\n  const progress = last > 0 ? holder / last : 0;\n  const reached = finished ? legs.length : holder + 1;\n  const spent = legs.slice(0, reached).reduce((sum, l) => sum + l.minutes, 0);\n  const current = legs[holder];\n  const next = legs[holder + 1];\n\n  const pass = () => {\n    if (next) {\n      setHolder(holder + 1);\n      onPass?.(current, next);\n    } else {\n      setFinished(true);\n      onFinish?.();\n    }\n  };\n\n  const takeBack = () => {\n    if (finished) {\n      setFinished(false);\n      return;\n    }\n    if (holder > 0) {\n      setHolder(holder - 1);\n      onTakeBack?.(legs[holder - 1]);\n    }\n  };\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-2 @xl:p-6 @xl:pb-2\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              aria-live=\"polite\"\n              className=\"m-0 mt-1 flex items-center gap-2 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              <Dot size={8} color={finished ? GREEN : ACCENT} />\n              {finished ? \"Finished\" : `With ${current?.runner} now`}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\">\n              {clock(spent)}\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px]\"\n              style={{ color: c.sub }}\n            >\n              Time so far\n            </p>\n          </div>\n        </div>\n\n        {/* Everything on the track is SVG with explicit coordinates, so it can't fall out of line. */}\n        <div ref={trackRef} className=\"mt-2 w-full\" style={{ height: TRACK_H }}>\n          <svg\n            role=\"img\"\n            aria-label={`Relay: ${legs.map((l) => l.runner).join(\", then \")}.`}\n            width={width}\n            height={TRACK_H}\n            className=\"block\"\n          >\n            <line\n              x1={x(0)}\n              x2={x(last)}\n              y1={LINE_Y}\n              y2={LINE_Y}\n              stroke={c.track}\n              strokeWidth=\"1.5\"\n            />\n            <line\n              x1={x(0)}\n              x2={x(last)}\n              y1={LINE_Y}\n              y2={LINE_Y}\n              pathLength={1}\n              stroke={ACCENT}\n              strokeWidth=\"1.5\"\n              strokeDasharray=\"1 1\"\n              strokeDashoffset={1 - progress}\n              className=\"motion-safe:transition-[stroke-dashoffset] motion-safe:duration-500\"\n            />\n            {legs.slice(0, last).map((l, i) => (\n              <text\n                key={l.id}\n                x={Math.round((x(i) + x(i + 1)) / 2)}\n                y={LINE_Y - 10}\n                textAnchor=\"middle\"\n                fontSize=\"11\"\n                fill={i < holder ? c.sub : c.faint}\n                style={{ fontVariantNumeric: \"tabular-nums\" }}\n              >\n                {clock(l.minutes)}\n              </text>\n            ))}\n            {legs.map((l, i) => {\n              const past = i < holder || finished;\n              const now = i === holder && !finished;\n              return (\n                <g key={l.id}>\n                  <circle\n                    cx={x(i)}\n                    cy={LINE_Y}\n                    r={NODE_R}\n                    fill={past ? ACCENT : c.node}\n                    stroke={past ? ACCENT : c.border}\n                    className=\"motion-safe:transition-[fill,stroke] motion-safe:duration-300\"\n                  />\n                  <text\n                    x={x(i)}\n                    y={LINE_Y + 4}\n                    textAnchor=\"middle\"\n                    fontSize=\"12\"\n                    fontWeight=\"590\"\n                    fill={past ? \"#FFFFFF\" : now ? c.text : c.faint}\n                  >\n                    {l.runner.slice(0, 1)}\n                  </text>\n                  <text\n                    x={x(i)}\n                    y={LINE_Y + NODE_R + 18}\n                    textAnchor=\"middle\"\n                    fontSize=\"12\"\n                    fontWeight=\"510\"\n                    fill={now ? c.text : c.sub}\n                  >\n                    {l.runner}\n                  </text>\n                  <text\n                    x={x(i)}\n                    y={LINE_Y + NODE_R + 33}\n                    textAnchor=\"middle\"\n                    fontSize=\"11\"\n                    fill={c.faint}\n                  >\n                    {l.role}\n                  </text>\n                </g>\n              );\n            })}\n            {/* The baton: one ring that travels from runner to runner. */}\n            <g\n              className=\"motion-safe:transition-transform motion-safe:duration-500 motion-safe:ease-[cubic-bezier(0.22,1,0.36,1)]\"\n              style={{ transform: `translate(${x(holder)}px, ${LINE_Y}px)` }}\n            >\n              <circle\n                r={NODE_R + 4}\n                fill=\"none\"\n                stroke={finished ? GREEN : ACCENT}\n                strokeWidth=\"1.5\"\n              />\n            </g>\n          </svg>\n        </div>\n      </div>\n\n      {/* Every leg shares one cell, so passing the task never changes the card's height. */}\n      <div\n        className=\"grid border-t p-5 @xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        {legs.map((l, i) => {\n          const on = i === holder;\n          const after = legs[i + 1];\n          return (\n            <article\n              key={l.id}\n              aria-hidden={!on}\n              className={`grid min-w-0 gap-x-8 gap-y-3 [grid-area:1/1] motion-safe:transition-opacity motion-safe:duration-200 @xl:grid-cols-2 ${on ? \"visible opacity-100\" : \"invisible opacity-0\"}`}\n            >\n              <div className=\"min-w-0\">\n                <p\n                  className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: c.faint }}\n                >\n                  {l.runner} did\n                </p>\n                <p\n                  className=\"m-0 mt-1 text-[13.5px] leading-[20px] tracking-[-0.011em]\"\n                  style={{ color: c.soft }}\n                >\n                  {l.done}\n                </p>\n              </div>\n              <div className=\"min-w-0\">\n                <p\n                  className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: c.faint }}\n                >\n                  {after ? `Note for ${after.runner}` : \"Last leg\"}\n                </p>\n                <p\n                  className=\"m-0 mt-1 text-[13.5px] leading-[20px] tracking-[-0.011em]\"\n                  style={{ color: c.soft }}\n                >\n                  {l.handover}\n                </p>\n              </div>\n              <div className=\"flex flex-wrap gap-1.5 @xl:col-span-2\">\n                {l.items?.map((item) => (\n                  <span\n                    key={item}\n                    className=\"flex h-7 items-center rounded-full px-3 text-[12.5px] leading-[18px] tracking-[-0.008em]\"\n                    style={{ background: c.chip, color: c.sub }}\n                  >\n                    {item}\n                  </span>\n                ))}\n              </div>\n            </article>\n          );\n        })}\n      </div>\n\n      <footer\n        className=\"flex items-center justify-end gap-2 border-t px-5 py-3.5 @xl:px-6\"\n        style={{ borderColor: c.border }}\n      >\n        <button\n          type=\"button\"\n          data-back=\"\"\n          disabled={holder === 0 && !finished}\n          onClick={takeBack}\n          className={`h-9 flex-1 cursor-pointer rounded-full border-0 px-4 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] disabled:cursor-default @xl:flex-none ${RING}`}\n          style={{\n            background: c.chip,\n            color: holder === 0 && !finished ? c.faint : c.soft,\n          }}\n        >\n          {finished ? \"Reopen\" : \"Take it back\"}\n        </button>\n        <button\n          type=\"button\"\n          data-pass=\"\"\n          disabled={finished}\n          onClick={pass}\n          className={`h-9 flex-1 cursor-pointer rounded-full border-0 px-4 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] disabled:cursor-default @xl:w-[148px] @xl:flex-none ${RING}`}\n          style={{\n            background: finished ? c.chip : c.btn,\n            color: finished ? c.faint : c.btnText,\n          }}\n        >\n          {finished\n            ? \"Finished\"\n            : next\n              ? `Pass to ${next.runner}`\n              : \"Finish task\"}\n        </button>\n      </footer>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}