{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "measure-dim",
  "title": "Measure Dim",
  "description": "A gradient bar is measured by dimension lines as 184 fps overtakes 60 fps.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/measure-dim/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"400\", \"500\", \"600\"],\n  subsets: [\"latin\"],\n});\nconst display = manrope.fontFamily;\nconst { fontFamily: serif } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** Full logo as on remocn.dev: R mark (0.76em tall, baseline-aligned) + \"emocn\" in Manrope 600. */\nfunction RemocnLogo({ 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      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nexport interface MeasureDimProps {\n  subject?: React.ReactNode;\n  label?: string;\n  value?: string;\n  before?: string;\n  beforeLabel?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst SLIDE = Easing.bezier(0.45, 0, 0.12, 1);\n\nconst BAR_AT = 2;\nconst EXT_A = 16;\nconst ARR_A = 24;\nconst ARR_LEN = 26;\nconst GHOST_AT = ARR_A + ARR_LEN - 4;\nconst EXT_B = GHOST_AT + 10;\nconst ARR_B = GHOST_AT + 16;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    line: \"rgba(243,242,239,0.82)\",\n    ghost: \"rgba(243,242,239,0.42)\",\n    ghostFill: \"rgba(255,255,255,0.03)\",\n    sheen: 0.22,\n    tipStop: \"#E9ECFF\",\n    grain: 0.055,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    line: \"rgba(18,18,20,0.82)\",\n    ghost: \"rgba(18,18,20,0.42)\",\n    ghostFill: \"rgba(18,18,20,0.03)\",\n    sheen: 0.16,\n    tipStop: \"#A9AAFF\",\n    grain: 0.04,\n  },\n} as const;\n\nfunction parse(v: string) {\n  const m = v.match(/-?\\d[\\d,]*(\\.\\d+)?/);\n  if (!m || m.index === undefined) return null;\n  const n = Number.parseFloat(m[0].replace(/,/g, \"\"));\n  if (!Number.isFinite(n)) return null;\n  return {\n    n,\n    decimals: m[1] ? m[1].length - 1 : 0,\n    pre: v.slice(0, m.index),\n    post: v.slice(m.index + m[0].length),\n  };\n}\n\nfunction counted(v: string, k: number) {\n  const p = parse(v);\n  if (!p) return { num: v, unit: \"\" };\n  const n = (p.n * k).toFixed(p.decimals);\n  const [i, d] = n.split(\".\");\n  const grouped = Number(i).toLocaleString(\"en-US\");\n  return { num: `${p.pre}${grouped}${d ? `.${d}` : \"\"}`, unit: p.post.trim() };\n}\n\nfunction estimateEm(text: string) {\n  let w = 0;\n  for (const ch of text) {\n    if (ch === \" \") w += 0.25;\n    else if (\".,:;'!|/\".includes(ch)) w += 0.27;\n    else if (ch >= \"0\" && ch <= \"9\") w += 0.6;\n    else w += 0.52;\n  }\n  return w;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={23}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\ninterface DimProps {\n  x0: number;\n  x1: number;\n  y: number;\n  k: number;\n  value: string;\n  size: number;\n  color: string;\n  textColor: string;\n  unitColor: string;\n  u: number;\n}\n\nfunction Arrow({\n  side,\n  k,\n  color,\n  u,\n}: {\n  side: \"left\" | \"right\";\n  k: number;\n  color: string;\n  u: number;\n}) {\n  const head = 15 * u;\n  const wing = 5 * u;\n  const stroke = Math.max(1, 1.5 * u);\n  const headOp = interpolate(k, [0, 0.08], [0, 1], CLAMP);\n  const outer = side === \"left\" ? \"left\" : \"right\";\n  const inner = side === \"left\" ? \"right\" : \"left\";\n  return (\n    <div style={{ position: \"relative\", flex: 1, alignSelf: \"stretch\" }}>\n      <div\n        style={{\n          position: \"absolute\",\n          [inner]: 0,\n          top: \"50%\",\n          width: `${k * 100}%`,\n          height: 0,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            [outer]: head * 0.6,\n            [inner]: 0,\n            top: -stroke / 2,\n            height: stroke,\n            background: color,\n          }}\n        />\n        <svg\n          width={head}\n          height={wing * 2}\n          style={{\n            position: \"absolute\",\n            [outer]: 0,\n            top: -wing,\n            opacity: headOp,\n            transform: side === \"right\" ? \"scaleX(-1)\" : undefined,\n          }}\n          aria-hidden\n        >\n          <path\n            d={`M 0 ${wing} L ${head} 0 L ${head} ${wing * 2} Z`}\n            fill={color}\n          />\n        </svg>\n      </div>\n    </div>\n  );\n}\n\nfunction Dimension({\n  x0,\n  x1,\n  y,\n  k,\n  value,\n  size,\n  color,\n  textColor,\n  unitColor,\n  u,\n}: DimProps) {\n  if (k <= 0) return null;\n  const head = 15 * u;\n  const finalText = counted(value, 1);\n  const span = x1 - x0;\n  const inline =\n    span >\n    estimateEm(`${finalText.num} ${finalText.unit}`) * size + 2 * head + 72 * u;\n  const textOp = interpolate(k, [0, 0.18], [0, 1], CLAMP);\n  const now = counted(value, k);\n  const textRow = (txt: { num: string; unit: string }, hidden: boolean) => (\n    <div\n      style={{\n        gridArea: \"1 / 1\",\n        display: \"flex\",\n        alignItems: \"baseline\",\n        justifyContent: \"center\",\n        visibility: hidden ? \"hidden\" : \"visible\",\n      }}\n    >\n      <span style={{ fontVariantNumeric: \"tabular-nums\", color: textColor }}>\n        {txt.num}\n      </span>\n      {txt.unit ? (\n        <span\n          style={{\n            fontFamily: serif,\n            fontStyle: \"italic\",\n            fontWeight: 400,\n            fontSize: \"1.04em\",\n            letterSpacing: \"-0.01em\",\n            marginLeft: \"0.16em\",\n            color: unitColor,\n          }}\n        >\n          {txt.unit}\n        </span>\n      ) : null}\n    </div>\n  );\n  const text = (\n    <div\n      style={{\n        display: \"grid\",\n        padding: inline ? `0 ${18 * u}px` : 0,\n        fontFamily: display,\n        fontWeight: 500,\n        fontSize: size,\n        lineHeight: 1,\n        letterSpacing: \"-0.035em\",\n        whiteSpace: \"nowrap\",\n        opacity: textOp,\n      }}\n    >\n      {textRow(finalText, true)}\n      {textRow(now, false)}\n    </div>\n  );\n  return (\n    <>\n      <div\n        style={{\n          position: \"absolute\",\n          left: x0,\n          width: span,\n          top: y - size / 2,\n          height: size,\n          display: \"flex\",\n          alignItems: \"center\",\n        }}\n      >\n        <Arrow side=\"left\" k={k} color={color} u={u} />\n        {inline ? text : null}\n        <Arrow side=\"right\" k={k} color={color} u={u} />\n      </div>\n      {inline ? null : (\n        <div\n          style={{\n            position: \"absolute\",\n            left: x0 + span / 2,\n            top: y - size - 14 * u,\n            transform: \"translateX(-50%)\",\n          }}\n        >\n          {text}\n        </div>\n      )}\n    </>\n  );\n}\n\nexport function MeasureDim({\n  subject,\n  label = \"remocn\",\n  value = \"184 fps\",\n  before = \"60 fps\",\n  beforeLabel = \"Before\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: MeasureDimProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = Math.min(W / 1280, H / 720);\n  const p = THEMES[theme];\n\n  const a = parse(value)?.n ?? 1;\n  const b = before ? (parse(before)?.n ?? a * 0.4) : 0;\n  const hasGhost = Boolean(before);\n  const maxW = 0.7 * W;\n  const top = Math.max(a, hasGhost ? b : 0) || 1;\n  const heroW = maxW * Math.max(0.18, a / top);\n  const ghostW = maxW * Math.max(0.18, b / top);\n  const x0 = (W - maxW) / 2;\n\n  const heroSize = 104 * u;\n  const ghostSize = 40 * u;\n  const barH = 72 * u;\n  const total = (hasGhost ? 376 : 240) * u;\n  const dimA = H / 2 - total / 2 + heroSize / 2;\n  const heroTop = dimA + 76 * u;\n  const ghostTop = heroTop + barH + 28 * u;\n  const dimB = ghostTop + barH + 46 * u;\n\n  const bar = EASE_IO(interpolate(t, [BAR_AT, BAR_AT + 18], [0, 1], CLAMP));\n  const extA = EASE_OUT(interpolate(t, [EXT_A, EXT_A + 12], [0, 1], CLAMP));\n  const arrA = SLIDE(interpolate(t, [ARR_A, ARR_A + ARR_LEN], [0, 1], CLAMP));\n  const ghost = EASE_IO(\n    interpolate(t, [GHOST_AT, GHOST_AT + 16], [0, 1], CLAMP),\n  );\n  const extB = EASE_OUT(interpolate(t, [EXT_B, EXT_B + 12], [0, 1], CLAMP));\n  const arrB = SLIDE(interpolate(t, [ARR_B, ARR_B + 22], [0, 1], CLAMP));\n  const labelIn = EASE_OUT(\n    interpolate(t, [BAR_AT + 14, BAR_AT + 28], [0, 1], CLAMP),\n  );\n  const ghostLabelIn = EASE_OUT(\n    interpolate(t, [GHOST_AT + 10, GHOST_AT + 24], [0, 1], CLAMP),\n  );\n  const push = EASE_IO(interpolate(t, [0, ARR_B + 60], [0, 1], CLAMP));\n  const drift = interpolate(t, [0, 140], [0, 1], CLAMP);\n\n  // gradients.sh \"limb\" (#160c3a → #4b2bd6 → #8a8bff → #e9ecff) with the accent woven in.\n  const limb = `linear-gradient(90deg, #160C3A ${-6 + 4 * drift}%, #4B2BD6 ${30 + 3 * drift}%, ${accent} ${52 + 3 * drift}%, #8A8BFF ${80 + 2 * drift}%, ${p.tipStop} 104%)`;\n  const limbSheen = `radial-gradient(60% 140% at ${62 + 14 * drift}% 0%, rgba(233,236,255,${p.sheen}) 0%, transparent 70%)`;\n\n  const stroke = Math.max(1, 1.25 * u);\n  const ext = (x: number, y0: number, y1: number, k: number, c: string) =>\n    k > 0 ? (\n      <line\n        x1={x}\n        x2={x}\n        y1={y0}\n        y2={y0 + (y1 - y0) * k}\n        stroke={c}\n        strokeWidth={stroke}\n      />\n    ) : null;\n\n  const barLabel: React.CSSProperties = {\n    position: \"absolute\",\n    top: 0,\n    bottom: 0,\n    left: 22 * u,\n    display: \"flex\",\n    alignItems: \"center\",\n    fontFamily: display,\n    fontWeight: 500,\n    fontSize: 18 * u,\n    letterSpacing: \"-0.01em\",\n    whiteSpace: \"nowrap\",\n  };\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          transform: `scale(${0.985 + 0.015 * push})`,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: x0,\n            top: heroTop,\n            width: heroW,\n            height: barH,\n            borderRadius: 8 * u,\n            overflow: \"hidden\",\n            backgroundImage: subject ? undefined : `${limbSheen}, ${limb}`,\n            clipPath: `inset(0 ${(1 - bar) * 100}% 0 0 round ${8 * u}px)`,\n          }}\n        >\n          {subject ?? (\n            <div\n              style={{\n                ...barLabel,\n                color: \"#FFFFFF\",\n                opacity: labelIn,\n                transform: `translateX(${(1 - labelIn) * -8 * u}px)`,\n              }}\n            >\n              {label === \"remocn\" ? (\n                <RemocnLogo fontSize={26 * u} color=\"#FFFFFF\" />\n              ) : (\n                label\n              )}\n            </div>\n          )}\n        </div>\n\n        {hasGhost ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: x0,\n              top: ghostTop,\n              width: ghostW,\n              height: barH,\n              clipPath: `inset(-2px ${(1 - ghost) * 100}% -2px -2px)`,\n            }}\n          >\n            <svg\n              width={ghostW}\n              height={barH}\n              style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n            >\n              <rect\n                x={stroke / 2}\n                y={stroke / 2}\n                width={ghostW - stroke}\n                height={barH - stroke}\n                rx={8 * u}\n                fill={p.ghostFill}\n                stroke={p.ghost}\n                strokeWidth={stroke}\n                strokeDasharray={`${7 * u} ${5 * u}`}\n              />\n            </svg>\n            <div\n              style={{\n                ...barLabel,\n                color: p.muted,\n                opacity: ghostLabelIn,\n              }}\n            >\n              {beforeLabel}\n            </div>\n          </div>\n        ) : null}\n\n        <svg\n          width={W}\n          height={H}\n          style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n        >\n          {ext(x0, heroTop - 8 * u, dimA - 16 * u, extA, p.line)}\n          {ext(x0 + heroW, heroTop - 8 * u, dimA - 16 * u, extA, p.line)}\n          {hasGhost ? (\n            <>\n              {ext(x0, ghostTop + barH + 8 * u, dimB + 16 * u, extB, p.ghost)}\n              {ext(\n                x0 + ghostW,\n                ghostTop + barH + 8 * u,\n                dimB + 16 * u,\n                extB,\n                p.ghost,\n              )}\n            </>\n          ) : null}\n        </svg>\n\n        <Dimension\n          x0={x0}\n          x1={x0 + heroW}\n          y={dimA}\n          k={arrA}\n          value={value}\n          size={heroSize}\n          color={p.line}\n          textColor={p.fg}\n          unitColor={p.fg}\n          u={u}\n        />\n        {hasGhost ? (\n          <Dimension\n            x0={x0}\n            x1={x0 + ghostW}\n            y={dimB}\n            k={arrB}\n            value={before}\n            size={ghostSize}\n            color={p.ghost}\n            textColor={p.muted}\n            unitColor={p.muted}\n            u={u}\n          />\n        ) : null}\n      </AbsoluteFill>\n\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/measure-dim.tsx"
    }
  ],
  "type": "registry:component"
}
