{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "insights",
  "type": "registry:block",
  "title": "Insights block",
  "description": "Seven raised panels, one idea each: reply times as a dot plot, shortcuts as a bar list, a mail rule, a voice pad, a deploy timeline, a credits gauge and a heatmap of credits by day. Two columns when wide, one on a phone, and Create rule is the one accent fill.",
  "registryDependencies": [
    "https://littmd.vercel.app/r/litt.json",
    "https://littmd.vercel.app/r/avatar.json",
    "https://littmd.vercel.app/r/bar-list.json",
    "https://littmd.vercel.app/r/button.json",
    "https://littmd.vercel.app/r/callout.json",
    "https://littmd.vercel.app/r/chart.json",
    "https://littmd.vercel.app/r/dot-plot.json",
    "https://littmd.vercel.app/r/gauge.json",
    "https://littmd.vercel.app/r/heatmap.json",
    "https://littmd.vercel.app/r/input.json",
    "https://littmd.vercel.app/r/kbd.json",
    "https://littmd.vercel.app/r/pad.json",
    "https://littmd.vercel.app/r/segmented.json",
    "https://littmd.vercel.app/r/tag.json",
    "https://littmd.vercel.app/r/timeline.json",
    "https://littmd.vercel.app/r/token-input.json"
  ],
  "files": [
    {
      "path": "registry/litt/components/litt-blocks/insights.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n// @litt/insights 2026.10.26. What changed: https://littmd.vercel.app/changelog.md\n\n/**\n * Insights: a studio's inbox and build insights, in the data colors. A block: a whole screen built from the litt parts,\n * to copy and make your own. Swap the sample data at the top for yours; the panels and their words stay.\n *\n * Seven raised panels, one idea each: a dot plot of reply times, a bar list of shortcuts, a mail rule, a voice pad, a\n * deploy timeline, a credits gauge and a heatmap of the credits by day. Each hue means one thing in its panel (R7), the\n * deploy stays in the quiet foreground, and Create rule is the one accent fill. Two columns when the box is wide, one\n * on a phone.\n */\nimport { useId, useMemo, useState, type ReactNode } from \"react\";\nimport { Avatar } from \"../litt/avatar\";\nimport { BarList } from \"../litt/bar-list\";\nimport { Button } from \"../litt/button\";\nimport { Meter } from \"../litt/chart\";\nimport { Callout } from \"../litt/callout\";\nimport { DotPlot } from \"../litt/dot-plot\";\nimport { Gauge } from \"../litt/gauge\";\nimport { Heatmap } from \"../litt/heatmap\";\nimport { TextField } from \"../litt/input\";\nimport { Kbd } from \"../litt/kbd\";\nimport { Pad, type PadValue } from \"../litt/pad\";\nimport { Segmented } from \"../litt/segmented\";\nimport { Tag } from \"../litt/tag\";\nimport { Timeline, TimelineBar, TimelinePhase, TimelineResult, TimelineStep } from \"../litt/timeline\";\nimport { TokenInput } from \"../litt/token-input\";\n\n/* ----------------------------------------------------------------- data */\n\n/** A seeded generator (mulberry32), so the block draws the same data on every load and on the server. */\nfunction seeded(seed: number) {\n  let a = seed >>> 0;\n  return () => {\n    a = (a + 0x6d2b79f5) >>> 0;\n    let t = a;\n    t = Math.imul(t ^ (t >>> 15), t | 1);\n    t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n  };\n}\n\n/** Reply times in minutes, spread like real ones: most within the hour, a long tail into days. */\nfunction replyMinutes(seed: number, count: number, median: number, spread: number) {\n  const next = seeded(seed);\n  return Array.from({ length: count }, () => {\n    const z = Math.sqrt(-2 * Math.log(Math.max(next(), 1e-9))) * Math.cos(2 * Math.PI * next());\n    return Math.round(Math.min(1700, Math.max(3, median * Math.exp(spread * z))) * 10) / 10;\n  });\n}\n\nconst VIP = replyMinutes(21, 140, 34, 0.9);\nconst TEAM = [...replyMinutes(22, 270, 92, 1.1), 1980];\nconst REPLIES = { all: [...VIP, ...TEAM], vip: VIP, team: TEAM };\ntype Who = keyof typeof REPLIES;\n\nfunction duration(minutes: number) {\n  const t = Math.round(minutes);\n  if (t < 60) return `${t} m`;\n  if (t < 1440) return t % 60 ? `${Math.floor(t / 60)} h ${t % 60} m` : `${t / 60} h`;\n  return `${Math.round(t / 1440)} d`;\n}\n\nconst median = (values: number[]) => {\n  const sorted = [...values].sort((a, b) => a - b);\n  const mid = sorted.length / 2;\n  return sorted.length % 2 ? sorted[Math.floor(mid)]! : (sorted[mid - 1]! + sorted[mid]!) / 2;\n};\n\n/** Daily credit use for three months, with the days still to come left out. */\nfunction usage(seed: number, days: number, upTo = days) {\n  const next = seeded(seed);\n  return Array.from({ length: days }, (_, i) => (i < upTo ? Math.round(300 + next() * 1100 * (i % 7 < 5 ? 1 : 0.35)) : null));\n}\nconst MONTHS = [\n  { label: \"August\", values: usage(31, 31) },\n  { label: \"September\", values: usage(32, 30) },\n  { label: \"October\", values: usage(33, 31, 17) },\n].map((m) => ({ ...m, total: m.values.reduce<number>((sum, v) => sum + (v ?? 0), 0).toLocaleString(\"en-GB\") }));\n\nconst DEPLOY = [\n  {\n    label: \"Build\",\n    steps: [\n      { label: \"Clone repository\", seconds: 2, status: \"done\" as const },\n      { label: \"Restore build cache\", seconds: 4, status: \"done\" as const },\n      { label: \"Run build commands\", seconds: 21, status: \"done\" as const },\n    ],\n  },\n  {\n    label: \"Deploy\",\n    steps: [\n      { label: \"Upload build output\", seconds: 9, status: \"done\" as const },\n      { label: \"Assign atelier-nord.com\", seconds: 2, status: \"done\" as const },\n    ],\n  },\n];\n\n/* ----------------------------------------------------------------- the panels */\n\n/** A raised panel with a title and a tag: one idea per panel. `wide` spans both columns of the grid. */\nfunction Panel({ title, tag, wide = false, children }: { title: string; tag: ReactNode; wide?: boolean; children: ReactNode }) {\n  const id = useId();\n  return (\n    <section\n      aria-labelledby={id}\n      className={\"litt-raised grid min-w-0 content-start gap-6 rounded-litt-surface p-6 max-sm:p-4\" + (wide ? \" @min-[56rem]:col-span-2\" : \"\")}\n    >\n      <header className=\"flex items-center gap-3\">\n        <h3 id={id} className=\"text-litt-body text-litt-fg\">\n          {title}\n        </h3>\n        {tag}\n      </header>\n      {children}\n    </section>\n  );\n}\n\n/** A figure with its word and a change said in words, like the Stat, inside a panel. */\nfunction Figure({ value, word, delta }: { value: string; word: string; delta: string }) {\n  return (\n    <div className=\"grid gap-1\">\n      <p className=\"flex items-baseline gap-2\">\n        <span className=\"text-litt-h3 tabular-nums text-litt-fg\">{value}</span>\n        <span className=\"text-litt-small text-litt-fg-subtle\">{word}</span>\n      </p>\n      <p className=\"text-litt-caption text-litt-success\">\n        {delta}\n        <span className=\"sr-only\">, good news</span>\n      </p>\n    </div>\n  );\n}\n\nfunction ReplySpeed() {\n  const [who, setWho] = useState<Who>(\"all\");\n  const values = REPLIES[who];\n  const mid = useMemo(() => median(values), [values]);\n  return (\n    <Panel title=\"Reply speed\" tag={<Tag>14 days</Tag>}>\n      <div className=\"flex flex-wrap items-end justify-between gap-4\">\n        <Figure value={duration(mid)} word=\"median\" delta=\"Down 18 min on the fortnight before\" />\n        <Segmented\n          legend=\"Whose replies\"\n          size=\"sm\"\n          value={who}\n          onValueChange={setWho}\n          options={[\n            { value: \"all\", label: \"All\" },\n            { value: \"vip\", label: \"VIP\" },\n            { value: \"team\", label: \"Team\" },\n          ]}\n        />\n      </div>\n      <DotPlot\n        label=\"Reply times, last 14 days\"\n        values={values}\n        scale=\"log\"\n        domain={[3, 2880]}\n        ticks={[\n          { value: 5, label: \"5m\" },\n          { value: 60, label: \"1h\" },\n          { value: 240, label: \"4h\" },\n          { value: 1440, label: \"1d\" },\n        ]}\n        formatValue={duration}\n        unit={[\"reply\", \"replies\"]}\n        goal={240}\n        goalLabel=\"4 h goal\"\n        markers={who === \"vip\" ? [] : [{ value: 1980, label: \"Rui · 33 h\" }]}\n        height={144}\n      />\n    </Panel>\n  );\n}\n\nfunction Shortcuts() {\n  return (\n    <Panel title=\"Shortcuts\" tag={<Tag>This week</Tag>}>\n      <Figure value=\"2 h 14 m\" word=\"saved\" delta=\"Up 18% on last week\" />\n      <BarList\n        label=\"Most-used shortcuts this week\"\n        unit={[\"time\", \"times\"]}\n        hue=\"violet\"\n        items={[\n          { label: \"Archive\", value: 412, lead: <Kbd>E</Kbd> },\n          { label: \"Next and previous\", value: 388, lead: <><Kbd>J</Kbd><Kbd>K</Kbd></> },\n          { label: \"Reply\", value: 164, lead: <Kbd>R</Kbd> },\n        ]}\n      />\n      <Callout title=\"Try H to snooze\" description=\"You snoozed 31 threads with the mouse this week.\" action={<Kbd>H</Kbd>} />\n    </Panel>\n  );\n}\n\nconst CAUGHT = [\n  { from: \"Stripe\", subject: \"Invoice #4821 is ready\" },\n  { from: \"Ramp\", subject: \"Your March invoice\" },\n  { from: \"Brex\", subject: \"Your invoice is paid\" },\n];\n\nfunction NewRule() {\n  return (\n    <Panel title=\"New rule\" tag={<Tag status=\"neutral\">Draft</Tag>}>\n      <div className=\"grid gap-4\">\n        <TokenInput label=\"Mail from\" defaultValue={[\"@stripe.com\", \"ramp.com\", \"brex.com\"]} collapseAfter={1} placeholder=\"Add a sender\" />\n        <TextField label=\"That says\" defaultValue=\"invoice\" />\n        <p className=\"flex items-center gap-3 text-litt-small text-litt-fg\">\n          Goes to <Tag hue=\"amber\">Finance</Tag>\n        </p>\n      </div>\n      <div className=\"grid gap-2\">\n        <p className=\"flex justify-between gap-4 text-litt-small text-litt-fg-subtle\">\n          Would catch <span className=\"text-litt-caption font-normal tabular-nums text-litt-fg\">12 of the last 50</span>\n        </p>\n        <ul aria-label=\"Mail the rule would catch\">\n          {CAUGHT.map((m) => (\n            <li key={m.from} className=\"flex items-center gap-3 border-t border-litt-line py-3 first:border-t-0\">\n              <Avatar name={m.from} size=\"sm\" hue=\"neutral\" decorative />\n              <span className=\"w-16 shrink-0 text-litt-small text-litt-fg\">{m.from}</span>\n              <span className=\"w-0 min-w-0 flex-1 truncate text-litt-small text-litt-fg-subtle\">{m.subject}</span>\n            </li>\n          ))}\n        </ul>\n      </div>\n      <div className=\"flex justify-end gap-3\">\n        <Button variant=\"secondary\">Test</Button>\n        <Button variant=\"primary\">Create rule</Button>\n      </div>\n    </Panel>\n  );\n}\n\nconst VOICE_DEFAULT: PadValue = { x: 30, y: 40 };\nconst tone = (y: number) => (y >= 70 ? \"Casual\" : y >= 45 ? \"Warm\" : y >= 25 ? \"Even\" : \"Formal\");\nconst words = (x: number) => 20 + 2 * x;\n\nfunction YourVoice() {\n  const [voice, setVoice] = useState<PadValue>({ x: 15, y: 60 });\n  const greeting = voice.y >= 45 ? \"Hey Maya,\" : \"Hello Maya,\";\n  const signoff = voice.y >= 45 ? \"Cheers, Ines\" : \"Best regards, Ines\";\n  return (\n    <Panel title=\"Your voice\" tag={<Tag>Learning</Tag>}>\n      <Pad\n        label=\"How your replies sound\"\n        x={{ label: \"Length\", min: 0, max: 100, step: 5, minLabel: \"Brief\", maxLabel: \"Detailed\" }}\n        y={{ label: \"Tone\", min: 0, max: 100, step: 5, minLabel: \"Formal\", maxLabel: \"Casual\" }}\n        value={voice}\n        onValueChange={setVoice}\n        defaultMark={VOICE_DEFAULT}\n        formatValue={({ x, y }) => `${tone(y)}, about ${words(x)} words`}\n        height={176}\n      />\n      <div className=\"grid gap-2 border-t border-litt-line pt-4\">\n        <p className=\"text-litt-small text-litt-fg-subtle\">Reply to Maya</p>\n        <p className=\"text-litt-body text-litt-fg\">\n          {greeting} Friday works. I will send the forecast by the end of the day. {signoff}\n        </p>\n        <div className=\"flex items-center justify-between gap-4\">\n          <span className=\"text-litt-caption font-normal text-litt-fg-subtle\">About {words(voice.x)} words</span>\n          <Button variant=\"secondary\" size=\"sm\" onClick={() => setVoice(VOICE_DEFAULT)}>\n            Reset\n          </Button>\n        </div>\n      </div>\n    </Panel>\n  );\n}\n\nfunction Deploy() {\n  const total = DEPLOY.flatMap((p) => p.steps).reduce((sum, s) => sum + s.seconds, 0);\n  let at = 0;\n  const clock = (s: number) => `00:${String(s).padStart(2, \"0\")}`;\n  return (\n    <Panel title=\"Publish Halo case study\" tag={<Tag status=\"success\">Live</Tag>}>\n      <div className=\"flex items-baseline justify-between gap-4\">\n        <p className=\"font-litt-mono text-litt-caption font-normal text-litt-fg-subtle\">Ines · main / 7be04d1</p>\n        <p className=\"text-litt-h3 tabular-nums text-litt-fg\">{total}s</p>\n      </div>\n      <TimelineBar label=\"Publish Halo case study\" phases={DEPLOY} />\n      <Timeline label=\"Steps of the deploy\">\n        {DEPLOY.map((phase) => (\n          <TimelinePhase key={phase.label} label={phase.label} duration={phase.steps.reduce((sum, s) => sum + s.seconds, 0)}>\n            {phase.steps.map((step) => {\n              const start = at;\n              at += step.seconds;\n              return <TimelineStep key={step.label} at={clock(start)} label={step.label} status={step.status} seconds={step.seconds} />;\n            })}\n          </TimelinePhase>\n        ))}\n        <TimelineResult tone=\"success\" label=\"Live on atelier-nord.com\" total={total} />\n      </Timeline>\n    </Panel>\n  );\n}\n\nfunction Credits() {\n  return (\n    <Panel title=\"Credits\" tag={<Tag>October</Tag>}>\n      <Gauge\n        label=\"Credits left\"\n        value={20830}\n        max={30000}\n        valueText=\"20,830 credits\"\n        figure=\"20,830\"\n        caption=\"About 2k a day on average\"\n        hue=\"teal\"\n        className=\"mx-auto\"\n      />\n      {/* What used them: one quantity per row, so the meters stay in the quiet foreground. */}\n      <div className=\"grid gap-4 border-t border-litt-line pt-4\">\n        <Meter label=\"Builds\" value={5240} max={9170} valueText=\"5,240\" />\n        <Meter label=\"Preview links\" value={2610} max={9170} valueText=\"2,610\" />\n        <Meter label=\"Image resizing\" value={1320} max={9170} valueText=\"1,320\" />\n      </div>\n    </Panel>\n  );\n}\n\n/** Every day of the last three months, one row each, at a pitch where every row keeps its name and its total. */\nfunction Usage() {\n  return (\n    <Panel title=\"Credits by month\" tag={<Tag>Aug to Oct</Tag>} wide>\n      <Heatmap\n        label=\"Credits used per day, by month\"\n        rows={MONTHS}\n        hue=\"teal\"\n        unit={[\"credit\", \"credits\"]}\n        columns={Array.from({ length: 31 }, (_, i) => `day ${i + 1}`)}\n        cell={12}\n      />\n    </Panel>\n  );\n}\n\n/** The panels in a grid that measures itself: two columns when it is wide, one on a phone. The heatmap spans both. */\nexport function Insights() {\n  return (\n    <div className=\"@container w-full\">\n      <div className=\"grid grid-cols-1 gap-6 @min-[56rem]:grid-cols-2\">\n        <ReplySpeed />\n        <Shortcuts />\n        <NewRule />\n        <YourVoice />\n        <Deploy />\n        <Credits />\n        <Usage />\n      </div>\n    </div>\n  );\n}\n",
      "target": "components/litt-blocks/insights.tsx"
    }
  ],
  "docs": "Import Insights from components/litt-blocks/insights, or copy the panels you need: each is its own function in the file, with its sample data above it. See it live at https://littmd.vercel.app/#insights.",
  "meta": {
    "version": "2026.10.26",
    "released": "2026-10-26",
    "changelog": "https://littmd.vercel.app/changelog.md"
  }
}
