{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "help-centre",
  "type": "registry:block",
  "title": "Help Centre",
  "description": "A support site with a search that suggests articles as you type, topic cards, readable articles with a table of contents that follows you, and a feedback form that asks what went wrong.",
  "categories": [
    "screen",
    "Product"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/input.json",
    "https://coss.com/ui/r/kbd.json",
    "https://coss.com/ui/r/textarea.json"
  ],
  "files": [
    {
      "path": "registry/devl/help-centre.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowLeftRightIcon,\n  ArrowRightIcon,\n  CheckIcon,\n  ChevronLeftIcon,\n  ChevronRightIcon,\n  CircleAlertIcon,\n  ClockIcon,\n  CornerDownLeftIcon,\n  CreditCardIcon,\n  FileTextIcon,\n  InfoIcon,\n  LifeBuoyIcon,\n  MailIcon,\n  MessageCircleIcon,\n  PlugIcon,\n  RocketIcon,\n  SearchIcon,\n  SearchXIcon,\n  ShieldCheckIcon,\n  ThumbsDownIcon,\n  ThumbsUpIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport { Textarea } from \"@/components/ui/textarea\";\n\nfunction useReducedMotionAfterMount() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nexport type HelpTone = \"sky\" | \"emerald\" | \"amber\" | \"violet\" | \"rose\" | \"teal\";\nexport type HelpIcon = \"rocket\" | \"payments\" | \"invoices\" | \"billing\" | \"security\" | \"integrations\";\n\nexport interface HelpCategory {\n  id: string;\n  name: string;\n  description: string;\n  icon: HelpIcon;\n  tone: HelpTone;\n}\n\nexport type HelpBlock =\n  | { type: \"p\"; text: string }\n  | { type: \"h2\"; text: string }\n  | { type: \"steps\"; items: string[] }\n  | { type: \"list\"; items: string[] }\n  | { type: \"callout\"; tone: \"info\" | \"warning\"; text: string };\n\nexport interface HelpArticle {\n  id: string;\n  title: string;\n  categoryId: string;\n  summary: string;\n  updated: string;\n  minutes: number;\n  popular?: boolean;\n  body: HelpBlock[];\n}\n\nexport interface HelpCentreProps {\n  className?: string;\n  productName?: string;\n  categories?: HelpCategory[];\n  articles?: HelpArticle[];\n  popularSearches?: string[];\n  replyTime?: string;\n}\n\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst spring = { type: \"spring\", stiffness: 520, damping: 46, mass: 1 } as const;\nconst press = \"transition-[color,background-color,box-shadow,scale,border-color] duration-150 ease-out active:scale-[0.97]\";\nconst ring = \"outline-none focus-visible:ring-2 focus-visible:ring-ring\";\n\nconst icons: Record<HelpIcon, ReactNode> = {\n  rocket: <RocketIcon />,\n  payments: <ArrowLeftRightIcon />,\n  invoices: <FileTextIcon />,\n  billing: <CreditCardIcon />,\n  security: <ShieldCheckIcon />,\n  integrations: <PlugIcon />,\n};\n\nconst toneTile: Record<HelpTone, string> = {\n  sky: \"border bg-background text-sky-600 dark:bg-input/32 dark:text-sky-400\",\n  emerald: \"border bg-background text-emerald-600 dark:bg-input/32 dark:text-emerald-400\",\n  amber: \"border bg-background text-amber-600 dark:bg-input/32 dark:text-amber-400\",\n  violet: \"border bg-background text-violet-600 dark:bg-input/32 dark:text-violet-400\",\n  rose: \"border bg-background text-rose-600 dark:bg-input/32 dark:text-rose-400\",\n  teal: \"border bg-background text-teal-600 dark:bg-input/32 dark:text-teal-400\",\n};\n\nconst defaultCategories: HelpCategory[] = [\n  { id: \"start\", name: \"Getting started\", description: \"Set up your workspace and send your first invoice.\", icon: \"rocket\", tone: \"sky\" },\n  { id: \"payments\", name: \"Payments & payouts\", description: \"Get paid by card or bank transfer, and know when money lands.\", icon: \"payments\", tone: \"emerald\" },\n  { id: \"invoices\", name: \"Invoices & quotes\", description: \"Templates, reminders, taxes and credit notes.\", icon: \"invoices\", tone: \"amber\" },\n  { id: \"billing\", name: \"Plans & billing\", description: \"Change plan, update your card, download receipts.\", icon: \"billing\", tone: \"violet\" },\n  { id: \"security\", name: \"Account & security\", description: \"Two-factor, passkeys, sessions and data exports.\", icon: \"security\", tone: \"rose\" },\n  { id: \"integrations\", name: \"Integrations\", description: \"Connect accounting tools and bank feeds.\", icon: \"integrations\", tone: \"teal\" },\n];\n\nconst brief = (intro: string, heading: string, steps: string[], tail?: string): HelpBlock[] => [\n  { type: \"p\", text: intro },\n  { type: \"h2\", text: heading },\n  { type: \"steps\", items: steps },\n  ...(tail ? [{ type: \"p\", text: tail } as HelpBlock] : []),\n];\n\nconst defaultArticles: HelpArticle[] = [\n  {\n    id: \"payout-timing\",\n    title: \"How long do payouts take?\",\n    categoryId: \"payments\",\n    summary: \"Most payouts reach your bank in 2 business days. Timing depends on the payment method and your bank.\",\n    updated: \"Oct 12, 2026\",\n    minutes: 3,\n    popular: true,\n    body: [\n      { type: \"p\", text: \"Most payouts reach your bank in 2 business days. The exact timing depends on how your customer paid and where your bank is.\" },\n      { type: \"h2\", text: \"Payout timing by method\" },\n      {\n        type: \"list\",\n        items: [\n          \"Card payments: 2 business days after the payment clears.\",\n          \"Bank transfers (ACH or SEPA): 3 to 4 business days.\",\n          \"Instant payouts: within 30 minutes, for a 1% fee.\",\n        ],\n      },\n      { type: \"callout\", tone: \"info\", text: \"Payouts don't move on weekends or bank holidays. A payment made on Friday evening usually lands on Tuesday.\" },\n      { type: \"h2\", text: \"Check when a payout will arrive\" },\n      {\n        type: \"steps\",\n        items: [\n          \"Open Payments in the sidebar.\",\n          \"Select the Payouts tab.\",\n          \"Find the payout and check the Expected column. Hover the date to see which payments it includes.\",\n        ],\n      },\n      { type: \"h2\", text: \"If a payout is late\" },\n      {\n        type: \"p\",\n        text: \"If a payout hasn't arrived 2 business days after its expected date, check your bank details under Settings → Payouts, then contact us with the payout ID. It starts with po_.\",\n      },\n    ],\n  },\n  {\n    id: \"two-factor\",\n    title: \"Set up two-factor authentication\",\n    categoryId: \"security\",\n    summary: \"Add a second step at sign-in so a stolen password alone can't open your account.\",\n    updated: \"Sep 28, 2026\",\n    minutes: 2,\n    popular: true,\n    body: [\n      { type: \"p\", text: \"Two-factor authentication (2FA) asks for a second step when you sign in, so a stolen password alone can't get into your account.\" },\n      { type: \"h2\", text: \"Turn on 2FA\" },\n      {\n        type: \"steps\",\n        items: [\n          \"Go to Settings → Security.\",\n          \"Under Two-factor authentication, choose Authenticator app.\",\n          \"Scan the QR code with your app and enter the 6-digit code it shows.\",\n          \"Save your backup codes somewhere safe. Each one works once.\",\n        ],\n      },\n      { type: \"callout\", tone: \"warning\", text: \"If you lose your phone and your backup codes, we have to verify your identity before restoring access. That can take up to 3 business days.\" },\n      { type: \"h2\", text: \"Require 2FA for your team\" },\n      { type: \"p\", text: \"Owners and admins can make 2FA mandatory under Settings → Team → Security policy. Teammates without it are asked to set it up the next time they sign in.\" },\n    ],\n  },\n  {\n    id: \"reminders\",\n    title: \"Send automatic payment reminders\",\n    categoryId: \"invoices\",\n    summary: \"Choose when reminders go out before and after the due date, and what they say.\",\n    updated: \"Oct 3, 2026\",\n    minutes: 2,\n    popular: true,\n    body: [\n      { type: \"p\", text: \"Reminders go out on a schedule you choose, so you don't have to chase late invoices yourself.\" },\n      { type: \"h2\", text: \"Set a reminder schedule\" },\n      {\n        type: \"steps\",\n        items: [\n          \"Open Invoices → Settings → Reminders.\",\n          \"Pick when reminders go out: before the due date, on it, and after it.\",\n          \"Edit the message for each reminder, or keep the default wording.\",\n          \"Click Save. The schedule applies to every new invoice.\",\n        ],\n      },\n      { type: \"h2\", text: \"Turn reminders off for one customer\" },\n      { type: \"p\", text: \"Open the customer, choose Edit, and switch off Send payment reminders. Invoices already sent keep their schedule until you pause them.\" },\n      { type: \"callout\", tone: \"info\", text: \"Reminders stop automatically as soon as an invoice is paid in full.\" },\n    ],\n  },\n  {\n    id: \"declined\",\n    title: \"Why was a payment declined?\",\n    categoryId: \"payments\",\n    summary: \"The customer's bank made the call. Here's what each decline reason means and how to retry.\",\n    updated: \"Oct 18, 2026\",\n    minutes: 3,\n    popular: true,\n    body: [\n      { type: \"p\", text: \"When a card payment is declined, the customer's bank made the call. We show the reason the bank gave on the payment's timeline.\" },\n      { type: \"h2\", text: \"Common reasons\" },\n      {\n        type: \"list\",\n        items: [\n          \"Insufficient funds: the customer should try another card or pay by bank transfer.\",\n          \"Do not honour: a generic refusal. The customer needs to call their bank.\",\n          \"Suspected fraud: the bank flagged it. Ask the customer to approve the charge in their banking app, then retry.\",\n        ],\n      },\n      { type: \"h2\", text: \"Retry a declined payment\" },\n      {\n        type: \"steps\",\n        items: [\n          \"Open the invoice.\",\n          \"Click Send payment link to email the customer a fresh link.\",\n          \"Or, if they asked you to, choose Retry card to charge the saved card again.\",\n        ],\n      },\n      { type: \"callout\", tone: \"warning\", text: \"Retrying the same card more than 3 times in 24 hours can get it blocked. Ask the customer first.\" },\n    ],\n  },\n  {\n    id: \"change-plan\",\n    title: \"Change or cancel your plan\",\n    categoryId: \"billing\",\n    summary: \"Upgrades apply right away. Downgrades and cancellations take effect at the end of your billing period.\",\n    updated: \"Aug 30, 2026\",\n    minutes: 2,\n    popular: true,\n    body: brief(\n      \"Upgrades apply right away and you're charged the difference for the rest of the period. Downgrades and cancellations take effect when the current period ends.\",\n      \"Change your plan\",\n      [\"Go to Settings → Plan & billing.\", \"Click Change plan and pick the new plan.\", \"Review the price change, then confirm.\"],\n      \"Cancelling keeps your data for 90 days, so you can come back without losing invoices or customers.\",\n    ),\n  },\n  {\n    id: \"invite-accountant\",\n    title: \"Invite your accountant\",\n    categoryId: \"start\",\n    summary: \"Give your accountant read-only access to invoices, payouts and reports. It doesn't use a paid seat.\",\n    updated: \"Sep 9, 2026\",\n    minutes: 1,\n    popular: true,\n    body: brief(\n      \"Accountants get read-only access to invoices, payouts and reports. The Accountant role is free and doesn't count towards your seats.\",\n      \"Send the invite\",\n      [\"Open Settings → Team.\", \"Click Invite and enter their email.\", \"Choose the Accountant role and send.\"],\n    ),\n  },\n  {\n    id: \"first-invoice\",\n    title: \"Create your first invoice\",\n    categoryId: \"start\",\n    summary: \"Add a customer, line items and a due date, then send it by email or share a link.\",\n    updated: \"Jul 22, 2026\",\n    minutes: 3,\n    body: brief(\n      \"An invoice needs a customer, at least one line item and a due date. Everything else is optional.\",\n      \"Create and send\",\n      [\"Click New → Invoice.\", \"Pick a customer or add a new one.\", \"Add line items, then set the due date.\", \"Click Send, or Copy link to share it yourself.\"],\n    ),\n  },\n  {\n    id: \"vat\",\n    title: \"Add VAT or sales tax to invoices\",\n    categoryId: \"invoices\",\n    summary: \"Save tax rates once and apply them per line item. Totals and tax summaries update automatically.\",\n    updated: \"Oct 1, 2026\",\n    minutes: 2,\n    body: brief(\n      \"Save each tax rate once, then apply it to any line item. Invoice totals and the tax summary update as you go.\",\n      \"Add a tax rate\",\n      [\"Go to Invoices → Settings → Taxes.\", \"Click Add rate, name it (for example “VAT 20%”) and enter the percentage.\", \"On any invoice, pick the rate from the Tax column.\"],\n    ),\n  },\n  {\n    id: \"bank-feed\",\n    title: \"Connect a bank feed\",\n    categoryId: \"integrations\",\n    summary: \"Match incoming payments to invoices automatically by connecting your business bank account.\",\n    updated: \"Sep 17, 2026\",\n    minutes: 2,\n    body: brief(\n      \"A bank feed brings in transactions every few hours so we can match them to open invoices for you.\",\n      \"Connect your bank\",\n      [\"Open Integrations → Bank feeds.\", \"Search for your bank and sign in through its secure page.\", \"Pick the accounts to sync. The first import covers 90 days.\"],\n    ),\n  },\n  {\n    id: \"receipts\",\n    title: \"Download receipts and tax invoices\",\n    categoryId: \"billing\",\n    summary: \"Every charge has a PDF receipt. You can also add your tax ID so it appears on them.\",\n    updated: \"Aug 4, 2026\",\n    minutes: 1,\n    body: brief(\n      \"Every charge for your plan has a receipt you can download as a PDF.\",\n      \"Find a receipt\",\n      [\"Go to Settings → Plan & billing.\", \"Scroll to Billing history.\", \"Click Download next to the charge.\"],\n      \"To show your tax ID on receipts, add it under Billing details. It applies to future receipts only.\",\n    ),\n  },\n  {\n    id: \"passkey\",\n    title: \"Sign in with a passkey\",\n    categoryId: \"security\",\n    summary: \"Use your fingerprint, face or device PIN instead of a password.\",\n    updated: \"Oct 20, 2026\",\n    minutes: 1,\n    body: brief(\n      \"Passkeys let you sign in with your fingerprint, face or device PIN. They can't be phished or reused.\",\n      \"Add a passkey\",\n      [\"Go to Settings → Security.\", \"Under Passkeys, click Add passkey.\", \"Follow your device's prompt to confirm.\"],\n    ),\n  },\n  {\n    id: \"accounting-sync\",\n    title: \"Sync invoices to your accounting software\",\n    categoryId: \"integrations\",\n    summary: \"Invoices, payments and fees sync both ways, every 15 minutes.\",\n    updated: \"Sep 25, 2026\",\n    minutes: 3,\n    body: brief(\n      \"Once connected, invoices, payments and fees sync both ways every 15 minutes.\",\n      \"Turn on sync\",\n      [\"Open Integrations and choose your accounting tool.\", \"Sign in and approve access.\", \"Map your income and fee accounts, then click Start syncing.\"],\n    ),\n  },\n  {\n    id: \"refund\",\n    title: \"Issue a refund or credit note\",\n    categoryId: \"invoices\",\n    summary: \"Refund all or part of a payment. A credit note is created for your records automatically.\",\n    updated: \"Oct 9, 2026\",\n    minutes: 2,\n    body: brief(\n      \"You can refund all or part of a card payment. We create a matching credit note so your books stay balanced.\",\n      \"Refund a payment\",\n      [\"Open the paid invoice.\", \"Click Refund and enter the amount.\", \"Add a reason (the customer sees it) and confirm.\"],\n      \"Refunds take 5 to 10 business days to reach the customer's card.\",\n    ),\n  },\n  {\n    id: \"payout-account\",\n    title: \"Update your payout bank account\",\n    categoryId: \"payments\",\n    summary: \"Change where payouts go. Pending payouts still go to the old account.\",\n    updated: \"Sep 2, 2026\",\n    minutes: 1,\n    body: brief(\n      \"You can change the bank account payouts go to at any time. Payouts already on their way still go to the old account.\",\n      \"Change the account\",\n      [\"Go to Settings → Payouts.\", \"Click Change next to your bank account.\", \"Enter the new details and confirm with your 2FA code.\"],\n    ),\n  },\n];\n\nfunction slug(s: string) {\n  return s.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/(^-|-$)/g, \"\");\n}\n\nfunction Mark({ text, query }: { text: string; query: string }) {\n  const words = query.trim().toLowerCase().split(/\\s+/).filter((w) => w.length > 1);\n  if (!words.length) return <>{text}</>;\n  const re = new RegExp(`(${words.map((w) => w.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")).join(\"|\")})`, \"gi\");\n  return (\n    <>\n      {text.split(re).map((part, i) =>\n        i % 2 ? (\n          <mark className=\"rounded-[calc(var(--radius)*0.3)] bg-warning/25 text-foreground\" key={i}>\n            {part}\n          </mark>\n        ) : (\n          part\n        ),\n      )}\n    </>\n  );\n}\n\nfunction score(a: HelpArticle, query: string) {\n  const words = query.trim().toLowerCase().split(/\\s+/).filter(Boolean);\n  if (!words.length) return 0;\n  const title = a.title.toLowerCase();\n  const text = `${a.summary} ${a.body.map((b) => (\"text\" in b ? b.text : b.items.join(\" \"))).join(\" \")}`.toLowerCase();\n  let s = 0;\n  for (const w of words) {\n    if (title.includes(w)) s += 3;\n    else if (text.includes(w)) s += 1;\n    else return 0;\n  }\n  return s;\n}\n\nfunction search(articles: HelpArticle[], query: string) {\n  return articles\n    .map((a) => ({ a, s: score(a, query) }))\n    .filter((x) => x.s > 0)\n    .sort((x, y) => y.s - x.s)\n    .map((x) => x.a);\n}\n\ntype View =\n  | { name: \"home\" }\n  | { name: \"category\"; id: string }\n  | { name: \"results\"; query: string }\n  | { name: \"article\"; id: string };\n\nfunction SearchBox({\n  articles,\n  categories,\n  onOpen,\n  onSearch,\n  size,\n  initial = \"\",\n}: {\n  articles: HelpArticle[];\n  categories: HelpCategory[];\n  onOpen: (id: string) => void;\n  onSearch: (q: string) => void;\n  size: \"hero\" | \"compact\";\n  initial?: string;\n}) {\n  const [query, setQuery] = useState(initial);\n  const [open, setOpen] = useState(false);\n  const [active, setActive] = useState(-1);\n  const listId = useId();\n  const reduce = useReducedMotionAfterMount();\n  const results = search(articles, query).slice(0, 5);\n  const showList = open && query.trim().length > 0;\n\n  useEffect(() => setActive(-1), [query]);\n\n  const commit = () => {\n    if (active >= 0 && results[active]) onOpen(results[active].id);\n    else if (query.trim()) onSearch(query.trim());\n    setOpen(false);\n  };\n\n  const hero = size === \"hero\";\n\n  return (\n    <div\n      className=\"relative w-full\"\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node)) setOpen(false);\n      }}\n    >\n      <div\n        className={cn(\n          \"relative flex items-center rounded-xl border border-input bg-background text-foreground shadow-xs/5 transition-shadow has-focus-visible:border-ring has-focus-visible:ring-[3px] has-focus-visible:ring-ring/24 dark:bg-input/32\",\n          hero ? \"h-12 @lg:h-13\" : \"h-9\",\n        )}\n      >\n        <SearchIcon className={cn(\"pointer-events-none absolute text-muted-foreground\", hero ? \"left-4 size-4.5\" : \"left-3 size-4\")} />\n        <input\n          aria-activedescendant={active >= 0 ? `${listId}-${active}` : undefined}\n          aria-autocomplete=\"list\"\n          aria-controls={listId}\n          aria-expanded={showList}\n          aria-label=\"Search help articles\"\n          className={cn(\n            \"size-full min-w-0 bg-transparent outline-none placeholder:text-muted-foreground/72 [&::-webkit-search-cancel-button]:hidden\",\n            hero ? \"ps-11 pe-11 text-base\" : \"ps-9 pe-8 text-sm\",\n          )}\n          onChange={(e) => {\n            setQuery(e.target.value);\n            setOpen(true);\n          }}\n          onFocus={() => setOpen(true)}\n          onKeyDown={(e) => {\n            if (e.key === \"ArrowDown\") {\n              e.preventDefault();\n              setOpen(true);\n              setActive((a) => Math.min(results.length - 1, a + 1));\n            } else if (e.key === \"ArrowUp\") {\n              e.preventDefault();\n              setActive((a) => Math.max(-1, a - 1));\n            } else if (e.key === \"Enter\") {\n              e.preventDefault();\n              commit();\n            } else if (e.key === \"Escape\") {\n              if (showList) setOpen(false);\n              else setQuery(\"\");\n            }\n          }}\n          placeholder={hero ? \"Search for answers, e.g. “payout”\" : \"Search help\"}\n          role=\"combobox\"\n          type=\"search\"\n          value={query}\n        />\n        {query ? (\n          <button\n            aria-label=\"Clear search\"\n            className={cn(\"absolute flex size-7 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground\", ring, hero ? \"right-3\" : \"right-1\")}\n            onClick={() => setQuery(\"\")}\n            type=\"button\"\n          >\n            <XIcon className=\"size-4\" />\n          </button>\n        ) : (\n          hero && <Kbd className=\"absolute right-4 hidden @lg:inline-flex\">/</Kbd>\n        )}\n      </div>\n\n      <AnimatePresence>\n        {showList && (\n          <motion.div\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            className=\"absolute inset-x-0 top-full z-30 mt-2 origin-top overflow-hidden rounded-xl border bg-popover text-left text-popover-foreground shadow-lg/5\"\n            exit={{ opacity: 0, scale: 0.98, transition: { duration: 0.1 } }}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4, scale: 0.98 }}\n            transition={{ duration: 0.16, ease: easeOut }}\n          >\n            {results.length ? (\n              <ul className=\"p-1.5\" id={listId} role=\"listbox\">\n                {results.map((a, i) => {\n                  const cat = categories.find((c) => c.id === a.categoryId);\n                  return (\n                    <li aria-selected={active === i} id={`${listId}-${i}`} key={a.id} role=\"option\">\n                      <button\n                        className={cn(\"flex w-full cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2 text-left\", active === i ? \"bg-accent\" : \"hover:bg-accent/60\")}\n                        onClick={() => {\n                          onOpen(a.id);\n                          setOpen(false);\n                        }}\n                        onMouseEnter={() => setActive(i)}\n                        tabIndex={-1}\n                        type=\"button\"\n                      >\n                        <span className={cn(\"flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4\", cat && toneTile[cat.tone])}>\n                          {cat && icons[cat.icon]}\n                        </span>\n                        <span className=\"flex min-w-0 flex-1 flex-col\">\n                          <span className=\"truncate font-medium text-sm\">\n                            <Mark query={query} text={a.title} />\n                          </span>\n                          <span className=\"truncate text-muted-foreground text-xs\">{cat?.name}</span>\n                        </span>\n                        {active === i && <CornerDownLeftIcon className=\"size-3.5 shrink-0 text-muted-foreground\" />}\n                      </button>\n                    </li>\n                  );\n                })}\n              </ul>\n            ) : (\n              <div className=\"flex items-center gap-2.5 px-4 py-3.5 text-muted-foreground text-sm\" id={listId} role=\"listbox\">\n                <SearchXIcon className=\"size-4\" /> No articles match “{query.trim()}”\n              </div>\n            )}\n            <button\n              className=\"flex w-full cursor-pointer items-center justify-between gap-2 border-t px-4 py-2.5 text-muted-foreground text-xs hover:bg-accent/60 hover:text-foreground\"\n              onClick={() => {\n                onSearch(query.trim());\n                setOpen(false);\n              }}\n              tabIndex={-1}\n              type=\"button\"\n            >\n              <span className=\"truncate\">\n                See all results for “<span className=\"font-medium text-foreground\">{query.trim()}</span>”\n              </span>\n              <Kbd>↵</Kbd>\n            </button>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nfunction ArticleRow({ article, category, query = \"\", onOpen }: { article: HelpArticle; category?: HelpCategory; query?: string; onOpen: () => void }) {\n  return (\n    <li>\n      <button\n        className={cn(\"group/row flex w-full cursor-pointer items-start gap-3 rounded-xl px-3 py-3 text-left hover:bg-accent/60\", ring, press, \"active:scale-[0.99]\")}\n        onClick={onOpen}\n        type=\"button\"\n      >\n        <FileTextIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground\" />\n        <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n          <span className=\"font-medium\">\n            <Mark query={query} text={article.title} />\n          </span>\n          <span className=\"line-clamp-2 text-pretty text-muted-foreground text-xs leading-5\">\n            <Mark query={query} text={article.summary} />\n          </span>\n          {category && <span className=\"mt-1 text-muted-foreground text-xs\">{category.name}</span>}\n        </span>\n        <ChevronRightIcon className=\"mt-0.5 size-4 shrink-0 text-muted-foreground/60 transition-transform duration-150 ease-out [@media(hover:hover)]:group-hover/row:translate-x-0.5\" />\n      </button>\n    </li>\n  );\n}\n\nconst reasons = [\"Out of date\", \"Hard to follow\", \"Didn't fix my problem\", \"Something else\"];\n\nexport function HelpCentre({\n  className,\n  productName = \"Kite\",\n  categories = defaultCategories,\n  articles = defaultArticles,\n  popularSearches = [\"payouts\", \"2FA\", \"refund\", \"VAT\", \"cancel plan\"],\n  replyTime = \"4 min\",\n}: HelpCentreProps) {\n  const reduce = useReducedMotionAfterMount();\n  const [view, setView] = useState<View>({ name: \"home\" });\n  const [feedback, setFeedback] = useState<Record<string, { vote: \"up\" | \"down\"; reason?: string; note?: string; sent?: boolean }>>({});\n  const [activeHeading, setActiveHeading] = useState<string | null>(null);\n  const [contact, setContact] = useState<null | \"form\" | \"sent\">(null);\n  const [contactTopic, setContactTopic] = useState(\"Payments & payouts\");\n  const [contactMsg, setContactMsg] = useState(\"\");\n  const [contactError, setContactError] = useState(false);\n  const [heroKey, setHeroKey] = useState(0);\n  const scrollRef = useRef<HTMLDivElement>(null);\n  const articleRef = useRef<HTMLElement>(null);\n  const msgRef = useRef<HTMLTextAreaElement>(null);\n\n  useEffect(() => {\n    if (contact === \"form\") msgRef.current?.focus({ preventScroll: true });\n  }, [contact]);\n\n  const go = (v: View) => {\n    setView(v);\n    scrollRef.current?.scrollTo({ top: 0 });\n  };\n\n  const cat = (id: string) => categories.find((c) => c.id === id);\n  const count = (id: string) => articles.filter((a) => a.categoryId === id).length;\n  const article = view.name === \"article\" ? articles.find((a) => a.id === view.id) : undefined;\n  const headings = article ? article.body.filter((b) => b.type === \"h2\").map((b) => (b as { text: string }).text) : [];\n\n  useEffect(() => {\n    const box = scrollRef.current;\n    if (!box || !article) return;\n    const onScroll = () => {\n      const els = Array.from(box.querySelectorAll<HTMLElement>(\"[data-heading]\"));\n      const top = box.getBoundingClientRect().top + 96;\n      let current: string | null = els[0]?.dataset.heading ?? null;\n      for (const el of els) if (el.getBoundingClientRect().top <= top) current = el.dataset.heading ?? current;\n      if (box.scrollTop + box.clientHeight >= box.scrollHeight - 4 && els.length) current = els[els.length - 1].dataset.heading ?? current;\n      setActiveHeading(current);\n    };\n    onScroll();\n    box.addEventListener(\"scroll\", onScroll, { passive: true });\n    return () => box.removeEventListener(\"scroll\", onScroll);\n  }, [article]);\n\n  const jumpTo = (h: string) => {\n    const box = scrollRef.current;\n    const el = box?.querySelector<HTMLElement>(`[data-heading=\"${slug(h)}\"]`);\n    if (!box || !el) return;\n    box.scrollTo({ top: el.offsetTop - 24, behavior: reduce ? \"auto\" : \"smooth\" });\n  };\n\n  const openContact = () => {\n    setContact(\"form\");\n    setContactError(false);\n    if (article) setContactTopic(cat(article.categoryId)?.name ?? contactTopic);\n  };\n\n  const crumbs = (items: { label: string; onClick?: () => void }[]) => {\n    const parent = [...items].reverse().find((c) => c.onClick && c !== items[items.length - 1]);\n    return (\n    <>\n    {parent && (\n      <button\n        className={cn(\"-ms-1 flex w-fit cursor-pointer items-center gap-0.5 rounded text-muted-foreground text-xs hover:text-foreground @lg:hidden\", ring)}\n        onClick={parent.onClick}\n        type=\"button\"\n      >\n        <ChevronLeftIcon className=\"size-4\" /> {parent.label}\n      </button>\n    )}\n    <nav aria-label=\"Breadcrumb\" className=\"hidden min-w-0 items-center gap-1 text-muted-foreground text-xs @lg:flex\">\n      {items.map((c, i) => (\n        <span className=\"flex min-w-0 items-center gap-1\" key={c.label}>\n          {i > 0 && <ChevronRightIcon className=\"size-3.5 shrink-0 opacity-60\" />}\n          {c.onClick ? (\n            <button className={cn(\"cursor-pointer truncate rounded hover:text-foreground\", ring)} onClick={c.onClick} type=\"button\">\n              {c.label}\n            </button>\n          ) : (\n            <span aria-current=\"page\" className=\"truncate text-foreground\">\n              {c.label}\n            </span>\n          )}\n        </span>\n      ))}\n    </nav>\n    </>\n    );\n  };\n\n  const rail = (activeCat?: string, activeArticle?: string) => (\n    <nav aria-label=\"Topics\" className=\"sticky top-0 hidden w-52 shrink-0 self-start pt-11 @4xl:block\">\n      <p className=\"mb-2 px-2 font-medium text-xs\">Topics</p>\n      <ul className=\"flex flex-col gap-px\">\n        {categories.map((tc) => {\n          const on = tc.id === activeCat;\n          const inCat = on && activeArticle ? articles.filter((a) => a.categoryId === tc.id) : [];\n          return (\n            <li key={tc.id}>\n              <button\n                aria-current={on && !activeArticle ? \"page\" : undefined}\n                className={cn(\n                  \"flex h-8 w-full cursor-pointer items-center gap-2.5 rounded-md px-2 text-left [&_svg]:size-4\",\n                  ring,\n                  on ? \"bg-accent font-medium text-foreground\" : \"text-muted-foreground hover:bg-accent/60 hover:text-foreground\",\n                )}\n                onClick={() => go({ name: \"category\", id: tc.id })}\n                type=\"button\"\n              >\n                <span className={cn(\"shrink-0\", on ? \"text-foreground\" : \"opacity-80\")}>{icons[tc.icon]}</span>\n                <span className=\"truncate\">{tc.name}</span>\n              </button>\n              {inCat.length > 0 && (\n                <ul className=\"my-1 ms-4 flex flex-col border-l ps-2\">\n                  {inCat.map((a) => (\n                    <li key={a.id}>\n                      <button\n                        aria-current={a.id === activeArticle ? \"page\" : undefined}\n                        className={cn(\n                          \"w-full cursor-pointer rounded-md px-2 py-1.5 text-left text-xs leading-5\",\n                          ring,\n                          a.id === activeArticle ? \"font-medium text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n                        )}\n                        onClick={() => go({ name: \"article\", id: a.id })}\n                        type=\"button\"\n                      >\n                        {a.title}\n                      </button>\n                    </li>\n                  ))}\n                </ul>\n              )}\n            </li>\n          );\n        })}\n      </ul>\n    </nav>\n  );\n\n  const contactCard = (\n    <section className=\"flex flex-col gap-4 rounded-xl border bg-card p-5 @2xl:flex-row @2xl:items-center\">\n      <span className=\"flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground\">\n        <LifeBuoyIcon className=\"size-5\" />\n      </span>\n      <div className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n        <h2 className=\"font-heading font-semibold\">Still stuck?</h2>\n        <p className=\"text-pretty text-muted-foreground\">\n          Our support team replies in about <span className=\"font-medium text-foreground tabular-nums\">{replyTime}</span> on weekdays.\n        </p>\n      </div>\n      <div className=\"flex gap-2\">\n        <Button className={press} onClick={openContact}>\n          <MessageCircleIcon /> Contact support\n        </Button>\n      </div>\n    </section>\n  );\n\n  let body: ReactNode;\n  if (view.name === \"home\") {\n    const popular = articles.filter((a) => a.popular);\n    body = (\n      <>\n        <section className=\"border-b bg-muted/30 px-4 pt-12 pb-10 @2xl:pt-16 @2xl:pb-14\">\n          <div className=\"mx-auto flex max-w-xl flex-col items-center gap-5 text-center\">\n            <div className=\"flex flex-col gap-1.5\">\n              <h1 className=\"text-balance font-heading font-semibold text-2xl tracking-tight @2xl:text-3xl\">How can we help?</h1>\n              <p className=\"text-pretty text-muted-foreground\">\n                Search {articles.length} guides from the {productName} team, or browse by topic.\n              </p>\n            </div>\n            <SearchBox articles={articles} categories={categories} key={heroKey} onOpen={(id) => go({ name: \"article\", id })} onSearch={(q) => go({ name: \"results\", query: q })} size=\"hero\" />\n            <div className=\"flex flex-wrap items-center justify-center gap-1.5 text-xs\">\n              <span className=\"text-muted-foreground\">Popular:</span>\n              {popularSearches.map((p) => (\n                <button\n                  className={cn(\"h-7 cursor-pointer rounded-full border bg-background px-2.5 text-muted-foreground hover:border-foreground/20 hover:text-foreground dark:bg-input/32\", ring, press)}\n                  key={p}\n                  onClick={() => go({ name: \"results\", query: p })}\n                  type=\"button\"\n                >\n                  {p}\n                </button>\n              ))}\n            </div>\n          </div>\n        </section>\n\n        <div className=\"mx-auto flex w-full max-w-5xl flex-col gap-10 px-4 py-10 @2xl:px-8\">\n          <section aria-labelledby=\"hc-cats\" className=\"flex flex-col gap-3\">\n            <h2 className=\"font-medium\" id=\"hc-cats\">\n              Browse by topic\n            </h2>\n            <ul className=\"grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-3\">\n              {categories.map((c, i) => (\n                <motion.li\n                  animate={{ opacity: 1, y: 0 }}\n                  initial={reduce ? false : { opacity: 0, y: 6 }}\n                  key={c.id}\n                  transition={{ duration: 0.25, ease: easeOut, delay: Math.min(i, 6) * 0.03 }}\n                >\n                  <button\n                    className={cn(\n                      \"group/cat flex h-full w-full cursor-pointer items-start gap-3.5 rounded-xl border bg-card p-4 text-left hover:border-foreground/16 hover:bg-accent/32\",\n                      ring,\n                      press,\n                      \"active:scale-[0.98]\",\n                    )}\n                    onClick={() => go({ name: \"category\", id: c.id })}\n                    type=\"button\"\n                  >\n                    <span className={cn(\"flex size-9 shrink-0 items-center justify-center rounded-lg shadow-xs/5 [&_svg]:size-4\", toneTile[c.tone])}>{icons[c.icon]}</span>\n                    <span className=\"flex min-w-0 flex-1 flex-col gap-1\">\n                      <span className=\"flex items-center justify-between gap-2 font-medium\">\n                        {c.name}\n                        <ArrowRightIcon className=\"size-4 shrink-0 text-muted-foreground/0 transition-[color,translate] duration-150 ease-out [@media(hover:hover)]:group-hover/cat:translate-x-0.5 [@media(hover:hover)]:group-hover/cat:text-muted-foreground\" />\n                      </span>\n                      <span className=\"text-muted-foreground text-xs leading-5\">{c.description}</span>\n                      <span className=\"mt-1 text-muted-foreground text-xs tabular-nums\">{count(c.id)} articles</span>\n                    </span>\n                  </button>\n                </motion.li>\n              ))}\n            </ul>\n          </section>\n\n          <section aria-labelledby=\"hc-popular\" className=\"flex flex-col gap-3\">\n            <h2 className=\"font-medium\" id=\"hc-popular\">\n              Popular articles\n            </h2>\n            <ul className=\"grid grid-cols-1 divide-y overflow-hidden rounded-xl border bg-card [&_button]:rounded-none [&_button]:px-4 @3xl:grid-cols-2 @3xl:divide-y-0 @3xl:[&>li:nth-child(n+3)]:border-t @3xl:[&>li:nth-child(even)]:border-s\">\n              {popular.map((a) => (\n                <ArticleRow article={a} category={cat(a.categoryId)} key={a.id} onOpen={() => go({ name: \"article\", id: a.id })} />\n              ))}\n            </ul>\n          </section>\n\n          {contactCard}\n        </div>\n      </>\n    );\n  } else if (view.name === \"category\" || view.name === \"results\") {\n    const c = view.name === \"category\" ? cat(view.id) : undefined;\n    const list = view.name === \"category\" ? articles.filter((a) => a.categoryId === view.id) : search(articles, view.query);\n    body = (\n      <div className=\"mx-auto flex w-full max-w-6xl gap-10 px-4 py-8 @2xl:px-8 @2xl:py-10\">\n        {rail(c?.id)}\n        <div className=\"flex min-w-0 max-w-2xl flex-1 flex-col\">\n          {crumbs([{ label: \"Help Centre\", onClick: () => go({ name: \"home\" }) }, { label: c ? c.name : \"Search\" }])}\n          <div className=\"mt-5 flex items-start gap-4 border-b pb-6\">\n            {c && <span className={cn(\"flex size-10 shrink-0 items-center justify-center rounded-lg shadow-xs/5 [&_svg]:size-5\", toneTile[c.tone])}>{icons[c.icon]}</span>}\n            <div className=\"flex min-w-0 flex-col gap-1\">\n              <h1 className=\"text-balance font-heading font-semibold text-2xl tracking-tight\">\n                {c ? c.name : <>Results for “{view.name === \"results\" ? view.query : \"\"}”</>}\n              </h1>\n              <p className=\"text-pretty text-muted-foreground\">{c ? c.description : `${list.length} ${list.length === 1 ? \"article\" : \"articles\"} found`}</p>\n              {c && <p className=\"mt-1 text-muted-foreground text-xs tabular-nums\">{list.length} {list.length === 1 ? \"article\" : \"articles\"} · updated {list[0]?.updated ?? \"recently\"}</p>}\n            </div>\n          </div>\n          {list.length ? (\n            <ul className=\"mt-6 divide-y overflow-hidden rounded-xl border bg-card [&_button]:rounded-none [&_button]:px-4\">\n              {list.map((a) => (\n                <ArticleRow\n                  article={a}\n                  category={view.name === \"results\" ? cat(a.categoryId) : undefined}\n                  key={a.id}\n                  onOpen={() => go({ name: \"article\", id: a.id })}\n                  query={view.name === \"results\" ? view.query : \"\"}\n                />\n              ))}\n            </ul>\n          ) : (\n            <div className=\"mt-6 flex flex-col items-center gap-4 rounded-xl border border-dashed px-6 py-12 text-center\">\n              <span className=\"flex size-10 items-center justify-center rounded-lg border bg-background text-muted-foreground shadow-xs/5 dark:bg-input/32\">\n                <SearchXIcon className=\"size-4.5\" />\n              </span>\n              <div className=\"flex max-w-xs flex-col gap-1\">\n                <span className=\"font-medium\">Nothing matched that</span>\n                <span className=\"text-pretty text-muted-foreground text-xs\">Try fewer or different words, or ask us directly. A person reads every message.</span>\n              </div>\n              <div className=\"flex gap-2\">\n                <Button className={press} onClick={() => go({ name: \"home\" })} size=\"sm\" variant=\"outline\">\n                  Browse topics\n                </Button>\n                <Button className={press} onClick={openContact} size=\"sm\">\n                  Contact support\n                </Button>\n              </div>\n            </div>\n          )}\n          <div className=\"mt-10\">{contactCard}</div>\n        </div>\n      </div>\n    );\n  } else if (article) {\n    const c = cat(article.categoryId);\n    const fb = feedback[article.id];\n    const related = articles.filter((a) => a.categoryId === article.categoryId && a.id !== article.id).slice(0, 3);\n    let step = 0;\n    body = (\n      <div className=\"mx-auto flex w-full max-w-6xl gap-10 px-4 py-8 @2xl:px-8 @2xl:py-10\">\n        {rail(article.categoryId, article.id)}\n        <article className=\"flex min-w-0 max-w-2xl flex-1 flex-col\" ref={articleRef}>\n          {crumbs([\n            { label: \"Help Centre\", onClick: () => go({ name: \"home\" }) },\n            { label: c?.name ?? \"\", onClick: () => go({ name: \"category\", id: article.categoryId }) },\n            { label: article.title },\n          ])}\n          <header className=\"mt-5 border-b pb-6\">\n            <h1 className=\"text-balance font-heading font-semibold text-2xl tracking-tight @2xl:text-3xl\">{article.title}</h1>\n            <div className=\"mt-4 flex flex-wrap items-center gap-x-3 gap-y-2 text-muted-foreground text-xs\">\n              <span className=\"flex items-center gap-2\">\n                <span className=\"flex size-6 items-center justify-center rounded-full bg-foreground font-medium text-[10px] text-background\">\n                  {productName.slice(0, 1)}\n                </span>\n                <span>\n                  Written by <span className=\"font-medium text-foreground\">{productName} Support</span>\n                </span>\n              </span>\n              <span aria-hidden className=\"text-border\">\n                |\n              </span>\n              <span>Updated {article.updated}</span>\n              <span className=\"flex items-center gap-1 tabular-nums\">\n                <ClockIcon className=\"size-3.5\" /> {article.minutes} min read\n              </span>\n            </div>\n          </header>\n\n          <div className=\"mt-6 flex flex-col gap-4 text-[15px] text-foreground/90 leading-7\">\n            {article.body.map((b, i) => {\n              if (b.type === \"p\") return <p className=\"text-pretty\" key={i}>{b.text}</p>;\n              if (b.type === \"h2\")\n                return (\n                  <h2\n                    className=\"mt-6 scroll-mt-6 font-heading font-semibold text-foreground text-lg tracking-tight first:mt-0\"\n                    data-heading={slug(b.text)}\n                    id={`hc-${slug(b.text)}`}\n                    key={i}\n                  >\n                    {b.text}\n                  </h2>\n                );\n              if (b.type === \"list\")\n                return (\n                  <ul className=\"flex flex-col gap-2\" key={i}>\n                    {b.items.map((it) => {\n                      const [lead, ...rest] = it.split(\": \");\n                      return (\n                        <li className=\"flex gap-3\" key={it}>\n                          <span aria-hidden className=\"mt-[0.7rem] size-1.5 shrink-0 rounded-full bg-foreground/40\" />\n                          <span className=\"text-pretty\">\n                            {rest.length ? (\n                              <>\n                                <span className=\"font-medium text-foreground\">{lead}:</span> {rest.join(\": \")}\n                              </>\n                            ) : (\n                              it\n                            )}\n                          </span>\n                        </li>\n                      );\n                    })}\n                  </ul>\n                );\n              if (b.type === \"steps\") {\n                step = 0;\n                return (\n                  <ol className=\"flex flex-col gap-3.5\" key={i}>\n                    {b.items.map((it) => {\n                      step += 1;\n                      return (\n                        <li className=\"relative flex gap-3.5\" key={it}>\n                          <span className=\"flex size-6 shrink-0 items-center justify-center rounded-full border bg-background font-medium text-xs tabular-nums shadow-xs/5\">\n                            {step}\n                          </span>\n                          <span className=\"text-pretty pt-px leading-6\">{it}</span>\n                        </li>\n                      );\n                    })}\n                  </ol>\n                );\n              }\n              return (\n                <div\n                  className={cn(\n                    \"flex gap-3 rounded-lg border-s-2 px-4 py-3 text-sm leading-6\",\n                    b.tone === \"info\" ? \"border-info bg-info/6 dark:bg-info/10\" : \"border-warning bg-warning/8 dark:bg-warning/10\",\n                  )}\n                  key={i}\n                  role=\"note\"\n                >\n                  {b.tone === \"info\" ? (\n                    <InfoIcon className=\"mt-1 size-4 shrink-0 text-info-foreground\" />\n                  ) : (\n                    <CircleAlertIcon className=\"mt-1 size-4 shrink-0 text-warning-foreground\" />\n                  )}\n                  <p className=\"text-pretty\">{b.text}</p>\n                </div>\n              );\n            })}\n          </div>\n\n          <section aria-label=\"Article feedback\" className=\"mt-12 border-t pt-6\">\n            <AnimatePresence initial={false} mode=\"popLayout\">\n              {fb?.sent || fb?.vote === \"up\" ? (\n                <motion.div\n                  animate={{ opacity: 1, scale: 1 }}\n                  className=\"flex items-center gap-3\"\n                  initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.98 }}\n                  key=\"thanks\"\n                  transition={{ duration: 0.2, ease: easeOut }}\n                >\n                  <span className=\"flex size-8 shrink-0 items-center justify-center rounded-full bg-success/12 text-success-foreground\">\n                    <CheckIcon className=\"size-4\" />\n                  </span>\n                  <div className=\"flex flex-col\">\n                    <span className=\"font-medium\">{fb.vote === \"up\" ? \"Glad it helped.\" : \"Thanks, we'll use this to fix the article.\"}</span>\n                    <span className=\"text-muted-foreground text-xs\">\n                      {fb.vote === \"up\" ? \"Your vote helps others find the right answer.\" : \"The docs team reviews every note within a week.\"}\n                    </span>\n                  </div>\n                </motion.div>\n              ) : (\n                <motion.div\n                  className=\"flex flex-col gap-4\"\n                  exit={{ opacity: 0, scale: 0.98, transition: { duration: 0.12 } }}\n                  key=\"ask\"\n                  layout={reduce ? false : \"size\"}\n                  transition={spring}\n                >\n                  <div className=\"flex flex-wrap items-center justify-between gap-3\">\n                    <span className=\"font-medium\">Did this answer your question?</span>\n                    <div className=\"flex gap-2\">\n                      <Button\n                        aria-pressed={false}\n                        className={press}\n                        onClick={() => setFeedback((f) => ({ ...f, [article.id]: { vote: \"up\" } }))}\n                        size=\"sm\"\n                        variant=\"outline\"\n                      >\n                        <ThumbsUpIcon /> Yes\n                      </Button>\n                      <Button\n                        aria-pressed={fb?.vote === \"down\"}\n                        className={cn(press, fb?.vote === \"down\" && \"border-foreground/30 bg-accent\")}\n                        onClick={() => setFeedback((f) => ({ ...f, [article.id]: { vote: \"down\" } }))}\n                        size=\"sm\"\n                        variant=\"outline\"\n                      >\n                        <ThumbsDownIcon /> No\n                      </Button>\n                    </div>\n                  </div>\n                  {fb?.vote === \"down\" && (\n                    <motion.form\n                      animate={{ opacity: 1, y: 0 }}\n                      className=\"flex flex-col gap-3\"\n                      initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n                      onSubmit={(e) => {\n                        e.preventDefault();\n                        setFeedback((f) => ({ ...f, [article.id]: { ...f[article.id], sent: true } }));\n                      }}\n                      transition={{ duration: 0.2, ease: easeOut }}\n                    >\n                      <fieldset className=\"flex flex-col gap-2\">\n                        <legend className=\"mb-2 text-muted-foreground text-xs\">What went wrong?</legend>\n                        <div className=\"flex flex-wrap gap-1.5\">\n                          {reasons.map((r) => {\n                            const on = fb.reason === r;\n                            return (\n                              <button\n                                aria-pressed={on}\n                                className={cn(\n                                  \"h-8 cursor-pointer rounded-full border px-3 text-xs\",\n                                  ring,\n                                  press,\n                                  on ? \"border-primary bg-primary text-primary-foreground\" : \"bg-background text-foreground hover:bg-accent dark:bg-input/32\",\n                                )}\n                                key={r}\n                                onClick={() => setFeedback((f) => ({ ...f, [article.id]: { ...f[article.id], reason: r } }))}\n                                type=\"button\"\n                              >\n                                {r}\n                              </button>\n                            );\n                          })}\n                        </div>\n                      </fieldset>\n                      <Textarea\n                        aria-label=\"Tell us more (optional)\"\n                        onChange={(e) => setFeedback((f) => ({ ...f, [article.id]: { ...f[article.id], note: e.target.value } }))}\n                        placeholder=\"Tell us more (optional)\"\n                        size=\"sm\"\n                        value={fb.note ?? \"\"}\n                      />\n                      <div className=\"flex items-center justify-end gap-2\">\n                        <Button className={press} onClick={() => setFeedback((f) => {\n                          const { [article.id]: _, ...rest } = f;\n                          return rest;\n                        })} size=\"sm\" type=\"button\" variant=\"ghost\">\n                          Cancel\n                        </Button>\n                        <Button className={press} disabled={!fb.reason} size=\"sm\" type=\"submit\">\n                          Send feedback\n                        </Button>\n                      </div>\n                    </motion.form>\n                  )}\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </section>\n\n          {related.length > 0 && (\n            <section aria-labelledby=\"hc-related\" className=\"mt-10 flex flex-col gap-3\">\n              <h2 className=\"font-medium\" id=\"hc-related\">\n                Related articles\n              </h2>\n              <ul className=\"divide-y overflow-hidden rounded-xl border bg-card [&_button]:rounded-none [&_button]:px-4\">\n                {related.map((a) => (\n                  <ArticleRow article={a} key={a.id} onOpen={() => go({ name: \"article\", id: a.id })} />\n                ))}\n              </ul>\n            </section>\n          )}\n\n          <div className=\"mt-10\">{contactCard}</div>\n        </article>\n\n        {headings.length > 1 && (\n          <aside className=\"sticky top-0 hidden w-44 shrink-0 self-start pt-11 @6xl:block\">\n            <h2 className=\"mb-2 font-medium text-xs\">On this page</h2>\n            <ul className=\"relative flex flex-col border-l\">\n              {headings.map((h) => {\n                const on = activeHeading === slug(h);\n                return (\n                  <li className=\"relative\" key={h}>\n                    {on && (\n                      <motion.span\n                        className=\"absolute inset-y-1 -left-px w-0.5 rounded-full bg-foreground\"\n                        layoutId=\"hc-toc\"\n                        transition={reduce ? { duration: 0 } : spring}\n                      />\n                    )}\n                    <button\n                      className={cn(\n                        \"w-full cursor-pointer rounded-r-md py-1.5 ps-3 text-left text-xs leading-5 transition-colors\",\n                        ring,\n                        on ? \"font-medium text-foreground\" : \"text-muted-foreground hover:text-foreground\",\n                      )}\n                      onClick={() => jumpTo(h)}\n                      type=\"button\"\n                    >\n                      {h}\n                    </button>\n                  </li>\n                );\n              })}\n            </ul>\n          </aside>\n        )}\n      </div>\n    );\n  }\n\n  const viewKey = view.name === \"article\" ? `a-${view.id}` : view.name === \"category\" ? `c-${view.id}` : view.name === \"results\" ? `r-${view.query}` : \"home\";\n\n  return (\n    <div\n      className={cn(\"@container relative isolate flex h-[760px] w-full flex-col overflow-hidden bg-background text-foreground text-sm\", className)}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && contact) setContact(null);\n        const t = e.target as HTMLElement;\n        if (e.key === \"/\" && !t.closest(\"input, textarea\")) {\n          e.preventDefault();\n          (e.currentTarget.querySelector('input[role=\"combobox\"]') as HTMLInputElement | null)?.focus();\n        }\n      }}\n    >\n      <header className=\"flex h-14 shrink-0 items-center gap-3 border-b px-4 @2xl:px-6\">\n        <button\n          className={cn(\"flex shrink-0 cursor-pointer items-center gap-2.5 rounded-lg\", ring)}\n          onClick={() => {\n            go({ name: \"home\" });\n            setHeroKey((k) => k + 1);\n          }}\n          type=\"button\"\n        >\n          <span className=\"flex size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground\">\n            <svg aria-hidden className=\"size-4\" fill=\"none\" viewBox=\"0 0 16 16\">\n              <path d=\"M8 1.5 14 8l-6 6.5L2 8z\" fill=\"currentColor\" opacity=\".9\" />\n              <path d=\"M8 1.5V14.5\" stroke=\"var(--primary)\" strokeWidth=\"1.2\" />\n            </svg>\n          </span>\n          <span className=\"font-heading font-semibold\">{productName}</span>\n          <span className=\"hidden text-muted-foreground @md:inline\">Help Centre</span>\n        </button>\n        {view.name !== \"home\" && (\n          <div className=\"ms-2 hidden w-full max-w-xs @3xl:block\">\n            <SearchBox\n              articles={articles}\n              categories={categories}\n              initial={view.name === \"results\" ? view.query : \"\"}\n              key={viewKey}\n              onOpen={(id) => go({ name: \"article\", id })}\n              onSearch={(q) => go({ name: \"results\", query: q })}\n              size=\"compact\"\n            />\n          </div>\n        )}\n        <div className=\"ms-auto flex items-center gap-2\">\n          <span className=\"hidden items-center gap-1.5 rounded-full border px-2.5 py-1 text-muted-foreground text-xs @2xl:flex\">\n            <span className=\"size-1.5 rounded-full bg-success\" /> All systems normal\n          </span>\n          {view.name !== \"home\" && (\n            <Button aria-label=\"Search\" className=\"@3xl:hidden\" onClick={() => go({ name: \"home\" })} size=\"icon-sm\" variant=\"ghost\">\n              <SearchIcon />\n            </Button>\n          )}\n          <Button className={press} onClick={openContact} size=\"sm\" variant=\"outline\">\n            <MailIcon /> <span className=\"hidden @md:inline\">Contact us</span>\n            <span className=\"@md:hidden\">Contact</span>\n          </Button>\n        </div>\n      </header>\n\n      <div className=\"min-h-0 flex-1 overflow-y-auto\" ref={scrollRef}>\n        <motion.div\n          animate={{ opacity: 1, y: 0 }}\n          initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6 }}\n          key={viewKey}\n          transition={{ duration: 0.2, ease: easeOut }}\n        >\n          {body}\n        </motion.div>\n      </div>\n\n      <AnimatePresence>\n        {contact && (\n          <>\n            <motion.div\n              animate={{ opacity: 1 }}\n              aria-hidden\n              className=\"absolute inset-0 z-40 bg-black/32\"\n              exit={{ opacity: 0 }}\n              initial={{ opacity: 0 }}\n              onClick={() => setContact(null)}\n              transition={{ duration: 0.2, ease: easeOut }}\n            />\n            <motion.div\n              animate={{ opacity: 1, y: 0, scale: 1 }}\n              aria-labelledby=\"hc-contact-title\"\n              aria-modal\n              className=\"absolute inset-x-3 bottom-3 z-50 mx-auto flex max-w-md flex-col gap-4 rounded-2xl border bg-popover p-5 text-popover-foreground shadow-lg/10 @2xl:top-24 @2xl:bottom-auto\"\n              exit={{ opacity: 0, y: 8, scale: 0.98, transition: { duration: 0.15, ease: easeOut } }}\n              initial={reduce ? { opacity: 0 } : { opacity: 0, y: 12, scale: 0.98 }}\n              role=\"dialog\"\n              transition={{ duration: 0.22, ease: easeOut }}\n            >\n              <div className=\"flex items-start gap-3\">\n                <div className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n                  <h2 className=\"font-heading font-semibold text-base\" id=\"hc-contact-title\">\n                    {contact === \"sent\" ? \"Message sent\" : \"Contact support\"}\n                  </h2>\n                  <p className=\"text-pretty text-muted-foreground text-xs\">\n                    {contact === \"sent\" ? \"We've emailed you a copy. Replies land in your inbox.\" : `A real person replies, usually within ${replyTime}.`}\n                  </p>\n                </div>\n                <Button aria-label=\"Close\" className=\"-me-2 -mt-1\" onClick={() => setContact(null)} size=\"icon-sm\" variant=\"ghost\">\n                  <XIcon />\n                </Button>\n              </div>\n              {contact === \"sent\" ? (\n                <motion.div\n                  animate={{ opacity: 1, scale: 1 }}\n                  className=\"flex flex-col items-center gap-3 rounded-xl bg-muted/60 px-4 py-6 text-center\"\n                  initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.97 }}\n                  transition={{ duration: 0.22, ease: easeOut }}\n                >\n                  <span className=\"flex size-10 items-center justify-center rounded-full bg-success/12 text-success-foreground\">\n                    <CheckIcon className=\"size-5\" />\n                  </span>\n                  <span className=\"font-medium\">\n                    Ticket <span className=\"font-mono\">#48213</span> is open\n                  </span>\n                  <Button className={press} onClick={() => setContact(null)} size=\"sm\" variant=\"outline\">\n                    Done\n                  </Button>\n                </motion.div>\n              ) : (\n                <form\n                  className=\"flex flex-col gap-4\"\n                  noValidate\n                  onSubmit={(e) => {\n                    e.preventDefault();\n                    if (contactMsg.trim().length < 10) {\n                      setContactError(true);\n                      msgRef.current?.focus();\n                      return;\n                    }\n                    setContact(\"sent\");\n                    setContactMsg(\"\");\n                  }}\n                >\n                  <fieldset className=\"flex flex-col gap-2\">\n                    <legend className=\"mb-2 font-medium text-xs\">Topic</legend>\n                    <div className=\"flex flex-wrap gap-1.5\">\n                      {categories.map((c) => {\n                        const on = contactTopic === c.name;\n                        return (\n                          <button\n                            aria-pressed={on}\n                            className={cn(\n                              \"h-8 cursor-pointer rounded-full border px-3 text-xs\",\n                              ring,\n                              press,\n                              on ? \"border-primary bg-primary text-primary-foreground\" : \"bg-background hover:bg-accent dark:bg-input/32\",\n                            )}\n                            key={c.id}\n                            onClick={() => setContactTopic(c.name)}\n                            type=\"button\"\n                          >\n                            {c.name}\n                          </button>\n                        );\n                      })}\n                    </div>\n                  </fieldset>\n                  <label className=\"flex flex-col gap-2\">\n                    <span className=\"font-medium text-xs\">How can we help?</span>\n                    <Textarea\n                      aria-describedby={contactError ? \"hc-contact-err\" : undefined}\n                      aria-invalid={contactError || undefined}\n                      onChange={(e) => {\n                        setContactMsg(e.target.value);\n                        if (contactError && e.target.value.trim().length >= 10) setContactError(false);\n                      }}\n                      placeholder=\"Describe what happened and what you expected. Include IDs like po_ or inv_ if you have them.\"\n                      ref={msgRef}\n                      value={contactMsg}\n                    />\n                    <AnimatePresence initial={false}>\n                      {contactError && (\n                        <motion.span\n                          animate={{ opacity: 1, height: \"auto\" }}\n                          className=\"overflow-hidden text-destructive-foreground text-xs\"\n                          exit={{ opacity: 0, height: 0 }}\n                          id=\"hc-contact-err\"\n                          initial={{ opacity: 0, height: 0 }}\n                          transition={{ duration: 0.18, ease: easeOut }}\n                        >\n                          Add a few more words so we can help on the first reply.\n                        </motion.span>\n                      )}\n                    </AnimatePresence>\n                  </label>\n                  <div className=\"flex items-center gap-2\">\n                    <Input aria-label=\"Your email\" className=\"flex-1\" defaultValue=\"maya@larkfield.studio\" type=\"email\" />\n                    <Button className={press} type=\"submit\">\n                      Send\n                    </Button>\n                  </div>\n                </form>\n              )}\n            </motion.div>\n          </>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n"
    }
  ]
}