{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stepper",
  "type": "registry:ui",
  "title": "Stepper",
  "description": "Connectors draw, the current badge grows and panels slide in the direction of travel.",
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "files": [
    {
      "path": "components/prequelui/motion.tsx",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  MotionConfig,\n  useInView as useMotionInView,\n  type Transition,\n} from \"motion/react\";\nimport { useHydratedReducedMotion } from \"@/lib/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nconst TempoContext = React.createContext(1);\n\nexport function PrequelMotionProvider({\n  tempo = 1,\n  children,\n}: {\n  tempo?: number;\n  children: React.ReactNode;\n}) {\n  const value = React.useMemo(() => Math.max(0.4, tempo), [tempo]);\n  return (\n    <TempoContext.Provider value={value}>\n      <MotionConfig reducedMotion=\"user\">{children}</MotionConfig>\n    </TempoContext.Provider>\n  );\n}\n\nexport function useTempo() {\n  return React.useContext(TempoContext);\n}\n\nconst TIME_KEYS = [\n  \"duration\",\n  \"visualDuration\",\n  \"delay\",\n  \"repeatDelay\",\n  \"delayChildren\",\n] as const;\n\nfunction scaleValue(transition: Transition, tempo: number): Transition {\n  if (tempo === 1 || !transition || typeof transition !== \"object\") {\n    return transition;\n  }\n  const next: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(transition)) {\n    if (typeof value === \"number\" && (TIME_KEYS as readonly string[]).includes(key)) {\n      next[key] = value * tempo;\n    } else if (typeof value === \"number\" && key === \"stiffness\") {\n      next[key] = value / (tempo * tempo);\n    } else if (typeof value === \"number\" && key === \"damping\") {\n      next[key] = value / tempo;\n    } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n      next[key] = scaleValue(value as Transition, tempo);\n    } else {\n      next[key] = value;\n    }\n  }\n  return next as Transition;\n}\n\nexport function useTempoTransition(transition: Transition) {\n  const tempo = useTempo();\n  return React.useMemo(\n    () => scaleValue(transition, tempo),\n    [tempo, JSON.stringify(transition)],\n  );\n}\n\nexport function useReduceMotion() {\n  return useHydratedReducedMotion();\n}\n\nexport function usePageVisible() {\n  const [visible, setVisible] = React.useState(true);\n  React.useEffect(() => {\n    const update = () => setVisible(!document.hidden);\n    update();\n    document.addEventListener(\"visibilitychange\", update);\n    return () => document.removeEventListener(\"visibilitychange\", update);\n  }, []);\n  return visible;\n}\n\nexport function useMounted() {\n  return React.useSyncExternalStore(\n    () => () => {},\n    () => true,\n    () => false,\n  );\n}\n\nexport function useSeen(\n  ref: React.RefObject<Element | null>,\n  enabled = true,\n  once = true,\n) {\n  const inView = useMotionInView(ref, { once, amount: 0.35 });\n  return enabled ? inView : true;\n}\n\ntype SlotProps = React.HTMLAttributes<HTMLElement> & {\n  children?: React.ReactNode;\n  ref?: React.Ref<HTMLElement>;\n};\n\nexport function Slot({ children, ...props }: SlotProps) {\n  if (!React.isValidElement<Record<string, unknown>>(children)) {\n    return null;\n  }\n  const child = children as React.ReactElement<Record<string, unknown>>;\n  const childProps = child.props;\n  return React.cloneElement(child, {\n    ...props,\n    ...childProps,\n    className: cn(\n      String(props.className ?? \"\"),\n      String(childProps.className ?? \"\"),\n    ),\n    style: {\n      ...((props.style as React.CSSProperties) ?? {}),\n      ...((childProps.style as React.CSSProperties) ?? {}),\n    },\n  } as Record<string, unknown>);\n}\n\nexport function srOnlyStyle(): React.CSSProperties {\n  return {\n    position: \"absolute\",\n    width: 1,\n    height: 1,\n    padding: 0,\n    margin: -1,\n    overflow: \"hidden\",\n    clip: \"rect(0, 0, 0, 0)\",\n    whiteSpace: \"nowrap\",\n    borderWidth: 0,\n  };\n}\n\nlet segmenter: Intl.Segmenter | null | undefined;\n\nexport function splitGraphemes(text: string): string[] {\n  if (segmenter === undefined) {\n    segmenter =\n      typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\"\n        ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" })\n        : null;\n  }\n  if (!segmenter) return Array.from(text);\n  return Array.from(segmenter.segment(text), (entry) => entry.segment);\n}\n\nexport const easeOut = [0.23, 1, 0.32, 1] as const;\nexport const easeSoft = [0.215, 0.61, 0.355, 1] as const;\nexport const easeInOut = [0.77, 0, 0.175, 1] as const;\nexport const easeEnter = [0.25, 0.1, 0.35, 1] as const;\nexport const easeLeave = [0, 0, 0.58, 1] as const;\nexport const easeResize = [0.4, 0, 0.1, 1] as const;\nexport const easeAway = [0.33, 0.17, 0.67, 0.5] as const;\n\nexport const pressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const selectionSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n};\n\nexport const highlightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 40,\n};\n\nexport const popSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 29,\n};\n\nexport const tooltipSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 31,\n};\n\nexport const dialogSpring: Transition = {\n  type: \"spring\",\n  stiffness: 150,\n  damping: 25,\n};\n\nexport const toastSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 24,\n};\n\nexport const heightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n  bounce: 0,\n  restDelta: 0.01,\n};\n\nexport const progressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 35,\n  restDelta: 0.01,\n  restSpeed: 0.1,\n};\n\nexport const scrollSpring: Transition = {\n  type: \"spring\",\n  stiffness: 250,\n  damping: 40,\n  bounce: 0,\n};\n\nexport const avatarSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 17,\n};\n\nexport const pinnedSpring: Transition = {\n  type: \"spring\",\n  stiffness: 320,\n  damping: 25,\n  mass: 0.8,\n};\n\nexport const thumbSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 25,\n};\n\nexport const checkSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 24,\n};\n\nexport const cursorEntry: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const cursorExit: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 46.9,\n  restSpeed: 10,\n};\n\nexport const cursorLabel: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 50,\n  bounce: 0,\n};\n\nexport const swapTween: Transition = {\n  duration: 0.15,\n  ease: easeOut,\n};\n\nexport const overlayTween: Transition = {\n  duration: 0.4,\n  ease: easeSoft,\n};\n\nexport const disclosureTween: Transition = {\n  duration: 0.35,\n  ease: easeSoft,\n};\n\nexport const menuTween: Transition = {\n  duration: 0.22,\n  ease: easeSoft,\n};\n\nexport const panelOutTween: Transition = {\n  duration: 0.15,\n  ease: easeLeave,\n};\n\nexport const panelInTween: Transition = {\n  duration: 0.3,\n  ease: easeEnter,\n};\n\nexport const panelHeightTween: Transition = {\n  duration: 0.45,\n  ease: easeResize,\n};\n\nexport const exitTween: Transition = {\n  duration: 0.2,\n  ease: easeAway,\n};\n\nexport const faceSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 20,\n};\n\nexport const blurIcon = \"blur(2px)\";\n\nexport function flipTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate =\n    side === \"top\"\n      ? \"rotateX(-20deg)\"\n      : side === \"bottom\"\n        ? \"rotateX(20deg)\"\n        : side === \"left\"\n          ? \"rotateY(20deg)\"\n          : \"rotateY(-20deg)\";\n  return `perspective(500px) ${rotate} scale(0.8)`;\n}\n\nexport function uprightTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate = side === \"left\" || side === \"right\" ? \"rotateY(0deg)\" : \"rotateX(0deg)\";\n  return `perspective(500px) ${rotate} scale(1)`;\n}\n",
      "target": "components/prequelui/motion.tsx"
    },
    {
      "path": "components/prequelui/stepper.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\nimport { useReduceMotion } from \"./motion\";\n\nexport type StepperStep = {\n  id: string;\n  title: string;\n  description?: string;\n  content?: React.ReactNode;\n};\n\nexport type StepperProps = Omit<React.ComponentProps<\"div\">, \"onChange\"> & {\n  steps: StepperStep[];\n  value?: number;\n  defaultValue?: number;\n  onValueChange?: (index: number) => void;\n  controls?: boolean;\n  backLabel?: string;\n  nextLabel?: string;\n  finishLabel?: string;\n  onComplete?: () => void;\n  minHeight?: number;\n};\n\nconst clamp = (value: number, max: number) => Math.min(max, Math.max(0, value));\n\nfunction CheckIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" className=\"size-3.5\">\n      <motion.path\n        d=\"M3.4 8.4 6.6 11.5 12.6 4.8\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.9\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        initial={{ pathLength: 0 }}\n        animate={{ pathLength: 1 }}\n        transition={{ duration: 0.28, ease: [0.23, 1, 0.32, 1] }}\n      />\n    </svg>\n  );\n}\n\nexport function Stepper({\n  steps,\n  value,\n  defaultValue = 0,\n  onValueChange,\n  controls = true,\n  backLabel = \"Back\",\n  nextLabel = \"Continue\",\n  finishLabel = \"Finish\",\n  onComplete,\n  minHeight = 112,\n  className,\n  ...props\n}: StepperProps) {\n  const [internal, setInternal] = React.useState(() =>\n    clamp(defaultValue, Math.max(0, steps.length - 1)),\n  );\n  const current = clamp(value ?? internal, Math.max(0, steps.length - 1));\n  const previous = React.useRef(current);\n  const reduce = useReduceMotion();\n  const id = React.useId().replace(/:/g, \"\");\n  const direction = current >= previous.current ? 1 : -1;\n  const step = steps[current];\n\n  React.useEffect(() => {\n    previous.current = current;\n  }, [current]);\n\n  const go = React.useCallback(\n    (next: number) => {\n      const safe = clamp(next, Math.max(0, steps.length - 1));\n      if (safe === current) return;\n      if (value === undefined) setInternal(safe);\n      onValueChange?.(safe);\n    },\n    [current, onValueChange, steps.length, value],\n  );\n\n  const last = steps.length - 1;\n\n  return (\n    <div\n      data-slot=\"stepper\"\n      className={cn(\"w-full max-w-[440px]\", className)}\n      {...props}\n    >\n      <ol className=\"flex w-full items-start\" aria-label=\"Progress\">\n        {steps.map((item, index) => {\n          const state =\n            index < current ? \"complete\" : index === current ? \"current\" : \"upcoming\";\n          return (\n            <li\n              key={item.id}\n              className=\"relative flex min-w-0 flex-1 flex-col items-center\"\n            >\n              {index < last ? (\n                <span\n                  aria-hidden=\"true\"\n                  className=\"absolute left-1/2 top-[15px] -ml-px h-px w-full overflow-hidden bg-border\"\n                >\n                  <motion.span\n                    className=\"block h-full w-full origin-left bg-primary\"\n                    initial={false}\n                    animate={{ scaleX: index < current ? 1 : 0 }}\n                    transition={{ duration: 0.4, ease: [0.4, 0, 0.1, 1] }}\n                  />\n                </span>\n              ) : null}\n              <button\n                type=\"button\"\n                onClick={() => go(index)}\n                aria-current={state === \"current\" ? \"step\" : undefined}\n                aria-label={`Step ${index + 1}: ${item.title}`}\n                className=\"group relative z-10 flex flex-col items-center gap-2 rounded-lg px-1 py-0.5 text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n              >\n                <motion.span\n                  className={cn(\n                    \"flex size-[30px] items-center justify-center rounded-full border text-[13px] font-medium transition-colors\",\n                    state === \"complete\" &&\n                      \"border-primary bg-primary text-primary-foreground\",\n                    state === \"current\" &&\n                      \"border-primary bg-background text-foreground\",\n                    state === \"upcoming\" &&\n                      \"border-border bg-muted/40 text-muted-foreground\",\n                  )}\n                  initial={false}\n                  animate={\n                    state === \"current\" && !reduce ? { scale: 1.08 } : { scale: 1 }\n                  }\n                  transition={{ type: \"spring\", stiffness: 380, damping: 24 }}\n                >\n                  {state === \"complete\" ? <CheckIcon /> : index + 1}\n                </motion.span>\n                <span className=\"flex min-w-0 flex-col\">\n                  <span\n                    className={cn(\n                      \"truncate text-[13px] leading-4\",\n                      state === \"upcoming\"\n                        ? \"text-muted-foreground\"\n                        : \"font-medium text-foreground\",\n                    )}\n                  >\n                    {item.title}\n                  </span>\n                  {item.description ? (\n                    <span className=\"mt-0.5 hidden truncate text-[13px] leading-4 text-muted-foreground sm:block\">\n                      {item.description}\n                    </span>\n                  ) : null}\n                </span>\n              </button>\n            </li>\n          );\n        })}\n      </ol>\n\n      <div\n        className=\"relative mt-6 overflow-hidden rounded-xl border bg-background\"\n        style={{ minHeight }}\n      >\n        <AnimatePresence mode=\"wait\" initial={false} custom={direction}>\n          <motion.div\n            key={step?.id ?? current}\n            id={`stepper-panel-${id}`}\n            role=\"region\"\n            aria-live=\"polite\"\n            aria-label={step ? `${step.title} step` : undefined}\n            initial={\n              reduce\n                ? { opacity: 0 }\n                : { opacity: 0, x: direction * 18, filter: \"blur(3px)\" }\n            }\n            animate={{ opacity: 1, x: 0, filter: \"blur(0px)\" }}\n            exit={\n              reduce\n                ? { opacity: 0 }\n                : { opacity: 0, x: direction * -18, filter: \"blur(2px)\" }\n            }\n            transition={{ duration: reduce ? 0.15 : 0.26, ease: [0.23, 1, 0.32, 1] }}\n            className=\"p-4 text-[13px] leading-5 text-muted-foreground\"\n          >\n            {step?.content ?? (\n              <p className=\"text-foreground\">{step?.title}</p>\n            )}\n          </motion.div>\n        </AnimatePresence>\n      </div>\n\n      {controls ? (\n        <div className=\"mt-4 flex items-center justify-between gap-3\">\n          <button\n            type=\"button\"\n            onClick={() => go(current - 1)}\n            disabled={current === 0}\n            className=\"inline-flex h-9 items-center justify-center rounded-lg border px-3 text-[13px] font-medium transition-colors hover:bg-accent disabled:pointer-events-none disabled:opacity-40\"\n          >\n            {backLabel}\n          </button>\n          <span className=\"text-[13px] tabular-nums text-muted-foreground\">\n            {Math.min(current + 1, steps.length)} / {steps.length}\n          </span>\n          <button\n            type=\"button\"\n            onClick={() => {\n              if (current === last) onComplete?.();\n              else go(current + 1);\n            }}\n            className=\"inline-flex h-9 items-center justify-center rounded-lg bg-primary px-3 text-[13px] font-medium text-primary-foreground transition-colors hover:bg-primary/90\"\n          >\n            {current === last ? finishLabel : nextLabel}\n          </button>\n        </div>\n      ) : null}\n    </div>\n  );\n}\n",
      "target": "components/prequelui/stepper.tsx"
    },
    {
      "path": "lib/use-reduced-motion.ts",
      "target": "lib/use-reduced-motion.ts",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport { useReducedMotion } from \"motion/react\";\nimport { useSyncExternalStore } from \"react\";\n\nconst subscribe = () => () => {};\n\nexport function useHydratedReducedMotion() {\n  const reduce = useReducedMotion() ?? false;\n  const mounted = useSyncExternalStore(\n    subscribe,\n    () => true,\n    () => false,\n  );\n  return mounted ? reduce : false;\n}\n"
    }
  ]
}
