create-pmos 0.324.0 → 0.326.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-calendar-2-test.js +8 -6
  7. package/workspace/briefing-premium-calendar-3-test.js +7 -4
  8. package/workspace/briefing-premium-calendar-test.js +4 -2
  9. package/workspace/guide/briefing-premium.md +23 -2
  10. package/workspace/lib/engine/boards.js +28 -1
  11. package/workspace/lib/routes-boards.js +2 -2
  12. package/workspace/package-lock.json +2 -2
  13. package/workspace/package.json +1 -1
  14. package/workspace/premium-vw-backlog-test.js +127 -0
  15. package/workspace/premium-vw-doc-test.js +3 -1
  16. package/workspace/premium-vw-item-test.js +128 -0
  17. package/workspace/premium-vw-meet-test.js +210 -0
  18. package/workspace/premium-vw-notes-test.js +161 -0
  19. package/workspace/premium-vw-rec-test.js +209 -0
  20. package/workspace/public/pm/premium-board.js +13 -1
  21. package/workspace/public/pm/premium-initiative.js +7 -2
  22. package/workspace/public/pm/premium-meeting.js +106 -32
  23. package/workspace/public/pm/premium-shell.js +8 -2
  24. package/workspace/public/pm/premium-vw-backlog.css +30 -0
  25. package/workspace/public/pm/premium-vw-backlog.js +91 -0
  26. package/workspace/public/pm/premium-vw-doc-model.js +3 -2
  27. package/workspace/public/pm/premium-vw-doc.css +1 -0
  28. package/workspace/public/pm/premium-vw-doc.js +7 -4
  29. package/workspace/public/pm/premium-vw-item-model.js +58 -0
  30. package/workspace/public/pm/premium-vw-item.css +25 -0
  31. package/workspace/public/pm/premium-vw-item.js +66 -0
  32. package/workspace/public/pm/premium-vw-jira.js +3 -1
  33. package/workspace/public/pm/premium-vw-meet.css +87 -0
  34. package/workspace/public/pm/premium-vw-meet.js +322 -0
  35. package/workspace/public/pm/premium-vw-notes.css +43 -0
  36. package/workspace/public/pm/premium-vw-notes.js +188 -0
  37. package/workspace/public/pm/premium-vw-rec.css +75 -0
  38. package/workspace/public/pm/premium-vw-rec.js +257 -0
  39. package/workspace/public/pm/premium.js +2 -0
  40. package/workspace/test-files.json +2 -0
  41. package/workspace/test-lists/premium-viewer.json +4 -2
  42. package/workspace/test-lists/premium-vw-backlog.json +13 -0
  43. package/workspace/test-lists/premium-vw-item.json +13 -0
  44. package/workspace/test-lists/premium-vw-meet.json +13 -0
  45. package/workspace/test-lists/premium-vw-notes.json +13 -0
@@ -0,0 +1,188 @@
1
+ /* pm/premium-vw-notes.js — the Notes list in the premium dialog (initiative premium-viewer, R9; console parity: c3-notes.js, the list).
2
+ *
3
+ * The Briefing's Calendar card has a Notes button. It opens the dialog with every meeting note in the detail pane, with a search
4
+ * field, grouped by what a note is about as the console groups them: Portfolio, each board in the portfolio's order, Initiatives (linked
5
+ * before boards were), then Not linked. The notes of one meeting series (two or more notes with one series key) are one entry: its
6
+ * title, the newest day, "N meetings", "series" and how many next steps are still open; it folds open to its newest three notes.
7
+ * Pressing a note opens its note sheet as a viewer tab (premium-vw-meet.js openNoteTab: Before, During and After, series paging,
8
+ * Since the last one, the notes tables). Pressing a series opens its newest note, which pages through the series.
9
+ *
10
+ * Data: GET /api/notes (rows and series_open), GET /api/boards (the group order), GET /api/notes/search (what was said). Every row
11
+ * field is a field of those answers; a part a note does not hold is left out.
12
+ */
13
+ import { vwStyle } from './premium-viewer.js';
14
+ import { openNoteTab } from './premium-vw-meet.js';
15
+
16
+ const pad = (n) => String(n).padStart(2, '0');
17
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
19
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
20
+ const startOf = (r) => (r.meeting && r.meeting.start) || r.recorded_from || r.created_at || r.updated_at;
21
+ const at = (r) => Date.parse(startOf(r)) || 0;
22
+ const boardKey = (b) => (b.ws || '') + '/' + b.id;
23
+ export const SEARCH_MIN = 2;
24
+
25
+ /** "Mon 19 Oct 10:00", the day and time a note's meeting began (or it was recorded). */
26
+ export function whenOf(iso, withTime = true) {
27
+ const t = new Date(iso);
28
+ if (!Number.isFinite(t.getTime())) return '';
29
+ return WD[t.getDay()] + ' ' + t.getDate() + ' ' + MON[t.getMonth()] + (withTime ? ' ' + pad(t.getHours()) + ':' + pad(t.getMinutes()) : '');
30
+ }
31
+ const lenOf = (ms) => (ms >= 60000 ? Math.round(ms / 60000) + ' min' : '');
32
+ const words = (q) => String(q || '').toLowerCase().split(/\s+/).filter(Boolean);
33
+
34
+ /** One note row as the list draws it. */
35
+ export function rowOf(r) {
36
+ const live = r.state === 'recording' || r.state === 'paused' ? r.state : '';
37
+ const linked = !!(r.meeting && (r.meeting.kind === 'event' || r.meeting.kind === 'adhoc'));
38
+ return {
39
+ id: r.id, title: clip(r.title || 'Untitled note', 120), when: whenOf(startOf(r)), day: whenOf(startOf(r), false), len: lenOf(r.meeting_ms || 0), live,
40
+ initiative: r.initiative && r.initiative.id ? clip(r.initiative.title || r.initiative.id, 60) : '',
41
+ board: !(r.initiative && r.initiative.id) && r.board && r.board.id ? 'board' : '',
42
+ noMeeting: !linked && !live, conflicts: r.conflicts || 0, gist: r.private ? '' : clip((r.summary_lines || [])[0] || '', 140),
43
+ };
44
+ }
45
+
46
+ /** A note matches the search when every word is in its title, meeting, initiative, board or first summary line, or the server found it. */
47
+ export function hits(r, q, found) {
48
+ const ws = words(q);
49
+ if (!ws.length) return true;
50
+ if (found && found.has(r.id)) return true;
51
+ const hay = [r.title, r.meeting && r.meeting.title, r.initiative && (r.initiative.title || r.initiative.id), r.board && (r.board.title || r.board.id),
52
+ r.private ? '' : (r.summary_lines || []).join(' ')].filter(Boolean).join(' ').toLowerCase();
53
+ return ws.every((w) => hay.includes(w));
54
+ }
55
+
56
+ /**
57
+ * The list, from the GET /api/notes answer: { state, count, groups: [{ key, label, entries }] }. An entry is a note
58
+ * { kind: 'note', row } or a series { kind: 'series', key, title, when, size, open, carried, rows } (rows newest first).
59
+ * opts = { boards (GET /api/boards boards), q, found (Set of ids from /api/notes/search) }
60
+ */
61
+ export function notesList(answer, opts = {}) {
62
+ if (!answer || answer.ok !== true) return { state: 'error', error: (answer && answer.error) || 'The notes could not be read.', count: 0, groups: [] };
63
+ const all = (answer.notes || []).filter((r) => r && r.id);
64
+ const shown = all.filter((r) => hits(r, opts.q, opts.found));
65
+ const boards = (opts.boards || []).filter((b) => b && b.id && !b.error);
66
+ const order = new Map(boards.map((b, i) => [boardKey(b), i])), names = new Map(boards.map((b) => [boardKey(b), b.name || b.title || b.id]));
67
+ const size = new Map();
68
+ for (const r of all) { const k = r.series && r.series.key; if (k) size.set(k, (size.get(k) || 0) + 1); }
69
+ const entries = new Map();
70
+ for (const r of shown) {
71
+ const k = r.series && r.series.key, ek = k && size.get(k) >= 2 ? 'S' + k : 'N' + r.id;
72
+ if (!entries.has(ek)) entries.set(ek, { ek, series: ek[0] === 'S' ? k : null, rows: [] });
73
+ entries.get(ek).rows.push(r);
74
+ }
75
+ const g = new Map();
76
+ for (const e of entries.values()) {
77
+ e.rows.sort((a, b) => at(b) - at(a));
78
+ const r = e.rows[0];
79
+ const k = r.portfolio ? '@portfolio' : r.board && r.board.id ? boardKey(r.board) : r.initiative && r.initiative.id ? '@initiative' : '';
80
+ if (!g.has(k)) g.set(k, { key: k, label: k === '@portfolio' ? 'Portfolio' : k === '@initiative' ? 'Initiatives' : !k ? 'Not linked' : names.get(k) || clip(r.board.title || r.board.id, 60), entries: [], t: 0 });
81
+ const o = e.series ? (answer.series_open || {})[e.series] : null;
82
+ g.get(k).entries.push(e.series
83
+ ? { kind: 'series', key: e.series, t: at(r), title: clip((r.meeting && r.meeting.kind === 'event' && r.meeting.title) || r.title || 'Untitled meeting', 120), when: whenOf(startOf(r)), size: size.get(e.series), open: o && o.open ? o.open : 0, carried: !!(o && o.carried), rows: e.rows.map(rowOf) }
84
+ : { kind: 'note', t: at(r), row: rowOf(r) });
85
+ }
86
+ for (const x of g.values()) x.entries.sort((a, b) => b.t - a.t);
87
+ const rank = (x) => (x.key === '@portfolio' ? [0, 0] : x.key === '@initiative' ? [3, 0] : !x.key ? [4, 0] : order.has(x.key) ? [1, order.get(x.key)] : [2, 0]);
88
+ const groups = [...g.values()].sort((a, b) => { const p = rank(a), q = rank(b); return p[0] - q[0] || p[1] - q[1] || a.label.localeCompare(b.label); })
89
+ .map(({ key, label, entries: es }) => ({ key, label, entries: es }));
90
+ return { state: 'ok', count: shown.length, total: all.length, groups };
91
+ }
92
+
93
+ /* ── html, pure ───────────────────────────────────────────────────────────────────────────────────────────────────── */
94
+
95
+ const ICP = { doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>', notes: '<path d="M7 3h7l4 4v14H7zM14 3v4h4M10 12h5M10 16h4"/>', next: '<path d="M9 6l6 6-6 6"/>', fold: '<path d="M6 9l6 6 6-6"/>', search: '<circle cx="11" cy="11" r="6"/><path d="M20 20l-4.5-4.5"/>', alert: '<path d="M12 4l9 16H3zM12 10v4M12 17h.01"/>' };
96
+ const ic = (k) => `<svg class="i" viewBox="0 0 24 24">${ICP[k]}</svg>`;
97
+
98
+ /** A note's row button. `sub` is a note under an open series: it shows its day and the first line of its summary. */
99
+ export function noteRowHtml(r, esc, sub) {
100
+ const meta = [r.live ? 'now' : sub ? r.day : r.when, r.len].filter(Boolean).join(' · ');
101
+ const tags = [r.live ? `<span class="vn-tg vn-live">${r.live === 'paused' ? 'paused' : 'recording'}</span>` : '',
102
+ !sub && r.initiative ? `<span class="vn-tg">${esc(r.initiative)}</span>` : '', !sub && r.board ? '<span class="vn-tg" title="Linked to the board, not to one initiative">board</span>' : '',
103
+ !sub && r.noMeeting ? '<span class="vn-tg" title="Not linked to a meeting">no meeting</span>' : '',
104
+ r.conflicts ? `<span class="vn-tg vn-warn" title="${r.conflicts} ${r.conflicts === 1 ? 'statement differs' : 'statements differ'} from a file">${ic('alert')}${r.conflicts}</span>` : ''].join('');
105
+ return `<li class="vn-r${sub ? ' vn-sub' : ''}"><button type="button" class="vn-o" data-vn-note="${esc(r.id)}"><span class="vn-k${r.live ? ' hot' : ''}">${ic(r.live ? 'mic' : 'doc')}</span><span class="vn-t"><b>${esc(sub && r.gist ? r.gist : r.title)}</b><small>${esc(meta)}</small></span><span class="vn-tgs">${tags}</span></button></li>`;
106
+ }
107
+
108
+ /** A series entry: its row (opens the newest note) and a fold control; open, its newest three notes. */
109
+ export function seriesHtml(e, esc, open) {
110
+ const more = e.rows.length > 3 ? `<li class="vn-r vn-sub vn-more"><span>${e.rows.length - 3} more in the series. Page through them from a note.</span></li>` : '';
111
+ const left = e.open ? `<span class="vn-tg${e.carried ? ' vn-warn' : ''}" title="${e.open} ${e.open === 1 ? 'next step is' : 'next steps are'} still open across the series">${e.open} open</span>` : '';
112
+ return `<li class="vn-r vn-ser"><button type="button" class="vn-o" data-vn-series="${esc(e.key)}" data-vn-note="${esc(e.rows[0].id)}"><span class="vn-k">${ic('notes')}</span><span class="vn-t"><b>${esc(e.title)}</b><small>${esc(e.when)} · ${e.size} meetings</small></span><span class="vn-tgs"><span class="vn-tg" title="A regular meeting: its notes are kept together">series</span>${left}</span></button><button type="button" class="vn-x" data-vn-fold="${esc(e.key)}" aria-expanded="${!!open}" aria-label="${open ? 'Hide its recent meetings' : 'Show its recent meetings'}">${ic(open ? 'fold' : 'next')}</button></li>`
113
+ + (open ? e.rows.slice(0, 3).map((r) => noteRowHtml(r, esc, true)).join('') + more : '');
114
+ }
115
+
116
+ /** The groups, or what is missing. `ui` = { q, expand: Set, searching } */
117
+ export function listBodyHtml(L, esc, ui = {}) {
118
+ if (!L) return '<p class="note vn-none" role="status">Reading the notes.</p>';
119
+ if (L.state === 'error') return `<p class="note vn-none" role="status">The notes could not be read. ${esc(L.error)}</p>`;
120
+ if (!L.total) return '<p class="note vn-none">No notes yet. Notes you record show here, grouped by what they are about.</p>';
121
+ if (!L.count) return `<p class="note vn-none" role="status">${ui.searching ? 'Searching what was said.' : `No note matches “${esc(String(ui.q || '').trim())}”.`}</p>`;
122
+ const q = words(ui.q).length > 0;
123
+ return L.groups.map((g) => `<section class="vn-g" data-vn-group="${esc(g.label)}"><h4>${esc(g.label)}<small>${g.entries.length}</small></h4><ul class="vn-l" role="list">${g.entries.map((e) => (e.kind === 'series' ? seriesHtml(e, esc, q || (ui.expand && ui.expand.has(e.key))) : noteRowHtml(e.row, esc))).join('')}</ul></section>`).join('');
124
+ }
125
+
126
+ export const countLine = (L) => (L && L.state === 'ok' ? (L.count === L.total ? `${L.total} ${L.total === 1 ? 'note' : 'notes'}` : `${L.count} of ${L.total} notes`) : '');
127
+
128
+ /* ── the dialog ──────────────────────────────────────────────────────────────────────────────────────────────────────── */
129
+
130
+ /** Adds the Notes button to the Briefing's Calendar card: in the header on a wide screen, and under the day on a phone, where the
131
+ * header has no room. deps: { $, esc, openDlg, toast, pmGet, pmPost, task } */
132
+ export function mountNotes(d) {
133
+ const card = d.$('#todayCard'), head = card && card.querySelector('.ch');
134
+ if (!head || d.$('#vnOpen')) return null;
135
+ vwStyle('notes');
136
+ const mk = (id, cls) => {
137
+ const b = document.createElement('button');
138
+ b.type = 'button'; b.id = id; b.className = cls; b.setAttribute('aria-haspopup', 'dialog'); b.title = 'Every meeting note, grouped by what it is about';
139
+ b.innerHTML = `${ic('notes')}<span>Notes</span>`;
140
+ b.onclick = () => openNotes(d);
141
+ return b;
142
+ };
143
+ const f = head.querySelector('.fbtn'), b = mk('vnOpen', 'vn-open');
144
+ if (f) f.before(b); else head.append(b);
145
+ card.append(mk('vnOpenFoot', 'vn-open vn-foot'));
146
+ return { open: () => openNotes(d) };
147
+ }
148
+
149
+ /** Opens the dialog with the Notes list in its detail pane. */
150
+ export async function openNotes(d) {
151
+ vwStyle('notes'); vwStyle('meet');
152
+ const ui = { q: '', expand: new Set(), found: null, searching: false, answer: null, boards: [], token: 0 };
153
+ d.openDlg({ eye: 'Calendar', title: 'Notes', label: 'Notes', say: 'Every meeting note you recorded, grouped by what it is about. Press one to open it beside the list.',
154
+ pane: `<div class="vn" id="vnList"><div class="vn-s"><label class="vn-q">${ic('search')}<input type="search" id="vnQ" placeholder="Search notes, decisions, what was said" aria-label="Search the notes" autocomplete="off"></label><span class="vn-c" id="vnCount" aria-live="polite"></span></div><div id="vnBody">${listBodyHtml(null, d.esc)}</div></div>` });
155
+ const box = d.$('#vnList');
156
+ const model = () => (ui.answer ? notesList(ui.answer, { boards: ui.boards, q: ui.q, found: ui.found }) : null);
157
+ const draw = () => {
158
+ if (!box.isConnected) return;
159
+ const L = model();
160
+ d.$('#vnBody').innerHTML = listBodyHtml(L, d.esc, ui);
161
+ d.$('#vnCount').textContent = countLine(L);
162
+ };
163
+ const read = async () => {
164
+ const [l, bs] = await Promise.all([d.pmGet('/api/notes'), d.pmGet('/api/boards')]);
165
+ ui.answer = l || { ok: false, error: 'no answer' };
166
+ ui.boards = bs && bs.ok && Array.isArray(bs.boards) ? bs.boards : [];
167
+ draw();
168
+ };
169
+ let findT = null;
170
+ box.oninput = (e) => {
171
+ if (e.target.id !== 'vnQ') return;
172
+ ui.q = e.target.value; ui.found = null; clearTimeout(findT);
173
+ const q = ui.q.trim(), my = ++ui.token;
174
+ ui.searching = q.length >= SEARCH_MIN; draw();
175
+ if (!ui.searching) return;
176
+ findT = setTimeout(async () => {
177
+ const r = await d.pmGet('/api/notes/search?q=' + encodeURIComponent(q));
178
+ if (my !== ui.token) return;
179
+ ui.searching = false; ui.found = new Set(r && r.ok && Array.isArray(r.ids) ? r.ids : []); draw();
180
+ }, 250);
181
+ };
182
+ box.onclick = (e) => {
183
+ const t = e.target.closest('button'); if (!t) return;
184
+ if (t.dataset.vnFold) { const k = t.dataset.vnFold; if (ui.expand.has(k)) ui.expand.delete(k); else ui.expand.add(k); draw(); const x = box.querySelector(`[data-vn-fold="${CSS.escape(k)}"]`); if (x) x.focus(); return; }
185
+ if (t.dataset.vnNote) openNoteTab({ pmGet: d.pmGet, pmPost: d.pmPost, esc: d.esc, toast: d.toast, task: d.task || (async () => ({ ok: false, text: 'Make task is not available on this page.' })), changed: read }, t.dataset.vnNote);
186
+ };
187
+ await read();
188
+ }
@@ -0,0 +1,75 @@
1
+ :root{--fs-1:11px;--fs-2:12px;--fs-3:14px;--fs-4:16px;--fs-5:20px;--fs-6:28px}
2
+ /* pm/premium-vw-rec.css — note recording in the premium viewer (premium-viewer S4): the Record control, the Live notes tab and the Focus tab. Loaded by vwStyle('rec'). */
3
+ .recctl{position:relative;display:inline-flex;align-items:stretch;border-radius:8px;background:var(--solid);color:var(--on-solid);flex:none}
4
+ .recctl[hidden]{display:none}
5
+ .recb{display:inline-flex;align-items:center;gap:7px;min-height:44px;padding:0 14px;font-size:var(--fs-2);font-weight:600;color:inherit;border-radius:6px}
6
+ .recb .i{width:16px;height:16px}
7
+ .recb.arr{padding:0 10px;border-left:1px solid var(--hair)}
8
+ .recb:focus-visible{outline:2px solid var(--ink);outline-offset:2px}
9
+ .recm{position:absolute;right:0;top:calc(100% + 8px);z-index:40;width:min(320px,calc(100vw - 32px));padding:8px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);box-shadow:var(--card-shadow);color:var(--ink)}
10
+ .recm[hidden]{display:none}
11
+ .recm .label{display:block;margin:4px 8px 6px}
12
+ .recm [role="menuitem"]{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:6px 10px;border-radius:6px;text-align:left;font-size:var(--fs-2);font-weight:500}
13
+ .recm [role="menuitem"] b{font-weight:600;flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
14
+ .recm [role="menuitem"] small{color:var(--ink-3);font-size:var(--fs-1);white-space:nowrap}
15
+ .recm [role="menuitem"]:focus-visible{background:var(--well)}
16
+ @media (hover:hover){.recm [role="menuitem"]:hover{background:var(--well)}}
17
+ .recm [role="menuitem"][disabled]{opacity:.55}
18
+ .recm [role="menuitem"] .i{width:16px;height:16px}
19
+ .recm .note{margin:4px 8px 8px}
20
+ .recask{padding:6px}
21
+ .recask p{margin:0 0 8px;font-size:var(--fs-2)}
22
+ .recask div,.rvask div{display:flex;flex-wrap:wrap;gap:8px}
23
+
24
+ .rvw .rvt{margin:0 0 10px;font-size:var(--fs-4);font-weight:600}
25
+ .rvh{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:10px 12px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);box-shadow:var(--card-shadow)}
26
+ .rvh b{font-size:var(--fs-3);font-weight:600}
27
+ .rvsp{flex:1 1 auto}
28
+ .rvclk{font-family:var(--mono);font-size:var(--fs-2);color:var(--ink-2)}
29
+ .rvdot{width:9px;height:9px;border-radius:50%;background:var(--bad);animation:br 1.6s ease-in-out infinite}
30
+ .rvdot.paused{background:var(--ember);animation:none}
31
+ .rvb{display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 13px;border-radius:6px;background:var(--well);font-size:var(--fs-2);font-weight:600;color:var(--ink)}
32
+ .rvb .i{width:15px;height:15px}
33
+ .rvb.cta{background:var(--solid);color:var(--on-solid)}
34
+ .rvb[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
35
+ .rvb:disabled{opacity:.55}
36
+ .rvb:focus-visible{outline:2px solid var(--ink);outline-offset:2px}
37
+ .rvask{margin:10px 0 0;padding:12px 14px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid)}
38
+ .rvask p{margin:0 0 10px;font-size:var(--fs-2)}
39
+ .rvopts{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:10px 0 0}
40
+ .rvsec{margin:16px 0 0}
41
+ .rvsec>.label{display:block;margin:0 0 6px}
42
+ .rvta{width:100%;box-sizing:border-box;min-height:96px;padding:10px 12px;border:1px solid var(--hair);border-radius:6px;background:var(--card-solid);color:var(--ink);font:inherit;font-size:var(--fs-3);resize:vertical}
43
+ .rvta:focus-visible{outline:2px solid var(--ink);outline-offset:1px}
44
+ .rvhl{list-style:none;margin:0;padding:0;display:grid;gap:6px}
45
+ .rvhl li{display:flex;gap:10px;align-items:baseline;padding:8px 10px;border-radius:8px;background:var(--well);font-size:var(--fs-2)}
46
+ .rvhl time,.rvtr time{font-family:var(--mono);font-size:var(--fs-1);color:var(--ink-3);flex:none}
47
+ .rvhl em{margin-left:auto;font-style:normal;font-size:var(--fs-1);color:var(--ink-3)}
48
+ .rvtr{max-height:340px;overflow-y:auto;display:grid;gap:6px;padding:2px}
49
+ .rvtr p{display:flex;gap:8px;align-items:baseline;margin:0;font-size:var(--fs-2);color:var(--ink-2)}
50
+ .rvtr p b{font-weight:600;color:var(--ink);flex:none}
51
+ .rvtr p.cur{color:var(--ink)}
52
+
53
+ .fvh{display:flex;align-items:baseline;flex-wrap:wrap;gap:10px;margin:0 0 12px}
54
+ .fvh b{font-size:var(--fs-4);font-weight:600}
55
+ .fvbar{display:flex;gap:3px;height:28px;margin:0 0 12px}
56
+ .fvbar span{flex:var(--fc-flex,1);display:grid;place-items:center;min-width:18px;border-radius:6px;background:var(--well);font-size:var(--fs-1);font-weight:600;color:var(--ink-2)}
57
+ .fvbar span.on{background:var(--solid);color:var(--on-solid)}
58
+ .fvnow{padding:12px 14px;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid);box-shadow:var(--card-shadow)}
59
+ .fvnow b{display:block;font-size:var(--fs-4);font-weight:600}
60
+ .fvnow p{margin:6px 0 0;font-size:var(--fs-3);color:var(--ink-2)}
61
+ .fvg{display:grid;grid-template-columns:1fr 1fr;gap:16px}
62
+ .fvtp{margin:0;padding-left:20px;display:grid;gap:4px;font-size:var(--fs-2)}
63
+ .fvtp li{color:var(--ink-2)}
64
+ .fvtp li.now{color:var(--ink);font-weight:600}
65
+ .fvtp small{margin-left:6px;color:var(--ink-3);font-size:var(--fs-1)}
66
+ .fvcap{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
67
+ .fvcap div{padding:8px 10px;border-radius:8px;background:var(--well)}
68
+ .fvcap b{display:block;font-size:var(--fs-4);font-weight:600}
69
+ .fvcap span{font-size:var(--fs-1);color:var(--ink-3)}
70
+ .fvst{list-style:none;margin:0;padding:0;display:grid;gap:8px}
71
+ .fvst li{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:8px 10px;border:1px solid var(--hair);border-radius:8px}
72
+ .fvst li>span{flex:1 1 12em;min-width:0}
73
+ .fvst b{display:block;font-weight:600;font-size:var(--fs-2);overflow-wrap:anywhere}
74
+ .fvst small{font-size:var(--fs-1);color:var(--ink-3)}
75
+ @media (max-width:700px){.fvg{grid-template-columns:1fr}.recb span{display:none}}
@@ -0,0 +1,257 @@
1
+ /* pm/premium-vw-rec.js — note recording in the premium viewer (initiative premium-viewer, S4; the prototype Wawan approved on 2026-10-19).
2
+ * The Briefing holds the recorder (PR 826), so the Record control is on the Briefing only: Record starts an untitled note at once, the arrow lists today's meetings
3
+ * (of today, not ended more than 10 minutes ago). While a note records, the chip has Highlight, Pause, Focus and Stop; other pages show its state with Open and Stop.
4
+ * The note being recorded opens as a viewer tab beside the dialog's detail: the During capture (state, Highlight, Pause or Resume, Stop, Private, your notes, the
5
+ * highlights and the transcript). Focus opens as a second tab: the meeting as it is now, with Present and Audience view on a deck or Google Slides in its material.
6
+ * renderDuring(el, id, d) → draws the During capture of note `id` into `el` and reads it again every 3 s while `el` is shown. The notes view calls it.
7
+ * openLive(id, d) · openFocus(id, d) · mountRecord(here, d) d = { openDlg, toast, pmGet, pmPost } from premium-shell.js
8
+ * Reads GET /api/notes/one, GET /api/meeting-focus. Writes through window.__premiumRec (premium-meeting.js: the console's recorder) and POST /api/notes/save,
9
+ * /api/notes/private. The pure half (menuView, duringView, chipActs, focusPath) takes the routes' answers, so a test reads it without a DOM. */
10
+ import { vwOpen, vwStyle, vwConfirm, vwState } from './premium-viewer.js';
11
+ import { recordable, focusView, mmss, CONSENT_LINE, STOP_LINE, RECORD_LINE, FOCUS_LINE } from './premium-meeting.js';
12
+
13
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
14
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
15
+ const hhmm = (s) => (typeof s === 'string' && /T\d{2}:\d{2}/.test(s) ? s.slice(11, 16) : '');
16
+ const SPEAKER = { mic: 'You', system: 'Them', tab: 'Them' };
17
+ export const NEW_LINE = 'Starts an untitled note now and listens to your microphone and the meeting’s sound. The audio and the notes stay on this machine.';
18
+ export const PRIVATE_LINE = 'A private note keeps only what you type. Its audio, transcript and screen shots are deleted now and none are kept while it stays private.';
19
+ export const HL_LINE = 'Keeps the last 30 seconds and the next ones as a highlight, written from the transcript when the window closes.';
20
+
21
+ /* ── the pure half ─────────────────────────────────────────────────────────────────────────────────────────────── */
22
+
23
+ /** The Record menu: today's meetings that can still be recorded, each with the mark its note has. `busy` when a note records, so nothing new can start. */
24
+ export function menuView(rows, notes, now = Date.now()) {
25
+ const live = (Array.isArray(notes) ? notes : []).filter((n) => n && (n.state === 'recording' || n.state === 'paused'));
26
+ const items = (Array.isArray(rows) ? rows : []).filter((r) => r && recordable(r, now)).map((r, i) => {
27
+ const n = live.find((x) => x.meeting && x.meeting.kind === 'event' && ((x.meeting.event_id && x.meeting.event_id === r.id) || (Date.parse(x.meeting.start) === Date.parse(r.at) && clip(x.meeting.title, 120).toLowerCase() === clip(r.title, 120).toLowerCase())));
28
+ const at = Date.parse(r.at), end = Date.parse(r.end);
29
+ return { i, title: clip(r.title, 80), time: hhmm(r.at) + (hhmm(r.end) ? '–' + hhmm(r.end) : ''), mark: n ? (n.state === 'recording' ? 'Recording' : 'Paused') : now >= at && (!Number.isFinite(end) || now <= end) ? 'Now' : '' };
30
+ });
31
+ return { items, busy: live.some((n) => n.state === 'recording') };
32
+ }
33
+
34
+ /** The During capture from GET /api/notes/one (or its error). `held` is true when this page's recorder listens to the note. Nothing is invented: a part the note does not hold is empty. */
35
+ export function duringView(r, { held = false } = {}) {
36
+ if (!r || r.ok !== true || !r.note) return { state: 'error', reason: clip((r && r.error) || 'The note could not be read.', 160) };
37
+ const n = r.note, st = n.state;
38
+ const mode = st === 'recording' ? (held ? 'recording' : 'stale') : st === 'paused' ? 'paused' : st === 'ended' ? 'ended' : 'idle';
39
+ const who = (src) => clip((n.speakers && n.speakers[src]) || SPEAKER[src] || 'You', 40);
40
+ const lines = (Array.isArray(n.transcript) ? n.transcript : []).filter((x) => x && !x.dropped && x.text).slice(-40).map((x) => ({ who: who(x.source), t: Number(x.t) || 0, time: mmss(x.t), text: clip(x.text, 400) }));
41
+ const highlights = (Array.isArray(n.highlights) ? n.highlights : []).filter((h) => h && h.text).map((h) => ({ id: h.id, text: clip(h.text, 300), time: mmss(h.from), cat: h.cat || '' }));
42
+ const shots = r.screen && Array.isArray(r.screen.frames) ? r.screen.frames.length : 0;
43
+ return { state: 'ok', id: n.id, title: clip(n.title || (n.meeting && n.meeting.title) || 'Untitled note', 120), mode, private: !!n.private, body: String(n.body || ''), lines, highlights, shots,
44
+ until: hhmm(n.resume_until), event: !!(n.meeting && n.meeting.kind === 'event' && n.meeting.event_id) };
45
+ }
46
+
47
+ /** The presses the chip shows. `v` is recChipView's answer; `here` is the page ('brief' holds the recorder). Other pages say what records with Open and Stop. */
48
+ export function chipActs(v, here) {
49
+ if (!v) return [];
50
+ if (here !== 'brief') return ['open', 'stop'];
51
+ if (v.mode === 'recording' && v.held) return ['hl', 'pause', 'fv', 'open', 'stop'];
52
+ return ['open', ...(v.canResume ? ['resume'] : []), 'stop'];
53
+ }
54
+
55
+ /** The Focus read of a note: its calendar event and day. null when the note is not linked to an event, because Focus reads a meeting. */
56
+ export function focusPath(note) {
57
+ const m = note && note.meeting;
58
+ if (!m || m.kind !== 'event' || !m.event_id || !/T\d{2}:\d{2}/.test(String(m.start || ''))) return null;
59
+ return '/api/meeting-focus?event=' + encodeURIComponent(m.event_id) + '&date=' + String(m.start).slice(0, 10);
60
+ }
61
+
62
+ /** The material Focus can put on the stage: a PMOS deck (Present, Audience view) or Google Slides (Present); a link opens in a new tab. */
63
+ export function stageOf(material) {
64
+ return (Array.isArray(material) ? material : []).map((m, i) => ({ i, title: clip(m.title || m.ref || m.url, 100), kind: m.kind || '', topic: clip(m.topic, 60),
65
+ present: m.kind === 'pmos-deck' || m.kind === 'slides', audience: m.kind === 'pmos-deck', url: /^https:\/\//.test(String(m.url || '')) ? m.url : '' })).filter((x) => x.title);
66
+ }
67
+
68
+ /* ── the DOM half ──────────────────────────────────────────────────────────────────────────────────────────────── */
69
+ const $ = (s, r = document) => r.querySelector(s);
70
+ const REC = () => (typeof window !== 'undefined' && window.__premiumRec) || null;
71
+ const holding = () => (typeof window !== 'undefined' && window.__premiumHolding && window.__premiumHolding.id) || null;
72
+ const ICO = {
73
+ mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>', chev: '<path d="m6 9 6 6 6-6"/>', flag: '<path d="M5 21V4h11l-1.5 4L16 12H5"/>',
74
+ pause: '<path d="M8 5v14M16 5v14"/>', stop: '<rect x="6" y="6" width="12" height="12" rx="2"/>', play: '<path d="M7 5v14l11-7z"/>', lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',
75
+ focus: '<path d="M4 8V4h4M16 4h4v4M20 16v4h-4M8 20H4v-4"/><circle cx="12" cy="12" r="3"/>', plus: '<path d="M12 5v14M5 12h14"/>',
76
+ };
77
+ const ic = (k) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${ICO[k]}</svg>`;
78
+ const fail = (d, res, what) => d.toast((res && res.error) || what);
79
+
80
+ /** The dialog the tabs sit in: the open one, else the meeting's dialog on the Briefing, else a dialog of the note's own. */
81
+ async function ensureDialog(id, d) {
82
+ if ($('#dlg') && $('#dlg').classList.contains('on')) return true;
83
+ const rec = REC(), n = rec ? rec.note(id) : null;
84
+ if (rec && n && n.meeting && n.meeting.kind === 'event') { await rec.open(id); if ($('#dlg').classList.contains('on')) return true; }
85
+ if (!d.openDlg) return false;
86
+ d.openDlg({ eye: 'Note', title: clip((n && n.title) || 'Untitled note', 120), label: 'Note',
87
+ say: 'This note is not linked to a meeting in this week’s calendar. What it holds shows in the Live notes tab.', html: '<p class="note">The note has no meeting. Its live notes are in the next tab.</p>' });
88
+ return true;
89
+ }
90
+
91
+ export async function openLive(id, d) {
92
+ if (!id || !(await ensureDialog(id, d))) return null;
93
+ vwStyle('rec');
94
+ return vwOpen({ id: 'rec:' + id, title: 'Live notes', icon: 'mic', render: (el) => renderDuring(el, id, d) });
95
+ }
96
+
97
+ /** The During capture of one note. The notes view (thread "Viewer: notes") calls this for its During part; openLive puts it in a tab of its own. */
98
+ export function renderDuring(el, id, d) {
99
+ vwStyle('rec');
100
+ const ui = { v: null, ask: '', draft: null, saving: false };
101
+ let timer = null;
102
+ const read = async () => {
103
+ const r = await d.pmGet('/api/notes/one?id=' + encodeURIComponent(id));
104
+ ui.v = duringView(r, { held: holding() === id });
105
+ };
106
+ const clock = () => { const rec = REC(), t = rec && holding() === id ? rec.started() : null; return Number.isFinite(t) ? mmss(Date.now() - t) : ''; };
107
+ const draw = () => {
108
+ const v = ui.v;
109
+ if (!v) { el.innerHTML = '<article class="paper doc rvw"><p class="note" role="status">Reading the note.</p></article>'; return; }
110
+ if (v.state === 'error') { el.innerHTML = `<article class="paper doc rvw"><p class="note" role="status">The note could not be read: ${esc(v.reason)}</p></article>`; return; }
111
+ const b = (a, label, icon, cls) => `<button type="button" class="rvb${cls ? ' ' + cls : ''}" data-rv="${a}">${icon ? ic(icon) : ''}${label}</button>`;
112
+ const hl = REC() && REC().highlighting ? REC().highlighting() : null;
113
+ let head = '';
114
+ if (v.mode === 'recording') head = `<div class="rvh"><span class="rvdot" aria-hidden="true"></span><b>Recording</b><span class="rvclk" data-rv-clock>${esc(clock())}</span><span class="rvsp"></span>${b('hl', hl && hl.state === 'listening' ? 'Highlighting' : 'Highlight', 'flag')}${b('pause', 'Pause', 'pause')}${b('stop', 'Stop', 'stop', 'cta')}</div>`;
115
+ else if (v.mode === 'paused') head = `<div class="rvh"><span class="rvdot paused" aria-hidden="true"></span><b>Paused</b>${v.until ? `<span class="note">Open until ${esc(v.until)}</span>` : ''}<span class="rvsp"></span>${b('resume', 'Resume', 'play')}${b('stop', 'Stop', 'stop', 'cta')}</div>`;
116
+ else if (v.mode === 'stale') head = `<div class="rvh"><b>Marked recording</b><span class="rvsp"></span>${b('resume', 'Resume', 'play')}${b('stop', 'Stop', 'stop', 'cta')}</div><p class="note">The server holds this note as recording, but this page is not capturing audio. Resume starts listening again.</p>`;
117
+ else if (v.mode === 'ended') head = '<div class="rvh"><b>Ended</b></div><p class="note">The recording has ended. A stopped meeting cannot be recorded again. Its notes are in the meeting’s After part.</p>';
118
+ else head = '<div class="rvh"><b>Not recording</b></div>';
119
+ const ask = ui.ask === 'stop' ? `<div class="rvask" role="alert"><p><b>Stop “${esc(clip(v.title, 60))}” for good?</b> ${esc(STOP_LINE)}</p><div>${b('stopno', 'Cancel')}${v.mode === 'recording' ? b('pause', 'Pause instead') : ''}${b('stopgo', 'Stop for good', '', 'cta')}</div></div>` : '';
120
+ const opts = v.mode === 'ended' ? '' : `<div class="rvopts">${v.event ? b('fv', 'Focus', 'focus') : ''}<button type="button" class="rvb" data-rv="private" aria-pressed="${v.private}" title="${esc(PRIVATE_LINE)}">${ic('lock')}Private</button>${v.shots ? `<span class="note">${v.shots} screen ${v.shots === 1 ? 'shot' : 'shots'} kept</span>` : ''}</div>`;
121
+ const body = ui.draft == null ? v.body : ui.draft;
122
+ const mine = `<section class="rvsec"><label class="label" for="rvMine">Your notes</label><textarea id="rvMine" class="rvta" rows="4" placeholder="Type a line. Each line keeps the time it was written." data-rv-mine>${esc(body)}</textarea><p class="note" data-rv-saved>${ui.saving ? 'Saving.' : 'Saved on this machine when you leave the box.'}</p></section>`;
123
+ const hls = v.highlights.length ? `<section class="rvsec"><span class="label">Highlights</span><ul class="rvhl">${v.highlights.map((h) => `<li><time>${esc(h.time)}</time><span>${esc(h.text)}</span>${h.cat ? `<em>${esc(h.cat)}</em>` : ''}</li>`).join('')}</ul></section>` : '';
124
+ const tr = v.private ? '<p class="note">This note is private, so it keeps no transcript.</p>' : v.lines.length ? `<div class="rvtr" data-rv-tr>${v.lines.map((l, i) => `<p${i === v.lines.length - 1 ? ' class="cur"' : ''}><time>${esc(l.time)}</time><b>${esc(l.who)}</b><span>${esc(l.text)}</span></p>`).join('')}</div>` : `<p class="note">${v.mode === 'recording' ? 'Nothing has been heard yet.' : 'The transcript starts when the note records.'}</p>`;
125
+ const keep = el.querySelector('[data-rv-mine]') === document.activeElement;
126
+ el.innerHTML = `<article class="paper doc rvw"><h3 class="rvt">${esc(v.title)}</h3>${head}${ask}${opts}${mine}${hls}<section class="rvsec"><span class="label">${v.mode === 'recording' ? 'Live transcript' : 'Transcript'}</span>${tr}</section></article>`;
127
+ if (keep) { const t = el.querySelector('[data-rv-mine]'); t.focus(); t.setSelectionRange(t.value.length, t.value.length); }
128
+ const t = el.querySelector('[data-rv-tr]'); if (t) t.scrollTop = t.scrollHeight;
129
+ };
130
+ const loop = async () => {
131
+ clearTimeout(timer);
132
+ if (!el.isConnected) return;
133
+ if (!el.hidden) { await read(); if (!el.isConnected) return; if (el.querySelector('[data-rv-mine]') !== document.activeElement || !el.querySelector('.rvh')) draw(); }
134
+ timer = setTimeout(loop, 3000);
135
+ };
136
+ const tick = setInterval(() => { if (!el.isConnected) { clearInterval(tick); return; } const c = el.querySelector('[data-rv-clock]'); if (c) c.textContent = clock(); }, 1000);
137
+ const save = async () => {
138
+ if (ui.draft == null || !ui.v || ui.v.state !== 'ok' || ui.draft === ui.v.body) { ui.draft = null; return; }
139
+ ui.saving = true; const res = await d.pmPost('/api/notes/save', { id, body: ui.draft }); ui.saving = false;
140
+ if (!res || res.ok !== true) { fail(d, res, 'Your notes were not saved.'); return; }
141
+ ui.draft = null; await read(); draw();
142
+ };
143
+ el.addEventListener('input', (e) => { if (e.target.matches('[data-rv-mine]')) ui.draft = e.target.value; });
144
+ el.addEventListener('focusout', (e) => { if (e.target.matches('[data-rv-mine]')) save(); });
145
+ el.onclick = async (e) => { // delegated to the presses of the capture
146
+ const t = e.target.closest('[data-rv]'); if (!t) return;
147
+ const rec = REC(), a = t.dataset.rv; let res = null;
148
+ if (a === 'stop') { ui.ask = 'stop'; draw(); const g = el.querySelector('[data-rv="stopno"]'); if (g) g.focus(); return; }
149
+ if (a === 'stopno') { ui.ask = ''; draw(); return; }
150
+ if (a === 'fv') { openFocus(id, d); return; }
151
+ if (!rec) { d.toast('Recording is held by the Briefing. Open it there.'); return; }
152
+ t.disabled = true;
153
+ if (a === 'hl') { res = await rec.highlight(); if (res.ok) d.toast('Highlighting. ' + HL_LINE); }
154
+ else if (a === 'pause') { ui.ask = ''; res = await rec.pause(); if (res.ok) d.toast('Paused. You can resume within 1 hour.'); }
155
+ else if (a === 'resume') { res = await rec.resume(id); if (res.ok) d.toast('Resumed. Let people know.'); }
156
+ else if (a === 'stopgo') { ui.ask = ''; res = await rec.stop(id); if (res.ok) d.toast(res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped for good. The final notes are written now.'); }
157
+ else if (a === 'private') {
158
+ const on = !(ui.v && ui.v.private);
159
+ if (on && !(await vwConfirm(el, { text: PRIVATE_LINE, yes: 'Make it private', no: 'Cancel' }))) { t.disabled = false; return; }
160
+ res = await d.pmPost('/api/notes/private', { id, private: on });
161
+ }
162
+ if (res && res.ok !== true) fail(d, res, 'That did not work.');
163
+ await read(); draw();
164
+ };
165
+ draw(); loop();
166
+ }
167
+
168
+ /** Focus: the meeting as it is now, read every 3 s while its tab is shown (GET /api/meeting-focus), with the material on a stage. */
169
+ export async function openFocus(id, d) {
170
+ if (!id || !(await ensureDialog(id, d))) return null;
171
+ vwStyle('rec');
172
+ if (!vwState().ids.includes('rec:' + id)) vwOpen({ id: 'rec:' + id, title: 'Live notes', icon: 'mic', render: (el) => renderDuring(el, id, d) }); // Focus sits beside the note's live notes
173
+ return vwOpen({ id: 'focus:' + id, title: 'Focus', icon: 'list', render: (el) => renderFocus(el, id, d) });
174
+ }
175
+ function renderFocus(el, id, d) {
176
+ let F = null, stage = [], timer = null, path = null, note = null;
177
+ const draw = () => {
178
+ const head = `<div class="fvh"><b>${esc(clip((note && note.title) || 'Focus', 80))}</b><span class="note">${esc(F && F.state === 'ok' ? F.status : path ? 'Reading the meeting' : '')}</span></div>`;
179
+ if (!path) { el.innerHTML = `<article class="paper doc rvw">${head}<p class="note">Focus reads a meeting from the calendar. This note is not linked to a calendar event.</p></article>`; return; }
180
+ if (!F) { el.innerHTML = `<article class="paper doc rvw">${head}<p class="note">${esc(FOCUS_LINE)}</p></article>`; return; }
181
+ if (F.state === 'error') { el.innerHTML = `<article class="paper doc rvw">${head}<p class="note" role="status">Focus could not read this meeting: ${esc(F.reason)}</p></article>`; return; }
182
+ const nowT = F.phase === 'before' ? F.topics[0] : F.current;
183
+ let h = head;
184
+ if (F.stretches.length) h += `<div class="fvbar" role="img" aria-label="What the room talked about, in order. Numbers match the topic list.">${F.stretches.map((x) => `<span class="${x.on ? 'on' : ''}" data-flex="${x.flex}" title="${esc(x.text)}">${x.n}</span>`).join('')}</div>`;
185
+ h += `<div class="fvnow"><span class="label">${F.phase === 'before' ? 'First up' : 'Now'}</span><b>${esc(nowT ? nowT.text : 'No topic is current yet')}</b>${F.gist ? `<p>${esc(F.gist)}</p>` : ''}</div>`;
186
+ h += `<div class="fvg"><section class="rvsec"><span class="label">Topics</span>${F.topics.length ? `<ol class="fvtp">${F.topics.map((t) => `<li class="${t.state}"><span>${esc(t.text)}</span><small>${t.state === 'now' ? 'now' : t.state === 'done' ? (t.minutes ? t.minutes + ' min' : 'done') : t.state === 'parked' ? 'parked' : 'planned'}</small></li>`).join('')}</ol>` : '<p class="note">The meeting has no topics yet.</p>'}</section>`;
187
+ h += `<section class="rvsec"><span class="label">Captured so far</span>${F.rec || F.paused || F.phase === 'done' ? `<div class="fvcap"><div><b>${F.captured.decisions}</b><span>Decisions</span></div><div><b>${F.captured.actions}</b><span>Next steps</span></div><div><b>${F.captured.questions}</b><span>Questions</span></div></div>` : '<p class="note">Counts start when the note records.</p>'}</section></div>`;
188
+ h += `<section class="rvsec"><span class="label">${F.rec ? 'What is being said' : 'Transcript'}</span>${F.tail.length ? `<div class="rvtr">${F.tail.map((l, i) => `<p${i === F.tail.length - 1 ? ' class="cur"' : ''}><b>${esc(l.who)}</b><span>${esc(l.text)}</span></p>`).join('')}</div>` : `<p class="note">${F.rec ? 'Nothing has been said yet.' : 'The transcript starts when you record.'}</p>`}</section>`;
189
+ h += `<section class="rvsec"><span class="label">Material</span>${stage.length ? `<ul class="fvst">${stage.map((m) => `<li><span><b>${esc(m.title)}</b><small>${esc([m.kind, m.topic ? 'on ' + m.topic : ''].filter(Boolean).join(' · '))}</small></span>${m.present ? `<button type="button" class="rvb cta" data-fv="present" data-i="${m.i}">${ic('play')}Present</button>` : ''}${m.audience ? `<button type="button" class="rvb" data-fv="aud" data-i="${m.i}">Audience view</button>` : ''}${!m.present && m.url ? `<button type="button" class="rvb" data-fv="open" data-i="${m.i}">Open</button>` : ''}</li>`).join('')}</ul>` : '<p class="note">No material linked. Add some from the meeting.</p>'}</section>`;
190
+ if (F.companion) h += `<p class="note">${esc(F.companion)}</p>`;
191
+ el.innerHTML = `<article class="paper doc rvw">${h}</article>`;
192
+ el.querySelectorAll('.fvbar [data-flex]').forEach((x) => x.style.setProperty('--fc-flex', x.dataset.flex)); // run-time geometry: each stretch is as long as its talk
193
+ };
194
+ const loop = async () => {
195
+ clearTimeout(timer);
196
+ if (!el.isConnected) return;
197
+ if (!el.hidden) {
198
+ if (!note) { const one = await d.pmGet('/api/notes/one?id=' + encodeURIComponent(id)); note = one && one.ok ? one.note : null; path = focusPath(note); }
199
+ if (path) { const r = await d.pmGet(path); F = focusView(r); stage = stageOf(r && r.ok ? r.material : []); }
200
+ if (!el.isConnected) return;
201
+ draw();
202
+ if (!path) return;
203
+ }
204
+ timer = setTimeout(loop, 3000);
205
+ };
206
+ el.onclick = async (e) => { // delegated to Present, Audience view and Open
207
+ const t = e.target.closest('[data-fv]'); if (!t) return;
208
+ const r = F && F.state === 'ok' ? await d.pmGet(path) : null, raw = r && r.ok && Array.isArray(r.material) ? r.material[+t.dataset.i] : null, m = stage[+t.dataset.i];
209
+ if (!m) return;
210
+ if (t.dataset.fv === 'open') { window.open(m.url, '_blank', 'noopener'); return; }
211
+ const C = await import('./c3-material.js'); // the console's presenter: a PMOS deck in the presenter view, Google Slides in present mode
212
+ if (t.dataset.fv === 'present') C.presentItem(raw); else C.audienceItem(raw);
213
+ };
214
+ draw(); loop();
215
+ }
216
+
217
+ /** The Record control on the Briefing's top bar: Record (a new note now) and an arrow with today's meetings. Each start asks "Tell everyone first" once. */
218
+ export function mountRecord(here, d) {
219
+ if (here !== 'brief' || $('#recCtl')) return;
220
+ const at = $('.tools-top'); if (!at) return;
221
+ vwStyle('rec');
222
+ const w = document.createElement('div'); w.id = 'recCtl'; w.className = 'recctl';
223
+ w.innerHTML = `<button type="button" class="recb" data-rc="new" aria-label="Record a new note" title="${esc(NEW_LINE)}">${ic('mic')}<span>Record</span></button><button type="button" class="recb arr" data-rc="menu" aria-haspopup="menu" aria-expanded="false" aria-label="Record a meeting of today">${ic('chev')}</button><div class="recm" role="menu" hidden></div>`;
224
+ at.prepend(w);
225
+ const menu = $('.recm', w), arr = $('[data-rc="menu"]', w);
226
+ let rows = [], told = false, pend = null;
227
+ const close = () => { menu.hidden = true; arr.setAttribute('aria-expanded', 'false'); };
228
+ const consent = (what) => { pend = what; menu.innerHTML = `<div class="recask" role="alert"><p><b>Tell everyone first.</b> ${esc(CONSENT_LINE.replace('Tell everyone first. ', ''))}</p><p class="note">${esc(what === 'new' ? NEW_LINE : RECORD_LINE)}</p><div><button type="button" class="rvb cta" data-rc="go">I told them, start</button><button type="button" class="rvb" data-rc="no">Not yet</button></div></div>`; menu.hidden = false; arr.setAttribute('aria-expanded', 'true'); const g = $('[data-rc="go"]', menu); if (g) g.focus(); };
229
+ const start = async (what) => {
230
+ const rec = REC(); if (!rec) { d.toast('The recorder is not ready yet.'); return; }
231
+ close();
232
+ const res = what === 'new' ? await rec.fresh() : await rec.record(rows[what]);
233
+ if (!res || res.ok !== true) { fail(d, res, 'The recording did not start.'); return; }
234
+ d.toast('Recording. Notes are being taken on this machine. Let people know.');
235
+ const id = res.id || holding(); if (id) openLive(id, d);
236
+ };
237
+ const ask = (what) => { if (told) start(what); else consent(what); };
238
+ const list = async () => {
239
+ const rec = REC(); rows = rec ? await rec.today() : [];
240
+ const v = menuView(rows, rec ? rec.notes() : []);
241
+ menu.innerHTML = `<p class="label">Today’s meetings</p>${v.items.length ? v.items.map((x) => `<button type="button" role="menuitem" data-rc="ev" data-i="${x.i}"${x.mark === 'Recording' || x.mark === 'Paused' ? ' disabled' : ''}><b>${esc(x.title)}</b><small>${esc(x.time)}${x.mark ? ' · ' + esc(x.mark) : ''}</small></button>`).join('') : '<p class="note">No meeting of today can be recorded now.</p>'}<button type="button" role="menuitem" data-rc="new">${ic('plus')}New note</button>`;
242
+ menu.hidden = false; arr.setAttribute('aria-expanded', 'true'); const f = $('[role="menuitem"]:not([disabled])', menu); if (f) f.focus();
243
+ };
244
+ const draw = () => { const rec = REC(), live = rec ? rec.notes().some((n) => n.state === 'recording') || !!holding() : false; w.hidden = live; if (live) close(); };
245
+ w.onclick = (e) => { // delegated to the control's presses
246
+ const t = e.target.closest('[data-rc]'); if (!t) return; e.stopPropagation();
247
+ const a = t.dataset.rc;
248
+ if (a === 'menu') { if (menu.hidden) list(); else close(); return; }
249
+ if (a === 'new') { ask('new'); return; }
250
+ if (a === 'ev') { ask(+t.dataset.i); return; }
251
+ if (a === 'go') { told = true; start(pend); return; }
252
+ if (a === 'no') { close(); arr.focus(); }
253
+ };
254
+ w.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { close(); arr.focus(); } });
255
+ document.addEventListener('click', (e) => { if (!e.target.closest('#recCtl')) close(); });
256
+ addEventListener('premium-rec', draw); draw();
257
+ }
@@ -6,6 +6,7 @@ import { pmPost, pmGet } from './http.js';
6
6
  import { startAgent } from './page-agent.js';
7
7
  import { mountMeeting } from './premium-meeting.js';
8
8
  import { mountCalEntry } from './premium-vw-cal.js';
9
+ import { mountNotes } from './premium-vw-notes.js';
9
10
  import { mountFirst } from './premium-first.js';
10
11
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
11
12
  import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
@@ -25,6 +26,7 @@ const pinned = new Set();
25
26
  wireRail('brief');
26
27
  const week = mountMeeting({ $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, ws: () => new URLSearchParams(location.search).get('ws'), redraw: () => { if (M) drawTl(); } });
27
28
  mountCalEntry($('#todayCard'), { $, esc, openDlg, turnA, ptx, pmGet, ws: () => new URLSearchParams(location.search).get('ws'), openRow: week.openRow }); // the full calendar: Day, Week and Month in the viewer
29
+ mountNotes({ $, esc, openDlg, toast, pmGet, pmPost, task: week.task });
28
30
 
29
31
  /* ── a day's baseline, kept on this device, so "N of M done" counts rows that cleared since the page first read today ────── */
30
32
  const dayKey = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
@@ -48,6 +48,7 @@
48
48
  "briefing-premium-calendar.test.js",
49
49
  "briefing-premium-calendar-2.test.js",
50
50
  "briefing-premium-calendar-3.test.js",
51
+ "premium-vw-rec.test.js",
51
52
  "briefing-premium-products.test.js",
52
53
  "briefing-premium-sources.test.js",
53
54
  "briefing-premium-drafts.test.js",
@@ -219,6 +220,7 @@
219
220
  "briefing-premium-calendar.test.js": 1,
220
221
  "briefing-premium-calendar-2.test.js": 1,
221
222
  "briefing-premium-calendar-3.test.js": 1,
223
+ "premium-vw-rec.test.js": 1,
222
224
  "briefing-premium-products.test.js": 1,
223
225
  "briefing-premium-sources.test.js": 1,
224
226
  "briefing-premium-drafts.test.js": 1,
@@ -2,12 +2,14 @@
2
2
  "_comment": "Initiative premium-viewer: the premium dialog's right pane as a viewer with tabs (S1, the frame the view slices build on).",
3
3
  "panels": [
4
4
  "premium-viewer-test.js",
5
- "premium-vw-slides-test.js"
5
+ "premium-vw-slides-test.js",
6
+ "premium-vw-rec-test.js"
6
7
  ],
7
8
  "seconds": {
8
9
  "premium-viewer-test.js": 60,
9
10
  "premium-vw-slides.test.js": 1,
10
- "premium-vw-slides-test.js": 60
11
+ "premium-vw-slides-test.js": 60,
12
+ "premium-vw-rec-test.js": 120
11
13
  },
12
14
  "modules": [
13
15
  "premium-vw-slides.test.js"
@@ -0,0 +1,13 @@
1
+ {
2
+ "_comment": "Initiative premium-viewer, R9: the Jira backlog of a board as a viewer tab, opened from the Board's sprint dialog.",
3
+ "modules": [
4
+ "premium-vw-backlog.test.js"
5
+ ],
6
+ "panels": [
7
+ "premium-vw-backlog-test.js"
8
+ ],
9
+ "seconds": {
10
+ "premium-vw-backlog.test.js": 2,
11
+ "premium-vw-backlog-test.js": 45
12
+ }
13
+ }