{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "growth-line",
  "title": "Growth Line",
  "description": "An exponential growth curve draws through milestones to a 100k endpoint.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/growth-line/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/SchibstedGrotesk\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface GrowthMilestone {\n  /**\n   * Position along the curve, 0..1. Omit it when the label is a number (\"10k\"):\n   * the dot then sits where the curve actually crosses that value.\n   */\n  at?: number;\n  label: string;\n}\n\nexport interface GrowthLineProps {\n  /** The number that lands at the tip. */\n  value?: string;\n  /** Muted line under the value. */\n  label?: string;\n  milestones?: GrowthMilestone[];\n  /** How hard the curve bends upward: 2 = gentle, 6 = hockey stick. */\n  steepness?: number;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst DEFAULT_MILESTONES: GrowthMilestone[] = [\n  { at: 0.03, label: \"Launch\" },\n  { label: \"1k\" },\n  { label: \"10k\" },\n];\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    axis: \"rgba(255,255,255,0.16)\",\n    dot: \"rgba(255,255,255,0.07)\",\n    wash: \"rgba(255,122,61,0.07)\",\n    tail: 0.35,\n    fill: 0.26,\n    grain: 0.06,\n    /** gradients.sh \"fluted\" (#1d2a8f #2f7bff #ff7a3d #ffe2c4): cool start, hot tip */\n    line: [\"#3346C8\", \"#2F7BFF\", \"#FF7A3D\", \"#FFE2C4\"],\n    tip: \"#FFB27F\",\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    axis: \"rgba(18,18,20,0.16)\",\n    dot: \"rgba(18,18,20,0.08)\",\n    wash: \"rgba(255,255,255,0.7)\",\n    tail: 0.4,\n    fill: 0.22,\n    grain: 0.045,\n    line: [\"#1D2A8F\", \"#2F7BFF\", \"#FF7A3D\", \"#E2551C\"],\n    tip: \"#FF7A3D\",\n  },\n} as const;\n\n/** Beats, in frames at speed 1. */\nconst DRAW = [-4, 118] as const;\nconst PULL = [84, 128] as const;\nconst HIT = 120;\nconst DRAW_EASE = Easing.bezier(0.3, 0.05, 0.55, 1);\n\nconst drawProgress = (t: number) =>\n  interpolate(t, DRAW, [0, 1], { ...CLAMP, easing: DRAW_EASE });\n\n/** The frame at which the tip reaches `at` (inverts the draw easing). */\nfunction reachFrame(at: number) {\n  for (let fr = DRAW[0]; fr <= DRAW[1]; fr += 0.5) {\n    if (drawProgress(fr) >= at) return fr;\n  }\n  return DRAW[1];\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={11}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\n/** \"100k\" -> 100000, \"1.2M\" -> 1200000, \"10,000\" -> 10000. */\nfunction parseValue(v: string) {\n  const m = v.replace(/,/g, \"\").match(/([\\d.]+)\\s*([kKmMbB]?)/);\n  if (!m) return null;\n  const n = Number.parseFloat(m[1]);\n  if (!Number.isFinite(n)) return null;\n  const mult = { k: 1e3, m: 1e6, b: 1e9 }[m[2].toLowerCase()] ?? 1;\n  return n * mult;\n}\n\nconst lerp = (a: number, b: number, k: number) => a + (b - a) * k;\n\nexport function GrowthLine({\n  value = \"100k\",\n  label = \"creators in the first year\",\n  milestones = DEFAULT_MILESTONES,\n  steepness = 4.6,\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: GrowthLineProps) {\n  const t = useCurrentFrame() * speed;\n  const { width, height, fps } = useVideoConfig();\n  const u = height / 720;\n  const p = THEMES[theme];\n  const id = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  // World: the full curve as it sits in the final, pulled-back frame.\n  const L = width * 0.1;\n  const Rr = width * 0.84;\n  const B = height * 0.84;\n  const T = height * 0.2;\n  const k = steepness;\n  const base = (x: number) => (Math.exp(k * x) - 1) / (Math.exp(k) - 1);\n  const f = (x: number) => {\n    // a little organic texture that calms down as the curve takes off\n    const wob =\n      0.008 * Math.sin(x * 31 + 1.3) * Math.sin(x * 7.3 + 0.4) * (1 - x) +\n      0.004 * Math.sin(x * 67 + 2.1) * (1 - x);\n    return Math.max(0, base(x) + wob * Math.min(1, x * 6));\n  };\n  const world = (x: number): [number, number] => [\n    lerp(L, Rr, x),\n    lerp(B, T, f(x)),\n  ];\n\n  // Tip progress\n  const prog = drawProgress(t);\n  const [tipWx, tipWy] = world(prog);\n\n  // Camera: tracks the tip close-up, then pulls back to the whole curve.\n  const pull = interpolate(t, PULL, [0, 1], { ...CLAMP, easing: EASE_IO });\n  const zTrack = interpolate(t, [0, PULL[0]], [2.9, 2.2], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const kick =\n    1 +\n    0.014 *\n      interpolate(t, [HIT, HIT + 4, HIT + 22], [0, 1, 0], {\n        ...CLAMP,\n        easing: EASE_OUT,\n      });\n  const z = lerp(zTrack, 1, pull) * kick;\n  // the tip rides low-left of centre early on, drifting up as the curve steepens\n  const anchorX = width * lerp(0.56, 0.6, prog);\n  const anchorY = height * lerp(0.6, 0.66, prog);\n  const cx = lerp(tipWx, width / 2, pull);\n  const cy = lerp(tipWy, height / 2, pull);\n  const ax = lerp(anchorX, width / 2, pull);\n  const ay = lerp(anchorY, height / 2, pull);\n  const proj = (wx: number, wy: number): [number, number] => [\n    (wx - cx) * z + ax,\n    (wy - cy) * z + ay,\n  ];\n\n  // Curve path, screen space\n  const N = 220;\n  const pts: Array<[number, number]> = [];\n  const steps = Math.max(2, Math.ceil(N * prog));\n  for (let i = 0; i <= steps; i++) {\n    const [wx, wy] = world((prog * i) / steps);\n    pts.push(proj(wx, wy));\n  }\n  const d = pts\n    .map(([x, y], i) => `${i ? \"L\" : \"M\"}${x.toFixed(2)} ${y.toFixed(2)}`)\n    .join(\" \");\n  const [sx0, sy0] = proj(L, B);\n  const [sxr] = proj(Rr, B);\n  const [tipX, tipY] = proj(tipWx, tipWy);\n  const fillD = `${d} L${tipX.toFixed(2)} ${sy0.toFixed(2)} L${pts[0][0].toFixed(2)} ${sy0.toFixed(2)} Z`;\n  const [, syTop] = proj(L, T);\n\n  // Parallax dot grid behind the line (moves at a fraction of the camera)\n  const zp = 1 + (z - 1) * 0.45;\n  const gap = 44 * u * zp;\n  const gx = (((ax - cx * zp) % gap) + gap) % gap;\n  const gy = (((ay - cy * zp) % gap) + gap) % gap;\n\n  const enter = interpolate(t, [0, 10], [0.55, 1], CLAMP);\n\n  // A running count rides just ahead of the tip and hands off to the value.\n  const target = parseValue(value);\n  const marks = milestones.flatMap((m) => {\n    if (m.at !== undefined) return [{ at: m.at, label: m.label }];\n    const v = parseValue(m.label);\n    if (v === null || target === null || v <= 0 || v >= target) return [];\n    // invert the base curve: x where f(x) = v / target\n    const at = Math.log(1 + (v / target) * (Math.exp(k) - 1)) / k;\n    return [{ at, label: m.label }];\n  });\n  const count = target === null ? null : Math.round(target * base(prog));\n  const countO =\n    interpolate(t, [0, 6], [0.4, 1], CLAMP) *\n    interpolate(t, [HIT - 4, HIT + 2], [1, 0], CLAMP);\n\n  // Final hit\n  const hit = spring({\n    frame: t - HIT,\n    fps,\n    config: { damping: 15, stiffness: 170, mass: 0.7 },\n  });\n  const hitO = interpolate(t, [HIT, HIT + 6], [0, 1], CLAMP);\n  const ring = interpolate(t, [HIT, HIT + 26], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const lab = interpolate(t, [HIT + 8, HIT + 28], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const valueSize = 128 * u;\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      {/* depth: a sparse dot plane that drifts slower than the line */}\n      <AbsoluteFill\n        style={{\n          backgroundImage: `radial-gradient(circle at center, ${p.dot} ${1.1 * u}px, transparent ${1.7 * u}px)`,\n          backgroundSize: `${gap}px ${gap}px`,\n          backgroundPosition: `${gx - gap / 2}px ${gy - gap / 2}px`,\n          WebkitMaskImage:\n            \"radial-gradient(ellipse 70% 70% at 50% 50%, #000 20%, transparent 100%)\",\n          maskImage:\n            \"radial-gradient(ellipse 70% 70% at 50% 50%, #000 20%, transparent 100%)\",\n          opacity: enter,\n        }}\n      />\n      {/* soft light that follows the tip */}\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(circle ${height * 0.5}px at ${tipX}px ${tipY}px, ${p.wash}, transparent 100%)`,\n        }}\n      />\n\n      <svg\n        width={width}\n        height={height}\n        style={{ position: \"absolute\", inset: 0, opacity: enter }}\n        aria-hidden\n      >\n        <defs>\n          <linearGradient\n            id={`${id}s`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={pts[0][0]}\n            y1={pts[0][1]}\n            x2={tipX}\n            y2={tipY}\n          >\n            <stop offset=\"0\" stopColor={p.line[0]} stopOpacity={p.tail} />\n            <stop offset=\"0.42\" stopColor={p.line[1]} stopOpacity={0.9} />\n            <stop offset=\"0.86\" stopColor={p.line[2]} stopOpacity={1} />\n            <stop offset=\"1\" stopColor={p.line[3]} stopOpacity={1} />\n          </linearGradient>\n          {/* area: the same palette left to right, faded out toward the axis */}\n          <linearGradient\n            id={`${id}f`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={pts[0][0]}\n            y1={0}\n            x2={tipX}\n            y2={0}\n          >\n            <stop offset=\"0\" stopColor={p.line[0]} />\n            <stop offset=\"0.5\" stopColor={p.line[1]} />\n            <stop offset=\"1\" stopColor={p.line[2]} />\n          </linearGradient>\n          <linearGradient\n            id={`${id}v`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={0}\n            y1={Math.min(tipY, syTop)}\n            x2={0}\n            y2={sy0}\n          >\n            <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={p.fill} />\n            <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0} />\n          </linearGradient>\n          <mask id={`${id}m`} maskUnits=\"userSpaceOnUse\">\n            <rect\n              x={0}\n              y={Math.min(tipY, syTop) - 10}\n              width={width}\n              height={height * 4}\n              fill={`url(#${id}v)`}\n            />\n          </mask>\n          <radialGradient id={`${id}h`}>\n            <stop offset=\"0\" stopColor={p.line[2]} stopOpacity={0.3} />\n            <stop offset=\"1\" stopColor={p.line[2]} stopOpacity={0} />\n          </radialGradient>\n        </defs>\n\n        {/* hairline axes */}\n        <line\n          x1={sx0}\n          y1={sy0}\n          x2={sxr}\n          y2={sy0}\n          stroke={p.axis}\n          strokeWidth={Math.max(1, u)}\n        />\n        <line\n          x1={sx0}\n          y1={sy0}\n          x2={sx0}\n          y2={syTop}\n          stroke={p.axis}\n          strokeWidth={Math.max(1, u)}\n        />\n\n        <path d={fillD} fill={`url(#${id}f)`} mask={`url(#${id}m)`} />\n        <path\n          d={d}\n          fill=\"none\"\n          stroke={`url(#${id}s)`}\n          strokeWidth={3 * u}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n        />\n\n        {/* milestones */}\n        {marks.map((m) => {\n          const [mx, my] = proj(...world(m.at));\n          const reach = reachFrame(m.at);\n          const pop = spring({\n            frame: t - reach,\n            fps,\n            config: { damping: 13, stiffness: 190, mass: 0.6 },\n          });\n          if (t < reach) return null;\n          return (\n            <g key={m.label}>\n              <circle\n                cx={mx}\n                cy={my}\n                r={5.5 * u * (0.6 + 0.4 * pop)}\n                fill={p.bg}\n                stroke={accent}\n                strokeWidth={2.2 * u}\n                opacity={Math.min(1, pop * 1.5)}\n              />\n            </g>\n          );\n        })}\n\n        {/* tip */}\n        <circle cx={tipX} cy={tipY} r={18 * u} fill={`url(#${id}h)`} />\n        <circle\n          cx={tipX}\n          cy={tipY}\n          r={lerp(6, 40, ring) * u}\n          fill=\"none\"\n          stroke={p.line[2]}\n          strokeWidth={1.5 * u}\n          opacity={t >= HIT ? (1 - ring) * 0.7 : 0}\n        />\n        <circle cx={tipX} cy={tipY} r={5 * u} fill={p.tip} />\n        <circle cx={tipX} cy={tipY} r={1.8 * u} fill={p.bg} opacity={0.9} />\n      </svg>\n\n      {/* milestone labels: screen-space type, upper-left of the dot */}\n      {marks.map((m) => {\n        const [mx, my] = proj(...world(m.at));\n        const reach = reachFrame(m.at);\n        const a = interpolate(t, [reach + 1, reach + 14], [0, 1], {\n          ...CLAMP,\n          easing: EASE_OUT,\n        });\n        // labels quiet down once the camera pulls back so the value owns the frame\n        const quiet = interpolate(t, [HIT - 6, HIT + 14], [1, 0.55], CLAMP);\n        return (\n          <div\n            key={m.label}\n            style={{\n              position: \"absolute\",\n              left: mx - 200 * u,\n              top: my - 46 * u,\n              width: 200 * u + 6 * u,\n              textAlign: \"right\",\n              fontFamily: sans,\n              fontWeight: 500,\n              fontSize: 17 * u,\n              letterSpacing: \"-0.01em\",\n              color: p.fg,\n              opacity: a * quiet,\n              transform: `translateY(${(1 - a) * 10 * u}px)`,\n              fontVariantNumeric: \"tabular-nums\",\n              whiteSpace: \"nowrap\",\n            }}\n          >\n            {m.label}\n          </div>\n        );\n      })}\n\n      {count !== null && (\n        <div\n          style={{\n            position: \"absolute\",\n            left: tipX + 14 * u,\n            top: tipY - 34 * u,\n            fontFamily: sans,\n            fontWeight: 400,\n            fontSize: 16 * u,\n            letterSpacing: \"-0.01em\",\n            color: p.muted,\n            fontVariantNumeric: \"tabular-nums\",\n            opacity: countO,\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          {count.toLocaleString(\"en-US\")}\n        </div>\n      )}\n\n      {/* the value lands at the tip */}\n      <div\n        style={{\n          position: \"absolute\",\n          right: width - tipX + 78 * u,\n          top: tipY - 16 * u,\n          textAlign: \"right\",\n          opacity: hitO,\n          transform: `translateY(${(1 - hit) * 26 * u}px) scale(${1.06 - 0.06 * hit})`,\n          transformOrigin: \"100% 0%\",\n        }}\n      >\n        <div\n          style={{\n            fontFamily: sans,\n            fontWeight: 400,\n            fontSize: valueSize,\n            lineHeight: 0.9,\n            letterSpacing: \"-0.05em\",\n            color: p.fg,\n            fontVariantNumeric: \"tabular-nums\",\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          {value}\n        </div>\n        <div\n          style={{\n            marginTop: 14 * u,\n            fontFamily: sans,\n            fontWeight: 400,\n            fontSize: 20 * u,\n            letterSpacing: \"-0.01em\",\n            color: p.muted,\n            opacity: lab,\n            transform: `translateY(${(1 - lab) * 10 * u}px)`,\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          {label}\n        </div>\n      </div>\n\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 80% 80% at 50% 50%, transparent 60%, ${p.bg} 100%)`,\n          opacity: 0.7,\n        }}\n      />\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/growth-line.tsx"
    }
  ],
  "type": "registry:component"
}
