create-pmos 0.396.0 → 0.398.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 (177) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/payload/state/log.md +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +103 -74
  9. package/workspace/briefing-premium-board-test.js +316 -154
  10. package/workspace/briefing-premium-calendar-2-test.js +135 -195
  11. package/workspace/briefing-premium-calendar-3-test.js +143 -413
  12. package/workspace/briefing-premium-calendar-test.js +86 -185
  13. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  14. package/workspace/briefing-premium-initiative-test.js +166 -294
  15. package/workspace/briefing-premium-insights-test.js +351 -214
  16. package/workspace/briefing-premium-metrics-test.js +53 -118
  17. package/workspace/briefing-premium-products-test.js +40 -27
  18. package/workspace/briefing-premium-sources-test.js +91 -52
  19. package/workspace/briefing-premium-test.js +150 -633
  20. package/workspace/briefing-premium-work-test.js +88 -269
  21. package/workspace/changelog.json +24 -0
  22. package/workspace/fixtures/board-premium-facts.js +2 -1
  23. package/workspace/fixtures/board-premium-jira.js +28 -0
  24. package/workspace/fixtures/board-premium-trail.js +32 -0
  25. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  26. package/workspace/fixtures/initiatives-api/list.json +30 -42
  27. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  28. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  29. package/workspace/fixtures/insights-premium-facts.js +11 -2
  30. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  31. package/workspace/guide/briefing-premium.md +3 -1
  32. package/workspace/guide/home.md +47 -0
  33. package/workspace/guide/index.md +2 -0
  34. package/workspace/guide/lifecycle.md +51 -0
  35. package/workspace/home-shot.js +38 -0
  36. package/workspace/lib/agent-roles.js +71 -0
  37. package/workspace/lib/board-premium.js +160 -3
  38. package/workspace/lib/board-trail.js +223 -0
  39. package/workspace/lib/engine/boards.js +15 -14
  40. package/workspace/lib/engine/nine-stages.js +49 -20
  41. package/workspace/lib/engine/signals/detectors.js +13 -11
  42. package/workspace/lib/home-work-item.js +58 -0
  43. package/workspace/lib/insights-goals.js +196 -0
  44. package/workspace/lib/insights-premium.js +126 -1
  45. package/workspace/lib/insights-records.js +101 -0
  46. package/workspace/lib/jira-tickets.js +1 -1
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-board-premium.js +3 -2
  49. package/workspace/lib/routes-board-trail.js +33 -0
  50. package/workspace/lib/routes-home-desk.js +176 -0
  51. package/workspace/lib/routes-initiatives.js +1 -1
  52. package/workspace/lib/routes-insights-premium.js +19 -3
  53. package/workspace/lib/routes-insights-records.js +129 -0
  54. package/workspace/lib/routes-notes.js +1 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/transcript-steps.js +123 -0
  57. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-agreed-viewer-shots.js +76 -0
  63. package/workspace/premium-board-actions-test.js +85 -73
  64. package/workspace/premium-briefing-depth-test.js +66 -53
  65. package/workspace/premium-chat-attach-test.js +54 -63
  66. package/workspace/premium-chat-chart-tab-test.js +35 -36
  67. package/workspace/premium-chat-context-test.js +22 -19
  68. package/workspace/premium-chat-goal-view-test.js +28 -26
  69. package/workspace/premium-chat-notes-test.js +29 -33
  70. package/workspace/premium-chat-report-tab-test.js +35 -25
  71. package/workspace/premium-chat-term-test.js +16 -14
  72. package/workspace/premium-chat-viewer-test.js +60 -53
  73. package/workspace/premium-core-doc-issue-test.js +50 -41
  74. package/workspace/premium-html-viewer-test.js +17 -18
  75. package/workspace/premium-phone-card-test.js +8 -2
  76. package/workspace/premium-phone-room-test.js +42 -31
  77. package/workspace/premium-report-read-test.js +115 -197
  78. package/workspace/premium-viewer-download-test.js +19 -22
  79. package/workspace/premium-viewer-flicker-test.js +11 -16
  80. package/workspace/premium-viewer-share-test.js +6 -9
  81. package/workspace/premium-viewer-test.js +41 -60
  82. package/workspace/premium-vw-backlog-test.js +53 -31
  83. package/workspace/premium-vw-cal-test.js +82 -123
  84. package/workspace/premium-vw-copy-test.js +17 -33
  85. package/workspace/premium-vw-doc-test.js +12 -11
  86. package/workspace/premium-vw-item-test.js +50 -48
  87. package/workspace/premium-vw-jira-test.js +55 -26
  88. package/workspace/premium-vw-meet-test.js +118 -187
  89. package/workspace/premium-vw-notes-test.js +85 -107
  90. package/workspace/premium-vw-rec-test.js +72 -193
  91. package/workspace/premium-vw-slides-test.js +46 -50
  92. package/workspace/premium-welcome-test.js +3 -2
  93. package/workspace/premium-work-depth-test.js +63 -51
  94. package/workspace/public/pm/bd-acts.js +305 -0
  95. package/workspace/public/pm/bd-span.js +224 -0
  96. package/workspace/public/pm/bd-stages.js +47 -0
  97. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  98. package/workspace/public/pm/c3-md.js +3 -395
  99. package/workspace/public/pm/c3-phone-detail.js +1 -1
  100. package/workspace/public/pm/c3-phone-model.js +3 -68
  101. package/workspace/public/pm/chat-term.js +3 -3
  102. package/workspace/public/pm/cozy-board.css +640 -0
  103. package/workspace/public/pm/cozy-home.css +580 -0
  104. package/workspace/public/pm/cozy-home.js +172 -0
  105. package/workspace/public/pm/cozy-initiative.css +138 -0
  106. package/workspace/public/pm/cozy-insights.css +421 -0
  107. package/workspace/public/pm/cozy-md.js +396 -0
  108. package/workspace/public/pm/cozy-nav.js +65 -0
  109. package/workspace/public/pm/cozy-placeholder.js +26 -0
  110. package/workspace/public/pm/cozy-viewer.css +143 -0
  111. package/workspace/public/pm/cozy-viewer.js +144 -0
  112. package/workspace/public/pm/cozy-vw.css +485 -0
  113. package/workspace/public/pm/cozy.css +254 -0
  114. package/workspace/public/pm/home-adddoc.js +48 -0
  115. package/workspace/public/pm/home-app.js +905 -0
  116. package/workspace/public/pm/home-around.js +515 -0
  117. package/workspace/public/pm/home-chat.js +459 -0
  118. package/workspace/public/pm/home-data.js +312 -0
  119. package/workspace/public/pm/home-draft.js +68 -0
  120. package/workspace/public/pm/home-more.js +249 -0
  121. package/workspace/public/pm/home-phone-card.js +109 -0
  122. package/workspace/public/pm/home-work.js +519 -0
  123. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  124. package/workspace/public/pm/lifecycle-lens.js +22 -11
  125. package/workspace/public/pm/phone-moment.js +69 -0
  126. package/workspace/public/pm/pm-work-view.js +1 -1
  127. package/workspace/public/pm/premium-attach.js +4 -0
  128. package/workspace/public/pm/premium-board.js +544 -253
  129. package/workspace/public/pm/premium-brief.js +1 -1
  130. package/workspace/public/pm/premium-chart-tab.js +110 -62
  131. package/workspace/public/pm/premium-chat.js +17 -10
  132. package/workspace/public/pm/premium-deck.js +3 -3
  133. package/workspace/public/pm/premium-first.js +25 -21
  134. package/workspace/public/pm/premium-initiative-head.js +138 -0
  135. package/workspace/public/pm/premium-initiative.js +28 -4
  136. package/workspace/public/pm/premium-insights.js +950 -440
  137. package/workspace/public/pm/premium-meeting.js +61 -549
  138. package/workspace/public/pm/premium-notes.js +1 -1
  139. package/workspace/public/pm/premium-report-frame.css +20 -0
  140. package/workspace/public/pm/premium-report-read.js +509 -480
  141. package/workspace/public/pm/premium-report-tab.js +87 -63
  142. package/workspace/public/pm/premium-shell.js +107 -124
  143. package/workspace/public/pm/premium-viewer.js +27 -1
  144. package/workspace/public/pm/premium-vw-cal.js +187 -48
  145. package/workspace/public/pm/premium-vw-doc.css +6 -0
  146. package/workspace/public/pm/premium-vw-doc.js +40 -2
  147. package/workspace/public/pm/premium-vw-file.js +2 -2
  148. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  149. package/workspace/public/pm/premium-vw-jira.css +11 -0
  150. package/workspace/public/pm/premium-vw-jira.js +11 -4
  151. package/workspace/public/pm/premium-vw-meet.js +6 -83
  152. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  153. package/workspace/public/pm/premium-vw-notes.js +56 -69
  154. package/workspace/public/pm/premium-vw-open.js +35 -0
  155. package/workspace/public/pm/premium-vw-page.js +16 -0
  156. package/workspace/public/pm/premium-vw-rec.js +11 -215
  157. package/workspace/public/pm/premium-vw-slides.css +5 -0
  158. package/workspace/public/pm/premium-vw-slides.js +44 -8
  159. package/workspace/public/pm/term-view.js +22 -0
  160. package/workspace/public/premium-board.html +57 -64
  161. package/workspace/public/premium-chat.html +7 -33
  162. package/workspace/public/premium-initiative.html +8 -41
  163. package/workspace/public/premium-insights.html +63 -62
  164. package/workspace/public/premium-viewer.html +20 -0
  165. package/workspace/public/premium-work.html +6 -72
  166. package/workspace/public/premium.html +21 -66
  167. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  168. package/workspace/server.js +25 -3
  169. package/workspace/test-files.json +1 -0
  170. package/workspace/test-lists/home-libs.json +9 -0
  171. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  172. package/workspace/test-lists/premium-report-read.json +1 -1
  173. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  174. package/workspace/test-lists/premium-vw-notes.json +1 -1
  175. package/workspace/third-party/README.md +1 -0
  176. package/workspace/public/pm/premium-work.js +0 -719
  177. package/workspace/public/pm/premium.js +0 -1133
@@ -0,0 +1,731 @@
1
+ /* pm/premium-vw-mtg.js — a meeting in the Viewer, as the Agreed design draws it (initiative premium-agreed-design, area viewer; Main.dc.html
2
+ * viewer props prep, live and notes). One card, no tabs and no conversation:
3
+ * Head, row 1 the state chip · people · Record | Stop | Resume | Replay · ⋯ (Focus, Change what it is about, Copy as Markdown, New meeting,
4
+ * Not part of this series, What Record and Focus do; each with its sub-line)
5
+ * Head, row 2 the time · About <what it is about> · the series line with the meeting before and after
6
+ * Parts always Prep → Transcript → Notes. The part that fits the meeting's state is open; each part has its sub-line.
7
+ *
8
+ * WHERE EACH PART COMES FROM (nothing is invented; a part the answers do not hold is left out or says so):
9
+ * GET /api/notes, /api/notes/one the note, its transcript, highlights, body, speakers, screen shots, its place in a series
10
+ * GET /api/meeting-focus the event, its brief (In short, What matters today, Last time), material, topics, runs, captured
11
+ * GET /api/meeting-replay the recording's length, stretches by topic, key points and shots (the After replay track)
12
+ * GET /api/calendar-views?view=week the calendar row: what it is about, people, the boards and initiatives to link to
13
+ * GET /api/notes/series the meetings before this one
14
+ * GET /api/viewer-meeting agenda minutes per topic, the audio source and Pause shots, the steps that became a ticket or a task
15
+ * WRITES (each a press): Record, Pause, Resume, Stop and Highlight through the page's recorder (premium-meeting.js recCore); POST
16
+ * /api/notes/save (Your notes), /api/notes/private, /api/notes/speaker (naming a speaker), /api/notes/series-member, /api/notes/link or
17
+ * /api/calendar-links (About), /api/viewer-meeting/agenda|capture|work-item, /api/plan-items (Make task).
18
+ *
19
+ * meetModel(D, now) → the view model (pure; for the unit suite)
20
+ * meetHtml(model, ui) → the card's body (pure)
21
+ * mdOf(model) → the note as Markdown, for Copy as Markdown (pure)
22
+ * openMeeting(ref, { ws }) → opens the card. ref: a note id, { note }, { event, date }, a calendar week row or a brief-page today row. */
23
+ import { open as vOpen, current as vCur } from './cozy-viewer.js';
24
+ import { placeholderHtml } from './cozy-placeholder.js';
25
+ import { pmGet, pmPost } from './http.js';
26
+ import { noteSheet, aboutChoices, aboutBody, aboutNow } from './premium-vw-meet.js';
27
+ import { weekView, noteOfRow, sameMeeting, recordable, prevOf, taskEvent, linkBody, mmss, focusView, replayModel, RECORD_LINE, FOCUS_LINE, STOP_LINE, CONSENT_LINE, recCore } from './premium-meeting.js';
28
+ import { APPS, recall, remember } from './listen-sources.js';
29
+
30
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
31
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
32
+ const pad = (n) => String(n).padStart(2, '0');
33
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
34
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
35
+ const hasTime = (s) => typeof s === 'string' && /T\d{2}:\d{2}/.test(s);
36
+ const ok = (t) => Number.isFinite(Date.parse(t));
37
+ const hm = (iso) => { const t = new Date(iso); return ok(iso) ? pad(t.getHours()) + ':' + pad(t.getMinutes()) : ''; };
38
+ const dayKey = (ms) => { const t = new Date(ms); return t.getFullYear() + '-' + pad(t.getMonth() + 1) + '-' + pad(t.getDate()); };
39
+ /** "Oct 15". */
40
+ export const shortDay = (iso) => (ok(iso) ? MON[new Date(iso).getMonth()] + ' ' + new Date(iso).getDate() : '');
41
+ /** "Today", "Yesterday", "Tomorrow" or "Wed 21 Oct". */
42
+ export function dayWord(iso, now = Date.now()) {
43
+ if (!ok(iso)) return '';
44
+ const k = dayKey(Date.parse(iso));
45
+ if (k === dayKey(now)) return 'Today';
46
+ if (k === dayKey(now - 864e5)) return 'Yesterday';
47
+ if (k === dayKey(now + 864e5)) return 'Tomorrow';
48
+ const t = new Date(iso); return WD[t.getDay()] + ' ' + t.getDate() + ' ' + MON[t.getMonth()];
49
+ }
50
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many || one + 's');
51
+ const CLOCK_ICON = 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 7v5l3 2';
52
+ const MENU = {
53
+ focus: ['Focus', 'The meeting as it is now, with Present and Audience view for the deck'],
54
+ about: ['Change what it is about', 'Applies to every meeting in this series'],
55
+ copy: ['Copy as Markdown', 'The notes, decisions and next steps'],
56
+ fresh: ['New meeting', 'Start an untitled note now'],
57
+ serout: ['Not part of this series', 'Keep this note on its own'],
58
+ serback: ['Back in its series', 'Join the meetings with the same title again'],
59
+ why: ['What Record and Focus do', 'Audio and notes stay on this machine'],
60
+ replay: ['Full replay', 'Every line with its time. Waiting for design'],
61
+ };
62
+ export const EMPTY_LIVE = 'Press Record when the meeting starts. PMOS listens to your microphone and the meeting sound, and keeps both on this machine.';
63
+ export const EMPTY_NOTES = 'The summary, decisions and next steps are written when you stop recording.';
64
+ export const LIVE_FOOT = 'Transcribed on this machine. Audio and notes stay here.';
65
+ export const MINE_HINT = 'Type here. Your lines are kept with the transcript.';
66
+ export const PRIVATE_TEXT = 'Private: keep only what I type. Audio and transcript are deleted.';
67
+ const KIND = { 'pmos-deck': 'Deck', 'pmos-doc': 'Doc', report: 'Report', gdoc: 'Google doc', conf: 'Confluence', link: 'Link' };
68
+ /** The key of a next step: the first 8 hex of a hash of its words, as lib/viewer-meeting.js stepKey (sha256) — the server sends the keys it
69
+ * knows, so the page matches on the text it sent. The page keeps the text → key map from the answer of /api/viewer-meeting. */
70
+ const norm = (t) => String(t || '').toLowerCase().replace(/\s+/g, ' ').trim();
71
+ /** The words lib/viewer-meeting.js stepKey hashes: folded to lower-case letters, digits and single spaces. */
72
+ export const stepNorm = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, 400).toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').replace(/\s+/g, ' ').trim();
73
+
74
+ /** The transcript as lines with who said each, and the key that names a speaker: `source` for live lines, `key` for the final segments. */
75
+ export function linesOf(n) {
76
+ if (!n || n.private) return [];
77
+ const sp = n.speakers || {}, DEF = { mic: 'You', meeting: 'Meeting', speech: 'You' };
78
+ if (n.final && Array.isArray(n.final.segments) && n.final.segments.length) {
79
+ const names = (n.final && n.final.speakers) || {};
80
+ return n.final.segments.filter((g) => g && String(g.text || '').trim()).map((g) => ({ t: g.t, text: String(g.text), who: names[g.spk] || sp[g.spk] || DEF[g.spk] || String(g.spk || 'Speaker'), key: g.spk == null ? '' : String(g.spk), source: '' }));
81
+ }
82
+ return (n.transcript || []).filter((x) => x && x.text && !x.dropped).map((x) => ({ t: x.t, text: String(x.text), who: sp[x.source] || DEF[x.source] || 'You', key: '', source: x.source || 'mic' }));
83
+ }
84
+ /** The facts said in the meeting, as view-notes.js caught() reads them: a statement with a number, or one checked against a repository file. */
85
+ export function factsOf(n) {
86
+ if (!n || n.private) return [];
87
+ return (n.transcript || []).filter((x) => x && x.text && !x.dropped && x.cat === 'statement' && (/\d|\b(?:percent|half|double|twice)\b/i.test(x.text) || (x.check && x.check.doc)))
88
+ .map((x) => { const v = x.check && x.check.verdict; return { text: clip(x.text, 240), src: (x.check && x.check.doc) || '', tag: v === 'agrees' ? 'Matches' : v === 'differs' ? 'Differs' : 'Not checked', k: v === 'agrees' ? 'ok' : v === 'differs' ? 'warn' : '' }; });
89
+ }
90
+
91
+ /** The view model. D = { row, n (the raw note), S (noteSheet), F (the meeting-focus answer), rep (replayModel), vm (the viewer-meeting answer),
92
+ * prev (prevOf), about, people, rec: { held, started }, elapsed (ms heard so far), frames (screen shots kept), canRecord, app, steps } */
93
+ export function meetModel(D, now = Date.now()) {
94
+ const row = D.row || null, n = D.n || null, S = D.S || null, F = D.F && D.F.ok !== false ? D.F : null, rep = D.rep || null;
95
+ const ev = (F && F.event) || {}, nm = n && n.meeting && n.meeting.kind === 'event' ? n.meeting : null;
96
+ const at = (row && row.at) || (nm && nm.start) || ev.at || (n && (n.recorded_from || n.created_at)) || null;
97
+ const end = (row && row.end) || (nm && nm.end) || ev.end || null;
98
+ const title = clip((row && row.title) || (nm && nm.title) || (S && S.title) || ev.title || 'Untitled note', 120);
99
+ const st = n ? n.state : null;
100
+ const done = !!n && (st === 'ended' || !!(S && (S.from === 'final' || S.overview || S.decisions.length)));
101
+ const mk = st === 'recording' || st === 'paused' ? 'live' : done ? 'notes' : 'prep';
102
+ const liveK = st === 'paused' ? 'paused' : st === 'recording' ? (D.rec && D.rec.held ? 'rec' : 'stale') : '';
103
+ const el = Math.max(0, Number(D.elapsed) || 0);
104
+ /* row 1 */
105
+ let chip;
106
+ if (mk === 'live') chip = liveK === 'rec' ? { text: 'Recording', tone: 'rec' } : liveK === 'paused' ? { text: 'Paused', tone: 'warn', wait: true } : { text: 'Not capturing', tone: 'warn', wait: true };
107
+ else if (mk === 'notes') chip = { text: 'Done', tone: 'ok' };
108
+ else if (hasTime(at) && now < Date.parse(at)) { const m = Math.max(1, Math.round((Date.parse(at) - now) / 60000)); chip = { text: 'Starts in ' + (m < 60 ? m + ' min' : Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '')), tone: m <= 60 ? 'warn' : '' }; }
109
+ else if (hasTime(at) && (!ok(end) || now < Date.parse(end))) chip = { text: 'On now', tone: 'rec' };
110
+ else chip = { text: hasTime(at) ? 'Not recorded' : 'Not started', tone: '' };
111
+ const people = (D.people || []).map((p) => String(p)).filter(Boolean);
112
+ const primary = mk === 'live' ? (liveK === 'rec' ? { k: 'stop', label: 'Stop' } : { k: 'resume', label: 'Resume' })
113
+ : mk === 'notes' ? (rep ? { k: 'replay', label: 'Replay', out: true } : null) : D.canRecord ? { k: 'record', label: 'Record' } : null;
114
+ const series = S && S.series ? { title: S.series.title || title, pos: S.series.pos, count: S.series.count, prev: S.series.prev, next: S.series.next } : null;
115
+ const menu = ['focus', 'about'].concat(mk === 'notes' ? ['copy', 'fresh'] : [], n ? [S && S.seriesOff ? 'serback' : series ? 'serout' : null] : [], ['why'], mk === 'notes' && rep ? ['replay'] : []).filter(Boolean).map((k) => ({ k, label: MENU[k][0], sub: MENU[k][1] }));
116
+ /* row 2 */
117
+ const started = D.rec && D.rec.started ? new Date(D.rec.started).toISOString() : n && n.recorded_from ? n.recorded_from : at;
118
+ const when = mk === 'live' ? 'Started ' + hm(started) + ' · ' + mmss(el) + ' so far'
119
+ : [dayWord(at, now), hasTime(at) ? hm(at) + (hasTime(end) ? ' to ' + hm(end) : '') : ''].filter(Boolean).join(' ');
120
+ /* the parts */
121
+ const mats = (F && Array.isArray(F.material) ? F.material : []).map((m) => ({ kind: KIND[m.kind] || (m.kind ? String(m.kind) : 'Link'), title: clip(m.title || m.ref || m.url, 120), sub: [m.topic ? 'For ' + clip(m.topic, 60) : '', m.scope === 'series' ? 'every meeting of the series' : m.from === 'you' ? 'added by you' : m.from ? 'from ' + m.from : ''].filter(Boolean).join(' · ') || 'For the meeting', url: m.url || '', ref: m.ref || '', mkind: m.kind || '', ws: m.ws || '', scope: m.scope || 'meeting', topic: m.topic || '' }));
122
+ const brief = (F && F.brief) || null;
123
+ const prev = D.prev || [];
124
+ const carried = (S && S.carriedIn && S.carriedIn.items) || [];
125
+ const last = prev[0] ? prev[0].date + ' · ' + prev[0].decided + ' decided · ' + plural(prev[0].steps, 'next step') : brief && brief.last && brief.last.at ? shortDay(brief.last.at) + ' · ' + plural((brief.last.decisions || []).length, 'decided', 'decided') + ' · ' + plural((brief.last.actions || []).length, 'next step') : '';
126
+ const ready = [
127
+ { label: 'About', text: D.about || 'Not linked yet', ok: !!D.about },
128
+ { label: 'People', text: people.length ? people.slice(0, 3).join(', ') + (people.length > 3 ? ' and ' + (people.length - 3) + ' more' : '') : 'None listed', ok: people.length > 0 },
129
+ { label: 'Material', text: mats.length ? mats.length + ' linked' : 'None linked', ok: mats.length > 0 },
130
+ { label: 'Last time', text: last || 'No earlier notes', ok: !!last && !carried.length },
131
+ ];
132
+ const matters = (brief && Array.isArray(brief.matters) ? brief.matters : []).slice(0, 5).map((x) => ({ tag: clip(x.tag, 20) || 'Changed', text: clip(x.text, 200), meta: clip(x.meta, 80), k: x.tone === 'ok' ? 'ok' : x.tone ? 'warn' : '' }))
133
+ .concat(carried.slice(0, 4).map((x) => ({ tag: 'Carried in', text: x.text, meta: [x.owner, 'still open'].filter(Boolean).join(' · '), k: 'warn' })));
134
+ const ag = D.vm && D.vm.agenda ? D.vm.agenda : { topics: [], total: 0, key: '' };
135
+ const purpose = (S && S.context && S.context.purpose) || (brief && brief.purpose) || ev.purpose || '';
136
+ const prepText = (S && S.context && S.context.prep) || (brief && brief.prep) || '';
137
+ /* live */
138
+ const fv = F ? focusView(F) : null;
139
+ const topics = fv && fv.state === 'ok' ? fv.topics : [];
140
+ const cur = topics.findIndex((t) => t.state === 'now');
141
+ const cap = fv && fv.state === 'ok' ? fv.captured : { decisions: 0, actions: 0, questions: 0 };
142
+ const caughtText = [cap.decisions && plural(cap.decisions, 'decision'), cap.actions && plural(cap.actions, 'next step'), cap.questions && plural(cap.questions, 'question')].filter(Boolean).join(', ') || 'nothing yet';
143
+ const lines = linesOf(n);
144
+ const hl = (n && !n.private && Array.isArray(n.highlights) ? n.highlights : []).map((h) => ({ t: mmss(h.t || h.from || 0), text: clip(h.text, 300), label: h.label || '' }));
145
+ const capture = (D.vm && D.vm.capture) || { app: null, shots: 'on' };
146
+ const app = APPS.find((a) => a.id === (capture.app || D.app)) || APPS[0];
147
+ /* after */
148
+ const links = (D.vm && D.vm.steps && D.vm.steps.links) || {}, tasks = new Set((D.vm && D.vm.steps && D.vm.steps.tasks) || []), keys = D.steps || {};
149
+ const steps = (S ? S.actions : []).map((a, i) => { const key = keys[norm(a.text)] || ''; const tk = links[key] || ''; const task = !!key && tasks.has(key);
150
+ return { i, text: a.text, meta: [a.owner || 'No owner', a.due ? (/^\d{4}-\d{2}-\d{2}$/.test(a.due) ? shortDay(a.due + 'T12:00:00') : a.due) : 'No date'].join(' · '), owner: a.owner, due: a.due, key, ticket: tk, task, made: tk ? 'Becomes ' + tk : task ? 'Task made' : '' }; });
151
+ const since = S && S.since ? { sub: S.since.day.replace(/^\w+ /, '') + ' · ' + plural(S.since.items.length, 'step') + ' then, ' + S.since.fresh.length + ' new',
152
+ rows: S.since.items.map((x) => ({ tag: x.state === 'done' ? 'Done' : x.state === 'again' || x.state === 'raised' ? 'Raised again' : 'Not mentioned', k: x.state === 'done' ? 'ok' : x.state === 'again' || x.state === 'raised' ? 'warn' : '', text: x.text, owner: x.owner }))
153
+ .concat(S.since.fresh.map((x) => ({ tag: 'New', k: 'new', text: x.text, owner: x.owner }))) } : null;
154
+ const trk = rep ? { len: rep.len, stretches: rep.stretches.map((x, i) => ({ flex: Math.max(1, x.to - x.from), c: i % 3, text: x.text, from: x.from })), marks: rep.keys.filter((k) => k.t != null).map((k) => ({ at: Math.min(100, k.t / rep.len * 100), k: k.k, t: k.t })),
155
+ shots: rep.shots.slice(0, 8).map((x) => ({ t: x.t, cap: mmss(x.t) + (x.why ? ' · ' + x.why : ''), why: x.why })), noteId: rep.noteId || (n && n.id) || '', audio: rep.audio, topicAt: (pos) => { const s = rep.stretches.find((x) => pos >= x.from && pos < x.to); return s ? s.text : ''; } } : null;
156
+ const decided = S ? S.decisions.length : 0, nsteps = steps.length, nq = S ? S.questions.length : 0;
157
+ const parts = [
158
+ { k: 'prep', title: 'Prep and material', sub: mk === 'prep' ? 'Agenda, material and last time' : 'Prepared ' + (shortDay(at) || 'for this meeting') + ' · ' + mats.length + ' linked', empty: '' },
159
+ { k: 'live', title: 'Transcript and live notes', sub: mk === 'live' ? mmss(el) + ' · ' + (liveK === 'rec' ? 'recording' : liveK === 'paused' ? 'paused' : 'not capturing') : mk === 'notes' ? Math.max(1, Math.round(((rep && rep.len) || el || (S && S.minutes * 60000) || 0) / 60000)) + ' min · ' + plural(lines.length, 'line') : 'Starts when you record', empty: mk === 'prep' ? EMPTY_LIVE : '' },
160
+ { k: 'notes', title: 'Notes and next steps', sub: mk === 'notes' ? [plural(decided, 'decision'), plural(nsteps, 'next step'), plural(nq, 'question')].join(' · ') : mk === 'live' ? 'Written when you stop' : 'Written after the meeting', empty: mk !== 'notes' ? EMPTY_NOTES : '' },
161
+ ];
162
+ const kind = mk === 'live' ? 'Meeting · recording' : mk === 'notes' ? 'Meeting notes' : 'Meeting prep';
163
+ const head = title + ' · ' + (mk === 'live' ? 'now' : hasTime(at) ? (dayWord(at, now) === 'Today' ? (mk === 'notes' ? 'today ' : '') + hm(at) : shortDay(at) + ' ' + hm(at)) : shortDay(at) || 'note');
164
+ return {
165
+ mk, liveK, title, kind, head, noteId: n ? n.id : '', private: !!(n && n.private), at, end,
166
+ chip, people, primary, menu, when, about: D.about || '', series, parts,
167
+ prep: { ready, readyText: ready.filter((r) => r.ok).length + ' of ' + ready.length + ' ready', purpose: clip(purpose, 300), gist: clip(brief && Array.isArray(brief.gist) ? brief.gist.join(' ') : '', 600), matters,
168
+ agenda: ag.topics.map((t) => ({ n: t.n, text: t.text, min: t.min, set: !!t.set, key: ag.key })), agendaSub: ag.topics.length ? plural(ag.topics.length, 'topic') + (ag.total ? ' · ' + ag.total + ' min' : '') : '', agendaKey: ag.key,
169
+ toBeReady: clip(prepText, 300), material: mats, prev },
170
+ live: { state: liveK === 'rec' ? 'Recording · ' + mmss(el) : liveK === 'paused' ? 'Paused · ' + mmss(el) : 'Marked recording · not capturing', app: app.label, appId: app.id, shots: Number(D.frames) || 0, shotsPaused: capture.shots === 'paused',
171
+ topics: topics.map((t) => ({ n: t.n, text: t.text, k: t.state === 'now' ? 'now' : t.state === 'done' ? 'done' : 'plan', state: t.state === 'now' ? 'Now' : t.state === 'done' ? 'Discussed' : t.state === 'parked' ? 'Parked' : 'Planned', flex: Math.max(4, t.minutes || 0) })),
172
+ nowSub: topics.length ? (cur >= 0 ? 'topic ' + (cur + 1) + ' of ' + topics.length : plural(topics.length, 'topic') + ' planned') : '',
173
+ caught: caughtText, mine: n ? String(n.body || '') : '', hl, lines: mk === 'live' ? lines.slice(-6) : lines, total: lines.length },
174
+ notes: { summary: S ? S.overview : '', track: trk, since, decisions: S ? S.decisions : [], steps, stepsSub: Object.keys(links).length ? plural(steps.filter((s) => s.ticket).length, 'step') + ' proposed as work-items' : nsteps ? plural(nsteps, 'next step') : '',
175
+ facts: factsOf(n), questions: S ? S.questions : [], lines, trTitle: 'Transcript · ' + plural(lines.length, 'line') + ' · press a speaker to name them' },
176
+ };
177
+ }
178
+
179
+ /** The note as Markdown: title, when, about, summary, decisions, next steps and questions. */
180
+ export function mdOf(m) {
181
+ const out = ['# ' + m.title, '', '_' + [m.when, m.about ? 'about ' + m.about : ''].filter(Boolean).join(' · ') + '_', ''];
182
+ if (m.people.length) out.push('**People:** ' + m.people.join(', '), '');
183
+ if (m.notes.summary) out.push('## Summary', '', m.notes.summary, '');
184
+ if (m.notes.decisions.length) out.push('## Decisions', '', ...m.notes.decisions.map((d) => '- ' + d.text + (d.why ? ' (why: ' + d.why + ')' : '')), '');
185
+ if (m.notes.steps.length) out.push('## Next steps', '', ...m.notes.steps.map((s) => '- [ ] ' + s.text + ' (' + s.meta + ')' + (s.ticket ? ' → ' + s.ticket : '')), '');
186
+ if (m.notes.questions.length) out.push('## Open questions', '', ...m.notes.questions.map((q) => '- ' + q.text), '');
187
+ return out.join('\n').replace(/\n{3,}/g, '\n\n');
188
+ }
189
+
190
+ /* ── html (pure) ── */
191
+ const SV = { ppl: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>', link: '<path d="M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4 4 0 0 0-6 0l-3 3a4 4 0 0 0 6 6l1-1"/>',
192
+ prev: '<path d="M15 6l-6 6 6 6"/>', next: '<path d="M9 6l6 6-6 6"/>', chev: '<path d="M7 10l5 5 5-5"/>', play: '<path d="M7 4l13 8-13 8z"/>', pause: '<path d="M8 5h3v14H8zM13 5h3v14h-3z"/>' };
193
+ const svg = (k, w, extra) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"${extra || ''}>${SV[k]}</svg>`;
194
+ SV.check = '<path d="M5 12.5l4.5 4.5L19 7.5"/>';
195
+ /* bars split by weight (topics, the replay's stretches): an SVG, so each length is an attribute and not an inline style */
196
+ function weightBar(cls, parts, extra, attrs) {
197
+ const tot = parts.reduce((a, x) => a + x.w, 0) || 1, gap = 1.2, room = 100 - gap * Math.max(0, parts.length - 1);
198
+ let x = 0;
199
+ const rects = parts.map((q) => { const w = Math.max(0.6, room * q.w / tot), r = `<rect x="${x.toFixed(2)}%" width="${w.toFixed(2)}%" height="100%" rx="4"${q.attrs || ''}/>`; x += w + gap; return r; }).join('');
200
+ return `<svg class="${cls}" aria-hidden="true" width="100%" height="100%"${attrs || ''}>${rects}${extra || ''}</svg>`;
201
+ }
202
+ const dots = '<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" class="vz-dots"><circle cx="5" cy="12" r="2"/><circle cx="12" cy="12" r="2"/><circle cx="19" cy="12" r="2"/></svg>';
203
+ const wait = (what) => `<span class="vz-wait" data-cz-placeholder="${esc(what)}" title="${esc(what)}: this part has no design yet">Waiting for design</span>`;
204
+ const lineHtml = (l, i, ui) => {
205
+ const naming = ui.naming === i;
206
+ const who = naming ? `<span class="vz-name"><input data-a="namein" data-i="${i}" aria-label="Name this speaker" value="${esc(l.who)}" maxlength="60"><button type="button" class="vz-link vz-hv" data-a="nameok" data-i="${i}">Save</button></span>`
207
+ : `<button type="button" class="vz-who vz-hv" data-a="name" data-i="${i}" title="Name this speaker">${esc(l.who)}</button>`;
208
+ return `<div class="vz-line"><time>${esc(mmss(l.t))}</time><span>${who} ${esc(l.text)}</span></div>`;
209
+ };
210
+
211
+ function prepHtml(P) {
212
+ const h = [];
213
+ h.push(`<div class="vz-col"><h3>Prepared for you <small>${esc(P.readyText)}</small></h3>${P.ready.map((r) => `<div class="vz-ready"><span class="vz-mk" data-k="${r.ok ? 'ok' : 'no'}" aria-hidden="true">${r.ok ? svg('check', 12) : '!'}</span><span><b>${esc(r.label)}</b> <em>${esc(r.text)}</em></span></div>`).join('')}</div>`);
214
+ if (P.purpose) h.push(`<div><h3>What it is for</h3><p class="vz-p">${esc(P.purpose)}</p></div>`);
215
+ if (P.gist) h.push(`<div><h3>In short</h3><p class="vz-p">${esc(P.gist)}</p></div>`);
216
+ if (P.matters.length) h.push(`<div class="vz-col"><h3>What matters today</h3>${P.matters.map((x) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${x.k}">${esc(x.tag)}</span><span>${esc(x.text)} <small>${esc(x.meta)}</small></span></div>`).join('')}</div>`);
217
+ h.push(`<div class="vz-col"><h3>Agenda <small>${esc(P.agendaSub)}</small></h3>${P.agenda.length ? P.agenda.map((a, i) => `<div class="vz-ag"><i class="vz-num" aria-hidden="true">${a.n}</i><span>${esc(a.text)}</span><button type="button" class="vz-min vz-hv" data-a="min" data-i="${i}" title="Change the minutes for this topic" aria-label="${esc(a.text)}: ${a.min} minutes. Change">${a.min} min</button></div>`).join('') : '<p class="vz-empty">The invite lists no topics yet.</p>'}</div>`);
218
+ if (P.toBeReady) h.push(`<div><h3>To be ready</h3><p class="vz-p">${esc(P.toBeReady)}</p></div>`);
219
+ h.push(`<div class="vz-col"><div class="vz-hrow"><h3>Material <small>${P.material.length} linked</small></h3><button type="button" class="vz-addm vz-hv" data-a="addmat">+ Add material</button></div>${P.material.map((m, i) => `<button type="button" class="vz-mat vz-hv" data-a="mat" data-i="${i}"><span class="vz-kind">${esc(m.kind)}</span><span><b>${esc(m.title)}</b><small>${esc(m.sub)}</small></span></button>`).join('')}</div>`);
220
+ h.push(`<div class="vz-col"><h3>Previous meetings <small>${P.prev.length ? P.prev.length + ' before this' : 'none kept'}</small></h3>${P.prev.map((p) => `<button type="button" class="vz-prev vz-hv" data-a="note" data-id="${esc(p.id)}"><time>${esc(p.date)}</time><span>${esc(p.decided + ' decided · ' + plural(p.steps, 'next step') + (p.overview ? ' · ' + p.overview : ''))}</span></button>`).join('')}</div>`);
221
+ return `<div class="vz-col14">${h.join('')}</div>`;
222
+ }
223
+ function liveHtml(m, ui) {
224
+ const L = m.live, h = [];
225
+ if (m.mk === 'live') {
226
+ const acts = m.liveK === 'rec' ? [['hl', 'Highlight', 'Keep the last 30 seconds and the next ones'], ['pause', 'Pause', 'Pause listening; resume within an hour'], ['stop', 'Stop', 'Stop and write the notes']]
227
+ : [['resume', 'Resume', 'Start listening again on this note'], ['stop', 'Stop', 'Stop and write the notes']];
228
+ h.push(`<div class="vz-bar" role="group" aria-label="Recording" data-k="${m.liveK}"><b><i aria-hidden="true"></i><span data-clk="state">${esc(L.state)}</span></b>${m.liveK === 'rec' ? '' : wait('Paused and not-capturing states')}<span class="vz-sp"></span>${acts.map(([k, l, t]) => `<button type="button" class="vz-b vz-hv${k === 'stop' ? ' vz-solid' : ''}" data-a="${k}" title="${esc(t)}">${l}</button>`).join('')}</div>`);
229
+ if (ui.ask === 'stop') h.push(`<div class="vz-ask" role="alert"><span><b>Stop for good?</b> ${esc(STOP_LINE)}</span><div><button type="button" class="vz-b vz-solid" data-a="stopgo">Stop and write the notes</button>${m.liveK === 'rec' ? '<button type="button" class="vz-b" data-a="pause">Pause instead</button>' : ''}<button type="button" class="vz-b" data-a="askno">Cancel</button></div></div>`);
230
+ h.push(`<div class="vz-src"><span>Listening to <b>${esc(L.app)}</b> · microphone and meeting</span><button type="button" class="vz-link vz-hv" data-a="src" aria-expanded="${!!ui.src}">Change</button><span class="vz-sp"></span><span>${plural(L.shots, 'screen shot')}${L.shotsPaused ? ' · paused' : ''}</span><button type="button" class="vz-link vz-hv" data-a="shots">${L.shotsPaused ? 'Resume shots' : 'Pause shots'}</button></div>`);
231
+ if (ui.src) h.push(`<div class="vz-apps" role="radiogroup" aria-label="Where the meeting is">${APPS.map((a) => `<button type="button" role="radio" class="vz-b${a.id === L.appId ? ' vz-solid' : ''}" aria-checked="${a.id === L.appId}" data-a="app" data-id="${a.id}">${esc(a.label)}</button>`).join('')}<span class="vz-note">Used the next time you record or resume.</span></div>`);
232
+ h.push(`<label class="vz-priv"><input type="checkbox" data-a="priv"${m.private ? ' checked disabled' : ''}>${esc(PRIVATE_TEXT)}</label>`);
233
+ if (ui.ask === 'priv') h.push(`<div class="vz-ask" role="alert"><span>Make this note private? Its audio, transcript and screen shots are deleted now, and none are kept while it stays private.</span><div><button type="button" class="vz-b vz-solid" data-a="privgo">Make it private</button><button type="button" class="vz-b" data-a="askno">Cancel</button></div></div>`);
234
+ if (L.topics.length) h.push(`<div class="vz-col"><h3>Now on <small>${esc(L.nowSub)}</small></h3>${weightBar('vz-stretch', L.topics.map((t) => ({ w: +t.flex || 1, attrs: ` data-k="${t.k}"` })))}${L.topics.map((t) => `<div class="vz-ag" data-k="${t.k}"><i class="vz-num" data-k="${t.k}" aria-hidden="true">${t.n}</i><span>${esc(t.text)}</span><small>${esc(t.state)}</small></div>`).join('')}</div>`);
235
+ h.push(`<p class="vz-caught"><b>Caught so far:</b> ${esc(L.caught)}</p>`);
236
+ }
237
+ h.push(`<div class="vz-col"><h3>Your notes</h3><textarea class="vz-mine" data-a="mine" aria-label="Your notes" placeholder="${esc(MINE_HINT)}">${esc(L.mine)}</textarea></div>`);
238
+ h.push(`<div class="vz-col"><h3>Highlights <small>${L.hl.length} kept</small></h3>${L.hl.length ? L.hl.map((x) => `<div class="vz-hl"><time>${esc(x.t)}</time><span>${esc(x.text)}</span></div>`).join('') : `<p class="vz-empty">${m.mk === 'live' ? 'Press Highlight to keep the last 30 seconds and the next ones.' : 'No highlights were kept.'}</p>`}</div>`);
239
+ const off = m.mk === 'live' ? L.total - L.lines.length : 0;
240
+ h.push(`<div class="vz-col"><h3>Transcript <small>${m.mk === 'live' ? 'live · ' : ''}${plural(L.total, 'line')}</small></h3>${L.lines.length ? L.lines.map((l, i) => lineHtml(l, i + off, ui)).join('') : `<p class="vz-empty">${m.private ? 'This note is private: only what you type is kept.' : 'Nothing has been said yet.'}</p>`}<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p></div>`);
241
+ return `<div class="vz-col14">${h.join('')}</div>`;
242
+ }
243
+ function notesHtml(m, ui) {
244
+ const N = m.notes, h = [];
245
+ if (N.track) {
246
+ const T = N.track, pos = ui.pos || 0, pct = (x) => Math.min(100, Math.max(0, x)).toFixed(2);
247
+ h.push(`<div class="vz-rp" role="group" aria-label="Replay"><div><button type="button" class="vz-play" data-a="play" aria-label="${ui.playing ? 'Pause the recording' : 'Play the recording'}">${svg(ui.playing ? 'pause' : 'play', 13)}</button><div class="vz-rpm"><div class="vz-trk" data-a="seek" role="slider" tabindex="0" aria-label="Where the replay is" aria-valuemin="0" aria-valuemax="${Math.round(T.len / 1000)}" aria-valuenow="${Math.round(pos / 1000)}">${weightBar('vz-trs', (T.stretches.length ? T.stretches : [{ flex: 1, c: 2 }]).map((x) => ({ w: x.flex, attrs: ` class="vz-st" data-c="${x.c}"` })), T.marks.map((k) => `<rect class="vz-mk2" data-k="${esc(k.k)}" x="${pct(k.at)}%" y="-3" width="4" height="14" rx="2" transform="translate(-2 0)"/>`).join('') + `<circle class="vz-head" data-clk="head" cx="${pct(pos / T.len * 100)}%" cy="4" r="7"/>`)}</div><span class="vz-pos" data-clk="pos">${esc(mmss(pos) + ' of ' + mmss(T.len) + (T.topicAt(pos) ? ' · ' + T.topicAt(pos) : ''))}</span></div></div>`
248
+ + (T.shots.length ? `<div class="vz-shots">${T.shots.map((s) => `<button type="button" class="vz-shot vz-hv" data-a="seekto" data-t="${s.t}" aria-label="${esc('Screen at ' + mmss(s.t) + (s.why ? ': ' + s.why : ''))}"><span aria-hidden="true">${T.noteId ? `<img src="/api/notes/screen?id=${encodeURIComponent(T.noteId)}&amp;t=${s.t}" alt="" loading="lazy">` : ''}</span><small>${esc(s.cap)}</small></button>`).join('')}</div>` : '')
249
+ + '</div>'); // the well ends at the thumbnails; Full replay is in ⋯ (Waiting for design)
250
+ }
251
+ h.push(`<p class="vz-sum">${N.summary ? esc(N.summary) : '<span class="vz-empty">No summary was written for this meeting.</span>'}</p>`);
252
+ if (N.since) h.push(`<div class="vz-col"><h3>Since the last one <small>${esc(N.since.sub)}</small></h3>${N.since.rows.map((s) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${s.k}">${esc(s.tag)}</span><span>${esc(s.text)} <small>${esc(s.owner)}</small></span></div>`).join('')}</div>`);
253
+ h.push(`<div class="vz-col vz-g8"><h3>Decisions</h3>${N.decisions.length ? N.decisions.map((d) => `<div class="vz-dec"><p>${esc(d.text)}</p>${d.why ? `<p>Why: ${esc(d.why)}</p>` : ''}</div>`).join('') : '<p class="vz-empty">No decisions were caught.</p>'}</div>`);
254
+ h.push(`<div class="vz-col"><h3>Next steps <small>${esc(N.stepsSub)}</small></h3>${N.steps.length ? N.steps.map((a) => `<div class="vz-step"><span><span>${esc(a.text)}</span><span>${esc(a.meta)}</span></span>${a.made ? `<span class="vz-pill" data-k="${a.ticket ? 'ticket' : 'task'}">${esc(a.made)}</span>${a.undo ? '<button type="button" class="vz-link vz-hv" data-a="undo" data-i="' + a.i + '">Undo</button>' : ''}` : `<button type="button" class="vz-b vz-hv" data-a="task" data-i="${a.i}" aria-expanded="${ui.stepMenu === a.i}">Make task</button>`}${ui.stepMenu === a.i && !a.made ? `<div class="vz-smenu" role="group" aria-label="Make it"><button type="button" class="vz-b" data-a="maketask" data-i="${a.i}" title="A task in the initiative's breakdown">A task</button><button type="button" class="vz-b" data-a="makewi" data-i="${a.i}" title="A ticket Drafted in PMOS, shown on the Board. It goes to Jira only through the Commit gate.">A work-item</button>${wait('Make task status and Undo')}</div>` : ''}</div>`).join('') : '<p class="vz-empty">No next steps were caught.</p>'}</div>`);
255
+ if (N.facts.length) h.push(`<div class="vz-col"><h3>Facts mentioned <small>checked against the repository</small></h3>${N.facts.map((f) => `<div class="vz-tagrow"><span class="vz-tag" data-k="${f.k}">${esc(f.tag)}</span><span>${esc(f.text)} <small>${esc(f.src)}</small></span></div>`).join('')}</div>`);
256
+ if (N.questions.length) h.push(`<div class="vz-col"><h3>Open questions</h3>${N.questions.map((q) => `<div class="vz-tagrow"><span class="vz-tag">Question</span><span>${esc(q.text)}</span></div>`).join('')}</div>`);
257
+ if (N.lines.length) {
258
+ h.push(`<button type="button" class="vz-trt vz-hv" data-a="tr" aria-expanded="${!!ui.tr}"><span>${esc(N.trTitle)}</span>${svg('chev', 12)}</button>`);
259
+ if (ui.tr) h.push(`<div class="vz-col">${N.lines.map((l, i) => lineHtml(l, i, ui)).join('')}</div>`);
260
+ }
261
+ return `<div class="vz-col vz-g16">${h.join('')}</div>`;
262
+ }
263
+ /** The card's body. ui = { open: { part: bool }, more, ppl, why, ask, src, tr, naming, pos, playing, stepMenu, msg, about (html), sheet (html) } */
264
+ export function meetHtml(m, ui = {}) {
265
+ if (ui.sheet) return `<div class="vz">${ui.sheet}</div>`;
266
+ const c = m.chip, h = [];
267
+ h.push(`<div class="vz-r1 vz-hd1"><span class="vz-chip" data-tone="${c.tone}"><i aria-hidden="true"></i>${esc(c.text)}</span>`
268
+ + `<button type="button" class="vz-ppl vz-hv" data-a="ppl" aria-expanded="${!!ui.ppl}"${m.people.length ? '' : ' disabled'}>${svg('ppl', 13)}${esc(plural(m.people.length, 'person', 'people'))}</button><span class="vz-sp"></span>`
269
+ + (m.primary ? `<button type="button" class="vz-pri vz-hv${m.primary.out ? ' vz-out' : ''}" data-a="${m.primary.k}" data-k="${m.primary.k}" title="${esc(m.primary.k === 'record' ? RECORD_LINE : m.primary.k === 'stop' ? 'Stop and write the notes' : m.primary.label)}"><i aria-hidden="true"></i>${esc(m.primary.label)}</button>` : '')
270
+ + `<button type="button" class="vz-more vz-hv" data-a="more" aria-label="More for this meeting" aria-expanded="${!!ui.more}">${dots}</button></div>`);
271
+ if (ui.more) h.push(`<div class="vz-menu" role="menu">${m.menu.map((x) => `<button type="button" role="menuitem" class="vz-hv" data-a="m-${x.k}"${x.k === 'replay' ? ' data-cz-placeholder="Full Replay view"' : ''}><b>${esc(x.label)}</b><small>${esc(x.sub)}</small></button>`).join('')}</div>`);
272
+ if (ui.ppl && m.people.length) h.push(`<div class="vz-people">${m.people.map((p) => `<span class="vz-person"><i aria-hidden="true">${esc(p.trim().charAt(0).toUpperCase())}</i>${esc(clip(p, 40))}</span>`).join('')}</div>`);
273
+ h.push(`<div class="vz-r2"><span data-clk="when">${esc(m.when)}</span><span>${svg('link', 13)}${m.about ? `About <b>${esc(m.about)}</b>` : `Not linked <button type="button" class="vz-link vz-hv" data-a="m-about">Link it</button>`}</span>`
274
+ + (m.series ? `<span class="vz-ser"><button type="button" class="vz-nav vz-hv" data-a="note" data-id="${esc(m.series.prev ? m.series.prev.id : '')}" aria-label="${esc(m.series.prev ? 'The meeting before, ' + m.series.prev.day : 'No meeting before this one')}"${m.series.prev ? '' : ' disabled'}>${svg('prev', 12)}</button><span>${esc(m.series.title + ' · ' + m.series.pos + ' of ' + m.series.count)}</span><button type="button" class="vz-nav vz-hv" data-a="note" data-id="${esc(m.series.next ? m.series.next.id : '')}" aria-label="${esc(m.series.next ? 'The meeting after, ' + m.series.next.day : 'No meeting after this one yet')}"${m.series.next ? '' : ' disabled'}>${svg('next', 12)}</button></span>` : '') + '</div>');
275
+ if (ui.ask === 'consent') h.push(`<div class="vz-ask" role="alert"><span><b>Tell everyone first.</b> ${esc(CONSENT_LINE.replace('Tell everyone first. ', ''))}</span><div><button type="button" class="vz-b vz-solid" data-a="recgo">I told them, start</button><button type="button" class="vz-b" data-a="askno">Not yet</button></div></div>`);
276
+ if (ui.why) h.push(`<div class="vz-why" role="note"><p>${esc(RECORD_LINE)}</p><p>${esc(FOCUS_LINE)}</p></div>`);
277
+ if (ui.about) h.push(ui.about);
278
+ if (ui.msg) h.push(`<p class="vz-msg" role="status" data-tone="${ui.msg.tone || ''}"><span>${esc(ui.msg.text)}</span>${ui.msg.undo ? '<button type="button" class="vz-link vz-hv" data-a="msgundo">Undo</button>' : ''}</p>`);
279
+ for (const p of m.parts) {
280
+ const open = ui.open && ui.open[p.k] != null ? ui.open[p.k] : p.k === m.mk;
281
+ const body = !open ? '' : p.empty ? `<p class="vz-empty">${esc(p.empty)}</p>` : p.k === 'prep' ? prepHtml(m.prep) : p.k === 'live' ? liveHtml(m, ui) : notesHtml(m, ui);
282
+ h.push(`<section class="vz-part" data-part="${p.k}" data-open="${open}"><button type="button" class="vz-ph vz-hv" data-a="part" data-k="${p.k}" aria-expanded="${open}"><span><b>${esc(p.title)}</b><small>${esc(p.sub)}</small></span>${svg('chev', 14)}</button>${open ? `<div class="vz-pb">${body}</div>` : ''}</section>`);
283
+ }
284
+ return `<div class="vz vz-mtg" data-mk="${m.mk}">${h.join('')}</div>`;
285
+ }
286
+
287
+ /* ── the page half ── */
288
+ let MT = null; // the meeting shown
289
+ let WEEKS = new Map(); // date → weekView, read once per open
290
+ const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
291
+ const toast = (t) => { try { if (typeof window !== 'undefined' && window.pmToast) window.pmToast(t); } catch { /* none */ } };
292
+ /** The recorder of the page: the one Home mounted (premium-meeting.js mountMeeting), else one made here. */
293
+ const rec = () => recCore({ pmGet, pmPost, ws: () => (MT && MT.ws) || new URLSearchParams(location.search).get('ws') });
294
+ async function weekOf(date, ws) {
295
+ const k = date + '|' + (ws || '');
296
+ if (!WEEKS.has(k)) WEEKS.set(k, weekView(await pmGet('/api/calendar-views?' + q({ view: 'week', date, ws })), date));
297
+ return WEEKS.get(k);
298
+ }
299
+ const rowsOf = (W) => (W && W.state === 'ok' ? W.days.flatMap((d) => d.rows) : []);
300
+ /** The item's own address: Open in a new tab opens the standalone viewer page on it. */
301
+ export function meetingUrl(r) {
302
+ if (r.note) return '/premium-viewer.html?' + q({ open: 'meeting', note: r.note, ws: r.ws });
303
+ if (r.event) return '/premium-viewer.html?' + q({ open: 'meeting', event: r.event, date: r.date, ws: r.ws });
304
+ return '';
305
+ }
306
+ /** What a ref names: { note?, event?, date?, at?, title? }. */
307
+ export function refOf(ref) {
308
+ if (!ref) return {};
309
+ if (typeof ref === 'string') return /^\d{4}-\d{2}-\d{2}$/.test(ref) ? { date: ref } : { note: ref };
310
+ if (ref.note) return { note: typeof ref.note === 'string' ? ref.note : ref.note.id, event: ref.event, date: ref.date };
311
+ const at = ref.at || ref.start || null;
312
+ const date = ref.date || ref.day || (ok(at) ? dayKey(Date.parse(at)) : '');
313
+ return { event: ref.event || ref.id || '', date, at, title: ref.title || '', row: ref.at && ref.day && 'who' in ref ? ref : null };
314
+ }
315
+
316
+ export async function openMeeting(ref, o = {}) {
317
+ const R = refOf(ref);
318
+ const me = { R, ws: o.ws || new URLSearchParams(location.search).get('ws') || '', ui: { open: {} }, D: null, n: null, row: null, alive: true, timers: [], play: null };
319
+ if (MT) { MT.alive = false; MT.timers.forEach(clearInterval); stopPlay(MT); }
320
+ MT = me;
321
+ const id = 'meeting:' + (R.note || R.event || R.title || 'new');
322
+ const draw0 = (body) => { body.innerHTML = '<div class="vz"><p class="vz-empty" role="status">Reading the meeting.</p></div>'; };
323
+ me.vid = id;
324
+ vOpen({ id, kind: 'Meeting', title: R.title || 'Meeting', icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: draw0, onClose: () => { if (MT === me && !me.reopen) { me.alive = false; me.timers.forEach(clearInterval); stopPlay(me); MT = null; } } });
325
+ await load(me);
326
+ if (MT !== me) return;
327
+ if (o.about) await aboutPicker(me);
328
+ me.timers.push(setInterval(() => tick(me), 1000));
329
+ me.timers.push(setInterval(() => { if (me.model && me.model.mk === 'live') load(me, true); }, 4000));
330
+ me.timers.push(setInterval(() => { if (me.model && me.model.mk !== 'live') load(me, true); }, 30000));
331
+ }
332
+
333
+ /** Read everything the card shows, then draw it. */
334
+ async function load(me, quiet) {
335
+ const C = rec();
336
+ const NR = await C.refresh().catch(() => C.notes());
337
+ if (MT !== me) return;
338
+ let noteId = me.R.note || (me.n && me.n.id) || '';
339
+ let row = me.row;
340
+ if (!noteId && !row && me.R.row) row = me.R.row;
341
+ /* the calendar row, from the week of the meeting's day */
342
+ if (!row && (me.R.event || me.R.at) && me.R.date) {
343
+ const W = await weekOf(me.R.date, me.ws); me.W = W;
344
+ row = rowsOf(W).find((r) => (me.R.event && r.id === me.R.event) || (me.R.at && Date.parse(r.at) === Date.parse(me.R.at) && (!me.R.title || r.title === clip(me.R.title, 120)))) || null;
345
+ }
346
+ if (!noteId && row) { const nt = noteOfRow(NR, row); if (nt) noteId = nt.id; }
347
+ const one = noteId ? await pmGet('/api/notes/one?id=' + encodeURIComponent(noteId)) : null;
348
+ if (MT !== me) return;
349
+ const n = one && one.ok ? one.note : null, S = noteSheet(one);
350
+ if (n && !row && n.meeting && n.meeting.kind === 'event' && ok(n.meeting.start)) {
351
+ const W = await weekOf(dayKey(Date.parse(n.meeting.start)), me.ws); me.W = W;
352
+ row = rowsOf(W).find((r) => sameMeeting(n.meeting, r)) || null;
353
+ }
354
+ me.row = row; me.n = n;
355
+ const date = row ? row.day : n && n.meeting && ok(n.meeting.start) ? dayKey(Date.parse(n.meeting.start)) : me.R.date || '';
356
+ const evId = row ? row.id : n && n.meeting && n.meeting.event_id ? n.meeting.event_id : me.R.event || '';
357
+ const fq = evId ? { event: evId, date } : n ? { note: n.id } : null;
358
+ const done = n && (n.state === 'ended' || (S && S.from === 'final'));
359
+ const [F, rp, ser] = await Promise.all([
360
+ fq ? pmGet('/api/meeting-focus?' + q(fq)) : null,
361
+ n && done && !n.private ? pmGet('/api/meeting-replay?' + q({ note: n.id })) : null,
362
+ !quiet && S && S.series && S.series.key ? pmGet('/api/notes/series?key=' + encodeURIComponent(S.series.key)) : null,
363
+ ]);
364
+ if (MT !== me) return;
365
+ const topicTexts = (F && F.ok && Array.isArray(F.topics) && F.topics.length ? F.topics.map((t) => t.text) : S && S.context ? S.context.agenda.map((a) => a.text) : []).slice(0, 12);
366
+ const len = row && ok(row.at) && ok(row.end) ? Math.round((Date.parse(row.end) - Date.parse(row.at)) / 60000) : 0;
367
+ const vmq = new URLSearchParams(q({ note: n ? n.id : '', event: evId, series: row && row.series, title: (row && row.title) || (n && n.title) || '', length: len || '' }));
368
+ topicTexts.forEach((t) => vmq.append('topic', t));
369
+ const vm = await pmGet('/api/viewer-meeting?' + vmq.toString());
370
+ if (MT !== me) return;
371
+ /* the steps' keys: the server keys a step by its words; the page asks once per open for the keys of the note's steps */
372
+ const steps = me.D && me.D.steps ? me.D.steps : {};
373
+ if (S && S.actions.length && !Object.keys(steps).length) for (const a of S.actions) steps[norm(a.text)] = await keyOf(a.text);
374
+ if (ser) me.prev = prevOf(ser, row || { at: (n && n.meeting && n.meeting.start) || (n && n.created_at) });
375
+ const level = row && row.level ? row.level : F && F.ok && F.brief && F.brief.initiative ? { kind: 'initiative', id: F.brief.initiative.id, name: F.brief.initiative.title } : null;
376
+ const about = level ? (level.kind === 'portfolio' ? 'Portfolio' : clip(level.name || level.id, 60)) : S && S.about ? S.about : '';
377
+ const held = !!(window.__premiumHolding && n && window.__premiumHolding.id === n.id);
378
+ const nr = n ? NR.find((x) => x.id === n.id) : null;
379
+ me.D = { row, n, S, F: F && F.ok ? F : null, rep: rp && rp.ok ? replayModel(rp) : null, vm: vm && vm.ok ? vm : null, prev: me.prev || [], about, level,
380
+ people: (row && row.who && row.who.length ? row.who : F && F.ok && F.event && F.event.attendees && F.event.attendees.length ? F.event.attendees : S && S.context ? S.context.people : []),
381
+ rec: { held, started: held ? C.started() : null }, elapsedBase: nr ? nr.meeting_ms || 0 : 0, frames: one && one.screen ? (one.screen.frames || []).length : 0,
382
+ canRecord: row ? recordable(row) : !!(n && (n.state === 'idle' || !n.state)), app: recall(safeStorage()).app, steps };
383
+ draw(me);
384
+ }
385
+ async function keyOf(text) {
386
+ try {
387
+ const b = new TextEncoder().encode(stepNorm(text));
388
+ const h = await crypto.subtle.digest('SHA-256', b);
389
+ return [...new Uint8Array(h)].slice(0, 4).map((x) => x.toString(16).padStart(2, '0')).join('');
390
+ } catch { return ''; }
391
+ }
392
+ const safeStorage = () => { try { return localStorage; } catch { return null; } };
393
+ const elapsedOf = (me) => { const D = me.D; if (!D) return 0; if (D.rec.held && D.rec.started) return Date.now() - D.rec.started; return D.elapsedBase; };
394
+
395
+ function draw(me) {
396
+ if (MT !== me || !me.D) return;
397
+ const body = vCur() && vCur().id === me.vid ? document.querySelector('#czViewer .cz-vw-body') : null;
398
+ const m = me.model = meetModel({ ...me.D, elapsed: elapsedOf(me) });
399
+ const busy = body && body.contains(document.activeElement) && /^(TEXTAREA|INPUT|SELECT)$/.test(document.activeElement.tagName);
400
+ if (body && me.ui.sheet) return; // a sheet (Focus, Add material, the full Replay) keeps its own DOM and presses; closing it draws the card again
401
+ if (!body || me.kind !== m.kind || me.head !== m.head) { // the header names the state: open again when it changed
402
+ me.kind = m.kind; me.head = m.head; me.reopen = true;
403
+ const R = me.n ? { note: me.n.id } : me.row ? { event: me.row.id, date: me.row.day } : me.R;
404
+ vOpen({ id: me.vid, kind: m.kind, title: m.head, icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: (b) => paint(me, b), onClose: () => { if (MT === me && !me.reopen) { me.alive = false; me.timers.forEach(clearInterval); stopPlay(me); MT = null; } } });
405
+ me.reopen = false;
406
+ return;
407
+ }
408
+ if (busy) return; // the PM is typing: the next read draws it
409
+ paint(me, body);
410
+ }
411
+ function paint(me, body) {
412
+ const top = body.scrollTop;
413
+ body.innerHTML = meetHtml(me.model, me.ui);
414
+ body.scrollTop = top;
415
+ if (!body.dataset.vzWired) { body.dataset.vzWired = '1'; }
416
+ body.onclick = (e) => press(me, e);
417
+ body.onchange = (e) => change(me, e);
418
+ body.oninput = (e) => { if (e.target.dataset.a === 'mine') saveMine(me, e.target.value); };
419
+ body.onkeydown = (e) => { if (e.key === 'Enter' && e.target.dataset.a === 'namein') { e.preventDefault(); nameIt(me, +e.target.dataset.i, e.target.value); } if (e.key === 'Enter' && e.target.dataset.a === 'minin') { e.preventDefault(); setMin(me, +e.target.dataset.i, e.target.value); } if (e.key === 'Escape' && (me.ui.naming != null)) { me.ui.naming = null; paint(me, body); } };
420
+ }
421
+ const bodyEl = () => document.querySelector('#czViewer .cz-vw-body');
422
+ const repaint = (me) => { const b = bodyEl(); if (b && MT === me && !me.ui.sheet) paint(me, b); };
423
+ function say(me, text, tone, undo) { me.ui.msg = { text, tone, undo }; repaint(me); clearTimeout(me.msgT); me.msgT = setTimeout(() => { if (me.ui.msg && me.ui.msg.text === text) { me.ui.msg = null; repaint(me); } }, 9000); }
424
+ function tick(me) {
425
+ if (MT !== me || !me.model) return;
426
+ const b = bodyEl(); if (!b) return;
427
+ if (me.model.mk === 'live' && me.D.rec.held) {
428
+ const el = elapsedOf(me), s = b.querySelector('[data-clk="state"]'), w = b.querySelector('[data-clk="when"]');
429
+ if (s) s.textContent = 'Recording · ' + mmss(el);
430
+ if (w) w.textContent = me.model.when.replace(/ · [\d:]+ so far$/, ' · ' + mmss(el) + ' so far');
431
+ }
432
+ }
433
+
434
+ /* the presses */
435
+ async function press(me, e) {
436
+ const t = e.target.closest('[data-a]'); if (!t || t.disabled) return;
437
+ const a = t.dataset.a, ui = me.ui, m = me.model, C = rec();
438
+ if (a !== 'more' && !a.startsWith('m-')) ui.more = false;
439
+ switch (a) {
440
+ case 'part': ui.open[t.dataset.k] = !(t.getAttribute('aria-expanded') === 'true'); return repaint(me);
441
+ case 'more': ui.more = !ui.more; return repaint(me);
442
+ case 'ppl': ui.ppl = !ui.ppl; return repaint(me);
443
+ case 'askno': ui.ask = null; return repaint(me);
444
+ case 'record': ui.ask = 'consent'; return repaint(me);
445
+ case 'recgo': {
446
+ ui.ask = null; t.disabled = true;
447
+ const res = me.n && !me.row ? await C.resume(me.n.id) : await C.record(me.row);
448
+ say(me, res.ok ? 'Recording. Notes are being taken on this machine. Let people know.' : res.error, res.ok ? '' : 'bad');
449
+ ui.open = {}; return load(me);
450
+ }
451
+ case 'resume': { t.disabled = true; const res = await C.resume(me.n.id); say(me, res.ok ? 'Listening again.' : res.error, res.ok ? '' : 'bad'); return load(me); }
452
+ case 'pause': { ui.ask = null; t.disabled = true; const res = await C.pause(); say(me, res.ok ? 'Paused. You can resume within 1 hour.' : res.error, res.ok ? '' : 'bad'); return load(me); }
453
+ case 'stop': ui.ask = 'stop'; return repaint(me);
454
+ case 'stopgo': { ui.ask = null; t.disabled = true; const res = await C.stop(me.n.id); say(me, res.ok ? (res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped. The final notes are written now.') : res.error, res.ok ? '' : 'bad'); ui.open = {}; return load(me); }
455
+ case 'hl': { const res = await C.highlight(); say(me, res.ok ? 'Keeping the last 30 seconds and the next ones as a highlight.' : res.error, res.ok ? '' : 'bad'); return; }
456
+ case 'src': ui.src = !ui.src; return repaint(me);
457
+ case 'app': {
458
+ const s = safeStorage(); remember(s, { ...recall(s), app: t.dataset.id }); me.D.app = t.dataset.id;
459
+ if (me.n) { const r = await pmPost('/api/viewer-meeting/capture', { id: me.n.id, app: t.dataset.id }); if (r && r.ok) me.D.vm = { ...(me.D.vm || {}), capture: r.capture }; }
460
+ ui.src = false; return draw(me);
461
+ }
462
+ case 'shots': {
463
+ if (!me.n) return;
464
+ const r = await pmPost('/api/viewer-meeting/capture', { id: me.n.id, shots: m.live.shotsPaused ? 'on' : 'paused' });
465
+ if (!r || !r.ok) return say(me, 'Not changed: ' + ((r && r.error) || 'no answer'), 'bad');
466
+ me.D.vm = { ...(me.D.vm || {}), capture: r.capture }; say(me, r.capture.shots === 'paused' ? 'Screen shots are paused. Sound and the transcript go on.' : 'Screen shots go on.'); return draw(me);
467
+ }
468
+ case 'privgo': {
469
+ ui.ask = null; const r = await pmPost('/api/notes/private', { id: me.n.id, private: true });
470
+ say(me, r && r.ok ? 'Private. Only what you type is kept.' : 'Not changed: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad'); return load(me);
471
+ }
472
+ case 'name': ui.naming = +t.dataset.i; repaint(me); { const i = bodyEl().querySelector('[data-a="namein"]'); if (i) { i.focus(); i.select(); } } return;
473
+ case 'nameok': { const i = bodyEl().querySelector('[data-a="namein"]'); return nameIt(me, +t.dataset.i, i ? i.value : ''); }
474
+ case 'min': {
475
+ const row = t.closest('.vz-ag'), a0 = m.prep.agenda[+t.dataset.i]; if (!a0) return;
476
+ t.outerHTML = `<span class="vz-min"><input type="number" min="0" max="240" step="5" data-a="minin" data-i="${t.dataset.i}" value="${a0.min}" aria-label="Minutes for ${esc(a0.text)}"></span>`;
477
+ const i = row.querySelector('input'); if (i) { i.focus(); i.select(); i.onblur = () => setMin(me, +i.dataset.i, i.value); } return;
478
+ }
479
+ case 'note': if (t.dataset.id) return openMeeting({ note: t.dataset.id }, { ws: me.ws }); return;
480
+ case 'mat': {
481
+ const x = m.prep.material[+t.dataset.i]; if (!x) return;
482
+ if (x.url && /^https:\/\//.test(x.url)) { window.open(x.url, '_blank', 'noopener'); return; }
483
+ return say(me, '“' + x.title + '” is a PMOS ' + x.kind.toLowerCase() + '. Open it from its initiative.');
484
+ }
485
+ case 'addmat': return addMaterial(me);
486
+ case 'tr': ui.tr = !ui.tr; return repaint(me);
487
+ case 'task': ui.stepMenu = ui.stepMenu === +t.dataset.i ? null : +t.dataset.i; return repaint(me);
488
+ case 'maketask': return makeTask(me, +t.dataset.i);
489
+ case 'makewi': return makeWorkItem(me, +t.dataset.i);
490
+ case 'msgundo': { const u = ui.msg && ui.msg.undo; ui.msg = null; if (u) await u(); return; }
491
+ case 'play': case 'replay': return togglePlay(me, a === 'replay');
492
+ case 'seekto': return seek(me, +t.dataset.t, true);
493
+ case 'seek': { const r = t.getBoundingClientRect(); return seek(me, Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)) * m.notes.track.len, false); }
494
+ case 'fullreplay': return fullReplay(me);
495
+ case 'm-focus': ui.more = false; return focusView0(me);
496
+ case 'm-about': ui.more = false; return aboutPicker(me);
497
+ case 'm-copy': { ui.more = false; repaint(me); const md = mdOf(m); try { await navigator.clipboard.writeText(md); say(me, 'Copied the notes as Markdown.'); } catch { say(me, 'The browser did not allow copying. Select the text in the notes instead.', 'bad'); } return; }
498
+ case 'm-fresh': { ui.more = false; return newNote(me.ws); }
499
+ case 'm-serout': case 'm-serback': {
500
+ ui.more = false; const r = await pmPost('/api/notes/series-member', { id: me.n.id, key: a === 'm-serout' ? 'off' : null });
501
+ say(me, r && r.ok ? (a === 'm-serout' ? 'Taken out of the series. It stays a note on its own.' : 'Back in its series.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad'); return load(me);
502
+ }
503
+ case 'm-replay': ui.more = false; return fullReplay(me);
504
+ case 'm-why': ui.more = false; ui.why = !ui.why; return repaint(me);
505
+ case 'aboutno': ui.about = ''; return repaint(me);
506
+ case 'aboutgo': return saveAbout(me);
507
+ default:
508
+ }
509
+ }
510
+ function change(me, e) {
511
+ const t = e.target;
512
+ if (t.dataset.a === 'priv' && t.checked) { t.checked = false; me.ui.ask = 'priv'; repaint(me); }
513
+ }
514
+ let mineT = null;
515
+ function saveMine(me, v) {
516
+ if (!me.n) return;
517
+ clearTimeout(mineT);
518
+ mineT = setTimeout(async () => { const r = await pmPost('/api/notes/save', { id: me.n.id, body: v }); if (r && r.ok && me.n) me.n.body = v; else if (MT === me) say(me, 'Your notes were not saved: ' + ((r && r.error) || 'no answer'), 'bad'); }, 900);
519
+ }
520
+ async function nameIt(me, i, name) {
521
+ const lines = me.model.mk === 'live' ? me.model.live.lines : me.model.notes.lines, off = me.model.mk === 'live' ? me.model.live.total - me.model.live.lines.length : 0;
522
+ const all = linesOf(me.n), l = all[i] || lines[i - off];
523
+ me.ui.naming = null;
524
+ if (!l || !String(name).trim()) return repaint(me);
525
+ const body = l.key ? { id: me.n.id, key: l.key, name: String(name).trim() } : { id: me.n.id, source: l.source, name: String(name).trim() };
526
+ const r = await pmPost('/api/notes/speaker', body);
527
+ say(me, r && r.ok ? 'Named. Every line of this speaker shows the name.' : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
528
+ return load(me, true);
529
+ }
530
+ async function setMin(me, i, v) {
531
+ const a = me.model && me.model.prep.agenda[i]; if (!a || me.savingMin) return;
532
+ const min = Math.max(0, Math.min(240, Math.round(Number(v) || 0)));
533
+ if (min === a.min && a.set) return repaint(me);
534
+ me.savingMin = true;
535
+ const r = await pmPost('/api/viewer-meeting/agenda', { key: a.key, topic: a.text, min });
536
+ me.savingMin = false;
537
+ if (!r || !r.ok) say(me, 'The minutes were not saved: ' + ((r && r.error) || 'no answer'), 'bad');
538
+ return load(me, true);
539
+ }
540
+ /** Make task: the step goes into the first stage of the note's initiative (POST /api/plan-items); Undo withdraws it. */
541
+ async function makeTask(me, i) {
542
+ const S = me.D.S, step = S && S.actions[i]; me.ui.stepMenu = null; if (!step) return;
543
+ const lay = S.initiative ? await pmGet('/api/plan-items?' + q({ ladder: 0, ws: S.initiative.ws, id: S.initiative.id })) : null;
544
+ const plan = taskEvent(S, step, lay && lay.ok && (lay.stages || [])[0]);
545
+ if (!plan.ok) return say(me, 'The task was not made: ' + plan.reason, 'bad');
546
+ const r = await pmPost('/api/plan-items', { ws: plan.ws, events: [plan.event] });
547
+ if (!r || r.ok !== true) return say(me, 'The task was not made: ' + ((r && r.error) || 'no answer'), 'bad');
548
+ const item = r.written && r.written[0] && r.written[0].item;
549
+ await load(me, true);
550
+ say(me, 'Added to ' + S.initiative.name + ', under ' + (lay.stages[0].label || lay.stages[0].id) + '.', '', item ? async () => {
551
+ const u = await pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: S.initiative.id }] });
552
+ say(me, u && u.ok ? 'The task is withdrawn.' : 'The task was not withdrawn: ' + ((u && u.error) || 'no answer'), u && u.ok ? '' : 'bad'); load(me, true);
553
+ } : null);
554
+ }
555
+ /** A work-item: the step becomes a ticket Drafted in PMOS on the note's initiative (POST /api/viewer-meeting/work-item). */
556
+ async function makeWorkItem(me, i) {
557
+ const S = me.D.S, step = S && S.actions[i]; me.ui.stepMenu = null; if (!step) return;
558
+ const r = await workItem(me.n.id, step);
559
+ if (!r.ok) return say(me, 'The work-item was not made: ' + r.error, 'bad');
560
+ await load(me, true);
561
+ say(me, r.created ? r.ticket + ' is drafted in PMOS. It shows on the Board under Drafted in PMOS and goes to Jira only through the Commit gate.' : 'This step is already ' + r.ticket + '.');
562
+ }
563
+ export async function workItem(noteId, step) {
564
+ const r = await pmPost('/api/viewer-meeting/work-item', { note: noteId, step: { text: step.text, owner: step.owner || '', due: step.due || '' } });
565
+ return r && r.ok ? { ok: true, ticket: r.ticket && r.ticket.id ? r.ticket.id : r.ticket, created: !!r.created } : { ok: false, error: (r && r.error) || 'no answer' };
566
+ }
567
+ /** New meeting: an untitled note, listened to at once, shown live. */
568
+ export async function newNote(ws) {
569
+ const C = rec();
570
+ const r = await C.fresh();
571
+ if (!r.ok) { if (MT) say(MT, r.error, 'bad'); else toast(r.error); return r; }
572
+ await openMeeting({ note: r.id }, { ws });
573
+ return r;
574
+ }
575
+
576
+ /* the replay track */
577
+ function stopPlay(me) { if (me && me.play) { clearInterval(me.play.tm); if (me.play.aud) { try { me.play.aud.pause(); } catch { /* gone */ } } me.play.on = false; } }
578
+ function ensurePlay(me) {
579
+ const T = me.model.notes.track; if (!T) return null;
580
+ if (!me.play) { me.play = { pos: 0, on: false, aud: null, tm: null, last: 0 }; if (T.audio && T.audio.url) { me.play.aud = new Audio(T.audio.url); me.play.aud.preload = 'metadata'; me.play.aud.addEventListener('error', () => { if (me.play) me.play.aud = null; }); } }
581
+ return me.play;
582
+ }
583
+ function playUi(me) {
584
+ const P = me.play, T = me.model.notes.track; me.ui.pos = P.pos; me.ui.playing = P.on;
585
+ const b = bodyEl(); if (!b) return;
586
+ const h = b.querySelector('[data-clk="head"]'), p = b.querySelector('[data-clk="pos"]'), btn = b.querySelector('[data-a="play"]');
587
+ if (h) h.setAttribute('cx', Math.min(100, P.pos / T.len * 100).toFixed(2) + '%'); // an SVG attribute: where the replay is
588
+ if (p) p.textContent = mmss(P.pos) + ' of ' + mmss(T.len) + (T.topicAt(P.pos) ? ' · ' + T.topicAt(P.pos) : '');
589
+ if (btn && btn.dataset.on !== String(P.on)) { btn.dataset.on = String(P.on); btn.innerHTML = svg(P.on ? 'pause' : 'play', 13); btn.setAttribute('aria-label', P.on ? 'Pause the recording' : 'Play the recording'); }
590
+ }
591
+ function togglePlay(me, fromHead) {
592
+ const P = ensurePlay(me); if (!P) return;
593
+ if (fromHead) { me.ui.open.notes = true; repaint(me); const rp = bodyEl() && bodyEl().querySelector('.vz-rp'); if (rp) rp.scrollIntoView({ block: 'nearest' }); }
594
+ const T = me.model.notes.track;
595
+ if (P.on) { stopPlay(me); playUi(me); return; }
596
+ if (P.pos >= T.len - 200) P.pos = 0;
597
+ P.on = true; P.last = performance.now();
598
+ if (P.aud) { try { P.aud.currentTime = P.pos / 1000; } catch { /* not loaded */ } const pr = P.aud.play(); if (pr && pr.catch) pr.catch(() => { P.aud = null; P.last = performance.now(); }); }
599
+ P.tm = setInterval(() => {
600
+ if (MT !== me) { stopPlay(me); return; }
601
+ const now = performance.now();
602
+ if (P.aud && !P.aud.paused) P.pos = P.aud.currentTime * 1000; else P.pos += now - P.last; P.last = now;
603
+ if (P.pos >= T.len) { P.pos = T.len; stopPlay(me); }
604
+ playUi(me);
605
+ }, 250);
606
+ playUi(me);
607
+ }
608
+ function seek(me, ms, play) {
609
+ const P = ensurePlay(me); if (!P) return;
610
+ P.pos = Math.max(0, Math.min(me.model.notes.track.len, ms));
611
+ if (P.aud) { try { P.aud.currentTime = P.pos / 1000; } catch { /* not loaded */ } }
612
+ if (play && !P.on) togglePlay(me); else playUi(me);
613
+ }
614
+
615
+ /* ── the parts the design does not draw: plain and minimal, each with its "Waiting for design" marker ── */
616
+ function sheet(me, title, inner) {
617
+ me.ui.sheet = `<div class="vz-r1"><button type="button" class="vz-b vz-hv" data-a="back">Back to the meeting</button><span class="vz-sp"></span>${wait(title)}</div><h3>${esc(title)}</h3>${inner}`;
618
+ { const b0 = bodyEl(); if (b0 && MT === me) paint(me, b0); }
619
+ const b = bodyEl(); if (!b) return null;
620
+ const back = b.querySelector('[data-a="back"]'); if (back) back.onclick = (e) => { e.stopPropagation(); closeSheet(me); };
621
+ return b;
622
+ }
623
+ function closeSheet(me) { clearInterval(me.focusT); me.ui.sheet = ''; const ae = document.activeElement; if (ae && ae.blur && bodyEl() && bodyEl().contains(ae)) ae.blur(); draw(me); }
624
+ /** Focus: the meeting as it is now (GET /api/meeting-focus every 3 seconds), with Change topic. */
625
+ async function focusView0(me) {
626
+ const evId = me.row ? me.row.id : me.n && me.n.meeting && me.n.meeting.event_id;
627
+ const fq = evId ? { event: evId, date: me.row ? me.row.day : '' } : me.n ? { note: me.n.id } : null;
628
+ if (!fq) return say(me, 'Focus needs a meeting or a note.', 'bad');
629
+ const read = async () => {
630
+ const F = focusView(await pmGet('/api/meeting-focus?' + q(fq)));
631
+ if (MT !== me || !me.ui.sheet) return;
632
+ const inner = F.state !== 'ok' ? `<p class="vz-empty">Focus could not read this meeting: ${esc(F.reason)}</p>`
633
+ : `<p class="vz-note">${esc(F.status)}</p><div class="vz-col"><h3>Now</h3><p>${esc(F.current ? F.current.text : 'No topic is current yet')}</p></div>`
634
+ + (F.gist ? `<p class="vz-p">${esc(F.gist)}</p>` : '')
635
+ + `<div class="vz-col"><h3>Topics</h3>${F.topics.map((t) => `<div class="vz-ag"><i class="vz-num" data-k="${t.state === 'now' ? 'now' : ''}">${t.n}</i><span>${esc(t.text)}</span>${t.state === 'now' ? '<small>Now</small>' : `<button type="button" class="vz-link vz-hv" data-f="topic" data-t="${esc(t.text)}">Make it the topic</button>`}</div>`).join('') || '<p class="vz-empty">The meeting has no topics yet.</p>'}</div>`
636
+ + `<div class="vz-col"><h3>${F.rec ? 'Live transcript' : 'Transcript'}</h3>${F.tail.map((l) => `<p class="vz-line"><span><b>${esc(l.who)}</b> ${esc(l.text)}</span></p>`).join('') || `<p class="vz-empty">${F.rec ? 'Nothing has been said yet.' : 'The transcript starts when you record.'}</p>`}</div>`
637
+ + `<p class="vz-note">Captured: ${F.captured.decisions} decisions · ${F.captured.actions} next steps · ${F.captured.questions} questions. ${esc(F.companion || '')}</p><p class="vz-note">${esc(FOCUS_LINE)}</p>`;
638
+ const b = sheet(me, 'Focus', inner);
639
+ if (b) b.querySelectorAll('[data-f="topic"]').forEach((x) => { x.onclick = async (e) => { e.stopPropagation(); if (!evId) return; await pmPost('/api/meeting-focus/topic', { event: evId, date: fq.date, action: 'set', topic: x.dataset.t }); read(); }; });
640
+ };
641
+ sheet(me, 'Focus', '<p class="vz-empty">Reading the meeting.</p>');
642
+ clearInterval(me.focusT); me.focusT = setInterval(() => { if (me.ui.sheet && MT === me) read(); else clearInterval(me.focusT); }, 3000);
643
+ read();
644
+ }
645
+ /** The full replay: every line, each one a press that plays from it. */
646
+ function fullReplay(me) {
647
+ const T = me.model.notes.track, L = me.model.notes.lines;
648
+ const b = sheet(me, 'Full Replay view', `<p class="vz-note">${esc(mmss(T.len))} · ${plural(L.length, 'line')}. Press a line to play from it.</p><div class="vz-col">${L.map((l) => `<button type="button" class="vz-line vz-hv" data-f="at" data-t="${l.t}"><time>${esc(mmss(l.t))}</time><span><b>${esc(l.who)}</b> ${esc(l.text)}</span></button>`).join('')}</div>`);
649
+ if (b) b.querySelectorAll('[data-f="at"]').forEach((x) => { x.onclick = (e) => { e.stopPropagation(); closeSheet(me); me.ui.open.notes = true; seek(me, +x.dataset.t, true); }; });
650
+ }
651
+ /** About: Portfolio, a board or an initiative. A calendar meeting is linked for its whole series (POST /api/calendar-links); a note with no
652
+ * calendar event is linked itself (POST /api/notes/link). */
653
+ async function aboutPicker(me) {
654
+ let opts;
655
+ if (me.row) {
656
+ const W = me.W || (me.row.day ? await weekOf(me.row.day, me.ws) : null);
657
+ opts = [['portfolio', 'Portfolio']].concat((W && W.boards || []).map((b) => ['board|' + b.ws + '|' + b.id, 'Board: ' + b.name]), (W && W.initiatives || []).map((i) => ['initiative|' + i.id, 'Initiative: ' + i.name]), [['none', 'Remove the link']]);
658
+ } else if (me.n) {
659
+ const r = await pmGet('/api/boards'), list = r && r.ok && Array.isArray(r.boards) ? r.boards.filter((b) => b && b.id && !b.error) : [];
660
+ await Promise.all(list.map(async (b) => { const x = await pmGet('/api/boards/backlog?' + q({ ws: b.ws, board: b.id, limit: 100 })); b.inis = x && x.ok && Array.isArray(x.rows) ? x.rows : []; }));
661
+ me.choices = aboutChoices(list);
662
+ opts = me.choices.map((c) => [c.v, c.label]).concat([['none', 'Not linked']]);
663
+ } else return say(me, 'There is nothing to link yet.', 'bad');
664
+ const cur = me.n && !me.row ? aboutNow(me.n) : '';
665
+ me.ui.about = `<div class="vz-why" role="group" aria-label="What it is about"><div class="vz-r1"><b class="vz-t13">What it is about</b><span class="vz-sp"></span>${wait('About picker')}</div><select class="vz-in" data-a="aboutsel" aria-label="What this meeting is about"><option value="">Choose</option>${opts.map(([v, l]) => `<option value="${esc(v)}"${v === cur ? ' selected' : ''}>${esc(l)}</option>`).join('')}</select><p>${me.row ? 'Applies to every meeting of “' + esc(me.row.title) + '”. The calendar itself is never written.' : 'Applies to this note.'}</p><div class="vz-r1"><button type="button" class="vz-b vz-solid" data-a="aboutgo">Link it</button><button type="button" class="vz-b" data-a="aboutno">Cancel</button></div></div>`;
666
+ repaint(me);
667
+ }
668
+ async function saveAbout(me) {
669
+ const sel = bodyEl() && bodyEl().querySelector('[data-a="aboutsel"]'), v = sel ? sel.value : '';
670
+ if (!v) return;
671
+ let r;
672
+ if (me.row) { const W = me.W || {}; const body = linkBody(me.row, v, W.boards || []); if (!body) return; r = await pmPost('/api/calendar-links', body); WEEKS = new Map(); me.row = null; me.R.row = null; }
673
+ else { const body = aboutBody(me.n.id, v, me.choices); if (!body) return; r = await pmPost('/api/notes/link', body); }
674
+ me.ui.about = '';
675
+ say(me, r && r.ok ? (v === 'none' ? 'The link is removed.' : 'Linked.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
676
+ return load(me);
677
+ }
678
+ /** Add material (Waiting for design): what is linked now, each with Remove (Undo puts it back at the same scope); search PMOS or paste an https
679
+ * link; a topic of the meeting; for this meeting or the whole series. POST /api/meeting-material { op: add | remove }. The calendar is never written. */
680
+ async function addMaterial(me) {
681
+ const row = me.row; if (!row) return say(me, 'Material is kept per calendar meeting. This note has no calendar event.', 'bad');
682
+ const ev = { id: row.id || undefined, title: row.title, ...(row.series ? { series: row.series } : {}) };
683
+ const now = (me.model && me.model.prep.material) || [];
684
+ const itemOf = (x) => (x.url && !x.ref ? { url: x.url, title: x.title } : { kind: x.mkind || x.kind, ref: x.ref, title: x.title, ...(x.ws ? { ws: x.ws } : {}) });
685
+ const linked = now.length ? `<div class="vz-col"><h3>Linked now</h3>${now.map((x, i) => `<div class="vz-ag"><span class="vz-kind">${esc(x.kind)}</span><span>${esc(x.title)}<small> · ${esc(x.sub)}</small></span><button type="button" class="vz-link vz-hv" data-f="rm" data-i="${i}" aria-label="Remove ${esc(x.title)}">Remove</button></div>`).join('')}</div>` : '';
686
+ const b = sheet(me, 'Add material', `<p class="vz-note">${esc(row.title)}. PMOS keeps the link on its record of this meeting. The invite in your calendar is not changed.</p>${linked}<input class="vz-in" data-f="q" type="search" placeholder="Find a document, report or deck in PMOS" aria-label="Find in PMOS"><div class="vz-col" data-f="list"><p class="vz-empty">Looking in PMOS.</p></div><div class="vz-r1"><input class="vz-in vz-grow" data-f="url" type="url" placeholder="Or paste an https link" aria-label="Paste a link"><button type="button" class="vz-b vz-hv" data-f="addurl">Add link</button></div><span data-f="topicbox"></span><label class="vz-priv"><input type="checkbox" data-f="series">For every meeting in the series</label><p class="vz-msg" data-tone="bad" role="alert" data-f="err" hidden></p>`);
687
+ if (!b) return;
688
+ const list = b.querySelector('[data-f="list"]'), err = b.querySelector('[data-f="err"]');
689
+ const fail = (t) => { err.textContent = t; err.hidden = !t; };
690
+ const show = (items) => { list.innerHTML = items.length ? items.map((it, i) => `<button type="button" class="vz-mat vz-hv" data-f="pick" data-i="${i}"><span class="vz-kind">${esc(KIND[it.kind] || it.kind || 'Doc')}</span><span><b>${esc(clip(it.title, 100))}</b><small>${esc(it.meta || '')}</small></span></button>`).join('') : '<p class="vz-empty">Nothing in PMOS matches. Paste a link instead.</p>'; list.items = items; };
691
+ const suggest = async (qq) => { const r = await pmGet('/api/meeting-material/suggest?' + q({ ws: me.ws, q: qq, initiative: !qq && row.level && row.level.kind === 'initiative' ? row.level.id : '' })); if (b.isConnected) show(r && r.ok ? (qq ? r.found : r.suggested) || [] : []); };
692
+ suggest('');
693
+ pmGet('/api/meeting-material?' + q({ event: row.id, title: row.title, series: row.series, date: row.day, topics: 1, ws: me.ws })).then((r) => {
694
+ const T = r && r.ok && Array.isArray(r.topics) ? r.topics : [];
695
+ const box = b.querySelector('[data-f="topicbox"]');
696
+ if (box && T.length) box.innerHTML = `<select class="vz-in" data-f="topic" aria-label="Topic"><option value="">For the whole meeting</option>${T.map((t) => `<option value="${esc(t.text)}">For ${esc(clip(t.text, 80))}</option>`).join('')}</select>`;
697
+ });
698
+ let tq = null;
699
+ b.querySelector('[data-f="q"]').oninput = (e) => { clearTimeout(tq); const v = e.target.value.trim(); tq = setTimeout(() => suggest(v.length >= 2 ? v : ''), 220); };
700
+ const post = (op, scope, item, topic) => pmPost('/api/meeting-material', { op, event: ev, scope, item, ...(topic ? { topic } : {}) });
701
+ const add = async (item) => {
702
+ const scope = b.querySelector('[data-f="series"]').checked ? 'series' : 'meeting', tsel = b.querySelector('[data-f="topic"]'), topic = tsel ? tsel.value : '';
703
+ fail('');
704
+ const r = await post('add', scope, item, topic);
705
+ if (!r || !r.ok) return fail('Not added: ' + ((r && r.error) || 'no answer'));
706
+ closeSheet(me); say(me, 'Added “' + clip(item.title, 60) + '”' + (scope === 'series' ? ' for every meeting of the series.' : ' for this meeting.')); load(me, true);
707
+ };
708
+ const addUrl = () => {
709
+ const v = b.querySelector('[data-f="url"]').value.trim(); let u = null;
710
+ try { u = new URL(v); } catch { /* not an address */ }
711
+ if (!u || u.protocol !== 'https:') return fail('Only an https link can be added.');
712
+ return add({ url: u.href, title: u.hostname });
713
+ };
714
+ b.querySelector('[data-f="url"]').onkeydown = (e) => { if (e.key === 'Enter') { e.preventDefault(); addUrl(); } };
715
+ b.querySelector('[data-f="addurl"]').onclick = (e) => { e.stopPropagation(); addUrl(); };
716
+ list.onclick = (e) => { const x = e.target.closest('[data-f="pick"]'); if (!x) return; e.stopPropagation(); const it = list.items[+x.dataset.i]; if (it) add(it.url && !it.ref ? { url: it.url, title: it.title } : { kind: it.kind, ref: it.ref, title: it.title, ...(it.ws ? { ws: it.ws } : {}) }); };
717
+ b.querySelectorAll('[data-f="rm"]').forEach((x) => { x.onclick = async (e) => {
718
+ e.stopPropagation();
719
+ const m = now[+x.dataset.i]; if (!m) return;
720
+ const scope = m.scope || 'meeting', item = itemOf(m);
721
+ const r = await post('remove', scope, item);
722
+ if (!r || !r.ok) return fail('Not removed: ' + ((r && r.error) || 'no answer'));
723
+ closeSheet(me); await load(me, true);
724
+ say(me, 'Removed “' + clip(m.title, 60) + '”.', '', async () => { const u = await post('add', scope, item, m.topic || ''); say(me, u && u.ok ? 'It is back.' : 'Not added back: ' + ((u && u.error) || 'no answer'), u && u.ok ? '' : 'bad'); load(me, true); });
725
+ }; });
726
+ }
727
+
728
+ if (typeof window !== 'undefined') {
729
+ document.addEventListener('click', (e) => { if (MT && MT.ui.more && !e.target.closest('.vz-menu,[data-a="more"]')) { MT.ui.more = false; repaint(MT); } });
730
+ }
731
+ export const _test = { refOf, linesOf, factsOf };