{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cover-ring",
  "title": "Cover Ring",
  "description": "An audio-style bar meter sits above the line \"They're composed\" over green light.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "registryDependencies": ["@remocn/gsh"],
  "files": [
    {
      "path": "registry/remocn/cover-ring/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/Newsreader\";\nimport {\n  AbsoluteFill,\n  Easing,\n  Img,\n  interpolate,\n  random,\n  spring,\n  staticFile,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst geist = loadFont(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst newsreader = loadSerif(\"italic\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface CoverRingProps {\n  images?: string[];\n  line?: string;\n  caption?: string;\n  theme?: \"dark\" | \"light\";\n  background?: string;\n  ink?: string;\n  accent?: string;\n  fog?: string[];\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n}\n\nconst THEMES = {\n  dark: {\n    background: \"#010605\",\n    ink: \"#ecfff7\",\n    accent: \"#8ff0cc\",\n    ground: \"kiruna\" as GshPresetId | undefined,\n    groundParams: undefined as Partial<GradientParams> | undefined,\n    shadowRgb: \"0,8,6\",\n    edge: \"rgba(4,22,18,0.9)\",\n    scrim: \"rgba(1,8,6,0.55)\",\n  },\n  light: {\n    background: \"#eef3f0\",\n    ink: \"#0f241d\",\n    accent: \"#0f8a6c\",\n    ground: undefined as GshPresetId | undefined,\n    groundParams: {\n      kind: \"aurora\",\n      background: \"#eef3f0\",\n      colors: [\"#0e9a7e\", \"#55e6bd\", \"#bfeede\", \"#e4f2ec\"],\n      scale: 0.75,\n      warp: 0.45,\n      grain: 0.12,\n      seed: 106,\n    } as Partial<GradientParams> | undefined,\n    shadowRgb: \"18,70,56\",\n    edge: \"rgba(160,196,184,0.95)\",\n    scrim: \"rgba(240,246,243,0.6)\",\n  },\n};\n\nconst DEFAULT_IMAGES = [\n  \"templates/launch-anything/rocket.jpg\",\n  \"templates/brand-guidelines/ceramics.jpg\",\n  \"reel/reel-1.jpg\",\n  \"templates/product-showcase/sculpture.jpg\",\n  \"templates/launch-anything/earth.jpg\",\n  \"templates/brand-guidelines/chair.jpg\",\n  \"reel/reel-4.jpg\",\n  \"templates/launch-anything/desk.jpg\",\n  \"templates/product-showcase/courtyard.jpg\",\n  \"reel/reel-6.jpg\",\n];\n\nconst BEATS = [\n  { id: \"lineIn\", at: -6 },\n  { id: \"tilesIn\", at: 0 },\n  { id: \"lineOut\", at: 78 },\n  { id: \"collapse\", at: 78 },\n  { id: \"bars\", at: 96 },\n  { id: \"caption\", at: 100 },\n  { id: \"pulse\", at: 114 },\n  { id: \"end\", at: 150 },\n] as const;\nconst beat = (id: (typeof BEATS)[number][\"id\"]) =>\n  BEATS.find((b) => b.id === id)?.at ?? 0;\nconst COLLAPSE_LEN = 18;\n\nconst EASE_ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst EASE_EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst EASE_MOVE = Easing.bezier(0.83, 0, 0.17, 1);\nconst EASE_CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst SPRING_CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst SPRING_CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nfunction mix(color: string, pct: number) {\n  return `color-mix(in oklab, ${color} ${pct}%, transparent)`;\n}\n\nfunction enterTime(i: number) {\n  let t = beat(\"tilesIn\");\n  let step = 5;\n  for (let k = 0; k < i; k++) {\n    t += step;\n    step = Math.max(1.6, step * 0.8);\n  }\n  return Math.round(t);\n}\n\nfunction balance(text: string) {\n  const words = text.split(\" \");\n  if (text.length < 22 || words.length < 3) return [text];\n  let best = 1;\n  let bestCost = Number.POSITIVE_INFINITY;\n  for (let k = 1; k < words.length; k++) {\n    const a = words.slice(0, k).join(\" \").length;\n    const b = words.slice(k).join(\" \").length;\n    const cost = Math.max(a, b);\n    if (cost < bestCost) {\n      bestCost = cost;\n      best = k;\n    }\n  }\n  return [words.slice(0, best).join(\" \"), words.slice(best).join(\" \")];\n}\n\nfunction RevealWords({\n  text,\n  start,\n  frame,\n  stagger,\n  accentFrom,\n}: {\n  text: string;\n  start: number;\n  frame: number;\n  stagger: number;\n  accentFrom?: number;\n}) {\n  const words = text.split(\" \");\n  return (\n    <span\n      style={{\n        display: \"inline-flex\",\n        flexWrap: \"wrap\",\n        justifyContent: \"center\",\n        columnGap: \"0.24em\",\n      }}\n    >\n      {words.map((word, i) => {\n        const p = interpolate(\n          frame,\n          [start + i * stagger, start + i * stagger + 12],\n          [0, 1],\n          { ...CLAMP, easing: EASE_ENTER },\n        );\n        const accent = accentFrom !== undefined && i >= accentFrom;\n        return (\n          <span\n            key={`${word}-${i}`}\n            style={{\n              display: \"inline-block\",\n              overflow: \"hidden\",\n              padding: \"0.06em 0.06em 0.18em\",\n              margin: \"-0.06em -0.06em -0.18em\",\n            }}\n          >\n            <span\n              style={{\n                display: \"inline-block\",\n                transform: `translateY(${(1 - p) * 140}%)`,\n                filter: `blur(${(1 - p) * 6}px)`,\n                fontFamily: accent ? newsreader.fontFamily : undefined,\n                fontStyle: accent ? \"italic\" : undefined,\n                letterSpacing: accent ? \"-0.02em\" : undefined,\n              }}\n            >\n              {word}\n            </span>\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\nexport function CoverRing({\n  images,\n  line = \"Launch videos aren't edited anymore\",\n  caption = \"They're composed.\",\n  theme = \"dark\",\n  background,\n  ink,\n  accent,\n  fog,\n  ground,\n  groundParams,\n}: CoverRingProps) {\n  const frame = useCurrentFrame();\n  const { width: W, height: H, fps } = useVideoConfig();\n  const t = THEMES[theme];\n  const light = theme === \"light\";\n  const bg = background ?? t.background;\n  const fg = ink ?? t.ink;\n  const acc = accent ?? t.accent;\n  const preset = ground ?? (groundParams ? undefined : t.ground);\n  const gParams =\n    groundParams ??\n    (fog ? { ...(t.groundParams ?? {}), colors: fog } : t.groundParams);\n  const srcs =\n    images && images.length > 0 ? images : DEFAULT_IMAGES.map(staticFile);\n  const portrait = H > W;\n  const n = Math.max(6, Math.min(12, srcs.length));\n\n  const cx = W / 2;\n  const cy = H * (portrait ? 0.46 : 0.5);\n  const rx = portrait ? W * 0.39 : W * 0.33;\n  const ry = portrait ? H * 0.25 : H * 0.36;\n  const tilt = (-12 * Math.PI) / 180;\n  const tile = portrait ? W * 0.25 : W * 0.118;\n  const dot = portrait ? W * 0.05 : W * 0.026;\n  const dotGap = dot * 1.9;\n  const dots = 5;\n  const lineSize = portrait ? W * 0.062 : W * 0.034;\n  const capSize = portrait ? W * 0.12 : W * 0.074;\n  const capGap = portrait ? H * 0.035 : H * 0.06;\n  const barMax = portrait ? H * 0.09 : H * 0.17;\n  const liftAt = (f: number) =>\n    interpolate(\n      f,\n      [beat(\"bars\"), beat(\"bars\") + 14],\n      [0, (capSize * 1.1 + capGap) / 2],\n      { ...CLAMP, easing: Easing.bezier(0.65, 0, 0.35, 1) },\n    );\n\n  const collapseAt = (f: number) =>\n    interpolate(\n      f,\n      [beat(\"collapse\"), beat(\"collapse\") + COLLAPSE_LEN],\n      [0, 1],\n      { ...CLAMP, easing: EASE_MOVE },\n    );\n\n  const rotAt = (f: number) => {\n    const c = interpolate(\n      f,\n      [beat(\"collapse\"), beat(\"collapse\") + COLLAPSE_LEN],\n      [0, 1],\n      CLAMP,\n    );\n    return -0.4 + f * 0.0095 + c * c * 1.8;\n  };\n\n  const tileAt = (i: number, f: number) => {\n    const e0 = enterTime(i);\n    const land = spring({ frame: f - e0, fps, config: SPRING_CARD });\n    const q = collapseAt(f);\n    const theta = rotAt(f) + (i / n) * Math.PI * 2;\n    const ex = Math.cos(theta) * rx;\n    const ey = Math.sin(theta) * ry;\n    const rxp = ex * Math.cos(tilt) - ey * Math.sin(tilt);\n    const ryp = ex * Math.sin(tilt) + ey * Math.cos(tilt);\n    const depth = (Math.sin(theta) + 1) / 2;\n    const fly = 1 - land;\n    const jitter = random(`cr2-j-${i}`) - 0.5;\n    const ringX = cx + rxp * (1 + fly * 1.4) + fly * jitter * W * 0.25;\n    const ringY = cy + ryp * (1 + fly * 1.4) + fly * H * 0.12;\n    const k = i % dots;\n    const dx = cx + (k - (dots - 1) / 2) * dotGap;\n    const dy = cy - liftAt(f);\n    const x = ringX * (1 - q) + dx * q;\n    const y = ringY * (1 - q) + dy * q;\n    return { x, y, depth, theta, land, q, fly, jitter };\n  };\n\n  const barP = spring({\n    frame: frame - beat(\"bars\"),\n    fps,\n    config: SPRING_CHIP,\n  });\n  const pulse = interpolate(\n    frame,\n    [beat(\"pulse\"), beat(\"pulse\") + 5, beat(\"pulse\") + 18],\n    [0, 1, 0],\n    { ...CLAMP, easing: Easing.bezier(0.65, 0, 0.35, 1) },\n  );\n  const barHeights = [0.5, 0.82, 0.6, 1, 0.7];\n  const pulseHeights = [0.9, 0.46, 1, 0.58, 0.95];\n\n  const lineOut = interpolate(\n    frame,\n    [beat(\"lineOut\"), beat(\"lineOut\") + 8],\n    [0, 1],\n    { ...CLAMP, easing: EASE_EXIT },\n  );\n  const push = interpolate(frame, [0, beat(\"end\")], [1, 1.05], {\n    ...CLAMP,\n    easing: EASE_CAMERA,\n  });\n\n  const order = Array.from({ length: n }, (_, i) => i).sort(\n    (a, b) => tileAt(a, frame).depth - tileAt(b, frame).depth,\n  );\n\n  const captionWords = caption.split(\" \");\n\n  return (\n    <AbsoluteFill style={{ backgroundColor: bg, overflow: \"hidden\" }}>\n      <GshGround\n        preset={preset}\n        params={gParams}\n        timeOffset={light ? 3 : 4}\n        timeScale={0.8}\n      />\n      <AbsoluteFill\n        style={{\n          backgroundImage: `radial-gradient(${portrait ? \"60% 26%\" : \"36% 34%\"} at 50% ${(cy / H) * 100}%, ${t.scrim} 0%, transparent 74%)`,\n        }}\n      />\n      <svg width=\"0\" height=\"0\" style={{ position: \"absolute\" }} aria-hidden>\n        {order.map((i) => {\n          const now = tileAt(i, frame);\n          const prev = tileAt(i, frame - 1);\n          const vx = Math.min(9, Math.abs(now.x - prev.x) * 0.12);\n          const vy = Math.min(9, Math.abs(now.y - prev.y) * 0.12);\n          return (\n            <filter\n              key={`f-${i}`}\n              id={`cr2-mb-${i}`}\n              x=\"-25%\"\n              y=\"-25%\"\n              width=\"150%\"\n              height=\"150%\"\n            >\n              <feGaussianBlur stdDeviation={`${vx} ${vy}`} />\n            </filter>\n          );\n        })}\n      </svg>\n      <AbsoluteFill\n        style={{\n          transform: `scale(${push})`,\n          perspective: portrait ? 2200 : 1400,\n          perspectiveOrigin: `50% ${(cy / H) * 100}%`,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: cx - (portrait ? W * 0.34 : W * 0.2),\n            width: portrait ? W * 0.68 : W * 0.4,\n            top: cy,\n            height: 0,\n            display: \"flex\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            textAlign: \"center\",\n            fontFamily: geist.fontFamily,\n            fontWeight: 300,\n            fontSize: lineSize,\n            lineHeight: 1.1,\n            letterSpacing: \"-0.03em\",\n            color: fg,\n            opacity: 1 - lineOut,\n            transform: `scale(${1 - lineOut * 0.2})`,\n            filter: `blur(${lineOut * 8}px)`,\n            zIndex: 50,\n          }}\n        >\n          <div style={{ display: \"flex\", flexDirection: \"column\" }}>\n            {balance(line).map((row, r) => (\n              <RevealWords\n                key={row}\n                text={row}\n                start={beat(\"lineIn\") + r * 2 * row.split(\" \").length}\n                frame={frame}\n                stagger={2}\n              />\n            ))}\n          </div>\n        </div>\n        {order.map((i, z) => {\n          const s = tileAt(i, frame);\n          if (frame < enterTime(i)) return null;\n          const prev = tileAt(i, frame - 1);\n          const moving = Math.hypot(s.x - prev.x, s.y - prev.y) > 3;\n          const depthScale = 0.62 + 0.52 * s.depth;\n          const sizeRing = tile * depthScale * (1 + s.fly * 1.6);\n          const size = sizeRing * (1 - s.q) + dot * s.q;\n          const flat = 1 - s.q;\n          const rotY = -Math.cos(s.theta) * 28 * flat;\n          const rotX = (12 - Math.sin(s.theta) * 6) * flat;\n          const rotZ = (s.jitter * 16 + s.fly * s.jitter * 70) * flat;\n          const depthBlur = (1 - s.depth) * (light ? 4 : 5) * flat;\n          const fill = interpolate(s.q, [0.5, 0.92], [0, 1], CLAMP);\n          const enter = Math.min(1, Math.max(0, s.land) * 3);\n          const dim = light\n            ? 1 - (1 - s.depth) * 0.12 * flat\n            : (0.45 + 0.55 * s.depth) * flat + s.q;\n          const extra = i >= dots;\n          const fadeExtra = extra\n            ? interpolate(s.q, [0.72, 0.98], [1, 0], CLAMP)\n            : 1;\n          const barShape = !extra && frame >= beat(\"bars\");\n          const k = i % dots;\n          const hBar =\n            dot +\n            (barMax * (barHeights[k] ?? 0.7) - dot) * barP +\n            barMax *\n              ((pulseHeights[k] ?? 0.7) - (barHeights[k] ?? 0.7)) *\n              pulse;\n          const w = size;\n          const h = barShape ? hBar : size;\n          const radius = s.q > 0.6 ? Math.min(w, h) / 2 : size * 0.16;\n          const ex = -Math.cos(s.theta) * 0.035 * size * flat;\n          const ey = 0.04 * size * flat;\n          const edge = [1, 2, 3, 4]\n            .map(\n              (m) =>\n                `${(ex * m) / 4}px ${(ey * m) / 4}px 0 0 ${m === 4 ? t.edge : mix(t.edge, 70)}`,\n            )\n            .join(\", \");\n          const lift = size * (0.12 + 0.2 * s.depth) * flat;\n          const shadow =\n            s.q > 0.6\n              ? `0 0 ${dot * 1.2}px ${mix(acc, 50)}, 0 0 ${dot * 0.3}px ${mix(acc, 70)}`\n              : `${edge}, 0 ${lift * 0.3}px ${lift * 0.5}px rgba(${t.shadowRgb},0.28), 0 ${lift}px ${lift * 2.2}px rgba(${t.shadowRgb},0.38)`;\n          return (\n            <div\n              key={`cr-${i}`}\n              style={{\n                position: \"absolute\",\n                left: s.x - w / 2,\n                top: s.y - h / 2,\n                width: w,\n                height: h,\n                borderRadius: radius,\n                zIndex: z,\n                opacity: enter * fadeExtra,\n                transform: `rotateX(${rotX}deg) rotateY(${rotY}deg) rotateZ(${rotZ}deg)`,\n                filter: `${moving ? `url(#cr2-mb-${i}) ` : \"\"}blur(${depthBlur + Math.max(0, s.fly) * 8}px) brightness(${dim})`,\n                boxShadow: shadow,\n                backgroundColor: acc,\n              }}\n            >\n              <div\n                style={{\n                  position: \"absolute\",\n                  inset: 0,\n                  borderRadius: \"inherit\",\n                  overflow: \"hidden\",\n                  opacity: 1 - fill,\n                }}\n              >\n                <Img\n                  src={srcs[i % srcs.length] as string}\n                  style={{\n                    position: \"absolute\",\n                    inset: 0,\n                    width: \"100%\",\n                    height: \"100%\",\n                    objectFit: \"cover\",\n                  }}\n                />\n                <div\n                  style={{\n                    position: \"absolute\",\n                    inset: 0,\n                    borderRadius: \"inherit\",\n                    backgroundImage:\n                      \"linear-gradient(145deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 34%, rgba(0,0,0,0) 66%, rgba(0,0,0,0.24) 100%)\",\n                    boxShadow:\n                      \"inset 0 0 0 1px rgba(255,255,255,0.18), inset 0 1px 0 rgba(255,255,255,0.35)\",\n                  }}\n                />\n              </div>\n            </div>\n          );\n        })}\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            width: W,\n            top: cy - liftAt(frame) + barMax * 0.5 + capGap,\n            textAlign: \"center\",\n            fontFamily: geist.fontFamily,\n            fontSize: capSize,\n            letterSpacing: \"-0.045em\",\n            fontWeight: 300,\n            lineHeight: 1,\n            color: fg,\n          }}\n        >\n          <RevealWords\n            text={caption}\n            start={beat(\"caption\")}\n            frame={frame}\n            stagger={3}\n            accentFrom={Math.max(1, captionWords.length - 1)}\n          />\n        </div>\n      </AbsoluteFill>\n    </AbsoluteFill>\n  );\n}\n\nexport default CoverRing;\n",
      "type": "registry:component",
      "target": "components/remocn/cover-ring.tsx"
    }
  ],
  "type": "registry:component"
}
