{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"border-beam","type":"registry:component","title":"Border Beam","description":"A beam laps the border of a dark card, then reveals 'kuchi 2.0' with a logo and description.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>.","registryDependencies":["https://kuchi.kalarislabs.com/r/gradient-ground.json"],"files":[{"path":"components/kuchi/border-beam.tsx","type":"registry:component","target":"components/kuchi/border-beam.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadGeistMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { type CSSProperties, useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/kuchi/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/kuchi/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/kuchi/gsh/presets\";\n\nconst geist = loadGeist(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst geistMono = loadGeistMono(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"600\"],\n  subsets: [\"latin\"],\n});\n\n\nfunction KuchiLogo({ 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      <span>Acme</span>\n    </div>\n  );\n}\n\nexport interface BorderBeamProps {\n  title?: string;\n  description?: string;\n  command?: string;\n  showLogo?: boolean;\n  /** Replaces the acme mark at the top of the card. */\n  logo?: React.ReactNode;\n  accent?: string;\n  /** Text color of the title and command; overrides the theme. */\n  ink?: string;\n  /** Solid fill in place of the gradient ground; \"transparent\" drops it. */\n  background?: string;\n  /** Typeface for the title and description. Load it yourself; Geist by default. */\n  fontFamily?: string;\n  /** Frames for one lap of the beam around the card. */\n  lap?: number;\n  /** Size of the card, around the frame's center. */\n  scale?: number;\n  /** Frames to hold the first frame before anything moves. */\n  delay?: number;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n}\n\nconst THEMES = {\n  dark: {\n    card: \"rgba(9,9,10,0.9)\",\n    depth: \"0 2px 6px rgba(0,0,0,0.35), 0 30px 80px -20px rgba(0,0,0,0.7)\",\n    hair: \"rgba(255,255,255,0.1)\",\n    trail: \"rgba(255,255,255,0.1)\",\n    rule: \"rgba(255,255,255,0.08)\",\n    head: \"#FFFFFF\",\n    fg: \"#EDEDED\",\n    muted: \"#8F8F94\",\n    logo: \"#EDEDED\",\n    glow: 0.55,\n    ground: \"charcoal-satin\" as GshPresetId,\n    groundParams: {\n      colors: [\"#2c3036\", \"#7d838c\", \"#4f555e\"],\n    } as Partial<GradientParams> | undefined,\n  },\n  light: {\n    card: \"rgba(255,255,255,0.9)\",\n    depth:\n      \"0 1px 2px rgba(20,24,60,0.06), 0 30px 70px -24px rgba(20,24,60,0.22)\",\n    hair: \"rgba(10,10,10,0.1)\",\n    trail: \"rgba(10,10,10,0.1)\",\n    rule: \"rgba(10,10,10,0.07)\",\n    head: \"\",\n    fg: \"#0F0F10\",\n    muted: \"#6E6E73\",\n    logo: \"#0F0F10\",\n    glow: 0.3,\n    ground: \"paper-crease\" as GshPresetId,\n    groundParams: undefined as Partial<GradientParams> | undefined,\n  },\n};\n\nconst LAYERS = 28;\n\nconst EASE_ENTER = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_MOVE = Easing.bezier(0.65, 0, 0.35, 1);\nconst SPRING_HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst T = {\n  lapStart: 14,\n  lapDur: 80,\n  lag: 8,\n  contentStart: 84,\n  stagger: 5,\n  contentDur: 18,\n};\n\nfunction hexToRgb(hex: string): [number, number, number] {\n  const h = hex.replace(\"#\", \"\");\n  const n = Number.parseInt(\n    h.length === 3\n      ? h\n          .split(\"\")\n          .map((ch) => ch + ch)\n          .join(\"\")\n      : h.slice(0, 6),\n    16,\n  );\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nfunction mix(a: string, b: string, t: number) {\n  const ca = hexToRgb(a);\n  const cb = hexToRgb(b);\n  const ch = ca.map((v, i) => Math.round(v + (cb[i] - v) * t));\n  return `rgb(${ch[0]},${ch[1]},${ch[2]})`;\n}\n\n/** The foreground at `scale`, around the frame's center; nothing extra at 1. */\nfunction ScaleLayer({\n  scale,\n  children,\n}: {\n  scale: number;\n  children: React.ReactNode;\n}) {\n  if (scale === 1) return children;\n  return (\n    <AbsoluteFill style={{ transform: `scale(${scale})` }}>\n      {children}\n    </AbsoluteFill>\n  );\n}\n\nexport function BorderBeam({\n  title = \"Version 2.0\",\n  description = \"Launch videos, written in React. Installed like shadcn.\",\n  command = \"npx shadcn add @kuchi/launch-film\",\n  showLogo = true,\n  logo,\n  accent = \"#3B5BFD\",\n  ink,\n  background,\n  fontFamily = geist.fontFamily,\n  lap = T.lapDur,\n  scale = 1,\n  delay = 0,\n  speed = 1,\n  theme = \"dark\",\n  ground,\n  groundParams,\n}: BorderBeamProps) {\n  const frame = Math.max(0, useCurrentFrame() - delay) * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const fg = ink ?? c.fg;\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const portrait = H > W * 1.1;\n  const preset = ground ?? (groundParams ? undefined : c.ground);\n  const gParams = groundParams ?? (ground ? undefined : c.groundParams);\n\n  const w = portrait ? W * 0.84 : W * 0.6;\n  const h = portrait ? H * 0.36 : H * 0.52;\n  const r = portrait ? W * 0.03 : W * 0.0125;\n  const P = 2 * (w - 2 * r) + 2 * (h - 2 * r) + 2 * Math.PI * r;\n  const pad = portrait ? W * 0.07 : W * 0.034;\n  const mx = w / 2;\n  const d = [\n    `M ${mx} 0`,\n    `H ${w - r}`,\n    `A ${r} ${r} 0 0 1 ${w} ${r}`,\n    `V ${h - r}`,\n    `A ${r} ${r} 0 0 1 ${w - r} ${h}`,\n    `H ${r}`,\n    `A ${r} ${r} 0 0 1 0 ${h - r}`,\n    `V ${r}`,\n    `A ${r} ${r} 0 0 1 ${r} 0`,\n    \"Z\",\n  ].join(\" \");\n\n  const enter = spring({ frame, fps, config: SPRING_HEAVY });\n  const enterO = interpolate(frame, [0, 12], [0, 1], {\n    ...CLAMP,\n    easing: EASE_ENTER,\n  });\n  const lapAt = (start: number) =>\n    interpolate(frame, [start, start + lap], [0, P], {\n      ...CLAMP,\n      easing: EASE_MOVE,\n    });\n  const headD = lapAt(T.lapStart);\n  const tailD = lapAt(T.lapStart + T.lag);\n  const L = headD - tailD;\n\n  const head = c.head || accent;\n  const target = (m: number) =>\n    m > LAYERS ? 0 : Math.min(0.98, (1 - (m - 1) / LAYERS) ** 1.6);\n  const layers: { j: number; len: number; color: string; alpha: number }[] = [];\n  if (L > 0.5) {\n    for (let j = LAYERS; j >= 1; j--) {\n      const alpha = 1 - (1 - target(j)) / (1 - target(j + 1));\n      const tt = (j - 1) / (LAYERS - 1);\n      layers.push({\n        j,\n        len: (L * j) / LAYERS,\n        color:\n          theme === \"dark\"\n            ? mix(head, accent, Math.min(1, tt * 1.25))\n            : mix(accent, \"#0A0A0A\", 0.15 * (1 - tt)),\n        alpha,\n      });\n    }\n  }\n\n  const beamPaths = (strokeWidth: number) =>\n    layers.map((layer) => (\n      <path\n        key={layer.j}\n        d={d}\n        fill=\"none\"\n        stroke={layer.color}\n        strokeOpacity={layer.alpha}\n        strokeWidth={strokeWidth}\n        strokeDasharray={`${layer.len} ${P}`}\n        strokeDashoffset={-(headD - layer.len)}\n      />\n    ));\n\n  const item = (i: number): CSSProperties => {\n    const p = interpolate(\n      frame,\n      [\n        T.contentStart + i * T.stagger,\n        T.contentStart + i * T.stagger + T.contentDur,\n      ],\n      [0, 1],\n      { ...CLAMP, easing: EASE_ENTER },\n    );\n    return {\n      opacity: p,\n      filter: `blur(${(1 - p) * 6}px)`,\n      transform: `translateY(${(1 - p) * H * 0.02}px)`,\n    };\n  };\n\n  const s = Math.min(W / 1280, H / 720);\n  const titleFs = portrait ? W * 0.1 : W * 0.056;\n  const descFs = portrait ? W * 0.038 : H * 0.032;\n  const monoFs = portrait ? W * 0.03 : H * 0.025;\n  const logoFs = portrait ? W * 0.045 : H * 0.036;\n\n  return (\n    <AbsoluteFill style={{ overflow: \"hidden\" }}>\n      {background === undefined ? (\n        <GshGround\n          preset={preset}\n          params={gParams}\n          timeOffset={theme === \"light\" ? 3 : 5}\n          timeScale={0.4}\n        />\n      ) : (\n        <AbsoluteFill\n          style={{\n            background: background === \"transparent\" ? undefined : background,\n          }}\n        />\n      )}\n      <ScaleLayer scale={scale}>\n        <div\n          style={{\n            position: \"absolute\",\n            left: (W - w) / 2,\n            top: (H - h) / 2,\n            width: w,\n            height: h,\n            opacity: enterO,\n            transform: `translateY(${(1 - enter) * H * 0.04}px) scale(${0.97 + 0.03 * enter})`,\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              borderRadius: r,\n              backgroundColor: c.card,\n              boxShadow: c.depth,\n            }}\n          />\n          <svg\n            width={w}\n            height={h}\n            viewBox={`0 0 ${w} ${h}`}\n            style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n            aria-hidden\n          >\n            <defs>\n              <filter\n                id={`${uid}-glow`}\n                x={-40 * s}\n                y={-40 * s}\n                width={w + 80 * s}\n                height={h + 80 * s}\n                filterUnits=\"userSpaceOnUse\"\n              >\n                <feGaussianBlur stdDeviation={5 * s} />\n              </filter>\n            </defs>\n            <path d={d} fill=\"none\" stroke={c.hair} strokeWidth={1} />\n            {tailD > 0 ? (\n              <path\n                d={d}\n                fill=\"none\"\n                stroke={c.trail}\n                strokeWidth={1}\n                strokeDasharray={`${tailD} ${P}`}\n              />\n            ) : null}\n            <g filter={`url(#${uid}-glow)`} opacity={c.glow}>\n              {beamPaths(4 * s)}\n            </g>\n            <g>{beamPaths(Math.max(1, 1.5 * s))}</g>\n          </svg>\n\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              padding: pad,\n              display: \"flex\",\n              flexDirection: \"column\",\n              justifyContent: \"space-between\",\n            }}\n          >\n            <div style={{ ...item(0), minHeight: logoFs }}>\n              {showLogo\n                ? (logo ?? <KuchiLogo fontSize={logoFs} color={c.logo} />)\n                : null}\n            </div>\n            <div>\n              <div\n                style={{\n                  ...item(1),\n                  fontFamily,\n                  fontWeight: 400,\n                  fontSize: titleFs,\n                  letterSpacing: \"-0.045em\",\n                  lineHeight: 1,\n                  color: fg,\n                  whiteSpace: \"pre\",\n                }}\n              >\n                {title}\n              </div>\n              <div\n                style={{\n                  ...item(2),\n                  marginTop: titleFs * 0.32,\n                  fontFamily,\n                  fontWeight: 300,\n                  fontSize: descFs,\n                  letterSpacing: \"-0.01em\",\n                  lineHeight: 1.4,\n                  color: c.muted,\n                  maxWidth: w - pad * 2,\n                  textWrap: \"balance\",\n                }}\n              >\n                {description}\n              </div>\n              {command ? (\n                <div\n                  style={{\n                    ...item(3),\n                    marginTop: titleFs * 0.5,\n                    paddingTop: monoFs * 1.1,\n                    borderTop: `1px solid ${c.rule}`,\n                    display: \"flex\",\n                    gap: monoFs * 0.7,\n                    fontFamily: geistMono.fontFamily,\n                    fontWeight: 400,\n                    fontSize: monoFs,\n                    letterSpacing: \"-0.01em\",\n                    whiteSpace: \"pre\",\n                    color: fg,\n                  }}\n                >\n                  <span style={{ color: c.muted }}>$</span>\n                  <span style={{ flex: 1 }}>{command}</span>\n                  <svg\n                    width={monoFs * 1.1}\n                    height={monoFs * 1.1}\n                    viewBox=\"0 0 24 24\"\n                    fill=\"none\"\n                    stroke={c.muted}\n                    strokeWidth={1.5}\n                    strokeLinejoin=\"round\"\n                    aria-hidden\n                    style={{ alignSelf: \"center\" }}\n                  >\n                    <rect\n                      x=\"8.5\"\n                      y=\"8.5\"\n                      width=\"11\"\n                      height=\"11\"\n                      rx=\"2.5\"\n                      vectorEffect=\"non-scaling-stroke\"\n                    />\n                    <path\n                      d=\"M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2\"\n                      vectorEffect=\"non-scaling-stroke\"\n                    />\n                  </svg>\n                </div>\n              ) : null}\n            </div>\n          </div>\n        </div>\n      </ScaleLayer>\n    </AbsoluteFill>\n  );\n}\n"}]}