{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dynamic-island-nav",
  "type": "registry:ui",
  "title": "Dynamic Island Navigation",
  "description": "An iOS-inspired adaptive Dynamic Island navigation bar with fluid physics.",
  "dependencies": [
    "react",
    "motion"
  ],
  "devDependencies": [
    "@types/react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "ui/dynamic-island-nav.tsx",
      "content": "\"use client\";\n\nimport React, {\n  useEffect,\n  useId,\n  useRef,\n  useState,\n} from \"react\";\nimport {\n  motion,\n  AnimatePresence,\n  LayoutGroup,\n} from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\n\n\nexport const ICONS: Record<string, { viewBox: string; svg: string }> = {\n  home: {\n    viewBox: \"0 0 48 48\",\n    svg: '<path fill=\"currentColor\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M20.5682 2.81246c2.1784 -0.99734 4.6852 -0.99734 6.8636 0 7.7657 3.5554 13.5513 8.64154 16.3373 11.38514 1.5022 1.4793 2.3049 3.4519 2.4175 5.4865 0.1388 2.5072 0.3134 6.5725 0.3134 11.1586 0 3.2363 -0.087 6.2126 -0.1868 8.5643 -0.1601 3.7688 -3.1695 6.7252 -6.9275 6.8541 -3.4773 0.1192 -8.6464 0.2389 -15.3857 0.2389s-11.9084 -0.1197 -15.38569 -0.2389c-3.75796 -0.1289 -6.76743 -3.0853 -6.92748 -6.8541C1.58696 37.0553 1.5 34.079 1.5 30.8427c0 -4.5861 0.17463 -8.6514 0.31339 -11.1586 0.1126 -2.0346 0.91528 -4.0072 2.41753 -5.4865C7.01693 11.454 12.8025 6.36786 20.5682 2.81246ZM16 36c-1.1046 0 -2 0.8954 -2 2s0.8954 2 2 2h16c1.1046 0 2 -0.8954 2 -2s-0.8954 -2 -2 -2H16Z\"/>',\n  },\n  feature: {\n    viewBox: \"0 0 24 24\",\n    svg: '<path fill=\"currentColor\" opacity=\"0.45\" d=\"M2 12c0 -4.71405 0 -7.07107 1.46447 -8.53553C4.92893 2 7.28595 2 12 2c4.714 0 7.0711 0 8.5355 1.46447C22 4.92893 22 7.28595 22 12c0 4.714 0 7.0711 -1.4645 8.5355C19.0711 22 16.714 22 12 22c-4.71405 0 -7.07107 0 -8.53553 -1.4645C2 19.0711 2 16.714 2 12Z\"/><path fill=\"currentColor\" d=\"M3.46451 20.5355C4.92902 22 7.28611 22 12.0003 22c4.7142 0 7.0713 0 8.5358 -1.4645C21.8931 19.1785 21.9927 17.0551 22 13h-3.1598c-0.9052 0 -1.3578 0 -1.7556 0.183 -0.3978 0.1829 -0.6924 0.5266 -1.2815 1.2138l-0.6054 0.7064c-0.5891 0.6872 -0.8837 1.0309 -1.2815 1.2138 -0.3978 0.183 -0.8504 0.183 -1.7556 0.183H11.84c-0.9052 0 -1.3578 0 -1.7556 -0.183 -0.39785 -0.1829 -0.6924 -0.5266 -1.28149 -1.2138l-0.60544 -0.7064c-0.5891 -0.6872 -0.88365 -1.0309 -1.28148 -1.2138C6.51815 13 6.06555 13 5.16035 13H2c0.0073 4.0551 0.10744 6.1785 1.46451 7.5355Z\"/><path fill=\"currentColor\" d=\"M8 6.25c-0.41421 0 -0.75 0.33579 -0.75 0.75s0.33579 0.75 0.75 0.75h8c0.4142 0 0.75 -0.33579 0.75 -0.75s-0.3358 -0.75 -0.75 -0.75H8Z\"/><path fill=\"currentColor\" d=\"M10 9.75c-0.41421 0 -0.75 0.3358 -0.75 0.75s0.33579 0.75 0.75 0.75h4c0.4142 0 0.75 -0.3358 0.75 -0.75s-0.3358 -0.75 -0.75 -0.75h-4Z\"/>',\n  },\n  showcase: {\n    viewBox: \"0 0 24 24\",\n    svg: '<path fill=\"currentColor\" opacity=\"0.45\" d=\"M2 17.5c0 -2.1213 0 -3.182 0.65901 -3.841C3.31802 13 4.37868 13 6.5 13s3.18198 0 3.841 0.659C11 14.318 11 15.3787 11 17.5s0 3.182 -0.659 3.841C9.68198 22 8.62132 22 6.5 22s-3.18198 0 -3.84099 -0.659C2 20.682 2 19.6213 2 17.5Z\"/><path fill=\"currentColor\" fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M17.5 2.75c0.4142 0 0.75 0.33579 0.75 0.75v2.25h2.25c0.4142 0 0.75 0.33579 0.75 0.75s-0.3358 0.75 -0.75 0.75h-2.25V9.5c0 0.41421 -0.3358 0.75 -0.75 0.75s-0.75 -0.33579 -0.75 -0.75V7.25H14.5c-0.4142 0 -0.75 -0.33579 -0.75 -0.75s0.3358 -0.75 0.75 -0.75h2.25V3.5c0 -0.41421 0.3358 -0.75 0.75 -0.75Z\"/><path fill=\"currentColor\" d=\"M2 6.5c0 -2.12132 0 -3.18198 0.65901 -3.84099C3.31802 2 4.37868 2 6.5 2s3.18198 0 3.841 0.65901C11 3.31802 11 4.37868 11 6.5s0 3.18198 -0.659 3.841C9.68198 11 8.62132 11 6.5 11s-3.18198 0 -3.84099 -0.659C2 9.68198 2 8.62132 2 6.5Z\"/><path fill=\"currentColor\" d=\"M13 17.5c0 -2.1213 0 -3.182 0.659 -3.841C14.318 13 15.3787 13 17.5 13s3.182 0 3.841 0.659C22 14.318 22 15.3787 22 17.5s0 3.182 -0.659 3.841C20.682 22 19.6213 22 17.5 22s-3.182 0 -3.841 -0.659C13 20.682 13 19.6213 13 17.5Z\"/>',\n  },\n  about: {\n    viewBox: \"0 0 24 24\",\n    svg: '<path fill=\"currentColor\" opacity=\"0.45\" d=\"M20 17.5c0 2.4853 0 4.5 -8 4.5s-8 -2.0147 -8 -4.5S7.58172 13 12 13c4.4183 0 8 2.0147 8 4.5Z\"/><path fill=\"currentColor\" d=\"M12 10c2.2091 0 4 -1.79086 4 -4s-1.7909 -4 -4 -4C9.79086 2 8 3.79086 8 6s1.79086 4 4 4Z\"/>',\n  },\n  contact: {\n    viewBox: \"0 0 24 24\",\n    svg: '<path fill=\"currentColor\" opacity=\"0.45\" d=\"M14.2 3H9.8C5.65164 3 3.57746 3 2.28873 4.31802 1 5.63604 1 7.75736 1 12c0 4.2426 0 6.364 1.28873 7.682C3.57746 21 5.65164 21 9.8 21h4.4c4.1484 0 6.2225 0 7.5113 -1.318C23 18.364 23 16.2426 23 12c0 -4.24264 0 -6.36396 -1.2887 -7.68198C20.4225 3 18.3484 3 14.2 3Z\"/><path fill=\"currentColor\" d=\"M19.1284 8.034c0.35 -0.29169 0.3973 -0.81191 0.1056 -1.16194 -0.2917 -0.35002 -0.8119 -0.39732 -1.1619 -0.10563l-2.3748 1.97899c-1.0263 0.85521 -1.7388 1.44708 -2.3403 1.83398 -0.5823 0.3745 -0.9772 0.5002 -1.3568 0.5002 -0.3796 0 -0.7744 -0.1257 -1.3567 -0.5002 -0.6016 -0.3869 -1.31409 -0.97877 -2.34035 -1.83398L5.92837 6.76643c-0.35003 -0.29169 -0.87025 -0.24439 -1.16194 0.10563 -0.29169 0.35003 -0.24439 0.87025 0.10563 1.16194l2.41615 2.0135c0.97499 0.8125 1.76523 1.471 2.4627 1.9196 0.72659 0.4673 1.43409 0.7625 2.24929 0.7625 0.8152 0 1.5228 -0.2952 2.2493 -0.7625 0.6975 -0.4486 1.4877 -1.1071 2.4627 -1.9197l2.4162 -2.0134Z\"/>',\n  },\n  dots: {\n    viewBox: \"0 0 24 24\",\n    svg: '<path fill=\"currentColor\" opacity=\"0.45\" d=\"M14 12c0 1.1046 -0.8954 2 -2 2s-2 -0.8954 -2 -2 0.8954 -2 2 -2 2 0.8954 2 2Z\"/><path fill=\"currentColor\" d=\"M7 12c0 1.1046 -0.89543 2 -2 2s-2 -0.8954 -2 -2 0.89543 -2 2 -2 2 0.8954 2 2Z\"/><path fill=\"currentColor\" d=\"M21 12c0 1.1046 -0.8954 2 -2 2s-2 -0.8954 -2 -2 0.8954 -2 2 -2 2 0.8954 2 2Z\"/>',\n  },\n};\n\nfunction Glyph({ name = \"home\" }: { name?: string }) {\n  const icon = ICONS[name] || ICONS.home;\n  return (\n    <svg\n      className=\"w-5 h-5 flex-none overflow-visible\"\n      viewBox={icon.viewBox}\n      aria-hidden=\"true\"\n      focusable=\"false\"\n      dangerouslySetInnerHTML={{ __html: icon.svg }}\n    />\n  );\n}\n\nfunction findSection(id: string) {\n  if (!id || typeof document === \"undefined\") return null;\n  const cleanId = id.replace(/^#/, \"\");\n  const el = document.getElementById(cleanId);\n  if (el) return el;\n  try {\n    return document.querySelector(`[data-section=\"${cleanId}\" i], #${cleanId}`);\n  } catch {\n    return null;\n  }\n}\n\nexport interface DynamicIslandNavItem {\n  id: string;\n  label: string;\n  icon?: string;\n  section?: string;\n  href?: string;\n}\n\nexport interface DynamicIslandNavProps {\n  items?: DynamicIslandNavItem[];\n  activeId?: string;\n  onSelect?: (id: string) => void;\n  theme?: \"dark\" | \"light\";\n  compactOnScroll?: boolean;\n  scrollOffset?: number;\n  className?: string;\n  containerClassName?: string;\n  scrollContainerRef?: React.RefObject<HTMLElement | null>;\n  forceCompact?: boolean;\n}\n\nconst DEFAULT_ITEMS: DynamicIslandNavItem[] = [\n  { id: \"home\", label: \"Home\", icon: \"home\", section: \"home\" },\n  { id: \"features\", label: \"Features\", icon: \"feature\", section: \"features\" },\n  { id: \"showcase\", label: \"Showcase\", icon: \"showcase\", section: \"showcase\" },\n  { id: \"about\", label: \"About\", icon: \"about\", section: \"about\" },\n  { id: \"contact\", label: \"Contact\", icon: \"contact\", section: \"contact\" },\n];\n\nconst springTransition = {\n  type: \"spring\" as const,\n  stiffness: 420,\n  damping: 32,\n  mass: 0.8,\n};\n\nconst swapTransition = {\n  type: \"spring\" as const,\n  stiffness: 380,\n  damping: 28,\n  mass: 0.6,\n};\n\nconst swapVariants = {\n  enter: (dir: number) => ({\n    y: dir * 12,\n    opacity: 0,\n    filter: \"blur(3px)\",\n  }),\n  center: {\n    y: 0,\n    opacity: 1,\n    filter: \"blur(0px)\",\n  },\n  exit: (dir: number) => ({\n    y: -dir * 12,\n    opacity: 0,\n    filter: \"blur(3px)\",\n  }),\n};\n\nexport default function DynamicIslandNav({\n  items = DEFAULT_ITEMS,\n  activeId: controlledActiveId,\n  onSelect,\n  theme = \"dark\",\n  compactOnScroll = true,\n  scrollOffset = 80,\n  className = \"\",\n  containerClassName,\n  scrollContainerRef,\n  forceCompact,\n}: DynamicIslandNavProps) {\n  const reactId = useId();\n  const navId = \"din-\" + reactId.replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const [activeIdx, setActiveIdx] = useState(0);\n  const [prevIdx, setPrevIdx] = useState(0);\n  const [direction, setDirection] = useState(1);\n\n  if (activeIdx !== prevIdx) {\n    setDirection(activeIdx > prevIdx ? 1 : -1);\n    setPrevIdx(activeIdx);\n  }\n\n  const [hoverIdx, setHoverIdx] = useState<number | null>(null);\n  const [scrolled, setScrolled] = useState(false);\n  const [hoverOpen, setHoverOpen] = useState(false);\n  const [forceOpen, setForceOpen] = useState(false);\n  const [open, setOpen] = useState(false);\n  const [isMobile, setIsMobile] = useState(false);\n\n  const containerRef = useRef<HTMLDivElement | null>(null);\n  const leaveTimerRef = useRef<NodeJS.Timeout | null>(null);\n  const hoverTimerRef = useRef<NodeJS.Timeout | null>(null);\n  const forceOpenRef = useRef(false);\n  const scrolledRef = useRef(false);\n  const spyLockRef = useRef<number>(0);\n  const shapeAtRef = useRef<number>(0);\n  const armRef = useRef({ armed: true, x: -1, y: -1 });\n\n  forceOpenRef.current = forceOpen;\n\n  // Responsive Breakpoint Observer\n  useEffect(() => {\n    const checkMobile = () => {\n      setIsMobile(window.innerWidth < 640);\n    };\n    checkMobile();\n    window.addEventListener(\"resize\", checkMobile);\n    return () => window.removeEventListener(\"resize\", checkMobile);\n  }, []);\n\n  // Sync external controlled activeId\n  useEffect(() => {\n    if (controlledActiveId) {\n      const idx = items.findIndex((it) => it.id === controlledActiveId);\n      if (idx >= 0) setActiveIdx(idx);\n    }\n  }, [controlledActiveId, items]);\n\n  // Compact state calculation (supports manual override via forceCompact prop)\n  const isCompactState =\n    forceCompact !== undefined\n      ? forceCompact\n      : (!isMobile && compactOnScroll && scrolled);\n  const compact = isCompactState && !forceOpen && !hoverOpen;\n\n  // Protect clicks on links that slide under resting pointer when expanding\n  const prevCompactRef = useRef(compact);\n  useEffect(() => {\n    if (prevCompactRef.current !== compact) {\n      prevCompactRef.current = compact;\n      shapeAtRef.current = performance.now();\n      armRef.current = { armed: false, x: -1, y: -1 };\n    }\n  }, [compact]);\n\n  // Scroll compaction listener (supports window, custom scrollContainerRef, or auto-detected scrolling ancestor)\n  useEffect(() => {\n    if (!compactOnScroll && forceCompact === undefined) return;\n\n    const getScrollParent = (node: HTMLElement | null): HTMLElement | Window => {\n      if (scrollContainerRef?.current) return scrollContainerRef.current;\n      let parent = node?.parentElement;\n      while (parent) {\n        const style = window.getComputedStyle(parent);\n        if (style.overflowY === 'auto' || style.overflowY === 'scroll') {\n          return parent;\n        }\n        parent = parent.parentElement;\n      }\n      return window;\n    };\n\n    const scrollParent = getScrollParent(containerRef.current);\n    const targets = scrollParent === window ? [window] : [scrollParent, window];\n\n    const getScrollY = () => {\n      if (scrollParent !== window) {\n        return (scrollParent as HTMLElement).scrollTop || 0;\n      }\n      return window.scrollY || 0;\n    };\n\n    let lastY = getScrollY();\n    let down = 0;\n    let up = 0;\n    let sinceOpen = 0;\n    let raf = 0;\n\n    const run = () => {\n      raf = 0;\n      const y = getScrollY();\n      const dy = y - lastY;\n      lastY = y;\n\n      if (y <= scrollOffset) {\n        down = 0;\n        up = 0;\n        scrolledRef.current = false;\n        setScrolled(false);\n        forceOpenRef.current = false;\n        setForceOpen(false);\n        return;\n      }\n\n      // Scrolling down by >48px while force-opened folds it back\n      if (forceOpenRef.current && dy > 0) {\n        sinceOpen += dy;\n        if (sinceOpen > 48) {\n          sinceOpen = 0;\n          forceOpenRef.current = false;\n          setForceOpen(false);\n        }\n      } else if (!forceOpenRef.current || dy < 0) {\n        sinceOpen = 0;\n      }\n\n      if (dy > 0) {\n        down += dy;\n        up = 0;\n        if (down > 15) {\n          scrolledRef.current = true;\n          setScrolled(true);\n        }\n      } else if (dy < 0) {\n        up -= dy;\n        down = 0;\n        if (up > 15) {\n          scrolledRef.current = false;\n          setScrolled(false);\n          forceOpenRef.current = false;\n          setForceOpen(false);\n        }\n      }\n    };\n\n    const onScroll = () => {\n      if (!raf) raf = requestAnimationFrame(run);\n    };\n\n    targets.forEach((t) => t.addEventListener(\"scroll\", onScroll, { passive: true, capture: true }));\n    return () => {\n      targets.forEach((t) => t.removeEventListener(\"scroll\", onScroll, { capture: true } as any));\n      if (raf) cancelAnimationFrame(raf);\n    };\n  }, [compactOnScroll, scrollOffset, scrollContainerRef, forceCompact]);\n\n  // Outside click closes forceOpen & mobile menu\n  useEffect(() => {\n    if (!forceOpen && !open) return;\n    let timer: NodeJS.Timeout | null = null;\n    const onOutside = (e: MouseEvent | PointerEvent) => {\n      const container = containerRef.current;\n      if (container && e.target instanceof Node && !container.contains(e.target)) {\n        if (forceOpen) {\n          forceOpenRef.current = false;\n          setForceOpen(false);\n        }\n        if (open) setOpen(false);\n      }\n    };\n    timer = setTimeout(() => {\n      document.addEventListener(\"pointerdown\", onOutside);\n    }, 60);\n\n    return () => {\n      if (timer) clearTimeout(timer);\n      document.removeEventListener(\"pointerdown\", onOutside);\n    };\n  }, [forceOpen, open]);\n\n  // Section Tracking (Scroll Spy)\n  useEffect(() => {\n    if (typeof window === \"undefined\") return;\n\n    const getScrollParent = (node: HTMLElement | null): HTMLElement | Window => {\n      if (scrollContainerRef?.current) return scrollContainerRef.current;\n      let parent = node?.parentElement;\n      while (parent) {\n        const style = window.getComputedStyle(parent);\n        if (style.overflowY === 'auto' || style.overflowY === 'scroll') {\n          return parent;\n        }\n        parent = parent.parentElement;\n      }\n      return window;\n    };\n\n    const scrollParent = getScrollParent(containerRef.current);\n    const targets = scrollParent === window ? [window] : [scrollParent, window];\n\n    const handleSpy = () => {\n      if (Date.now() < spyLockRef.current) return;\n      const isWindow = scrollParent === window;\n      const vh = isWindow ? window.innerHeight : (scrollParent as HTMLElement).clientHeight;\n      const containerTop = isWindow ? 0 : (scrollParent as HTMLElement).getBoundingClientRect().top;\n      const rootSearch = isWindow ? document : (scrollParent as HTMLElement);\n\n      let bestIdx = -1;\n      let maxCover = -1;\n\n      for (let i = 0; i < items.length; i++) {\n        const it = items[i];\n        const secId = it.section || it.id;\n        const cleanId = secId.replace(/^#/, \"\");\n        const el = rootSearch.querySelector(`[data-section=\"${cleanId}\" i], #${cleanId}`) || findSection(secId);\n        if (!el) continue;\n\n        const rect = el.getBoundingClientRect();\n        const top = rect.top - containerTop;\n        const bottom = rect.bottom - containerTop;\n        const visibleHeight = Math.min(bottom, vh) - Math.max(top, 0);\n\n        if (visibleHeight > 0) {\n          const ratio = visibleHeight / Math.min(vh, rect.height || vh);\n          if (ratio > maxCover) {\n            maxCover = ratio;\n            bestIdx = i;\n          }\n        }\n      }\n\n      if (bestIdx >= 0 && maxCover > 0.2) {\n        setActiveIdx(bestIdx);\n        onSelect?.(items[bestIdx].id);\n      }\n    };\n\n    targets.forEach((t) => t.addEventListener(\"scroll\", handleSpy, { passive: true, capture: true }));\n    handleSpy();\n    return () => targets.forEach((t) => t.removeEventListener(\"scroll\", handleSpy, { capture: true } as any));\n  }, [items, onSelect, scrollContainerRef]);\n\n  // Hover Intent (Opens compact island on hover, keeps open while pointer is inside)\n  const startHoverIntent = () => {\n    if (leaveTimerRef.current) {\n      clearTimeout(leaveTimerRef.current);\n      leaveTimerRef.current = null;\n    }\n    if (hoverOpen || hoverTimerRef.current) return;\n    hoverTimerRef.current = setTimeout(() => {\n      hoverTimerRef.current = null;\n      setHoverOpen(true);\n    }, 80);\n  };\n\n  const handleIslandEnter = () => {\n    if (isMobile) return;\n    if (leaveTimerRef.current) {\n      clearTimeout(leaveTimerRef.current);\n      leaveTimerRef.current = null;\n    }\n    startHoverIntent();\n  };\n\n  const handleIslandMove = (e: React.PointerEvent) => {\n    if (isMobile) return;\n    if (leaveTimerRef.current) {\n      clearTimeout(leaveTimerRef.current);\n      leaveTimerRef.current = null;\n    }\n    const arm = armRef.current;\n    if (!arm.armed) {\n      if (arm.x < 0) {\n        arm.x = e.clientX;\n        arm.y = e.clientY;\n      } else if (Math.hypot(e.clientX - arm.x, e.clientY - arm.y) > 6) {\n        arm.armed = true;\n      }\n    }\n    if (!hoverOpen) {\n      startHoverIntent();\n    }\n  };\n\n  const handleIslandLeave = () => {\n    if (isMobile) return;\n    if (hoverTimerRef.current) {\n      clearTimeout(hoverTimerRef.current);\n      hoverTimerRef.current = null;\n    }\n    setHoverIdx(null);\n\n    // If forceOpen was activated by clicking ⋯, do not fold back on mouse leave\n    if (forceOpenRef.current) return;\n\n    if (leaveTimerRef.current) clearTimeout(leaveTimerRef.current);\n    leaveTimerRef.current = setTimeout(() => {\n      leaveTimerRef.current = null;\n      setHoverOpen(false);\n    }, 350);\n  };\n\n  const handleItemClick = (i: number, e: React.MouseEvent) => {\n    // Slid-in link guard: ignore resting click on item that just slid into view\n    const timeSinceShape = performance.now() - shapeAtRef.current;\n    if (!isMobile && !armRef.current.armed && timeSinceShape < 450) {\n      e.preventDefault();\n      e.stopPropagation();\n      return;\n    }\n\n    setActiveIdx(i);\n    onSelect?.(items[i].id);\n    setOpen(false);\n    forceOpenRef.current = false;\n    setForceOpen(false);\n    setHoverOpen(false);\n\n    const it = items[i];\n    const targetId = it.section || it.id;\n    const cleanId = targetId.replace(/^#/, \"\");\n\n    const getScrollParent = (node: HTMLElement | null): HTMLElement | Window => {\n      if (scrollContainerRef?.current) return scrollContainerRef.current;\n      let parent = node?.parentElement;\n      while (parent) {\n        const style = window.getComputedStyle(parent);\n        if (style.overflowY === 'auto' || style.overflowY === 'scroll') {\n          return parent;\n        }\n        parent = parent.parentElement;\n      }\n      return window;\n    };\n\n    const scrollParent = getScrollParent(containerRef.current);\n    const rootSearch = scrollParent === window ? document : (scrollParent as HTMLElement);\n    const el = rootSearch.querySelector(`[data-section=\"${cleanId}\" i], #${cleanId}`) || findSection(targetId);\n\n    if (el) {\n      e.preventDefault();\n      spyLockRef.current = Date.now() + 1000;\n      if (scrollParent !== window) {\n        const parentEl = scrollParent as HTMLElement;\n        const targetTop =\n          (el as HTMLElement).getBoundingClientRect().top -\n          parentEl.getBoundingClientRect().top +\n          parentEl.scrollTop -\n          75;\n        parentEl.scrollTo({ top: Math.max(0, targetTop), behavior: \"smooth\" });\n      } else {\n        el.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n      }\n    }\n  };\n\n  const handleMoreClick = (e: React.MouseEvent) => {\n    e.preventDefault();\n    e.stopPropagation();\n    forceOpenRef.current = true;\n    setForceOpen(true);\n  };\n\n  return (\n    <div\n      className={cn(\n        \"fixed top-4 left-0 right-0 z-50 flex justify-center px-4 pointer-events-none select-none\",\n        containerClassName\n      )}\n    >\n      <LayoutGroup id={navId}>\n        <motion.nav\n          ref={containerRef}\n          layout\n          transition={springTransition}\n          onPointerEnter={handleIslandEnter}\n          onPointerMove={handleIslandMove}\n          onPointerLeave={handleIslandLeave}\n          className={cn(\n            \"relative pointer-events-auto flex flex-col items-center overflow-hidden border backdrop-blur-2xl transition-colors duration-300\",\n            isMobile && open ? \"rounded-[28px] w-full max-w-[340px]\" : \"rounded-full\",\n            theme === \"dark\"\n              ? \"bg-[#121214]/94 border-white/10 shadow-[0_18px_40px_-12px_rgba(0,0,0,0.65),0_1px_2px_rgba(0,0,0,0.2),inset_0_1px_0_0_rgba(255,255,255,0.12)] text-white\"\n              : \"bg-white/92 border-black/8 shadow-[0_16px_36px_-12px_rgba(15,15,20,0.2),0_1px_2px_rgba(15,15,20,0.06),inset_0_1px_0_0_rgba(255,255,255,0.7)] text-neutral-900\",\n            className\n          )}\n        >\n          {/* Main Horizontal Island Bar (Height 48px) */}\n          <div className=\"relative flex items-center h-12 px-1.5 w-full\">\n            {/* Desktop Navigation Links */}\n            {!isMobile && (\n              <div className=\"flex items-center gap-1\">\n                {compact ? (\n                  <>\n                    {/* Compact Active Capsule with Buttery Vertical Slide + Blur */}\n                    <motion.button\n                      key=\"compact-active-pill\"\n                      layout\n                      type=\"button\"\n                      transition={springTransition}\n                      onClick={(e) => handleItemClick(activeIdx, e)}\n                      className={cn(\n                        \"relative flex items-center h-[38px] rounded-full transition-colors cursor-pointer outline-none overflow-hidden select-none\",\n                        theme === \"dark\"\n                          ? \"text-white bg-white/[0.14] shadow-[inset_0_1px_0_0_rgba(255,255,255,0.14)]\"\n                          : \"text-neutral-950 bg-black/[0.08] shadow-[inset_0_1px_0_0_rgba(0,0,0,0.06)]\"\n                      )}\n                    >\n                      <div className=\"relative overflow-hidden h-[38px] flex items-center\">\n                        <AnimatePresence mode=\"popLayout\" custom={direction} initial={false}>\n                          <motion.div\n                            key={items[activeIdx]?.id}\n                            custom={direction}\n                            variants={swapVariants}\n                            initial=\"enter\"\n                            animate=\"center\"\n                            exit=\"exit\"\n                            transition={swapTransition}\n                            className=\"flex items-center gap-2 whitespace-nowrap px-3 h-full\"\n                          >\n                            <span className=\"grid place-items-center w-5 h-5 flex-none\">\n                              <Glyph name={items[activeIdx]?.icon || items[activeIdx]?.id} />\n                            </span>\n                            <span className=\"text-sm font-medium tracking-tight\">\n                              {items[activeIdx]?.label}\n                            </span>\n                          </motion.div>\n                        </AnimatePresence>\n                      </div>\n                    </motion.button>\n\n                    {/* Compact State More Button (Dots) */}\n                    <motion.button\n                      key=\"compact-more\"\n                      layout\n                      type=\"button\"\n                      initial={{ opacity: 0, scale: 0.8, width: 0 }}\n                      animate={{ opacity: 1, scale: 1, width: 38 }}\n                      exit={{ opacity: 0, scale: 0.8, width: 0 }}\n                      transition={springTransition}\n                      onClick={handleMoreClick}\n                      onMouseEnter={handleIslandEnter}\n                      aria-label=\"Expand all links\"\n                      className={cn(\n                        \"relative grid place-items-center w-[38px] h-[38px] rounded-full transition-colors cursor-pointer outline-none flex-none\",\n                        theme === \"dark\"\n                          ? \"text-white/60 hover:text-white hover:bg-white/10\"\n                          : \"text-neutral-600 hover:text-neutral-900 hover:bg-black/5\"\n                      )}\n                    >\n                      <Glyph name=\"dots\" />\n                    </motion.button>\n                  </>\n                ) : (\n                  items.map((it, i) => {\n                    const isCur = i === activeIdx;\n                    const isHovered = hoverIdx === i;\n                    const showLabel = isHovered || (hoverIdx === null && isCur);\n\n                    return (\n                      <motion.button\n                        key={it.id}\n                        layout\n                        type=\"button\"\n                        transition={springTransition}\n                        onMouseEnter={() => setHoverIdx(i)}\n                        onClick={(e) => handleItemClick(i, e)}\n                        className={cn(\n                          \"relative flex items-center h-[38px] rounded-full px-2.5 transition-colors cursor-pointer outline-none\",\n                          isCur || isHovered\n                            ? theme === \"dark\"\n                              ? \"text-white\"\n                              : \"text-neutral-950\"\n                            : theme === \"dark\"\n                            ? \"text-white/60 hover:text-white/90\"\n                            : \"text-neutral-600 hover:text-neutral-900\"\n                        )}\n                      >\n                        {/* Spring Liquid Indicator Pill */}\n                        {(isHovered || (hoverIdx === null && isCur)) && (\n                          <motion.div\n                            layoutId={`pill-${navId}`}\n                            transition={springTransition}\n                            className={cn(\n                              \"absolute inset-0 rounded-full\",\n                              theme === \"dark\"\n                                ? \"bg-white/[0.14] shadow-[inset_0_1px_0_0_rgba(255,255,255,0.14)]\"\n                                : \"bg-black/[0.08] shadow-[inset_0_1px_0_0_rgba(0,0,0,0.06)]\"\n                            )}\n                          />\n                        )}\n\n                        <span className=\"relative z-10 flex items-center\">\n                          <span className=\"grid place-items-center w-5 h-5 flex-none\">\n                            <Glyph name={it.icon || it.id} />\n                          </span>\n\n                          <AnimatePresence initial={false}>\n                            {showLabel && (\n                              <motion.span\n                                initial={{ opacity: 0, width: 0, marginLeft: 0 }}\n                                animate={{ opacity: 1, width: \"auto\", marginLeft: 8 }}\n                                exit={{ opacity: 0, width: 0, marginLeft: 0 }}\n                                transition={springTransition}\n                                className=\"overflow-hidden whitespace-nowrap text-sm font-medium tracking-tight\"\n                              >\n                                {it.label}\n                              </motion.span>\n                            )}\n                          </AnimatePresence>\n                        </span>\n                      </motion.button>\n                    );\n                  })\n                )}\n              </div>\n            )}\n\n            {/* Mobile View: Active item label + Hamburger menu button */}\n            {isMobile && (\n              <div className=\"flex items-center justify-between w-full px-1\">\n                <div className=\"relative overflow-hidden h-[38px] flex items-center pl-2\">\n                  <AnimatePresence mode=\"popLayout\" custom={direction} initial={false}>\n                    <motion.div\n                      key={items[activeIdx]?.id}\n                      custom={direction}\n                      variants={swapVariants}\n                      initial=\"enter\"\n                      animate=\"center\"\n                      exit=\"exit\"\n                      transition={swapTransition}\n                      className=\"flex items-center gap-2 text-sm font-medium whitespace-nowrap\"\n                    >\n                      <span className=\"grid place-items-center w-5 h-5 flex-none\">\n                        <Glyph name={items[activeIdx]?.icon || items[activeIdx]?.id} />\n                      </span>\n                      <span>{items[activeIdx]?.label}</span>\n                    </motion.div>\n                  </AnimatePresence>\n                </div>\n\n                <button\n                  type=\"button\"\n                  onClick={() => setOpen((v) => !v)}\n                  aria-label={open ? \"Close menu\" : \"Open menu\"}\n                  className={cn(\n                    \"relative grid place-items-center w-[38px] h-[38px] rounded-full transition-colors cursor-pointer\",\n                    theme === \"dark\" ? \"text-white\" : \"text-neutral-900\"\n                  )}\n                >\n                  <motion.span\n                    animate={{ rotate: open ? 45 : 0, y: open ? 0 : -3.5 }}\n                    transition={springTransition}\n                    className=\"absolute w-4 h-[1.75px] rounded-full bg-current\"\n                  />\n                  <motion.span\n                    animate={{ rotate: open ? -45 : 0, y: open ? 0 : 3.5 }}\n                    transition={springTransition}\n                    className=\"absolute w-4 h-[1.75px] rounded-full bg-current\"\n                  />\n                </button>\n              </div>\n            )}\n          </div>\n\n          {/* Mobile Animated Dropdown Modal Panel */}\n          <AnimatePresence initial={false}>\n            {isMobile && open && (\n              <motion.div\n                key=\"mobile-panel\"\n                initial={{ opacity: 0, height: 0 }}\n                animate={{ opacity: 1, height: \"auto\" }}\n                exit={{ opacity: 0, height: 0 }}\n                transition={springTransition}\n                className=\"w-full px-2.5 pb-3 pt-1 overflow-hidden\"\n              >\n                <div className=\"flex flex-col gap-1 w-full\">\n                  {items.map((it, i) => {\n                    const isCur = i === activeIdx;\n                    return (\n                      <motion.button\n                        key={it.id}\n                        initial={{ opacity: 0, y: -6 }}\n                        animate={{ opacity: 1, y: 0 }}\n                        transition={{ delay: 0.04 + i * 0.025, ...springTransition }}\n                        onClick={(e) => handleItemClick(i, e)}\n                        className={cn(\n                          \"flex items-center justify-start gap-3 w-full h-12 px-3.5 rounded-2xl text-left transition-colors cursor-pointer\",\n                          isCur\n                            ? theme === \"dark\"\n                              ? \"bg-white/[0.14] text-white shadow-[inset_0_1px_0_0_rgba(255,255,255,0.12)]\"\n                              : \"bg-black/[0.08] text-neutral-900\"\n                            : theme === \"dark\"\n                            ? \"text-white/60 hover:text-white hover:bg-white/[0.08]\"\n                            : \"text-neutral-600 hover:text-neutral-900 hover:bg-black/[0.05]\"\n                        )}\n                      >\n                        <span className=\"grid place-items-center w-6 h-6 flex-none\">\n                          <Glyph name={it.icon || it.id} />\n                        </span>\n                        <span className=\"text-[15px] font-medium leading-none\">\n                          {it.label}\n                        </span>\n                      </motion.button>\n                    );\n                  })}\n                </div>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </motion.nav>\n      </LayoutGroup>\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ]
}