{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "price-page",
  "title": "Price Page",
  "description": "A huge teal \"Free.\" fills the frame with \"That's the whole pricing page.\".",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/price-page/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/AlbertSans\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst albert = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface PricePageProps {\n  label?: string;\n  lines?: string[];\n  price?: string;\n  note?: string;\n  accent?: string;\n  background?: string;\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst THEMES = {\n  dark: { bg: \"#141414\", ink: \"#FFFFFF\", accent: \"#3DD9FF\" },\n  light: { bg: \"#FFFFFF\", ink: \"#000000\", accent: \"#0077B6\" },\n} as const;\n\nconst DEFAULT_LINES = [\n  \"Starter, Pro, Team, Enterprise\",\n  \"Per seat, per month\",\n  \"Billed yearly, save 20%\",\n  \"Watermark on the free plan\",\n  \"Three exports a month\",\n  \"Overage fees may apply\",\n  \"Contact sales\",\n];\n\nconst LH = 1.2;\nconst TRACK_LINE = -0.015;\nconst TRACK_PRICE = -0.04;\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_EXIT = Easing.bezier(0.6, 0, 0.9, 0.3);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nfunction useWidths(keys: string[]) {\n  const key = keys.join(\"\\u0001\");\n  const [state, setState] = useState<{\n    key: string;\n    w: Record<string, number>;\n  } | null>(null);\n  const [handle] = useState(() => delayRender(\"price-page: measuring\"));\n  const released = useRef(false);\n  const ref = useRef(keys);\n  ref.current = keys;\n  useEffect(() => {\n    let live = true;\n    Promise.all([\n      albert.waitUntilDone(),\n      document.fonts.load(`400 100px \"${albert.fontFamily}\"`),\n      document.fonts.load(`500 100px \"${albert.fontFamily}\"`),\n    ])\n      .catch(() => undefined)\n      .then(() => {\n        if (!live) return;\n        const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n        const w: Record<string, number> = {};\n        for (const k of ref.current) {\n          const cut = k.indexOf(\"|\");\n          const wt = k.slice(0, cut);\n          const s = k.slice(cut + 1);\n          if (ctx) ctx.font = `${wt} 100px \"${albert.fontFamily}\"`;\n          w[k] = ctx ? ctx.measureText(s).width / 100 : s.length * 0.5;\n        }\n        setState({ key, w });\n        if (!released.current) {\n          released.current = true;\n          continueRender(handle);\n        }\n      });\n    return () => {\n      live = false;\n    };\n  }, [key, handle]);\n  return state && state.key === key ? state.w : null;\n}\n\nexport function PricePage({\n  label = \"Pricing\",\n  lines = DEFAULT_LINES,\n  price = \"Free.\",\n  note = \"That’s the whole pricing page.\",\n  accent,\n  background,\n  speed = 1,\n  theme = \"dark\",\n}: PricePageProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H, durationInFrames } = useVideoConfig();\n  const T = durationInFrames * speed;\n  const c = THEMES[theme];\n  const hi = accent ?? c.accent;\n  const stage =\n    background === \"transparent\" ? \"transparent\" : (background ?? c.bg);\n\n  const rows = lines.filter((s) => s.trim().length > 0);\n  const keys = [\n    ...rows.map((s) => `400|${s}`),\n    `500|${price}`,\n    `400|${note}`,\n    `400|${label}`,\n  ];\n  const w = useWidths(keys);\n\n  if (!w) {\n    return (\n      <div style={{ position: \"absolute\", inset: 0, background: stage }} />\n    );\n  }\n\n  const adv = (wt: number, s: string, track: number) =>\n    (w[`${wt}|${s}`] ?? 0) + track * Array.from(s).length;\n\n  const portrait = H > W * 1.1;\n  const unit = Math.min(W, H);\n  const right = W * (portrait ? 0.92 : 0.925);\n  const maxW = W * (portrait ? 0.84 : 0.6);\n  const n = rows.length;\n\n  const longest = Math.max(0.01, ...rows.map((s) => adv(400, s, TRACK_LINE)));\n  const F = Math.max(\n    14,\n    Math.min(\n      (H * (portrait ? 0.42 : 0.68)) / Math.max(1, n * LH),\n      maxW / longest,\n      unit * (portrait ? 0.08 : 0.1),\n    ),\n  );\n  const lineH = F * LH;\n\n  const priceMax = W * (portrait ? 0.84 : 0.7);\n  const Fp = Math.min(\n    unit * (portrait ? 0.42 : 0.38),\n    priceMax / Math.max(0.01, adv(500, price, TRACK_PRICE)),\n  );\n  const priceH = Fp * 0.98;\n\n  const Fs = Math.max(16, unit * 0.034);\n  const Fn = Math.min(\n    Math.max(16, unit * 0.044),\n    maxW / Math.max(0.01, adv(400, note, -0.005)),\n  );\n  const labelH = Fs * 2.1;\n  const noteH = note ? Fn * 1.9 : 0;\n\n  const intro = 40;\n  const tail = 44;\n  const land = 22;\n  const gap =\n    n > 1\n      ? Math.max(4, Math.min(10, (T - intro - tail - land - 12) / (n - 1)))\n      : 0;\n  const ord = Array.from({ length: n }, (_, i) => i).sort(\n    (a, b) => ((a * 3) % n) - ((b * 3) % n) || a - b,\n  );\n  const exitAt: number[] = new Array(n).fill(0);\n  ord.forEach((i, k) => {\n    exitAt[i] = intro + k * gap;\n  });\n  const EXIT_LEN = 9;\n  const lastExit = n > 0 ? intro + (n - 1) * gap : intro;\n  const landAt = lastExit + 8;\n\n  const presence = rows.map((_, i) =>\n    interpolate(t, [exitAt[i] + 7, exitAt[i] + 18], [1, 0], {\n      ...CLAMP,\n      easing: EASE_IO,\n    }),\n  );\n  const listH = presence.reduce((a, p) => a + p * lineH, 0);\n  const grow = interpolate(t, [landAt - 6, landAt + 14], [0, 1], {\n    ...CLAMP,\n    easing: EASE_IO,\n  });\n  const contentH = labelH + listH + grow * (priceH + noteH);\n  const top = H / 2 - contentH / 2;\n  const listTop = top + labelH;\n\n  const labelIn = interpolate(t, [0, 16], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n\n  const lineNodes = rows.map((s, i) => {\n    let rank = 0;\n    for (let j = 0; j < i; j++) rank += presence[j];\n    const base = listTop + rank * lineH + F * 0.93;\n    const enter = interpolate(t, [3 + i * 3, 19 + i * 3], [0, 1], {\n      ...CLAMP,\n      easing: EASE_OUT,\n    });\n    const out = interpolate(t, [exitAt[i], exitAt[i] + EXIT_LEN], [0, 1], {\n      ...CLAMP,\n      easing: EASE_EXIT,\n    });\n    if (out >= 1) return null;\n    const lw = adv(400, s, TRACK_LINE) * F;\n    const dx = out * (W - right + lw + F);\n    const dy = (1 - enter) * F * 0.45;\n    return (\n      <text\n        key={`l${i}`}\n        x={right}\n        y={base}\n        textAnchor=\"end\"\n        fontSize={F}\n        fontWeight={400}\n        letterSpacing={`${TRACK_LINE}em`}\n        fill={c.ink}\n        opacity={enter * interpolate(out, [0.55, 1], [1, 0], CLAMP)}\n        transform={`translate(${dx.toFixed(2)} ${dy.toFixed(2)})`}\n      >\n        {s}\n      </text>\n    );\n  });\n\n  const priceIn = interpolate(t, [landAt, landAt + 20], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const noteIn = interpolate(t, [landAt + 12, landAt + 30], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const priceBase = listTop + listH + Fp * 0.82;\n  const noteBase = listTop + listH + priceH + Fn * 1.35;\n\n  return (\n    <AbsoluteFill style={{ background: stage, overflow: \"hidden\" }}>\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        fontFamily={albert.fontFamily}\n        aria-hidden\n      >\n        <text\n          x={right}\n          y={top + Fs}\n          textAnchor=\"end\"\n          fontSize={Fs}\n          fontWeight={400}\n          fill={c.ink}\n          opacity={labelIn * 0.55}\n          transform={`translate(0 ${((1 - labelIn) * Fs * 0.4).toFixed(2)})`}\n        >\n          {label}\n        </text>\n        {lineNodes}\n        {priceIn > 0 ? (\n          <text\n            x={right}\n            y={priceBase}\n            textAnchor=\"end\"\n            fontSize={Fp}\n            fontWeight={500}\n            letterSpacing={`${TRACK_PRICE}em`}\n            fill={hi}\n            opacity={priceIn}\n            transform={`translate(0 ${((1 - priceIn) * Fp * 0.22).toFixed(2)})`}\n          >\n            {price}\n          </text>\n        ) : null}\n        {note && noteIn > 0 ? (\n          <text\n            x={right}\n            y={noteBase}\n            textAnchor=\"end\"\n            fontSize={Fn}\n            fontWeight={400}\n            letterSpacing=\"-0.005em\"\n            fill={c.ink}\n            opacity={noteIn}\n            transform={`translate(0 ${((1 - noteIn) * Fn * 0.5).toFixed(2)})`}\n          >\n            {note}\n          </text>\n        ) : null}\n      </svg>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/price-page.tsx"
    }
  ],
  "type": "registry:component"
}
