{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lights-out",
  "title": "Lights Out",
  "description": "Five lights go out and a heavy italic headline slams in, with a blue period.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/lights-out/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Unbounded\";\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});\n\nexport interface LightsOutProps {\n  /** Headline that slams in the instant the lights go out. Set in caps. */\n  title?: string;\n  /** Frames between two lights coming on. */\n  beat?: number;\n  /** Frames all five lights stay lit before they go out together. */\n  hold?: number;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// Unbounded 500, per 1000 em, chars 32–126 then ’ “ ” … – — (harfbuzz): advance,\n// left and right side bearing, and the caps/punctuation kerning pairs.\nconst ADV = [\n  256, 302, 464, 842, 788, 1252, 909, 252, 361, 361, 528, 620, 282, 361, 279,\n  440, 909, 495, 812, 821, 832, 791, 841, 728, 873, 841, 311, 316, 620, 620,\n  620, 679, 1031, 928, 865, 923, 911, 780, 755, 955, 924, 323, 792, 851, 751,\n  1206, 954, 956, 796, 957, 830, 823, 801, 870, 910, 1338, 832, 897, 791, 407,\n  440, 407, 620, 482, 346, 806, 799, 743, 808, 722, 563, 796, 757, 293, 293,\n  714, 293, 1182, 766, 778, 800, 800, 530, 719, 579, 754, 742, 1120, 682, 746,\n  672, 440, 298, 440, 620, 277, 510, 514, 783, 652, 1182,\n];\nconst LSB = [\n  0, 54, 43, 44, 38, 25, 33, 43, 39, 23, 38, 30, 38, 57, 41, 15, 46, 11, 38, 32,\n  24, 32, 47, 11, 46, 44, 58, 57, 29, 30, 31, 17, 36, 4, 53, 41, 77, 53, 77, 41,\n  77, 77, 21, 77, 77, 77, 77, 40, 77, 40, 77, 37, 17, 67, 4, 12, -8, 11, 41, 72,\n  15, 31, 35, -26, 29, 36, 63, 33, 36, 33, 19, 34, 63, 44, 44, 63, 63, 36, 36,\n  33, 63, 35, 36, 27, 5, 55, 5, 7, -9, 9, 38, 33, 77, 32, 30, 52, 34, 52, 41,\n  56, 56,\n];\nconst RSB = [\n  256, 54, 44, 44, 39, 24, -10, 43, 23, 39, 38, 30, 43, 57, 41, 15, 46, 81, 43,\n  47, 31, 39, 44, 27, 46, 46, 58, 60, 31, 30, 29, 24, 32, 4, 36, 34, 40, 52, 37,\n  59, 77, 76, 67, -3, 18, 76, 76, 40, 22, 41, 28, 37, 18, 67, 4, 12, -8, 12, 41,\n  31, 15, 72, 34, -26, 29, 49, 35, 27, 26, 35, 0, 60, 55, 45, 45, -5, 63, 55,\n  55, 34, 35, 62, 14, 33, 26, 36, 5, 8, -10, 4, 38, 32, 76, 32, 30, 29, 42, 28,\n  41, 56, 56,\n];\nconst KERN = new Map(\n  [\n    \"AC-43 AG-43 AJ-26 AO-43 AQ-43 AS-37 AT-126 AU-44 AV-125 AW-65 AY-156\",\n    \"AZ-7 A0-40 A1-77 A2-10 A3-22 A4-20 A5-22 A6-38 A7-56 A8-22 A9-31\",\n    \"A:-16 A?-78 A--58 A'-101 A’-94 A–-58 A—-58 BA-36 BC-1 BG-1 BO-1 BQ-1\",\n    \"BT-29 BV-38 BW-25 BX-34 BY-65 BZ-6 B1-8 B7-10 B?-5 CA-37 CB-2 CE-2\",\n    \"CT-32 CV-37 CW-22 CX-57 CY-72 CZ-14 C1-4 C7-10 C.-27 C,-27 C…-27\",\n    \"DA-45 DB-8 DE-8 DT-35 DV-45 DW-25 DX-66 DY-93 DZ-21 D1-12 D7-22 D.-37\",\n    \"D,-37 D…-37 EA-15 EC-12 EG-12 EJ-8 EO-12 EQ-12 ET-11 EV-18 EW-8 EY-27\",\n    \"E4-4 FA-65 FC-8 FG-8 FJ-6 FO-8 FQ-8 FS-9 FV-1 FX-12 FY-15 F2-6 F4-14\",\n    \"F.-103 F,-103 F…-103 GA-14 GT-33 GV-50 GW-28 GY-94 G1-14 G7-19 G'-11\",\n    \"G’-10 JA-40 JX-2 J.-29 J,-29 J…-29 KC-47 KG-47 KJ-41 KO-47 KQ-47\",\n    \"KS-27 KX3 K0-30 K3-7 K4-17 K5-4 K6-28 K78 K8-7 K9-14 K!5 K?-22 K--69\",\n    \"K'5 K–-69 K—-69 LC-39 LG-39 LJ-17 LO-39 LQ-39 LS-25 LT-153 LU-34\",\n    \"LV-137 LW-89 LX7 LY-167 L0-25 L1-82 L3-4 L4-7 L5-5 L6-23 L7-52 L8-4\",\n    \"L9-13 L?-84 L--89 L'-119 L’-120 L–-89 L—-89 OA-43 OB-8 OE-8 OT-35\",\n    \"OV-43 OW-24 OX-61 OY-87 OZ-19 O1-10 O7-20 O.-35 O,-35 O…-35 PA-90\",\n    \"PB-1 PE-1 PJ-6 PT-10 PV-25 PW-12 PX-62 PY-41 PZ-11 P4-35 P.-114\",\n    \"P,-114 P?24 P&-18 P…-114 QA-43 QB-8 QE-8 QT-35 QV-43 QW-24 QX-55\",\n    \"QY-87 QZ-19 Q1-10 Q7-20 Q.-35 Q,-33 Q…-35 RA-16 RC-7 RG-7 RJ-23 RO-7\",\n    \"RQ-7 RS-2 RT-24 RU-2 RV-37 RW-24 RX-5 RY-58 R0-1 R4-36 R5-7 R6-1 R8-5\",\n    \"R&-5 R--15 R–-15 R—-15 SA-36 SB-1 SE-1 ST-28 SV-38 SW-27 SX-44 SY-63\",\n    \"SZ-6 S7-4 TA-126 TC-35 TG-35 TJ-134 TO-35 TQ-35 TS-21 T0-24 T17 T2-7\",\n    \"T3-8 T4-102 T5-14 T6-23 T78 T8-10 T9-5 T.-128 T,-128 T:-79 T?4 T&-35\",\n    \"T--112 T…-128 T–-112 T—-112 UA-44 UX-2 U.-33 U,-33 U…-33 VA-125 VC-43\",\n    \"VG-43 VJ-84 VO-43 VQ-43 VS-37 VZ-9 V0-40 V1-2 V2-24 V3-29 V4-87 V5-29\",\n    \"V6-39 V712 V8-30 V9-24 V.-122 V,-122 V:-56 V!6 V?-15 V&-51 V--73 V'6\",\n    \"V’-5 V…-122 V–-73 V—-73 WA-65 WC-24 WG-24 WJ-25 WO-24 WQ-24 WS-26\",\n    \"W0-22 W2-9 W3-15 W4-54 W5-19 W6-21 W74 W8-17 W9-13 W.-86 W,-86 W:-32\",\n    \"W!3 W&-37 W--43 W'3 W…-86 W–-43 W—-43 XC-61 XG-61 XJ-57 XO-61 XQ-61\",\n    \"XS-44 XU-2 XX1 XY-5 X0-37 X3-12 X4-28 X5-10 X6-34 X8-10 X9-17 X!4\",\n    \"X?-23 X&-4 X--77 X'4 X–-77 X—-77 YA-157 YC-88 YG-88 YJ-136 YO-88\",\n    \"YQ-88 YS-51 YT-1 YX-5 YY-6 YZ-20 Y0-76 Y1-11 Y2-48 Y3-60 Y4-134 Y5-47\",\n    \"Y6-74 Y72 Y8-58 Y9-50 Y.-136 Y,-136 Y:-101 Y!5 Y?-31 Y&-72 Y--128\",\n    \"Y'-3 Y’-29 Y…-136 Y–-128 Y—-128 ZA-7 ZC-19 ZG-19 ZJ-18 ZO-19 ZQ-19\",\n    \"ZS-5 ZV-9 ZY-19 Z0-14 Z4-4 Z6-13 Z--43 Z–-43 Z—-43 0A-42 0B-6 0E-6\",\n    \"0T-28 0V-43 0W-23 0X-38 0Y-75 0Z-16 01-8 07-16 0.-31 0,-31 0…-31 1A-4\",\n    \"1V-5 1Y-17 2A-4 2C-1 2G-1 2J-4 2O-1 2Q-1 2T-9 2V-32 2W-19 2Y-62 2--17\",\n    \"2–-17 2—-17 3A-24 3T-9 3V-28 3W-16 3X-13 3Y-55 4A-20 4T-45 4V-57\",\n    \"4W-43 4X-17 4Y-73 41-35 42-6 47-35 4'-40 4’-37 5A-23 5T-14 5V-25\",\n    \"5W-16 5X-9 5Y-37 51-7 52-4 57-6 6A-24 6T-13 6V-33 6W-18 6X-17 6Y-63\",\n    \"67-4 7A-95 7C-16 7G-16 7J-58 7O-16 7Q-16 70-9 74-75 75-8 76-8 7.-122\",\n    \"7,-122 7--55 7…-122 7–-55 7—-55 8A-22 8T-11 8V-32 8W-18 8X-12 8Y-61\",\n    \"87-4 9A-41 9B-6 9E-6 9T-25 9V-41 9W-23 9X-37 9Y-73 9Z-15 91-7 97-14\",\n    \"9.-25 9,-25 9…-25 .C-35 .G-35 .J-8 .O-35 .Q-35 .S-8 .T-128 .U-33\",\n    \".V-122 .W-86 .Y-135 .0-31 .1-92 .6-25 .7-57 .9-16 .?-88 .--77 .'-126\",\n    \".’-127 .–-77 .—-77 ,C-35 ,G-35 ,J-8 ,O-35 ,Q-35 ,S-8 ,T-128 ,U-33\",\n    \",V-122 ,W-86 ,Y-135 ,0-31 ,1-92 ,6-25 ,7-57 ,9-16 ,?-88 ,--77 ,'-126\",\n    \",’-127 ,–-77 ,—-77 :A-16 :T-79 :V-56 :W-32 :Y-101 ??15 &A19 &J-5\",\n    \"&S-17 &T-67 &U-16 &V-55 &W-28 &X32 &Y-81 &'-56 &’-55 -A-58 -B-17\",\n    \"-E-17 -T-112 -V-73 -W-43 -X-77 -Y-128 -Z-45 -1-64 -2-18 -7-46 -.-77\",\n    \"-,-77 -'-13 -…-77 'A-101 'J-76 'V6 'W3 'X4 'Y5 '4-79 '.-126 ',-126\",\n    \"'&-30 '--13 '…-126 '–-13 '—-13 ’A-107 ’C-11 ’G-11 ’J-99 ’O-11 ’Q-11\",\n    \"’T2 ’Y-15 ’112 ’4-92 ’712 ’.-138 ’,-138 ’:-24 ’?4 ’&-28 ’--38 ’…-138\",\n    \"’–-38 ’—-38 …C-35 …G-35 …J-8 …O-35 …Q-35 …S-8 …T-128 …U-33 …V-122\",\n    \"…W-86 …Y-135 …0-31 …1-92 …6-25 …7-57 …9-16 …?-88 …--77 …'-126 …’-127\",\n    \"…–-77 …—-77 –A-58 –B-17 –E-17 –T-112 –V-73 –W-43 –X-77 –Y-128 –Z-45\",\n    \"–1-64 –2-18 –7-46 –.-77 –,-77 –'-13 –…-77 —A-58 —B-17 —E-17 —T-112\",\n    \"—V-73 —W-43 —X-77 —Y-128 —Z-45 —1-64 —2-18 —7-46 —.-77 —,-77 —'-13\",\n    \"—…-77\",\n  ]\n    .join(\" \")\n    .split(\" \")\n    .map((p) => [p.slice(0, 2), Number(p.slice(2)) / 1000] as const),\n);\nconst CAP = 0.75;\n/** Oblique slant, degrees: Unbounded has no italic, so the word is sheared. */\nconst SLANT = 11;\n\n// Beat sheet (30fps, speed 1, beat 10, hold 24):\n//  0–10    five dim discs on a thin rail, the row creeping closer (slow push)\n//  10–50   the lamps come on one by one, one every 10 frames, hard on; each\n//          one warms the \"rise\" ground glow from below a step more\n//  50–74   all five lit, the push keeps tightening\n//  74      lights out: all five go dark and the glow dies on the same frame;\n//          the headline is already halfway in from the left, cut into lagging\n//          bands that drag solid extrusions of themselves (a flat smear frame)\n//  74–78   the headline brakes to a hard stop and the bands line up; the dark\n//          row snaps up and shrinks to sit above it\n//  78–     poster hold, the ground glow comes back low under the headline\nconst FIRST_LIGHT = 10;\nconst SLAM_LEN = 5;\nconst RISE_LEN = 9;\n\nconst SLAM = Easing.bezier(0.22, 1, 0.36, 1);\nconst RISE = Easing.bezier(0.2, 0.9, 0.3, 1);\nconst PUSH = Easing.bezier(0.5, 0, 0.75, 0.4);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#0A0A0B\",\n    ink: \"#F3F2EF\",\n    off: \"#26262B\",\n    rail: \"#1B1B1F\",\n    glow: [\"#FF8A3D\", \"#A3301A\", \"#2A0D0A\"],\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    off: \"#DCDAD3\",\n    rail: \"#E6E4DE\",\n    glow: [\"#FF9F5E\", \"#FFC9A3\", \"#FBE6D6\"],\n  },\n} as const;\n\nconst EXTRA = \"’“”…–—\";\nfunction code(ch: string) {\n  const c = ch.charCodeAt(0);\n  if (c >= 32 && c < 127) return c - 32;\n  const x = EXTRA.indexOf(ch);\n  return x >= 0 ? 95 + x : 46;\n}\n\nfunction advance(text: string) {\n  let adv = 0;\n  for (let i = 0; i < text.length; i++) {\n    adv += ADV[code(text[i])] / 1000;\n    if (i > 0) adv += KERN.get(text[i - 1] + text[i]) ?? 0;\n  }\n  return adv;\n}\n\n/** Pen offsets of each glyph, in em, kerned. */\nfunction penOffsets(text: string) {\n  const out: number[] = [];\n  let pen = 0;\n  for (let i = 0; i < text.length; i++) {\n    if (i > 0) pen += KERN.get(text[i - 1] + text[i]) ?? 0;\n    out.push(pen);\n    pen += ADV[code(text[i])] / 1000;\n  }\n  return out;\n}\n\nconst BANDS = 12;\n// Lag of each band, 0–1: tuned by eye so the bands read as streaks, not noise.\nconst LAGS = [0.55, 0.15, 0.85, 0.4, 1, 0.25, 0.7, 0.05, 0.9, 0.35, 0.6, 0.2];\n\nexport function LightsOut({\n  title = \"SHIP IT.\",\n  beat = 10,\n  hold = 24,\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: LightsOutProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const c = THEMES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const text = title.trim().toUpperCase() || \"GO\";\n  const lastLight = FIRST_LIGHT + 4 * beat;\n  const outAt = lastLight + hold;\n  const out = t >= outAt;\n\n  // Headline metrics: sized so its ink spans ~86% of the width.\n  const adv = advance(text);\n  const lsb = LSB[code(text[0])] / 1000;\n  const rsb = RSB[code(text[text.length - 1])] / 1000;\n  const inkEm = Math.max(0.5, adv - lsb - rsb);\n  const fs = Math.min((0.86 * W) / inkEm, (0.34 * H) / CAP);\n  const cap = CAP * fs;\n  const inkW = inkEm * fs;\n\n  // Lights: big row centered, small row parked above the headline.\n  const d = 0.105 * W;\n  const gap = 0.04 * W;\n  const rowW = 5 * d + 4 * gap;\n  const small = Math.min(0.36, (0.34 * inkW) / rowW);\n  const blockGap = 0.075 * H;\n  const blockH = d * small + blockGap + cap;\n  const top = (H - blockH) / 2;\n  const smallCy = top + (d * small) / 2;\n  const baseline = top + d * small + blockGap + cap;\n\n  const push = 1 + 0.06 * PUSH(interpolate(t, [0, outAt], [0, 1], CLAMP));\n  const rise = RISE(interpolate(t, [outAt, outAt + RISE_LEN], [0, 1], CLAMP));\n  const rowScale = push + (small - push) * rise;\n  const rowCy = H / 2 + (smallCy - H / 2) * rise;\n\n  // Slam: its clock starts a frame early, so on the out frame the headline is\n  // already halfway across, then it brakes hard.\n  const slamStart = outAt - 1;\n  // The shear pushes the cap line right; center the sheared ink, not the\n  // upright one.\n  const shear = Math.tan((SLANT * Math.PI) / 180);\n  const restX = (W - inkW) / 2 - lsb * fs - (shear * cap) / 2;\n  const from = restX - 0.62 * inkW - 0.12 * W;\n  const xAt = (f: number) =>\n    from +\n    (restX - from) *\n      SLAM(interpolate(f, [slamStart, slamStart + SLAM_LEN], [0, 1], CLAMP));\n  const x = xAt(t);\n  const velocity = x - xAt(t - 1);\n  const smear = Math.min(velocity * 1.15, 0.9 * W);\n\n  const pens = penOffsets(text);\n  const lastIsDot = /[.!]$/.test(text);\n  const glyphs = text.split(\"\").map((ch, i) => ({\n    ch,\n    dx: pens[i] * fs,\n    fill: lastIsDot && i === text.length - 1 ? accent : c.ink,\n  }));\n\n  const renderWord = (ox: number, key: string) => (\n    <g key={key}>\n      {glyphs.map((g, i) =>\n        g.ch === \" \" ? null : (\n          <text\n            key={i}\n            x={ox + g.dx}\n            y={baseline}\n            fill={g.fill}\n            fontFamily={display}\n            fontWeight={500}\n            fontSize={fs}\n            style={{ fontKerning: \"none\" }}\n          >\n            {g.ch}\n          </text>\n        ),\n      )}\n    </g>\n  );\n\n  // While it moves the word is cut into horizontal bands. Each band lags by\n  // its own amount and drags a solid extrusion of itself behind it: a flat\n  // smear frame, no blur. Once the velocity is gone the bands line up.\n  const bandTop = baseline - cap * 1.08;\n  const bandH = (cap * 1.16) / BANDS;\n  const moving = out && smear > 0.025 * W;\n  const step = 0.07 * fs;\n  const lights = Array.from({ length: 5 }, (_, i) => {\n    const on = !out && t >= FIRST_LIGHT + i * beat;\n    const cx = W / 2 + (i - 2) * (d + gap) * rowScale;\n    return { cx, on };\n  });\n  const r = (d / 2) * rowScale;\n  const slantT = `translate(0 ${baseline}) skewX(${-SLANT}) translate(0 ${-baseline})`;\n\n  // Ground: a warm \"rise\" glow from below that builds with every lamp, dies\n  // on lights out, and comes back low under the landed headline.\n  const lit = lights.reduce(\n    (acc, _, i) =>\n      acc +\n      RISE(\n        interpolate(\n          t,\n          [FIRST_LIGHT + i * beat, FIRST_LIGHT + i * beat + 6],\n          [0, 1],\n          CLAMP,\n        ),\n      ),\n    0,\n  );\n  const after = interpolate(t, [outAt + 4, outAt + 30], [0, 0.42], {\n    ...CLAMP,\n    easing: Easing.bezier(0.3, 0, 0.2, 1),\n  });\n  const glow = out ? after : lit / 5;\n  const g = c.glow;\n\n  return (\n    <AbsoluteFill style={{ background: c.stage }}>\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          opacity: glow,\n          background: `radial-gradient(75% 62% at 50% 122%, ${g[0]} 0%, ${g[1]} 30%, ${g[2]} 56%, transparent 82%)`,\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={text}\n      >\n        <rect\n          x={W / 2 - (rowW / 2 + gap * 0.9) * rowScale}\n          y={rowCy - 0.05 * d * rowScale}\n          width={(rowW + gap * 1.8) * rowScale}\n          height={0.1 * d * rowScale}\n          fill={c.rail}\n        />\n        {lights.map((l, i) => (\n          <circle\n            key={i}\n            cx={l.cx}\n            cy={rowCy}\n            r={r}\n            fill={l.on ? `url(#${uid}-lamp)` : c.off}\n          />\n        ))}\n        <defs>\n          {/* Lamp lens: concentric, centered, so it reads as a flat light and\n              not a lit sphere. */}\n          <radialGradient id={`${uid}-lamp`} cx=\"0.5\" cy=\"0.5\" r=\"0.5\">\n            <stop offset=\"0\" stopColor=\"#FFF1E2\" />\n            <stop offset=\"0.22\" stopColor=\"#FFC08A\" />\n            <stop offset=\"0.55\" stopColor=\"#FF8A3D\" />\n            <stop offset=\"0.92\" stopColor=\"#D2502A\" />\n            <stop offset=\"1\" stopColor=\"#A3301A\" />\n          </radialGradient>\n          {Array.from({ length: BANDS }, (_, k) => (\n            <clipPath key={k} id={`${uid}-b${k}`}>\n              <rect\n                x={0}\n                y={bandTop + k * bandH}\n                width={W}\n                height={bandH + 0.5}\n              />\n            </clipPath>\n          ))}\n        </defs>\n        <g transform={slantT}>\n          {moving\n            ? Array.from({ length: BANDS }, (_, k) => {\n                const lag = LAGS[k % LAGS.length];\n                // Only the long-lag bands streak; the rest just slip, so the\n                // letterforms still read through the smear.\n                const head = x - smear * lag * 0.3;\n                const tail = lag > 0.5 ? smear * lag * 0.85 : 0;\n                const n = Math.min(18, Math.ceil(tail / step));\n                return (\n                  <g key={k} clipPath={`url(#${uid}-b${k})`}>\n                    {Array.from({ length: n + 1 }, (_, j) =>\n                      renderWord(\n                        head - (n ? (tail * (n - j)) / n : 0),\n                        `c${j}`,\n                      ),\n                    )}\n                  </g>\n                );\n              })\n            : null}\n          {out && !moving ? renderWord(x, \"w\") : null}\n        </g>\n      </svg>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/lights-out.tsx"
    }
  ],
  "type": "registry:component"
}
