{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"prompt-send","type":"registry:component","title":"Prompt Send","description":"AI prompt typing animation: a chat input types a prompt and a cursor clicks send. A composer that unrolls from a hairline, writes a brief into itself while the camera cuts in and rides the caret, then cuts back out to the send button as a pointer arrives and clicks it.","dependencies":["remotion","@remotion/google-fonts"],"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","https://kuchi.kalarislabs.com/r/input.json"],"files":[{"path":"components/kuchi/prompt-send.tsx","type":"registry:component","target":"components/kuchi/prompt-send.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadSans } from \"@remotion/google-fonts/Inter\";\r\nimport type { ReactNode } from \"react\";\r\nimport {\r\n  AbsoluteFill,\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport { inputStyleContext } from \"@/components/kuchi/input\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  parseColor,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n  withAlpha,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\n// Loaded through @remotion/google-fonts, never a CSS variable — a Remotion\r\n// bundle has none of the app's CSS, so a `var(--font-…)` gets you the right face\r\n// in the Player and a fallback in the mp4 (design-system rule 4).\r\nconst { fontFamily: SANS } = loadSans(\"normal\", {\r\n  weights: [\"400\", \"500\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\n// --- The stage -------------------------------------------------------------\r\n//\r\n// The reference recording is 890×486, and every ratio below was read off its\r\n// frames, so there is no second conversion to get wrong. `stageScale` fits this\r\n// rectangle into whatever composition the component is given.\r\n\r\nconst REF_W = 890;\r\nconst REF_H = 486;\r\n/** How far past the stage the backdrop is painted, so a cut never frames off it. */\r\nconst BLEED = 1.4;\r\nconst OX = (REF_W * (BLEED - 1)) / 2;\r\nconst OY = (REF_H * (BLEED - 1)) / 2;\r\n\r\n// --- Measured proportions --------------------------------------------------\r\n//\r\n// Everything the layout needs is either a fixed inset (a padding, which should\r\n// not change when the type does) or a **ratio of a font size** (a type metric,\r\n// which must). Feeding the defaults through `layoutFor` reproduces the\r\n// recording's own geometry to a pixel; changing `fontSize`, `width`,\r\n// `fieldHeight` or the labels moves the whole thing coherently instead of\r\n// clipping against a constant that was tuned for one sentence.\r\n\r\n/** Panel → field inset, and the panel's own bottom padding under the chips. */\r\nconst PAD = 4.7;\r\n/** The panel sits a hair below the frame's centre line, as the reference's does. */\r\nconst PANEL_BIAS = 3.3;\r\n/** Field text inset, and the line box, as multiples of the prompt's font size. */\r\nconst LINE_PAD_X = 1.12143;\r\nconst LINE_PAD_Y = 1.27857;\r\nconst LINE_HEIGHT = 1.21429;\r\nconst CARET_RATIO = 0.15714;\r\n/** The chip row's own metrics, as multiples of the chip font size. */\r\nconst CHIP_HEIGHT = 2;\r\nconst CHIP_PAD_X = 0.93496;\r\nconst CHIP_GAP = 0.70732;\r\nconst CHIP_TOP = 0.54472;\r\n/** The row starts a little inside the field's text inset. */\r\nconst CHIP_INSET = 0.72639;\r\n/** The send button's corner, measured off the field's bottom-right. */\r\nconst SEND_RIGHT = 14.4;\r\nconst SEND_BOTTOM = 10.3;\r\n\r\n// --- Measured timeline, in seconds -----------------------------------------\r\n\r\n/** Reveal: a hairline at the panel's top edge that unrolls downward. */\r\nconst PANEL_GROW = 0.445;\r\n/** The writing surface finishes first — 0.83 of the panel's own duration. */\r\nconst FIELD_GROW = 0.831;\r\n/** The panel also widens as it unrolls — 0.93 of its width to all of it. */\r\nconst WIDEN = 0.2;\r\nconst WIDEN_FROM = 0.93;\r\n/** Placeholder and send button, together, on a straight ramp. */\r\nconst FIELD_FADE = 0.3;\r\n/** Each chip fades up over this, rising as it goes. */\r\nconst CHIP_DUR = 0.59;\r\nconst CHIP_RISE = 11.4;\r\n/** Caret blink half-cycle, re-anchored on every keystroke. */\r\nconst BLINK = 0.474;\r\n/** Press, then release, on the send button. */\r\nconst PRESS_DOWN = 0.067;\r\nconst PRESS_UP = 0.25;\r\nconst PRESS_SCALE = 0.87;\r\n\r\n/**\r\n * The unroll. Nearly linear out of the gate, then a long settle — fitted to the\r\n * panel's measured height on twenty frames (rmse 2.5px on a 167px box).\r\n */\r\nconst REVEAL_EASE = Easing.bezier(0.3, 0, 0.35, 1);\r\n/** The chips' rise. Fitted separately: it is a harder ease-out than the unroll. */\r\nconst CHIP_EASE = Easing.bezier(0.2, 0, 0.25, 1);\r\n/** Real mouse deceleration — half the distance in the first eighth of the move. */\r\nconst CURSOR_EASE = Easing.bezier(0.16, 1, 0.3, 1);\r\n\r\n// --- Pure helpers (unit-tested) --------------------------------------------\r\n\r\n/** Eased 0→1 for a beat that starts at `at` and runs for `dur` seconds. */\r\nexport function beat(\r\n  t: number,\r\n  at: number,\r\n  dur: number,\r\n  ease: (n: number) => number = REVEAL_EASE,\r\n): number {\r\n  if (dur <= 0) return t >= at ? 1 : 0;\r\n  return interpolate(t, [at, at + dur], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n    easing: ease,\r\n  });\r\n}\r\n\r\n/**\r\n * Characters revealed at `t`, on an **ease-in-out sine** over `dur`.\r\n *\r\n * This is the one measurement that surprised: the reference does not type at a\r\n * constant rate. It accelerates in and decelerates out — 17 chars/sec over the\r\n * first word, 33 in the middle, and a visible settle on the last three. Fitting\r\n * a sine ease to the character count read off twenty-four frames lands within\r\n * **0.30 characters rms** across all 69, which no constant rate comes close to.\r\n *\r\n * It is also what makes the shot work: the camera rides this same curve, so the\r\n * push never jerks and never coasts.\r\n */\r\nexport function typedCount(\r\n  t: number,\r\n  start: number,\r\n  dur: number,\r\n  total: number,\r\n): number {\r\n  if (t <= start) return 0;\r\n  if (dur <= 0 || t >= start + dur) return total;\r\n  const u = (t - start) / dur;\r\n  return Math.min(total, Math.round((total * (1 - Math.cos(Math.PI * u))) / 2));\r\n}\r\n\r\n/** Continuous 0→1 of the same curve — what the camera and the field ride. */\r\nexport function typedProgress(t: number, start: number, dur: number): number {\r\n  if (t <= start) return 0;\r\n  if (dur <= 0 || t >= start + dur) return 1;\r\n  return (1 - Math.cos((Math.PI * (t - start)) / dur)) / 2;\r\n}\r\n\r\n/**\r\n * When the `count`-th character landed — the inverse of the sine ease.\r\n *\r\n * Needed because a caret does not blink on a wall clock, it blinks a fixed\r\n * interval after the last thing you typed. Anchoring the blink here is what\r\n * keeps it solid through the sentence and gets the two measured blinks after it\r\n * (off at 4.27s, on at 4.74s) for free.\r\n */\r\nexport function keystrokeAt(\r\n  count: number,\r\n  start: number,\r\n  dur: number,\r\n  total: number,\r\n): number {\r\n  if (count <= 0 || total <= 0) return start;\r\n  const p = Math.min(1, count / total);\r\n  return start + (dur * Math.acos(1 - 2 * p)) / Math.PI;\r\n}\r\n\r\n/** Caret visibility: solid while typing, then blinking from the last keystroke. */\r\nexport function caretOn(t: number, anchor: number, half: number): boolean {\r\n  if (t < anchor) return false;\r\n  if (half <= 0) return true;\r\n  return Math.floor((t - anchor) / half) % 2 === 0;\r\n}\r\n\r\nexport interface CameraShot {\r\n  scale: number;\r\n  x: number;\r\n  y: number;\r\n}\r\n\r\n/**\r\n * The camera, as three hard states — there is no interpolation between them.\r\n *\r\n * Measured on the reference: the wide view is whole on one frame and fully\r\n * pushed in on the very next (1.958s → 1.975s), and the same again on the way\r\n * back out at 4.008s. Nothing in between, either time. Ramping it, even across\r\n * two frames, turns a cut into a zoom and the shot stops snapping.\r\n *\r\n * What *does* move is the middle state. It is not a fixed frame: it is pinned to\r\n * the caret, so as the sentence grows the camera tracks left with it. The pin is\r\n * on the **continuous** typing curve, not on the character count — which is why\r\n * the caret in the reference wobbles ±8px around its mark instead of sitting\r\n * dead still. Each keystroke jumps it forward; the camera slides underneath.\r\n *\r\n * Both marks are *fractions of the frame*, never pixel offsets, so a wider panel\r\n * or a bigger type size reframes rather than drifting off the edge.\r\n */\r\nexport function cameraFor(\r\n  t: number,\r\n  o: {\r\n    cutInAt: number;\r\n    cutOutAt: number;\r\n    zoomIn: number;\r\n    zoomOut: number;\r\n    caretX: number;\r\n    caretY: number;\r\n    sendX: number;\r\n    sendY: number;\r\n    focusX: number;\r\n    focusY: number;\r\n    outX: number;\r\n    outY: number;\r\n  },\r\n): CameraShot {\r\n  if (t >= o.cutOutAt) {\r\n    return {\r\n      scale: o.zoomOut,\r\n      x: o.outX * REF_W - o.zoomOut * o.sendX,\r\n      y: o.outY * REF_H - o.zoomOut * o.sendY,\r\n    };\r\n  }\r\n  if (t >= o.cutInAt) {\r\n    return {\r\n      scale: o.zoomIn,\r\n      x: o.focusX * REF_W - o.zoomIn * o.caretX,\r\n      y: o.focusY * REF_H - o.zoomIn * o.caretY,\r\n    };\r\n  }\r\n  return { scale: 1, x: 0, y: 0 };\r\n}\r\n\r\n/**\r\n * Greedy row-fill for the suggestion row.\r\n *\r\n * Four short labels are one row and that is the shot the reference shows, but a\r\n * component that only works for four short labels is one that breaks the first\r\n * time somebody writes a real one. Anything that will not fit wraps, the panel\r\n * grows by exactly the rows it gained, and the stagger keeps running in label\r\n * order across them.\r\n */\r\nexport function packChipRows(\r\n  widths: number[],\r\n  available: number,\r\n  gap: number,\r\n): number[][] {\r\n  const rows: number[][] = [];\r\n  let row: number[] = [];\r\n  let used = 0;\r\n  widths.forEach((w, i) => {\r\n    if (row.length > 0 && used + gap + w > available) {\r\n      rows.push(row);\r\n      row = [];\r\n      used = 0;\r\n    }\r\n    used += row.length === 0 ? w : gap + w;\r\n    row.push(i);\r\n  });\r\n  if (row.length > 0) rows.push(row);\r\n  return rows;\r\n}\r\n\r\nexport interface PromptSendLayout {\r\n  panelTop: number;\r\n  panelWidth: number;\r\n  panelHeight: number;\r\n  pad: number;\r\n  fieldHeight: number;\r\n  fieldRadius: number;\r\n  /** Prompt line, relative to the panel's own box. */\r\n  lineX: number;\r\n  lineY: number;\r\n  lineHeight: number;\r\n  /** How much line fits before the field has to scroll under the caret. */\r\n  lineMaxWidth: number;\r\n  caretWidth: number;\r\n  /** Suggestion row: `chipsX` from the panel's left, `chipsGap` below the field. */\r\n  chipsX: number;\r\n  chipsGap: number;\r\n  chipHeight: number;\r\n  chipPadX: number;\r\n  chipGap: number;\r\n  chipRows: number[][];\r\n  sendSize: number;\r\n  sendRight: number;\r\n  sendBottom: number;\r\n}\r\n\r\n/**\r\n * The whole geometry, from four numbers and the measured label widths.\r\n *\r\n * Every offset the recording gave up is in here either as a fixed inset or as a\r\n * ratio of a font size, so the defaults reproduce the reference exactly and any\r\n * other content still lands somewhere sensible. The panel's height is *derived*\r\n * — padding, field, the gap, however many chip rows there turned out to be — so\r\n * it hugs its content rather than being a constant that fits one sentence.\r\n */\r\nexport function layoutFor(o: {\r\n  width: number;\r\n  fieldHeight: number;\r\n  fontSize: number;\r\n  chipFontSize: number;\r\n  radius: number;\r\n  sendSize: number;\r\n  chipWidths: number[];\r\n}): PromptSendLayout {\r\n  const lineX = PAD + o.fontSize * LINE_PAD_X;\r\n  const chipHeight = o.chipFontSize * CHIP_HEIGHT;\r\n  const chipGap = o.chipFontSize * CHIP_GAP;\r\n  const chipsX = PAD + (lineX - PAD) * CHIP_INSET;\r\n  const chipRows = packChipRows(o.chipWidths, o.width - chipsX * 2, chipGap);\r\n  const chipsGap = o.chipFontSize * CHIP_TOP;\r\n\r\n  // The line only yields room to the send button when the two actually share a\r\n  // row. On the reference's 121px field they do not — the button sits well below\r\n  // the text — so the full width is the line's. Shrink the field to a single-row\r\n  // control and the line starts scrolling before it can run under the button.\r\n  const lineBottom = PAD + o.fontSize * LINE_PAD_Y + o.fontSize * LINE_HEIGHT;\r\n  const sendTop = PAD + o.fieldHeight - SEND_BOTTOM - o.sendSize;\r\n  const sendGutter =\r\n    lineBottom > sendTop ? o.sendSize + SEND_RIGHT + o.fontSize * 0.5 : 0;\r\n\r\n  // No chips → the panel simply hugs the field. With chips it opens up by the\r\n  // gap, the rows it needs, and its own bottom padding.\r\n  const below =\r\n    chipRows.length === 0\r\n      ? PAD\r\n      : chipsGap +\r\n        chipRows.length * chipHeight +\r\n        (chipRows.length - 1) * chipGap +\r\n        PAD * 2;\r\n  const panelHeight = PAD + o.fieldHeight + below;\r\n\r\n  return {\r\n    panelTop: (REF_H - panelHeight) / 2 + PANEL_BIAS,\r\n    panelWidth: o.width,\r\n    panelHeight,\r\n    pad: PAD,\r\n    fieldHeight: o.fieldHeight,\r\n    fieldRadius: Math.max(0, o.radius - 2),\r\n    lineX,\r\n    lineY: PAD + o.fontSize * LINE_PAD_Y,\r\n    lineHeight: o.fontSize * LINE_HEIGHT,\r\n    lineMaxWidth: Math.max(0, o.width - lineX * 2 - sendGutter),\r\n    caretWidth: o.fontSize * CARET_RATIO,\r\n    chipsX,\r\n    chipsGap,\r\n    chipHeight,\r\n    chipPadX: o.chipFontSize * CHIP_PAD_X,\r\n    chipGap,\r\n    chipRows,\r\n    sendSize: o.sendSize,\r\n    sendRight: SEND_RIGHT,\r\n    sendBottom: SEND_BOTTOM,\r\n  };\r\n}\r\n\r\n/** Accepts an array or the comma-separated string the customizer passes. */\r\nexport function chipList(chips?: string[] | string): string[] {\r\n  const list = typeof chips === \"string\" ? chips.split(\",\") : (chips ?? []);\r\n  return list.map((c) => c.trim()).filter(Boolean);\r\n}\r\n\r\n// One measuring context, reused. `measureText` runs once per label per frame,\r\n// and allocating a canvas each time is the sort of thing that only shows up\r\n// when somebody renders four minutes of it.\r\nlet measureCtx: CanvasRenderingContext2D | null | undefined;\r\n\r\n/** Advance width of `text`, measured on the face we actually draw. */\r\nexport function measureWidth(\r\n  text: string,\r\n  size: number,\r\n  family: string = SANS,\r\n  weight = 400,\r\n): number {\r\n  if (!text) return 0;\r\n  if (typeof document === \"undefined\") return text.length * size * 0.5;\r\n  if (measureCtx === undefined) {\r\n    measureCtx = document.createElement(\"canvas\").getContext(\"2d\");\r\n  }\r\n  if (!measureCtx) return text.length * size * 0.5;\r\n  measureCtx.font = `${weight} ${size}px ${family}, system-ui, sans-serif`;\r\n  return measureCtx.measureText(text).width;\r\n}\r\n\r\n// --- Cursor ----------------------------------------------------------------\r\n\r\n/**\r\n * The pointing hand, at the size the recording caught it: 18×27, hotspot on the\r\n * fingertip. Drawn in **stage** space, outside the camera — a pointer is a\r\n * property of the screen, not of the thing on it, so it must not scale when the\r\n * camera cuts in.\r\n */\r\nfunction HandCursor({\r\n  x,\r\n  y,\r\n  size,\r\n  fill,\r\n  stroke,\r\n}: {\r\n  x: number;\r\n  y: number;\r\n  size: number;\r\n  fill: string;\r\n  stroke: string;\r\n}) {\r\n  return (\r\n    <svg\r\n      viewBox=\"0 0 18 27\"\r\n      width={size * (18 / 27)}\r\n      height={size}\r\n      style={{\r\n        position: \"absolute\",\r\n        // The hotspot is the fingertip, which sits 6.2 of 18 across the glyph\r\n        // and 1 of 27 down it — not the box's corner.\r\n        left: x - size * (6.2 / 27),\r\n        top: y - size * (1 / 27),\r\n        display: \"block\",\r\n        filter: \"drop-shadow(0 1px 1.5px rgba(0,0,0,0.28))\",\r\n      }}\r\n    >\r\n      <title>Pointer</title>\r\n      <path\r\n        d=\"M4.1 15.6V3.1a2.1 2.1 0 0 1 4.2 0v7.6h.6l.3-1.5a1.7 1.7 0 0 1 3.4.3v1.5l.4-.5a1.7 1.7 0 0 1 3 1.1v1.1l.4-.2a1.6 1.6 0 0 1 1.9 1.6v4.6c0 3.6-2.4 6.3-6.1 6.3H9.6c-2.6 0-4-1-5.2-2.7l-3.2-4.6a1.7 1.7 0 0 1 2.5-2.2l.4.4Z\"\r\n        fill={fill}\r\n        stroke={stroke}\r\n        strokeWidth={1.1}\r\n        strokeLinejoin=\"round\"\r\n      />\r\n    </svg>\r\n  );\r\n}\r\n\r\n/** The send glyph: an up arrow, drawn to fill its disc the way the reference does. */\r\nfunction SendArrow({ size, color }: { size: number; color: string }) {\r\n  return (\r\n    <svg\r\n      viewBox=\"0 0 24 24\"\r\n      width={size}\r\n      height={size}\r\n      fill=\"none\"\r\n      stroke={color}\r\n      strokeWidth={2.2}\r\n      strokeLinecap=\"round\"\r\n      strokeLinejoin=\"round\"\r\n      style={{ display: \"block\" }}\r\n    >\r\n      <title>Send</title>\r\n      <path d=\"M12 19V5M5.5 11.5 12 5l6.5 6.5\" />\r\n    </svg>\r\n  );\r\n}\r\n\r\n// --- Props -----------------------------------------------------------------\r\n\r\nexport interface PromptSendProps {\r\n  /** The brief that types itself. Any length — the field scrolls under the caret. */\r\n  text?: string;\r\n  /** Shown until the first character lands. */\r\n  placeholder?: string;\r\n  /**\r\n   * The suggestion row under the field. Pass an array, or the comma-separated\r\n   * string the customizer sends. They wrap, and the panel grows to hold them;\r\n   * pass `[]` for a bare field.\r\n   */\r\n  chips?: string[] | string;\r\n  /** Replaces the up-arrow in the send button. */\r\n  sendIcon?: ReactNode;\r\n\r\n  // --- Size. Every default is the recording's own measurement. ---\r\n  /** Panel width, in stage px (the stage is 890×486, scaled to the composition). */\r\n  width?: number;\r\n  /** Height of the writing surface. The panel's height follows from it. */\r\n  fieldHeight?: number;\r\n  /** Prompt type size. The line box, caret and field padding all follow from it. */\r\n  fontSize?: number;\r\n  /** Chip label size. Chip height, padding and the row gap all follow from it. */\r\n  chipFontSize?: number;\r\n  /** Panel corner radius. The field's is this less 2, as the reference's is. */\r\n  radius?: number;\r\n  /** Diameter of the send button. */\r\n  sendSize?: number;\r\n  /** Overrides the loaded Inter — only useful if you have already loaded a face. */\r\n  fontFamily?: string;\r\n\r\n  // --- Timing, in seconds. ---\r\n  /** When the panel starts to unroll, and how long the unroll takes. */\r\n  revealAt?: number;\r\n  revealDuration?: number;\r\n  /** When the placeholder and the send button fade up. */\r\n  fieldAt?: number;\r\n  /** When the caret arrives (whole — it does not fade). */\r\n  caretAt?: number;\r\n  /** When the first chip starts, and the gap between them. */\r\n  chipsAt?: number;\r\n  chipStagger?: number;\r\n  /** When typing starts, and how long the whole sentence takes. */\r\n  typeStart?: number;\r\n  typeDuration?: number;\r\n  /** When the view cuts in to the caret, and back out to the button. */\r\n  cutInAt?: number;\r\n  cutOutAt?: number;\r\n  /** How far each cut pushes. Both are measured off the reference. */\r\n  zoomIn?: number;\r\n  zoomOut?: number;\r\n  /** Where the caret sits in frame while the camera rides it. */\r\n  focusX?: number;\r\n  focusY?: number;\r\n  /** Where the send button sits in frame after the second cut. */\r\n  outX?: number;\r\n  outY?: number;\r\n  /** When the pointer starts its approach, how long it takes, and when it clicks. */\r\n  cursorAt?: number;\r\n  cursorDuration?: number;\r\n  clickAt?: number;\r\n  /** Show the pointer at all. Off drops the click and the send bloom with it. */\r\n  cursor?: boolean;\r\n\r\n  // --- Paint. ---\r\n  /** The wash behind the panel and the send bloom. Defaults to `theme.primary`. */\r\n  accentColor?: string;\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n  speed?: number;\r\n}\r\n\r\n// --- Main composition ------------------------------------------------------\r\n\r\n/**\r\n * A prompt composer that unrolls from a hairline, writes a brief into itself\r\n * while the camera rides the caret, then cuts back out and gets sent.\r\n *\r\n * ## Four things were measured, and they are the component\r\n *\r\n * **The unroll.** It does not fade in and it does not scale up from nothing. A\r\n * 2px white line appears at the panel's top edge and the box grows *downward*\r\n * out of it — top edge pinned, bottom edge travelling its full height in 445ms —\r\n * while the width goes from 0.93 to 1. The writing surface and the chip strip\r\n * are two separate heights on the same curve with different durations, which is\r\n * why the strip surfaces from under the field late rather than being there from\r\n * the first frame.\r\n *\r\n * **The typing is eased.** 17 chars/sec on the first word, 33 in the middle, and\r\n * a visible settle on the last three. An ease-in-out sine over the character\r\n * count fits all 69 of the reference's to within 0.30 characters rms; no\r\n * constant rate is close.\r\n *\r\n * **The camera cuts, and then it rides.** 2.327× in a single frame, landing with\r\n * the caret 57% across the frame, then tracking left with the sentence — pinned\r\n * to the *continuous* typing curve, so the caret wobbles ±8px about its mark as\r\n * each character jumps ahead of the slide. Then it cuts again, out to 1.44×,\r\n * centred on the send button, which is where the pointer is already heading.\r\n *\r\n * **The pointer is a real mouse.** It enters the bottom-right corner and its\r\n * distance to the button halves every 44ms — an exponential approach, not a\r\n * constant glide. It is drawn outside the camera because a pointer belongs to\r\n * the screen, not to the scene, and must not grow when the shot pushes in.\r\n *\r\n * ## Nothing here is a constant tuned to one sentence\r\n *\r\n * Every offset above is either a fixed inset or a ratio of a font size, and\r\n * `layoutFor` turns four numbers — `width`, `fieldHeight`, `fontSize`,\r\n * `chipFontSize` — into the whole geometry. Longer copy scrolls the field under\r\n * the caret instead of running past its edge; more chips wrap and the panel\r\n * grows by exactly the rows they needed; no chips at all and it hugs the field.\r\n * Both camera marks are fractions of the frame, so a wider panel reframes rather\r\n * than drifting off it.\r\n *\r\n * ## What is not measured\r\n *\r\n * The colours and the wording. The reference is a specific product with a\r\n * specific blue; none of that belongs in a component that ships to strangers and\r\n * lands next to somebody else's `Input` (design-system rule 5). The paint is the\r\n * shadcn token set, the field takes its surface from the `Input` primitive's own\r\n * style context so the two cannot drift, the wash is layered from `accentColor`\r\n * (`theme.primary` by default), and every string is a prop.\r\n */\r\nexport function PromptSend({\r\n  text = \"Add a text reveal, a soft blur transition, and a gradient background\",\r\n  placeholder = \"Describe the scene you want…\",\r\n  chips = [\r\n    \"Add a text reveal\",\r\n    \"Try a blur transition\",\r\n    \"Pick a background\",\r\n    \"Assemble a scene\",\r\n  ],\r\n  sendIcon,\r\n  width = 636.2,\r\n  fieldHeight = 121.2,\r\n  fontSize = 14,\r\n  chipFontSize = 12.3,\r\n  radius = 22,\r\n  sendSize = 27.4,\r\n  fontFamily,\r\n  revealAt = 0.025,\r\n  revealDuration = PANEL_GROW,\r\n  fieldAt = 0.417,\r\n  caretAt = 0.742,\r\n  chipsAt = 0.545,\r\n  chipStagger = 0.1,\r\n  typeStart = 0.915,\r\n  typeDuration = 3.025,\r\n  cutInAt = 1.975,\r\n  cutOutAt = 4.008,\r\n  zoomIn = 2.327,\r\n  zoomOut = 1.44,\r\n  focusX = 0.573,\r\n  focusY = 0.4881,\r\n  outX = 0.5305,\r\n  outY = 0.5261,\r\n  cursorAt = 4.042,\r\n  cursorDuration = 0.42,\r\n  clickAt = 4.658,\r\n  cursor = true,\r\n  accentColor,\r\n  theme,\r\n  mode,\r\n  speed = 1,\r\n}: PromptSendProps) {\r\n  const frame = useCurrentFrame();\r\n  const { width: compWidth, height: compHeight, fps } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode);\r\n  const face = resolveFont(fontFamily ?? t.fontFamily) ?? SANS;\r\n  const ui = inputStyleContext(t);\r\n  const accent = accentColor ?? t.primary;\r\n\r\n  const now = (frame * speed) / fps;\r\n  const stageScale = Math.min(compWidth / REF_W, compHeight / REF_H);\r\n\r\n  // --- layout -------------------------------------------------------------\r\n  const labels = chipList(chips);\r\n  const L = layoutFor({\r\n    width,\r\n    fieldHeight,\r\n    fontSize,\r\n    chipFontSize,\r\n    radius,\r\n    sendSize,\r\n    chipWidths: labels.map(\r\n      (c) =>\r\n        measureWidth(c, chipFontSize, face) + chipFontSize * CHIP_PAD_X * 2 + 2,\r\n    ),\r\n  });\r\n\r\n  // --- reveal -------------------------------------------------------------\r\n  const panelH = L.panelHeight * beat(now, revealAt, revealDuration);\r\n  const fieldH =\r\n    L.fieldHeight * beat(now, revealAt, revealDuration * FIELD_GROW);\r\n  const panelW =\r\n    L.panelWidth * (WIDEN_FROM + (1 - WIDEN_FROM) * beat(now, revealAt, WIDEN));\r\n  const panelLeft = (REF_W - panelW) / 2;\r\n  // The chips hang off the field's bottom edge, so they ride its growth and are\r\n  // already in place by the time the first one fades up.\r\n  const fieldBottom = L.pad + fieldH;\r\n\r\n  const fieldIn = interpolate(now, [fieldAt, fieldAt + FIELD_FADE], [0, 1], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n\r\n  // --- typing -------------------------------------------------------------\r\n  const count = typedCount(now, typeStart, typeDuration, text.length);\r\n  const typed = text.slice(0, count);\r\n  const progress = typedProgress(now, typeStart, typeDuration);\r\n  const fullWidth = measureWidth(text, fontSize, face);\r\n\r\n  // The line rides the *continuous* curve, so a sentence longer than the field\r\n  // scrolls under the caret the way a real single-line input does — and the\r\n  // caret, quantised to whole characters, hops either side of the mark rather\r\n  // than the whole line jerking once per keystroke.\r\n  const advance = fullWidth * progress;\r\n  const room = Math.max(0, L.lineMaxWidth - L.caretWidth);\r\n  const scrolled = Math.max(0, advance - room);\r\n  const caretSceneX = panelLeft + L.lineX + Math.min(advance, room);\r\n\r\n  const caretAnchor =\r\n    count === 0\r\n      ? caretAt\r\n      : // Clamped to `now`: the count is rounded, so the inverse of the ease can\r\n        // put the \"last keystroke\" a few milliseconds in the future — and a\r\n        // blink anchored in the future reads as a caret that is off while you\r\n        // are typing.\r\n        Math.min(\r\n          now,\r\n          Math.max(\r\n            caretAt,\r\n            // `count - 0.5` because the count is *rounded*: the character\r\n            // appears when the eased value crosses the half, and that crossing\r\n            // is the keystroke the caret's blink hangs off.\r\n            keystrokeAt(count - 0.5, typeStart, typeDuration, text.length),\r\n          ),\r\n        );\r\n  const caretLit = now >= caretAt && caretOn(now, caretAnchor, BLINK);\r\n\r\n  // --- camera -------------------------------------------------------------\r\n  const sendX = panelLeft + panelW - L.pad - L.sendRight - L.sendSize / 2;\r\n  const sendY =\r\n    L.panelTop + L.pad + L.fieldHeight - L.sendBottom - L.sendSize / 2;\r\n  const shot = cameraFor(now, {\r\n    cutInAt,\r\n    cutOutAt,\r\n    zoomIn,\r\n    zoomOut,\r\n    caretX: caretSceneX,\r\n    caretY: L.panelTop + L.lineY + L.lineHeight / 2,\r\n    sendX,\r\n    sendY,\r\n    focusX,\r\n    focusY,\r\n    outX,\r\n    outY,\r\n  });\r\n\r\n  // --- pointer ------------------------------------------------------------\r\n  const approach = interpolate(\r\n    now,\r\n    [cursorAt, cursorAt + cursorDuration],\r\n    [0, 1],\r\n    {\r\n      extrapolateLeft: \"clamp\",\r\n      extrapolateRight: \"clamp\",\r\n      easing: CURSOR_EASE,\r\n    },\r\n  );\r\n  // It parks just up and right of dead centre on the button, which is where a\r\n  // hand cursor actually lands when you aim at a target this size.\r\n  const sendScreenX = shot.x + shot.scale * sendX + sendSize * 0.098;\r\n  const sendScreenY = shot.y + shot.scale * sendY - sendSize * 0.091;\r\n  const cursorX = interpolate(approach, [0, 1], [REF_W * 0.86, sendScreenX]);\r\n  const cursorY = interpolate(approach, [0, 1], [REF_H * 1.02, sendScreenY]);\r\n\r\n  // --- press and send -----------------------------------------------------\r\n  const press = !cursor\r\n    ? 0\r\n    : now < clickAt\r\n      ? 0\r\n      : now < clickAt + PRESS_DOWN\r\n        ? (now - clickAt) / PRESS_DOWN\r\n        : Math.max(0, 1 - (now - clickAt - PRESS_DOWN) / PRESS_UP);\r\n  const pressScale = 1 - (1 - PRESS_SCALE) * press;\r\n  // The send bloom. It opens 220ms after the press — the reference's does — and\r\n  // sweeps across the field rather than sitting still. The recording ends 140ms\r\n  // into it, so the opening is measured and the rest is ours.\r\n  const glow = !cursor\r\n    ? 0\r\n    : beat(now, clickAt + 0.22, 0.3, Easing.out(Easing.quad));\r\n  const sweep = beat(now, clickAt + 0.22, 1.1, Easing.out(Easing.quad));\r\n\r\n  // --- paint --------------------------------------------------------------\r\n  // A hairline is specified at a 40px control; this panel is much taller, so the\r\n  // token is walked toward the background through the system's own mix rather\r\n  // than by picking a lighter grey (design-system rule 3b).\r\n  const hairline = mixOklch(ui.idleBorder, t.background, 0.1);\r\n  // A transparent page asks for no page: the wash is the page's, so it goes too.\r\n  const bare = parseColor(t.background).alpha === 0;\r\n  const surface = withAlpha(t.card, 0.94);\r\n  const glassy = withAlpha(t.card, 0.52);\r\n  const sendIdle = mixOklch(t.foreground, t.card, 0.55);\r\n  const armed = count > 0;\r\n\r\n  const isRendering = getRemotionEnvironment().isRendering;\r\n  const willChange = isRendering ? undefined : (\"transform\" as const);\r\n\r\n  return (\r\n    <AbsoluteFill style={{ background: t.background }}>\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: \"50%\",\r\n          top: \"50%\",\r\n          width: REF_W,\r\n          height: REF_H,\r\n          transform: `translate(-50%, -50%) scale(${stageScale})`,\r\n          overflow: \"hidden\",\r\n        }}\r\n      >\r\n        {/* The camera. A plain static transform per shot — never interpolated\r\n            between them, so there is no frame on which a cut is halfway. */}\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            transform: `translate(${shot.x}px, ${shot.y}px) scale(${shot.scale})`,\r\n            transformOrigin: \"0 0\",\r\n            willChange,\r\n          }}\r\n        >\r\n          {/* The backdrop rides *inside* the camera, because on the reference it\r\n              does — the wash grows with everything else when the shot pushes in.\r\n              It is drawn on an oversized box (and positioned in px, not %, so\r\n              the maths stays the stage's) because the second cut frames past the\r\n              stage's right edge and a wash that stopped there would show a seam.\r\n\r\n              The shape is the reference's: a cool field falling from the top\r\n              right, a bright patch left of centre, a warm corner under it. The\r\n              paint is not — it is layered as alpha over the installer's own\r\n              `background` and `accentColor` (design-system rule 5). Alpha, not\r\n              `mixOklch`: hue interpolation from a near-neutral page colour to\r\n              blue takes the short way round, through green. */}\r\n          {!bare && (\r\n            <div\r\n              style={{\r\n                position: \"absolute\",\r\n                left: -OX,\r\n                top: -OY,\r\n                width: REF_W * BLEED,\r\n                height: REF_H * BLEED,\r\n                background: t.background,\r\n                backgroundImage: [\r\n                  `radial-gradient(${0.96 * REF_W}px ${0.8 * REF_H}px at ${OX + 0.06 * REF_W}px ${OY + 0.98 * REF_H}px, ${withAlpha(t.background, 0.9)} 0%, transparent 62%)`,\r\n                  `radial-gradient(${0.74 * REF_W}px ${0.62 * REF_H}px at ${OX + 0.1 * REF_W}px ${OY + 0.46 * REF_H}px, ${withAlpha(t.card, 0.42)} 0%, transparent 66%)`,\r\n                  `linear-gradient(215deg, ${withAlpha(accent, 0.5)} 0%, ${withAlpha(accent, 0.28)} 52%, ${withAlpha(accent, 0.14)} 100%)`,\r\n                ].join(\",\"),\r\n              }}\r\n            />\r\n          )}\r\n\r\n          {/* ---- The glass panel */}\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: panelLeft,\r\n              top: L.panelTop,\r\n              width: panelW,\r\n              height: panelH,\r\n              borderRadius: radius,\r\n              background: glassy,\r\n              // The hairline is an inset shadow, not a border: a border is\r\n              // layout, and every measured offset below is from the panel's own\r\n              // box. One pixel of border would push all of them one pixel in.\r\n              boxShadow: `inset 0 0 0 1px ${withAlpha(t.card, 0.6)}, 0 12px 32px ${withAlpha(t.foreground, 0.05)}`,\r\n              overflow: \"hidden\",\r\n            }}\r\n          >\r\n            {/* ---- The writing surface */}\r\n            <div\r\n              style={{\r\n                position: \"absolute\",\r\n                left: L.pad,\r\n                top: L.pad,\r\n                width: Math.max(0, panelW - L.pad * 2),\r\n                height: fieldH,\r\n                borderRadius: L.fieldRadius,\r\n                background: surface,\r\n                boxShadow: `0 6px 18px ${withAlpha(t.foreground, 0.05)}`,\r\n                overflow: \"hidden\",\r\n              }}\r\n            >\r\n              {/* The send bloom: what the click buys you. Inside the field so it\r\n                  is clipped by its radius, the way the reference's is. */}\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  inset: 0,\r\n                  opacity: glow,\r\n                  background: `radial-gradient(80% 170% at ${16 + sweep * 66}% 96%, ${withAlpha(accent, 0.55)} 0%, transparent 66%)`,\r\n                }}\r\n              />\r\n\r\n              {/* The prompt line, translated left once the sentence outgrows the\r\n                  field. Caret between the value and the placeholder, which is\r\n                  where the reference puts it — the placeholder starts one caret\r\n                  width right of the text origin, not on it. */}\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  left: L.lineX - L.pad - scrolled,\r\n                  top: L.lineY - L.pad,\r\n                  display: \"flex\",\r\n                  alignItems: \"center\",\r\n                  height: L.lineHeight,\r\n                  fontFamily: face,\r\n                  fontWeight: 400,\r\n                  fontSize,\r\n                  lineHeight: `${L.lineHeight}px`,\r\n                  color: t.foreground,\r\n                  whiteSpace: \"pre\",\r\n                  textRendering: \"geometricPrecision\",\r\n                }}\r\n              >\r\n                {typed}\r\n                <span\r\n                  style={{\r\n                    display: \"inline-block\",\r\n                    width: L.caretWidth,\r\n                    height: L.lineHeight,\r\n                    background: t.foreground,\r\n                    opacity: caretLit ? 1 : 0,\r\n                    flexShrink: 0,\r\n                  }}\r\n                />\r\n                {count === 0 ? (\r\n                  <span style={{ color: ui.mutedForeground, opacity: fieldIn }}>\r\n                    {placeholder}\r\n                  </span>\r\n                ) : null}\r\n              </div>\r\n\r\n              {/* ---- Send */}\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  right: L.sendRight,\r\n                  bottom: L.sendBottom,\r\n                  width: L.sendSize,\r\n                  height: L.sendSize,\r\n                  borderRadius: L.sendSize / 2,\r\n                  background: armed ? t.foreground : sendIdle,\r\n                  display: \"flex\",\r\n                  alignItems: \"center\",\r\n                  justifyContent: \"center\",\r\n                  opacity: fieldIn,\r\n                  transform: `scale(${pressScale})`,\r\n                  willChange,\r\n                }}\r\n              >\r\n                {sendIcon ?? (\r\n                  <SendArrow size={L.sendSize * 0.56} color={t.card} />\r\n                )}\r\n              </div>\r\n            </div>\r\n\r\n            {/* ---- Suggestions */}\r\n            <div\r\n              style={{\r\n                position: \"absolute\",\r\n                left: L.chipsX,\r\n                top: fieldBottom + L.chipsGap,\r\n                right: L.chipsX,\r\n                display: \"flex\",\r\n                flexDirection: \"column\",\r\n                gap: L.chipGap,\r\n              }}\r\n            >\r\n              {L.chipRows.map((row) => (\r\n                <div\r\n                  key={row.join(\"-\")}\r\n                  style={{ display: \"flex\", gap: L.chipGap }}\r\n                >\r\n                  {row.map((i) => {\r\n                    const p = beat(\r\n                      now,\r\n                      chipsAt + i * chipStagger,\r\n                      CHIP_DUR,\r\n                      CHIP_EASE,\r\n                    );\r\n                    return (\r\n                      <Item key={labels[i]} index={i}>\r\n                        <div\r\n                          style={{\r\n                            boxSizing: \"border-box\",\r\n                            height: L.chipHeight,\r\n                            padding: `0 ${L.chipPadX}px`,\r\n                            borderRadius: L.chipHeight / 2,\r\n                            background: t.card,\r\n                            border: `1px solid ${hairline}`,\r\n                            color: t.foreground,\r\n                            fontFamily: face,\r\n                            fontWeight: 400,\r\n                            fontSize: chipFontSize,\r\n                            // The label rides low in the pill on the reference,\r\n                            // which is what stops a small label in a round pill\r\n                            // reading as though it were floating.\r\n                            paddingTop: chipFontSize * 0.17073,\r\n                            lineHeight: `${L.chipHeight - 4}px`,\r\n                            whiteSpace: \"nowrap\",\r\n                            textRendering: \"geometricPrecision\",\r\n                            opacity: p,\r\n                            transform: `translateY(${(1 - p) * CHIP_RISE}px)`,\r\n                            willChange,\r\n                          }}\r\n                        >\r\n                          {labels[i]}\r\n                        </div>\r\n                      </Item>\r\n                    );\r\n                  })}\r\n                </div>\r\n              ))}\r\n            </div>\r\n          </div>\r\n        </div>\r\n\r\n        {cursor && approach > 0 ? (\r\n          <HandCursor\r\n            x={cursorX}\r\n            y={cursorY}\r\n            size={27}\r\n            fill={t.card}\r\n            stroke={mixOklch(t.foreground, t.card, 0.2)}\r\n          />\r\n        ) : null}\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n"}]}