{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"logo-flicker","type":"registry:component","title":"Logo Flicker","description":"Logo reveal intro: a fast image flicker that settles on your logo. Images flip across a central card very fast, the flicker decelerates and fades, and the logo and brand name resolve underneath — a strobe of imagery settling onto the mark.","dependencies":["remotion"],"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>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json"],"files":[{"path":"components/kuchi/logo-flicker.tsx","type":"registry:component","target":"components/kuchi/logo-flicker.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport {\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  Img,\r\n  interpolate,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\n/**\r\n * A Marvel-Studios-style flicker reveal: images flip full-screen at a constant\r\n * fast rate right to the end, then cross-fade — the flicker fading OUT while the\r\n * logo and brand name fade IN, together, in one move.\r\n */\r\n\r\nexport interface LogoFlickerProps {\r\n  /** The logo mark (simple/monochrome — it resolves over the dark backdrop). */\r\n  logoSrc?: string;\r\n  /** Brand name shown under the logo. */\r\n  brandName?: string;\r\n  /** Image pool the flicker flips through, full-screen. */\r\n  images?: string[];\r\n  /** Frames each image holds — the (constant) flip speed. */\r\n  flipInterval?: number;\r\n  /** Backdrop color. Overrides the design system's `background`. */\r\n  background?: string;\r\n  speed?: number;\r\n  className?: string;\r\n  /** Design-system token overrides. */\r\n  theme?: Partial<KuchiTheme>;\r\n  /**\r\n   * Defaults to `\"dark\"`: the shipped `logoSrc` is a white mark, so the stage\r\n   * has to be dark for it to read. Pass `\"light\"` with a dark logo asset.\r\n   */\r\n  mode?: \"light\" | \"dark\";\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts`\r\n   * (\"Inter\", \"Space Grotesk\", \"Instrument Serif\") or a CSS family you have\r\n   * loaded yourself. Unset, the scene keeps the face it was designed around.\r\n   *\r\n   * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole\r\n   * timeline from one value.\r\n   */\r\n  fontFamily?: string;\r\n}\r\n\r\nconst FONT_FAMILY =\r\n  'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif';\r\n\r\n/** Sample images. Absolute, because a root-relative default becomes\r\n *  `staticFile()` in a render and 404s in the project this file was just\r\n *  copied into. Pass your own — root-relative or remote, both resolve. */\r\nconst DEFAULT_IMAGES = [\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n];\r\n\r\n// ─── Timeline (frames @ 30fps; ~3.5s) ──────────────────────────────────────────\r\n/** Default frames per image — the flip speed, held constant to the very end. */\r\nexport const FLIP_INTERVAL = 2;\r\n/**\r\n * The single cross-fade window: the flicker fades OUT and the logo + name fade\r\n * IN across exactly these frames — simultaneously, not one after the other.\r\n */\r\nexport const FADE_START = 66;\r\nexport const FADE_END = 84;\r\n\r\nexport const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);\r\nconst CLAMP = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\r\n\r\n/**\r\n * Which image shows at `frame`. A constant `interval` (no deceleration) and a\r\n * coprime stride so it hops through the whole pool as it flips.\r\n */\r\nexport function flickerImage(\r\n  frame: number,\r\n  count: number,\r\n  interval: number = FLIP_INTERVAL,\r\n): number {\r\n  const n = Math.max(1, count);\r\n  const step = Math.floor(frame / Math.max(1, interval));\r\n  return (step * 7) % n;\r\n}\r\n\r\n/** Flicker opacity — solid, then fades out across the cross-fade window. */\r\nexport function flickerOpacity(frame: number): number {\r\n  return interpolate(frame, [FADE_START, FADE_END], [1, 0], CLAMP);\r\n}\r\n\r\n/** Logo + name opacity — the INVERSE of the flicker, on the SAME window. */\r\nexport function revealOpacity(frame: number): number {\r\n  return interpolate(frame, [FADE_START, FADE_END], [0, 1], CLAMP);\r\n}\r\n\r\n/** A small settle on the lockup as it fades in (shared by logo and name). */\r\nexport function revealScale(frame: number): number {\r\n  return interpolate(frame, [FADE_START, FADE_END], [0.92, 1], {\r\n    ...CLAMP,\r\n    easing: EASE,\r\n  });\r\n}\r\n\r\n/** Rewrite root-relative assets through staticFile everywhere but the Player. */\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base\r\n  // (`/static-<hash>/…`); running it through again would prefix it twice.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\nexport function LogoFlicker({\r\n  logoSrc = \"https://kuchi-media.kalarislabs.com/components/art/mark-white.svg\",\r\n  brandName = \"kuchi\",\r\n  images = DEFAULT_IMAGES,\r\n  flipInterval = FLIP_INTERVAL,\r\n  background,\r\n  speed = 1,\r\n  className,\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n}: LogoFlickerProps) {\r\n  const frame = useCurrentFrame() * speed;\r\n  const { width, height } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode ?? \"dark\");\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? FONT_FAMILY;\r\n  const stage = background ?? t.background;\r\n  const short = Math.min(width, height);\r\n  const isRendering = getRemotionEnvironment().isRendering;\r\n\r\n  const flkOpacity = flickerOpacity(frame);\r\n  const reveal = revealOpacity(frame);\r\n  const scale = revealScale(frame);\r\n  const imgIdx = flickerImage(frame, images.length, flipInterval);\r\n\r\n  const logoSize = Math.round(short * 0.15);\r\n  const nameSize = Math.round(short * 0.055);\r\n\r\n  return (\r\n    <div\r\n      className={className}\r\n      style={{\r\n        position: \"absolute\",\r\n        inset: 0,\r\n        overflow: \"hidden\",\r\n        backgroundColor: stage,\r\n        fontFamily: face,\r\n        textRendering: \"geometricPrecision\",\r\n      }}\r\n    >\r\n      {/* Full-screen flicker */}\r\n      {flkOpacity > 0 && (\r\n        <Img\r\n          src={resolveSrc(images[imgIdx] ?? images[0])}\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            width: \"100%\",\r\n            height: \"100%\",\r\n            maxWidth: \"none\",\r\n            objectFit: \"cover\",\r\n            opacity: flkOpacity,\r\n            ...(isRendering ? {} : { willChange: \"opacity\" as const }),\r\n          }}\r\n        />\r\n      )}\r\n\r\n      {/* Logo + brand name — fade IN on the same window the flicker fades OUT */}\r\n      {reveal > 0 && (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            display: \"flex\",\r\n            flexDirection: \"column\",\r\n            alignItems: \"center\",\r\n            justifyContent: \"center\",\r\n            gap: Math.round(short * 0.02),\r\n            opacity: reveal,\r\n            transform: `scale(${scale})`,\r\n            transformOrigin: \"center center\",\r\n          }}\r\n        >\r\n          <Img\r\n            src={resolveSrc(logoSrc)}\r\n            style={{\r\n              width: logoSize,\r\n              height: logoSize,\r\n              maxWidth: \"none\",\r\n              objectFit: \"contain\",\r\n            }}\r\n          />\r\n          <div\r\n            style={{\r\n              color: t.foreground,\r\n              fontSize: nameSize,\r\n              fontWeight: 600,\r\n              letterSpacing: \"-0.02em\",\r\n            }}\r\n          >\r\n            {brandName}\r\n          </div>\r\n        </div>\r\n      )}\r\n    </div>\r\n  );\r\n}\r\n"}]}