{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "candle-rally",
  "title": "Candle Rally",
  "description": "Candlesticks rally past a prior high as 'ALL-TIME HIGH' lands beside a price tag.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/candle-rally/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BarlowCondensed\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface CandleRallyProps {\n  /** Ticker on the price tag riding the last wick. Fictional. */\n  symbol?: string;\n  /** Where the last candle closes; printed on the tag. */\n  price?: number;\n  /** The previous high the rally breaks through (dashed level). */\n  prevHigh?: number;\n  /** First line of the slam. */\n  headline?: string;\n  /** Second line of the slam. */\n  headline2?: string;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_PUSH = Easing.bezier(0.42, 0, 0.18, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// Beat sheet (30fps, speed 1):\n//   0–48   ten small candles chop sideways, one every 4 frames\n//  50–82   the rally: five green candles, 6 frames apart, each bigger\n//  82–108  the last candle pushes up huge and fills with the aurora gradient;\n//          the price tag rides its wick and breaks the dashed previous high\n// 110–122  ALL-TIME / HIGH slams in, the candles fall back behind it\n// 122–     poster holds\nconst RALLY_AT = 50;\nconst FINAL_AT = 82;\nconst FINAL_LEN = 26;\nconst SLAM = 110;\n\n// Candles as [open, close, high, low]; the last close is replaced by `price`.\nconst CHOP: Array<[number, number, number, number]> = [\n  [63.5, 66.5, 68, 62],\n  [66.5, 63, 67.5, 61.5],\n  [65.5, 62, 66.5, 60.5],\n  [62, 65, 66, 61],\n  [65, 62.5, 66.5, 61.5],\n  [62.5, 66, 67.5, 61.5],\n  [66, 63.5, 67.5, 62.5],\n  [63.5, 65.5, 66.5, 62.5],\n];\nconst RALLY: Array<[number, number, number, number]> = [\n  [63, 66.5, 67.5, 62.5],\n  [66.5, 71, 72, 65.5],\n  [71, 77.5, 79, 70],\n  [77.5, 87, 88.5, 76.5],\n  [87, 99.5, 101.5, 86],\n];\n// The y-range auto-scales like a live chart: tight on the chop, pulled\n// open by the rally so the newest high always rides near the top.\nconst LO = 58.5;\nconst HI_MIN = 70;\n\n// gradients.sh \"aurora\" (bg #03050b): #a0f0c8 #3fb5a3 #5147b6 #b25c9c.\nconst AURORA = [\"#A0F0C8\", \"#3FB5A3\", \"#5147B6\", \"#B25C9C\"];\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#77767C\",\n    hair: \"rgba(243,242,239,0.08)\",\n    up: \"#4FC8AE\",\n    down: \"#E4604E\",\n    tagInk: \"#06140F\",\n    ground: 0.55,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#8A8883\",\n    hair: \"rgba(18,18,20,0.08)\",\n    up: \"#169C82\",\n    down: \"#D44A37\",\n    tagInk: \"#06140F\",\n    ground: 0.14,\n  },\n} as const;\n\nexport function CandleRally({\n  symbol = \"RMCN\",\n  price = 128.4,\n  prevHigh = 112,\n  headline = \"All-time\",\n  headline2 = \"high\",\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: CandleRallyProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const p = THEMES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  // ---- candle slots: chop narrow and even, rally widening, last one huge ---\n  const finalCandle: [number, number, number, number] = [\n    99.5,\n    price,\n    price + 1.6,\n    98.5,\n  ];\n  const all = [...CHOP, ...RALLY, finalCandle];\n  const widths = all.map((_, i) =>\n    i < CHOP.length\n      ? 0.03\n      : i < all.length - 1\n        ? 0.032 + (i - CHOP.length) * 0.004\n        : 0.09,\n  );\n  const gaps = all.map((_, i) =>\n    i < CHOP.length\n      ? 0.022\n      : i < all.length - 1\n        ? 0.024 + (i - CHOP.length) * 0.003\n        : 0.04,\n  );\n  const xs: number[] = [];\n  {\n    let x = 0.065;\n    all.forEach((_, i) => {\n      if (i > 0) x += widths[i - 1] / 2 + gaps[i] + widths[i] / 2;\n      xs.push(x);\n    });\n  }\n  // fit the run so the last candle sits at ~84% of the width\n  const fit = (0.84 - 0.065) / (xs[xs.length - 1] - 0.065);\n\n  const startOf = (i: number) =>\n    i < CHOP.length\n      ? 4 + i * 5\n      : i < all.length - 1\n        ? RALLY_AT + (i - CHOP.length) * 6\n        : FINAL_AT;\n  const lenOf = (i: number) =>\n    i < CHOP.length\n      ? 8\n      : i < all.length - 1\n        ? 9 + (i - CHOP.length)\n        : FINAL_LEN;\n\n  const fi = all.length - 1;\n  const cx = (i: number) => W * (0.065 + (xs[i] - 0.065) * fit * zx);\n  const cw = (i: number) => W * widths[i] * fit * zx;\n  const kOf = (i: number, tt: number) => {\n    const r = Math.max(0, Math.min(1, (tt - startOf(i)) / lenOf(i)));\n    return i === fi ? EASE_PUSH(r) : EASE_OUT(r);\n  };\n  // the auto-scaling range follows the highest wick so far, box-filtered\n  // over a few frames so each new candle pumps the scale smoothly\n  const topAt = (tt: number) => {\n    let m = HI_MIN;\n    all.forEach(([o, c, h], i) => {\n      if (tt < startOf(i)) return;\n      const k = kOf(i, tt);\n      const cur = o + (c - o) * k;\n      m = Math.max(m, Math.max(o, cur) + (h - Math.max(o, c)) * k);\n    });\n    return m;\n  };\n  let hiSum = 0;\n  for (let k = 0; k < 6; k++) {\n    const top = topAt(t - k);\n    hiSum += Math.max(HI_MIN, top + (top - LO) * 0.12);\n  }\n  const topNow = topAt(t);\n  const hi = Math.max(hiSum / 6, topNow + (topNow - LO) * 0.05);\n  const lo = LO - (hi - HI_MIN) * 0.03;\n  const yOf = (v: number) => H * 0.88 - ((v - lo) / (hi - lo)) * H * 0.76;\n  // the camera pulls back as the rally needs the room\n  const zx = interpolate(t, [0, RALLY_AT - 4, FINAL_AT + 16], [1.5, 1.42, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n\n  const slam1 = interpolate(t, [SLAM, SLAM + 7], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const slam2 = interpolate(t, [SLAM + 4, SLAM + 11], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const dim = interpolate(t, [SLAM, SLAM + 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  // one impact: the chart dips on the slam and settles\n  const hit =\n    interpolate(t, [SLAM + 1, SLAM + 3, SLAM + 16], [0, 1, 0], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    }) *\n    10 *\n    u;\n\n  // last candle's live close, the tag reads it\n  const fk = EASE_PUSH(Math.max(0, Math.min(1, (t - FINAL_AT) / FINAL_LEN)));\n  const live = finalCandle[0] + (finalCandle[1] - finalCandle[0]) * fk;\n  const broke = live >= prevHigh;\n  const breakAt = (() => {\n    // frame where the live close crosses the previous high\n    for (let f = FINAL_AT; f <= FINAL_AT + FINAL_LEN; f += 0.25) {\n      const k = EASE_PUSH(Math.min(1, (f - FINAL_AT) / FINAL_LEN));\n      if (finalCandle[0] + (finalCandle[1] - finalCandle[0]) * k >= prevHigh)\n        return f;\n    }\n    return FINAL_AT + FINAL_LEN;\n  })();\n  const levelIn = interpolate(t, [6, 22], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const levelFlash = interpolate(\n    t,\n    [breakAt, breakAt + 2, breakAt + 16],\n    [0, 1, 0],\n    CLAMP,\n  );\n  const levelOut = interpolate(\n    t,\n    [breakAt + 6, breakAt + 22],\n    [1, 0.35],\n    CLAMP,\n  );\n  const ground = interpolate(t, [FINAL_AT, FINAL_AT + FINAL_LEN + 10], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const gradK = interpolate(t, [FINAL_AT + 6, FINAL_AT + FINAL_LEN], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n\n  const candle = (i: number) => {\n    const [o, c, h, l] = all[i];\n    const s = startOf(i);\n    const k = EASE_OUT(Math.max(0, Math.min(1, (t - s) / lenOf(i))));\n    const isFinal = i === all.length - 1;\n    const kk = isFinal ? fk : k;\n    if (t < s) return null;\n    const cur = o + (c - o) * kk;\n    const top = Math.max(o, cur) + (h - Math.max(o, c)) * kk;\n    const bot = Math.min(o, cur) - (Math.min(o, c) - l) * kk;\n    const x = cx(i);\n    const w = cw(i);\n    const yA = yOf(Math.max(o, cur));\n    const yB = yOf(Math.min(o, cur));\n    const bodyH = Math.max(2 * u, yB - yA);\n    const color = c >= o ? p.up : p.down;\n    const appear = interpolate(t, [s, s + 2], [0, 1], CLAMP);\n    const wick = Math.max(1.5 * u, w * (isFinal ? 0.05 : 0.09));\n    const fade = isFinal ? 1 : 1 - dim * 0.78;\n    return (\n      <g key={i} opacity={appear * fade}>\n        <rect\n          x={x - wick / 2}\n          y={yOf(top)}\n          width={wick}\n          height={yOf(bot) - yOf(top)}\n          fill={isFinal ? `url(#${uid}wick)` : color}\n        />\n        <rect\n          x={x - w / 2}\n          y={yA - (bodyH - (yB - yA)) / 2}\n          width={w}\n          height={bodyH}\n          rx={Math.min(w * 0.08, 4 * u)}\n          fill={color}\n        />\n        {isFinal ? (\n          <rect\n            x={x - w / 2}\n            y={yA}\n            width={w}\n            height={bodyH}\n            rx={Math.min(w * 0.08, 4 * u)}\n            fill={`url(#${uid}aurora)`}\n            opacity={gradK}\n          />\n        ) : null}\n      </g>\n    );\n  };\n\n  const fx = cx(fi);\n  const fw = cw(fi);\n  const wickTop = yOf(\n    Math.max(finalCandle[0], live) +\n      (finalCandle[2] - Math.max(finalCandle[0], finalCandle[1])) * fk,\n  );\n  const tagIn = interpolate(t, [FINAL_AT + 2, FINAL_AT + 10], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const tagH = 44 * u;\n  const tagFont = 21 * u;\n  const levelY = yOf(prevHigh);\n  const S = H * 0.3;\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      {/* aurora ground behind the breakout */}\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          opacity: ground * p.ground,\n          background: [\n            `radial-gradient(34% 62% at 84% 26%, color-mix(in oklab, ${AURORA[0]} 55%, transparent) 0%, transparent 70%)`,\n            `radial-gradient(40% 70% at 72% 40%, color-mix(in oklab, ${AURORA[2]} 45%, transparent) 0%, transparent 72%)`,\n          ].join(\", \"),\n        }}\n      />\n\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        role=\"img\"\n        aria-label={`${symbol} candles rally to ${price.toFixed(2)}, ${headline} ${headline2}`}\n      >\n        <defs>\n          <linearGradient\n            id={`${uid}aurora`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={0}\n            y1={yOf(finalCandle[1])}\n            x2={0}\n            y2={yOf(finalCandle[0])}\n          >\n            {AURORA.map((c, i) => (\n              <stop key={c} offset={i / (AURORA.length - 1)} stopColor={c} />\n            ))}\n          </linearGradient>\n          <linearGradient\n            id={`${uid}wick`}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={0}\n            y1={yOf(finalCandle[2])}\n            x2={0}\n            y2={yOf(finalCandle[3])}\n          >\n            <stop offset={0} stopColor={AURORA[0]} />\n            <stop offset={1} stopColor={AURORA[3]} />\n          </linearGradient>\n        </defs>\n\n        <g transform={`translate(0 ${hit})`}>\n          {/* minimal axis: four faint levels with mono ticks */}\n          {[60, 80, 100, 120].map((v) => (\n            <g key={v} opacity={levelIn * (1 - dim * 0.6)}>\n              <rect\n                x={W * 0.04}\n                y={yOf(v) - 0.5 * u}\n                width={W * 0.88}\n                height={1 * u}\n                fill={p.hair}\n              />\n              <text\n                x={W * 0.965}\n                y={yOf(v) + 5 * u}\n                textAnchor=\"end\"\n                fontFamily={mono}\n                fontWeight={400}\n                fontSize={13 * u}\n                fill={p.muted}\n              >\n                {v.toFixed(0)}\n              </text>\n            </g>\n          ))}\n\n          {/* previous high: dashed level the last candle punches through */}\n          <g opacity={levelIn * levelOut * (1 - dim)}>\n            <line\n              x1={W * 0.04}\n              x2={W * 0.92}\n              y1={levelY}\n              y2={levelY}\n              stroke={broke ? p.up : accent}\n              strokeOpacity={0.55 + 0.45 * levelFlash}\n              strokeWidth={(1.5 + 2 * levelFlash) * u}\n              strokeDasharray={`${6 * u} ${6 * u}`}\n            />\n            <text\n              x={W * 0.04}\n              y={levelY - 12 * u}\n              fontFamily={mono}\n              fontWeight={500}\n              fontSize={14 * u}\n              letterSpacing=\"0.1em\"\n              fill={p.muted}\n            >\n              PREV HIGH {prevHigh.toFixed(2)}\n            </text>\n          </g>\n\n          {all.map((_, i) => candle(i))}\n        </g>\n      </svg>\n\n      {/* price tag riding the last wick */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: fx - fw / 2 - 14 * u,\n          top: wickTop + hit,\n          height: tagH,\n          transform: `translate(-100%, -50%) translateX(${(1 - tagIn) * 16 * u}px)`,\n          opacity: tagIn,\n          display: \"flex\",\n          alignItems: \"center\",\n          gap: 10 * u,\n          padding: `0 ${16 * u}px`,\n          borderRadius: tagH / 2,\n          background: AURORA[0],\n          color: p.tagInk,\n          fontFamily: mono,\n          fontWeight: 500,\n          fontSize: tagFont,\n          letterSpacing: \"0.02em\",\n          fontVariantNumeric: \"tabular-nums\",\n          whiteSpace: \"nowrap\",\n          lineHeight: 1,\n        }}\n      >\n        <span style={{ opacity: 0.62 }}>{symbol}</span>\n        <span>{live.toFixed(2)}</span>\n        <svg\n          width={0.62 * tagFont}\n          height={0.54 * tagFont}\n          viewBox=\"0 0 10 8.66\"\n          aria-hidden\n          style={{ display: \"block\" }}\n        >\n          <path d=\"M5 0 L10 8.66 L0 8.66 Z\" fill={p.tagInk} />\n        </svg>\n      </div>\n\n      {/* the slam */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: W * 0.058,\n          top: H * 0.255,\n          fontFamily: display,\n          fontWeight: 500,\n          fontSize: S,\n          lineHeight: 0.96,\n          letterSpacing: \"-0.012em\",\n          textTransform: \"uppercase\",\n          color: p.fg,\n          whiteSpace: \"nowrap\",\n        }}\n      >\n        <div\n          style={{\n            opacity: Math.min(1, slam1 * 2.5),\n            transform: `scale(${1.28 - 0.28 * slam1})`,\n            transformOrigin: \"0% 60%\",\n          }}\n        >\n          {headline}\n        </div>\n        <div\n          style={{\n            opacity: Math.min(1, slam2 * 2.5),\n            transform: `scale(${1.28 - 0.28 * slam2})`,\n            transformOrigin: \"0% 60%\",\n          }}\n        >\n          {headline2}\n        </div>\n      </div>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/candle-rally.tsx"
    }
  ],
  "type": "registry:component"
}
