{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "nav-mega-menu",
  "type": "registry:component",
  "title": "Nav Mega Menu",
  "description": "A top bar whose triggers open a wide mega menu with three columns of icon links, a featured card and a footer strip. Opens on hover with an intent delay and is fully keyboard driven.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "navigation",
    "navbar",
    "mega menu",
    "header",
    "dropdown",
    "keyboard",
    "navigation"
  ],
  "docs": "https://hyperblur.dev/effects/nav-mega-menu",
  "files": [
    {
      "path": "registry/hyperblur/nav-mega-menu.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/nav-mega-menu.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type NavMegaMenuIcon =\n  \"bolt\" | \"chart\" | \"shield\" | \"layers\" | \"code\" | \"globe\" | \"users\" | \"book\" | \"terminal\" | \"plug\" | \"spark\" | \"cube\";\n\nexport interface NavMegaMenuLink {\n  label: string;\n  href: string;\n}\n\nexport interface NavMegaMenuItem {\n  label: string;\n  description?: string;\n  href: string;\n  icon?: NavMegaMenuIcon;\n  badge?: string;\n}\n\nexport interface NavMegaMenuColumn {\n  title: string;\n  items: NavMegaMenuItem[];\n}\n\nexport interface NavMegaMenuFeatured {\n  eyebrow: string;\n  title: string;\n  description: string;\n  href: string;\n  cta: string;\n}\n\nexport interface NavMegaMenuEntry {\n  id: string;\n  label: string;\n  href?: string;\n  columns?: NavMegaMenuColumn[];\n  featured?: NavMegaMenuFeatured;\n  footer?: NavMegaMenuLink[];\n}\n\nexport interface NavMegaMenuProps extends Omit<React.HTMLAttributes<HTMLElement>, \"children\"> {\n  brand?: string;\n  menus?: NavMegaMenuEntry[];\n  signIn?: NavMegaMenuLink | null;\n  cta?: NavMegaMenuLink | null;\n  accent?: string;\n  openId?: string | null;\n  defaultOpenId?: string | null;\n  onOpenChange?: (id: string | null) => void;\n  hoverDelay?: number;\n  showBackdrop?: boolean;\n}\n\nconst css = `\n.hb-ke1 {\n  --hb-ke1-accent: #8b5cf6;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-ke1 *, .hb-ke1 *::before, .hb-ke1 *::after { box-sizing: border-box; }\n.hb-ke1-bar {\n  position: relative;\n  z-index: 3;\n  border-bottom: 1px solid rgba(255,255,255,.08);\n  background: rgba(10,10,10,.92);\n  backdrop-filter: saturate(140%) blur(12px);\n}\n.hb-ke1-row {\n  display: flex;\n  align-items: center;\n  gap: 20px;\n  max-width: 1120px;\n  height: 64px;\n  margin: 0 auto;\n  padding: 0 24px;\n}\n.hb-ke1-brand {\n  display: inline-flex;\n  align-items: center;\n  gap: 10px;\n  flex: none;\n  color: #ededed;\n  font-size: 16px;\n  font-weight: 650;\n  letter-spacing: -.01em;\n  text-decoration: none;\n  border-radius: 8px;\n}\n.hb-ke1-mark {\n  display: grid;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  border-radius: 8px;\n  background: linear-gradient(140deg, color-mix(in srgb, var(--hb-ke1-accent) 90%, #fff), color-mix(in srgb, var(--hb-ke1-accent) 55%, #000));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 18px -6px var(--hb-ke1-accent);\n}\n.hb-ke1-mark svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }\n.hb-ke1-nav {\n  display: flex;\n  align-items: center;\n  gap: 2px;\n  flex: 1;\n  min-width: 0;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n.hb-ke1-top {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 36px;\n  margin: 0;\n  padding: 0 12px;\n  border: 0;\n  border-radius: 999px;\n  background: transparent;\n  color: #a1a1a1;\n  font: inherit;\n  font-size: 14px;\n  font-weight: 500;\n  white-space: nowrap;\n  text-decoration: none;\n  cursor: pointer;\n  transition: color .18s ease, background-color .18s ease;\n}\n.hb-ke1-top:hover, .hb-ke1-top[aria-expanded=\"true\"] { color: #ededed; background: rgba(255,255,255,.06); }\n.hb-ke1-top svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .25s cubic-bezier(.2,.8,.2,1); }\n.hb-ke1-top[aria-expanded=\"true\"] svg { transform: rotate(180deg); }\n.hb-ke1-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }\n.hb-ke1-ghost, .hb-ke1-cta {\n  display: inline-flex;\n  align-items: center;\n  height: 36px;\n  padding: 0 14px;\n  border-radius: 999px;\n  font-size: 14px;\n  font-weight: 500;\n  text-decoration: none;\n  white-space: nowrap;\n  transition: background-color .18s ease, color .18s ease, transform .15s ease, box-shadow .2s ease;\n}\n.hb-ke1-ghost { color: #a1a1a1; }\n.hb-ke1-ghost:hover { color: #ededed; }\n.hb-ke1-cta {\n  gap: 6px;\n  color: #0a0a0a;\n  background: #ededed;\n  box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);\n}\n.hb-ke1-cta:hover { background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-ke1-accent) 25%, transparent); }\n.hb-ke1-cta:active { transform: scale(.97); }\n.hb-ke1-cta svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s ease; }\n.hb-ke1-cta:hover svg { transform: translateX(2px); }\n.hb-ke1 a:focus-visible, .hb-ke1 button:focus-visible { outline: 2px solid var(--hb-ke1-accent); outline-offset: 2px; }\n.hb-ke1-panel {\n  position: absolute;\n  z-index: 4;\n  top: 100%;\n  left: 0;\n  right: 0;\n  padding: 10px 24px 0;\n  pointer-events: none;\n}\n.hb-ke1-card {\n  position: relative;\n  max-width: 1072px;\n  margin: 0 auto;\n  overflow: hidden;\n  border: 1px solid rgba(255,255,255,.09);\n  border-radius: 18px;\n  background:\n    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--hb-ke1-accent) 10%, transparent), transparent 60%),\n    linear-gradient(#121212, #0e0e0e);\n  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 30px 80px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(0,0,0,.6);\n  opacity: 0;\n  visibility: hidden;\n  transform: translate3d(0,-8px,0) scale(.985);\n  transform-origin: 50% 0;\n  transition: opacity .2s ease, transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s;\n}\n.hb-ke1-panel[data-open=\"true\"] { pointer-events: auto; }\n.hb-ke1-panel[data-open=\"true\"] .hb-ke1-card {\n  opacity: 1;\n  visibility: visible;\n  transform: none;\n  transition: opacity .2s ease, transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s;\n}\n.hb-ke1-sheets { position: relative; }\n.hb-ke1-sheet {\n  display: grid;\n  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.15fr);\n  gap: 8px;\n  padding: 18px;\n  transition: opacity .18s ease;\n}\n.hb-ke1-sheet[data-on=\"false\"] { position: absolute; inset: 0; opacity: 0; visibility: hidden; }\n.hb-ke1-col { min-width: 0; padding: 6px; }\n.hb-ke1-colt {\n  margin: 4px 10px 10px;\n  color: #6f6f6f;\n  font-size: 11px;\n  font-weight: 600;\n  letter-spacing: .08em;\n  text-transform: uppercase;\n}\n.hb-ke1-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }\n.hb-ke1-item {\n  display: flex;\n  align-items: flex-start;\n  gap: 12px;\n  padding: 10px;\n  border-radius: 12px;\n  color: #ededed;\n  text-decoration: none;\n  transition: background-color .18s ease;\n}\n.hb-ke1-item:hover, .hb-ke1-item:focus-visible { background: rgba(255,255,255,.05); }\n.hb-ke1-sheet[data-on=\"true\"] .hb-ke1-item { animation: hb-ke1-in .42s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--hb-ke1-i) * 26ms); }\n.hb-ke1-ico {\n  display: grid;\n  place-items: center;\n  flex: none;\n  width: 34px;\n  height: 34px;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 10px;\n  background: linear-gradient(#1b1b1b, #141414);\n  color: #a1a1a1;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);\n  transition: color .18s ease, border-color .18s ease, background .18s ease;\n}\n.hb-ke1-ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }\n.hb-ke1-item:hover .hb-ke1-ico, .hb-ke1-item:focus-visible .hb-ke1-ico {\n  color: var(--hb-ke1-accent);\n  border-color: color-mix(in srgb, var(--hb-ke1-accent) 45%, transparent);\n  background: color-mix(in srgb, var(--hb-ke1-accent) 12%, #141414);\n}\n.hb-ke1-txt { min-width: 0; }\n.hb-ke1-lab { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 550; line-height: 1.3; }\n.hb-ke1-badge {\n  padding: 2px 7px;\n  border-radius: 999px;\n  background: color-mix(in srgb, var(--hb-ke1-accent) 18%, transparent);\n  color: color-mix(in srgb, var(--hb-ke1-accent) 70%, #fff);\n  font-size: 10.5px;\n  font-weight: 600;\n}\n.hb-ke1-desc { margin-top: 3px; color: #8f8f8f; font-size: 12.5px; line-height: 1.45; }\n.hb-ke1-feat {\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-end;\n  min-height: 260px;\n  margin: 6px;\n  padding: 18px;\n  overflow: hidden;\n  isolation: isolate;\n  border: 1px solid rgba(255,255,255,.09);\n  border-radius: 14px;\n  background: #0d0d10;\n  color: #ededed;\n  text-decoration: none;\n}\n.hb-ke1-feat::before {\n  content: \"\";\n  position: absolute;\n  z-index: -2;\n  inset: -40%;\n  background: conic-gradient(from 0deg at 50% 50%, transparent 0deg, color-mix(in srgb, var(--hb-ke1-accent) 55%, transparent) 70deg, transparent 140deg, rgba(56,189,248,.35) 220deg, transparent 300deg);\n  filter: blur(36px);\n  animation: hb-ke1-spin 12s linear infinite;\n}\n.hb-ke1-feat::after {\n  content: \"\";\n  position: absolute;\n  z-index: -1;\n  inset: 0;\n  background:\n    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px) 0 0 / 22px 22px,\n    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px) 0 0 / 22px 22px,\n    linear-gradient(180deg, rgba(13,13,16,.1), rgba(13,13,16,.92) 70%);\n}\n.hb-ke1-chip {\n  position: absolute;\n  top: 18px;\n  left: 18px;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 4px 10px;\n  border: 1px solid rgba(255,255,255,.14);\n  border-radius: 999px;\n  background: rgba(10,10,10,.5);\n  font-size: 11.5px;\n  font-weight: 550;\n}\n.hb-ke1-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--hb-ke1-accent); box-shadow: 0 0 10px var(--hb-ke1-accent); }\n.hb-ke1-ft { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }\n.hb-ke1-fd { margin: 6px 0 14px; color: #a1a1a1; font-size: 13px; line-height: 1.5; }\n.hb-ke1-fl { display: inline-flex; align-items: center; gap: 6px; color: #ededed; font-size: 13px; font-weight: 550; }\n.hb-ke1-fl svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s ease; }\n.hb-ke1-feat:hover .hb-ke1-fl svg { transform: translateX(3px); }\n.hb-ke1-foot {\n  display: flex;\n  align-items: center;\n  gap: 18px;\n  padding: 12px 24px;\n  border-top: 1px solid rgba(255,255,255,.07);\n  background: rgba(255,255,255,.02);\n  font-size: 12.5px;\n}\n.hb-ke1-foot span { color: #6f6f6f; }\n.hb-ke1-foot a { color: #a1a1a1; text-decoration: none; transition: color .15s ease; }\n.hb-ke1-foot a:hover { color: #ededed; }\n.hb-ke1-stage {\n  position: relative;\n  z-index: 1;\n  height: 520px;\n  overflow: hidden;\n  -webkit-mask-image: linear-gradient(#000 40%, transparent);\n  mask-image: linear-gradient(#000 40%, transparent);\n}\n.hb-ke1-stage::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background:\n    radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--hb-ke1-accent) 16%, transparent), transparent 70%),\n    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 48px 48px,\n    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 48px 48px;\n}\n.hb-ke1-hero { position: relative; max-width: 760px; margin: 0 auto; padding: 96px 24px 0; text-align: center; opacity: .42; }\n.hb-ke1-pill { display: inline-block; padding: 5px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; color: #a1a1a1; font-size: 12px; }\n.hb-ke1-h { margin: 20px 0 14px; font-size: clamp(30px, 6cqi, 56px); font-weight: 650; letter-spacing: -.035em; line-height: 1.04; }\n.hb-ke1-s { margin: 0 auto; max-width: 520px; color: #8f8f8f; font-size: 16px; line-height: 1.55; }\n.hb-ke1-frame { width: min(920px, calc(100% - 48px)); height: 200px; margin: 44px auto 0; border: 1px solid rgba(255,255,255,.1); border-radius: 16px 16px 0 0; background: linear-gradient(#141414, #0c0c0c); }\n.hb-ke1-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-ke1-in { from { opacity: 0; transform: translate3d(0,6px,0); } to { opacity: 1; transform: none; } }\n@keyframes hb-ke1-spin { to { transform: rotate(1turn); } }\n@container (max-width: 980px) {\n  .hb-ke1-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n  .hb-ke1-feat { min-height: 180px; grid-column: span 2; }\n}\n@container (max-width: 760px) {\n  .hb-ke1-row { flex-wrap: wrap; height: auto; padding: 12px 16px 0; row-gap: 6px; }\n  .hb-ke1-nav { order: 3; flex: 1 0 100%; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }\n  .hb-ke1-nav::-webkit-scrollbar { display: none; }\n  .hb-ke1-ghost { display: none; }\n  .hb-ke1-panel { padding: 8px 12px 0; }\n  .hb-ke1-sheet { grid-template-columns: minmax(0, 1fr); padding: 10px; max-height: 70vh; overflow-y: auto; }\n  .hb-ke1-feat { grid-column: auto; }\n  .hb-ke1-desc { display: none; }\n  .hb-ke1-foot { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }\n  .hb-ke1-hero { padding-top: 64px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ke1 *, .hb-ke1 *::before, .hb-ke1 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nconst paths: Record<NavMegaMenuIcon, string[]> = {\n  bolt: [\"M13 2 4 14h7l-1 8 9-12h-7l1-8z\"],\n  chart: [\"M4 20V10M10 20V4M16 20v-7M21 20H3\"],\n  shield: [\"M12 3 4 6v6c0 4.5 3.2 8 8 9 4.8-1 8-4.5 8-9V6l-8-3z\", \"m9 12 2 2 4-4\"],\n  layers: [\"m12 3 9 5-9 5-9-5 9-5z\", \"m3 13 9 5 9-5\"],\n  code: [\"m8 8-4 4 4 4M16 8l4 4-4 4M13.5 5l-3 14\"],\n  globe: [\"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18z\", \"M3 12h18M12 3c3 3.2 3 14.8 0 18M12 3c-3 3.2-3 14.8 0 18\"],\n  users: [\n    \"M16 20v-1.5a3.5 3.5 0 0 0-3.5-3.5h-4A3.5 3.5 0 0 0 5 18.5V20\",\n    \"M10.5 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6z\",\n    \"M19 20v-1.5a3.5 3.5 0 0 0-2.5-3.3M15.5 5.2a3 3 0 0 1 0 5.6\",\n  ],\n  book: [\"M4 5.5A2.5 2.5 0 0 1 6.5 3H20v16H6.5A2.5 2.5 0 0 0 4 21.5v-16z\", \"M4 21.5A2.5 2.5 0 0 1 6.5 19H20\"],\n  terminal: [\"M4 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z\", \"m7 10 3 2-3 2M13 15h4\"],\n  plug: [\"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8z\", \"M12 17v4\"],\n  spark: [\"M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5 18 18M6 18l2.5-2.5M15.5 8.5 18 6\"],\n  cube: [\"m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3z\", \"m4 7.5 8 4.5 8-4.5M12 12v9\"],\n};\n\nfunction Icon({ name }: { name: NavMegaMenuIcon }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n      {paths[name].map((d) => (\n        <path key={d} d={d} />\n      ))}\n    </svg>\n  );\n}\n\nconst defaultMenus: NavMegaMenuEntry[] = [\n  {\n    id: \"product\",\n    label: \"Product\",\n    columns: [\n      {\n        title: \"Platform\",\n        items: [\n          { label: \"Insights\", description: \"Funnels, cohorts and retention in one query\", href: \"#\", icon: \"chart\" },\n          { label: \"Flows\", description: \"Trigger journeys from live product events\", href: \"#\", icon: \"bolt\", badge: \"New\" },\n          { label: \"Warehouse sync\", description: \"Two-way sync with Snowflake and BigQuery\", href: \"#\", icon: \"layers\" },\n        ],\n      },\n      {\n        title: \"Build\",\n        items: [\n          { label: \"Events API\", description: \"Typed SDKs for 14 languages\", href: \"#\", icon: \"code\" },\n          { label: \"CLI\", description: \"Ship tracking plans from your terminal\", href: \"#\", icon: \"terminal\" },\n          { label: \"Integrations\", description: \"Connect 180+ tools in a click\", href: \"#\", icon: \"plug\" },\n        ],\n      },\n      {\n        title: \"Trust\",\n        items: [\n          { label: \"Security\", description: \"SSO, SCIM and audit trails\", href: \"#\", icon: \"shield\" },\n          { label: \"Data residency\", description: \"Host in the EU, US or Australia\", href: \"#\", icon: \"globe\" },\n          { label: \"Status\", description: \"99.99% uptime over 12 months\", href: \"#\", icon: \"spark\" },\n        ],\n      },\n    ],\n    featured: {\n      eyebrow: \"Lumen 4.2\",\n      title: \"Flows: journeys that react in under 200ms\",\n      description: \"Send the right nudge the moment a user hits a milestone, without a single cron job.\",\n      href: \"#\",\n      cta: \"See what shipped\",\n    },\n    footer: [\n      { label: \"Changelog\", href: \"#\" },\n      { label: \"Roadmap\", href: \"#\" },\n      { label: \"Book a demo\", href: \"#\" },\n    ],\n  },\n  {\n    id: \"solutions\",\n    label: \"Solutions\",\n    columns: [\n      {\n        title: \"By team\",\n        items: [\n          { label: \"Product\", description: \"Find the features that drive retention\", href: \"#\", icon: \"cube\" },\n          { label: \"Growth\", description: \"Experiment with every onboarding step\", href: \"#\", icon: \"spark\" },\n          { label: \"Engineering\", description: \"Debug releases with session context\", href: \"#\", icon: \"terminal\" },\n        ],\n      },\n      {\n        title: \"By stage\",\n        items: [\n          { label: \"Startups\", description: \"Free up to 10M events a month\", href: \"#\", icon: \"bolt\" },\n          { label: \"Scale-ups\", description: \"Governance without the overhead\", href: \"#\", icon: \"layers\" },\n          { label: \"Enterprise\", description: \"Dedicated clusters and support\", href: \"#\", icon: \"shield\" },\n        ],\n      },\n      {\n        title: \"By industry\",\n        items: [\n          { label: \"Fintech\", description: \"PCI-ready event pipelines\", href: \"#\", icon: \"chart\" },\n          { label: \"Marketplaces\", description: \"Two-sided funnels out of the box\", href: \"#\", icon: \"users\" },\n          { label: \"Media\", description: \"Engagement scoring per article\", href: \"#\", icon: \"book\" },\n        ],\n      },\n    ],\n    featured: {\n      eyebrow: \"Customer story\",\n      title: \"How Fernway cut churn by 18% in one quarter\",\n      description: \"Their product team replaced four dashboards with a single retention view.\",\n      href: \"#\",\n      cta: \"Read the story\",\n    },\n    footer: [\n      { label: \"All customers\", href: \"#\" },\n      { label: \"Partners\", href: \"#\" },\n    ],\n  },\n  {\n    id: \"developers\",\n    label: \"Developers\",\n    columns: [\n      {\n        title: \"Docs\",\n        items: [\n          { label: \"Quickstart\", description: \"Track your first event in five minutes\", href: \"#\", icon: \"bolt\" },\n          { label: \"API reference\", description: \"Every endpoint with live examples\", href: \"#\", icon: \"code\" },\n        ],\n      },\n      {\n        title: \"Tools\",\n        items: [\n          { label: \"SDKs\", description: \"Web, iOS, Android, Node and Go\", href: \"#\", icon: \"cube\" },\n          { label: \"Webhooks\", description: \"Signed payloads with automatic retries\", href: \"#\", icon: \"plug\" },\n        ],\n      },\n      {\n        title: \"Community\",\n        items: [\n          { label: \"Forum\", description: \"12,400 builders sharing recipes\", href: \"#\", icon: \"users\" },\n          { label: \"Guides\", description: \"Patterns from production teams\", href: \"#\", icon: \"book\" },\n        ],\n      },\n    ],\n    featured: {\n      eyebrow: \"Open source\",\n      title: \"lumen-js passed 9,000 stars\",\n      description: \"The tracking SDK is MIT licensed and tree-shakes to 3.1 kB.\",\n      href: \"#\",\n      cta: \"View on GitHub\",\n    },\n  },\n  { id: \"pricing\", label: \"Pricing\", href: \"#\" },\n  { id: \"customers\", label: \"Customers\", href: \"#\" },\n];\n\nexport function NavMegaMenu({\n  brand = \"Lumen\",\n  menus = defaultMenus,\n  signIn = { label: \"Sign in\", href: \"#\" },\n  cta = { label: \"Start free\", href: \"#\" },\n  accent = \"#8b5cf6\",\n  openId,\n  defaultOpenId = null,\n  onOpenChange,\n  hoverDelay = 120,\n  showBackdrop = true,\n  className = \"\",\n  style,\n  ...rest\n}: NavMegaMenuProps) {\n  const uid = React.useId();\n  const [inner, setInner] = React.useState<string | null>(defaultOpenId);\n  const current = openId !== undefined ? openId : inner;\n  const rootRef = React.useRef<HTMLElement>(null);\n  const tops = React.useRef<(HTMLElement | null)[]>([]);\n  const openTimer = React.useRef<number | undefined>(undefined);\n  const closeTimer = React.useRef<number | undefined>(undefined);\n  const mega = menus.filter((m) => m.columns && m.columns.length);\n  const active = mega.find((m) => m.id === current) ?? null;\n\n  const setOpen = React.useCallback(\n    (id: string | null) => {\n      if (openId === undefined) setInner(id);\n      onOpenChange?.(id);\n    },\n    [openId, onOpenChange],\n  );\n\n  React.useEffect(\n    () => () => {\n      window.clearTimeout(openTimer.current);\n      window.clearTimeout(closeTimer.current);\n    },\n    [],\n  );\n\n  React.useEffect(() => {\n    if (!active) return;\n    const onDown = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(null);\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [active, setOpen]);\n\n  function clearTimers() {\n    window.clearTimeout(openTimer.current);\n    window.clearTimeout(closeTimer.current);\n  }\n\n  function hoverTop(e: React.PointerEvent, id: string | null) {\n    if (e.pointerType !== \"mouse\") return;\n    clearTimers();\n    if (id === null) {\n      if (active) closeTimer.current = window.setTimeout(() => setOpen(null), hoverDelay + 80);\n      return;\n    }\n    if (active) setOpen(id);\n    else openTimer.current = window.setTimeout(() => setOpen(id), hoverDelay);\n  }\n\n  function leaveRoot(e: React.PointerEvent) {\n    if (e.pointerType !== \"mouse\") return;\n    clearTimers();\n    closeTimer.current = window.setTimeout(() => setOpen(null), hoverDelay + 100);\n  }\n\n  function items(id: string) {\n    const panel = document.getElementById(`${uid}-${id}`);\n    return panel ? Array.from(panel.querySelectorAll<HTMLElement>(\"[data-hb-ke1-item]\")) : [];\n  }\n\n  function focusTop(index: number) {\n    const list = tops.current.filter((n): n is HTMLElement => Boolean(n));\n    if (!list.length) return;\n    list[(index + list.length) % list.length].focus();\n  }\n\n  function onTopKey(e: React.KeyboardEvent, index: number, entry: NavMegaMenuEntry) {\n    const hasMenu = Boolean(entry.columns && entry.columns.length);\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      focusTop(index + 1);\n      if (active && hasMenu) setOpen(null);\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      focusTop(index - 1);\n      if (active && hasMenu) setOpen(null);\n    } else if (e.key === \"ArrowDown\" && hasMenu) {\n      e.preventDefault();\n      setOpen(entry.id);\n      window.requestAnimationFrame(() => items(entry.id)[0]?.focus());\n    } else if (e.key === \"Escape\") {\n      setOpen(null);\n    }\n  }\n\n  function onPanelKey(e: React.KeyboardEvent) {\n    if (!active) return;\n    const list = items(active.id);\n    const at = list.indexOf(document.activeElement as HTMLElement);\n    if (e.key === \"Escape\") {\n      e.preventDefault();\n      const index = menus.findIndex((m) => m.id === active.id);\n      setOpen(null);\n      tops.current[index]?.focus();\n    } else if (e.key === \"ArrowDown\" || e.key === \"ArrowRight\") {\n      e.preventDefault();\n      list[(at + 1) % list.length]?.focus();\n    } else if (e.key === \"ArrowUp\" || e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      if (at <= 0) {\n        const index = menus.findIndex((m) => m.id === active.id);\n        tops.current[index]?.focus();\n      } else list[at - 1]?.focus();\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      list[0]?.focus();\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      list[list.length - 1]?.focus();\n    }\n  }\n\n  function onBlur(e: React.FocusEvent) {\n    const next = e.relatedTarget as Node | null;\n    if (active && next && rootRef.current && !rootRef.current.contains(next)) setOpen(null);\n  }\n\n  const arrow = (\n    <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n      <path d=\"M3 8h10M9 4l4 4-4 4\" />\n    </svg>\n  );\n\n  return (\n    <header\n      ref={rootRef}\n      className={`hb-ke1 ${className}`}\n      style={{ \"--hb-ke1-accent\": accent, ...style } as React.CSSProperties}\n      onPointerLeave={leaveRoot}\n      onPointerEnter={() => window.clearTimeout(closeTimer.current)}\n      onBlur={onBlur}\n      {...rest}\n    >\n      <style href=\"hb-nav-mega-menu\" precedence=\"default\">\n        {css}\n      </style>\n      <div className=\"hb-ke1-bar\">\n        <div className=\"hb-ke1-row\">\n          <a href=\"#\" className=\"hb-ke1-brand\" aria-label={`${brand} home`}>\n            <span className=\"hb-ke1-mark\" aria-hidden=\"true\">\n              <svg viewBox=\"0 0 16 16\">\n                <path d=\"M4 3v10h8\" />\n                <path d=\"M8 3v6h4\" />\n              </svg>\n            </span>\n            {brand}\n          </a>\n          <ul className=\"hb-ke1-nav\" aria-label=\"Main\">\n            {menus.map((entry, i) => {\n              const hasMenu = Boolean(entry.columns && entry.columns.length);\n              const open = current === entry.id && hasMenu;\n              return (\n                <li key={entry.id}>\n                  {hasMenu ? (\n                    <button\n                      type=\"button\"\n                      ref={(n) => {\n                        tops.current[i] = n;\n                      }}\n                      className=\"hb-ke1-top\"\n                      aria-expanded={open}\n                      aria-controls={`${uid}-${entry.id}`}\n                      onClick={() => setOpen(open ? null : entry.id)}\n                      onPointerEnter={(e) => hoverTop(e, entry.id)}\n                      onKeyDown={(e) => onTopKey(e, i, entry)}\n                    >\n                      {entry.label}\n                      <svg viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n                        <path d=\"m3 4.5 3 3 3-3\" />\n                      </svg>\n                    </button>\n                  ) : (\n                    <a\n                      ref={(n) => {\n                        tops.current[i] = n;\n                      }}\n                      href={entry.href ?? \"#\"}\n                      className=\"hb-ke1-top\"\n                      onPointerEnter={(e) => hoverTop(e, null)}\n                      onKeyDown={(e) => onTopKey(e, i, entry)}\n                    >\n                      {entry.label}\n                    </a>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n          <div className=\"hb-ke1-end\">\n            {signIn && (\n              <a href={signIn.href} className=\"hb-ke1-ghost\">\n                {signIn.label}\n              </a>\n            )}\n            {cta && (\n              <a href={cta.href} className=\"hb-ke1-cta\">\n                {cta.label}\n                {arrow}\n              </a>\n            )}\n          </div>\n        </div>\n        <div className=\"hb-ke1-panel\" data-open={active ? \"true\" : \"false\"} onKeyDown={onPanelKey}>\n          <div className=\"hb-ke1-card\">\n            <div className=\"hb-ke1-sheets\">\n              {mega.map((entry) => {\n                const on = active?.id === entry.id;\n                let n = 0;\n                return (\n                  <div key={entry.id} id={`${uid}-${entry.id}`} data-on={on ? \"true\" : \"false\"} aria-label={entry.label} role=\"region\">\n                    <div className=\"hb-ke1-sheet\" data-on={on ? \"true\" : \"false\"}>\n                      {entry.columns!.map((col) => (\n                        <div key={col.title} className=\"hb-ke1-col\">\n                          <p className=\"hb-ke1-colt\">{col.title}</p>\n                          <ul className=\"hb-ke1-list\">\n                            {col.items.map((item) => {\n                              const i = n++;\n                              return (\n                                <li key={item.label}>\n                                  <a\n                                    href={item.href}\n                                    className=\"hb-ke1-item\"\n                                    data-hb-ke1-item=\"\"\n                                    style={{ \"--hb-ke1-i\": i } as React.CSSProperties}\n                                    onClick={() => setOpen(null)}\n                                  >\n                                    {item.icon && (\n                                      <span className=\"hb-ke1-ico\">\n                                        <Icon name={item.icon} />\n                                      </span>\n                                    )}\n                                    <span className=\"hb-ke1-txt\">\n                                      <span className=\"hb-ke1-lab\">\n                                        {item.label}\n                                        {item.badge && <span className=\"hb-ke1-badge\">{item.badge}</span>}\n                                      </span>\n                                      {item.description && <span className=\"hb-ke1-desc\">{item.description}</span>}\n                                    </span>\n                                  </a>\n                                </li>\n                              );\n                            })}\n                          </ul>\n                        </div>\n                      ))}\n                      {entry.featured && (\n                        <a href={entry.featured.href} className=\"hb-ke1-feat\" data-hb-ke1-item=\"\" onClick={() => setOpen(null)}>\n                          <span className=\"hb-ke1-chip\">\n                            <i />\n                            {entry.featured.eyebrow}\n                          </span>\n                          <p className=\"hb-ke1-ft\">{entry.featured.title}</p>\n                          <p className=\"hb-ke1-fd\">{entry.featured.description}</p>\n                          <span className=\"hb-ke1-fl\">\n                            {entry.featured.cta}\n                            {arrow}\n                          </span>\n                        </a>\n                      )}\n                    </div>\n                    {on && entry.footer && entry.footer.length > 0 && (\n                      <div className=\"hb-ke1-foot\">\n                        <span>Also in {entry.label}</span>\n                        {entry.footer.map((link) => (\n                          <a key={link.label} href={link.href} data-hb-ke1-item=\"\">\n                            {link.label}\n                          </a>\n                        ))}\n                      </div>\n                    )}\n                  </div>\n                );\n              })}\n            </div>\n          </div>\n        </div>\n      </div>\n      {showBackdrop && (\n        <div className=\"hb-ke1-stage\" aria-hidden=\"true\">\n          <div className=\"hb-ke1-hero\">\n            <span className=\"hb-ke1-pill\">Trusted by 4,200 product teams</span>\n            <p className=\"hb-ke1-h\">Product analytics that answers back</p>\n            <p className=\"hb-ke1-s\">Ask a question about your users and get a chart, a cohort and the next experiment to run.</p>\n          </div>\n          <div className=\"hb-ke1-frame\" />\n        </div>\n      )}\n    </header>\n  );\n}\n"
    }
  ]
}