{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "video-print",
  "title": "VideoPrint",
  "description": "A printed video still on a Paper sheet: a pale 16:9 line sketch, an ink scrub rule with anchor ticks, title and date, and an optional punched link tag.",
  "registryDependencies": [
    "@jbm/tokens",
    "@jbm/scene-geometry",
    "@jbm/paper",
    "@jbm/punched-tag"
  ],
  "files": [
    {
      "path": "registry/jbm/ui/video-print.tsx",
      "content": "import type { CSSProperties } from \"react\"\nimport { color, font, stroke } from \"../lib/tokens\"\nimport { unit, type Box, type Pt } from \"../lib/geometry\"\nimport { Paper } from \"./paper\"\nimport { PunchedTag } from \"./punched-tag\"\n\nexport type VideoPrintProps = {\n  /** Playhead 0–1: how far the ink scrub rule has advanced along the print. */\n  scrub: number\n  /** Positions 0–1 along the scrub rule. Each leaves an ink tick once the rule passes it and exposes an anchor point (see videoPrintLayout). */\n  marks?: readonly number[]\n  /** The video's title, set in bold type under the rule (one line, ellipsis when long). */\n  title: string\n  /** The line under the title, usually source and date (\"Video · 4 nov 2025\"). */\n  date: string\n  /** A URL set in mono on a punched tag hanging from the bottom edge (one line, ellipsis past the print's width). Its presence means \"this page was opened\". */\n  link?: string\n  /** 0–1: the tag fades in and settles into place from just below its resting spot. Only used with `link`. */\n  opened?: number\n  /** Width in stage pixels; every measurement scales with it (the height is 0.765 × w). */\n  w?: number\n  /** Draw the Paper sheet. false renders only the print's contents, for nesting on a Paper you already have. */\n  sheet?: boolean\n  /** Inline styles for the outer box (position it with left/top or a transform). */\n  style?: CSSProperties\n}\n\nconst BASE = 480\n\n/** `over` laid on `under` at `alpha`, as an opaque hex colour. */\nfunction mix(under: string, over: string, alpha: number) {\n  const channel = (hex: string, i: number) => parseInt(hex.slice(1 + 2 * i, 3 + 2 * i), 16)\n  return `#${[0, 1, 2]\n    .map((i) =>\n      Math.round(channel(under, i) * (1 - alpha) + channel(over, i) * alpha)\n        .toString(16)\n        .padStart(2, \"0\")\n    )\n    .join(\"\")}`\n}\n/** The still's pale tint: 8% ink on card stock, opaque, so it reads the same with or without the sheet under it. */\nconst stillTint = mix(color.card, color.ink, 0.08)\n\n/**\n * Where everything on the print sits, in pixels from the print's top-left corner (or from `at`,\n * the print's position on your stage). Use `marks` as Hilo anchors: each is the tick's point on the\n * scrub rule's centreline.\n */\nexport function videoPrintLayout(\n  { w = BASE, marks = [], link }: Pick<VideoPrintProps, \"w\" | \"marks\" | \"link\">,\n  at: Pt = { x: 0, y: 0 }\n) {\n  const s = (Number.isFinite(w) && w > 0 ? w : BASE) / BASE\n  const pad = 22 * s\n  const frame: Box = {\n    x: at.x + pad,\n    y: at.y + pad,\n    w: BASE * s - 2 * pad,\n    h: ((BASE * s - 2 * pad) * 9) / 16,\n  }\n  const ruleY = frame.y + frame.h + 12 * s\n  const titleY = ruleY + 18 * s\n  const dateY = titleY + 30 * s\n  const h = dateY - at.y + 18 * s + pad\n  const tagX = at.x + 2 * pad\n  // The link tag straddles the bottom edge: half its height (a 14 × s line and 6 × s padding\n  // above and below, inside the Paper edge on each side) hangs below the sheet.\n  // Plus the 8 × s it settles up from while `opened` is below 1.\n  const edge = stroke.outline\n  const ring = Math.min(edge, Math.max(1, edge * s))\n  const tagHang = link ? (14 * 1.3 * s + 12 * s + 2 * edge) / 2 + 8 * s : 0\n  return {\n    scale: s,\n    w: BASE * s,\n    h,\n    pad,\n    frame,\n    rule: { x: frame.x, y: ruleY, w: frame.w },\n    titleY,\n    dateY,\n    marks: marks.map((m) => ({ x: frame.x + unit(m) * frame.w, y: ruleY })),\n    /** The punched hole of the link tag: where a thread would tie on. Null without a link. */\n    // Sheet edge + left padding + the hole's radius and ring (PunchedTag's rule at scale s).\n    tag: link ? { x: tagX + edge + 10 * s + 7 * s + ring, y: at.y + h } : null,\n    tagX,\n    /** The link tag's widest extent, from tagX: it ends a padding short of the sheet's right edge. */\n    tagMaxW: BASE * s - 3 * pad,\n    /** The box everything draws in, from `at`: the sheet plus, with a link, the tag hanging below it. */\n    bounds: { w: BASE * s, h: h + tagHang },\n  }\n}\n\n/**\n * A printed still of a video on a Paper sheet: a pale 16:9 frame sketched in ink line (head and\n * shoulders, not a solid block), an ink scrub rule that advances with `scrub` and leaves ticks at\n * `marks`, the title and date in type, and optionally a punched tag with the URL, meaning \"this\n * page was opened\". Pure React; controlled and deterministic.\n */\nexport function VideoPrint({\n  scrub,\n  marks = [],\n  title,\n  date,\n  link,\n  opened = 1,\n  w = BASE,\n  sheet = true,\n  style,\n}: VideoPrintProps) {\n  const l = videoPrintLayout({ w, marks, link })\n  const s = l.scale\n  const p = unit(scrub)\n  const { frame } = l\n  const cx = frame.x + frame.w / 2\n  const bottom = frame.y + frame.h\n  const headR = frame.h * 0.14\n  const headY = frame.y + frame.h * 0.42\n  const shoulderA = frame.w * 0.18\n  const shoulderB = frame.h * 0.21\n  const tagIn = unit(opened)\n  const r2 = (v: number) => Math.round(v * 100) / 100\n  const text: CSSProperties = {\n    position: \"absolute\",\n    left: frame.x,\n    width: frame.w,\n    whiteSpace: \"nowrap\",\n    overflow: \"hidden\",\n    textOverflow: \"ellipsis\",\n    margin: 0,\n  }\n  return (\n    <div\n      style={{ position: \"relative\", width: l.w, height: l.h, flexShrink: 0, ...style }}\n      data-video-print=\"\"\n    >\n      {sheet && (\n        <Paper radius={10 * s} style={{ position: \"absolute\", inset: 0 }} />\n      )}\n      <svg\n        aria-hidden=\"true\"\n        viewBox={`0 0 ${r2(l.w)} ${r2(l.h)}`}\n        width={l.w}\n        height={l.h}\n        style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n      >\n        <rect\n          x={r2(frame.x)}\n          y={r2(frame.y)}\n          width={r2(frame.w)}\n          height={r2(frame.h)}\n          rx={2 * s}\n          fill={stillTint}\n          stroke=\"none\"\n        />\n        <g\n          fill=\"none\"\n          stroke={color.ink}\n          strokeWidth={1.5 * s}\n          strokeLinecap=\"round\"\n        >\n          <circle cx={r2(cx)} cy={r2(headY)} r={r2(headR)} />\n          <path\n            d={`M${r2(cx - shoulderA)} ${r2(bottom)}A${r2(shoulderA)} ${r2(shoulderB)} 0 0 1 ${r2(cx + shoulderA)} ${r2(bottom)}`}\n          />\n        </g>\n        <rect\n          x={r2(frame.x)}\n          y={r2(frame.y)}\n          width={r2(frame.w)}\n          height={r2(frame.h)}\n          rx={2 * s}\n          fill=\"none\"\n          stroke={color.ink}\n          strokeWidth={stroke.outline}\n        />\n        <rect\n          x={r2(l.rule.x)}\n          y={r2(l.rule.y - 2 * s)}\n          width={r2(l.rule.w)}\n          height={r2(4 * s)}\n          fill={color.line}\n        />\n        {p > 0 && (\n          <rect\n            data-scrub=\"\"\n            x={r2(l.rule.x)}\n            y={r2(l.rule.y - 2 * s)}\n            width={r2(l.rule.w * p)}\n            height={r2(4 * s)}\n            fill={color.ink}\n          />\n        )}\n        {l.marks.map((m, i) =>\n          unit(marks[i]) <= p && p > 0 ? (\n            <path\n              key={i}\n              data-mark={i}\n              d={`M${r2(m.x)} ${r2(m.y - 6 * s)}V${r2(m.y + 8 * s)}`}\n              stroke={color.ink}\n              strokeWidth={2 * s}\n              strokeLinecap=\"round\"\n            />\n          ) : null\n        )}\n      </svg>\n      <p\n        style={{\n          ...text,\n          top: l.titleY,\n          fontFamily: font.sans,\n          fontWeight: 700,\n          fontSize: 22 * s,\n          lineHeight: 1.2,\n          letterSpacing: -0.3 * s,\n          color: color.ink,\n        }}\n      >\n        {title}\n      </p>\n      <p\n        style={{\n          ...text,\n          top: l.dateY,\n          fontFamily: font.sans,\n          fontWeight: 400,\n          fontSize: 14 * s,\n          lineHeight: 1.3,\n          color: color.dim,\n        }}\n      >\n        {date}\n      </p>\n      {link && tagIn > 0 && (\n        <div\n          style={{\n            position: \"absolute\",\n            left: l.tagX,\n            top: l.h,\n            // It settles into place from just below and never rises past its resting spot, so its\n            // top edge never crosses the date line above it while it fades in.\n            opacity: Math.min(1, tagIn / 0.5),\n            transform: `translateY(calc(-50% + ${r2((1 - tagIn) * 8 * s)}px))`,\n          }}\n        >\n          <PunchedTag\n            scale={s}\n            cut={8}\n            maxWidth={l.tagMaxW}\n            labelStyle={{\n              fontFamily: font.mono,\n              fontWeight: 500,\n              fontSize: 14 * s,\n              lineHeight: 1.3,\n            }}\n            style={{\n              gap: 10 * s,\n              padding: `${6 * s}px ${14 * s}px ${6 * s}px ${10 * s}px`,\n            }}\n          >\n            {link}\n          </PunchedTag>\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:ui",
      "target": "src/jbm/ui/video-print.tsx"
    }
  ],
  "categories": [
    "UI Bits"
  ],
  "type": "registry:ui"
}