{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ui-fluid-glass-slider",
  "title": "UI Fluid Glass Slider",
  "author": "AlgorizeTech",
  "description": "A glass-morphism slide viewer with fluid GSAP transitions between panels. Use it for hero galleries with a soft, liquid feel.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/components/custom/ui/FluidGlassSlider.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\n\n// ==========================================\n// MOTION — Web Animations and CSS, no library\n// ==========================================\n// GSAP's power4.inOut (sampled, max error 0.15%), power2.out and power1.out.\nconst POWER4_IN_OUT =\n  \"linear(0, .0005 12.5%, .0037 18.75%, .008 21.875%, .0156 25%, .0282 28.125%, .0477 31.25%, .0768 34.375%, .0959 35.938%, .1187 37.5%, .1455 39.063%, .177 40.625%, .2138 42.188%, .2565 43.75%, .3056 45.313%, .3621 46.875%, .4266 48.438%, .5 50%, .5734 51.563%, .6379 53.125%, .6944 54.688%, .7435 56.25%, .7862 57.813%, .823 59.375%, .8545 60.938%, .8813 62.5%, .9041 64.063%, .9232 65.625%, .9523 68.75%, .9718 71.875%, .9844 75%, .992 78.125%, .9963 81.25%, .9995 87.5%, 1)\";\nconst POWER2_OUT = \"cubic-bezier(.3333, 1, .6667, 1)\";\nconst POWER1_OUT = \"cubic-bezier(.3333, .6667, .6667, 1)\";\n\nconst tweens = new WeakMap<HTMLElement, Animation>();\n\n/**\n * Tween `el` to `to` from wherever it is right now (mid-flight included), so a\n * new target takes over a running tween with the full duration. The end values\n * are written inline, so nothing is held by a fill.\n */\nfunction tweenTo(el: HTMLElement, to: Record<string, string>, duration: number, easing: string) {\n  const computed = getComputedStyle(el);\n  const from: Record<string, string> = {};\n  for (const key of Object.keys(to)) from[key] = computed.getPropertyValue(key);\n  tweens.get(el)?.cancel();\n  for (const [key, value] of Object.entries(to)) el.style.setProperty(key, value);\n  if (typeof el.animate !== \"function\") return null;\n  const animation = el.animate([from, to], { duration: duration * 1000, easing });\n  tweens.set(el, animation);\n  return animation;\n}\n\nexport type Slide = {\n  id: number;\n  image: string;\n  title: string;\n  subtitle: string;\n};\n\nconst DEFAULT_SLIDES_DATA: Slide[] = [\n  {\n    id: 1,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_2574,c_limit/v1790146210/photo-1506905925346-21bda4d32df4-1790146212208.jpg\",\n    title: \"Discover pristine tropical beaches and crystal-clear waters\",\n    subtitle: \"TROPICAL PARADISE\",\n  },\n  {\n    id: 2,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_2574,c_limit/v1790146211/photo-1441974231531-c6227db76b6e-1790146212212.jpg\",\n    title: \"Escape to the serene mountain heights and wilderness trails\",\n    subtitle: \"MOUNTAIN ADVENTURES\",\n  },\n  {\n    id: 3,\n    image:\n      \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_2574,c_limit/v1790145141/photo-1464822759023-fed622ff2c3b-1790145143491.jpg\",\n    title: \"Surround yourself with majestic peaks and alpine lakes\",\n    subtitle: \"ALPINE RETREAT\",\n  },\n];\n\ntype Props = {\n  slides?: Slide[];\n  className?: string;\n};\n\nexport default function FluidGlassSlider({ slides, className }: Props) {\n  const slidesData = slides && slides.length > 0 ? slides : DEFAULT_SLIDES_DATA;\n  const [currentIndex, setCurrentIndex] = useState<number>(0);\n\n  const containerRef = useRef<HTMLDivElement | null>(null);\n  const sliderRef = useRef<HTMLDivElement | null>(null);\n  const progressRef = useRef<HTMLDivElement | null>(null);\n  const cursorRef = useRef<HTMLDivElement | null>(null);\n\n  const isFirstSlide = currentIndex === 0;\n  const isLastSlide = currentIndex === slidesData.length - 1;\n\n  useEffect(() => {\n    if (!sliderRef.current) return;\n\n    // Slide animation\n    const slide = tweenTo(\n      sliderRef.current,\n      { translate: `-${currentIndex * (100 / slidesData.length)}% 0px` },\n      1.2,\n      POWER4_IN_OUT,\n    );\n\n    if (!progressRef.current || typeof progressRef.current.animate !== \"function\") return;\n\n    // Auto-play progress bar (Infinite Loop)\n    const progress = progressRef.current.animate(\n      [{ width: \"0%\" }, { width: \"100%\" }],\n      { duration: 5000, easing: \"linear\", fill: \"forwards\" },\n    );\n    progress.onfinish = () => {\n      // Auto-play continues infinitely\n      setCurrentIndex((prev) =>\n        prev < slidesData.length - 1 ? prev + 1 : 0,\n      );\n    };\n\n    // A hidden tab holds both where they are, as it always has: the timer\n    // must not run on and flip slides nobody is watching.\n    const onVisibility = () => {\n      for (const animation of [slide, progress]) {\n        if (!animation || animation.playState === \"finished\") continue;\n        if (document.hidden) animation.pause();\n        else animation.play();\n      }\n    };\n    document.addEventListener(\"visibilitychange\", onVisibility);\n    onVisibility();\n\n    return () => {\n      document.removeEventListener(\"visibilitychange\", onVisibility);\n      progress.onfinish = null;\n      progress.cancel();\n    };\n  }, [currentIndex]);\n\n  useEffect(() => {\n    const container = containerRef.current;\n    const cursor = cursorRef.current;\n    if (!container || !cursor) return;\n\n    // Follows the pointer through a 0.1s transition on `translate` (see the\n    // cursor's style).\n    const onMouseMove = (e: MouseEvent) => {\n      if (!cursor) return;\n      cursor.style.translate = `${(e.clientX || 0) + 15}px ${(e.clientY || 0) + 15}px`;\n    };\n\n    container.addEventListener(\"mousemove\", onMouseMove);\n    return () => container.removeEventListener(\"mousemove\", onMouseMove);\n  }, []);\n\n  const nextSlide = () => {\n    if (!isLastSlide) setCurrentIndex((prev) => prev + 1);\n  };\n\n  const prevSlide = () => {\n    if (!isFirstSlide) setCurrentIndex((prev) => prev - 1);\n  };\n\n  const showCursor = () => {\n    if (!cursorRef.current) return;\n    tweenTo(cursorRef.current, { opacity: \"1\", scale: \"1\" }, 0.2, POWER1_OUT);\n  };\n  const hideCursor = () => {\n    if (!cursorRef.current) return;\n    tweenTo(cursorRef.current, { opacity: \"0\", scale: \"0.8\" }, 0.2, POWER1_OUT);\n  };\n\n  return (\n    <div\n      ref={containerRef}\n      onMouseEnter={showCursor}\n      onMouseLeave={hideCursor}\n      className={`relative w-full h-[500px] md:h-[650px] overflow-hidden bg-[#111] text-white font-sans rounded-2xl shadow-xl ${className || \"\"}`}\n    >\n      <div\n        ref={cursorRef}\n        className=\"fixed top-0 left-0 px-3 py-1.5 bg-white/20 backdrop-blur-md border border-white/30 text-white text-[10px] font-semibold tracking-widest uppercase flex items-center justify-center opacity-0 z-[100] pointer-events-none scale-80\"\n        style={{ transition: `translate 0.1s ${POWER2_OUT}` }}\n      >\n        VIEW\n      </div>\n      <header className=\"absolute top-0 left-0 w-full z-20 flex justify-between items-center p-6 md:p-8 pointer-events-none\">\n        <div className=\"flex-1 hidden sm:block\"></div>\n        <div className=\"flex-1 text-left sm:text-center\">\n          <h1 className=\"text-xl md:text-2xl font-medium tracking-wide drop-shadow-md pointer-events-auto cursor-pointer hover:opacity-70 transition\">\n            Fluid Glass\n          </h1>\n        </div>\n        <div className=\"flex-1 hidden sm:block\"></div>\n      </header>\n      <main\n        ref={sliderRef}\n        className=\"flex h-full\"\n        style={{ width: `${slidesData.length * 100}%` }}\n      >\n        {slidesData.map((slide) => (\n          <section\n            key={slide.id}\n            className=\"relative flex items-end pb-24 md:pb-32 px-6 md:px-12 bg-cover bg-center h-full\"\n            style={{\n              backgroundImage: `url(${slide.image})`,\n              width: `${100 / slidesData.length}%`,\n            }}\n          >\n            <div className=\"absolute inset-0 bg-gradient-to-t from-black/90 via-black/30 to-black/40\"></div>\n\n            <div className=\"relative z-10 w-full\">\n              <h2 className=\"text-3xl md:text-5xl lg:text-[4rem] font-semibold leading-[1.1] mb-8 md:mb-14 tracking-tight max-w-4xl drop-shadow-xl\">\n                {slide.title}\n              </h2>\n              <p className=\"text-[10px] md:text-[11px] uppercase tracking-[0.2em] font-semibold text-gray-300 drop-shadow-md\">\n                {slide.subtitle}\n              </p>\n            </div>\n          </section>\n        ))}\n      </main>\n      <div className=\"absolute bottom-0 left-0 w-full pointer-events-none z-20 pb-6 md:pb-10 px-6 md:px-12 flex items-end\">\n        <div className=\"w-full flex flex-col sm:flex-row sm:justify-between items-start sm:items-center gap-6 sm:gap-0\">\n          <div className=\"w-full sm:flex-1 sm:mr-12 h-[2px] bg-gray-600/30 rounded-full overflow-hidden\">\n            <div ref={progressRef} className=\"h-full bg-white w-0\" />\n          </div>\n          <div className=\"flex items-center justify-between w-full sm:w-auto gap-8 pointer-events-auto shrink-0\">\n            <div className=\"flex gap-2\">\n              <button\n                onClick={prevSlide}\n                disabled={isFirstSlide}\n                onMouseEnter={hideCursor}\n                onMouseLeave={showCursor}\n                className={`w-10 h-10 md:w-12 md:h-12 rounded-full backdrop-blur-sm border flex items-center justify-center transition-all ${\n                  isFirstSlide\n                    ? \"bg-black/20 border-white/10 opacity-30 cursor-not-allowed\"\n                    : \"bg-black/40 border-white/20 hover:bg-white/20 hover:scale-105 cursor-pointer\"\n                }`}\n              >\n                <svg\n                  className=\"w-5 h-5 text-white\"\n                  fill=\"none\"\n                  stroke=\"currentColor\"\n                  viewBox=\"0 0 24 24\"\n                  xmlns=\"http://www.w3.org/2000/svg\"\n                >\n                  <path\n                    strokeLinecap=\"round\"\n                    strokeLinejoin=\"round\"\n                    strokeWidth={2}\n                    d=\"M15 19l-7-7 7-7\"\n                  />\n                </svg>\n              </button>\n\n              <button\n                onClick={nextSlide}\n                disabled={isLastSlide}\n                onMouseEnter={hideCursor}\n                onMouseLeave={showCursor}\n                className={`w-10 h-10 md:w-12 md:h-12 rounded-full backdrop-blur-sm border flex items-center justify-center transition-all ${\n                  isLastSlide\n                    ? \"bg-black/20 border-white/10 opacity-30 cursor-not-allowed\"\n                    : \"bg-black/40 border-white/20 hover:bg-white/20 hover:scale-105 cursor-pointer\"\n                }`}\n              >\n                <svg\n                  className=\"w-5 h-5 text-white\"\n                  fill=\"none\"\n                  stroke=\"currentColor\"\n                  viewBox=\"0 0 24 24\"\n                  xmlns=\"http://www.w3.org/2000/svg\"\n                >\n                  <path\n                    strokeLinecap=\"round\"\n                    strokeLinejoin=\"round\"\n                    strokeWidth={2}\n                    d=\"M9 5l7 7-7 7\"\n                  />\n                </svg>\n              </button>\n            </div>\n\n            <div className=\"text-[11px] md:text-[13px] font-semibold tracking-widest font-mono drop-shadow-md\">\n              <span>0{currentIndex + 1}</span> / 0{slidesData.length}\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/custom/ui/FluidGlassSlider.tsx"
    }
  ],
  "docs": "Named export: FluidGlassSlider. Slides take { id, image, title, subtitle }. Installs standalone with no registry dependencies — not even `utils`.",
  "categories": [
    "media"
  ],
  "type": "registry:ui"
}
