{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "caption-redact",
  "title": "Caption Redact",
  "description": "The whole phrase starts blacked out like a declassified file, and each bar pulls away the moment its word is spoken.",
  "dependencies": ["remotion", "@remotion/captions"],
  "registryDependencies": ["@remocn/caption-core"],
  "files": [
    {
      "path": "registry/remocn/caption-redact/index.tsx",
      "content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate } from \"remotion\";\nimport {\n  type CaptionBaseProps,\n  captionWordText,\n  DEFAULT_HOLD_MS,\n  getExitWindowMs,\n  groupCaptionWords,\n  useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionRedactProps extends CaptionBaseProps {\n  barColor?: string;\n  shadow?: boolean;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst MIN_REVEAL_MS = 180;\nconst OVERHANG_EM = 0.06;\nconst RADIUS_EM = 0.06;\nconst BAR_TOP = \"14%\";\nconst BAR_BOTTOM = \"6%\";\nconst LEGIBILITY_SHADOW =\n  \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\nconst revealEasing = Easing.inOut(Easing.cubic);\n\nconst clamp = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionRedact({\n  captions,\n  combineTokensWithinMilliseconds = 1200,\n  holdMs = DEFAULT_HOLD_MS,\n  fontSize = 64,\n  fontWeight = 800,\n  color = \"#ffffff\",\n  barColor = \"#0a0a0a\",\n  shadow = true,\n  className,\n}: CaptionRedactProps) {\n  const state = useCaptions({\n    captions,\n    combineTokensWithinMilliseconds,\n    holdMs,\n  });\n  if (!state) return null;\n\n  const enter = interpolate(\n    state.previous ? ENTER_MS : state.sinceStartMs,\n    [0, ENTER_MS],\n    [0, 1],\n    { ...clamp, easing: enterEasing },\n  );\n  const exit = state.endsInSilence\n    ? interpolate(\n        state.untilEndMs,\n        [0, getExitWindowMs(state, EXIT_MS)],\n        [0, 1],\n        clamp,\n      )\n    : 1;\n  const textShadow = shadow ? LEGIBILITY_SHADOW : undefined;\n\n  return (\n    <div\n      className={className}\n      style={{\n        fontSize,\n        fontWeight,\n        color,\n        lineHeight: 1.2,\n        textAlign: \"center\",\n        opacity: Math.min(enter, exit),\n        transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n      }}\n    >\n      {groupCaptionWords(state.tokens).map((word, w) => {\n        const fromMs = word[0].token.fromMs;\n        const toMs = word[word.length - 1].token.toMs;\n        const revealMs = Math.max(toMs - fromMs, MIN_REVEAL_MS);\n        const revealed = interpolate(\n          state.timeMs - fromMs,\n          [0, revealMs],\n          [0, 1],\n          { ...clamp, easing: revealEasing },\n        );\n        return (\n          <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n            {w > 0 && \" \"}\n            <span\n              style={{\n                position: \"relative\",\n                display: \"inline-block\",\n                whiteSpace: \"nowrap\",\n              }}\n            >\n              <span\n                style={{\n                  textShadow,\n                  visibility: revealed > 0 ? \"visible\" : \"hidden\",\n                  clipPath:\n                    revealed >= 1\n                      ? undefined\n                      : `inset(-50% ${(1 - revealed) * 100}% -50% -50%)`,\n                }}\n              >\n                {captionWordText(word)}\n              </span>\n              {revealed < 1 && (\n                <span\n                  aria-hidden\n                  style={{\n                    position: \"absolute\",\n                    left: `-${OVERHANG_EM}em`,\n                    right: `-${OVERHANG_EM}em`,\n                    top: BAR_TOP,\n                    bottom: BAR_BOTTOM,\n                    background: barColor,\n                    borderRadius: `${RADIUS_EM}em`,\n                    transformOrigin: \"right center\",\n                    transform: `scaleX(${1 - revealed})`,\n                  }}\n                />\n              )}\n            </span>\n          </Fragment>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/caption-redact.tsx"
    }
  ],
  "type": "registry:component"
}
