{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"morphing-icons","type":"registry:ui","title":"Morphing Icons","description":"Icons that morph into their next state.","dependencies":["motion"],"registryDependencies":["@kobra/copy-check"],"docs":"Sound: the data-slot attributes on this component are read by the Sound layer, installed separately with `npx shadcn@latest add @kobra/sound`.\nKeep the data-slot and data-sound attributes as written — they are the wiring, not decoration.\nWrap your app once in <SoundEffects> from components/ui/sound.tsx and every Kobra component answers a press.","files":[{"path":"components/ui/morphing-icons.tsx","content":"'use client'\n\nimport { useEffect, useId, useRef, useState, type ComponentProps, type ReactNode } from 'react'\nimport {\n  animate,\n  motion,\n  useMotionValue,\n  useMotionValueEvent,\n  useReducedMotion,\n  useTime,\n  useTransform,\n  type MotionValue,\n  type Transition,\n} from 'motion/react'\n\nimport { CopyCheck } from '@/components/ui/copy-check'\nimport { cn } from '@/lib/utils'\n\nconst MORPH: Transition = { type: 'spring', duration: 0.5, bounce: 0 }\n\nconst STAGED: Transition = { duration: 0.62, ease: [0.65, 0, 0.35, 1] }\nconst BLINK: Transition = { type: 'spring', duration: 0.45, bounce: 0 }\nconst DUSK: Transition = { type: 'spring', duration: 0.6, bounce: 0 }\nconst LISTEN: Transition = { duration: 0.75, ease: [0.65, 0, 0.35, 1] }\n\nfunction useMorph(target: number, transition: Transition = MORPH, delay = 0) {\n  const value = useMotionValue(target)\n  const still = useReducedMotion()\n  useEffect(() => {\n    if (value.get() === target && !value.isAnimating()) return\n    const controls = animate(value, target, still ? { duration: 0 } : { ...transition, delay })\n    return () => controls.stop()\n  }, [value, target, still, transition, delay])\n  return value\n}\n\ntype Pt = readonly [number, number]\n\nconst clamp01 = (v: number) => Math.min(1, Math.max(0, v))\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t\nconst smooth = (x: number) => x * x * (3 - 2 * x)\nconst stage = (t: number, from: number, to: number) => smooth(clamp01((t - from) / (to - from)))\n\nconst visible = (length: number) => clamp01(length * 6)\n\nconst lerpPts = (a: readonly Pt[], b: readonly Pt[], t: number): Pt[] =>\n  a.map((p, i) => [lerp(p[0], b[i]![0], t), lerp(p[1], b[i]![1], t)] as const)\n\nconst n = (v: number) => Math.round(v * 1000) / 1000\nconst pt = (p: Pt) => `${n(p[0])} ${n(p[1])}`\nconst line = (a: Pt, b: Pt) => `M${pt(a)}L${pt(b)}`\nconst polyline = (pts: readonly Pt[]) => pts.map((p, i) => `${i ? 'L' : 'M'}${pt(p)}`).join('')\nconst cubic2 = (p: readonly Pt[]) =>\n  `M${pt(p[0]!)}C${pt(p[1]!)} ${pt(p[2]!)} ${pt(p[3]!)}C${pt(p[4]!)} ${pt(p[5]!)} ${pt(p[6]!)}`\n\nfunction roundedPolygon(pts: readonly Pt[], radius: number) {\n  const count = pts.length\n  const corners = pts.map((p, i) => {\n    const prev = pts[(i - 1 + count) % count]!\n    const next = pts[(i + 1) % count]!\n    const d1 = Math.hypot(prev[0] - p[0], prev[1] - p[1])\n    const d2 = Math.hypot(next[0] - p[0], next[1] - p[1])\n    const r = Math.min(radius, d1 / 2, d2 / 2)\n    const toward = (q: Pt, d: number): Pt =>\n      d < 1e-6 ? p : [p[0] + ((q[0] - p[0]) * r) / d, p[1] + ((q[1] - p[1]) * r) / d]\n    return { into: toward(prev, d1), at: p, out: toward(next, d2) }\n  })\n  let d = `M${pt(corners[0]!.out)}`\n  for (let i = 1; i <= count; i++) {\n    const c = corners[i % count]!\n    d += `L${pt(c.into)}Q${pt(c.at)} ${pt(c.out)}`\n  }\n  return `${d}Z`\n}\n\ntype MorphingIconProps = Omit<ComponentProps<'svg'>, 'children'> & {\n  size?: number\n  strokeWidth?: number\n}\n\nfunction Glyph({\n  size = 24,\n  strokeWidth = 1.5,\n  className,\n  children,\n  ...props\n}: MorphingIconProps & { children: ReactNode }) {\n  return (\n    <svg\n      data-slot=\"morphing-icon\"\n      viewBox=\"0 0 24 24\"\n      width={size}\n      height={size}\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={strokeWidth}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden\n      className={cn('shrink-0', className)}\n      {...props}\n    >\n      {children}\n    </svg>\n  )\n}\n\nfunction CopyIcon({\n  copied = false,\n  size = 24,\n  strokeWidth = 1.5,\n  className,\n}: {\n  copied?: boolean\n  size?: number\n  strokeWidth?: number\n  className?: string\n}) {\n  return <CopyCheck copied={copied} size={size} strokeWidth={strokeWidth} className={className} />\n}\n\nconst PLAY: Pt[] = [\n  [5.5, 4.6],\n  [19, 11.2],\n  [19, 12.8],\n  [5.5, 19.4],\n]\nconst BAR_START: Pt[] = [\n  [5, 4],\n  [10, 4],\n  [10, 20],\n  [5, 20],\n]\nconst BAR_END: Pt[] = [\n  [14, 4],\n  [19, 4],\n  [19, 20],\n  [14, 20],\n]\n\nfunction Interior({\n  id,\n  d,\n  strokeWidth,\n}: {\n  id: string\n  d: MotionValue<string>\n  strokeWidth: number\n}) {\n  return (\n    <mask id={id} maskUnits=\"userSpaceOnUse\" x=\"-2\" y=\"-2\" width=\"28\" height=\"28\">\n      <rect x=\"-2\" y=\"-2\" width=\"28\" height=\"28\" fill=\"#fff\" />\n      <motion.path d={d} fill=\"#000\" stroke=\"#fff\" strokeWidth={strokeWidth} />\n    </mask>\n  )\n}\n\nfunction PlayPauseIcon({\n  playing = false,\n  strokeWidth = 1.5,\n  ...props\n}: MorphingIconProps & { playing?: boolean }) {\n  const t = useMorph(playing ? 1 : 0)\n  const id = useId()\n  const first = useTransform(t, (v) => roundedPolygon(lerpPts(PLAY, BAR_START, v), 2.4))\n  const second = useTransform(t, (v) => roundedPolygon(lerpPts(PLAY, BAR_END, v), 2.4))\n\n  const secondOpacity = useTransform(t, (v) => clamp01(v * 25))\n  return (\n    <Glyph strokeWidth={strokeWidth} {...props}>\n      <defs>\n        <Interior id={`${id}-a`} d={second} strokeWidth={strokeWidth} />\n        <Interior id={`${id}-b`} d={first} strokeWidth={strokeWidth} />\n      </defs>\n      <motion.path d={first} mask={`url(#${id}-a)`} />\n      <motion.path d={second} opacity={secondOpacity} mask={`url(#${id}-b)`} />\n    </Glyph>\n  )\n}\n\nfunction bar(v: number, from: number, turn: 1 | -1) {\n  const travel = stage(v, 0, 0.6)\n  const rotate = stage(v, 0.3, 1)\n  const cy = lerp(from, 12, travel)\n  const angle = (turn * Math.PI * rotate) / 4\n  const half = lerp(8, 8.485, rotate)\n  const dx = half * Math.cos(angle)\n  const dy = half * Math.sin(angle)\n  return line([12 - dx, cy - dy], [12 + dx, cy + dy])\n}\n\nfunction MenuIcon({ open = false, ...props }: MorphingIconProps & { open?: boolean }) {\n  const t = useMorph(open ? 1 : 0)\n  const top = useTransform(t, (v) => bar(v, 5, 1))\n  const bottom = useTransform(t, (v) => bar(v, 19, -1))\n  const middle = useTransform(t, (v) => {\n    const half = lerp(8, 0, stage(v, 0, 0.4))\n    return line([12 - half, 12], [12 + half, 12])\n  })\n  const middleOpacity = useTransform(t, (v) => 1 - stage(v, 0.05, 0.3))\n  return (\n    <Glyph {...props}>\n      <motion.path d={top} />\n      <motion.path d={middle} opacity={middleOpacity} />\n      <motion.path d={bottom} />\n    </Glyph>\n  )\n}\n\nfunction Ray({ t, k }: { t: MotionValue<number>; k: number }) {\n  const from = k * 0.05\n  const d = useTransform(t, (v) => {\n    const a = ((-90 + k * 45 + v * 30) * Math.PI) / 180\n    const reach = lerp(10, 8.5, stage(v, from, from + 0.4))\n    return line(\n      [12 + 8.5 * Math.cos(a), 12 + 8.5 * Math.sin(a)],\n      [12 + reach * Math.cos(a), 12 + reach * Math.sin(a)],\n    )\n  })\n  const opacity = useTransform(t, (v) => 1 - stage(v, from, from + 0.25))\n  return <motion.path d={d} opacity={opacity} />\n}\n\nconst CUTTER = 8.2\n\nfunction ThemeIcon({\n  dark = false,\n  strokeWidth = 1.5,\n  ...props\n}: MorphingIconProps & { dark?: boolean }) {\n  const t = useMorph(dark ? 1 : 0, DUSK)\n  const id = useId()\n  const body = useTransform(t, (v) => lerp(4.5, 9, v))\n  const bodyClip = useTransform(body, (r) => r + strokeWidth / 2)\n  const cutX = useTransform(t, (v) => lerp(26, 17.5, v))\n  const cutY = useTransform(t, (v) => lerp(-2, 6.5, v))\n  return (\n    <Glyph strokeWidth={strokeWidth} {...props}>\n\n      <defs>\n        <mask id={`${id}-cut`} maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"24\" height=\"24\">\n          <rect width=\"24\" height=\"24\" fill=\"#fff\" />\n          <motion.circle\n            cx={cutX}\n            cy={cutY}\n            r={CUTTER - strokeWidth / 2}\n            fill=\"#000\"\n            stroke=\"none\"\n          />\n        </mask>\n        <clipPath id={`${id}-body`}>\n          <motion.circle cx={12} cy={12} r={bodyClip} />\n        </clipPath>\n      </defs>\n      <motion.circle cx={12} cy={12} r={body} mask={`url(#${id}-cut)`} />\n      <motion.circle cx={cutX} cy={cutY} r={CUTTER} clipPath={`url(#${id}-body)`} />\n      {Array.from({ length: 8 }, (_, k) => (\n        <Ray key={k} t={t} k={k} />\n      ))}\n    </Glyph>\n  )\n}\n\nconst LID_UPPER: Pt[] = [\n  [2, 12],\n  [3.8, 9.2],\n  [7.5, 5],\n  [12, 5],\n  [16.5, 5],\n  [20.2, 9.2],\n  [22, 12],\n]\nconst LID_LOWER: Pt[] = [\n  [2, 12],\n  [3.8, 14.8],\n  [7.5, 19],\n  [12, 19],\n  [16.5, 19],\n  [20.2, 14.8],\n  [22, 12],\n]\nconst LID_SHUT: Pt[] = [\n  [2, 8.5],\n  [2, 8.5],\n  [6, 14.5],\n  [12, 14.5],\n  [18, 14.5],\n  [22, 8.5],\n  [22, 8.5],\n]\nconst LASHES: Array<[Pt, Pt]> = [\n  [\n    [9, 14],\n    [7.5, 16.5],\n  ],\n  [\n    [15, 14],\n    [16.5, 16.5],\n  ],\n  [\n    [4, 11.5],\n    [2, 13.5],\n  ],\n  [\n    [20, 11.5],\n    [22, 13.5],\n  ],\n]\n\nfunction Lash({ t, k }: { t: MotionValue<number>; k: number }) {\n  const [a, b] = LASHES[k]!\n  const from = 0.6 + (k >> 1) * 0.08\n  const length = useTransform(t, (v) => stage(v, from, from + 0.3))\n  const opacity = useTransform(length, visible)\n  return <motion.path d={line(a, b)} pathLength={length} opacity={opacity} />\n}\n\nfunction EyeIcon({ closed = false, ...props }: MorphingIconProps & { closed?: boolean }) {\n  const t = useMorph(closed ? 1 : 0, BLINK)\n  const id = useId()\n  const shut = useTransform(t, (v) => stage(v, 0, 0.7))\n  const upper = useTransform(shut, (p) => cubic2(lerpPts(LID_UPPER, LID_SHUT, p)))\n  const lower = useTransform(shut, (p) => cubic2(lerpPts(LID_LOWER, LID_SHUT, p)))\n\n  const opening = useTransform(shut, (p) => {\n    const u = lerpPts(LID_UPPER, LID_SHUT, p)\n    const l = lerpPts(LID_LOWER, LID_SHUT, p)\n    return `${cubic2(u)}C${pt(l[5]!)} ${pt(l[4]!)} ${pt(l[3]!)}C${pt(l[2]!)} ${pt(l[1]!)} ${pt(l[0]!)}Z`\n  })\n\n  const lowerOpacity = useTransform(t, (v) => 1 - stage(v, 0.6, 0.7))\n  const pupilY = useTransform(shut, (p) => lerp(12, 13.5, p))\n  const pupilR = useTransform(shut, (p) => lerp(3, 2.2, p))\n  return (\n    <Glyph {...props}>\n      <defs>\n        <clipPath id={`${id}-open`}>\n          <motion.path d={opening} />\n        </clipPath>\n      </defs>\n      <motion.circle cx={12} cy={pupilY} r={pupilR} clipPath={`url(#${id}-open)`} />\n      <motion.path d={upper} />\n      <motion.path d={lower} opacity={lowerOpacity} />\n      {LASHES.map((_, k) => (\n        <Lash key={k} t={t} k={k} />\n      ))}\n    </Glyph>\n  )\n}\n\nconst SHACKLE_LEG = 5.5\nconst SHACKLE_LENGTH = SHACKLE_LEG * 2 + Math.PI * 4\n\nconst SHACKLE_OPEN = (SHACKLE_LENGTH - SHACKLE_LEG + 1.2) / SHACKLE_LENGTH\n\nconst SIDE: readonly { from: Pt; to: Pt }[] = [\n  { from: [6, 9], to: [2.9, 6.6] },\n  { from: [7, 8.1], to: [5.6, 4.2] },\n]\nconst mirror = ([x, y]: Pt): Pt => [24 - x, y]\n\nconst SPARKS = SIDE.flatMap((spark) => [spark, { from: mirror(spark.from), to: mirror(spark.to) }])\nconst SPARK: Transition = {\n  duration: 0.45,\n  ease: [0.23, 1, 0.32, 1],\n\n  opacity: { duration: 0.45, times: [0, 0.45, 1], ease: 'easeOut' },\n}\n\nfunction LockIcon({ unlocked = false, ...props }: MorphingIconProps & { unlocked?: boolean }) {\n  const t = useMorph(unlocked ? 1 : 0)\n  const id = useId()\n  const still = useReducedMotion()\n\n  const armed = useRef(false)\n  const [burst, setBurst] = useState(0)\n  useEffect(() => {\n    armed.current = !unlocked && !still\n  }, [unlocked, still])\n  useMotionValueEvent(t, 'change', (v) => {\n\n    if (!armed.current || v > 0.35) return\n    armed.current = false\n    setBurst((count) => count + 1)\n  })\n  const shackle = useTransform(t, (v) => {\n    const dy = -2 * stage(v, 0, 0.7)\n    return `M8 ${13 + dy}V${7.5 + dy}A4 4 0 0 1 16 ${7.5 + dy}V${13 + dy}`\n  })\n  const length = useTransform(t, (v) => lerp(1, SHACKLE_OPEN, stage(v, 0.2, 1)))\n  return (\n    <Glyph {...props}>\n\n      <defs>\n        <mask id={`${id}-body`} maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"24\" height=\"24\">\n          <rect width=\"24\" height=\"24\" fill=\"#fff\" />\n          <rect x=\"4.5\" y=\"10\" width=\"15\" height=\"11.5\" rx=\"4\" fill=\"#000\" stroke=\"none\" />\n        </mask>\n      </defs>\n      <g mask={`url(#${id}-body)`}>\n        <motion.path d={shackle} pathLength={length} />\n      </g>\n      <rect x=\"4.5\" y=\"10\" width=\"15\" height=\"11.5\" rx=\"4\" />\n      <path d=\"M12 14.75V16.75\" />\n      {burst > 0 && (\n        <g key={burst} fill=\"currentColor\" stroke=\"none\">\n          {SPARKS.map((spark, k) => (\n            <motion.circle\n              key={k}\n              initial={{ cx: spark.from[0], cy: spark.from[1], r: 1.35, opacity: 1 }}\n              animate={{ cx: spark.to[0], cy: spark.to[1], r: 0.7, opacity: [1, 1, 0] }}\n              transition={SPARK}\n            />\n          ))}\n        </g>\n      )}\n    </Glyph>\n  )\n}\n\nconst SPEAKER =\n  'M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z'\nconst WAVE_INNER = 'M16 9a5 5 0 0 1 0 6'\nconst WAVE_OUTER = 'M19.364 18.364a9 9 0 0 0 0-12.728'\nconst SLASH = 'M2 2 22 22'\n\nfunction VolumeIcon({ muted = false, ...props }: MorphingIconProps & { muted?: boolean }) {\n  const id = useId()\n  return (\n    <Glyph data-muted={muted} {...props}>\n\n      <mask id={`${id}-slash`}>\n        <rect width=\"24\" height=\"24\" fill=\"white\" />\n        <path className=\"sound-slash\" d={SLASH} pathLength={1} stroke=\"black\" strokeWidth={4} />\n      </mask>\n      <g mask={`url(#${id}-slash)`}>\n        <path className=\"sound-speaker\" d={SPEAKER} />\n        <path className=\"sound-wave sound-wave-inner\" d={WAVE_INNER} />\n        <path className=\"sound-wave sound-wave-outer\" d={WAVE_OUTER} />\n      </g>\n      <path className=\"sound-slash\" d={SLASH} pathLength={1} />\n    </Glyph>\n  )\n}\n\nconst ARROWHEAD: Pt[] = [\n  [7.5, 11],\n  [12, 15.5],\n  [16.5, 11],\n]\nconst TICK: Pt[] = [\n  [7, 10.5],\n  [10.5, 14],\n  [17, 7.5],\n]\nconst TRAY = 'M3 16.5V17a4 4 0 0 0 4 4h10a4 4 0 0 0 4-4v-.5'\n\nfunction DownloadIcon({ done = false, ...props }: MorphingIconProps & { done?: boolean }) {\n  const t = useMorph(done ? 1 : 0, STAGED)\n  const bend = useTransform(t, (v) => stage(v, 0.3, 1))\n  const head = useTransform(bend, (p) => polyline(lerpPts(ARROWHEAD, TICK, p)))\n  const shaft = useTransform([t, bend], ([v, p]: number[]) => {\n    const [x, y] = lerpPts(ARROWHEAD, TICK, p!)[1]!\n    return line([x, lerp(3, y, stage(v!, 0, 0.6))], [x, y])\n  })\n  const shaftOpacity = useTransform(t, (v) => 1 - stage(v, 0.45, 0.6))\n  return (\n    <Glyph {...props}>\n      <path d={TRAY} />\n      <motion.path d={shaft} opacity={shaftOpacity} />\n      <motion.path d={head} />\n    </Glyph>\n  )\n}\n\nconst TILE = 7\nconst TILE_RADIUS = 2.2\n\nfunction LayoutRow({ rows, y, delay }: { rows: boolean; y: number; delay: number }) {\n  const t = useMorph(rows ? 1 : 0, MORPH, delay)\n  const width = useTransform(t, (v) => lerp(TILE, 18, v))\n\n  const fold = useTransform(t, (v) => stage(v, 0, 0.6))\n  const partnerX = useTransform(fold, (f) => lerp(14, 20.5, f))\n  const partnerWidth = useTransform(fold, (f) => lerp(TILE, 0.5, f))\n  const partnerRadius = useTransform(partnerWidth, (w) => Math.min(TILE_RADIUS, w / 2))\n  const partnerOpacity = useTransform(t, (v) => 1 - stage(v, 0.2, 0.55))\n  return (\n    <>\n      <motion.rect x={3} y={y} width={width} height={TILE} rx={TILE_RADIUS} />\n      <motion.rect\n        x={partnerX}\n        y={y}\n        width={partnerWidth}\n        height={TILE}\n        rx={partnerRadius}\n        opacity={partnerOpacity}\n      />\n    </>\n  )\n}\n\nfunction LayoutIcon({ rows = false, ...props }: MorphingIconProps & { rows?: boolean }) {\n  return (\n    <Glyph {...props}>\n      <LayoutRow rows={rows} y={3} delay={0} />\n      <LayoutRow rows={rows} y={14} delay={0.05} />\n    </Glyph>\n  )\n}\n\nconst ALIGN_LINES = [\n  { y: 4, width: 18 },\n  { y: 9.33, width: 12 },\n  { y: 14.67, width: 16 },\n  { y: 20, width: 9 },\n]\nconst ALIGN_STOPS = { left: 0, center: 1, right: 2 } as const\n\nfunction AlignLine({\n  at,\n  y,\n  width,\n  delay,\n}: {\n  at: number\n  y: number\n  width: number\n  delay: number\n}) {\n  const t = useMorph(at, MORPH, delay)\n\n  const d = useTransform(t, (v) => {\n    const x = 3 + (v / 2) * (18 - width)\n    return line([x, y], [x + width, y])\n  })\n  return <motion.path d={d} />\n}\n\nfunction AlignIcon({\n  align = 'left',\n  ...props\n}: MorphingIconProps & { align?: keyof typeof ALIGN_STOPS }) {\n  return (\n    <Glyph {...props}>\n      {ALIGN_LINES.map(({ y, width }, i) => (\n        <AlignLine key={y} at={ALIGN_STOPS[align]} y={y} width={width} delay={i * 0.04} />\n      ))}\n    </Glyph>\n  )\n}\n\nconst WAVEFORM = [\n  { x: 4, height: 2.5, ring: 2, hz: 1.7, phase: 0.2 },\n  { x: 8, height: 5.5, ring: 1, hz: 1.3, phase: 1.9 },\n  { x: 16, height: 5.5, ring: 1, hz: 1.5, phase: 3.4 },\n  { x: 20, height: 2.5, ring: 2, hz: 1.9, phase: 4.6 },\n]\n\nconst breathe = (v: number, ms: number, hz: number, phase: number, still: boolean) =>\n  still ? 1 : 1 + 0.32 * stage(v, 0.85, 1) * Math.sin((ms / 1000) * Math.PI * 2 * hz + phase)\n\nfunction WaveBar({\n  t,\n  time,\n  still,\n  x,\n  height,\n  ring,\n  hz,\n  phase,\n}: {\n  t: MotionValue<number>\n  time: MotionValue<number>\n  still: boolean\n} & (typeof WAVEFORM)[number]) {\n  const from = 0.45 + (ring - 1) * 0.12\n  const d = useTransform([t, time], ([v, ms]: number[]) => {\n    const half = height * stage(v!, from, from + 0.4) * breathe(v!, ms!, hz, phase, still)\n    return line([x, 12 - half], [x, 12 + half])\n  })\n  const opacity = useTransform(t, (v) => visible(stage(v, from, from + 0.4)))\n  return <motion.path d={d} opacity={opacity} />\n}\n\nfunction MicIcon({ listening = false, ...props }: MorphingIconProps & { listening?: boolean }) {\n  const t = useMorph(listening ? 1 : 0, LISTEN)\n  const time = useTime()\n  const still = useReducedMotion() ?? false\n\n  const capsule = useTransform([t, time], ([v, ms]: number[]) => {\n    const p = stage(v!, 0.1, 0.7)\n    const width = lerp(10, 0.01, p)\n    const height = lerp(14, 16 * breathe(v!, ms!, 1.1, 0, still), p)\n    const cy = lerp(9, 12, p)\n    return { x: 12 - width / 2, y: cy - height / 2, width, height }\n  })\n  const capX = useTransform(capsule, (c) => c.x)\n  const capY = useTransform(capsule, (c) => c.y)\n  const capWidth = useTransform(capsule, (c) => c.width)\n  const capHeight = useTransform(capsule, (c) => c.height)\n  const capRadius = useTransform(capsule, (c) => c.width / 2)\n  const holder = useTransform(t, (v) => 1 - stage(v, 0, 0.45))\n  const holderOffset = useTransform(holder, (l) => (1 - l) / 2)\n  const holderOpacity = useTransform(holder, visible)\n  const stand = useTransform(t, (v) => {\n    const k = 1 - stage(v, 0, 0.35)\n    return `M12 19V${19 + 3 * k}${line([12 - 3 * k, 22], [12 + 3 * k, 22])}`\n  })\n  const standOpacity = useTransform(t, (v) => 1 - stage(v, 0.15, 0.35))\n  return (\n    <Glyph {...props}>\n      <motion.path\n        d=\"M4 11C4 15.418 7.582 19 12 19C16.418 19 20 15.418 20 11\"\n        style={{ pathLength: holder, pathOffset: holderOffset, opacity: holderOpacity }}\n      />\n      <motion.path d={stand} opacity={standOpacity} />\n      <motion.rect x={capX} y={capY} width={capWidth} height={capHeight} rx={capRadius} />\n      {WAVEFORM.map((bar) => (\n        <WaveBar key={bar.x} t={t} time={time} still={still} {...bar} />\n      ))}\n    </Glyph>\n  )\n}\n\nconst BUBBLE = { x: 3, y: 4.5, width: 18, height: 12.5, rx: 4.5 }\n\nconst DOTS = [\n  { cx: 6.5, from: 0.12, phase: 0 },\n  { cx: 12, from: 0.2, phase: 0.9 },\n  { cx: 17.5, from: 0.28, phase: 1.8 },\n] as const\nconst DOT = 2.4\nconst DOT_Y = 11\n\nfunction TypingDot({\n  t,\n  time,\n  still,\n  cx,\n  from,\n  phase,\n}: {\n  t: MotionValue<number>\n  time: MotionValue<number>\n  still: boolean\n} & (typeof DOTS)[number]) {\n  const box = useTransform([t, time], ([v, ms]: number[]) => {\n    const p = stage(v!, from, from + 0.5)\n\n    const hop = still\n      ? 0\n      : -1.5 * stage(v!, 0.82, 1) * Math.max(0, Math.sin((ms! / 1000) * Math.PI * 2.2 - phase))\n    const width = lerp(BUBBLE.width, DOT, p)\n    const height = lerp(BUBBLE.height, DOT, p)\n    const x = lerp(BUBBLE.x, cx - DOT / 2, p)\n    const y = lerp(BUBBLE.y, DOT_Y - DOT / 2, p) + hop\n    return { x, y, width, height, rx: lerp(BUBBLE.rx, DOT / 2, p) }\n  })\n  const x = useTransform(box, (b) => b.x)\n  const y = useTransform(box, (b) => b.y)\n  const width = useTransform(box, (b) => b.width)\n  const height = useTransform(box, (b) => b.height)\n  const rx = useTransform(box, (b) => b.rx)\n\n  const fill = useTransform(t, (v) => stage(v, from + 0.35, from + 0.5))\n  return (\n    <motion.rect\n      x={x}\n      y={y}\n      width={width}\n      height={height}\n      rx={rx}\n      fill=\"currentColor\"\n      style={{ fillOpacity: fill }}\n    />\n  )\n}\n\nfunction MessageIcon({ typing = false, ...props }: MorphingIconProps & { typing?: boolean }) {\n  const t = useMorph(typing ? 1 : 0, LISTEN)\n  const time = useTime()\n  const still = useReducedMotion() ?? false\n  const tail = useTransform(t, (v) => 1 - stage(v, 0, 0.3))\n  const tailOpacity = useTransform(tail, visible)\n  return (\n    <Glyph {...props}>\n\n      <motion.path d=\"M10 17L6.5 20.5V17\" style={{ pathLength: tail, opacity: tailOpacity }} />\n      {DOTS.map((dot) => (\n        <TypingDot key={dot.cx} t={t} time={time} still={still} {...dot} />\n      ))}\n    </Glyph>\n  )\n}\n\nexport {\n  AlignIcon,\n  CopyIcon,\n  DownloadIcon,\n  EyeIcon,\n  LayoutIcon,\n  LockIcon,\n  MenuIcon,\n  MessageIcon,\n  MicIcon,\n  PlayPauseIcon,\n  ThemeIcon,\n  VolumeIcon,\n  type MorphingIconProps,\n}\n","type":"registry:ui","target":"components/ui/morphing-icons.tsx"}],"css":{".sound-slash":{"stroke-dasharray":"1 2","stroke-dashoffset":"1.02","--slash-ms":"200ms","transition":"stroke-dashoffset var(--slash-ms) var(--ease-out)"},"[data-muted='true'] .sound-slash":{"stroke-dashoffset":"0","--slash-ms":"260ms"},".sound-wave":{"transform-box":"view-box","transform-origin":"11px 12px","transition":"opacity 130ms var(--ease-out) var(--wave-delay), transform 130ms var(--ease-out) var(--wave-delay), filter 130ms var(--ease-out) var(--wave-delay)"},"[data-muted='true'] .sound-wave":{"opacity":"0","transform":"scale(0.25)","filter":"blur(1px)"},".sound-wave-inner":{"--wave-delay":"45ms"},".sound-wave-outer":{"--wave-delay":"20ms"},"[data-muted='true'] .sound-wave-inner":{"--wave-delay":"50ms"},"[data-muted='true'] .sound-wave-outer":{"--wave-delay":"75ms"},".sound-speaker":{"--speaker-ms":"220ms","--speaker-delay":"0ms","transition":"transform var(--speaker-ms) var(--ease-out) var(--speaker-delay)"},"[data-muted='true'] .sound-speaker":{"transform":"translateX(5.5px)","--speaker-ms":"260ms","--speaker-delay":"80ms"},"@media (prefers-reduced-motion: reduce)":{".sound-slash, .sound-wave, .sound-speaker":{"transition":"none"}}}}