{
  "$schema": "https://www.cooki-ui.design/schema/registry-item.json",
  "name": "morphing-navigation",
  "type": "registry:ui",
  "title": "Morphing Navigation",
  "description": "Adaptive floating navigation bar that morphs between expanded desktop tabs and compact floating glass capsules on scroll.",
  "category": "navigation",
  "dependencies": [
    "framer-motion",
    "clsx",
    "tailwind-merge"
  ],
  "tags": [
    "navigation",
    "navbar",
    "morphing",
    "glassmorphic",
    "tabs",
    "framer-motion"
  ],
  "files": [
    {
      "path": "registry/navigation/morphing-navigation/morphing-navigation.tsx",
      "type": "registry:ui",
      "target": "components/ui/morphing-navigation.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useRef, useState, useCallback } from \"react\";\nimport { motion, AnimatePresence } from \"framer-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MorphingNavigationLink {\n  id: string;\n  label: string;\n  href: string;\n  icon?: React.ReactNode;\n}\n\nexport interface MorphingNavigationProps {\n  links: MorphingNavigationLink[];\n  scrollThreshold?: number;\n  enablePageBlur?: boolean;\n  theme?: \"dark\" | \"light\" | \"glass\" | \"custom\";\n  backgroundColor?: string;\n  textColor?: string;\n  borderColor?: string;\n  initialTop?: number;\n  compactTop?: number;\n  animationDuration?: number;\n  className?: string;\n  onLinkClick?: (link: MorphingNavigationLink) => void;\n  onMenuToggle?: (isOpen: boolean) => void;\n  enableSmoothTransitions?: boolean;\n  customHamburgerIcon?: React.ReactNode;\n  disableAutoMorph?: boolean;\n}\n\nexport const MorphingNavigation: React.FC<MorphingNavigationProps> = ({\n  links,\n  scrollThreshold = 100,\n  enablePageBlur = true,\n  theme = \"glass\",\n  backgroundColor,\n  textColor,\n  borderColor,\n  initialTop = 70,\n  compactTop = 20,\n  animationDuration = 1,\n  className,\n  onLinkClick,\n  onMenuToggle,\n  enableSmoothTransitions = true,\n  customHamburgerIcon,\n  disableAutoMorph = false,\n}) => {\n  const [isSticky, setIsSticky] = useState(false);\n  const [isMenuOpen, setIsMenuOpen] = useState(false);\n  const [isMobile, setIsMobile] = useState(false);\n  const navRef = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    const handleResize = () => {\n      setIsMobile(window.innerWidth < 768);\n    };\n    handleResize();\n    window.addEventListener(\"resize\", handleResize);\n    return () => window.removeEventListener(\"resize\", handleResize);\n  }, []);\n\n  const getThemeStyles = useCallback(() => {\n    switch (theme) {\n      case \"dark\":\n        return {\n          nav: \"bg-black/80 border-gray-800\",\n          text: \"text-white\",\n          button: \"bg-black/50 border-gray-700\",\n        };\n      case \"light\":\n        return {\n          nav: \"bg-white/80 border-gray-200\",\n          text: \"text-gray-900\",\n          button: \"bg-white/50 border-gray-300\",\n        };\n      case \"custom\":\n        return {\n          nav: backgroundColor ? \"\" : \"bg-white/5 border-white/10\",\n          text: textColor ? \"\" : \"text-white\",\n          button: \"bg-black/30 border-white/10\",\n        };\n      case \"glass\":\n      default:\n        return {\n          nav: \"bg-white/5 border-white/10\",\n          text: \"text-foreground\",\n          button: \"bg-black/30 border-white/10\",\n        };\n    }\n  }, [theme, backgroundColor, textColor]);\n\n  const themeStyles = getThemeStyles();\n\n  useEffect(() => {\n    if (disableAutoMorph && !isMobile) return;\n    const handleScroll = () => {\n      if (isMobile) {\n        setIsSticky(true);\n        setIsMenuOpen(false);\n      } else {\n        setIsSticky(window.scrollY >= scrollThreshold);\n        setIsMenuOpen(false);\n      }\n    };\n    window.addEventListener(\"scroll\", handleScroll);\n    return () => window.removeEventListener(\"scroll\", handleScroll);\n  }, [scrollThreshold, disableAutoMorph, isMobile]);\n\n  const handleMenuToggle = () => {\n    const open = !isMenuOpen;\n    setIsMenuOpen(open);\n    if (isMobile && open) {\n      setIsSticky(true);\n    } else if (isMobile && !open) {\n      setIsSticky(window.scrollY >= scrollThreshold);\n    } else {\n      setIsSticky(false);\n    }\n    onMenuToggle?.(open);\n  };\n\n  const handleLinkClick = (link: MorphingNavigationLink, e: React.MouseEvent) => {\n    e.preventDefault();\n    setIsMenuOpen(false);\n    onLinkClick?.(link);\n    if (enableSmoothTransitions) {\n      const target = document.querySelector(link.href);\n      if (target) {\n        target.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n      }\n    }\n  };\n\n  useEffect(() => {\n    const handleClickOutside = (e: MouseEvent) => {\n      if (navRef.current && !navRef.current.contains(e.target as Node) && isMenuOpen) {\n        setIsMenuOpen(false);\n      }\n    };\n    document.addEventListener(\"click\", handleClickOutside);\n    return () => document.removeEventListener(\"click\", handleClickOutside);\n  }, [isMenuOpen]);\n\n  const customStyles = {\n    backgroundColor: theme === \"custom\" ? backgroundColor : undefined,\n    color: theme === \"custom\" ? textColor : undefined,\n    borderColor: theme === \"custom\" ? borderColor : undefined,\n  };\n\n  return (\n    <>\n      <AnimatePresence>\n        {enablePageBlur && isMenuOpen && (\n          <motion.div\n            className=\"fixed inset-0 bg-black/20 backdrop-blur-sm z-40\"\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n          />\n        )}\n      </AnimatePresence>\n\n      <motion.header\n        className={cn(\"fixed top-4 z-50 w-full\", className)}\n        initial={false}\n        animate={{\n          top: isMobile ? compactTop : isSticky ? compactTop : initialTop,\n        }}\n        transition={{ duration: animationDuration }}\n      >\n        <motion.nav\n          ref={navRef}\n          className={cn(\n            \"flex justify-center items-center mx-auto backdrop-blur-md border fixed\",\n            themeStyles.nav,\n            themeStyles.text,\n            {\n              \"left-1/2 -translate-x-1/2\": !isMobile && !isSticky,\n              \"left-0 right-0\": isMobile || isSticky,\n              \"sm:w-[70px] sm:h-[70px] sm:rounded-full\": isMobile,\n            }\n          )}\n          animate={{\n            height: isMobile ? 70 : isSticky ? 90 : 100,\n            width: isMobile ? 70 : isSticky ? 90 : 500,\n            borderRadius: 9999,\n          }}\n          transition={{ duration: animationDuration }}\n          style={{ top: 0, ...customStyles }}\n        >\n          <AnimatePresence>\n            {!isMobile && !isSticky &&\n              links.map((link, i) => (\n                <motion.a\n                  key={link.id}\n                  href={link.href}\n                  onClick={(e) => handleLinkClick(link, e)}\n                  initial={{ opacity: 0, scale: 0.5 }}\n                  animate={{ opacity: 1, scale: 1 }}\n                  exit={{ opacity: 0, scale: 0 }}\n                  transition={{ delay: i * 0.1 }}\n                  className=\"px-5 py-2.5 text-sm font-bold lowercase tracking-wide\"\n                >\n                  {link.icon && <span className=\"mr-2 inline-block\">{link.icon}</span>}\n                  {link.label}\n                </motion.a>\n              ))}\n          </AnimatePresence>\n\n          <motion.button\n            onClick={handleMenuToggle}\n            className={cn(\n              \"absolute w-[60px] h-[60px] rounded-full outline-none border cursor-pointer\",\n              themeStyles.button,\n              {\n                hidden: !isSticky && !isMobile,\n                block: isMobile || isSticky,\n              }\n            )}\n            animate={{ scale: isMobile || isSticky ? 1 : 0 }}\n            transition={{ delay: isMobile || isSticky ? 0.2 : 0 }}\n          >\n            {customHamburgerIcon || (\n              <div className=\"flex flex-col items-center justify-center h-full\">\n                <span className=\"block w-4 h-0.5 bg-current my-1\"></span>\n                <span className=\"block w-4 h-0.5 bg-current my-1\"></span>\n                <span className=\"block w-4 h-0.5 bg-current my-1\"></span>\n              </div>\n            )}\n          </motion.button>\n        </motion.nav>\n      </motion.header>\n\n      <AnimatePresence>\n        {isMenuOpen && (\n          <motion.div\n            className=\"fixed inset-0 z-40 flex items-center justify-center\"\n            initial={{ opacity: 0, scale: 0.95 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={{ opacity: 0, scale: 0.95 }}\n            transition={{ duration: 0.3 }}\n          >\n            <motion.div\n              className={cn(\n                \"p-8 rounded-2xl backdrop-blur-md border w-11/12 max-w-sm\",\n                themeStyles.nav,\n                themeStyles.text\n              )}\n              style={customStyles}\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ opacity: 0 }}\n            >\n              <div className=\"flex flex-col space-y-4\">\n                {links.map((link) => (\n                  <a\n                    key={link.id}\n                    href={link.href}\n                    onClick={(e) => handleLinkClick(link, e)}\n                    className=\"font-bold text-lg tracking-wide lowercase hover:scale-105 transition-transform\"\n                  >\n                    {link.icon && <span className=\"inline-block mr-3\">{link.icon}</span>}\n                    {link.label}\n                  </a>\n                ))}\n              </div>\n            </motion.div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </>\n  );\n};\n\nexport default MorphingNavigation;\n"
    }
  ]
}