{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "issue-tracker",
  "type": "registry:block",
  "title": "Issue Tracker",
  "description": "An issue list you drive with your hands on the keys: J and K to move, S, P, A and L to change status, priority, assignee and labels, X to multi-select, ⌘K for everything else, and rows glide to their new group when they change.",
  "categories": [
    "screen",
    "Dev"
  ],
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/kbd.json"
  ],
  "files": [
    {
      "path": "registry/devl/issue-tracker.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, MotionConfig, motion } from \"motion/react\";\nimport {\n  ArrowLeftIcon,\n  CheckIcon,\n  ChevronDownIcon,\n  CircleDotIcon,\n  CopyIcon,\n  CornerDownLeftIcon,\n  ArchiveIcon,\n  CalendarIcon,\n  LayersIcon,\n  ListFilterIcon,\n  type LucideIcon,\n  MenuIcon,\n  PlusIcon,\n  SearchIcon,\n  TagIcon,\n  Trash2Icon,\n  UserRoundIcon,\n  XIcon,\n} from \"lucide-react\";\nimport {\n  type KeyboardEvent,\n  type ReactNode,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Button } from \"@/components/ui/button\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport { cn } from \"@/lib/utils\";\n\nexport type IssueStatus = \"backlog\" | \"todo\" | \"in_progress\" | \"in_review\" | \"done\";\nexport type IssuePriority = 0 | 1 | 2 | 3 | 4;\nexport type IssueTone = \"blue\" | \"orange\" | \"teal\" | \"violet\" | \"rose\" | \"amber\" | \"emerald\" | \"sky\";\n\nexport interface IssuePerson {\n  id: string;\n  name: string;\n  tone: IssueTone;\n}\n\nexport interface IssueLabel {\n  id: string;\n  name: string;\n  tone: IssueTone;\n}\n\nexport interface IssueActivity {\n  who: string;\n  text: string;\n  when: string;\n  comment?: boolean;\n}\n\nexport interface Issue {\n  id: string;\n  title: string;\n  status: IssueStatus;\n  priority: IssuePriority;\n  assignee?: string;\n  labels?: string[];\n  estimate?: number;\n  due?: string;\n  created: string;\n  description?: string[];\n  subtasks?: { title: string; done: boolean }[];\n  activity?: IssueActivity[];\n}\n\nexport interface IssueTrackerProps {\n  team?: { name: string; key: string };\n  me?: string;\n  people?: IssuePerson[];\n  labels?: IssueLabel[];\n  issues?: Issue[];\n  className?: string;\n}\n\nconst avatarTone: Record<IssueTone, string> = {\n  blue: \"bg-blue-500/14 text-blue-700 dark:text-blue-300\",\n  orange: \"bg-orange-500/14 text-orange-700 dark:text-orange-300\",\n  teal: \"bg-teal-500/16 text-teal-700 dark:text-teal-300\",\n  violet: \"bg-violet-500/16 text-violet-700 dark:text-violet-300\",\n  rose: \"bg-rose-500/14 text-rose-700 dark:text-rose-300\",\n  amber: \"bg-amber-500/18 text-amber-800 dark:text-amber-300\",\n  emerald: \"bg-emerald-500/16 text-emerald-700 dark:text-emerald-300\",\n  sky: \"bg-sky-500/16 text-sky-700 dark:text-sky-300\",\n};\n\nconst dotTone: Record<IssueTone, string> = {\n  blue: \"bg-blue-500\",\n  orange: \"bg-orange-500\",\n  teal: \"bg-teal-500\",\n  violet: \"bg-violet-500\",\n  rose: \"bg-rose-500\",\n  amber: \"bg-amber-500\",\n  emerald: \"bg-emerald-500\",\n  sky: \"bg-sky-500\",\n};\n\nconst ease = [0.23, 1, 0.32, 1] as const;\nconst glide = { type: \"spring\", stiffness: 500, damping: 44 } as const;\n\nconst groupTone: Record<IssueStatus, string> = {\n  backlog: \"from-muted/80 to-muted/80 dark:from-muted/60 dark:to-muted/60\",\n  todo: \"from-muted/80 to-muted/80 dark:from-muted/60 dark:to-muted/60\",\n  in_progress: \"from-amber-500/6 to-amber-500/6 dark:from-amber-400/7 dark:to-amber-400/7\",\n  in_review: \"from-emerald-500/6 to-emerald-500/6 dark:from-emerald-400/7 dark:to-emerald-400/7\",\n  done: \"from-blue-500/6 to-blue-500/6 dark:from-blue-400/7 dark:to-blue-400/7\",\n};\n\nconst STATUSES: { id: IssueStatus; label: string }[] = [\n  { id: \"in_progress\", label: \"In Progress\" },\n  { id: \"in_review\", label: \"In Review\" },\n  { id: \"todo\", label: \"Todo\" },\n  { id: \"backlog\", label: \"Backlog\" },\n  { id: \"done\", label: \"Done\" },\n];\nconst statusLabel = (s: IssueStatus) => STATUSES.find((x) => x.id === s)?.label ?? s;\n\nconst PRIORITIES: { id: IssuePriority; label: string }[] = [\n  { id: 1, label: \"Urgent\" },\n  { id: 2, label: \"High\" },\n  { id: 3, label: \"Medium\" },\n  { id: 4, label: \"Low\" },\n  { id: 0, label: \"No priority\" },\n];\nconst priorityLabel = (p: IssuePriority) => PRIORITIES.find((x) => x.id === p)?.label ?? \"\";\n\nconst initials = (name: string) =>\n  name\n    .split(\" \")\n    .map((p) => p[0])\n    .slice(0, 2)\n    .join(\"\")\n    .toUpperCase();\n\nfunction StatusIcon({ status, className }: { status: IssueStatus; className?: string }) {\n  const c = cn(\"size-3.5 shrink-0\", className);\n  if (status === \"backlog\")\n    return (\n      <svg aria-hidden className={cn(c, \"text-muted-foreground\")} viewBox=\"0 0 14 14\">\n        <circle cx=\"7\" cy=\"7\" fill=\"none\" r=\"5.5\" stroke=\"currentColor\" strokeDasharray=\"2.2 1.8\" strokeWidth=\"1.5\" />\n      </svg>\n    );\n  if (status === \"todo\")\n    return (\n      <svg aria-hidden className={cn(c, \"text-muted-foreground\")} viewBox=\"0 0 14 14\">\n        <circle cx=\"7\" cy=\"7\" fill=\"none\" r=\"5.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n      </svg>\n    );\n  if (status === \"in_progress\")\n    return (\n      <svg aria-hidden className={cn(c, \"text-amber-500\")} viewBox=\"0 0 14 14\">\n        <circle cx=\"7\" cy=\"7\" fill=\"none\" r=\"5.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n        <path d=\"M7 3.5 A3.5 3.5 0 0 1 7 10.5 Z\" fill=\"currentColor\" />\n      </svg>\n    );\n  if (status === \"in_review\")\n    return (\n      <svg aria-hidden className={cn(c, \"text-emerald-500\")} viewBox=\"0 0 14 14\">\n        <circle cx=\"7\" cy=\"7\" fill=\"none\" r=\"5.5\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n        <path d=\"M7 3.5 A3.5 3.5 0 1 1 3.5 7 L7 7 Z\" fill=\"currentColor\" />\n      </svg>\n    );\n  return (\n    <svg aria-hidden className={cn(c, \"text-blue-500\")} viewBox=\"0 0 14 14\">\n      <circle cx=\"7\" cy=\"7\" fill=\"currentColor\" r=\"6.25\" />\n      <path d=\"M4.4 7.2 6.2 9 9.7 5.3\" fill=\"none\" stroke=\"white\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"1.5\" />\n    </svg>\n  );\n}\n\nfunction PriorityIcon({ priority, className }: { priority: IssuePriority; className?: string }) {\n  if (priority === 1)\n    return (\n      <span\n        aria-hidden\n        className={cn(\"flex size-3.5 shrink-0 items-center justify-center rounded-[calc(var(--radius)*0.3)] bg-orange-500 font-bold text-[10px] text-white leading-none\", className)}\n      >\n        !\n      </span>\n    );\n  if (priority === 0)\n    return (\n      <svg aria-hidden className={cn(\"size-3.5 shrink-0 text-muted-foreground\", className)} viewBox=\"0 0 14 14\">\n        {[2.5, 6, 9.5].map((x) => (\n          <rect fill=\"currentColor\" height=\"1.5\" key={x} opacity=\"0.7\" rx=\"0.75\" width=\"2\" x={x} y=\"6.25\" />\n        ))}\n      </svg>\n    );\n  const filled = 5 - priority;\n  return (\n    <svg aria-hidden className={cn(\"size-3.5 shrink-0 text-foreground/80\", className)} viewBox=\"0 0 14 14\">\n      {[0, 1, 2].map((i) => (\n        <rect\n          fill=\"currentColor\"\n          height={4 + i * 3}\n          key={i}\n          opacity={i < filled ? 1 : 0.22}\n          rx=\"1\"\n          width=\"3\"\n          x={1.5 + i * 4}\n          y={11.5 - (4 + i * 3)}\n        />\n      ))}\n    </svg>\n  );\n}\n\nfunction PersonAvatar({ person, size = \"size-5\" }: { person?: IssuePerson; size?: string }) {\n  if (!person)\n    return (\n      <span className={cn(\"flex shrink-0 items-center justify-center rounded-full border border-muted-foreground/50 border-dashed text-muted-foreground\", size)}>\n        <UserRoundIcon className=\"size-2.5\" />\n      </span>\n    );\n  return (\n    <Avatar className={size}>\n      <AvatarFallback className={cn(\"font-medium text-[9px]\", avatarTone[person.tone])}>{initials(person.name)}</AvatarFallback>\n    </Avatar>\n  );\n}\n\nconst defaultPeople: IssuePerson[] = [\n  { id: \"maya\", name: \"Maya Okafor\", tone: \"teal\" },\n  { id: \"sam\", name: \"Sam Whitfield\", tone: \"amber\" },\n  { id: \"jonas\", name: \"Jonas Weber\", tone: \"blue\" },\n  { id: \"leo\", name: \"Leo Marchetti\", tone: \"rose\" },\n  { id: \"ana\", name: \"Ana Sousa\", tone: \"orange\" },\n  { id: \"priya\", name: \"Priya Raman\", tone: \"violet\" },\n];\n\nconst defaultLabels: IssueLabel[] = [\n  { id: \"bug\", name: \"Bug\", tone: \"rose\" },\n  { id: \"feature\", name: \"Feature\", tone: \"violet\" },\n  { id: \"infra\", name: \"Infra\", tone: \"sky\" },\n  { id: \"perf\", name: \"Performance\", tone: \"amber\" },\n  { id: \"docs\", name: \"Docs\", tone: \"emerald\" },\n];\n\nconst defaultIssues: Issue[] = [\n  {\n    id: \"PLT-231\",\n    title: \"Poison messages stall the webhook consumer\",\n    status: \"in_progress\",\n    priority: 1,\n    assignee: \"sam\",\n    labels: [\"bug\", \"infra\"],\n    estimate: 3,\n    due: \"Oct 24\",\n    created: \"Oct 21\",\n    description: [\n      \"A single malformed payload blocks the consumer for its partition. Retries keep it at the head of the queue, so deliveries behind it wait until the message expires.\",\n      \"Move messages that fail three times to a dead-letter queue and keep the consumer moving. Surface them in the delivery dashboard with a one-click replay.\",\n    ],\n    subtasks: [\n      { title: \"Dead-letter queue with 7-day retention\", done: true },\n      { title: \"Skip after 3 failed attempts\", done: true },\n      { title: \"Replay from the dashboard\", done: false },\n    ],\n    activity: [\n      { who: \"jonas\", text: \"created the issue\", when: \"Oct 21\" },\n      { who: \"jonas\", text: \"set priority to Urgent\", when: \"Oct 21\" },\n      { who: \"sam\", text: \"Reproduced with a truncated JSON body from a customer integration. Patch is up behind a flag.\", when: \"Oct 22\", comment: true },\n    ],\n  },\n  { id: \"PLT-224\", title: \"Replay tool for missed webhook deliveries\", status: \"in_progress\", priority: 2, assignee: \"jonas\", labels: [\"feature\"], estimate: 5, due: \"Oct 30\", created: \"Oct 19\" },\n  { id: \"PLT-215\", title: \"Move job scheduler to the new queue\", status: \"in_progress\", priority: 3, assignee: \"maya\", labels: [\"infra\"], estimate: 8, created: \"Oct 12\" },\n  { id: \"PLT-218\", title: \"Rate limit headers missing on 429 responses\", status: \"in_review\", priority: 3, assignee: \"leo\", labels: [\"bug\"], estimate: 1, created: \"Oct 17\" },\n  { id: \"PLT-198\", title: \"Flaky test: delivery ordering under load\", status: \"in_review\", priority: 4, assignee: \"sam\", labels: [\"bug\"], estimate: 2, created: \"Oct 9\" },\n  { id: \"PLT-212\", title: \"p95 latency regression on /v2/events\", status: \"todo\", priority: 1, assignee: \"ana\", labels: [\"perf\", \"bug\"], estimate: 3, due: \"Oct 25\", created: \"Oct 20\" },\n  { id: \"PLT-229\", title: \"Alert when consumer lag exceeds 2 minutes\", status: \"todo\", priority: 2, assignee: \"sam\", labels: [\"infra\"], estimate: 2, created: \"Oct 22\" },\n  { id: \"PLT-209\", title: \"Rotate signing secrets without downtime\", status: \"todo\", priority: 3, labels: [\"feature\"], estimate: 5, created: \"Oct 15\" },\n  { id: \"PLT-205\", title: \"Document retry semantics for webhooks\", status: \"todo\", priority: 4, assignee: \"priya\", labels: [\"docs\"], estimate: 1, created: \"Oct 14\" },\n  { id: \"PLT-196\", title: \"Per-endpoint delivery dashboard\", status: \"backlog\", priority: 3, assignee: \"priya\", labels: [\"feature\"], created: \"Oct 8\" },\n  { id: \"PLT-201\", title: \"Deprecate the v1 events endpoint\", status: \"backlog\", priority: 4, labels: [\"docs\"], created: \"Oct 11\" },\n  { id: \"PLT-185\", title: \"Batch webhook deliveries per endpoint\", status: \"backlog\", priority: 0, labels: [\"perf\"], created: \"Oct 2\" },\n  { id: \"PLT-190\", title: \"Upgrade Postgres to 17\", status: \"done\", priority: 2, assignee: \"leo\", labels: [\"infra\"], estimate: 5, created: \"Oct 3\" },\n  { id: \"PLT-188\", title: \"Add jitter to retry backoff\", status: \"done\", priority: 3, assignee: \"sam\", labels: [\"infra\"], estimate: 1, created: \"Oct 1\" },\n];\n\ntype PaletteMode = \"root\" | \"status\" | \"priority\" | \"assignee\" | \"label\";\n\ninterface Command {\n  id: string;\n  label: string;\n  group: string;\n  icon: ReactNode;\n  hint?: string;\n  checked?: boolean;\n  keepOpen?: boolean;\n  run: () => void;\n}\n\nfunction Palette({\n  mode,\n  commands,\n  target,\n  onClose,\n  onBack,\n}: {\n  mode: PaletteMode;\n  commands: Command[];\n  target: string;\n  onClose: () => void;\n  onBack: () => void;\n}) {\n  const [query, setQuery] = useState(\"\");\n  const [active, setActive] = useState(0);\n  const inputRef = useRef<HTMLInputElement>(null);\n  const listRef = useRef<HTMLDivElement>(null);\n  const q = query.trim().toLowerCase();\n  const filtered = commands.filter((c) => !q || c.label.toLowerCase().includes(q) || c.group.toLowerCase().includes(q));\n  const groups = Array.from(new Set(filtered.map((c) => c.group)));\n\n  useEffect(() => {\n    inputRef.current?.focus();\n  }, []);\n  useEffect(() => {\n    setActive(0);\n    setQuery(\"\");\n  }, [mode]);\n  useEffect(() => {\n    const el = listRef.current?.querySelector<HTMLElement>(`[data-index=\"${active}\"]`);\n    if (el && listRef.current) {\n      const box = listRef.current;\n      if (el.offsetTop < box.scrollTop) box.scrollTop = el.offsetTop - 4;\n      else if (el.offsetTop + el.offsetHeight > box.scrollTop + box.clientHeight) box.scrollTop = el.offsetTop + el.offsetHeight - box.clientHeight + 4;\n    }\n  }, [active]);\n\n  const placeholder: Record<PaletteMode, string> = {\n    root: \"Type a command or search…\",\n    status: \"Change status…\",\n    priority: \"Set priority…\",\n    assignee: \"Assign to…\",\n    label: \"Add or remove labels…\",\n  };\n\n  return (\n    <motion.div\n      animate={{ opacity: 1 }}\n      className=\"absolute inset-0 z-50 flex items-start justify-center bg-black/24 px-3 pt-16 @3xl:pt-24\"\n      exit={{ opacity: 0 }}\n      initial={{ opacity: 0 }}\n      onMouseDown={(e) => {\n        if (e.target === e.currentTarget) onClose();\n      }}\n      transition={{ duration: 0.12 }}\n    >\n      <motion.div\n        animate={{ opacity: 1, scale: 1 }}\n        aria-label=\"Command menu\"\n        aria-modal=\"true\"\n        className=\"flex max-h-[420px] w-full max-w-lg origin-top flex-col overflow-hidden rounded-2xl border bg-popover shadow-lg/10\"\n        exit={{ opacity: 0, scale: 0.98 }}\n        initial={{ opacity: 0, scale: 0.98 }}\n        role=\"dialog\"\n        transition={{ duration: 0.14, ease }}\n      >\n        <div className=\"flex items-center gap-2 px-3 pt-3\">\n          <span className=\"max-w-full truncate rounded-md bg-muted px-1.5 py-0.5 font-medium font-mono text-[11px] text-muted-foreground\">{target}</span>\n        </div>\n        <div className=\"flex items-center gap-2 border-b px-3\">\n          <SearchIcon className=\"size-4 shrink-0 text-muted-foreground\" />\n          <input\n            aria-activedescendant={filtered[active] ? `cmd-${filtered[active].id}` : undefined}\n            aria-controls=\"cmd-list\"\n            aria-expanded\n            aria-label={placeholder[mode]}\n            className=\"h-12 min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n            onChange={(e) => {\n              setQuery(e.target.value);\n              setActive(0);\n            }}\n            onKeyDown={(e) => {\n              if (e.key === \"ArrowDown\") {\n                e.preventDefault();\n                setActive((a) => Math.min(filtered.length - 1, a + 1));\n              } else if (e.key === \"ArrowUp\") {\n                e.preventDefault();\n                setActive((a) => Math.max(0, a - 1));\n              } else if (e.key === \"Enter\") {\n                e.preventDefault();\n                const c = filtered[active];\n                if (c) {\n                  c.run();\n                  if (!c.keepOpen) onClose();\n                }\n              } else if (e.key === \"Escape\") {\n                e.preventDefault();\n                e.stopPropagation();\n                onClose();\n              } else if (e.key === \"Backspace\" && !query && mode !== \"root\") {\n                e.preventDefault();\n                onBack();\n              }\n            }}\n            placeholder={placeholder[mode]}\n            ref={inputRef}\n            role=\"combobox\"\n            value={query}\n          />\n          <Kbd>Esc</Kbd>\n        </div>\n        <div className=\"min-h-0 flex-1 overflow-y-auto p-1.5 [scrollbar-width:thin]\" id=\"cmd-list\" ref={listRef} role=\"listbox\">\n          {filtered.length === 0 && <div className=\"px-3 py-8 text-center text-muted-foreground text-sm\">No commands match “{query}”</div>}\n          {groups.map((g) => (\n            <div className=\"mb-1\" key={g} role=\"group\" aria-label={g}>\n              <div className=\"px-2.5 pt-2 pb-1 font-medium text-muted-foreground text-xs\">{g}</div>\n              {filtered\n                .filter((c) => c.group === g)\n                .map((c) => {\n                  const i = filtered.indexOf(c);\n                  return (\n                    <div\n                      aria-selected={i === active}\n                      className={cn(\n                        \"flex h-9 cursor-pointer items-center gap-2.5 rounded-lg px-2.5 text-sm\",\n                        i === active ? \"bg-accent text-foreground\" : \"text-foreground/90\",\n                      )}\n                      data-index={i}\n                      id={`cmd-${c.id}`}\n                      key={c.id}\n                      onClick={() => {\n                        c.run();\n                        if (!c.keepOpen) onClose();\n                      }}\n                      onMouseMove={() => setActive(i)}\n                      role=\"option\"\n                    >\n                      <span className=\"flex size-4 items-center justify-center text-muted-foreground\">{c.icon}</span>\n                      <span className=\"flex-1 truncate\">{c.label}</span>\n                      {c.checked && <CheckIcon className=\"size-4 text-foreground\" />}\n                      {c.hint && <Kbd>{c.hint}</Kbd>}\n                    </div>\n                  );\n                })}\n            </div>\n          ))}\n        </div>\n        <div className=\"flex items-center gap-3 border-t px-3 py-2 text-muted-foreground text-xs\">\n          <span className=\"flex items-center gap-1\">\n            <Kbd>↑</Kbd>\n            <Kbd>↓</Kbd> navigate\n          </span>\n          <span className=\"flex items-center gap-1\">\n            <Kbd>\n              <CornerDownLeftIcon />\n            </Kbd>{\" \"}\n            select\n          </span>\n          {mode !== \"root\" && (\n            <span className=\"ms-auto flex items-center gap-1\">\n              <Kbd>⌫</Kbd> back\n            </span>\n          )}\n        </div>\n      </motion.div>\n    </motion.div>\n  );\n}\n\nfunction Property({ label, onClick, children }: { label: string; onClick?: () => void; children: ReactNode }) {\n  return (\n    <div className=\"flex min-h-8 items-center gap-2\">\n      <span className=\"w-20 shrink-0 text-muted-foreground text-xs\">{label}</span>\n      <button\n        className=\"-ms-2 flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring\"\n        onClick={onClick}\n        type=\"button\"\n      >\n        {children}\n      </button>\n    </div>\n  );\n}\n\ntype IssueView = \"mine\" | \"active\" | \"backlog\" | \"all\";\n\nconst navItems: { id: IssueView; label: string; title: string; icon: LucideIcon }[] = [\n  { id: \"mine\", label: \"My issues\", title: \"My issues\", icon: CircleDotIcon },\n  { id: \"active\", label: \"Active\", title: \"Active issues\", icon: LayersIcon },\n  { id: \"backlog\", label: \"Backlog\", title: \"Backlog\", icon: ArchiveIcon },\n  { id: \"all\", label: \"All issues\", title: \"All issues\", icon: ListFilterIcon },\n];\n\nconst inView = (view: IssueView, i: Issue, me: string) =>\n  view === \"mine\" ? i.assignee === me : view === \"active\" ? i.status !== \"backlog\" : view === \"backlog\" ? i.status === \"backlog\" : true;\n\nexport function IssueTracker({\n  team = { name: \"Platform\", key: \"PLT\" },\n  me = \"maya\",\n  people = defaultPeople,\n  labels = defaultLabels,\n  issues: initialIssues = defaultIssues,\n  className,\n}: IssueTrackerProps) {\n  const [issues, setIssues] = useState(initialIssues);\n  const [cursor, setCursor] = useState(initialIssues[0]?.id ?? \"\");\n  const [picked, setPicked] = useState<Set<string>>(() => new Set());\n  const [openId, setOpenId] = useState<string | null>(null);\n  const [palette, setPalette] = useState<{ mode: PaletteMode; ids: string[] } | null>(null);\n  const [collapsed, setCollapsed] = useState<Set<IssueStatus>>(() => new Set());\n  const [query, setQuery] = useState(\"\");\n  const [view, setView] = useState<IssueView>(\"active\");\n  const [searchOpen, setSearchOpen] = useState(false);\n  const [drawer, setDrawer] = useState(false);\n  const [comment, setComment] = useState(\"\");\n  const [toast, setToast] = useState<{ key: number; text: string } | null>(null);\n  const rootRef = useRef<HTMLDivElement>(null);\n  const listRef = useRef<HTMLDivElement>(null);\n  const searchRef = useRef<HTMLInputElement>(null);\n  const mobileSearchRef = useRef<HTMLInputElement>(null);\n  const focusSearch = () =>\n    requestAnimationFrame(() => (searchRef.current?.offsetParent ? searchRef.current : mobileSearchRef.current)?.focus());\n  const titleRef = useRef<HTMLTextAreaElement>(null);\n  const rowRefs = useRef(new Map<string, HTMLElement>());\n  const detailRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    if (!toast) return;\n    const id = window.setTimeout(() => setToast(null), 2600);\n    return () => window.clearTimeout(id);\n  }, [toast]);\n\n  const person = (id?: string) => people.find((p) => p.id === id);\n  const label = (id: string) => labels.find((l) => l.id === id);\n\n  const filtered = useMemo(() => {\n    const q = query.trim().toLowerCase();\n    return issues.filter(\n      (i) => inView(view, i, me) && (!q || i.title.toLowerCase().includes(q) || i.id.toLowerCase().includes(q)),\n    );\n  }, [issues, query, view, me]);\n\n  const groups = STATUSES.map((s) => ({\n    ...s,\n    items: filtered.filter((i) => i.status === s.id).sort((a, b) => (a.priority || 9) - (b.priority || 9)),\n  })).filter((g) => g.items.length > 0);\n\n  const flat = groups.flatMap((g) => (collapsed.has(g.id) ? [] : g.items));\n  const open = issues.find((i) => i.id === openId) ?? null;\n\n  // biome-ignore lint/correctness/useExhaustiveDependencies: reset when another issue opens\n  useEffect(() => {\n    if (detailRef.current) detailRef.current.scrollTop = 0;\n  }, [openId]);\n\n  const focusRow = (id: string) => {\n    setCursor(id);\n    const el = rowRefs.current.get(id);\n    const box = listRef.current;\n    if (el && box) {\n      el.focus({ preventScroll: true });\n      const top = el.offsetTop - 36;\n      const bottom = el.offsetTop + el.offsetHeight;\n      if (top < box.scrollTop) box.scrollTop = top;\n      else if (bottom > box.scrollTop + box.clientHeight) box.scrollTop = bottom - box.clientHeight + 8;\n    }\n  };\n\n  const move = (d: number) => {\n    if (!flat.length) return;\n    const i = flat.findIndex((x) => x.id === cursor);\n    const next = flat[Math.max(0, Math.min(flat.length - 1, (i < 0 ? 0 : i + d)))];\n    if (!next) return;\n    focusRow(next.id);\n    if (openId) setOpenId(next.id);\n  };\n\n  const targets = () => (picked.size ? Array.from(picked) : cursor ? [cursor] : []);\n  const describe = (ids: string[]) => (ids.length === 1 ? ids[0] : `${ids.length} issues`);\n\n  const update = (ids: string[], fn: (i: Issue) => Partial<Issue>, log?: (i: Issue) => string) =>\n    setIssues((all) =>\n      all.map((i) => {\n        if (!ids.includes(i.id)) return i;\n        const p = fn(i);\n        const entry = log?.(i);\n        return { ...i, ...p, activity: entry ? [...(i.activity ?? []), { who: me, text: entry, when: \"just now\" }] : i.activity };\n      }),\n    );\n\n  const setStatus = (ids: string[], status: IssueStatus) => {\n    update(ids, () => ({ status }), () => `moved to ${statusLabel(status)}`);\n    if (status === \"done\" && collapsed.has(\"done\")) setToast({ key: Date.now(), text: `${describe(ids)} marked done` });\n  };\n  const setPriority = (ids: string[], priority: IssuePriority) => update(ids, () => ({ priority }), () => `set priority to ${priorityLabel(priority)}`);\n  const setAssignee = (ids: string[], assignee?: string) =>\n    update(ids, () => ({ assignee }), () => (assignee ? `assigned ${person(assignee)?.name.split(\" \")[0]}` : \"removed the assignee\"));\n  const toggleLabel = (ids: string[], lid: string) => {\n    const allHave = ids.every((id) => issues.find((i) => i.id === id)?.labels?.includes(lid));\n    update(ids, (i) => ({ labels: allHave ? (i.labels ?? []).filter((l) => l !== lid) : Array.from(new Set([...(i.labels ?? []), lid])) }));\n  };\n\n  const createIssue = (status: IssueStatus = view === \"backlog\" ? \"backlog\" : \"todo\") => {\n    const n = Math.max(0, ...issues.map((i) => Number(i.id.split(\"-\")[1]) || 0)) + 1;\n    const id = `${team.key}-${n}`;\n    setIssues((all) => [\n      { id, title: \"\", status, priority: 0, assignee: me, created: \"Today\", activity: [{ who: me, text: \"created the issue\", when: \"just now\" }] },\n      ...all,\n    ]);\n    setQuery(\"\");\n    setCollapsed((c) => {\n      const next = new Set(c);\n      next.delete(status);\n      return next;\n    });\n    setCursor(id);\n    setOpenId(id);\n    requestAnimationFrame(() => titleRef.current?.focus());\n  };\n\n  const remove = (ids: string[]) => {\n    setIssues((all) => all.filter((i) => !ids.includes(i.id)));\n    setPicked(new Set());\n    if (openId && ids.includes(openId)) setOpenId(null);\n    setToast({ key: Date.now(), text: `Deleted ${describe(ids)}` });\n    rootRef.current?.focus({ preventScroll: true });\n  };\n\n  const commandsFor = (mode: PaletteMode, ids: string[]): Command[] => {\n    const one = ids.length === 1 ? issues.find((i) => i.id === ids[0]) : undefined;\n    if (mode === \"status\")\n      return STATUSES.map((s) => ({\n        id: `s-${s.id}`,\n        label: s.label,\n        group: \"Status\",\n        icon: <StatusIcon status={s.id} />,\n        checked: one?.status === s.id,\n        run: () => setStatus(ids, s.id),\n      }));\n    if (mode === \"priority\")\n      return PRIORITIES.map((p) => ({\n        id: `p-${p.id}`,\n        label: p.label,\n        group: \"Priority\",\n        icon: <PriorityIcon priority={p.id} />,\n        hint: String(p.id),\n        checked: one?.priority === p.id,\n        run: () => setPriority(ids, p.id),\n      }));\n    if (mode === \"assignee\")\n      return [\n        ...people.map((p) => ({\n          id: `a-${p.id}`,\n          label: p.id === me ? `${p.name} (you)` : p.name,\n          group: \"Assignee\",\n          icon: <PersonAvatar person={p} size=\"size-4\" />,\n          checked: one?.assignee === p.id,\n          run: () => setAssignee(ids, p.id),\n        })),\n        { id: \"a-none\", label: \"No assignee\", group: \"Assignee\", icon: <PersonAvatar size=\"size-4\" />, checked: one ? !one.assignee : false, run: () => setAssignee(ids, undefined) },\n      ];\n    if (mode === \"label\")\n      return labels.map((l) => ({\n        id: `l-${l.id}`,\n        label: l.name,\n        group: \"Labels\",\n        icon: <span className={cn(\"size-2 rounded-full\", dotTone[l.tone])} />,\n        checked: ids.every((id) => issues.find((i) => i.id === id)?.labels?.includes(l.id)),\n        keepOpen: true,\n        run: () => toggleLabel(ids, l.id),\n      }));\n    const has = ids.length > 0;\n    return [\n      ...(has\n        ? [\n            { id: \"c-status\", label: \"Change status…\", group: \"Issue\", icon: <StatusIcon status=\"in_progress\" />, hint: \"S\", keepOpen: true, run: () => setPalette({ mode: \"status\", ids }) },\n            { id: \"c-priority\", label: \"Set priority…\", group: \"Issue\", icon: <PriorityIcon priority={2} />, hint: \"P\", keepOpen: true, run: () => setPalette({ mode: \"priority\", ids }) },\n            { id: \"c-assign\", label: \"Assign to…\", group: \"Issue\", icon: <UserRoundIcon className=\"size-4\" />, hint: \"A\", keepOpen: true, run: () => setPalette({ mode: \"assignee\", ids }) },\n            { id: \"c-label\", label: \"Add label…\", group: \"Issue\", icon: <TagIcon className=\"size-4\" />, hint: \"L\", keepOpen: true, run: () => setPalette({ mode: \"label\", ids }) },\n            { id: \"c-me\", label: \"Assign to me\", group: \"Issue\", icon: <PersonAvatar person={person(me)} size=\"size-4\" />, hint: \"I\", run: () => setAssignee(ids, me) },\n            {\n              id: \"c-copy\",\n              label: ids.length === 1 ? `Copy ${ids[0]}` : \"Copy IDs\",\n              group: \"Issue\",\n              icon: <CopyIcon className=\"size-4\" />,\n              run: () => {\n                navigator.clipboard?.writeText(ids.join(\", \")).catch(() => {});\n                setToast({ key: Date.now(), text: `Copied ${describe(ids)}` });\n              },\n            },\n            { id: \"c-delete\", label: ids.length === 1 ? \"Delete issue\" : `Delete ${ids.length} issues`, group: \"Issue\", icon: <Trash2Icon className=\"size-4\" />, run: () => remove(ids) },\n          ]\n        : []),\n      { id: \"c-new\", label: \"Create new issue\", group: \"Workspace\", icon: <PlusIcon className=\"size-4\" />, hint: \"C\", run: () => createIssue() },\n      ...navItems\n        .filter((n) => n.id !== view)\n        .map((n) => ({ id: `v-${n.id}`, label: `Go to ${n.label}`, group: \"Views\", icon: <n.icon className=\"size-4\" />, run: () => goView(n.id) })),\n      {\n        id: \"c-done\",\n        label: collapsed.has(\"done\") ? \"Show completed issues\" : \"Hide completed issues\",\n        group: \"Workspace\",\n        icon: <StatusIcon status=\"done\" />,\n        run: () =>\n          setCollapsed((c) => {\n            const next = new Set(c);\n            if (next.has(\"done\")) next.delete(\"done\");\n            else next.add(\"done\");\n            return next;\n          }),\n      },\n    ];\n  };\n\n  const goView = (v: IssueView) => {\n    setView(v);\n    setPicked(new Set());\n    setDrawer(false);\n    listRef.current?.scrollTo({ top: 0 });\n    if (v === \"backlog\")\n      setCollapsed((c) => {\n        const next = new Set(c);\n        next.delete(\"backlog\");\n        return next;\n      });\n  };\n\n  const closePalette = () => {\n    setPalette(null);\n    requestAnimationFrame(() => {\n      const el = rowRefs.current.get(cursor);\n      (el ?? rootRef.current)?.focus({ preventScroll: true });\n    });\n  };\n\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (palette) return;\n    if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === \"k\") {\n      e.preventDefault();\n      setPalette({ mode: \"root\", ids: targets() });\n      return;\n    }\n    const t = e.target as HTMLElement;\n    if (t.tagName === \"INPUT\" || t.tagName === \"TEXTAREA\") {\n      if (e.key === \"Escape\") {\n        t.blur();\n        rootRef.current?.focus({ preventScroll: true });\n      }\n      return;\n    }\n    if (e.metaKey || e.ctrlKey || e.altKey) return;\n    const k = e.key.toLowerCase();\n    if (k === \"j\" || e.key === \"ArrowDown\") {\n      e.preventDefault();\n      move(1);\n    } else if (k === \"k\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      move(-1);\n    } else if (e.key === \"Enter\" || k === \"o\") {\n      e.preventDefault();\n      if (cursor) setOpenId(cursor);\n    } else if (e.key === \"Escape\") {\n      if (drawer) setDrawer(false);\n      else if (openId) {\n        setOpenId(null);\n        focusRow(cursor);\n      } else if (picked.size) setPicked(new Set());\n    } else if (k === \"x\" && cursor) {\n      e.preventDefault();\n      setPicked((p) => {\n        const next = new Set(p);\n        if (next.has(cursor)) next.delete(cursor);\n        else next.add(cursor);\n        return next;\n      });\n    } else if (k === \"s\" || k === \"p\" || k === \"a\" || k === \"l\") {\n      e.preventDefault();\n      const ids = targets();\n      if (ids.length) setPalette({ mode: ({ s: \"status\", p: \"priority\", a: \"assignee\", l: \"label\" } as const)[k], ids });\n    } else if (k === \"i\") {\n      const ids = targets();\n      if (ids.length) setAssignee(ids, me);\n    } else if ([\"0\", \"1\", \"2\", \"3\", \"4\"].includes(e.key)) {\n      const ids = targets();\n      if (ids.length) setPriority(ids, Number(e.key) as IssuePriority);\n    } else if (k === \"c\") {\n      e.preventDefault();\n      createIssue();\n    } else if (e.key === \"/\") {\n      e.preventDefault();\n      setSearchOpen(true);\n      focusSearch();\n    }\n  };\n\n  const sidebar = (onClose?: () => void) => (\n    <div className=\"flex h-full flex-col px-2 pt-3 pb-3\">\n      <div className=\"flex items-center gap-2 px-1.5 pb-3\">\n        <span className=\"flex size-7 items-center justify-center rounded-lg bg-sky-700 font-semibold text-[11px] text-white\">{team.key.slice(0, 2)}</span>\n        <div className=\"min-w-0 flex-1 leading-tight\">\n          <div className=\"truncate font-medium\">Kestrel</div>\n          <div className=\"truncate text-muted-foreground text-xs\">{team.name} team</div>\n        </div>\n        {onClose && (\n          <Button aria-label=\"Close navigation\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n            <XIcon />\n          </Button>\n        )}\n      </div>\n      <button\n        className=\"mb-3 flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg border bg-background px-2.5 text-muted-foreground shadow-xs/5 outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring dark:bg-input/32\"\n        onClick={() => {\n          onClose?.();\n          setPalette({ mode: \"root\", ids: targets() });\n        }}\n        type=\"button\"\n      >\n        <SearchIcon className=\"size-4\" />\n        <span className=\"flex-1 text-left\">Command</span>\n        <Kbd>⌘K</Kbd>\n      </button>\n      <nav aria-label=\"Views\" className=\"flex flex-col gap-0.5\">\n        {navItems.map((n) => {\n          const on = n.id === view;\n          const count = issues.filter((i) => inView(n.id, i, me) && i.status !== \"done\").length;\n          return (\n            <button\n              aria-current={on ? \"page\" : undefined}\n              className={cn(\n                \"group/nav relative flex h-8 cursor-pointer items-center gap-2.5 rounded-lg px-2.5 text-left text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n                on ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n              )}\n              key={n.id}\n              onClick={() => goView(n.id)}\n              type=\"button\"\n            >\n              {on ? (\n                <motion.span\n                  className=\"absolute inset-0 rounded-lg bg-accent\"\n                  layoutId={onClose ? \"issue-nav-drawer\" : \"issue-nav\"}\n                  transition={{ type: \"spring\", stiffness: 520, damping: 42 }}\n                />\n              ) : (\n                <span className=\"absolute inset-0 rounded-lg transition-colors group-hover/nav:bg-accent/60\" />\n              )}\n              <n.icon className=\"relative size-4\" />\n              <span className=\"relative flex-1 font-medium\">{n.label}</span>\n              <span className=\"relative text-muted-foreground text-xs tabular-nums\">{count}</span>\n            </button>\n          );\n        })}\n      </nav>\n      <div className=\"mt-6 px-2.5 font-medium text-muted-foreground text-xs\">Cycle 42 · ends Oct 30</div>\n      <div className=\"mx-2.5 mt-2\">\n        <div className=\"flex h-1.5 overflow-hidden rounded-full bg-muted\">\n          <div className=\"h-full bg-blue-500\" style={{ width: `${(issues.filter((i) => i.status === \"done\").length / Math.max(1, issues.length)) * 100}%` }} />\n          <div className=\"h-full bg-emerald-500\" style={{ width: `${(issues.filter((i) => i.status === \"in_review\").length / Math.max(1, issues.length)) * 100}%` }} />\n          <div className=\"h-full bg-amber-500\" style={{ width: `${(issues.filter((i) => i.status === \"in_progress\").length / Math.max(1, issues.length)) * 100}%` }} />\n        </div>\n        <div className=\"mt-2 flex justify-between text-muted-foreground text-xs tabular-nums\">\n          <span>\n            {issues.filter((i) => i.status === \"done\").length} of {issues.length} done\n          </span>\n          <span>6 days left</span>\n        </div>\n      </div>\n      <div className=\"mt-auto flex flex-col gap-1.5 px-2.5 text-muted-foreground text-xs\">\n        {[\n          [\"J K\", \"move\"],\n          [\"S P A L\", \"set fields\"],\n          [\"X\", \"select\"],\n          [\"⌘K\", \"everything else\"],\n        ].map(([k, v]) => (\n          <div className=\"flex items-center gap-1.5\" key={k}>\n            {k.split(\" \").map((x) => (\n              <Kbd key={x}>{x}</Kbd>\n            ))}\n            <span className=\"truncate\">{v}</span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div\n        className={cn(\"@container relative isolate flex h-[760px] w-full overflow-hidden bg-sidebar text-foreground text-sm outline-none\", className)}\n        onKeyDown={onKeyDown}\n        ref={rootRef}\n        tabIndex={-1}\n      >\n        <aside aria-label=\"Navigation\" className=\"hidden w-56 shrink-0 @5xl:block\">\n          {sidebar()}\n        </aside>\n\n        <AnimatePresence>\n          {drawer && (\n            <>\n              <motion.div\n                animate={{ opacity: 1 }}\n                aria-hidden\n                className=\"absolute inset-0 z-40 bg-black/32 @5xl:hidden\"\n                exit={{ opacity: 0 }}\n                initial={{ opacity: 0 }}\n                onClick={() => setDrawer(false)}\n              />\n              <motion.div\n                animate={{ x: 0 }}\n                aria-label=\"Navigation\"\n                aria-modal=\"true\"\n                className=\"absolute inset-y-2 left-2 z-50 w-[248px] max-w-[calc(100%-3rem)] overflow-hidden rounded-2xl border bg-sidebar shadow-lg/10 @5xl:hidden\"\n                exit={{ x: \"-110%\" }}\n                initial={{ x: \"-110%\" }}\n                role=\"dialog\"\n                transition={{ type: \"spring\", stiffness: 420, damping: 40 }}\n              >\n                {sidebar(() => setDrawer(false))}\n              </motion.div>\n            </>\n          )}\n        </AnimatePresence>\n\n        <main className=\"relative flex min-w-0 flex-1 overflow-hidden bg-background @5xl:my-2 @5xl:me-2 @5xl:rounded-2xl @5xl:border @5xl:shadow-xs/5\">\n          <section aria-label=\"Issues\" className=\"flex min-w-0 flex-1 flex-col\">\n            <header className=\"flex h-13 shrink-0 items-center gap-2 border-b px-3 @lg:px-4\">\n              <Button aria-label=\"Open navigation\" className=\"@5xl:hidden\" onClick={() => setDrawer(true)} size=\"icon-sm\" variant=\"ghost\">\n                <MenuIcon />\n              </Button>\n              <h2 className=\"font-semibold\">{navItems.find((n) => n.id === view)?.title}</h2>\n              <span className=\"text-muted-foreground text-xs tabular-nums\">{filtered.filter((i) => i.status !== \"done\").length}</span>\n              <div className=\"ms-auto flex items-center gap-1.5\">\n                <Button\n                  aria-label=\"Filter issues\"\n                  aria-pressed={searchOpen}\n                  className=\"@2xl:hidden\"\n                  onClick={() => {\n                    setSearchOpen((v) => !v);\n                    if (!searchOpen) focusSearch();\n                    else setQuery(\"\");\n                  }}\n                  size=\"icon-sm\"\n                  variant=\"ghost\"\n                >\n                  <SearchIcon />\n                </Button>\n                <label className=\"hidden h-8 w-52 items-center gap-2 rounded-lg border bg-background px-2.5 text-muted-foreground shadow-xs/5 transition-shadow focus-within:border-ring/60 focus-within:ring-3 focus-within:ring-ring/16 @2xl:flex dark:bg-input/32\">\n                  <SearchIcon className=\"size-3.5 shrink-0\" />\n                  <input\n                    aria-label=\"Filter issues\"\n                    className=\"min-w-0 flex-1 bg-transparent text-foreground text-sm outline-none placeholder:text-muted-foreground\"\n                    onChange={(e) => setQuery(e.target.value)}\n                    onKeyDown={(e) => {\n                      if (e.key === \"ArrowDown\" || e.key === \"Enter\") {\n                        e.preventDefault();\n                        if (flat[0]) focusRow(flat[0].id);\n                      }\n                      if (e.key === \"Escape\") {\n                        setQuery(\"\");\n                        setSearchOpen(false);\n                      }\n                    }}\n                    placeholder=\"Filter by title or ID\"\n                    ref={searchRef}\n                    value={query}\n                  />\n                  {query ? (\n                    <button\n                      aria-label=\"Clear filter\"\n                      className=\"-me-1.5 flex size-6 cursor-pointer items-center justify-center rounded-md outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                      onClick={() => setQuery(\"\")}\n                      type=\"button\"\n                    >\n                      <XIcon className=\"size-3.5\" />\n                    </button>\n                  ) : (\n                    <Kbd>/</Kbd>\n                  )}\n                </label>\n                <Button className=\"transition-[box-shadow,scale] duration-150 ease-out active:scale-[0.97]\" onClick={() => createIssue()} size=\"sm\">\n                  <PlusIcon />\n                  <span className=\"hidden @md:inline\">New issue</span>\n                </Button>\n              </div>\n            </header>\n\n            {searchOpen && (\n              <div className=\"flex h-11 shrink-0 items-center gap-2 border-b px-4 @2xl:hidden\">\n                <SearchIcon className=\"size-4 shrink-0 text-muted-foreground\" />\n                <input\n                  aria-label=\"Filter issues by title or ID\"\n                  className=\"min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground\"\n                  onChange={(e) => setQuery(e.target.value)}\n                  onKeyDown={(e) => {\n                    if (e.key === \"Enter\") {\n                      e.preventDefault();\n                      (e.target as HTMLInputElement).blur();\n                    }\n                    if (e.key === \"Escape\") {\n                      setQuery(\"\");\n                      setSearchOpen(false);\n                    }\n                  }}\n                  placeholder=\"Filter by title or ID\"\n                  ref={mobileSearchRef}\n                  value={query}\n                />\n                <Button\n                  aria-label=\"Close filter\"\n                  onClick={() => {\n                    setQuery(\"\");\n                    setSearchOpen(false);\n                  }}\n                  size=\"icon-xs\"\n                  variant=\"ghost\"\n                >\n                  <XIcon />\n                </Button>\n              </div>\n            )}\n\n            <AnimatePresence initial={false}>\n              {picked.size > 0 && (\n                <motion.div\n                  animate={{ height: 44, opacity: 1 }}\n                  className=\"flex shrink-0 items-center gap-2 overflow-hidden border-b bg-muted/50 px-3 @lg:px-4\"\n                  exit={{ height: 0, opacity: 0 }}\n                  initial={{ height: 0, opacity: 0 }}\n                  transition={{ duration: 0.18, ease }}\n                >\n                  <span className=\"font-medium tabular-nums\">{picked.size} selected</span>\n                  <div className=\"ms-auto flex items-center gap-1\">\n                    <Button onClick={() => setPalette({ mode: \"status\", ids: Array.from(picked) })} size=\"xs\" variant=\"outline\">\n                      <StatusIcon status=\"in_progress\" /> Status\n                    </Button>\n                    <Button className=\"hidden @md:inline-flex\" onClick={() => setPalette({ mode: \"priority\", ids: Array.from(picked) })} size=\"xs\" variant=\"outline\">\n                      <PriorityIcon priority={2} /> Priority\n                    </Button>\n                    <Button onClick={() => setPalette({ mode: \"assignee\", ids: Array.from(picked) })} size=\"xs\" variant=\"outline\">\n                      <UserRoundIcon /> Assign\n                    </Button>\n                    <Button aria-label=\"Clear selection\" onClick={() => setPicked(new Set())} size=\"icon-xs\" variant=\"ghost\">\n                      <XIcon />\n                    </Button>\n                  </div>\n                </motion.div>\n              )}\n            </AnimatePresence>\n\n            <div\n              aria-label={groups.length ? \"Issues\" : undefined}\n              aria-multiselectable={groups.length ? true : undefined}\n              className=\"relative min-h-0 flex-1 overflow-y-auto [scrollbar-width:thin]\"\n              ref={listRef}\n              role={groups.length ? \"grid\" : undefined}\n            >\n              {groups.length === 0 ? (\n                <div className=\"flex h-full flex-col items-center justify-center px-6 text-center\">\n                  <span className=\"flex size-10 items-center justify-center rounded-xl border bg-card text-muted-foreground shadow-xs/5\">\n                    <SearchIcon className=\"size-5\" />\n                  </span>\n                  <p className=\"mt-3 font-medium\">{query ? \"No issues match\" : \"Nothing here\"}</p>\n                  <p className=\"mt-1 text-muted-foreground text-xs\">\n                    {query ? `Nothing in ${navItems.find((n) => n.id === view)?.label} mentions “${query}”.` : \"Press C to create an issue.\"}\n                  </p>\n                </div>\n              ) : (\n                <LayoutGroup id={`issues-${view}-${query}`} key={`${view}-${query}`}>\n                  {groups.map((g) => {\n                    const isCollapsed = collapsed.has(g.id);\n                    return (\n                      <div key={g.id} role=\"rowgroup\">\n                        <div className={cn(\"sticky top-0 z-10 flex h-9 items-center gap-2 border-b bg-background bg-linear-to-r ps-3 pe-2 @lg:ps-4\", groupTone[g.id])} role=\"row\">\n                          <span className=\"contents\" role=\"gridcell\">\n                            <button\n                              aria-expanded={!isCollapsed}\n                              className=\"flex cursor-pointer items-center gap-2 rounded outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n                              onClick={() =>\n                                setCollapsed((c) => {\n                                  const next = new Set(c);\n                                  if (next.has(g.id)) next.delete(g.id);\n                                  else next.add(g.id);\n                                  return next;\n                                })\n                              }\n                              type=\"button\"\n                            >\n                              <ChevronDownIcon className={cn(\"size-3.5 text-muted-foreground transition-transform duration-200\", isCollapsed && \"-rotate-90\")} />\n                              <StatusIcon status={g.id} />\n                              <span className=\"font-medium text-[13px]\">{g.label}</span>\n                              <span className=\"text-muted-foreground text-xs tabular-nums\">{g.items.length}</span>\n                            </button>\n                          </span>\n                          {g.id !== \"done\" && (\n                            <span className=\"contents\" role=\"gridcell\">\n                              <Button aria-label={`New issue in ${g.label}`} className=\"ms-auto\" onClick={() => createIssue(g.id)} size=\"icon-xs\" variant=\"ghost\">\n                                <PlusIcon />\n                              </Button>\n                            </span>\n                          )}\n                        </div>\n                        {!isCollapsed && (\n                          <ul role=\"none\">\n                            <AnimatePresence initial={false}>\n                              {g.items.map((issue) => {\n                                const isCursor = issue.id === cursor;\n                                const isPicked = picked.has(issue.id);\n                                const a = person(issue.assignee);\n                                return (\n                                  <motion.li\n                                    animate={{ opacity: 1 }}\n                                    exit={{ opacity: 0 }}\n                                    initial={{ opacity: 0 }}\n                                    key={issue.id}\n                                    layout=\"position\"\n                                    layoutId={issue.id}\n                                    role=\"none\"\n                                    transition={{ layout: glide, opacity: { duration: 0.15 } }}\n                                  >\n                                    <div\n                                      aria-label={`${issue.id} ${issue.title || \"Untitled issue\"}`}\n                                      aria-selected={isPicked}\n                                      className={cn(\n                                        \"group/row relative flex h-10 cursor-pointer items-center gap-2.5 border-b border-border/60 ps-3 pe-3 outline-none @lg:ps-4\",\n                                        isCursor ? \"bg-accent\" : \"hover:bg-accent/50\",\n                                        isPicked && \"bg-info/8 hover:bg-info/10\",\n                                        issue.id === openId && \"bg-accent\",\n                                      )}\n                                      onClick={() => {\n                                        setCursor(issue.id);\n                                        setOpenId(issue.id);\n                                      }}\n                                      onFocus={() => setCursor(issue.id)}\n                                      ref={(el) => {\n                                        if (el) rowRefs.current.set(issue.id, el);\n                                        else rowRefs.current.delete(issue.id);\n                                      }}\n                                      role=\"row\"\n                                      tabIndex={isCursor ? 0 : -1}\n                                    >\n                                      {isCursor && <span className=\"absolute inset-y-0 left-0 w-0.5 bg-foreground/70\" />}\n                                      <span className=\"contents\" role=\"gridcell\">\n                                        <button\n                                          aria-label={isPicked ? \"Deselect\" : \"Select\"}\n                                          aria-pressed={isPicked}\n                                          className={cn(\n                                            \"-ms-1 hidden size-5 shrink-0 cursor-pointer items-center justify-center rounded border outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-ring @lg:flex\",\n                                            isPicked ? \"border-info bg-info text-white\" : \"border-muted-foreground/40 opacity-0 group-hover/row:opacity-100\",\n                                          )}\n                                          onClick={(e) => {\n                                            e.stopPropagation();\n                                            setPicked((p) => {\n                                              const next = new Set(p);\n                                              if (next.has(issue.id)) next.delete(issue.id);\n                                              else next.add(issue.id);\n                                              return next;\n                                            });\n                                          }}\n                                          tabIndex={-1}\n                                          type=\"button\"\n                                        >\n                                          {isPicked && <CheckIcon className=\"size-3\" strokeWidth={3} />}\n                                        </button>\n                                      </span>\n                                      <span title={priorityLabel(issue.priority)}>\n                                        <PriorityIcon priority={issue.priority} />\n                                      </span>\n                                      <span className=\"hidden w-16 shrink-0 font-mono text-muted-foreground text-xs @xl:block\">{issue.id}</span>\n                                      <span title={statusLabel(issue.status)}>\n                                        <StatusIcon status={issue.status} />\n                                      </span>\n                                      <span className={cn(\"min-w-0 flex-1 truncate font-medium text-[13px]\", !issue.title && \"font-normal text-muted-foreground italic\", issue.status === \"done\" && \"text-muted-foreground\")} role=\"gridcell\">\n                                        {issue.title || \"Untitled issue\"}\n                                      </span>\n                                      <span className=\"hidden shrink-0 items-center gap-1 @3xl:flex\">\n                                        {issue.labels?.map((lid) => {\n                                          const l = label(lid);\n                                          return l ? (\n                                            <span className=\"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[11px] text-muted-foreground\" key={lid}>\n                                              <span className={cn(\"size-1.5 rounded-full\", dotTone[l.tone])} />\n                                              {l.name}\n                                            </span>\n                                          ) : null;\n                                        })}\n                                      </span>\n                                      {issue.due && (\n                                        <span\n                                          className={cn(\n                                            \"hidden h-5 shrink-0 items-center gap-1 rounded-full border px-1.5 text-[11px] tabular-nums @2xl:inline-flex\",\n                                            issue.priority === 1 && issue.status !== \"done\" ? \"border-destructive/30 text-destructive-foreground\" : \"text-muted-foreground\",\n                                          )}\n                                        >\n                                          <CalendarIcon className=\"size-3\" />\n                                          {issue.due}\n                                        </span>\n                                      )}\n                                      <span className=\"hidden w-12 shrink-0 text-right text-muted-foreground text-xs tabular-nums @xl:block\">{issue.created}</span>\n                                      <span title={a?.name ?? \"Unassigned\"}>\n                                        <PersonAvatar person={a} />\n                                      </span>\n                                    </div>\n                                  </motion.li>\n                                );\n                              })}\n                            </AnimatePresence>\n                          </ul>\n                        )}\n                      </div>\n                    );\n                  })}\n                </LayoutGroup>\n              )}\n            </div>\n          </section>\n\n          <AnimatePresence>\n            {open && (\n              <motion.aside\n                animate={{ x: 0, opacity: 1 }}\n                aria-label={`${open.id} details`}\n                className=\"absolute inset-0 z-30 flex flex-col bg-background @4xl:static @4xl:z-auto @4xl:w-[400px] @4xl:shrink-0 @4xl:border-s @6xl:w-[440px]\"\n                exit={{ x: 32, opacity: 0 }}\n                initial={{ x: 32, opacity: 0 }}\n                key=\"detail\"\n                transition={{ duration: 0.2, ease }}\n              >\n                <header className=\"flex h-13 shrink-0 items-center gap-2 border-b px-3\">\n                  <Button aria-label=\"Back to issues\" className=\"@4xl:hidden\" onClick={() => setOpenId(null)} size=\"icon-sm\" variant=\"ghost\">\n                    <ArrowLeftIcon />\n                  </Button>\n                  <span className=\"font-mono text-muted-foreground text-xs\">{open.id}</span>\n                  <div className=\"ms-auto flex items-center gap-1\">\n                    <span className=\"me-1 hidden text-muted-foreground text-xs @4xl:inline\">\n                      <Kbd>J</Kbd> <Kbd>K</Kbd>\n                    </span>\n                    <Button aria-label=\"More actions\" onClick={() => setPalette({ mode: \"root\", ids: [open.id] })} size=\"xs\" variant=\"outline\">\n                      <Kbd className=\"h-4 bg-transparent px-0\">⌘K</Kbd>\n                    </Button>\n                    <Button aria-label=\"Close details\" onClick={() => setOpenId(null)} size=\"icon-sm\" variant=\"ghost\">\n                      <XIcon />\n                    </Button>\n                  </div>\n                </header>\n                <div className=\"min-h-0 flex-1 overflow-y-auto [scrollbar-width:thin]\" ref={detailRef}>\n                  <div className=\"flex flex-col gap-5 p-4\">\n                    <textarea\n                      aria-label=\"Issue title\"\n                      className=\"w-full resize-none bg-transparent font-heading font-semibold text-lg leading-snug tracking-tight outline-none placeholder:text-muted-foreground/60 [field-sizing:content]\"\n                      onBlur={() => !open.title.trim() && update([open.id], () => ({ title: \"Untitled issue\" }))}\n                      onChange={(e) => update([open.id], () => ({ title: e.target.value.replace(/\\n/g, \"\") }))}\n                      onKeyDown={(e) => {\n                        if (e.key === \"Enter\") {\n                          e.preventDefault();\n                          (e.target as HTMLTextAreaElement).blur();\n                          focusRow(open.id);\n                        }\n                      }}\n                      placeholder=\"Issue title\"\n                      ref={titleRef}\n                      rows={1}\n                      value={open.title}\n                    />\n\n                    <div className=\"flex flex-col gap-0.5 rounded-xl border bg-card p-2 ps-3\">\n                      <Property label=\"Status\" onClick={() => setPalette({ mode: \"status\", ids: [open.id] })}>\n                        <StatusIcon status={open.status} />\n                        {statusLabel(open.status)}\n                        <Kbd className=\"ms-auto\">S</Kbd>\n                      </Property>\n                      <Property label=\"Priority\" onClick={() => setPalette({ mode: \"priority\", ids: [open.id] })}>\n                        <PriorityIcon priority={open.priority} />\n                        {priorityLabel(open.priority)}\n                        <Kbd className=\"ms-auto\">P</Kbd>\n                      </Property>\n                      <Property label=\"Assignee\" onClick={() => setPalette({ mode: \"assignee\", ids: [open.id] })}>\n                        <PersonAvatar person={person(open.assignee)} />\n                        <span className={cn(!open.assignee && \"text-muted-foreground\")}>{person(open.assignee)?.name ?? \"Unassigned\"}</span>\n                        <Kbd className=\"ms-auto\">A</Kbd>\n                      </Property>\n                      <Property label=\"Labels\" onClick={() => setPalette({ mode: \"label\", ids: [open.id] })}>\n                        <span className=\"flex min-w-0 flex-1 flex-wrap gap-1\">\n                          {open.labels?.length ? (\n                            open.labels.map((lid) => {\n                              const l = label(lid);\n                              return l ? (\n                                <span className=\"inline-flex h-5 items-center gap-1 rounded-full border px-1.5 text-[11px]\" key={lid}>\n                                  <span className={cn(\"size-1.5 rounded-full\", dotTone[l.tone])} />\n                                  {l.name}\n                                </span>\n                              ) : null;\n                            })\n                          ) : (\n                            <span className=\"text-muted-foreground\">Add label</span>\n                          )}\n                        </span>\n                        <Kbd className=\"ms-auto\">L</Kbd>\n                      </Property>\n                      <div className=\"flex min-h-8 items-center gap-2\">\n                        <span className=\"w-20 shrink-0 text-muted-foreground text-xs\">Estimate</span>\n                        <span className=\"tabular-nums\">{open.estimate ? `${open.estimate} ${open.estimate === 1 ? \"point\" : \"points\"}` : \"—\"}</span>\n                        {open.due && <span className=\"ms-auto pe-2 text-muted-foreground text-xs tabular-nums\">Due {open.due}</span>}\n                      </div>\n                    </div>\n\n                    <div className=\"flex flex-col gap-3 text-pretty leading-6\">\n                      {open.description?.length ? (\n                        open.description.map((p) => <p key={p}>{p}</p>)\n                      ) : (\n                        <p className=\"text-muted-foreground\">No description yet. Add context, links and acceptance criteria here.</p>\n                      )}\n                    </div>\n\n                    {open.subtasks && (\n                      <div>\n                        <div className=\"mb-1.5 flex items-center gap-2 text-muted-foreground text-xs\">\n                          <span className=\"font-medium\">Sub-issues</span>\n                          <span className=\"tabular-nums\">\n                            {open.subtasks.filter((s) => s.done).length}/{open.subtasks.length}\n                          </span>\n                        </div>\n                        <ul className=\"flex flex-col\">\n                          {open.subtasks.map((s, i) => (\n                            <li key={s.title}>\n                              <button\n                                className=\"flex h-8 w-full cursor-pointer items-center gap-2.5 rounded-lg px-1.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring\"\n                                onClick={() =>\n                                  update([open.id], (iss) => ({\n                                    subtasks: iss.subtasks?.map((x, j) => (j === i ? { ...x, done: !x.done } : x)),\n                                  }))\n                                }\n                                type=\"button\"\n                              >\n                                <StatusIcon status={s.done ? \"done\" : \"todo\"} />\n                                <span className={cn(s.done && \"text-muted-foreground line-through decoration-muted-foreground/50\")}>{s.title}</span>\n                              </button>\n                            </li>\n                          ))}\n                        </ul>\n                      </div>\n                    )}\n\n                    <div>\n                      <div className=\"mb-2 font-medium text-muted-foreground text-xs\">Activity</div>\n                      <ol className=\"relative flex flex-col gap-3 before:absolute before:top-2 before:bottom-2 before:left-[9px] before:w-px before:bg-border\">\n                        {(open.activity ?? [{ who: open.assignee ?? \"jonas\", text: \"created the issue\", when: open.created }]).map((a, i) => {\n                          const p = person(a.who);\n                          return a.comment ? (\n                            <li className=\"relative flex gap-2.5\" key={i}>\n                              <PersonAvatar person={p} />\n                              <div className=\"min-w-0 flex-1 rounded-xl border bg-card px-3 py-2\">\n                                <div className=\"flex items-baseline gap-2 text-xs\">\n                                  <span className=\"font-medium\">{p?.name}</span>\n                                  <span className=\"text-muted-foreground\">{a.when}</span>\n                                </div>\n                                <p className=\"mt-1 text-pretty leading-6\">{a.text}</p>\n                              </div>\n                            </li>\n                          ) : (\n                            <motion.li\n                              animate={{ opacity: 1, y: 0 }}\n                              className=\"relative flex items-center gap-2.5 text-muted-foreground text-xs\"\n                              initial={a.when === \"just now\" ? { opacity: 0, y: 4 } : false}\n                              key={i}\n                              transition={{ duration: 0.2, ease }}\n                            >\n                              <span className=\"flex size-5 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n                                <span className=\"size-1.5 rounded-full bg-muted-foreground/60\" />\n                              </span>\n                              <span>\n                                <span className=\"font-medium text-foreground\">{a.who === me ? \"You\" : p?.name.split(\" \")[0]}</span> {a.text}\n                              </span>\n                              <span className=\"ms-auto tabular-nums\">{a.when}</span>\n                            </motion.li>\n                          );\n                        })}\n                      </ol>\n                    </div>\n                  </div>\n                </div>\n                <div className=\"shrink-0 border-t p-3\">\n                  <div className=\"flex items-end gap-2 rounded-xl border bg-card p-1.5 ps-3 shadow-xs/5 transition-shadow focus-within:border-ring/60 focus-within:ring-3 focus-within:ring-ring/16\">\n                    <textarea\n                      aria-label=\"Leave a comment\"\n                      className=\"max-h-28 min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm leading-5 outline-none placeholder:text-muted-foreground/70 [field-sizing:content]\"\n                      onChange={(e) => setComment(e.target.value)}\n                      onKeyDown={(e) => {\n                        if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey) && comment.trim()) {\n                          e.preventDefault();\n                          update([open.id], (i) => ({ activity: [...(i.activity ?? []), { who: me, text: comment.trim(), when: \"just now\", comment: true }] }));\n                          setComment(\"\");\n                        }\n                      }}\n                      placeholder=\"Leave a comment…\"\n                      rows={1}\n                      value={comment}\n                    />\n                    <Button\n                      disabled={!comment.trim()}\n                      onClick={() => {\n                        update([open.id], (i) => ({ activity: [...(i.activity ?? []), { who: me, text: comment.trim(), when: \"just now\", comment: true }] }));\n                        setComment(\"\");\n                      }}\n                      size=\"sm\"\n                      variant={comment.trim() ? \"default\" : \"ghost\"}\n                    >\n                      Comment\n                    </Button>\n                  </div>\n                </div>\n              </motion.aside>\n            )}\n          </AnimatePresence>\n\n          <AnimatePresence>\n            {palette && (\n              <Palette\n                commands={commandsFor(palette.mode, palette.ids)}\n                mode={palette.mode}\n                onBack={() => setPalette({ mode: \"root\", ids: palette.ids })}\n                onClose={closePalette}\n                target={palette.ids.length ? describe(palette.ids) : `${team.name} team`}\n              />\n            )}\n          </AnimatePresence>\n\n          <div aria-live=\"polite\" className=\"pointer-events-none absolute inset-x-0 bottom-4 z-40 flex justify-center px-4\">\n            <AnimatePresence mode=\"popLayout\">\n              {toast && (\n                <motion.div\n                  animate={{ opacity: 1, y: 0, scale: 1 }}\n                  className=\"flex h-9 items-center rounded-full border bg-popover px-4 text-sm shadow-lg/10\"\n                  exit={{ opacity: 0, y: 6, scale: 0.98 }}\n                  initial={{ opacity: 0, y: 8, scale: 0.98 }}\n                  key={toast.key}\n                  transition={{ duration: 0.2, ease }}\n                >\n                  {toast.text}\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n        </main>\n      </div>\n    </MotionConfig>\n  );\n}\n"
    }
  ]
}