{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cavemio-collapsible",
  "title": "Collapsible",
  "description": "\"Show 4 more\" that opens in place: the hidden part eases open through a blur while the button's words morph to \"Show less\".",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/collapsible.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Chevron, Fold } from \"./accordion\";\nimport { TextMorph } from \"./text-morph\";\nimport {\n  INTERACTION_FOCUS,\n  INTERACTION_PRESS,\n  useInteractionReducedMotion,\n} from \"./imported-ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * COLLAPSIBLE: \"Show 4 more\" that opens in place\n *\n *   open     the hidden part's height eases open while its content\n *            rises out of a blur; the button's words morph\n *            (\"Show 4 more\" → \"Show less\") and its chevron turns\n *   close    the reverse; the button stays where your finger is\n *            when it sits above the content (`placement=\"top\"`)\n *\n * One disclosure: aria-expanded on the button, the content a\n * region it controls, folded content inert.\n * ───────────────────────────────────────────────────────── */\n\nexport interface CollapsibleProps {\n  children: React.ReactNode;\n  /** Words on the button when closed and open. */\n  labels?: { closed: string; open: string };\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** Button above the hidden part (details) or below it (\"show more\" lists). */\n  placement?: \"top\" | \"bottom\";\n  className?: string;\n}\n\nexport function Collapsible({\n  children,\n  labels = { closed: \"Show more\", open: \"Show less\" },\n  open: controlled,\n  defaultOpen = false,\n  onOpenChange,\n  placement = \"bottom\",\n  className = \"\",\n}: CollapsibleProps) {\n  const reduced = useInteractionReducedMotion();\n  const id = React.useId();\n  const [own, setOwn] = React.useState(defaultOpen);\n  const open = controlled ?? own;\n\n  const button = (\n    <button\n      type=\"button\"\n      aria-expanded={open}\n      aria-controls={id}\n      onClick={() => {\n        if (controlled === undefined) setOwn(!open);\n        onOpenChange?.(!open);\n      }}\n      className={`-ml-3 inline-flex h-8 items-center gap-1.5 self-start rounded-full px-3 text-[13px] font-medium text-foreground cursor-pointer hover:bg-accent ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n    >\n      <TextMorph>{open ? labels.open : labels.closed}</TextMorph>\n      <Chevron open={open} reduced={reduced} />\n    </button>\n  );\n\n  return (\n    <div className={`flex w-full flex-col gap-1 ${className}`}>\n      {placement === \"top\" && button}\n      <Fold open={open} reduced={reduced} id={id}>\n        {children}\n      </Fold>\n      {placement === \"bottom\" && button}\n    </div>\n  );\n}\n\nexport default Collapsible;\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/accordion.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  EASE_OUT,\n  INTERACTION_FOCUS,\n  useInteractionReducedMotion,\n} from \"./imported-ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * ACCORDION: sections that open in place\n *\n *   open     the section's height eases open (0fr → 1fr) while its\n *            content rises out of a blur a beat later; the chevron\n *            turns over in the same motion\n *   single   opening one folds the open one at the same time, so\n *            the page below barely moves\n *   keys     ↑/↓ move between headers, Home/End jump; Enter and\n *            Space open\n *\n * For FAQ sections on landing pages there is faq-accordion; this\n * is the plain one for settings, filters and details.\n * ───────────────────────────────────────────────────────── */\n\nexport interface AccordionItem {\n  value: string;\n  title: React.ReactNode;\n  /** A second line under the title. */\n  subtitle?: React.ReactNode;\n  content: React.ReactNode;\n  disabled?: boolean;\n}\n\nexport interface AccordionProps {\n  items: AccordionItem[];\n  /** One open at a time, or any number. */\n  type?: \"single\" | \"multiple\";\n  value?: string[];\n  defaultValue?: string[];\n  onValueChange?: (value: string[]) => void;\n  /** thin line rows, or each section as its own card. */\n  variant?: \"rows\" | \"cards\";\n  className?: string;\n}\n\n/** The fold every disclosure in the library uses: height by grid rows, content through a blur. */\nexport function Fold({\n  open,\n  children,\n  reduced,\n  id,\n  labelledBy,\n}: {\n  open: boolean;\n  children: React.ReactNode;\n  reduced: boolean;\n  id?: string;\n  labelledBy?: string;\n}) {\n  return (\n    <div\n      id={id}\n      role={labelledBy ? \"region\" : undefined}\n      aria-labelledby={labelledBy}\n      inert={!open || undefined}\n      className=\"grid\"\n      style={{\n        gridTemplateRows: open ? \"1fr\" : \"0fr\",\n        transition: reduced ? \"none\" : `grid-template-rows 420ms ${EASE_OUT}`,\n      }}\n    >\n      <div className=\"min-h-0 overflow-hidden\">\n        <div\n          style={{\n            opacity: open ? 1 : 0,\n            filter: open || reduced ? \"blur(0px)\" : \"blur(4px)\",\n            translate: open || reduced ? \"0 0\" : \"0 -6px\",\n            transition: reduced\n              ? \"none\"\n              : open\n                ? `opacity 300ms ${EASE_OUT} 90ms, filter 300ms ${EASE_OUT} 90ms, translate 420ms ${EASE_OUT}`\n                : `opacity 160ms ${EASE_OUT}, filter 160ms ${EASE_OUT}, translate 260ms ${EASE_OUT}`,\n          }}\n        >\n          {children}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport function Chevron({\n  open,\n  reduced,\n}: {\n  open: boolean;\n  reduced: boolean;\n}) {\n  return (\n    <svg\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      aria-hidden=\"true\"\n      className=\"size-3.5 shrink-0 text-muted-foreground\"\n      style={{\n        transform: open ? \"rotate(180deg)\" : \"none\",\n        transition: reduced ? \"none\" : `transform 420ms ${EASE_OUT}`,\n      }}\n    >\n      <path\n        d=\"M4 6l4 4 4-4\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.6\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function Accordion({\n  items,\n  type = \"single\",\n  value,\n  defaultValue = [],\n  onValueChange,\n  variant = \"rows\",\n  className = \"\",\n}: AccordionProps) {\n  const reduced = useInteractionReducedMotion();\n  const baseId = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const [own, setOwn] = React.useState(defaultValue);\n  const open = value ?? own;\n  const cards = variant === \"cards\";\n\n  const toggle = (v: string) => {\n    const next = open.includes(v)\n      ? open.filter((x) => x !== v)\n      : type === \"single\"\n        ? [v]\n        : [...open, v];\n    if (value === undefined) setOwn(next);\n    onValueChange?.(next);\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    const heads = Array.from(\n      rootRef.current?.querySelectorAll<HTMLButtonElement>(\n        \"[data-accordion-head]:not(:disabled)\",\n      ) ?? [],\n    );\n    const i = heads.indexOf(document.activeElement as HTMLButtonElement);\n    if (i < 0) return;\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = (i + 1) % heads.length;\n    else if (e.key === \"ArrowUp\") next = (i - 1 + heads.length) % heads.length;\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = heads.length - 1;\n    if (next < 0) return;\n    e.preventDefault();\n    heads[next].focus();\n  };\n\n  return (\n    <div\n      ref={rootRef}\n      onKeyDown={onKeyDown}\n      className={`flex w-full flex-col ${cards ? \"gap-2\" : \"divide-y divide-border border-y border-border\"} ${className}`}\n    >\n      {items.map((item) => {\n        const on = open.includes(item.value);\n        const head = `${baseId}-h-${item.value}`;\n        const panel = `${baseId}-p-${item.value}`;\n        return (\n          <div\n            key={item.value}\n            className={\n              cards\n                ? `rounded-[16px] bg-card shadow-[inset_0_0_0_1px_var(--border)] transition-colors duration-300 ${on ? \"\" : \"hover:bg-accent/40\"}`\n                : \"\"\n            }\n          >\n            <h3 className=\"m-0\">\n              <button\n                type=\"button\"\n                id={head}\n                data-accordion-head=\"\"\n                aria-expanded={on}\n                aria-controls={panel}\n                disabled={item.disabled}\n                onClick={() => toggle(item.value)}\n                className={`flex w-full items-center gap-3 text-left cursor-pointer disabled:cursor-default disabled:opacity-40 ${cards ? \"rounded-[16px] px-4 py-3.5\" : \"py-3.5\"} ${INTERACTION_FOCUS} focus-visible:ring-offset-0`}\n              >\n                <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n                  <span className=\"text-[14px] font-medium text-foreground\">\n                    {item.title}\n                  </span>\n                  {item.subtitle && (\n                    <span className=\"text-[12.5px] text-muted-foreground\">\n                      {item.subtitle}\n                    </span>\n                  )}\n                </span>\n                <Chevron open={on} reduced={reduced} />\n              </button>\n            </h3>\n            <Fold open={on} reduced={reduced} id={panel} labelledBy={head}>\n              <div\n                className={`text-[13.5px] leading-relaxed text-muted-foreground ${cards ? \"px-4 pb-4\" : \"pb-4\"}`}\n              >\n                {item.content}\n              </div>\n            </Fold>\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n\nexport default Accordion;\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/imported-ui-interaction-motion.ts",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport const EASE_OUT = \"cubic-bezier(0.16, 1, 0.3, 1)\";\nexport const EASE_SETTLE = \"cubic-bezier(0.22, 1.18, 0.36, 1)\";\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = \"cubic-bezier(0.34, 1.36, 0.64, 1)\";\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  \"transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100\";\nexport const INTERACTION_FOCUS =\n  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background\";\n\nconst query = \"(prefers-reduced-motion: reduce)\";\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener(\"change\", notify);\n  return () => media.removeEventListener(\"change\", notify);\n};\nexport const useInteractionReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribe,\n    () => window.matchMedia(query).matches,\n    () => false,\n  );\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) =>\n      setVisible(entry.isIntersecting),\n    );\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility();\n    document.addEventListener(\"visibilitychange\", visibility);\n    return () => {\n      observer.disconnect();\n      document.removeEventListener(\"visibilitychange\", visibility);\n    };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(\n  on: boolean,\n  reduced: boolean,\n): React.CSSProperties {\n  return {\n    opacity: on ? 1 : 0,\n    transform: on ? \"none\" : \"scale(0.6)\",\n    filter: on ? \"blur(0px)\" : \"blur(3px)\",\n    transition: reduced\n      ? \"none\"\n      : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}`,\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(\n  samples: PointerSample[],\n  x: number,\n  time: number,\n) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100)\n    return 0;\n  const first = samples[0],\n    last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(\n  overshoot: number,\n  dimension = 320,\n  constant = 0.55,\n): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(\n  distance: number,\n  velocity: number,\n  time = 0.12,\n): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(\n  velocity: number,\n  distanceToTarget: number,\n  factor = 10,\n): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient =\n    (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value =\n      to +\n      Math.exp(-damping * omega * t) *\n        (displacement * Math.cos(damped * t) +\n          coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/text-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * TEXT MORPH: text that changes the way it should\n *\n *   shared   letters both texts share stay alive and slide to\n *            their new place (\"Save\" → \"Saving\" keeps \"Sav\")\n *   new      letters that weren't there rise in out of a blur,\n *            one after another\n *   gone     letters that leave lift away and blur out where\n *            they stood\n *   width    the box eases to its new width, so a button or\n *            pill holding it resizes with it\n *\n * Texts with little in common crossfade as a whole instead of\n * flinging single letters across. The real text is always\n * there for screen readers.\n * ───────────────────────────────────────────────────────── */\n\nexport interface TextMorphProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  children: string;\n  /** Morph time in ms. */\n  duration?: number;\n  /** Where new letters come from: below (\"up\") or above (\"down\"). */\n  direction?: \"up\" | \"down\";\n  /** Ease the box's width too; turn off for text that wraps. */\n  animateWidth?: boolean;\n}\n\ntype Glyph = { key: number; char: string };\ntype Leaving = Glyph & { x: number; y: number };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Keep the letters two texts share (longest common subsequence); everything else is new. */\nfunction morph(\n  previous: Glyph[],\n  text: string,\n  nextKey: () => number,\n): Glyph[] {\n  const a = previous.map((g) => g.char);\n  const b = Array.from(text);\n  const fresh = () => b.map((char) => ({ key: nextKey(), char }));\n  if (!a.length || !b.length) return fresh();\n\n  const dp = Array.from(\n    { length: a.length + 1 },\n    () => new Uint16Array(b.length + 1),\n  );\n  for (let i = a.length - 1; i >= 0; i--)\n    for (let j = b.length - 1; j >= 0; j--)\n      dp[i][j] =\n        a[i] === b[j]\n          ? dp[i + 1][j + 1] + 1\n          : Math.max(dp[i + 1][j], dp[i][j + 1]);\n\n  // Too little in common reads as two different words: crossfade them instead.\n  if (dp[0][0] < Math.min(a.length, b.length) * 0.5) return fresh();\n\n  const out: Glyph[] = [];\n  let i = 0;\n  let j = 0;\n  while (j < b.length) {\n    if (i < a.length && a[i] === b[j]) {\n      out.push(previous[i++]);\n      j++;\n    } else if (i < a.length && dp[i + 1][j] >= dp[i][j + 1]) i++;\n    else out.push({ key: nextKey(), char: b[j++] });\n  }\n  return out;\n}\n\nfunction LeavingGlyph({\n  glyph,\n  lift,\n  duration,\n  onDone,\n}: {\n  glyph: Leaving;\n  lift: number;\n  duration: number;\n  onDone: (key: number) => void;\n}) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const animation = el.animate(\n      [\n        { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n        { opacity: 0, filter: \"blur(4px)\", transform: `translateY(${lift}em)` },\n      ],\n      { duration: duration * 0.6, easing: EASE, fill: \"forwards\" },\n    );\n    animation.onfinish = () => onDone(glyph.key);\n    return () => animation.cancel();\n  }, [glyph.key, lift, duration, onDone]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden=\"true\"\n      className=\"pointer-events-none absolute whitespace-pre\"\n      style={{ left: glyph.x, top: glyph.y }}\n    >\n      {glyph.char}\n    </span>\n  );\n}\n\nexport function TextMorph({\n  children: text,\n  duration = 460,\n  direction = \"up\",\n  animateWidth = true,\n  className = \"\",\n  ...props\n}: TextMorphProps) {\n  const reduced = useReducedMotion();\n  const counter = React.useRef(text.length);\n  const nextKey = React.useCallback(() => ++counter.current, []);\n  const [glyphs, setGlyphs] = React.useState<Glyph[]>(() =>\n    Array.from(text).map((char, i) => ({ key: i + 1, char })),\n  );\n  const [leaving, setLeaving] = React.useState<Leaving[]>([]);\n  const rootRef = React.useRef<HTMLSpanElement>(null);\n  const els = React.useRef(new Map<number, HTMLSpanElement>());\n  const before = React.useRef<{\n    at: Map<number, { x: number; y: number }>;\n    width: number;\n  } | null>(null);\n  const rise = direction === \"up\" ? 0.35 : -0.35;\n\n  // A preference change must also finish an in-flight morph whose target text\n  // already matches the glyphs (including the empty label in a folded receipt).\n  React.useLayoutEffect(() => {\n    if (!reduced) return;\n    before.current = null;\n    const root = rootRef.current;\n    root\n      ?.getAnimations({ subtree: true })\n      .forEach((animation) => animation.cancel());\n    if (root) root.style.whiteSpace = \"\";\n    setLeaving((previous) => (previous.length ? [] : previous));\n  }, [reduced]);\n\n  // 1. The text changed: note where every letter stands, then work out which letters stay.\n  React.useLayoutEffect(() => {\n    if (text === glyphs.map((g) => g.char).join(\"\")) return;\n    const root = rootRef.current;\n    if (!root || reduced) {\n      setLeaving([]);\n      setGlyphs(Array.from(text).map((char) => ({ key: nextKey(), char })));\n      return;\n    }\n    const box = root.getBoundingClientRect();\n    const at = new Map<number, { x: number; y: number }>();\n    els.current.forEach((el, key) => {\n      const r = el.getBoundingClientRect();\n      at.set(key, { x: r.left - box.left, y: r.top - box.top });\n    });\n    before.current = { at, width: box.width };\n    const next = morph(glyphs, text, nextKey);\n    const kept = new Set(next.map((g) => g.key));\n    setLeaving((l) => [\n      ...l,\n      ...glyphs\n        .filter((g) => !kept.has(g.key))\n        .map((g) => ({ ...g, ...(at.get(g.key) ?? { x: 0, y: 0 }) })),\n    ]);\n    setGlyphs(next);\n  }, [text, reduced]);\n\n  // 2. The new letters are in place: glide the ones that stayed, raise the new ones, ease the width.\n  React.useLayoutEffect(() => {\n    const prev = before.current;\n    const root = rootRef.current;\n    if (!prev || !root) return;\n    before.current = null;\n    const box = root.getBoundingClientRect();\n    let order = 0;\n    for (const g of glyphs) {\n      const el = els.current.get(g.key);\n      if (!el) continue;\n      const from = prev.at.get(g.key);\n      if (from) {\n        const r = el.getBoundingClientRect();\n        const dx = from.x - (r.left - box.left);\n        const dy = from.y - (r.top - box.top);\n        if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5)\n          el.animate(\n            [\n              { transform: `translate(${dx}px, ${dy}px)` },\n              { transform: \"none\" },\n            ],\n            { duration, easing: EASE },\n          );\n      } else {\n        el.animate(\n          [\n            {\n              opacity: 0,\n              filter: \"blur(4px)\",\n              transform: `translateY(${rise}em)`,\n            },\n            { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n          ],\n          {\n            duration,\n            easing: EASE,\n            delay: Math.min(order++ * 16, 160),\n            fill: \"backwards\",\n          },\n        );\n      }\n    }\n    if (animateWidth && Math.abs(prev.width - box.width) > 0.5) {\n      // Hold the words on one line while the box is narrower than them, or \"No credits left\" would wrap mid-morph.\n      root.style.whiteSpace = \"nowrap\";\n      const resize = root.animate(\n        [{ width: `${prev.width}px` }, { width: `${box.width}px` }],\n        { duration, easing: EASE },\n      );\n      resize.onfinish = resize.oncancel = () => {\n        root.style.whiteSpace = \"\";\n      };\n    }\n  }, [glyphs, duration, rise, animateWidth]);\n\n  const done = React.useCallback(\n    (key: number) => setLeaving((l) => l.filter((g) => g.key !== key)),\n    [],\n  );\n\n  // Words stay unbroken; lines may only wrap at spaces.\n  const words: Glyph[][] = [];\n  for (const g of glyphs) {\n    if (\n      g.char === \" \" ||\n      !words.length ||\n      words[words.length - 1][0]?.char === \" \"\n    )\n      words.push([g]);\n    else words[words.length - 1].push(g);\n  }\n\n  return (\n    <span\n      ref={rootRef}\n      className={`relative inline-block ${className}`}\n      {...props}\n    >\n      <span className=\"sr-only\">{text}</span>\n      {words.map((word, w) => (\n        <span\n          key={w}\n          aria-hidden=\"true\"\n          className=\"inline-block whitespace-pre\"\n        >\n          {word.map((g) => (\n            <span\n              key={g.key}\n              ref={(el) => {\n                if (el) els.current.set(g.key, el);\n                else els.current.delete(g.key);\n              }}\n              className=\"inline-block\"\n            >\n              {g.char}\n            </span>\n          ))}\n        </span>\n      ))}\n      {leaving.map((g) => (\n        <LeavingGlyph\n          key={`out-${g.key}`}\n          glyph={g}\n          lift={-rise}\n          duration={duration}\n          onDone={done}\n        />\n      ))}\n    </span>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {},
  "meta": {
    "cavemio": {
      "component": "collapsible",
      "exportName": "Collapsible",
      "categories": [
        "display"
      ],
      "isNew": true,
      "usage": "import { Collapsible } from \"@/components/collapsible\";\n\n<Collapsible labels={{ closed: \"Show 4 more\", open: \"Show less\" }}>\n  {rest.map((row) => <Row key={row.id} {...row} />)}\n</Collapsible>",
      "accessibility": "- Installs accordion for the shared fold and chevron.\n- Reduced motion: opens in place.",
      "previewNote": "Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.",
      "documentation": {
        "props": [
          {
            "name": "children",
            "type": "ReactNode",
            "description": "– · The hidden part."
          },
          {
            "name": "labels",
            "type": "{ closed, open }",
            "description": "{ \"Show more\", \"Show less\" } · Button words."
          },
          {
            "name": "open / defaultOpen / onOpenChange",
            "type": "boolean / (open) => void",
            "description": "– · State."
          },
          {
            "name": "placement",
            "type": "\"top\" | \"bottom\"",
            "description": "\"bottom\" · Button above or below."
          }
        ],
        "useCases": [
          {
            "title": "Long lists",
            "description": "The first five, then \"Show 12 more\"."
          },
          {
            "title": "Descriptions",
            "description": "A clamp that opens to the full text."
          },
          {
            "title": "Advanced settings",
            "description": "Rarely used fields folded away."
          },
          {
            "title": "Changelogs",
            "description": "Older entries under one button."
          }
        ],
        "features": [
          {
            "title": "Morphing label",
            "description": "TextMorph between your closed and open words."
          },
          {
            "title": "Same fold as the accordion",
            "description": "Height by grid rows, content through a blur."
          },
          {
            "title": "Either side",
            "description": "placement=\"top\" or \"bottom\"."
          },
          {
            "title": "Accessible",
            "description": "aria-expanded, aria-controls, folded content inert."
          }
        ],
        "states": [
          {
            "title": "open",
            "description": "Height eases (420ms); the label morphs; the chevron turns."
          },
          {
            "title": "close",
            "description": "The reverse."
          }
        ]
      }
    }
  },
  "type": "registry:component"
}