{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "memories-card",
  "title": "Memories Card",
  "author": "AlgorizeTech",
  "description": "A swipeable stack of photo cards with location, date and tag metadata. Use it for travel, gallery and testimonial carousels.",
  "dependencies": [
    "gsap",
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/MemoriesCardBlock.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport gsap from \"gsap\";\nimport { Calendar, MapPin, RotateCcw, Sparkles } from \"lucide-react\";\nimport React, { useLayoutEffect, useReducer, useRef, useState } from \"react\";\nimport { bezierEase, gsapTicker } from \"./gsap-motion\";\nimport {\n  createSpringFollower,\n  MOTION_EASE,\n  springEase,\n  type SpringFollower,\n} from \"./motion-curves\";\n\nexport interface MemoryItem {\n  id: string;\n  title: string;\n  location?: string;\n  date?: string;\n  image: string;\n  description?: string;\n  tag?: string;\n}\n\nexport interface MemoriesCardProps\n  extends React.HTMLAttributes<HTMLDivElement> {\n  items: MemoryItem[];\n  onCardChange?: (index: number) => void;\n}\n\n// ------------------------------------------\n// Motion — the same numbers as the motion/ build\n// ------------------------------------------\n\n/** Every card's pose, written to the DOM as one transform in Motion's order. */\ntype Pose = {\n  x: number;\n  y: number;\n  scale: number;\n  rotateX: number;\n  rotateY: number;\n  rotateZ: number;\n  opacity: number;\n};\ntype PoseKey = keyof Pose;\n\n/** Where a card starts when it joins the deck. */\nconst MOUNT_POSE: Pose = { x: 0, y: 50, scale: 0.8, rotateX: 0, rotateY: 0, rotateZ: 0, opacity: 0 };\nconst MOUNT_STYLE = { opacity: 0, transform: \"translateY(50px) scale(0.8)\" };\n\n/** Fan slots and the mount entrance. */\nconst SLOT_SPRING = { stiffness: 260, damping: 25 };\n/** Hover tilt on the front card. */\nconst TILT_SPRING = { stiffness: 300, damping: 25 };\n/** The spring that pulls a released card back inside its 0/0 drag constraints. */\nconst BOUNCE_SPRING = { stiffness: 200, damping: 40 };\nconst DRAG_ELASTIC = 0.6;\n/** Leaving the deck: a 0.3s tween on Motion's default `easeOut`. */\nconst EXIT_EASE = bezierEase(MOTION_EASE.easeOut);\n\n/** Drag styles Motion puts on an element while `drag=\"x\"` is on. */\nconst DRAG_STYLE: React.CSSProperties = {\n  userSelect: \"none\",\n  WebkitUserSelect: \"none\",\n  WebkitTouchCallout: \"none\",\n  touchAction: \"pan-y\",\n} as React.CSSProperties;\n\ninterface SpringRun {\n  tween: gsap.core.Tween;\n  from: number;\n  to: number;\n  duration: number;\n  ease: (progress: number) => number;\n}\n\ninterface CardMotion {\n  el: HTMLDivElement | null;\n  pose: Pose;\n  /** The last slot values asked for — only a changed value animates. */\n  targets: Partial<Pose>;\n  runs: Partial<Record<PoseKey, SpringRun>>;\n  exit: gsap.core.Tween | null;\n  /** Wears the hover tilt (the front card, including one that is leaving). */\n  tilted: boolean;\n}\n\nfunction frameTransform(p: Pose) {\n  let t = \"\";\n  if (p.x) t += `translateX(${p.x}px) `;\n  if (p.y) t += `translateY(${p.y}px) `;\n  if (p.scale !== 1) t += `scale(${p.scale}) `;\n  if (p.rotateX) t += `rotateX(${p.rotateX}deg) `;\n  if (p.rotateY) t += `rotateY(${p.rotateY}deg) `;\n  if (p.rotateZ) t += `rotateZ(${p.rotateZ}deg) `;\n  return t ? t.trim() : \"none\";\n}\n\nfunction renderPose(card: CardMotion) {\n  if (!card.el) return;\n  card.el.style.transform = frameTransform(card.pose);\n  card.el.style.opacity = String(card.pose.opacity);\n}\n\n/** Speed of a running spring right now, so a new target keeps its momentum. */\nfunction velocityOf(run: SpringRun | undefined) {\n  if (!run) return 0;\n  const p = run.tween.progress();\n  if (p >= 1) return 0;\n  const a = Math.max(0, p - 0.001);\n  const b = Math.min(1, p + 0.001);\n  return (((run.ease(b) - run.ease(a)) / (b - a)) * (run.to - run.from)) / run.duration;\n}\n\nfunction stop(card: CardMotion, key: PoseKey) {\n  card.runs[key]?.tween.kill();\n  delete card.runs[key];\n}\n\nfunction springTo(\n  card: CardMotion,\n  key: PoseKey,\n  to: number,\n  spring: { stiffness: number; damping: number },\n) {\n  const velocity = velocityOf(card.runs[key]);\n  stop(card, key);\n  const from = card.pose[key];\n  if (from === to) return;\n  const { duration, ease } = springEase({ ...spring, velocity: velocity / (to - from) });\n  const tween = gsap.to(card.pose, {\n    [key]: to,\n    duration,\n    ease,\n    onUpdate: () => renderPose(card),\n  });\n  card.runs[key] = { tween, from, to, duration, ease };\n}\n\n// Calculate fanned background spread offsets\nfunction slotFor(index: number): Partial<Pose> {\n  const isFront = index === 0;\n  const fanRotate = index === 1 ? 6 : index === 2 ? -6 : index * 4;\n  const fanX = index === 1 ? 24 : index === 2 ? -24 : 0;\n  const fanY = index * 12;\n  return {\n    scale: 1 - index * 0.05,\n    rotateZ: isFront ? 0 : fanRotate,\n    x: isFront ? 0 : fanX,\n    y: isFront ? 0 : fanY,\n    opacity: 1 - index * 0.2,\n  };\n}\n\n/** Tilt range: pointer offset ±150px maps onto ±14deg, clamped. */\nconst tiltFrom = (offset: number) =>\n  Math.max(-14, Math.min(14, (offset / 150) * 14));\n\n/** A card on screen: in the deck, or still flying out of it. */\ninterface StackEntry {\n  item: MemoryItem;\n  index: number;\n  zIndex: number;\n  present: boolean;\n}\n\nexport const MemoriesCard = React.forwardRef<HTMLDivElement, MemoriesCardProps>(\n  ({ items, onCardChange, className, ...props }, ref) => {\n    const [cards, setCards] = useState<MemoryItem[]>(items);\n    // The swiped card leaves toward the side it was thrown.\n    const [exitDirection, setExitDirection] = useState(1);\n    const [, forceRender] = useReducer((n: number) => n + 1, 0);\n\n    const elements = useRef(new Map<string, HTMLDivElement>());\n    const motions = useRef(new Map<string, CardMotion>());\n    const rendered = useRef<StackEntry[]>([]);\n    const exited = useRef(new Set<string>());\n    const tilt = useRef<{ x: SpringFollower; y: SpringFollower } | null>(null);\n    const endDrag = useRef<(() => void) | null>(null);\n\n    // 3D Tilt springs for the front card, fed by the pointer offset from its centre\n    useLayoutEffect(() => {\n      const apply = () =>\n        motions.current.forEach((card) => {\n          if (!card.tilted || !tilt.current) return;\n          card.pose.rotateX = tilt.current.x.get();\n          card.pose.rotateY = tilt.current.y.get();\n          renderPose(card);\n        });\n      tilt.current = {\n        x: createSpringFollower(0, apply, { ...TILT_SPRING, ticker: gsapTicker }),\n        y: createSpringFollower(0, apply, { ...TILT_SPRING, ticker: gsapTicker }),\n      };\n      const cardMotions = motions.current;\n      return () => {\n        tilt.current?.x.destroy();\n        tilt.current?.y.destroy();\n        tilt.current = null;\n        endDrag.current?.();\n        // Forget what was asked for, so a remount (Strict Mode) picks every\n        // animation up again from where it stopped.\n        cardMotions.forEach((card) => {\n          Object.values(card.runs).forEach((run) => run?.tween.kill());\n          card.runs = {};\n          card.targets = {};\n          card.exit?.kill();\n          card.exit = null;\n        });\n      };\n    }, []);\n\n    const setTilt = (offsetX: number, offsetY: number) => {\n      tilt.current?.x.set(-tiltFrom(offsetY));\n      tilt.current?.y.set(tiltFrom(offsetX));\n    };\n\n    const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n      const rect = e.currentTarget.getBoundingClientRect();\n      const centerX = rect.left + rect.width / 2;\n      const centerY = rect.top + rect.height / 2;\n      setTilt(e.clientX - centerX, e.clientY - centerY);\n    };\n\n    const handleMouseLeave = () => {\n      setTilt(0, 0);\n    };\n\n    const handleDragEnd = (offsetX: number) => {\n      const threshold = 80;\n      if (Math.abs(offsetX) > threshold) {\n        setExitDirection(offsetX < 0 ? -1 : 1);\n        // Remove front card and push to the back of the stack\n        setCards((prev) => {\n          const newStack = [...prev];\n          const removed = newStack.shift();\n          if (removed) newStack.push(removed);\n\n          // Fixed: Pass the correct original index of the NEW front card to the parent\n          if (onCardChange && newStack[0]) {\n            const nextActiveIndex = items.findIndex(\n              (orig) => orig.id === newStack[0].id,\n            );\n            onCardChange(nextActiveIndex);\n          }\n\n          return newStack;\n        });\n        setTilt(0, 0);\n      }\n    };\n    const dragEnd = useRef(handleDragEnd);\n    dragEnd.current = handleDragEnd;\n\n    // Horizontal drag of the front card: 0/0 constraints with 0.6 elastic, so\n    // the card trails the pointer at 0.6x and springs home on release.\n    const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>, id: string) => {\n      if (e.pointerType === \"mouse\" ? e.button > 0 : e.isPrimary === false) return;\n      const card = motions.current.get(id);\n      if (!card) return;\n      endDrag.current?.();\n      // Grabbing the card stops whatever its x and y were doing.\n      stop(card, \"x\");\n      stop(card, \"y\");\n\n      const startX = e.pageX;\n      const startY = e.pageY;\n      let lastX = startX;\n      let originX = 0;\n      let dragging = false;\n\n      const move = (ev: PointerEvent) => {\n        lastX = ev.pageX;\n        const offsetX = ev.pageX - startX;\n        if (!dragging) {\n          if (Math.hypot(offsetX, ev.pageY - startY) < 3) return;\n          dragging = true;\n          originX = card.pose.x;\n        }\n        card.pose.x = (originX + offsetX) * DRAG_ELASTIC;\n        renderPose(card);\n      };\n      const up = (ev: PointerEvent) => {\n        remove();\n        if (!dragging) return;\n        const offsetX = (ev.type === \"pointercancel\" ? lastX : ev.pageX) - startX;\n        springTo(card, \"x\", 0, BOUNCE_SPRING);\n        requestAnimationFrame(() => dragEnd.current(offsetX));\n      };\n      const remove = () => {\n        window.removeEventListener(\"pointermove\", move);\n        window.removeEventListener(\"pointerup\", up);\n        window.removeEventListener(\"pointercancel\", up);\n        endDrag.current = null;\n      };\n      window.addEventListener(\"pointermove\", move);\n      window.addEventListener(\"pointerup\", up);\n      window.addEventListener(\"pointercancel\", up);\n      endDrag.current = remove;\n    };\n\n    const handleReset = () => {\n      setExitDirection(1);\n      setCards(items);\n      if (onCardChange) onCardChange(0);\n    };\n\n    // Cards in the deck (the first four), plus any still flying out, kept\n    // where they sat in the previous render.\n    const present: StackEntry[] = [];\n    cards.forEach((item, index) => {\n      // Hide cards deep in the stack for performance\n      if (index > 3) return;\n      present.push({ item, index, zIndex: cards.length - index, present: true });\n    });\n    const presentIds = new Set(present.map((entry) => entry.item.id));\n    const entries = [...present];\n    rendered.current.forEach((entry, i) => {\n      if (presentIds.has(entry.item.id) || exited.current.has(entry.item.id)) return;\n      entries.splice(i, 0, { ...entry, present: false });\n    });\n\n    useLayoutEffect(() => {\n      const seen = new Set<string>();\n      entries.forEach((entry) => {\n        const id = entry.item.id;\n        seen.add(id);\n        let card = motions.current.get(id);\n        if (!card) {\n          card = { el: null, pose: { ...MOUNT_POSE }, targets: {}, runs: {}, exit: null, tilted: false };\n          motions.current.set(id, card);\n        }\n        card.el = elements.current.get(id) ?? null;\n\n        const tilted = entry.index === 0;\n        if (tilted !== card.tilted) {\n          card.tilted = tilted;\n          card.pose.rotateX = tilted && tilt.current ? tilt.current.x.get() : 0;\n          card.pose.rotateY = tilted && tilt.current ? tilt.current.y.get() : 0;\n          renderPose(card);\n        }\n\n        if (entry.present) {\n          exited.current.delete(id);\n          if (card.exit) {\n            card.exit.kill();\n            card.exit = null;\n            card.targets = {};\n          }\n          const slot = slotFor(entry.index);\n          (Object.keys(slot) as PoseKey[]).forEach((key) => {\n            const value = slot[key] as number;\n            if (card.targets[key] === value) return;\n            card.targets[key] = value;\n            springTo(card, key, value, SLOT_SPRING);\n          });\n        } else if (!card.exit) {\n          const leaving = card;\n          ([\"x\", \"rotateZ\", \"opacity\"] as const).forEach((key) => stop(leaving, key));\n          leaving.exit = gsap.to(leaving.pose, {\n            x: exitDirection * 350,\n            opacity: 0,\n            rotateZ: exitDirection * 20,\n            duration: 0.3,\n            ease: EXIT_EASE,\n            onUpdate: () => renderPose(leaving),\n            onComplete: () => {\n              exited.current.add(id);\n              forceRender();\n            },\n          });\n        }\n      });\n\n      motions.current.forEach((card, id) => {\n        if (seen.has(id)) return;\n        Object.values(card.runs).forEach((run) => run?.tween.kill());\n        card.exit?.kill();\n        motions.current.delete(id);\n        exited.current.delete(id);\n      });\n      rendered.current = entries;\n    });\n\n    return (\n      <div\n        ref={ref}\n        className={cn(\n          \"relative w-full min-h-[520px] flex flex-col items-center justify-center py-8 select-none perspective-[1200px]\",\n          className,\n        )}\n        {...props}\n      >\n        {/* Card Stack Container */}\n        <div className=\"relative w-[300px] sm:w-[340px] md:w-[380px] h-[440px] sm:h-[480px] flex items-center justify-center\">\n          {entries.map(({ item, index, zIndex, present: isPresent }) => {\n            const isFront = index === 0;\n            const canDrag = isFront && isPresent;\n\n            // Fixed: Lookup card's original sequence index in the immutable items prop\n            const originalIndex = items.findIndex(\n              (orig) => orig.id === item.id,\n            );\n\n            return (\n              <div\n                key={item.id}\n                ref={(el) => {\n                  if (el) elements.current.set(item.id, el);\n                  else elements.current.delete(item.id);\n                }}\n                style={\n                  isFront\n                    ? { ...MOUNT_STYLE, zIndex, ...DRAG_STYLE }\n                    : { ...MOUNT_STYLE, zIndex }\n                }\n                draggable={isFront ? false : undefined}\n                onMouseMove={isFront ? handleMouseMove : undefined}\n                onMouseLeave={isFront ? handleMouseLeave : undefined}\n                onPointerDown={canDrag ? (e) => handlePointerDown(e, item.id) : undefined}\n                className={cn(\n                  \"absolute inset-0 rounded-3xl overflow-hidden shadow-2xl transition-shadow duration-300\",\n                  \"bg-card border border-border/80\",\n                  isFront\n                    ? \"cursor-grab active:cursor-grabbing shadow-primary/20 dark:shadow-primary/20 ring-2 ring-primary/30\"\n                    : \"pointer-events-none hover:border-primary/50 shadow-md shadow-zinc-300/40 dark:shadow-black/50\",\n                )}\n              >\n                {/* Card Background Image */}\n                <div className=\"relative w-full h-full overflow-hidden\">\n                  <img\n                    src={item.image}\n                    alt={item.title}\n                    className=\"w-full h-full object-cover pointer-events-none transition-transform duration-700 hover:scale-105\"\n                  />\n\n                  {/* Gradient Overlay for Text Readability */}\n                  <div className=\"absolute inset-0 bg-gradient-to-t from-black/90 via-black/30 to-transparent dark:from-black/95 dark:via-black/40 dark:to-transparent\" />\n\n                  {/* Top Bar Badges */}\n                  <div className=\"absolute top-5 inset-x-5 flex items-center justify-between pointer-events-none text-white\">\n                    {item.tag ? (\n                      <span className=\"inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider px-3 py-1 rounded-full bg-primary/90 backdrop-blur-md text-primary-foreground shadow-sm\">\n                        <Sparkles className=\"w-3 h-3\" />\n                        {item.tag}\n                      </span>\n                    ) : (\n                      <div />\n                    )}\n\n                    {/* Fixed: Displays actual sequence (1/4, 2/4, etc.) based on original index */}\n                    <span className=\"text-xs font-medium text-white/80 bg-black/30 backdrop-blur-md px-2.5 py-1 rounded-full border border-white/10\">\n                      {originalIndex + 1} / {items.length}\n                    </span>\n                  </div>\n\n                  {/* Bottom Metadata Payload */}\n                  <div className=\"absolute inset-x-0 bottom-0 p-6 flex flex-col justify-end pointer-events-none text-white\">\n                    <div className=\"flex items-center gap-4 text-xs font-medium text-zinc-300 dark:text-zinc-400 mb-2\">\n                      {item.date && (\n                        <span className=\"inline-flex items-center gap-1\">\n                          <Calendar className=\"w-3.5 h-3.5 text-primary\" />\n                          {item.date}\n                        </span>\n                      )}\n                      {item.location && (\n                        <span className=\"inline-flex items-center gap-1\">\n                          <MapPin className=\"w-3.5 h-3.5 text-primary\" />\n                          {item.location}\n                        </span>\n                      )}\n                    </div>\n\n                    <h3 className=\"text-2xl md:text-3xl font-semibold tracking-tight mb-2 leading-snug text-white\">\n                      {item.title}\n                    </h3>\n\n                    {item.description && (\n                      <p className=\"text-sm text-zinc-300 dark:text-zinc-400 line-clamp-2 leading-relaxed\">\n                        {item.description}\n                      </p>\n                    )}\n                  </div>\n                </div>\n              </div>\n            );\n          })}\n        </div>\n\n        {/* Action Controls & Instructions */}\n        <div className=\"flex items-center justify-between w-full max-w-[340px] sm:max-w-[380px] mt-6 px-2 z-40\">\n          <span className=\"text-xs font-medium text-muted-foreground tracking-wide\">\n            ← Swipe card left or right to cycle →\n          </span>\n\n          <button\n            onClick={handleReset}\n            title=\"Reset stack order\"\n            className=\"inline-flex items-center gap-1.5 text-xs font-semibold text-foreground bg-background border border-border px-3 py-1.5 rounded-full shadow-sm hover:bg-primary hover:text-primary-foreground hover:border-primary/30 active:scale-95 transition-all\"\n          >\n            <RotateCcw className=\"w-3.5 h-3.5\" />\n            Reset\n          </button>\n        </div>\n      </div>\n    );\n  },\n);\n\nMemoriesCard.displayName = \"MemoriesCard\";\n",
      "type": "registry:component",
      "target": "components/custom/blocks/MemoriesCardBlock.tsx"
    },
    {
      "path": "src/components/custom/blocks/gsap-motion.ts",
      "content": "import gsap from \"gsap\";\nimport { cubicBezier, type FrameTicker } from \"./motion-curves\";\n\n/**\n * GSAP-side glue for the GSAP builds of components that also ship a Motion\n * Motion twin. Kept apart from motion-curves.ts so the library-free curves\n * never pull GSAP into a CSS or Motion build.\n */\n\n/** `gsap.ticker` as a FrameTicker, so spring followers run on GSAP's loop. */\nexport const gsapTicker: FrameTicker = {\n  add(callback) {\n    const tick = (_time: number, deltaTime: number) => callback(deltaTime);\n    gsap.ticker.add(tick);\n    return () => gsap.ticker.remove(tick);\n  },\n};\n\n/** A Motion / CSS cubic-bezier array as a GSAP ease. */\nexport const bezierEase = (curve: readonly [number, number, number, number] | readonly number[]) =>\n  cubicBezier(curve[0], curve[1], curve[2], curve[3]);\n\n/** `(prefers-reduced-motion: reduce)` right now. */\nexport const prefersReducedMotion = () =>\n  typeof window !== \"undefined\" &&\n  window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches === true;\n",
      "type": "registry:component",
      "target": "components/custom/blocks/gsap-motion.ts"
    },
    {
      "path": "src/components/custom/blocks/motion-curves.ts",
      "content": "/**\n * Motion curves with no animation library behind them.\n *\n * The components here ship as CSS, GSAP or Motion builds that must move\n * identically, so the curves are computed once, from the same numbers, and\n * handed to whichever engine runs them:\n *\n *   - `cubicBezier(x1, y1, x2, y2)` → an easing function (GSAP accepts any\n *     `(progress) => value` as `ease`), exact for Motion's `ease: [..]` arrays\n *     and for CSS `cubic-bezier()`.\n *   - `spring({ stiffness, damping, mass })` → the analytic solution Motion\n *     Motion uses, as an easing function plus the time it takes to settle, or\n *     as a CSS `linear()` string for a fixed start and end.\n *   - `createSpringFollower` → a value that chases a moving target through the\n *     same spring every frame, like Motion's `useSpring`, for pointer-driven\n *     motion that no fixed curve can describe.\n */\n\n// ---------------------------------------------------------------------------\n// Cubic bezier\n// ---------------------------------------------------------------------------\n\n/**\n * The CSS / Motion cubic-bezier as a function of progress. Newton-Raphson\n * with a bisection fallback, the same solver browsers use.\n */\nexport function cubicBezier(x1: number, y1: number, x2: number, y2: number) {\n  if (x1 === y1 && x2 === y2) return (t: number) => t;\n\n  const a = (p1: number, p2: number) => 1 - 3 * p2 + 3 * p1;\n  const b = (p1: number, p2: number) => 3 * p2 - 6 * p1;\n  const c = (p1: number) => 3 * p1;\n  const at = (t: number, p1: number, p2: number) =>\n    ((a(p1, p2) * t + b(p1, p2)) * t + c(p1)) * t;\n  const slope = (t: number, p1: number, p2: number) =>\n    3 * a(p1, p2) * t * t + 2 * b(p1, p2) * t + c(p1);\n\n  const solveX = (x: number) => {\n    let t = x;\n    for (let i = 0; i < 8; i++) {\n      const s = slope(t, x1, x2);\n      if (Math.abs(s) < 1e-6) break;\n      const err = at(t, x1, x2) - x;\n      if (Math.abs(err) < 1e-7) return t;\n      t -= err / s;\n    }\n    let lo = 0;\n    let hi = 1;\n    t = x;\n    for (let i = 0; i < 30 && hi - lo > 1e-7; i++) {\n      const value = at(t, x1, x2);\n      if (value < x) lo = t;\n      else hi = t;\n      t = (lo + hi) / 2;\n    }\n    return t;\n  };\n\n  return (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : at(solveX(x), y1, y2));\n}\n\n/** Motion's named eases, as the cubic-beziers they are. */\nexport const MOTION_EASE = {\n  linear: [0, 0, 1, 1],\n  easeIn: [0.42, 0, 1, 1],\n  easeOut: [0, 0, 0.58, 1],\n  easeInOut: [0.42, 0, 0.58, 1],\n  circIn: [0.55, 0, 1, 0.45],\n  circOut: [0.55, 0, 0.45, 1],\n  circInOut: [0.85, 0, 0.15, 1],\n  backIn: [0.31, 0.01, 0.66, -0.59],\n  backOut: [0.33, 1.53, 0.69, 0.99],\n  anticipate: [0.66, -0.56, 0.34, 1.35],\n} as const;\n\n/**\n * Motion's default layout transition (`layout` / `layoutId`):\n * `{ duration: 0.45, ease: [0.4, 0, 0.1, 1] }`.\n */\nexport const LAYOUT_TRANSITION = { duration: 0.45, ease: [0.4, 0, 0.1, 1] as const };\n\n// ---------------------------------------------------------------------------\n// Spring\n// ---------------------------------------------------------------------------\n\nexport interface SpringOptions {\n  /** Motion default 100. */\n  stiffness?: number;\n  /** Motion default 10. */\n  damping?: number;\n  /** Motion default 1. */\n  mass?: number;\n  /** Starting velocity, in units of the whole distance per second. */\n  velocity?: number;\n  /** How close to the end counts as settled, as a fraction of the distance. */\n  restDelta?: number;\n}\n\n/**\n * Normalised position (0 → 1) of a spring released from 0 towards 1, at time\n * `t` seconds. The closed-form solution Motion's `spring()` generator\n * uses for the under-, critically and over-damped cases.\n */\nexport function springAt(options: SpringOptions = {}) {\n  const { stiffness = 100, damping = 10, mass = 1, velocity = 0 } = options;\n  const zeta = damping / (2 * Math.sqrt(stiffness * mass));\n  const omega0 = Math.sqrt(stiffness / mass);\n  // Motion's convention: distance still to cover, velocity toward it negated.\n  const delta = 1;\n  const v0 = -velocity;\n\n  if (zeta < 1) {\n    const omegaD = omega0 * Math.sqrt(1 - zeta * zeta);\n    return (t: number) => {\n      const envelope = Math.exp(-zeta * omega0 * t);\n      return (\n        1 -\n        envelope *\n          (((v0 + zeta * omega0 * delta) / omegaD) * Math.sin(omegaD * t) +\n            delta * Math.cos(omegaD * t))\n      );\n    };\n  }\n  if (zeta === 1) {\n    return (t: number) => 1 - Math.exp(-omega0 * t) * (delta + (v0 + omega0 * delta) * t);\n  }\n  const omegaD = omega0 * Math.sqrt(zeta * zeta - 1);\n  return (t: number) => {\n    const envelope = Math.exp(-zeta * omega0 * t);\n    const freq = Math.min(omegaD * t, 300);\n    return (\n      1 -\n      (envelope *\n        ((v0 + zeta * omega0 * delta) * Math.sinh(freq) + omegaD * delta * Math.cosh(freq))) /\n        omegaD\n    );\n  };\n}\n\n/** Seconds until the spring stays within `restDelta` of its end. */\nexport function springDuration(options: SpringOptions = {}) {\n  const at = springAt(options);\n  const restDelta = options.restDelta ?? 0.001;\n  const step = 1 / 240;\n  let lastOutside = 0;\n  for (let t = 0; t <= 10; t += step) {\n    if (Math.abs(1 - at(t)) > restDelta) lastOutside = t;\n    else if (t - lastOutside > 0.1) break;\n  }\n  return Math.max(lastOutside + step, step);\n}\n\n/**\n * A spring as a duration and an easing function over it — what GSAP takes:\n *\n *   const { duration, ease } = springEase({ stiffness: 300, damping: 20 });\n *   gsap.to(el, { y: 0, duration, ease });\n *\n * Exact for a fixed start and end; a spring that has to react mid-flight to a\n * new target needs `createSpringFollower` instead.\n */\nexport function springEase(options: SpringOptions = {}) {\n  const duration = springDuration(options);\n  const at = springAt(options);\n  return {\n    duration,\n    ease: (progress: number) => (progress >= 1 ? 1 : at(progress * duration)),\n  };\n}\n\n/**\n * A spring as a CSS `linear()` easing and its duration in ms, for\n * `transition` / `animation` with a fixed start and end.\n *\n *   const { easing, duration } = springLinear({ stiffness: 400, damping: 30 });\n *   el.style.transition = `transform ${duration}ms ${easing}`;\n */\nexport function springLinear(options: SpringOptions = {}, pointsPerSecond = 60) {\n  const duration = springDuration(options);\n  const at = springAt(options);\n  const count = Math.max(Math.ceil(duration * pointsPerSecond), 8);\n  const points: string[] = [];\n  for (let i = 0; i <= count; i++) {\n    const t = (i / count) * duration;\n    points.push(String(Math.round((i === count ? 1 : at(t)) * 10000) / 10000));\n  }\n  return { easing: `linear(${points.join(\", \")})`, duration: Math.round(duration * 1000) };\n}\n\n// ---------------------------------------------------------------------------\n// Spring follower (useSpring equivalent)\n// ---------------------------------------------------------------------------\n\n/** Something that calls back once per frame with the time since the last, in ms. */\nexport interface FrameTicker {\n  add: (callback: (deltaMs: number) => void) => () => void;\n}\n\n/** requestAnimationFrame as a ticker — the library-free default. */\nexport const rafTicker: FrameTicker = {\n  add(callback) {\n    let last = performance.now();\n    let frame = requestAnimationFrame(function tick(now) {\n      callback(now - last);\n      last = now;\n      frame = requestAnimationFrame(tick);\n    });\n    return () => cancelAnimationFrame(frame);\n  },\n};\n\nexport interface SpringFollower {\n  /** Chase a new target from wherever the value is now, keeping its velocity. */\n  set: (target: number) => void;\n  /** Move to a value instantly, with no motion. */\n  jump: (value: number) => void;\n  get: () => number;\n  destroy: () => void;\n}\n\n/**\n * A value that follows its target through a spring, integrating the same\n * equation of motion Motion's `useSpring` solves — so a pointer-driven spring\n * reads the same in every build. Runs only while moving; `onUpdate` receives\n * each new value.\n */\nexport function createSpringFollower(\n  initial: number,\n  onUpdate: (value: number) => void,\n  options: SpringOptions & { restSpeed?: number; ticker?: FrameTicker } = {},\n): SpringFollower {\n  const { stiffness = 100, damping = 10, mass = 1, ticker = rafTicker } = options;\n  const restDelta = options.restDelta ?? 0.01;\n  const restSpeed = options.restSpeed ?? 0.01;\n  let value = initial;\n  let target = initial;\n  let velocity = 0;\n  let stop: (() => void) | null = null;\n\n  const step = (deltaMs: number) => {\n    // Fixed 1ms sub-steps keep the integration stable for stiff springs and\n    // independent of the frame rate.\n    const steps = Math.min(Math.max(Math.round(deltaMs), 1), 250);\n    for (let i = 0; i < steps; i++) {\n      const force = -stiffness * (value - target) - damping * velocity;\n      velocity += (force / mass) * 0.001;\n      value += velocity * 0.001;\n    }\n    if (Math.abs(target - value) < restDelta && Math.abs(velocity) < restSpeed) {\n      value = target;\n      velocity = 0;\n      stop?.();\n      stop = null;\n    }\n    onUpdate(value);\n  };\n\n  return {\n    set(next) {\n      target = next;\n      if (!stop && value !== target) stop = ticker.add(step);\n    },\n    jump(next) {\n      stop?.();\n      stop = null;\n      value = target = next;\n      velocity = 0;\n      onUpdate(value);\n    },\n    get: () => value,\n    destroy() {\n      stop?.();\n      stop = null;\n    },\n  };\n}\n",
      "type": "registry:component",
      "target": "components/custom/blocks/motion-curves.ts"
    }
  ],
  "docs": "Named export: MemoriesCard. `items` take { id, title, location, date, image, description?, tag? }; `onCardChange` reports the active index. Drag or click to advance the stack.",
  "categories": [
    "media",
    "marketing"
  ],
  "type": "registry:component"
}
