{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "live-bot-pointers",
  "title": "Live Bot Pointers",
  "description": "Named pointers show where each AI bot is working on a shared surface, with the area it's changing, a live list of what each one is doing, and a pause for any of them.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/live-bot-pointers/live-bot-pointers.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BotArea {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n}\n\nexport interface BotStop {\n  /** Where the pointer goes, as a percent of the surface. */\n  x: number;\n  y: number;\n  /** What the bot is doing there, e.g. \"Rewriting the intro\". */\n  action: string;\n  /** The region it works on, as percents of the surface. */\n  area?: BotArea;\n}\n\nexport interface LiveBot {\n  id: string;\n  name: string;\n  color?: string;\n  /** Milliseconds at each stop. */\n  dwell?: number;\n  stops: BotStop[];\n}\n\nexport interface LiveBotPointersProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  bots?: LiveBot[];\n  /** Your own surface. Stops are percents of it, so any layout works. */\n  children?: React.ReactNode;\n  onPauseChange?: (pausedIds: string[]) => void;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst BOT_COLORS = [\"#5E6AD2\", \"#4EA7FC\", \"#27A644\", \"#FC7840\"];\n\nconst PALETTES = {\n  dark: {\n    card: \"#0F1011\",\n    surface: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    block: \"rgba(255,255,255,0.07)\",\n    strong: \"rgba(255,255,255,0.14)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    idle: \"#62666D\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    surface: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.1)\",\n    block: \"rgba(8,9,10,0.06)\",\n    strong: \"rgba(8,9,10,0.14)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.05)\",\n    idle: \"#8A8F98\",\n  },\n};\n\nconst LOG_ROWS = 5;\nconst areaKey = (a: BotArea) => `${a.x}-${a.y}-${a.w}-${a.h}`;\n\ninterface LogEntry {\n  key: number;\n  bot: string;\n  action: string;\n}\n\nconst INTRO: BotArea = { x: 5, y: 17, w: 57, h: 17 };\nconst CHART: BotArea = { x: 5, y: 39, w: 41, h: 30 };\nconst TABLE: BotArea = { x: 50, y: 39, w: 45, h: 30 };\nconst TASKS: BotArea = { x: 67, y: 6, w: 28, h: 28 };\nconst SUMMARY: BotArea = { x: 5, y: 74, w: 90, h: 20 };\n\nconst DEFAULT_BOTS: LiveBot[] = [\n  {\n    id: \"aria\",\n    name: \"Aria\",\n    dwell: 2000,\n    stops: [\n      { x: 40, y: 26, action: \"Rewriting the intro\", area: INTRO },\n      { x: 18, y: 84, action: \"Tightening the summary\", area: SUMMARY },\n      { x: 56, y: 82, action: \"Fixing the last line\", area: SUMMARY },\n    ],\n  },\n  {\n    id: \"scout\",\n    name: \"Scout\",\n    dwell: 3000,\n    stops: [\n      { x: 26, y: 54, action: \"Checking the numbers\", area: CHART },\n      { x: 82, y: 20, action: \"Ticking off tasks\", area: TASKS },\n    ],\n  },\n  {\n    id: \"relay\",\n    name: \"Relay\",\n    dwell: 1500,\n    stops: [\n      { x: 62, y: 48, action: \"Filling in dates\", area: TABLE },\n      { x: 78, y: 56, action: \"Adding owners\", area: TABLE },\n      { x: 90, y: 62, action: \"Linking tickets\", area: TABLE },\n      { x: 66, y: 62, action: \"Checking the table\", area: TABLE },\n    ],\n  },\n];\n\nconst LINES = [100, 94, 72];\nconst BARS = [38, 62, 48, 80, 66, 92];\nconst ROWS = [0, 1, 2, 3];\n\n/** A plain document, placed by percent so the bots line up at any size. */\nfunction DefaultSurface({ c }: { c: (typeof PALETTES)[\"dark\"] }) {\n  const place = (a: BotArea): React.CSSProperties => ({\n    position: \"absolute\",\n    left: `${a.x}%`,\n    top: `${a.y}%`,\n    width: `${a.w}%`,\n    height: `${a.h}%`,\n  });\n  return (\n    <div aria-hidden=\"true\" className=\"absolute inset-0\">\n      <p\n        className=\"m-0 truncate text-[15px] leading-[22px] font-[590] tracking-[-0.014em]\"\n        style={{ ...place({ x: 6, y: 6, w: 56, h: 8 }), color: c.text }}\n      >\n        Launch brief\n      </p>\n      <div\n        className=\"flex flex-col justify-center gap-[9%] px-[2%]\"\n        style={place(INTRO)}\n      >\n        {LINES.map((w) => (\n          <span\n            key={w}\n            className=\"block h-1.5 rounded-full\"\n            style={{ width: `${w}%`, background: c.block }}\n          />\n        ))}\n      </div>\n      <div\n        className=\"flex items-end gap-[5%] px-[3%] py-[3%]\"\n        style={place(CHART)}\n      >\n        {BARS.map((h) => (\n          <span\n            key={h}\n            className=\"block flex-1 rounded-[2px]\"\n            style={{ height: `${h}%`, background: c.strong }}\n          />\n        ))}\n      </div>\n      <div\n        className=\"flex flex-col justify-around px-[3%] py-[2%]\"\n        style={place(TABLE)}\n      >\n        {ROWS.map((r) => (\n          <span key={r} className=\"flex gap-[6%]\">\n            <span\n              className=\"block h-1.5 flex-[3] rounded-full\"\n              style={{ background: c.strong }}\n            />\n            <span\n              className=\"block h-1.5 flex-[2] rounded-full\"\n              style={{ background: c.block }}\n            />\n            <span\n              className=\"block h-1.5 flex-[2] rounded-full\"\n              style={{ background: c.block }}\n            />\n          </span>\n        ))}\n      </div>\n      <div\n        className=\"flex flex-col justify-around px-[5%] py-[3%]\"\n        style={place(TASKS)}\n      >\n        {[0, 1, 2].map((r) => (\n          <span key={r} className=\"flex items-center gap-[8%]\">\n            <span\n              className=\"block size-2.5 shrink-0 rounded-[3px]\"\n              style={{ background: c.strong }}\n            />\n            <span\n              className=\"block h-1.5 flex-1 rounded-full\"\n              style={{ background: c.block }}\n            />\n          </span>\n        ))}\n      </div>\n      <div\n        className=\"flex flex-col justify-center gap-[10%] px-[1.5%]\"\n        style={place(SUMMARY)}\n      >\n        {[98, 88, 54].map((w) => (\n          <span\n            key={w}\n            className=\"block h-1.5 rounded-full\"\n            style={{ width: `${w}%`, background: c.block }}\n          />\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\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\n        cx={r}\n        cy={r}\n        r={r}\n        className=\"motion-safe:transition-[fill] motion-safe:duration-200\"\n        style={{ fill: color }}\n      />\n    </svg>\n  );\n}\n\nexport function LiveBotPointers({\n  theme = \"dark\",\n  title = \"Three bots on this document\",\n  bots = DEFAULT_BOTS,\n  children,\n  onPauseChange,\n  className,\n  style,\n  ...rest\n}: LiveBotPointersProps) {\n  const c = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLElement>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [stops, setStops] = React.useState<number[]>(() => bots.map(() => 0));\n  const [paused, setPaused] = React.useState<string[]>([]);\n  const [log, setLog] = React.useState<LogEntry[]>(() =>\n    bots.map((b, i) => ({\n      key: i,\n      bot: b.name,\n      action: b.stops[0]?.action ?? \"\",\n    })),\n  );\n  const walked = React.useRef<number[]>(bots.map(() => 0));\n  const logKey = React.useRef(bots.length);\n  const allPaused = bots.every((b) => paused.includes(b.id));\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      ([entry]) => setVisible(entry.isIntersecting),\n      { threshold: 0.2 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  // Each bot walks its own stops on its own clock, and only while the card can be seen.\n  React.useEffect(() => {\n    if (!visible || reduce) return;\n    const timers: number[] = [];\n    bots.forEach((bot, i) => {\n      if (paused.includes(bot.id) || bot.stops.length < 2) return;\n      timers.push(\n        window.setInterval(() => {\n          const at = ((walked.current[i] ?? 0) + 1) % bot.stops.length;\n          walked.current[i] = at;\n          setStops([...walked.current]);\n          logKey.current += 1;\n          const entry = {\n            key: logKey.current,\n            bot: bot.name,\n            action: bot.stops[at].action,\n          };\n          setLog((prev) => [entry, ...prev].slice(0, LOG_ROWS));\n        }, bot.dwell ?? 2000),\n      );\n    });\n    return () => timers.forEach((t) => window.clearInterval(t));\n  }, [bots, paused, reduce, visible]);\n\n  const update = (next: string[]) => {\n    setPaused(next);\n    onPauseChange?.(next);\n  };\n\n  const toggle = (id: string) => {\n    update(\n      paused.includes(id) ? paused.filter((p) => p !== id) : [...paused, id],\n    );\n  };\n\n  const working = bots.length - paused.length;\n\n  return (\n    <section\n      ref={rootRef}\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      <header className=\"flex items-start justify-between gap-4 p-5 pb-4 @2xl:px-6\">\n        <div className=\"min-w-0\">\n          <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.018em]\">\n            {title}\n          </h3>\n          <p\n            aria-live=\"polite\"\n            className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em] tabular-nums\"\n            style={{ color: c.sub }}\n          >\n            {working === 0 ? \"Everyone is paused\" : `${working} working now`}\n          </p>\n        </div>\n        <button\n          type=\"button\"\n          data-all=\"\"\n          onClick={() => update(allPaused ? [] : bots.map((b) => b.id))}\n          className={`h-8 w-[92px] shrink-0 cursor-pointer rounded-full border-0 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] ${RING}`}\n          style={{ background: c.chip, color: c.soft }}\n        >\n          {allPaused ? \"Resume all\" : \"Pause all\"}\n        </button>\n      </header>\n\n      <div\n        className=\"grid border-t @2xl:grid-cols-[minmax(0,1fr)_248px]\"\n        style={{ borderColor: c.border }}\n      >\n        <div className=\"p-4 @2xl:p-5\">\n          <div\n            role=\"img\"\n            aria-label={`${title}. ${bots\n              .map(\n                (b, i) => `${b.name}: ${b.stops[stops[i] ?? 0]?.action ?? \"\"}`,\n              )\n              .join(\". \")}.`}\n            className=\"relative aspect-[4/3] w-full overflow-hidden rounded-xl border\"\n            style={{ background: c.surface, borderColor: c.border }}\n          >\n            {children ?? <DefaultSurface c={c} />}\n\n            {/* Every area stays mounted and fades, so a highlight never slides across other blocks. */}\n            {bots.map((bot, i) => {\n              const current = bot.stops[stops[i] ?? 0]?.area;\n              const color = bot.color ?? BOT_COLORS[i % BOT_COLORS.length];\n              const off = paused.includes(bot.id);\n              const areas = new Map(\n                bot.stops.flatMap((stop) =>\n                  stop.area ? [[areaKey(stop.area), stop.area] as const] : [],\n                ),\n              );\n              return [...areas].map(([key, area]) => (\n                <span\n                  key={`${bot.id}-${key}`}\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute rounded-md border motion-safe:transition-[opacity,border-color,background-color] motion-safe:duration-300\"\n                  style={{\n                    left: `${area.x}%`,\n                    top: `${area.y}%`,\n                    width: `${area.w}%`,\n                    height: `${area.h}%`,\n                    opacity: current && areaKey(current) === key ? 1 : 0,\n                    borderColor: off ? c.strong : color,\n                    background: off ? \"transparent\" : `${color}14`,\n                  }}\n                />\n              ));\n            })}\n\n            {bots.map((bot, i) => {\n              const stop = bot.stops[stops[i] ?? 0];\n              if (!stop) return null;\n              const off = paused.includes(bot.id);\n              const color = off\n                ? c.idle\n                : (bot.color ?? BOT_COLORS[i % BOT_COLORS.length]);\n              return (\n                // A full-size layer moves by percents of itself, which are percents of the surface.\n                <span\n                  key={bot.id}\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute inset-0 motion-safe:transition-transform motion-safe:duration-700 motion-safe:ease-[cubic-bezier(0.22,1,0.36,1)]\"\n                  style={{ transform: `translate(${stop.x}%, ${stop.y}%)` }}\n                >\n                  <span className=\"absolute top-0 left-0 size-0\">\n                    <svg\n                      width=\"16\"\n                      height=\"18\"\n                      viewBox=\"0 0 16 18\"\n                      className=\"absolute top-0 left-0 block\"\n                    >\n                      <path\n                        d=\"M1 1v14l4-3.6 2.6 5.6 2.6-1.2-2.6-5.4H13L1 1Z\"\n                        fill={color}\n                        stroke={c.card}\n                        strokeWidth=\"1\"\n                        strokeLinejoin=\"round\"\n                      />\n                    </svg>\n                    <span\n                      className={`absolute top-[16px] rounded-full px-2 py-px text-[11.5px] leading-[16px] font-[510] tracking-[-0.005em] whitespace-nowrap motion-safe:transition-colors motion-safe:duration-200 ${stop.x > 72 ? \"right-[-6px]\" : \"left-[10px]\"}`}\n                      style={{ background: color, color: \"#FFFFFF\" }}\n                    >\n                      {bot.name}\n                    </span>\n                  </span>\n                </span>\n              );\n            })}\n          </div>\n        </div>\n\n        <div\n          className=\"flex flex-col border-t p-3 @2xl:border-t-0 @2xl:border-l @2xl:p-4\"\n          style={{ borderColor: c.border }}\n        >\n          <ul className=\"m-0 list-none p-0\">\n            {bots.map((bot, i) => {\n              const off = paused.includes(bot.id);\n              const color = bot.color ?? BOT_COLORS[i % BOT_COLORS.length];\n              return (\n                <li key={bot.id}>\n                  <button\n                    type=\"button\"\n                    data-bot={bot.id}\n                    aria-pressed={off}\n                    onClick={() => toggle(bot.id)}\n                    className={`flex w-full cursor-pointer items-center gap-2.5 rounded-lg border-0 bg-transparent px-2.5 py-2 text-left ${RING}`}\n                  >\n                    <Dot size={8} color={off ? c.idle : color} />\n                    <span className=\"min-w-0 flex-1\">\n                      <span\n                        className=\"block truncate text-[13.5px] leading-[20px] font-[510] tracking-[-0.011em]\"\n                        style={{ color: off ? c.sub : c.text }}\n                      >\n                        {bot.name}\n                      </span>\n                      <span\n                        className=\"block truncate text-[12px] leading-[16px] tracking-[-0.005em]\"\n                        style={{ color: c.faint }}\n                      >\n                        {off\n                          ? \"Paused\"\n                          : (bot.stops[stops[i] ?? 0]?.action ?? \"Waiting\")}\n                      </span>\n                    </span>\n                    <span\n                      className=\"shrink-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n                      style={{ color: c.sub }}\n                    >\n                      {off ? \"Resume\" : \"Pause\"}\n                    </span>\n                  </button>\n                </li>\n              );\n            })}\n          </ul>\n          {/* Wide cards have room for what just happened. */}\n          <div\n            className=\"mt-auto hidden border-t px-2.5 pt-3 @2xl:block\"\n            style={{ borderColor: c.border }}\n          >\n            <p\n              className=\"m-0 text-[12px] leading-[16px] tracking-[-0.005em]\"\n              style={{ color: c.faint }}\n            >\n              Just now\n            </p>\n            <ol\n              className=\"m-0 mt-1.5 list-none p-0\"\n              style={{ height: LOG_ROWS * 24 }}\n            >\n              {log.map((entry) => (\n                <li\n                  key={entry.key}\n                  className=\"truncate text-[12.5px] leading-[24px] tracking-[-0.008em]\"\n                  style={{ color: c.sub }}\n                >\n                  <span style={{ color: c.soft }}>{entry.bot}</span>{\" \"}\n                  {entry.action.toLowerCase()}\n                </li>\n              ))}\n            </ol>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}