{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "magnetic-dock",
  "title": "Magnetic Dock",
  "description": "A frosted dock of glossy app tiles that grow toward your pointer and bounce as they open.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "components/ui/magnetic-dock.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  AnimatePresence,\n  animate,\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useSpring,\n  useTransform,\n  type MotionValue,\n} from \"motion/react\"\n\nimport { spring, springs } from \"@/lib/afterglow\"\nimport { cn } from \"@/lib/utils\"\n\ntype DockItem = {\n  label: string\n  icon: React.ReactNode\n  /** a CSS background for an app-style tile, e.g. a gradient */\n  tone?: string\n  /** shows the running dot */\n  active?: boolean\n  onClick?: () => void\n}\n\n/** \"divider\" draws a thin separator, like the one before the trash */\ntype DockEntry = DockItem | \"divider\"\n\ntype MagneticDockProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n  items: DockEntry[]\n  size?: number\n  magnification?: number\n  range?: number\n}\n\nfunction MagneticDock({\n  items,\n  size = 48,\n  magnification = 76,\n  range = 150,\n  className,\n  style,\n  onPointerMove,\n  onPointerLeave,\n  ...props\n}: MagneticDockProps) {\n  // Infinity means \"pointer is not over the dock\"\n  const pointerX = useMotionValue(Infinity)\n\n  return (\n    <nav\n      data-slot=\"magnetic-dock\"\n      aria-label=\"Dock\"\n      className={cn(\n        \"flex items-end gap-2 rounded-[22px] border border-transparent bg-glass px-2.5 pb-2.5 shadow-glass backdrop-blur-2xl backdrop-saturate-150\",\n        className\n      )}\n      style={{ height: size + 20, ...style }}\n      onPointerMove={(event) => {\n        onPointerMove?.(event)\n        pointerX.set(event.clientX)\n      }}\n      onPointerLeave={(event) => {\n        onPointerLeave?.(event)\n        pointerX.set(Infinity)\n      }}\n      {...props}\n    >\n      {items.map((item, index) =>\n        item === \"divider\" ? (\n          <span\n            key={`divider-${index}`}\n            aria-hidden\n            className=\"mx-0.5 mb-1.5 w-px shrink-0 self-end bg-foreground/15\"\n            style={{ height: size - 12 }}\n          />\n        ) : (\n          <DockIcon\n            key={item.label}\n            item={item}\n            pointerX={pointerX}\n            size={size}\n            magnification={magnification}\n            range={range}\n          />\n        )\n      )}\n    </nav>\n  )\n}\n\ntype DockIconProps = {\n  item: DockItem\n  pointerX: MotionValue<number>\n  size: number\n  magnification: number\n  range: number\n}\n\nfunction DockIcon({ item, pointerX, size, magnification, range }: DockIconProps) {\n  const ref = React.useRef<HTMLButtonElement>(null)\n  const reduceMotion = useReducedMotion()\n  const [focused, setFocused] = React.useState(false)\n  const [hovered, setHovered] = React.useState(false)\n\n  const distance = useTransform(pointerX, (x) => {\n    const node = ref.current\n    if (!node || !Number.isFinite(x)) return Infinity\n    const rect = node.getBoundingClientRect()\n    return x - rect.left - rect.width / 2\n  })\n  const magnified = useTransform(\n    distance,\n    [-range, 0, range],\n    [size, magnification, size]\n  )\n\n  const width = useSpring(size, springs.snappy)\n  // the glow uses a slower spring, so it trails behind the pointer\n  const glow = useSpring(0, springs.glide)\n  const iconSize = useTransform(width, (w) => w * (item.tone ? 0.52 : 0.5))\n  const lift = useMotionValue(0)\n\n  React.useEffect(() => {\n    const update = () => {\n      const target = focused ? magnification : magnified.get()\n      width.set(reduceMotion ? size : target)\n      const growth = magnification - size\n      glow.set(growth > 0 ? (target - size) / growth : focused ? 1 : 0)\n    }\n    update()\n    return magnified.on(\"change\", update)\n  }, [focused, glow, magnification, magnified, reduceMotion, size, width])\n\n  return (\n    <motion.button\n      ref={ref}\n      type=\"button\"\n      aria-label={item.label}\n      aria-current={item.active ? \"page\" : undefined}\n      className=\"relative shrink-0 cursor-pointer rounded-[28%] outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n      style={{ width, height: width }}\n      onClick={() => {\n        // an app bounces as it opens\n        if (!reduceMotion && !item.active) {\n          animate(lift, [0, -22, 0, -10, 0], { duration: 0.85, ease: \"easeOut\" })\n        }\n        item.onClick?.()\n      }}\n      onFocus={() => setFocused(true)}\n      onBlur={() => setFocused(false)}\n      onPointerEnter={() => setHovered(true)}\n      onPointerLeave={() => setHovered(false)}\n    >\n      <motion.span\n        aria-hidden\n        className=\"pointer-events-none absolute -inset-2 -z-10 rounded-full bg-glow/35 blur-xl\"\n        style={{ opacity: glow }}\n      />\n      <motion.span\n        aria-hidden\n        className={cn(\n          \"absolute inset-0 grid place-items-center overflow-hidden rounded-[inherit] shadow-gloss\",\n          item.tone\n            ? \"text-white [&_svg]:drop-shadow-[0_1px_1px_oklch(0_0_0/25%)]\"\n            : \"bg-linear-to-b from-card to-muted text-foreground\"\n        )}\n        style={{ y: lift, background: item.tone }}\n      >\n        {/* specular sheen on the upper half of the glossy tile */}\n        <span className=\"pointer-events-none absolute inset-x-[6%] top-px h-1/2 rounded-[inherit] bg-linear-to-b from-white/35 to-transparent\" />\n        <motion.span\n          className=\"relative grid place-items-center [&>svg]:size-full\"\n          style={{ width: iconSize, height: iconSize }}\n        >\n          {item.icon}\n        </motion.span>\n      </motion.span>\n      <AnimatePresence>\n        {item.active && (\n          <motion.span\n            aria-hidden\n            className=\"absolute -bottom-2 left-1/2 size-1 -translate-x-1/2 rounded-full bg-foreground/80 shadow-[0_0_6px_var(--glow)]\"\n            initial={{ opacity: 0, scale: 0.5 }}\n            animate={{ opacity: 1, scale: 1 }}\n            exit={{ opacity: 0, scale: 0.5 }}\n            transition={{ duration: 0.2 }}\n          />\n        )}\n      </AnimatePresence>\n      <AnimatePresence>\n        {(hovered || focused) && (\n          <motion.span\n            aria-hidden\n            className=\"pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 rounded-lg bg-glass px-2.5 py-1 text-xs font-medium whitespace-nowrap text-foreground shadow-glass backdrop-blur-xl\"\n            initial={{ opacity: 0, y: 4 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={{ opacity: 0, y: 2, transition: { duration: 0.1 } }}\n            transition={spring(\"snappy\")}\n          >\n            {item.label}\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </motion.button>\n  )\n}\n\nexport { MagneticDock, type DockEntry, type DockItem, type MagneticDockProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/afterglow.ts",
      "content": "import type { CSSProperties } from \"react\"\nimport type { TargetAndTransition, Transition } from \"motion/react\"\n\n// shared spring presets, every component picks from these\nexport const springs = {\n  snappy: { stiffness: 520, damping: 34, mass: 0.6 },\n  soft: { stiffness: 260, damping: 26, mass: 0.8 },\n  glide: { stiffness: 120, damping: 20, mass: 1 },\n} as const\n\nexport type SpringName = keyof typeof springs\n\nexport function spring(name: SpringName): Transition {\n  return { type: \"spring\", ...springs[name] }\n}\n\n// how a glow fades once its source moves away: slow, with a long tail\nexport const afterglow = {\n  linger: 0.9,\n  ease: [0.22, 1, 0.36, 1],\n} as const satisfies { linger: number; ease: Transition[\"ease\"] }\n\n// paints only the padding ring of an element, used for glowing borders\nexport const ringMask: CSSProperties = {\n  WebkitMask:\n    \"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// small icon gestures, played when a control is pressed or selected\nexport const iconGestures = {\n  pop: { scale: [1, 1.2, 1] },\n  ring: { rotate: [0, -18, 14, -9, 4, 0], scale: [1, 1.12, 1] },\n  // a gear looks the same after half a turn, so it can rest there and snap back unseen\n  turn: { rotate: [0, 180], scale: [1, 1.12, 1] },\n  hop: { y: [0, -3, 0], scale: [1, 1.1, 1] },\n  nudge: { x: [0, 2.5, 0], scale: [1, 1.1, 1] },\n} satisfies Record<string, TargetAndTransition>\n\nexport type IconGesture = keyof typeof iconGestures\n\n// leaving a gesture is instant: every gesture already ends at, or looks like, its resting pose\nexport const iconRest: TargetAndTransition = { scale: 1, rotate: 0, x: 0, y: 0, transition: { duration: 0 } }\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-glow": "var(--glow)",
      "color-glow-foreground": "var(--glow-foreground)",
      "color-glow-2": "var(--glow-2)",
      "color-glow-3": "var(--glow-3)",
      "color-glass": "var(--glass)",
      "color-gloss-highlight": "var(--gloss-highlight)",
      "shadow-gloss": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -1px 0 0 var(--gloss-shade), 0 0 0 1px var(--gloss-edge), 0 1px 2px 0 var(--gloss-depth), 0 4px 12px -4px var(--gloss-depth)",
      "shadow-glass": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -10px 24px -18px var(--gloss-shade), inset 0 0 0 1px var(--gloss-edge), 0 2px 6px -1px var(--gloss-depth), 0 18px 40px -12px var(--gloss-depth)",
      "shadow-well": "inset 0 1px 3px 0 var(--gloss-depth), inset 0 0 0 1px var(--gloss-edge), 0 1px 0 0 var(--gloss-highlight)"
    },
    "light": {
      "glow": "oklch(0.7 0.19 45)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.64 0.22 12)",
      "glow-3": "oklch(0.56 0.21 300)",
      "glass": "oklch(1 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 95%)",
      "gloss-shade": "oklch(0.3 0.03 285 / 10%)",
      "gloss-depth": "oklch(0.32 0.03 285 / 20%)",
      "gloss-edge": "oklch(0.22 0.02 285 / 10%)",
      "liquid-tint": "oklch(1 0 0 / 18%)",
      "liquid-fallback": "oklch(1 0 0 / 55%)",
      "liquid-rim": "oklch(1 0 0 / 95%)",
      "liquid-edge": "oklch(0.2 0.02 285 / 10%)",
      "liquid-shadow": "oklch(0.22 0.02 285 / 26%)",
      "liquid-glow": "oklch(1 0 0 / 55%)",
      "liquid-shade": "oklch(0.25 0.03 285 / 14%)"
    },
    "dark": {
      "glow": "oklch(0.8 0.16 55)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.7 0.2 15)",
      "glow-3": "oklch(0.65 0.2 300)",
      "glass": "oklch(0.19 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 16%)",
      "gloss-shade": "oklch(0 0 0 / 30%)",
      "gloss-depth": "oklch(0.04 0 0 / 60%)",
      "gloss-edge": "oklch(1 0 0 / 9%)",
      "liquid-tint": "oklch(0.2 0 0 / 22%)",
      "liquid-fallback": "oklch(0.2 0 0 / 45%)",
      "liquid-rim": "oklch(1 0 0 / 60%)",
      "liquid-edge": "oklch(1 0 0 / 10%)",
      "liquid-shadow": "oklch(0 0 0 / 50%)",
      "liquid-glow": "oklch(1 0 0 / 24%)",
      "liquid-shade": "oklch(0 0 0 / 28%)"
    }
  },
  "type": "registry:ui"
}