{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rank-climb",
  "title": "Rank Climb",
  "description": "A rank list reorders until the product reaches #1 on Product Hunt.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/rank-climb/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/IBMPlexMono\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  interpolateColors,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** Full logo as on remocn.dev: R mark (0.76em tall, baseline-aligned) + \"emocn\" in Manrope 600, tracking-tight. */\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nconst isBrandLabel = (label: string) => label.trim().toLowerCase() === \"remocn\";\n\nexport interface RankItem {\n  label: string;\n  value: number;\n}\n\nexport interface RankClimbProps {\n  items?: RankItem[];\n  brand?: string;\n  from?: number;\n  to?: number;\n  eyebrow?: string;\n  caption?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\nconst DEFAULT_ITEMS: RankItem[] = [\n  { label: \"remocn\", value: 2318 },\n  { label: \"Kitebase\", value: 2140 },\n  { label: \"Lumen\", value: 1986 },\n  { label: \"Fernway\", value: 1712 },\n  { label: \"Quarry\", value: 1544 },\n  { label: \"Orbitly\", value: 1390 },\n  { label: \"Halcyon\", value: 1208 },\n  { label: \"Tessel\", value: 1062 },\n];\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_SWAP = Easing.bezier(0.6, 0, 0.3, 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    faint: \"#5A595F\",\n    hair: \"rgba(255,255,255,0.09)\",\n    pill: \"#1B1B1F\",\n    pillEdge: \"rgba(255,255,255,0.14)\",\n    shadow: \"rgba(0,0,0,0.55)\",\n    stage: \"rgba(255,255,255,0.05)\",\n    // gradients.sh \"fluted\": cobalt into ember into peach, top to bottom.\n    paint:\n      \"linear-gradient(172deg, #2F7BFF 8%, #8C7BFF 38%, #FF7A3D 70%, #FFE2C4 96%)\",\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    faint: \"#A3A099\",\n    hair: \"rgba(18,18,20,0.09)\",\n    pill: \"#FFFFFF\",\n    pillEdge: \"rgba(18,18,20,0.12)\",\n    shadow: \"rgba(40,36,28,0.16)\",\n    stage: \"rgba(255,255,255,0.7)\",\n    paint: \"linear-gradient(172deg, #1D2A8F 8%, #2F7BFF 40%, #FF7A3D 82%)\",\n    grain: 0.045,\n  },\n} as const;\n\ntype Theme = (typeof THEMES)[keyof typeof THEMES];\n\nconst T_CLIMB = 28;\nconst LAST_DUR = 22;\n\nfunction groupThousands(n: number) {\n  return String(Math.round(n)).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\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={13}\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\nfunction RollNumber({\n  value,\n  min,\n  max,\n  size,\n  lineHeight,\n  color,\n  font,\n  weight,\n  travel = 0.34,\n  blur = 0,\n  paint,\n}: {\n  value: number;\n  min: number;\n  max: number;\n  size: number;\n  lineHeight: number;\n  color: string;\n  font: string;\n  weight: number;\n  travel?: number;\n  blur?: number;\n  paint?: string;\n}) {\n  const nums: number[] = [];\n  for (let n = min; n <= max; n++) nums.push(n);\n  const lh = size * lineHeight;\n  const text: React.CSSProperties = {\n    height: lh,\n    lineHeight: `${lh}px`,\n    fontFamily: font,\n    fontWeight: weight,\n    fontSize: size,\n    fontVariantNumeric: \"tabular-nums\",\n    whiteSpace: \"nowrap\",\n    ...(paint\n      ? {\n          backgroundImage: paint,\n          WebkitBackgroundClip: \"text\",\n          backgroundClip: \"text\",\n          WebkitTextFillColor: \"transparent\",\n        }\n      : null),\n  };\n  return (\n    <span\n      style={{\n        display: \"inline-block\",\n        position: \"relative\",\n        height: lh,\n        verticalAlign: \"top\",\n      }}\n    >\n      <span style={{ ...text, visibility: \"hidden\" }}>{max}</span>\n      {nums.map((n) => {\n        const d = n - value;\n        const a = interpolate(Math.abs(d), [0, 0.62], [1, 0], CLAMP);\n        if (a <= 0) return null;\n        const b = Math.abs(d) * blur;\n        return (\n          <span\n            key={n}\n            style={{\n              ...text,\n              position: \"absolute\",\n              left: 0,\n              top: 0,\n              color,\n              opacity: a,\n              transform: `translateY(${d * travel * size}px)`,\n              filter: b > 0.2 ? `blur(${b}px)` : undefined,\n            }}\n          >\n            {n}\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\nfunction Upvote({ size, color }: { size: number; color: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 10 10\" aria-hidden>\n      <path d=\"M5 1.6 L9 8.2 H1 Z\" fill={color} />\n    </svg>\n  );\n}\n\nfunction Row({\n  item,\n  pos,\n  isBrand,\n  n,\n  rowH,\n  rowW,\n  u,\n  enter,\n  lift,\n  dim,\n  win,\n  value,\n  accent,\n  th,\n}: {\n  item: RankItem;\n  pos: number;\n  isBrand: boolean;\n  n: number;\n  rowH: number;\n  rowW: number;\n  u: number;\n  enter: number;\n  lift: number;\n  dim: number;\n  win: number;\n  value: number;\n  accent: string;\n  th: Theme;\n}) {\n  const pad = 22 * u;\n  const pillBg = interpolateColors(win, [0, 1], [th.pill, accent]);\n  const nameColor = isBrand\n    ? interpolateColors(win, [0, 1], [th.fg, \"#FFFFFF\"])\n    : th.fg;\n  const subColor = isBrand\n    ? interpolateColors(win, [0, 1], [th.muted, \"rgba(255,255,255,0.78)\"])\n    : th.muted;\n  const inset = 4 * u;\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: 0,\n        top: pos * rowH,\n        width: rowW,\n        height: rowH,\n        zIndex: isBrand ? 2 : 1,\n        opacity: enter * (isBrand ? 1 : 1 - 0.62 * dim),\n        transform: `translateY(${(1 - enter) * 14 * u}px) scale(${1 + 0.018 * lift})`,\n      }}\n    >\n      {isBrand ? (\n        <div\n          style={{\n            position: \"absolute\",\n            left: -pad * 0.55,\n            right: -pad * 0.55,\n            top: inset,\n            bottom: inset,\n            borderRadius: 14 * u,\n            background: pillBg,\n            boxShadow: `0 0 0 ${Math.max(1, u)}px ${interpolateColors(win, [0, 1], [th.pillEdge, accent])}, 0 ${(4 + 14 * lift) * u}px ${(10 + 30 * lift) * u}px ${th.shadow}`,\n          }}\n        />\n      ) : null}\n      <div\n        style={{\n          position: \"relative\",\n          height: \"100%\",\n          display: \"flex\",\n          alignItems: \"center\",\n          gap: 18 * u,\n          paddingLeft: pad * 0.25,\n          paddingRight: pad * 0.25,\n        }}\n      >\n        <div style={{ width: 34 * u, display: \"flex\" }}>\n          <RollNumber\n            value={pos + 1}\n            min={1}\n            max={n}\n            size={20 * u}\n            lineHeight={1.3}\n            color={subColor}\n            font={mono}\n            weight={400}\n            travel={0.6}\n            blur={2 * u}\n          />\n        </div>\n        <span\n          style={{\n            flex: 1,\n            display: \"flex\",\n            fontFamily: sans,\n            fontSize: 25 * u,\n            fontWeight: isBrand ? 500 : 400,\n            letterSpacing: \"-0.02em\",\n            color: nameColor,\n            whiteSpace: \"nowrap\",\n          }}\n        >\n          {isBrandLabel(item.label) ? (\n            <RemocnLogo fontSize={25 * u} color={nameColor} />\n          ) : (\n            item.label\n          )}\n        </span>\n        <span\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: 8 * u,\n            fontFamily: mono,\n            fontSize: 18 * u,\n            fontWeight: 400,\n            fontVariantNumeric: \"tabular-nums\",\n            color: subColor,\n          }}\n        >\n          <Upvote size={11 * u} color={subColor} />\n          {groupThousands(value)}\n        </span>\n      </div>\n    </div>\n  );\n}\n\nexport function RankClimb({\n  items = DEFAULT_ITEMS,\n  brand = \"remocn\",\n  from = 8,\n  to = 1,\n  eyebrow = \"Product of the day\",\n  caption = \"on Product Hunt\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: RankClimbProps) {\n  const t = useCurrentFrame() * speed;\n  const { width, height } = useVideoConfig();\n  const u = Math.min(width / 1280, height / 720);\n  const th: Theme = THEMES[theme];\n\n  const found = items.find((i) => i.label === brand);\n  const others = items\n    .filter((i) => i.label !== brand)\n    .slice()\n    .sort((a, b) => b.value - a.value);\n  const brandItem: RankItem = found ?? {\n    label: brand,\n    value: Math.round((others[0]?.value ?? 1000) * 1.08),\n  };\n  const n = others.length + 1;\n  const start = Math.min(Math.max(1, Math.round(from)), n) - 1;\n  const end = Math.min(Math.max(1, Math.round(to)), start + 1) - 1;\n  const K = start - end;\n\n  const swaps: { s: number; d: number; passed: number }[] = [];\n  let clock = T_CLIMB;\n  for (let k = 0; k < K; k++) {\n    const last = k === K - 1;\n    const gap = K > 1 ? 13 - (5 * k) / Math.max(1, K - 2) : 13;\n    const s = clock + (last && K > 1 ? 3 : 0);\n    const d = last ? LAST_DUR : gap * 1.35;\n    swaps.push({ s, d, passed: start - 1 - k });\n    clock += gap;\n  }\n  const climbEnd = swaps.length\n    ? swaps[swaps.length - 1].s + swaps[swaps.length - 1].d\n    : T_CLIMB;\n  const prog = swaps.map((w) =>\n    interpolate(t, [w.s, w.s + w.d], [0, 1], { ...CLAMP, easing: EASE_SWAP }),\n  );\n\n  const initialSlot = (i: number) => (i < start ? i : i + 1);\n  const brandPos = start - prog.reduce((a, b) => a + b, 0);\n\n  const checkpoints: number[] = [];\n  if (K > 0) {\n    const firstPassed = others[swaps[0].passed]?.value ?? brandItem.value;\n    checkpoints.push(Math.min(firstPassed * 0.9, brandItem.value * 0.9));\n    swaps.forEach((w, k) => {\n      const pv = others[w.passed]?.value ?? 0;\n      checkpoints.push(\n        k === K - 1\n          ? brandItem.value\n          : Math.min(pv + 14, brandItem.value - (K - k) * 10),\n      );\n    });\n  }\n  const brandValue =\n    K > 0\n      ? prog.reduce(\n          (v, e, k) => v + (checkpoints[k + 1] - checkpoints[k]) * e,\n          checkpoints[0],\n        )\n      : brandItem.value;\n\n  const lift = swaps.length\n    ? interpolate(\n        t,\n        [T_CLIMB - 4, T_CLIMB + 6, climbEnd - 6, climbEnd + 6],\n        [0, 1, 1, 0],\n        { ...CLAMP, easing: EASE_IO },\n      )\n    : 0;\n  const T_WIN = climbEnd - 2;\n  const win = interpolate(t, [T_WIN, T_WIN + 14], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const dim = interpolate(t, [T_WIN + 2, T_WIN + 20], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const capIn = interpolate(t, [T_WIN + 4, T_WIN + 26], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  const margin = width * 0.085;\n  const listX = width * 0.5;\n  const rowW = width - margin - listX;\n  const rowH = Math.min(62 * u, (height * 0.7) / n);\n  const listH = rowH * n;\n  const listTop = (height - listH) / 2;\n\n  const leftIn = interpolate(t, [-6, 16], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const bigSize = Math.min(232 * u, width * 0.18);\n  const bigColor = interpolateColors(win, [0, 1], [th.muted, th.fg]);\n  const push = interpolate(t, [0, climbEnd + 60], [1.03, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n\n  return (\n    <AbsoluteFill style={{ background: th.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 60% 70% at 30% 40%, ${th.stage}, transparent 75%)`,\n        }}\n      />\n      <AbsoluteFill\n        style={{ transform: `scale(${push})`, transformOrigin: \"50% 50%\" }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: margin,\n            top: height / 2,\n            transform: `translateY(-50%) translateY(${(1 - leftIn) * 12 * u}px)`,\n            opacity: leftIn,\n            display: \"flex\",\n            flexDirection: \"column\",\n            alignItems: \"flex-start\",\n          }}\n        >\n          <span\n            style={{\n              fontFamily: mono,\n              fontSize: 15 * u,\n              fontWeight: 400,\n              letterSpacing: \"0.08em\",\n              textTransform: \"uppercase\",\n              color: th.muted,\n              whiteSpace: \"nowrap\",\n              marginBottom: 14 * u,\n            }}\n          >\n            {eyebrow}\n          </span>\n          <div\n            style={{\n              display: \"flex\",\n              alignItems: \"flex-start\",\n              marginLeft: -bigSize * 0.04,\n              letterSpacing: \"-0.045em\",\n            }}\n          >\n            <span\n              style={{\n                position: \"relative\",\n                fontFamily: sans,\n                fontWeight: 400,\n                fontSize: bigSize,\n                lineHeight: `${bigSize * 1.04}px`,\n                color: th.faint,\n                marginRight: bigSize * 0.03,\n              }}\n            >\n              <span style={{ opacity: 1 - win }}>#</span>\n              <span\n                style={{\n                  position: \"absolute\",\n                  left: 0,\n                  top: 0,\n                  opacity: win,\n                  backgroundImage: th.paint,\n                  WebkitBackgroundClip: \"text\",\n                  backgroundClip: \"text\",\n                  WebkitTextFillColor: \"transparent\",\n                }}\n              >\n                #\n              </span>\n            </span>\n            <span style={{ position: \"relative\", display: \"inline-block\" }}>\n              <span style={{ display: \"inline-block\", opacity: 1 - win }}>\n                <RollNumber\n                  value={brandPos + 1}\n                  min={end + 1}\n                  max={start + 1}\n                  size={bigSize}\n                  lineHeight={1.04}\n                  color={bigColor}\n                  font={sans}\n                  weight={500}\n                  blur={14 * u}\n                />\n              </span>\n              <span\n                style={{\n                  position: \"absolute\",\n                  left: 0,\n                  top: 0,\n                  opacity: win,\n                }}\n              >\n                <RollNumber\n                  value={brandPos + 1}\n                  min={end + 1}\n                  max={start + 1}\n                  size={bigSize}\n                  lineHeight={1.04}\n                  color={bigColor}\n                  font={sans}\n                  weight={500}\n                  blur={14 * u}\n                  paint={th.paint}\n                />\n              </span>\n            </span>\n          </div>\n          <span\n            style={{\n              marginTop: 4 * u,\n              fontFamily: sans,\n              fontWeight: 400,\n              fontSize: 50 * u,\n              letterSpacing: \"-0.03em\",\n              color: th.fg,\n              whiteSpace: \"nowrap\",\n              opacity: capIn,\n              transform: `translateY(${(1 - capIn) * 14 * u}px)`,\n              filter:\n                capIn < 0.98 ? `blur(${(1 - capIn) * 6 * u}px)` : undefined,\n            }}\n          >\n            {caption}\n          </span>\n        </div>\n\n        <div\n          style={{\n            position: \"absolute\",\n            left: listX,\n            top: listTop,\n            width: rowW,\n            height: listH,\n          }}\n        >\n          {Array.from({ length: n - 1 }).map((_, i) => {\n            const a = interpolate(t, [i * 2 + 4, i * 2 + 22], [0, 1], {\n              ...CLAMP,\n              easing: EASE_IO,\n            });\n            return (\n              <div\n                key={`h${i}`}\n                style={{\n                  position: \"absolute\",\n                  left: 0,\n                  top: (i + 1) * rowH,\n                  height: Math.max(1, u),\n                  width: rowW * a,\n                  background: th.hair,\n                  opacity: 1 - 0.5 * dim,\n                }}\n              />\n            );\n          })}\n          {others.map((item, i) => {\n            const slot = initialSlot(i);\n            const k = swaps.findIndex((w) => w.passed === i);\n            const pos = slot + (k >= 0 ? prog[k] : 0);\n            const enter = interpolate(\n              t,\n              [slot * 2 - 6, slot * 2 + 14],\n              [0, 1],\n              {\n                ...CLAMP,\n                easing: EASE_OUT,\n              },\n            );\n            return (\n              <Row\n                key={item.label}\n                item={item}\n                pos={pos}\n                isBrand={false}\n                n={n}\n                rowH={rowH}\n                rowW={rowW}\n                u={u}\n                enter={enter}\n                lift={0}\n                dim={dim}\n                win={0}\n                value={item.value}\n                accent={accent}\n                th={th}\n              />\n            );\n          })}\n          <Row\n            item={brandItem}\n            pos={brandPos}\n            isBrand\n            n={n}\n            rowH={rowH}\n            rowW={rowW}\n            u={u}\n            enter={interpolate(t, [start * 2 - 6, start * 2 + 14], [0, 1], {\n              ...CLAMP,\n              easing: EASE_OUT,\n            })}\n            lift={lift}\n            dim={dim}\n            win={win}\n            value={brandValue}\n            accent={accent}\n            th={th}\n          />\n        </div>\n      </AbsoluteFill>\n\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 85% 85% at 50% 50%, transparent 60%, ${th.bg} 100%)`,\n          opacity: 0.55,\n        }}\n      />\n      <Grain opacity={th.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/rank-climb.tsx"
    }
  ],
  "type": "registry:component"
}
