{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "manifold",
  "type": "registry:block",
  "title": "Manifold",
  "description": "Integrations directory section block: searchable, Detent-filtered grid of seeded geometric app marks with badges and connected chips that re-flows on layout springs, a cursor-follow accent border glow, a featured hero row, and a detail sheet (side or bottom, focus-trapped) where a Conduit beam joins your app to the integration — async Connect carries light down the beam and morphs to Connected with a Disconnect ghost.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://crucibleui.com/r/detent.json",
    "https://crucibleui.com/r/conduit.json",
    "https://crucibleui.com/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/default/sections/manifold/manifold.tsx",
      "type": "registry:block",
      "target": "components/crucible/manifold.tsx",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, motion, useInView, type Transition, type Variants } from \"motion/react\";\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { Detent } from \"@/components/crucible/detent\";\nimport { Conduit } from \"@/components/crucible/conduit\";\n\n/* ---------------------------------------------------------------- types */\n\n/** Badge shown on a card. The three built-ins get distinct styles; any other string renders neutral. */\nexport type ManifoldBadge = \"Popular\" | \"New\" | \"Beta\" | (string & {});\n\n/** One integration in the directory. */\nexport interface ManifoldIntegration {\n  /** Stable unique id — passed to `onConnect` / `onDisconnect` and `open(id)`. */\n  id: string;\n  /** Display name. */\n  name: string;\n  /** Category name; drives the category tabs. */\n  category: string;\n  /** One-line description shown on the card and in the sheet. */\n  description: string;\n  /** Longer copy for the detail sheet. Falls back to `description`. */\n  about?: string;\n  /** Card badges, e.g. `[\"Popular\"]`, `[\"New\"]`, `[\"Beta\"]`. */\n  badges?: ManifoldBadge[];\n  /** Initial connected state (the block owns it afterwards; see `onConnectedChange`). */\n  connected?: boolean;\n  /** \"What you can do\" bullets in the detail sheet. */\n  features?: string[];\n  /** Permissions the integration requests, listed in the detail sheet. */\n  permissions?: string[];\n  /** Custom mark (e.g. your own SVG). Omit for a seeded geometric glyph. */\n  mark?: React.ReactNode;\n  /** Show this integration in the larger \"Featured\" hero row (first 3 used). */\n  featured?: boolean;\n}\n\n/** Imperative verbs exposed through the `ref` prop. */\nexport interface ManifoldHandle {\n  /** Replay the intro (header, featured row and grid cascade). */\n  replay: () => void;\n  /** Open the detail sheet for an integration id. */\n  open: (id: string) => void;\n  /** Close the detail sheet if open. */\n  close: () => void;\n}\n\nexport interface ManifoldProps extends Omit<React.ComponentPropsWithoutRef<\"section\">, \"children\" | \"title\"> {\n  /** Integrations to list. @default 24 seeded fictional integrations in 6 categories */\n  integrations?: ManifoldIntegration[];\n  /** Category tab order. @default categories in order of first appearance */\n  categories?: string[];\n  /** Section eyebrow. @default \"Integrations\" */\n  eyebrow?: React.ReactNode;\n  /** Section headline (`<h2>`). @default \"Plug into the tools you already use\" */\n  title?: React.ReactNode;\n  /** Supporting copy under the headline. */\n  subtitle?: React.ReactNode;\n  /** Label for the catch-all tab. @default \"All\" */\n  allLabel?: string;\n  /** Show the larger \"Featured\" hero row (integrations with `featured: true`). Hidden while searching. @default true */\n  showFeatured?: boolean;\n  /** Your product's mark, shown on the left of the connection beam. @default a neutral seeded mark */\n  appMark?: React.ReactNode;\n  /** Your product's name, shown under `appMark`. @default \"Your workspace\" */\n  appName?: string;\n  /**\n   * Called when Connect is pressed. Return a Promise to hold the beam in its\n   * pending state — resolve to connect, reject to show the error inline.\n   * @default a simulated 1.2s connection\n   */\n  onConnect?: (id: string) => void | Promise<unknown>;\n  /** Called when Disconnect is pressed. Same Promise semantics as `onConnect`. */\n  onDisconnect?: (id: string) => void | Promise<unknown>;\n  /** Fires after a connect/disconnect settles successfully. */\n  onConnectedChange?: (id: string, connected: boolean) => void;\n  /** Fires when the detail sheet opens (`id`) or closes (`null`). */\n  onOpenChange?: (id: string | null) => void;\n  /** Href for the empty-state \"Request an integration\" link. @default \"#\" */\n  requestHref?: string;\n  /** Click handler for the \"Request an integration\" link (receives the current query). */\n  onRequest?: (query: string) => void;\n  /** Signature accent (hex) for glows, focus rings, the beam and the Connect button. @default \"#f472b6\" */\n  accentColor?: string;\n  /** Imperative handle (`replay()`, `open(id)`, `close()`). React 19 ref-as-prop. */\n  ref?: React.Ref<ManifoldHandle>;\n  /** Extra classes for the `<section>` root. */\n  className?: string;\n}\n\n/* ---------------------------------------------------------------- sample data */\n\nconst DEFAULT_ACCENT = \"#f472b6\";\n\nconst DEFAULT_INTEGRATIONS: ManifoldIntegration[] = [\n  // Communication\n  { id: \"parlance\", name: \"Parlance\", category: \"Communication\", description: \"Post updates and alerts into team channels.\", badges: [\"Popular\"], connected: true, featured: true,\n    about: \"Route project activity into the channels where your team already talks. Pick which events post where, and reply to threads without leaving the conversation.\",\n    features: [\"Post new issues and status changes to any channel\", \"Unfurl links into rich previews\", \"Create tasks from a message with one shortcut\"],\n    permissions: [\"Read channel names\", \"Post messages as the app\", \"Read messages that mention the app\"] },\n  { id: \"beacon-mail\", name: \"Beacon Mail\", category: \"Communication\", description: \"Turn inbound email into tracked conversations.\",\n    features: [\"Forward any inbox to a shared queue\", \"Thread replies back to the sender\", \"Auto-tag by sender domain\"],\n    permissions: [\"Read forwarded messages\", \"Send email on your behalf\"] },\n  { id: \"hallway\", name: \"Hallway\", category: \"Communication\", description: \"Start a video huddle from any record.\", badges: [\"New\"],\n    features: [\"One-click huddles from a task or doc\", \"Attach recordings to the record\", \"Live captions and notes\"],\n    permissions: [\"Create meetings\", \"Read your calendar availability\"] },\n  { id: \"murmur\", name: \"Murmur\", category: \"Communication\", description: \"Text-message alerts for urgent incidents.\",\n    features: [\"Page on-call by SMS\", \"Acknowledge by replying\", \"Quiet hours per person\"],\n    permissions: [\"Send SMS to verified numbers\", \"Read on-call schedules\"] },\n  // Developer\n  { id: \"forgeline\", name: \"Forgeline\", category: \"Developer\", description: \"Link commits and pull requests to work items.\", badges: [\"Popular\"], featured: true,\n    about: \"Every branch, commit and review shows up next to the work it belongs to. Merges move items forward automatically, so the board stays honest without anyone updating it.\",\n    features: [\"Link branches and pull requests automatically\", \"Move items when a review merges\", \"Show build status on every card\"],\n    permissions: [\"Read repository metadata\", \"Read pull requests and commits\", \"Create webhooks\"] },\n  { id: \"faultline\", name: \"Faultline\", category: \"Developer\", description: \"Open issues from production errors in one click.\",\n    features: [\"Create an issue from any error group\", \"Attach stack traces and breadcrumbs\", \"Resolve errors when the issue closes\"],\n    permissions: [\"Read error groups\", \"Update error status\"] },\n  { id: \"dockhand\", name: \"Dockhand CI\", category: \"Developer\", description: \"Pipeline status and deploys on every item.\", badges: [\"Beta\"],\n    features: [\"See pipeline runs on linked items\", \"Trigger deploys from a release\", \"Fail-fast alerts on main\"],\n    permissions: [\"Read pipelines\", \"Trigger deploy jobs\"] },\n  { id: \"toggleworks\", name: \"Toggleworks\", category: \"Developer\", description: \"Tie feature flags to the work that ships them.\",\n    features: [\"Attach flags to items\", \"Roll out by percentage from the release view\", \"Audit every toggle\"],\n    permissions: [\"Read flags and environments\", \"Change rollout percentages\"] },\n  // Analytics\n  { id: \"pulsegraph\", name: \"Pulsegraph\", category: \"Analytics\", description: \"Product metrics beside the features that move them.\", badges: [\"Popular\"], featured: true,\n    about: \"Pin live charts to roadmap items and see whether what you shipped actually moved the number. Funnels, retention and custom events, refreshed every five minutes.\",\n    features: [\"Embed live charts on any item\", \"Alert when a metric crosses a threshold\", \"Compare cohorts before and after a release\"],\n    permissions: [\"Read dashboards and saved charts\", \"Read event definitions\"] },\n  { id: \"cohort-lab\", name: \"Cohort Lab\", category: \"Analytics\", description: \"Retention cohorts and experiment readouts.\",\n    features: [\"Sync experiment results to items\", \"Weekly retention digests\", \"Segment by plan or region\"],\n    permissions: [\"Read experiments\", \"Read cohort definitions\"] },\n  { id: \"lantern\", name: \"Lantern Metrics\", category: \"Analytics\", description: \"Web vitals and uptime for every page.\", badges: [\"New\"],\n    features: [\"Track page speed per release\", \"Uptime checks every minute\", \"Regression alerts on deploy\"],\n    permissions: [\"Read site monitors\", \"Read performance reports\"] },\n  { id: \"tidewater\", name: \"Tidewater\", category: \"Analytics\", description: \"Sync records to your data warehouse nightly.\",\n    features: [\"Nightly or hourly table sync\", \"Schema changes handled automatically\", \"Backfill any date range\"],\n    permissions: [\"Read all workspace records\", \"Write to a configured warehouse\"] },\n  // Storage\n  { id: \"driftwood\", name: \"Driftwood Drive\", category: \"Storage\", description: \"Attach files and folders that stay in sync.\", badges: [\"Popular\"], connected: true,\n    features: [\"Attach live files to any record\", \"Preview documents inline\", \"Keep permissions in step\"],\n    permissions: [\"Read files you pick\", \"Create share links\"] },\n  { id: \"vaultbox\", name: \"Vaultbox\", category: \"Storage\", description: \"Encrypted storage for sensitive attachments.\",\n    features: [\"Client-side encryption\", \"Expiring access links\", \"Full access audit log\"],\n    permissions: [\"Store encrypted files\", \"Read access logs\"] },\n  { id: \"archivist\", name: \"Archivist\", category: \"Storage\", description: \"Automatic, versioned backups of every record.\",\n    features: [\"Hourly incremental snapshots\", \"Point-in-time restore\", \"Export to open formats\"],\n    permissions: [\"Read all workspace records\", \"Write backup archives\"] },\n  { id: \"strata\", name: \"Strata DB\", category: \"Storage\", description: \"Query records with plain SQL.\", badges: [\"Beta\"],\n    features: [\"Read-only SQL over your workspace\", \"Saved queries as views\", \"Schedule CSV exports\"],\n    permissions: [\"Read all workspace records\"] },\n  // Payments\n  { id: \"coinage\", name: \"Coinage\", category: \"Payments\", description: \"See customer plan and revenue on every account.\",\n    features: [\"Show MRR beside each account\", \"Flag failed payments\", \"Link invoices to support tickets\"],\n    permissions: [\"Read customers and subscriptions\", \"Read invoices\"] },\n  { id: \"remit\", name: \"Remit\", category: \"Payments\", description: \"Pay contractors when milestones close.\", badges: [\"New\"],\n    features: [\"Release payouts from a closed milestone\", \"Multi-currency payouts\", \"Approval chains\"],\n    permissions: [\"Create payouts\", \"Read payee details\"] },\n  { id: \"settle\", name: \"Settle\", category: \"Payments\", description: \"Reconcile payouts against your ledger.\",\n    features: [\"Match deposits to invoices\", \"Flag mismatches daily\", \"Month-end close checklist\"],\n    permissions: [\"Read bank transactions\", \"Read invoices\"] },\n  { id: \"tillpoint\", name: \"Tillpoint\", category: \"Payments\", description: \"In-person sales synced to customer records.\",\n    features: [\"Attach receipts to customers\", \"Daily sales summary\", \"Refunds from the record\"],\n    permissions: [\"Read sales\", \"Issue refunds\"] },\n  // Automation\n  { id: \"relay-flows\", name: \"Relay Flows\", category: \"Automation\", description: \"Build multi-step automations without code.\", badges: [\"Popular\"],\n    features: [\"Trigger on any record change\", \"Branch on conditions\", \"Run on a schedule\"],\n    permissions: [\"Read and write workspace records\", \"Create webhooks\"] },\n  { id: \"timekeep\", name: \"Timekeep\", category: \"Automation\", description: \"Recurring tasks and reminders on a schedule.\",\n    features: [\"Cron-style recurring items\", \"Snooze and remind\", \"Holiday-aware calendars\"],\n    permissions: [\"Create items\", \"Read your calendar\"] },\n  { id: \"switchyard\", name: \"Switchyard\", category: \"Automation\", description: \"Route requests to the right team automatically.\", badges: [\"Beta\"],\n    features: [\"Rules by keyword, customer or priority\", \"Round-robin assignment\", \"Escalate on SLA breach\"],\n    permissions: [\"Read incoming requests\", \"Assign items\"] },\n  { id: \"hookline\", name: \"Hookline\", category: \"Automation\", description: \"Send signed webhooks for any event.\",\n    features: [\"Signed payloads with retries\", \"Replay any delivery\", \"Per-endpoint event filters\"],\n    permissions: [\"Read workspace events\", \"Send outbound requests\"] },\n];\n\n/* ---------------------------------------------------------------- helpers */\n\n/** FNV-1a string hash → 32-bit seed. */\nfunction hashString(s: string): number {\n  let h = 0x811c9dc5;\n  for (let i = 0; i < s.length; i++) {\n    h ^= s.charCodeAt(i);\n    h = Math.imul(h, 0x01000193);\n  }\n  return h >>> 0;\n}\n\n/** Black or white text, whichever reads against the accent fill. */\nfunction readableOn(hex: string): string {\n  const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());\n  if (!m) return \"#0a0a0a\";\n  let s = m[1];\n  if (s.length === 3) s = s.replace(/./g, (c) => c + c);\n  const n = parseInt(s, 16);\n  const lum = 0.2126 * ((n >> 16) & 255) + 0.7152 * ((n >> 8) & 255) + 0.0722 * (n & 255);\n  return lum > 140 ? \"#0a0a0a\" : \"#ffffff\";\n}\n\nconst slug = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, \"-\");\nconst ALL = \"__all\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\nconst SPRING: Transition = { type: \"spring\", stiffness: 380, damping: 34, mass: 0.8 };\nconst SHEET_SPRING: Transition = { type: \"spring\", stiffness: 420, damping: 40, mass: 0.9 };\nconst FADE: Transition = { duration: 0.2, ease: \"easeOut\" };\n\n/* ---------------------------------------------------------------- glyphs */\n\n/** Seeded geometric app mark — a white figure on a hued rounded square. Never a real logo. */\nfunction SeededMark({ seed, size = 40, className }: { seed: string; size?: number; className?: string }) {\n  const h = hashString(seed);\n  const hue = h % 360;\n  const shape = (h >>> 9) % 10;\n  const rot = ((h >>> 13) % 4) * 90;\n  const tilt = ((h >>> 17) % 2) * 20;\n  const W = \"#ffffff\";\n  let figure: React.ReactNode;\n  switch (shape) {\n    case 0:\n      figure = (\n        <>\n          <circle cx=\"12\" cy=\"12\" r=\"6.2\" fill=\"none\" stroke={W} strokeWidth=\"2.4\" />\n          <circle cx=\"12\" cy=\"12\" r=\"2.1\" fill={W} />\n        </>\n      );\n      break;\n    case 1:\n      figure = (\n        <>\n          <circle cx=\"9.2\" cy=\"12\" r=\"5.2\" fill={W} fillOpacity=\"0.95\" />\n          <circle cx=\"14.8\" cy=\"12\" r=\"5.2\" fill={W} fillOpacity=\"0.5\" />\n        </>\n      );\n      break;\n    case 2:\n      figure = <path d=\"M12 4.8 19.4 18H4.6Z\" fill={W} strokeLinejoin=\"round\" stroke={W} strokeWidth=\"1.2\" />;\n      break;\n    case 3:\n      figure = (\n        <>\n          <rect x=\"6.5\" y=\"6.5\" width=\"11\" height=\"11\" rx=\"2\" fill=\"none\" stroke={W} strokeWidth=\"2.2\" transform=\"rotate(45 12 12)\" />\n          <rect x=\"10.2\" y=\"10.2\" width=\"3.6\" height=\"3.6\" rx=\"0.8\" fill={W} transform=\"rotate(45 12 12)\" />\n        </>\n      );\n      break;\n    case 4:\n      figure = (\n        <>\n          <rect x=\"5\" y=\"13\" width=\"3.4\" height=\"6\" rx=\"1.2\" fill={W} fillOpacity=\"0.6\" />\n          <rect x=\"10.3\" y=\"9\" width=\"3.4\" height=\"10\" rx=\"1.2\" fill={W} fillOpacity=\"0.8\" />\n          <rect x=\"15.6\" y=\"5\" width=\"3.4\" height=\"14\" rx=\"1.2\" fill={W} />\n        </>\n      );\n      break;\n    case 5:\n      figure = (\n        <>\n          <path d=\"M5.5 18.5A13 13 0 0 1 18.5 5.5\" fill=\"none\" stroke={W} strokeWidth=\"2.4\" strokeLinecap=\"round\" />\n          <path d=\"M5.5 18.5A7 7 0 0 1 12.5 11.5\" fill=\"none\" stroke={W} strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeOpacity=\"0.65\" />\n          <circle cx=\"5.8\" cy=\"18.2\" r=\"1.6\" fill={W} />\n        </>\n      );\n      break;\n    case 6:\n      figure = (\n        <>\n          <path d=\"M12 4.5 18.5 8.25v7.5L12 19.5l-6.5-3.75v-7.5Z\" fill=\"none\" stroke={W} strokeWidth=\"2.1\" strokeLinejoin=\"round\" />\n          <path d=\"M12 9.2 14.4 10.6v2.8L12 14.8l-2.4-1.4v-2.8Z\" fill={W} />\n        </>\n      );\n      break;\n    case 7:\n      figure = (\n        <>\n          <rect x=\"5.5\" y=\"5.5\" width=\"5.6\" height=\"5.6\" rx=\"2.8\" fill={W} />\n          <rect x=\"12.9\" y=\"5.5\" width=\"5.6\" height=\"5.6\" rx=\"1.4\" fill={W} fillOpacity=\"0.55\" />\n          <rect x=\"5.5\" y=\"12.9\" width=\"5.6\" height=\"5.6\" rx=\"1.4\" fill={W} fillOpacity=\"0.55\" />\n          <rect x=\"12.9\" y=\"12.9\" width=\"5.6\" height=\"5.6\" rx=\"1.4\" fill={W} fillOpacity=\"0.8\" />\n        </>\n      );\n      break;\n    case 8:\n      figure = (\n        <>\n          <path d=\"m6.5 7 5 5-5 5\" fill=\"none\" stroke={W} strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n          <path d=\"m12.5 7 5 5-5 5\" fill=\"none\" stroke={W} strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeOpacity=\"0.55\" />\n        </>\n      );\n      break;\n    default:\n      figure = (\n        <>\n          <path d=\"M5 13a7 7 0 0 1 14 0Z\" fill={W} />\n          <rect x=\"5\" y=\"15.4\" width=\"14\" height=\"2.6\" rx=\"1.3\" fill={W} fillOpacity=\"0.6\" />\n        </>\n      );\n  }\n  return (\n    <span\n      aria-hidden\n      className={cn(\"relative inline-flex shrink-0 items-center justify-center overflow-hidden\", className)}\n      style={{\n        width: size,\n        height: size,\n        borderRadius: size * 0.28,\n        backgroundImage: `linear-gradient(${140 + tilt}deg, hsl(${hue} 62% 58%), hsl(${(hue + 28) % 360} 58% 36%))`,\n        boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.28), inset 0 -1px 0 rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.5)\",\n      }}\n    >\n      <svg viewBox=\"0 0 24 24\" width={size * 0.58} height={size * 0.58} style={{ transform: `rotate(${rot}deg)` }}>\n        {figure}\n      </svg>\n    </span>\n  );\n}\n\n/** Default \"your app\" mark: neutral plate with an accent figure. */\nfunction DefaultAppMark({ size, accent }: { size: number; accent: string }) {\n  return (\n    <span\n      aria-hidden\n      className=\"inline-flex shrink-0 items-center justify-center border border-white/10 bg-neutral-900\"\n      style={{\n        width: size,\n        height: size,\n        borderRadius: size * 0.28,\n        boxShadow: \"inset 0 1px 0 rgba(255,255,255,0.08), 0 1px 2px rgba(0,0,0,0.5)\",\n      }}\n    >\n      <svg viewBox=\"0 0 24 24\" width={size * 0.56} height={size * 0.56} fill=\"none\">\n        <rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"5\" stroke={accent} strokeWidth=\"2.2\" />\n        <rect x=\"9\" y=\"9\" width=\"6\" height=\"6\" rx=\"2\" fill={accent} />\n      </svg>\n    </span>\n  );\n}\n\nfunction MarkFor({ item, size, className }: { item: ManifoldIntegration; size: number; className?: string }) {\n  if (item.mark) {\n    return (\n      <span\n        aria-hidden\n        className={cn(\"inline-flex shrink-0 items-center justify-center overflow-hidden\", className)}\n        style={{ width: size, height: size, borderRadius: size * 0.28 }}\n      >\n        {item.mark}\n      </span>\n    );\n  }\n  return <SeededMark seed={item.id} size={size} className={className} />;\n}\n\nfunction SearchGlyph({ className }: { className?: string }) {\n  return (\n    <svg aria-hidden viewBox=\"0 0 24 24\" className={className} fill=\"none\">\n      <circle cx=\"11\" cy=\"11\" r=\"6.5\" stroke=\"currentColor\" strokeWidth=\"1.8\" />\n      <path d=\"m16 16 4 4\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction CheckGlyph({ className }: { className?: string }) {\n  return (\n    <svg aria-hidden viewBox=\"0 0 24 24\" className={className} fill=\"none\">\n      <path d=\"M5 12.5l4.5 4.5L19 7.5\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nfunction CloseGlyph({ className }: { className?: string }) {\n  return (\n    <svg aria-hidden viewBox=\"0 0 24 24\" className={className} fill=\"none\">\n      <path d=\"M6.5 6.5l11 11M17.5 6.5l-11 11\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction KeyGlyph({ className }: { className?: string }) {\n  return (\n    <svg aria-hidden viewBox=\"0 0 24 24\" className={className} fill=\"none\">\n      <rect x=\"5\" y=\"10.5\" width=\"14\" height=\"9\" rx=\"2.2\" stroke=\"currentColor\" strokeWidth=\"1.7\" />\n      <path d=\"M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5\" stroke=\"currentColor\" strokeWidth=\"1.7\" />\n    </svg>\n  );\n}\n\nfunction Spinner({ className }: { className?: string }) {\n  return (\n    <svg aria-hidden viewBox=\"0 0 24 24\" className={cn(\"motion-safe:animate-spin\", className)} fill=\"none\">\n      <circle cx=\"12\" cy=\"12\" r=\"9\" stroke=\"currentColor\" strokeOpacity=\"0.25\" strokeWidth=\"3\" />\n      <path d=\"M21 12a9 9 0 0 0-9-9\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\n/* ---------------------------------------------------------------- pieces */\n\nfunction Badge({ label }: { label: ManifoldBadge }) {\n  const popular = label === \"Popular\";\n  const beta = label === \"Beta\";\n  return (\n    <span\n      className={cn(\n        \"inline-flex h-5 items-center rounded-full px-2 text-[10.5px] font-medium tracking-wide whitespace-nowrap\",\n        popular && \"text-[color:var(--mf-accent)]\",\n        label === \"New\" && \"bg-white/[0.08] text-white/80\",\n        beta && \"border border-dashed border-white/20 text-white/55\",\n        !popular && !beta && label !== \"New\" && \"bg-white/[0.06] text-white/60\"\n      )}\n      style={popular ? { backgroundColor: \"color-mix(in srgb, var(--mf-accent) 14%, transparent)\" } : undefined}\n    >\n      {label}\n    </span>\n  );\n}\n\nfunction ConnectedChip({ reducedMotion }: { reducedMotion: boolean }) {\n  return (\n    <motion.span\n      initial={reducedMotion ? { opacity: 0 } : { opacity: 0, scale: 0.85 }}\n      animate={{ opacity: 1, scale: 1 }}\n      exit={{ opacity: 0, scale: reducedMotion ? 1 : 0.85 }}\n      transition={reducedMotion ? FADE : SPRING}\n      className=\"inline-flex h-5 items-center gap-1.5 rounded-full border border-white/10 bg-white/[0.04] px-2 text-[10.5px] font-medium text-white/80\"\n    >\n      <span className=\"size-1.5 rounded-full bg-[color:var(--mf-accent)] shadow-[0_0_6px_var(--mf-accent)]\" />\n      Connected\n    </motion.span>\n  );\n}\n\n/** Cursor-follow accent glow: a lit border ring + a soft inner wash, both keyed to --mx/--my. */\nfunction CardGlow() {\n  return (\n    <>\n      <span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover/card:opacity-100 group-focus-visible/card:opacity-100\"\n        style={{\n          background:\n            \"radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--mf-accent) 9%, transparent), transparent 70%)\",\n        }}\n      />\n      <span\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 rounded-[inherit] p-px opacity-0 transition-opacity duration-300 group-hover/card:opacity-100 group-focus-visible/card:opacity-100\"\n        style={{\n          background: \"radial-gradient(180px circle at var(--mx, 50%) var(--my, 0%), var(--mf-accent), transparent 70%)\",\n          WebkitMask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n          WebkitMaskComposite: \"xor\",\n          mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n          maskComposite: \"exclude\",\n        }}\n      />\n    </>\n  );\n}\n\nfunction trackPointer(e: React.PointerEvent<HTMLElement>) {\n  const el = e.currentTarget;\n  const r = el.getBoundingClientRect();\n  el.style.setProperty(\"--mx\", `${e.clientX - r.left}px`);\n  el.style.setProperty(\"--my\", `${e.clientY - r.top}px`);\n}\n\nfunction resetPointer(e: React.FocusEvent<HTMLElement>) {\n  // Keyboard focus lights the top edge.\n  e.currentTarget.style.setProperty(\"--mx\", \"50%\");\n  e.currentTarget.style.setProperty(\"--my\", \"0%\");\n}\n\nconst cardVariants: Variants = {\n  hidden: { opacity: 0, y: 12 },\n  shown: (delay: number) => ({ opacity: 1, y: 0, transition: { ...SPRING, delay } }),\n};\n\ninterface CardProps {\n  item: ManifoldIntegration;\n  connected: boolean;\n  delay: number;\n  show: boolean;\n  enter: boolean;\n  layoutId: string;\n  reducedMotion: boolean;\n  onOpen: (id: string, el: HTMLElement) => void;\n  registerRef: (id: string, el: HTMLElement | null) => void;\n}\n\nfunction IntegrationCard({ item, connected, delay, show, enter, layoutId, reducedMotion, onOpen, registerRef }: CardProps) {\n  return (\n    <motion.li\n      layoutId={reducedMotion ? undefined : layoutId}\n      layout={!reducedMotion}\n      custom={delay}\n      variants={cardVariants}\n      initial={reducedMotion || !enter ? false : \"hidden\"}\n      animate={show ? \"shown\" : \"hidden\"}\n      exit={{ opacity: 0, scale: reducedMotion ? 1 : 0.96, transition: { duration: 0.16 } }}\n      transition={reducedMotion ? FADE : SPRING}\n      className=\"min-w-0\"\n    >\n      <button\n        type=\"button\"\n        ref={(el) => registerRef(item.id, el)}\n        aria-haspopup=\"dialog\"\n        onClick={(e) => onOpen(item.id, e.currentTarget)}\n        onPointerMove={trackPointer}\n        onFocus={resetPointer}\n        className={cn(\n          \"group/card relative flex h-full w-full flex-col gap-3 rounded-xl border border-white/[0.08] bg-white/[0.02] p-4 text-left\",\n          \"transition-colors duration-200 hover:bg-white/[0.035]\",\n          \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)] focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950\"\n        )}\n      >\n        <CardGlow />\n        <span className=\"relative flex items-start gap-3\">\n          <MarkFor item={item} size={40} />\n          <span className=\"flex min-w-0 flex-1 flex-col\">\n            <span className=\"truncate text-[14px] font-semibold tracking-[-0.01em] text-white\">{item.name}</span>\n            <span className=\"truncate text-[12px] text-white/45\">{item.category}</span>\n          </span>\n          {item.badges?.length ? (\n            <span className=\"flex shrink-0 gap-1\">\n              {item.badges.slice(0, 2).map((b) => (\n                <Badge key={b} label={b} />\n              ))}\n            </span>\n          ) : null}\n        </span>\n        <span className=\"relative line-clamp-2 text-[13px] leading-relaxed text-white/60\">{item.description}</span>\n        <span className=\"relative mt-auto flex h-5 items-center justify-between\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            {connected ? (\n              <ConnectedChip key=\"on\" reducedMotion={reducedMotion} />\n            ) : (\n              <motion.span\n                key=\"off\"\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0 }}\n                transition={FADE}\n                className=\"text-[12px] text-white/35\"\n              >\n                Not connected\n              </motion.span>\n            )}\n          </AnimatePresence>\n          <span className=\"inline-flex items-center gap-1 text-[12px] font-medium text-white/40 transition-colors group-hover/card:text-white/85 group-focus-visible/card:text-white/85\">\n            Details\n            <span aria-hidden className=\"transition-transform duration-200 motion-safe:group-hover/card:translate-x-0.5\">\n              →\n            </span>\n          </span>\n        </span>\n      </button>\n    </motion.li>\n  );\n}\n\nfunction FeaturedCard({\n  item,\n  connected,\n  delay,\n  show,\n  reducedMotion,\n  onOpen,\n  registerRef,\n}: Omit<CardProps, \"enter\" | \"layoutId\">) {\n  const hue = hashString(item.id) % 360;\n  return (\n    <motion.li\n      custom={delay}\n      variants={cardVariants}\n      initial={reducedMotion ? false : \"hidden\"}\n      animate={show ? \"shown\" : \"hidden\"}\n      className=\"w-[78%] shrink-0 snap-start @2xl:w-auto\"\n    >\n      <button\n        type=\"button\"\n        ref={(el) => registerRef(`featured:${item.id}`, el)}\n        aria-haspopup=\"dialog\"\n        onClick={(e) => onOpen(item.id, e.currentTarget)}\n        onPointerMove={trackPointer}\n        onFocus={resetPointer}\n        className={cn(\n          \"group/card relative flex h-full w-full flex-col gap-4 overflow-hidden rounded-2xl border border-white/[0.08] bg-neutral-900/60 p-5 text-left\",\n          \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)] focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950\"\n        )}\n      >\n        {/* Mark-hued aurora so each featured card has its own temperature. */}\n        <span\n          aria-hidden\n          className=\"pointer-events-none absolute inset-x-0 top-0 h-28 opacity-70\"\n          style={{\n            background: `radial-gradient(70% 100% at 18% 0%, hsl(${hue} 70% 55% / 0.22), transparent 70%)`,\n          }}\n        />\n        <span aria-hidden className=\"pointer-events-none absolute inset-x-5 top-0 h-px bg-gradient-to-r from-transparent via-white/20 to-transparent\" />\n        <CardGlow />\n        <span className=\"relative flex items-start justify-between gap-3\">\n          <MarkFor item={item} size={48} />\n          <span className=\"text-[10.5px] font-medium tracking-[0.14em] text-white/40 uppercase\">Featured</span>\n        </span>\n        <span className=\"relative flex flex-col gap-1.5\">\n          <span className=\"text-[16px] font-semibold tracking-[-0.015em] text-white\">{item.name}</span>\n          <span className=\"line-clamp-2 text-[13px] leading-relaxed text-white/60\">{item.description}</span>\n        </span>\n        <span className=\"relative mt-auto flex h-5 items-center justify-between gap-2\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            {connected ? (\n              <ConnectedChip key=\"on\" reducedMotion={reducedMotion} />\n            ) : (\n              <motion.span key=\"off\" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={FADE} className=\"text-[12px] text-white/40\">\n                {item.category}\n              </motion.span>\n            )}\n          </AnimatePresence>\n          <span className=\"inline-flex items-center gap-1 text-[12px] font-medium text-white/55 transition-colors group-hover/card:text-white group-focus-visible/card:text-white\">\n            {connected ? \"Manage\" : \"Connect\"}\n            <span aria-hidden className=\"transition-transform duration-200 motion-safe:group-hover/card:translate-x-0.5\">\n              →\n            </span>\n          </span>\n        </span>\n      </button>\n    </motion.li>\n  );\n}\n\n/* ---------------------------------------------------------------- sheet */\n\ntype Status = \"idle\" | \"connecting\" | \"disconnecting\";\n\ninterface SheetProps {\n  item: ManifoldIntegration;\n  connected: boolean;\n  status: Status;\n  error: string | null;\n  accent: string;\n  appMark: React.ReactNode;\n  appName: string;\n  reducedMotion: boolean;\n  onClose: () => void;\n  onConnect: () => void;\n  onDisconnect: () => void;\n}\n\nfunction Sheet({ item, connected, status, error, accent, appMark, appName, reducedMotion, onClose, onConnect, onDisconnect }: SheetProps) {\n  const overlayRef = React.useRef<HTMLDivElement>(null);\n  const dialogRef = React.useRef<HTMLDivElement>(null);\n  const beamRef = React.useRef<HTMLDivElement>(null);\n  const fromRef = React.useRef<HTMLDivElement>(null);\n  const toRef = React.useRef<HTMLDivElement>(null);\n  const [mode, setMode] = React.useState<\"side\" | \"bottom\" | null>(null);\n  const titleId = React.useId();\n  const descId = React.useId();\n\n  // The sheet is position: fixed — its containing block is the viewport, or the\n  // nearest transformed / `contain: paint` ancestor. Pick side vs bottom from\n  // that box's width before first paint.\n  React.useLayoutEffect(() => {\n    const el = overlayRef.current;\n    if (!el) return;\n    const measure = () => setMode(el.getBoundingClientRect().width >= 640 ? \"side\" : \"bottom\");\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (mode) dialogRef.current?.focus({ preventScroll: true });\n  }, [mode]);\n\n  const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === \"Escape\") {\n      e.stopPropagation();\n      onClose();\n      return;\n    }\n    if (e.key !== \"Tab\" || !dialogRef.current) return;\n    const nodes = Array.from(\n      dialogRef.current.querySelectorAll<HTMLElement>('button:not([disabled]), a[href], input, [tabindex]:not([tabindex=\"-1\"])')\n    );\n    if (!nodes.length) return;\n    const first = nodes[0];\n    const last = nodes[nodes.length - 1];\n    const active = document.activeElement;\n    if (e.shiftKey && (active === first || active === dialogRef.current)) {\n      e.preventDefault();\n      last.focus();\n    } else if (!e.shiftKey && active === last) {\n      e.preventDefault();\n      first.focus();\n    }\n  };\n\n  const busy = status !== \"idle\";\n  const beamLive = status === \"connecting\" || connected;\n  const ink = readableOn(accent);\n  const features = item.features ?? [];\n  const permissions = item.permissions ?? [];\n  const side = mode === \"side\";\n  const hidden = side ? { x: \"100%\" } : { y: \"100%\" };\n\n  const stateLabel =\n    status === \"connecting\" ? \"Connecting…\" : status === \"disconnecting\" ? \"Disconnecting…\" : connected ? \"Connected\" : \"Not connected\";\n\n  return (\n    <motion.div\n      ref={overlayRef}\n      className=\"fixed inset-0 z-50\"\n      initial={{ opacity: 1 }}\n      animate={{ opacity: 1 }}\n      exit={{ opacity: 1, transition: { duration: reducedMotion ? 0.2 : 0.32 } }}\n    >\n      <motion.div\n        aria-hidden\n        className=\"absolute inset-0 bg-black/60 backdrop-blur-[2px]\"\n        initial={{ opacity: 0 }}\n        animate={{ opacity: 1 }}\n        exit={{ opacity: 0 }}\n        transition={{ duration: 0.24, ease: \"easeOut\" }}\n        onClick={onClose}\n      />\n      {mode ? (\n        <motion.div\n          ref={dialogRef}\n          role=\"dialog\"\n          aria-modal=\"true\"\n          aria-labelledby={titleId}\n          aria-describedby={descId}\n          tabIndex={-1}\n          onKeyDown={onKeyDown}\n          initial={reducedMotion ? { opacity: 0 } : hidden}\n          animate={reducedMotion ? { opacity: 1 } : { x: 0, y: 0 }}\n          exit={reducedMotion ? { opacity: 0 } : hidden}\n          transition={reducedMotion ? FADE : SHEET_SPRING}\n          className={cn(\n            \"absolute flex flex-col overflow-hidden border-white/[0.08] bg-neutral-950 text-white shadow-[0_0_60px_rgba(0,0,0,0.6)] outline-none\",\n            side\n              ? \"inset-y-2 right-2 w-[min(440px,calc(100%-1rem))] rounded-2xl border\"\n              : \"inset-x-0 bottom-0 max-h-[90%] rounded-t-2xl border-t\"\n          )}\n        >\n          {!side ? <div aria-hidden className=\"mx-auto mt-2 h-1 w-10 shrink-0 rounded-full bg-white/15\" /> : null}\n\n          <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain\">\n            {/* Beam header: your app ↔ integration. */}\n            <div className=\"relative border-b border-white/[0.06] px-5 pt-5 pb-6\">\n              <div\n                aria-hidden\n                className=\"pointer-events-none absolute inset-0\"\n                style={{\n                  background: `radial-gradient(60% 90% at 50% 40%, color-mix(in srgb, ${accent} ${beamLive ? 14 : 6}%, transparent), transparent 75%)`,\n                  transition: \"background 400ms ease\",\n                }}\n              />\n              <div className=\"relative flex items-center justify-between\">\n                <span className=\"text-[11px] font-medium tracking-[0.14em] text-white/40 uppercase\">Integration</span>\n                <button\n                  type=\"button\"\n                  onClick={onClose}\n                  aria-label=\"Close\"\n                  className=\"-mr-1.5 inline-flex size-8 items-center justify-center rounded-lg text-white/55 transition-colors hover:bg-white/[0.06] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)]\"\n                >\n                  <CloseGlyph className=\"size-4\" />\n                </button>\n              </div>\n\n              <div ref={beamRef} className=\"relative mx-auto mt-4 flex max-w-[320px] items-start justify-between\">\n                {/* Static channel between the marks; the conduit pours light along it while live. */}\n                <span\n                  aria-hidden\n                  className=\"absolute top-7 right-16 left-16 h-px\"\n                  style={{\n                    backgroundImage: connected\n                      ? `linear-gradient(90deg, color-mix(in srgb, ${accent} 55%, transparent), color-mix(in srgb, ${accent} 55%, transparent))`\n                      : \"repeating-linear-gradient(90deg, rgba(255,255,255,0.22) 0 4px, transparent 4px 8px)\",\n                  }}\n                />\n                {beamLive ? (\n                  <Conduit\n                    key={status === \"connecting\" ? \"pending\" : \"live\"}\n                    containerRef={beamRef}\n                    fromRef={fromRef}\n                    toRef={toRef}\n                    pathOpacity={0}\n                    pathWidth={2}\n                    duration={status === \"connecting\" ? 1.1 : 2.8}\n                    slugColors={[\"#ffffff\", accent, accent]}\n                    glowOnReceive={status === \"connecting\"}\n                    className=\"z-0\"\n                  />\n                ) : null}\n                <div className=\"relative z-10 flex w-24 flex-col items-center gap-2\">\n                  <div ref={fromRef} className=\"rounded-2xl\">\n                    {appMark}\n                  </div>\n                  <span className=\"max-w-full truncate text-[12px] text-white/55\">{appName}</span>\n                </div>\n                <motion.span\n                  key={stateLabel}\n                  initial={reducedMotion ? { opacity: 0 } : { opacity: 0, y: 4 }}\n                  animate={{ opacity: 1, y: 0 }}\n                  transition={FADE}\n                  className={cn(\n                    \"absolute top-[64px] left-1/2 -translate-x-1/2 rounded-full border px-2 py-0.5 text-[10.5px] font-medium whitespace-nowrap\",\n                    connected && status === \"idle\"\n                      ? \"border-[color:var(--mf-accent)]/40 text-[color:var(--mf-accent)]\"\n                      : \"border-white/10 bg-neutral-950 text-white/55\"\n                  )}\n                  style={connected && status === \"idle\" ? { backgroundColor: `color-mix(in srgb, ${accent} 10%, #0a0a0a)` } : undefined}\n                >\n                  {stateLabel}\n                </motion.span>\n                <div className=\"relative z-10 flex w-24 flex-col items-center gap-2\">\n                  <div\n                    ref={toRef}\n                    className=\"rounded-2xl transition-shadow duration-500\"\n                    style={{\n                      boxShadow: connected\n                        ? `0 0 0 1px color-mix(in srgb, ${accent} 60%, transparent), 0 0 24px -4px ${accent}`\n                        : \"0 0 0 1px rgba(255,255,255,0)\",\n                    }}\n                  >\n                    <MarkFor item={item} size={56} />\n                  </div>\n                  <span className=\"max-w-full truncate text-[12px] text-white/55\">{item.name}</span>\n                </div>\n              </div>\n            </div>\n\n            <div className=\"flex flex-col gap-6 px-5 py-5\">\n              <div className=\"flex flex-col gap-2\">\n                <div className=\"flex flex-wrap items-center gap-2\">\n                  <h3 id={titleId} className=\"text-[18px] font-semibold tracking-[-0.015em] text-white\">\n                    Connect {item.name}\n                  </h3>\n                  {item.badges?.map((b) => (\n                    <Badge key={b} label={b} />\n                  ))}\n                </div>\n                <p className=\"text-[12px] text-white/40\">{item.category}</p>\n                <p id={descId} className=\"text-[13.5px] leading-relaxed text-pretty text-white/65\">\n                  {item.about ?? item.description}\n                </p>\n              </div>\n\n              {features.length ? (\n                <div className=\"flex flex-col gap-2.5\">\n                  <h4 className=\"text-[11px] font-medium tracking-[0.14em] text-white/40 uppercase\">What you can do</h4>\n                  <ul className=\"flex flex-col gap-2\">\n                    {features.map((f) => (\n                      <li key={f} className=\"flex items-start gap-2.5 text-[13.5px] leading-snug text-white/80\">\n                        <span\n                          className=\"mt-px inline-flex size-[18px] shrink-0 items-center justify-center rounded-full\"\n                          style={{ backgroundColor: `color-mix(in srgb, ${accent} 16%, transparent)`, color: accent }}\n                        >\n                          <CheckGlyph className=\"size-3\" />\n                        </span>\n                        {f}\n                      </li>\n                    ))}\n                  </ul>\n                </div>\n              ) : null}\n\n              {permissions.length ? (\n                <div className=\"flex flex-col gap-2.5\">\n                  <h4 className=\"text-[11px] font-medium tracking-[0.14em] text-white/40 uppercase\">Permissions requested</h4>\n                  <ul className=\"divide-y divide-white/[0.06] rounded-xl border border-white/[0.08] bg-white/[0.02]\">\n                    {permissions.map((p) => (\n                      <li key={p} className=\"flex items-center gap-2.5 px-3 py-2.5 text-[13px] text-white/70\">\n                        <KeyGlyph className=\"size-3.5 shrink-0 text-white/40\" />\n                        {p}\n                      </li>\n                    ))}\n                  </ul>\n                </div>\n              ) : null}\n            </div>\n          </div>\n\n          {/* Action footer */}\n          <div className=\"flex shrink-0 flex-col gap-2 border-t border-white/[0.06] bg-neutral-950 px-5 py-4\">\n            <AnimatePresence initial={false}>\n              {error ? (\n                <motion.p\n                  role=\"alert\"\n                  initial={{ opacity: 0, height: 0 }}\n                  animate={{ opacity: 1, height: \"auto\" }}\n                  exit={{ opacity: 0, height: 0 }}\n                  transition={FADE}\n                  className=\"text-[12.5px] text-rose-300\"\n                >\n                  {error}\n                </motion.p>\n              ) : null}\n            </AnimatePresence>\n            <div className=\"flex items-center gap-2\">\n              <motion.button\n                type=\"button\"\n                layout={!reducedMotion}\n                transition={SPRING}\n                onClick={connected ? undefined : onConnect}\n                disabled={busy}\n                aria-disabled={connected || busy}\n                className={cn(\n                  \"relative inline-flex h-10 flex-1 items-center justify-center gap-2 rounded-[10px] px-4 text-[13.5px] font-semibold\",\n                  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)] focus-visible:ring-offset-2 focus-visible:ring-offset-neutral-950\",\n                  connected ? \"cursor-default border border-white/10\" : \"transition-[filter] hover:brightness-110\",\n                  busy && !connected && \"cursor-wait\"\n                )}\n                style={\n                  connected\n                    ? { backgroundColor: \"rgba(255,255,255,0.04)\", color: \"#ffffff\", boxShadow: \"0 0 0 0 transparent\" }\n                    : { backgroundColor: accent, color: ink, boxShadow: `0 6px 24px -10px ${accent}` }\n                }\n              >\n                {status === \"connecting\" ? (\n                  <>\n                    <Spinner className=\"size-4\" />\n                    Connecting…\n                  </>\n                ) : connected ? (\n                  <>\n                    <CheckGlyph className=\"size-4 text-[color:var(--mf-accent)]\" />\n                    Connected\n                  </>\n                ) : (\n                  <>Connect {item.name}</>\n                )}\n              </motion.button>\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                {connected ? (\n                  <motion.button\n                    key=\"disconnect\"\n                    type=\"button\"\n                    initial={{ opacity: 0, x: reducedMotion ? 0 : 8 }}\n                    animate={{ opacity: 1, x: 0 }}\n                    exit={{ opacity: 0, x: reducedMotion ? 0 : 8 }}\n                    transition={reducedMotion ? FADE : SPRING}\n                    onClick={onDisconnect}\n                    disabled={busy}\n                    className=\"inline-flex h-10 items-center gap-2 rounded-[10px] px-3.5 text-[13px] font-medium text-white/60 transition-colors hover:bg-white/[0.06] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)] disabled:cursor-wait\"\n                  >\n                    {status === \"disconnecting\" ? <Spinner className=\"size-3.5\" /> : null}\n                    Disconnect\n                  </motion.button>\n                ) : null}\n              </AnimatePresence>\n            </div>\n          </div>\n        </motion.div>\n      ) : null}\n    </motion.div>\n  );\n}\n\n/* ---------------------------------------------------------------- main */\n\n/**\n * Manifold — an integrations directory section. A header with a live count\n * and search, an optional \"Featured\" hero row, and Detent category tabs over\n * a card grid that re-flows with layout springs as you search or filter\n * (with an empty state + \"Request an integration\" link). Each card carries a\n * seeded geometric mark (never a real logo), badges, and a connected chip;\n * hovering or focusing lights its border with a cursor-follow accent glow.\n * Clicking opens a detail sheet (side sheet on wide containers, bottom sheet\n * on narrow ones; dialog semantics, focus trap, Escape) whose header joins\n * your app mark and the integration's mark with a Conduit beam — Connect\n * fires async `onConnect`, the beam carries light while pending, then the\n * button morphs to \"Connected\" with a Disconnect ghost and the grid card gains\n * its chip. Reduced motion: final layout, crossfades only.\n *\n * The sheet is `position: fixed`: it covers the viewport, or the nearest\n * ancestor with `transform` / `contain: paint` if you want it confined.\n */\nexport function Manifold({\n  integrations = DEFAULT_INTEGRATIONS,\n  categories,\n  eyebrow = \"Integrations\",\n  title = \"Plug into the tools you already use\",\n  subtitle = \"Connect your stack in a click. Every integration is maintained by us, scoped to the permissions it needs, and can be switched off any time.\",\n  allLabel = \"All\",\n  showFeatured = true,\n  appMark,\n  appName = \"Your workspace\",\n  onConnect,\n  onDisconnect,\n  onConnectedChange,\n  onOpenChange,\n  requestHref = \"#\",\n  onRequest,\n  accentColor = DEFAULT_ACCENT,\n  ref,\n  className,\n  style,\n  ...props\n}: ManifoldProps) {\n  const reducedMotion = useReducedMotion();\n  const uid = React.useId().replace(/[:]/g, \"\");\n  const headingId = `${uid}-heading`;\n  const [replayKey, setReplayKey] = React.useState(0);\n  const [query, setQuery] = React.useState(\"\");\n  const [tab, setTab] = React.useState(ALL);\n  const [openId, setOpenId] = React.useState<string | null>(null);\n  const [announcement, setAnnouncement] = React.useState(\"\");\n\n  // Connected state is owned here, seeded from props (re-seeded when the list changes).\n  const seedConnected = React.useCallback(\n    (list: ManifoldIntegration[]) => Object.fromEntries(list.map((i) => [i.id, Boolean(i.connected)])),\n    []\n  );\n  const [connectedMap, setConnectedMap] = React.useState<Record<string, boolean>>(() => seedConnected(integrations));\n  const [seededFrom, setSeededFrom] = React.useState(integrations);\n  if (seededFrom !== integrations) {\n    setSeededFrom(integrations);\n    setConnectedMap(seedConnected(integrations));\n  }\n  const [statusMap, setStatusMap] = React.useState<Record<string, Status>>({});\n  const [errorMap, setErrorMap] = React.useState<Record<string, string | null>>({});\n\n  const triggerRefs = React.useRef(new Map<string, HTMLElement>());\n  const returnFocus = React.useRef<HTMLElement | null>(null);\n  const searchRef = React.useRef<HTMLInputElement>(null);\n\n  const cats = React.useMemo(() => {\n    if (categories?.length) return categories;\n    const seen: string[] = [];\n    for (const i of integrations) if (!seen.includes(i.category)) seen.push(i.category);\n    return seen;\n  }, [categories, integrations]);\n\n  const q = query.trim().toLowerCase();\n  const matchesQuery = React.useCallback(\n    (i: ManifoldIntegration) =>\n      !q || i.name.toLowerCase().includes(q) || i.description.toLowerCase().includes(q) || i.category.toLowerCase().includes(q),\n    [q]\n  );\n  const searched = React.useMemo(() => integrations.filter(matchesQuery), [integrations, matchesQuery]);\n  const activeCategory = tab === ALL ? null : (cats.find((c) => slug(c) === tab) ?? null);\n  const visible = React.useMemo(\n    () => (activeCategory ? searched.filter((i) => i.category === activeCategory) : searched),\n    [searched, activeCategory]\n  );\n  const featured = React.useMemo(() => integrations.filter((i) => i.featured).slice(0, 3), [integrations]);\n  const featuredOn = showFeatured && featured.length > 0;\n  const featuredShown = featuredOn && !q;\n\n  // Announce result counts after the user filters (not on mount).\n  const firstFilter = React.useRef(true);\n  React.useEffect(() => {\n    if (firstFilter.current) {\n      firstFilter.current = false;\n      return;\n    }\n    const t = window.setTimeout(() => {\n      const n = visible.length;\n      setAnnouncement(\n        `${n} ${n === 1 ? \"integration\" : \"integrations\"}${activeCategory ? ` in ${activeCategory}` : \"\"}${q ? ` matching “${query.trim()}”` : \"\"}.`\n      );\n    }, 350);\n    return () => window.clearTimeout(t);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [visible.length, activeCategory, q]);\n\n  const openSheet = React.useCallback(\n    (id: string, from?: HTMLElement | null) => {\n      if (!integrations.some((i) => i.id === id)) return;\n      returnFocus.current =\n        from ?? triggerRefs.current.get(id) ?? (typeof document !== \"undefined\" ? (document.activeElement as HTMLElement | null) : null);\n      setErrorMap((m) => ({ ...m, [id]: null }));\n      setOpenId(id);\n      onOpenChange?.(id);\n    },\n    [integrations, onOpenChange]\n  );\n\n  const closeSheet = React.useCallback(() => {\n    setOpenId((cur) => {\n      if (cur !== null) onOpenChange?.(null);\n      return null;\n    });\n  }, [onOpenChange]);\n\n  React.useImperativeHandle(\n    ref,\n    () => ({\n      replay: () => {\n        setOpenId(null);\n        setReplayKey((k) => k + 1);\n      },\n      open: (id: string) => openSheet(id),\n      close: closeSheet,\n    }),\n    [openSheet, closeSheet]\n  );\n\n  const runAction = async (id: string, kind: \"connect\" | \"disconnect\") => {\n    const item = integrations.find((i) => i.id === id);\n    if (!item) return;\n    setStatusMap((m) => ({ ...m, [id]: kind === \"connect\" ? \"connecting\" : \"disconnecting\" }));\n    setErrorMap((m) => ({ ...m, [id]: null }));\n    try {\n      if (kind === \"connect\") {\n        if (onConnect) await onConnect(id);\n        else await new Promise((r) => window.setTimeout(r, 1200));\n      } else if (onDisconnect) {\n        await onDisconnect(id);\n      } else {\n        await new Promise((r) => window.setTimeout(r, 500));\n      }\n      const next = kind === \"connect\";\n      setConnectedMap((m) => ({ ...m, [id]: next }));\n      setAnnouncement(`${item.name} ${next ? \"connected\" : \"disconnected\"}.`);\n      onConnectedChange?.(id, next);\n    } catch (err) {\n      const msg =\n        err instanceof Error && err.message\n          ? err.message\n          : kind === \"connect\"\n            ? `Couldn't connect ${item.name}. Try again.`\n            : `Couldn't disconnect ${item.name}. Try again.`;\n      setErrorMap((m) => ({ ...m, [id]: msg }));\n      setAnnouncement(msg);\n    } finally {\n      setStatusMap((m) => ({ ...m, [id]: \"idle\" }));\n    }\n  };\n\n  const registerRef = React.useCallback((id: string, el: HTMLElement | null) => {\n    if (el) triggerRefs.current.set(id, el);\n    else triggerRefs.current.delete(id);\n  }, []);\n\n  const openItem = openId ? (integrations.find((i) => i.id === openId) ?? null) : null;\n\n  return (\n    <section\n      data-crucible=\"manifold\"\n      aria-labelledby={headingId}\n      className={cn(\"@container relative isolate w-full overflow-hidden bg-neutral-950 text-white\", className)}\n      style={{ [\"--mf-accent\" as string]: accentColor, ...style }}\n      {...props}\n    >\n      <div aria-hidden className=\"pointer-events-none absolute inset-x-0 top-0 -z-10 h-[30rem]\">\n        <div className=\"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/12 to-transparent\" />\n        <div\n          className=\"absolute inset-0\"\n          style={{\n            background: `radial-gradient(55% 70% at 85% 0%, color-mix(in srgb, ${accentColor} 9%, transparent), transparent 70%)`,\n          }}\n        />\n      </div>\n\n      <Body\n        key={replayKey}\n        uid={uid}\n        headingId={headingId}\n        reducedMotion={reducedMotion}\n        eyebrow={eyebrow}\n        title={title}\n        subtitle={subtitle}\n        total={integrations.length}\n        query={query}\n        setQuery={setQuery}\n        searchRef={searchRef}\n        cats={cats}\n        tab={tab}\n        setTab={setTab}\n        allLabel={allLabel}\n        searched={searched}\n        visible={visible}\n        featured={featured}\n        featuredOn={featuredOn}\n        featuredShown={featuredShown}\n        connectedMap={connectedMap}\n        onOpen={openSheet}\n        registerRef={registerRef}\n        requestHref={requestHref}\n        onRequest={onRequest}\n      />\n\n      <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n        {announcement}\n      </p>\n\n      <AnimatePresence\n        onExitComplete={() => {\n          const el = returnFocus.current;\n          returnFocus.current = null;\n          if (el && el.isConnected) el.focus({ preventScroll: true });\n        }}\n      >\n        {openItem ? (\n          <Sheet\n            key={openItem.id}\n            item={openItem}\n            connected={Boolean(connectedMap[openItem.id])}\n            status={statusMap[openItem.id] ?? \"idle\"}\n            error={errorMap[openItem.id] ?? null}\n            accent={accentColor}\n            appMark={appMark ?? <DefaultAppMark size={56} accent={accentColor} />}\n            appName={appName}\n            reducedMotion={reducedMotion}\n            onClose={closeSheet}\n            onConnect={() => runAction(openItem.id, \"connect\")}\n            onDisconnect={() => runAction(openItem.id, \"disconnect\")}\n          />\n        ) : null}\n      </AnimatePresence>\n    </section>\n  );\n}\n\n/* ---------------------------------------------------------------- body */\n\ninterface BodyProps {\n  uid: string;\n  headingId: string;\n  reducedMotion: boolean;\n  eyebrow: React.ReactNode;\n  title: React.ReactNode;\n  subtitle: React.ReactNode;\n  total: number;\n  query: string;\n  setQuery: (q: string) => void;\n  searchRef: React.RefObject<HTMLInputElement | null>;\n  cats: string[];\n  tab: string;\n  setTab: (t: string) => void;\n  allLabel: string;\n  searched: ManifoldIntegration[];\n  visible: ManifoldIntegration[];\n  featured: ManifoldIntegration[];\n  featuredOn: boolean;\n  featuredShown: boolean;\n  connectedMap: Record<string, boolean>;\n  onOpen: (id: string, el: HTMLElement) => void;\n  registerRef: (id: string, el: HTMLElement | null) => void;\n  requestHref: string;\n  onRequest?: (query: string) => void;\n}\n\nfunction Body({\n  uid,\n  headingId,\n  reducedMotion,\n  eyebrow,\n  title,\n  subtitle,\n  total,\n  query,\n  setQuery,\n  searchRef,\n  cats,\n  tab,\n  setTab,\n  allLabel,\n  searched,\n  visible,\n  featured,\n  featuredOn,\n  featuredShown,\n  connectedMap,\n  onOpen,\n  registerRef,\n  requestHref,\n  onRequest,\n}: BodyProps) {\n  const headRef = React.useRef<HTMLDivElement>(null);\n  const gridRef = React.useRef<HTMLDivElement>(null);\n  const headInView = useInView(headRef, { once: true, amount: 0.2 });\n  const gridInView = useInView(gridRef, { once: true, amount: 0.05 });\n  // Never stuck invisible: if an in-view trigger never fires (print, odd\n  // scroll parents), reveal anyway after a beat.\n  const [fallback, setFallback] = React.useState(false);\n  React.useEffect(() => {\n    const t = window.setTimeout(() => setFallback(true), 2400);\n    return () => window.clearTimeout(t);\n  }, []);\n  const hShow = reducedMotion || headInView || fallback;\n  const gShow = reducedMotion || gridInView || fallback;\n\n  // Cascade window: during the intro the grid staggers in; afterwards only\n  // newly-entering cards fade in place while the rest re-flow.\n  const [intro, setIntro] = React.useState(true);\n  React.useEffect(() => {\n    if (!gShow) return;\n    const t = window.setTimeout(() => setIntro(false), 950);\n    return () => window.clearTimeout(t);\n  }, [gShow]);\n\n  const rise = (delay: number) =>\n    reducedMotion\n      ? { initial: false as const, animate: { opacity: 1, y: 0 } }\n      : {\n          initial: { opacity: 0, y: 10 },\n          animate: hShow ? { opacity: 1, y: 0 } : { opacity: 0, y: 10 },\n          transition: { duration: 0.5, ease: EASE, delay },\n        };\n\n  const countIn = (cat: string | null) => (cat ? searched.filter((i) => i.category === cat).length : searched.length);\n  const tabLabel = (name: string, n: number) => (\n    <span className=\"flex items-center gap-1.5\">\n      {name}\n      <span className={cn(\"text-[11px] tabular-nums\", n === 0 ? \"text-white/25\" : \"text-white/40\")}>{n}</span>\n    </span>\n  );\n\n  const gridId = `${uid}-grid`;\n  const grid =\n    visible.length > 0 ? (\n      <ul id={gridId} className=\"grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-3\">\n        <AnimatePresence initial={false} mode=\"popLayout\">\n          {visible.map((item, i) => (\n            <IntegrationCard\n              key={item.id}\n              item={item}\n              connected={Boolean(connectedMap[item.id])}\n              delay={intro ? 0.18 + Math.min(i, 10) * 0.03 : 0}\n              show={gShow}\n              enter={intro}\n              layoutId={`${uid}-card-${item.id}`}\n              reducedMotion={reducedMotion}\n              onOpen={onOpen}\n              registerRef={registerRef}\n            />\n          ))}\n        </AnimatePresence>\n      </ul>\n    ) : (\n      <motion.div\n        initial={{ opacity: 0 }}\n        animate={{ opacity: 1 }}\n        transition={FADE}\n        className=\"flex flex-col items-center gap-3 rounded-2xl border border-dashed border-white/[0.1] px-6 py-14 text-center\"\n      >\n        <span className=\"inline-flex size-11 items-center justify-center rounded-xl border border-white/10 bg-white/[0.03] text-white/45\">\n          <SearchGlyph className=\"size-5\" />\n        </span>\n        <p className=\"text-[14px] font-medium text-white\">\n          {query.trim() ? <>No integrations match “{query.trim()}”</> : \"Nothing in this category yet\"}\n        </p>\n        <p className=\"max-w-xs text-[13px] leading-relaxed text-white/50\">\n          Can&apos;t find what you need? Tell us which tool to support next.\n        </p>\n        <div className=\"mt-1 flex flex-wrap items-center justify-center gap-2\">\n          {query ? (\n            <button\n              type=\"button\"\n              onClick={() => {\n                setQuery(\"\");\n                searchRef.current?.focus();\n              }}\n              className=\"h-9 rounded-[10px] border border-white/10 px-3.5 text-[13px] text-white/75 transition-colors hover:bg-white/[0.05] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)]\"\n            >\n              Clear search\n            </button>\n          ) : null}\n          <a\n            href={requestHref}\n            onClick={(e) => {\n              if (onRequest) {\n                e.preventDefault();\n                onRequest(query.trim());\n              }\n            }}\n            className=\"group/req inline-flex h-9 items-center gap-1 rounded-[10px] px-3.5 text-[13px] font-medium text-[color:var(--mf-accent)] transition-colors hover:bg-white/[0.04] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)]\"\n          >\n            Request an integration\n            <span aria-hidden className=\"transition-transform motion-safe:group-hover/req:translate-x-0.5\">\n              →\n            </span>\n          </a>\n        </div>\n      </motion.div>\n    );\n\n  return (\n    <div className=\"mx-auto flex w-full max-w-6xl flex-col gap-8 px-5 py-10 @3xl:gap-10 @3xl:px-10 @3xl:py-14\">\n      {/* Header + search */}\n      <div ref={headRef} className=\"flex flex-col gap-6 @3xl:flex-row @3xl:items-end @3xl:justify-between\">\n        <div className=\"flex max-w-xl flex-col gap-3\">\n          <motion.div {...rise(0)} className=\"flex items-center gap-2.5\">\n            <span className=\"text-[12px] font-medium tracking-[0.14em] text-[color:var(--mf-accent)] uppercase\">{eyebrow}</span>\n            <span className=\"h-3 w-px bg-white/15\" />\n            <span className=\"text-[12px] text-white/50 tabular-nums\">{total} integrations</span>\n          </motion.div>\n          <motion.h2\n            {...rise(0.05)}\n            id={headingId}\n            className=\"text-[26px] leading-[1.15] font-semibold tracking-[-0.025em] text-balance text-white @3xl:text-[34px]\"\n          >\n            {title}\n          </motion.h2>\n          {subtitle ? (\n            <motion.p {...rise(0.1)} className=\"text-[14px] leading-relaxed text-pretty text-white/55\">\n              {subtitle}\n            </motion.p>\n          ) : null}\n        </div>\n        <motion.div {...rise(0.14)} className=\"relative w-full shrink-0 @3xl:w-72\">\n          <SearchGlyph className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-white/35\" />\n          <input\n            ref={searchRef}\n            type=\"search\"\n            value={query}\n            onChange={(e) => setQuery(e.target.value)}\n            onKeyDown={(e) => {\n              if (e.key === \"Escape\" && query) {\n                e.preventDefault();\n                setQuery(\"\");\n              }\n            }}\n            placeholder=\"Search integrations\"\n            aria-label=\"Search integrations\"\n            aria-controls={gridId}\n            className={cn(\n              \"h-10 w-full rounded-[10px] border border-white/[0.08] bg-white/[0.03] pr-9 pl-9 text-[13.5px] text-white placeholder:text-white/35\",\n              \"transition-colors outline-none hover:border-white/15 focus:border-[color:var(--mf-accent)]/60 focus:bg-white/[0.04]\",\n              \"focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)]/35\",\n              \"[&::-webkit-search-cancel-button]:appearance-none\"\n            )}\n          />\n          {query ? (\n            <button\n              type=\"button\"\n              aria-label=\"Clear search\"\n              onClick={() => {\n                setQuery(\"\");\n                searchRef.current?.focus();\n              }}\n              className=\"absolute top-1/2 right-1.5 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-white/45 transition-colors hover:bg-white/[0.06] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mf-accent)]\"\n            >\n              <CloseGlyph className=\"size-3.5\" />\n            </button>\n          ) : null}\n        </motion.div>\n      </div>\n\n      {/* Featured hero row — collapses while searching. */}\n      {featuredOn ? (\n        <AnimatePresence initial={false}>\n          {featuredShown ? (\n            <motion.div\n              key=\"featured\"\n              initial={{ opacity: 0, height: 0 }}\n              animate={{ opacity: 1, height: \"auto\" }}\n              exit={{ opacity: 0, height: 0 }}\n              transition={reducedMotion ? FADE : { duration: 0.32, ease: EASE }}\n              className=\"-mx-5 overflow-hidden @3xl:mx-0\"\n            >\n              <h3 className=\"sr-only\">Featured integrations</h3>\n              <ul className=\"flex snap-x snap-mandatory scroll-px-5 gap-3 overflow-x-auto px-5 pb-1 [scrollbar-width:none] @2xl:grid @2xl:grid-cols-3 @2xl:overflow-visible @3xl:px-0\">\n                {featured.map((item, i) => (\n                  <FeaturedCard\n                    key={item.id}\n                    item={item}\n                    connected={Boolean(connectedMap[item.id])}\n                    delay={0.12 + i * 0.06}\n                    show={hShow}\n                    reducedMotion={reducedMotion}\n                    onOpen={onOpen}\n                    registerRef={registerRef}\n                  />\n                ))}\n              </ul>\n            </motion.div>\n          ) : null}\n        </AnimatePresence>\n      ) : null}\n\n      {/* Category tabs + grid */}\n      <div ref={gridRef}>\n        <LayoutGroup id={`${uid}-grid`}>\n          <Detent\n            label=\"Filter integrations by category\"\n            value={tab}\n            onValueChange={setTab}\n            className=\"gap-5\"\n            listClassName=\"max-w-full overflow-x-auto [scrollbar-width:none]\"\n            panelClassName=\"focus-visible:ring-[color:var(--mf-accent)]/50\"\n            items={[\n              { value: ALL, label: tabLabel(allLabel, countIn(null)), content: tab === ALL ? grid : null },\n              ...cats.map((c) => ({\n                value: slug(c),\n                label: tabLabel(c, countIn(c)),\n                content: tab === slug(c) ? grid : null,\n              })),\n            ]}\n          />\n        </LayoutGroup>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}