create-pmos 0.398.0 → 0.399.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 (126) hide show
  1. package/package.json +13 -13
  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-adddoc-test.js +18 -14
  7. package/workspace/briefing-premium-board-test.js +80 -48
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +6 -2
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +46 -42
  18. package/workspace/briefing-premium-work-test.js +9 -9
  19. package/workspace/changelog.json +12 -0
  20. package/workspace/ev-everywhere-test.js +210 -0
  21. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  22. package/workspace/guide/home.md +39 -18
  23. package/workspace/guide/index.md +1 -1
  24. package/workspace/lib/board-grill.js +63 -0
  25. package/workspace/lib/board-premium.js +36 -5
  26. package/workspace/lib/initiative-layout.js +77 -0
  27. package/workspace/lib/insights-premium.js +3 -2
  28. package/workspace/lib/insights-records.js +21 -7
  29. package/workspace/lib/meeting-points.js +52 -0
  30. package/workspace/lib/news-for-you.js +88 -0
  31. package/workspace/lib/notes-series.js +29 -6
  32. package/workspace/lib/report-confirm.js +48 -0
  33. package/workspace/lib/route-modules.js +8 -0
  34. package/workspace/lib/routes-board-docs.js +46 -0
  35. package/workspace/lib/routes-board-grill.js +90 -0
  36. package/workspace/lib/routes-home-review.js +108 -0
  37. package/workspace/lib/routes-initiative-layout.js +57 -0
  38. package/workspace/lib/routes-insights-premium.js +4 -1
  39. package/workspace/lib/routes-insights-records.js +8 -4
  40. package/workspace/lib/routes-meeting-points.js +37 -0
  41. package/workspace/lib/routes-news.js +57 -0
  42. package/workspace/lib/routes-notes.js +2 -1
  43. package/workspace/lib/routes-report-confirm.js +31 -0
  44. package/workspace/lib/routes-search.js +38 -0
  45. package/workspace/lib/search-index.js +176 -0
  46. package/workspace/package-lock.json +2 -2
  47. package/workspace/package.json +1 -1
  48. package/workspace/premium-board-actions-test.js +86 -50
  49. package/workspace/premium-briefing-depth-test.js +55 -54
  50. package/workspace/premium-chat-chart-tab-test.js +4 -2
  51. package/workspace/premium-chat-report-tab-test.js +16 -2
  52. package/workspace/premium-core-doc-issue-test.js +15 -13
  53. package/workspace/premium-phone-card-test.js +5 -3
  54. package/workspace/premium-report-read-test.js +55 -18
  55. package/workspace/premium-vw-backlog-test.js +2 -2
  56. package/workspace/premium-vw-cal-test.js +50 -35
  57. package/workspace/premium-vw-doc-test.js +9 -3
  58. package/workspace/premium-vw-item-test.js +1 -1
  59. package/workspace/premium-vw-jira-test.js +2 -2
  60. package/workspace/premium-vw-meet-test.js +37 -40
  61. package/workspace/premium-vw-notes-test.js +21 -19
  62. package/workspace/premium-vw-rec-test.js +11 -12
  63. package/workspace/premium-welcome-test.js +3 -3
  64. package/workspace/premium-work-depth-test.js +3 -3
  65. package/workspace/public/pm/bd-acts.js +303 -225
  66. package/workspace/public/pm/bd-asks.js +261 -0
  67. package/workspace/public/pm/bd-pop.js +59 -0
  68. package/workspace/public/pm/bd-span.js +49 -13
  69. package/workspace/public/pm/bd-views.js +169 -0
  70. package/workspace/public/pm/cozy-board.css +301 -0
  71. package/workspace/public/pm/cozy-ev.css +228 -0
  72. package/workspace/public/pm/cozy-evmodel.js +106 -0
  73. package/workspace/public/pm/cozy-evui.js +47 -0
  74. package/workspace/public/pm/cozy-insights.css +148 -10
  75. package/workspace/public/pm/cozy-nav.js +103 -39
  76. package/workspace/public/pm/cozy-news.js +140 -0
  77. package/workspace/public/pm/cozy-search.js +203 -0
  78. package/workspace/public/pm/cozy-settings.js +198 -0
  79. package/workspace/public/pm/cozy-sources.js +89 -0
  80. package/workspace/public/pm/cozy-today.css +217 -0
  81. package/workspace/public/pm/cozy-viewer.js +1 -0
  82. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  83. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  84. package/workspace/public/pm/home-adddoc.js +5 -5
  85. package/workspace/public/pm/home-app.js +329 -55
  86. package/workspace/public/pm/home-around.js +24 -126
  87. package/workspace/public/pm/home-chat.js +67 -14
  88. package/workspace/public/pm/home-data.js +6 -6
  89. package/workspace/public/pm/home-dictate.js +54 -0
  90. package/workspace/public/pm/home-draft.js +6 -6
  91. package/workspace/public/pm/home-ini-model.js +190 -0
  92. package/workspace/public/pm/home-ini.css +171 -0
  93. package/workspace/public/pm/home-ini.js +456 -0
  94. package/workspace/public/pm/home-list.js +276 -0
  95. package/workspace/public/pm/home-more.js +17 -134
  96. package/workspace/public/pm/home-phone-card.js +4 -4
  97. package/workspace/public/pm/home-review.js +104 -0
  98. package/workspace/public/pm/home-task.js +67 -0
  99. package/workspace/public/pm/home-today.js +144 -0
  100. package/workspace/public/pm/home-work.js +54 -26
  101. package/workspace/public/pm/premium-board.js +163 -39
  102. package/workspace/public/pm/premium-chart-tab.js +4 -5
  103. package/workspace/public/pm/premium-first.js +5 -7
  104. package/workspace/public/pm/premium-insights.js +499 -202
  105. package/workspace/public/pm/premium-mtg-present.js +138 -0
  106. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  107. package/workspace/public/pm/premium-report-read.js +216 -52
  108. package/workspace/public/pm/premium-report-tab.js +44 -19
  109. package/workspace/public/pm/premium-shell.js +7 -7
  110. package/workspace/public/pm/premium-vw-cal.js +150 -60
  111. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  112. package/workspace/public/pm/premium-vw-notes.js +61 -0
  113. package/workspace/public/pm/rp-parts.js +269 -0
  114. package/workspace/public/premium-board.html +4 -3
  115. package/workspace/public/premium-insights.html +10 -10
  116. package/workspace/public/premium.html +3 -1
  117. package/workspace/r/m1.png +0 -0
  118. package/workspace/r/m2.png +0 -0
  119. package/workspace/r/m3.png +0 -0
  120. package/workspace/r/nl.png +0 -0
  121. package/workspace/test-lists/initiative-layout.json +9 -0
  122. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  123. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  124. package/workspace/test-lists/uf-everywhere.json +15 -0
  125. package/workspace/test-lists/uf-home.json +9 -0
  126. package/workspace/test-lists/uncovered-board.json +9 -0
@@ -1,31 +1,44 @@
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.
1
+ /* pm/premium-vw-mtg.js — a meeting in the Viewer (initiative premium-agreed-design, area viewer; redesigned by premium-uncovered-features, area
2
+ * meetings: MtReplay, MtFocus, MtMaterial, MtAfter, MtNotes and MtPhone.dc.html).
3
+ * Head the title, then one line: the day, the time, the length and who is in it. Beside it: the state (Starts in 30 min, Recording),
4
+ * the series "‹ 4 of 4 ›" (or "Not in a series"), what it is about (a dashed "What it is about" when it is not linked), Record
5
+ * before the meeting, and ⋯ (Copy as Markdown, New meeting, What Record and Focus do).
6
+ * Recording while it records, one line in the head: Recording · 12:04 with Highlight, Pause and Stop; "Recording paused at 12:04 · nothing
7
+ * is kept while paused" with Resume and Stop; and a warning when the sound stopped or the recording was off for a while.
8
+ * Tabs before the meeting none: the prep (Prepared for you, What it is for, What matters today, Agenda, Material, Previous meetings).
9
+ * While it records: Live notes | Focus | Transcript. After it: Notes | Replay | Transcript (Replay when it was recorded).
10
+ * Focus: Now · topic N of M with Change topic, what was said so far, the agenda with the minutes used, the material with
11
+ * Present (a deck: the presenter view, premium-mtg-present.js) and Add material.
12
+ * Replay: premium-mtg-replay.js. Notes: the summary, Since the last one, decisions, next steps (Make task, with "Task made ·
13
+ * added to <initiative>, under <stage>" and Undo; a work-item through the ticket button), facts, open questions, and the prep.
14
+ * Popovers Add material (suggested for this meeting, Find in PMOS, Paste a link, the topic and the series), What it is about (find an
15
+ * initiative, suggested from the notes, or the product, the whole portfolio, or leave it out), the series (take it out, put it back).
7
16
  *
8
17
  * WHERE EACH PART COMES FROM (nothing is invented; a part the answers do not hold is left out or says so):
9
18
  * GET /api/notes, /api/notes/one the note, its transcript, highlights, body, speakers, screen shots, its place in a series
10
19
  * 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)
20
+ * GET /api/meeting-replay the recording's length, stretches by topic, key points and shots (Replay)
21
+ * GET /api/meeting-points what the PM confirmed or marked not right in Replay
12
22
  * GET /api/calendar-views?view=week the calendar row: what it is about, people, the boards and initiatives to link to
13
23
  * GET /api/notes/series the meetings before this one
14
24
  * GET /api/viewer-meeting agenda minutes per topic, the audio source and Pause shots, the steps that became a ticket or a task
25
+ * GET /api/meeting-material/suggest Add material's suggestions and Find in PMOS
15
26
  * WRITES (each a press): Record, Pause, Resume, Stop and Highlight through the page's recorder (premium-meeting.js recCore); POST
16
27
  * /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).
28
+ * /api/calendar-links (About), /api/viewer-meeting/agenda|capture|work-item, /api/plan-items (Make task), /api/meeting-material (Add material,
29
+ * Remove), /api/meeting-focus/topic (Change topic), /api/meeting-points (Confirm, Not right).
18
30
  *
19
31
  * meetModel(D, now) → the view model (pure; for the unit suite)
20
32
  * meetHtml(model, ui) → the card's body (pure)
21
33
  * mdOf(model) → the note as Markdown, for Copy as Markdown (pure)
34
+ * aboutOptions(row | null, W | null, choices | null, notesText) → the What it is about choices (pure)
22
35
  * openMeeting(ref, { ws }) → opens the card. ref: a note id, { note }, { event, date }, a calendar week row or a brief-page today row. */
23
36
  import { open as vOpen, current as vCur } from './cozy-viewer.js';
24
- import { placeholderHtml } from './cozy-placeholder.js';
25
37
  import { pmGet, pmPost } from './http.js';
26
38
  import { noteSheet, aboutChoices, aboutBody, aboutNow } from './premium-vw-meet.js';
27
39
  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
40
  import { APPS, recall, remember } from './listen-sources.js';
41
+ import { replayView, replayHtml } from './premium-mtg-replay.js';
29
42
 
30
43
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
31
44
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
@@ -50,14 +63,9 @@ export function dayWord(iso, now = Date.now()) {
50
63
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many || one + 's');
51
64
  const CLOCK_ICON = 'M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18M12 7v5l3 2';
52
65
  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
66
  copy: ['Copy as Markdown', 'The notes, decisions and next steps'],
56
67
  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
68
  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
69
  };
62
70
  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
71
  export const EMPTY_NOTES = 'The summary, decisions and next steps are written when you stop recording.';
@@ -88,8 +96,32 @@ export function factsOf(n) {
88
96
  .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
97
  }
90
98
 
99
+ export const NO_NOTES = 'No notes for this meeting. It was not recorded, and nobody wrote any.';
100
+ export const PAUSED_LINE = 'nothing is kept while paused';
101
+ const peopleText = (ps) => (ps.length ? ps.slice(0, 3).join(', ') + (ps.length > 3 ? ' and ' + (ps.length - 3) + ' more' : '') : '');
102
+ const GAP_MS = 120000; // two minutes with no sound from the meeting while you speak: the warning line
103
+
104
+ /** Where the recording heard nothing: the stretches it was off between two starts (n.sessions), and, while it records, two minutes or more with
105
+ * no line from the meeting's sound while the microphone still has lines. → [{ kind: 'off' | 'quiet', from, to, text }] (from/to: wall clock HH:MM) */
106
+ export function gapsOf(n, now = Date.now()) {
107
+ if (!n || n.private) return [];
108
+ const out = [];
109
+ const ses = (Array.isArray(n.sessions) ? n.sessions : []).filter((x) => x && ok(x.from)).sort((a, b) => Date.parse(a.from) - Date.parse(b.from));
110
+ for (let i = 1; i < ses.length; i++) {
111
+ const off = Date.parse(ses[i - 1].to), on = Date.parse(ses[i].from);
112
+ if (Number.isFinite(off) && on > off + 30000) out.push({ kind: 'off', from: hm(ses[i - 1].to), to: hm(ses[i].from), min: Math.max(1, Math.round((on - off) / 60000)) });
113
+ }
114
+ if (n.state === 'recording' && ok(n.recorded_from)) {
115
+ const t0 = Date.parse(n.recorded_from), tr = (n.transcript || []).filter((x) => x && Number.isFinite(x.t) && !x.dropped);
116
+ const meet = tr.filter((x) => x.source === 'meeting'), mic = tr.filter((x) => x.source !== 'meeting');
117
+ const lastMeet = meet.length ? Math.max(...meet.map((x) => x.t)) : 0, lastMic = mic.length ? Math.max(...mic.map((x) => x.t)) : 0;
118
+ if (meet.length && lastMic - lastMeet >= GAP_MS) out.push({ kind: 'quiet', from: hm(new Date(t0 + lastMeet).toISOString()), to: hm(new Date(t0 + lastMic).toISOString()), min: Math.round((lastMic - lastMeet) / 60000) });
119
+ }
120
+ return out;
121
+ }
122
+
91
123
  /** 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 } */
124
+ * prev (prevOf), about, people, rec: { held, started }, elapsed (ms heard so far), frames (screen shots kept), canRecord, app, steps, points } */
93
125
  export function meetModel(D, now = Date.now()) {
94
126
  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
127
  const ev = (F && F.event) || {}, nm = n && n.meeting && n.meeting.kind === 'event' ? n.meeting : null;
@@ -101,31 +133,36 @@ export function meetModel(D, now = Date.now()) {
101
133
  const mk = st === 'recording' || st === 'paused' ? 'live' : done ? 'notes' : 'prep';
102
134
  const liveK = st === 'paused' ? 'paused' : st === 'recording' ? (D.rec && D.rec.held ? 'rec' : 'stale') : '';
103
135
  const el = Math.max(0, Number(D.elapsed) || 0);
104
- /* row 1 */
136
+ const over = hasTime(at) && ok(end) && now > Date.parse(end);
137
+ /* the state chip */
105
138
  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 };
139
+ if (mk === 'live') chip = liveK === 'rec' ? { text: 'Recording', tone: 'rec' } : liveK === 'paused' ? { text: 'Paused', tone: 'warn' } : { text: 'Not capturing', tone: 'warn' };
107
140
  else if (mk === 'notes') chip = { text: 'Done', tone: 'ok' };
108
141
  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
142
  else if (hasTime(at) && (!ok(end) || now < Date.parse(end))) chip = { text: 'On now', tone: 'rec' };
110
143
  else chip = { text: hasTime(at) ? 'Not recorded' : 'Not started', tone: '' };
111
144
  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;
145
+ const primary = mk === 'prep' && D.canRecord ? { k: 'record', label: 'Record' } : null;
114
146
  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 */
147
+ const seriesOff = !!(S && S.seriesOff);
148
+ const menu = (mk === 'notes' ? ['copy', 'fresh'] : ['fresh']).concat(['why']).map((k) => ({ k, label: MENU[k][0], sub: MENU[k][1] }));
149
+ /* the head's line: day · time · length · people */
150
+ const len = ok(at) && ok(end) ? Math.round((Date.parse(end) - Date.parse(at)) / 60000) : 0;
151
+ const heardMin = mk === 'notes' ? Math.round(((rep && rep.len) || (S && S.minutes * 60000) || 0) / 60000) : 0;
117
152
  const started = D.rec && D.rec.started ? new Date(D.rec.started).toISOString() : n && n.recorded_from ? n.recorded_from : at;
118
153
  const when = mk === 'live' ? 'Started ' + hm(started) + ' · ' + mmss(el) + ' so far'
119
154
  : [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 || '' }));
155
+ const sub = [mk === 'live' ? 'Live' : dayWord(at, now), hasTime(at) ? (mk === 'live' && hasTime(end) ? hm(at) + ' to ' + hm(end) : hm(at)) : '',
156
+ heardMin ? heardMin + ' min' : len > 0 && len < 1440 ? len + ' min' : '', peopleText(people)].filter(Boolean).join(' · ');
157
+ /* prep */
158
+ 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 || '', deck: m.kind === 'pmos-deck', slides: Number(m.slides) || 0 }));
122
159
  const brief = (F && F.brief) || null;
123
160
  const prev = D.prev || [];
124
161
  const carried = (S && S.carriedIn && S.carriedIn.items) || [];
125
162
  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
163
  const ready = [
127
164
  { 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 },
165
+ { label: 'People', text: people.length ? peopleText(people) : 'None listed', ok: people.length > 0 },
129
166
  { label: 'Material', text: mats.length ? mats.length + ' linked' : 'None linked', ok: mats.length > 0 },
130
167
  { label: 'Last time', text: last || 'No earlier notes', ok: !!last && !carried.length },
131
168
  ];
@@ -135,7 +172,7 @@ export function meetModel(D, now = Date.now()) {
135
172
  const purpose = (S && S.context && S.context.purpose) || (brief && brief.purpose) || ev.purpose || '';
136
173
  const prepText = (S && S.context && S.context.prep) || (brief && brief.prep) || '';
137
174
  /* live */
138
- const fv = F ? focusView(F) : null;
175
+ const fv = F ? focusView(F) : D.F && D.F.ok === false ? focusView(D.F) : null; // a refused read says why
139
176
  const topics = fv && fv.state === 'ok' ? fv.topics : [];
140
177
  const cur = topics.findIndex((t) => t.state === 'now');
141
178
  const cap = fv && fv.state === 'ok' ? fv.captured : { decisions: 0, actions: 0, questions: 0 };
@@ -144,6 +181,21 @@ export function meetModel(D, now = Date.now()) {
144
181
  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
182
  const capture = (D.vm && D.vm.capture) || { app: null, shots: 'on' };
146
183
  const app = APPS.find((a) => a.id === (capture.app || D.app)) || APPS[0];
184
+ const recLine = mk !== 'live' ? null : liveK === 'rec' ? { k: 'rec', text: 'Recording · ' + mmss(el) }
185
+ : liveK === 'paused' ? { k: 'paused', text: 'Recording paused at ' + mmss(el) + ' · ' + PAUSED_LINE }
186
+ : { k: 'stale', text: 'Recording, but not on this page · nothing is kept until you resume here' };
187
+ const gaps = gapsOf(n, now).map((g) => ({ ...g, text: g.kind === 'quiet' ? 'No sound from ' + app.label.replace(/ app$/, '') + ' for ' + plural(g.min, 'min', 'min') + ' (' + g.from + ' to ' + g.to + '). Is the meeting in another app?' : 'Earlier: the recording was off for ' + plural(g.min, 'min', 'min') + ' (' + g.from + ' to ' + g.to + '). That gap is marked in the notes.' }));
188
+ /* Focus: the topic now, the agenda with the minutes used of the minutes planned */
189
+ const plannedOf = (t, i) => { const a = ag.topics.find((x) => norm(x.text) === norm(t.text)) || ag.topics[i]; return a ? a.min : 0; };
190
+ const fAgenda = (topics.length ? topics : ag.topics.map((a) => ({ n: a.n, text: a.text, state: 'plan', minutes: 0 }))).map((t, i) => {
191
+ const plan = plannedOf(t, i), used = Math.round(t.minutes || 0);
192
+ const k = t.state === 'now' ? (plan && used >= plan * 0.9 ? 'late' : 'now') : t.state === 'done' ? 'done' : 'plan';
193
+ return { n: t.n || i + 1, text: t.text, k, used, plan, fill: plan ? Math.min(1, used / plan) : t.state === 'done' ? 1 : 0,
194
+ say: t.state === 'plan' ? (plan ? plan + ' min' : 'planned') : plan ? used + ' of ' + plan : used + ' min' };
195
+ });
196
+ const focus = { now: cur >= 0 ? topics[cur].text : '', nowLine: topics.length ? (cur >= 0 ? 'Now · topic ' + (cur + 1) + ' of ' + topics.length : plural(topics.length, 'topic') + ' planned') : 'No topics yet',
197
+ gist: fv && fv.state === 'ok' ? fv.gist : '', topics: topics.map((t) => ({ text: t.text, now: t.state === 'now' })), agenda: fAgenda,
198
+ agendaSub: ag.total ? ag.total + ' min' : '', material: mats, error: fv && fv.state !== 'ok' ? fv.reason : '' };
147
199
  /* after */
148
200
  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
201
  const steps = (S ? S.actions : []).map((a, i) => { const key = keys[norm(a.text)] || ''; const tk = links[key] || ''; const task = !!key && tasks.has(key);
@@ -151,27 +203,30 @@ export function meetModel(D, now = Date.now()) {
151
203
  const since = S && S.since ? { sub: S.since.day.replace(/^\w+ /, '') + ' · ' + plural(S.since.items.length, 'step') + ' then, ' + S.since.fresh.length + ' new',
152
204
  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
205
  .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;
206
+ const replay = rep ? replayView(rep, { n, points: D.points || {}, now }) : null;
207
+ const trk = rep ? { len: rep.len } : null;
156
208
  const decided = S ? S.decisions.length : 0, nsteps = steps.length, nq = S ? S.questions.length : 0;
209
+ const tabs = mk === 'live' ? [['notes', 'Live notes'], ['focus', 'Focus'], ['tr', 'Transcript']]
210
+ : mk === 'notes' ? [['notes', 'Notes']].concat(replay ? [['replay', 'Replay']] : [], [['tr', 'Transcript']]) : [];
157
211
  const parts = [
158
212
  { 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 : '' },
213
+ { 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, heardMin || Math.round(el / 60000)) + ' min · ' + plural(lines.length, 'line') : 'Starts when you record', empty: mk === 'prep' ? EMPTY_LIVE : '' },
160
214
  { 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
215
  ];
162
216
  const kind = mk === 'live' ? 'Meeting · recording' : mk === 'notes' ? 'Meeting notes' : 'Meeting prep';
163
217
  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
218
  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,
219
+ mk, liveK, title, kind, head, noteId: n ? n.id : '', private: !!(n && n.private), at, end, sub, tabs, noNotes: mk === 'prep' && over && !n,
220
+ chip, people, primary, menu, when, about: D.about || '', series, seriesOff, parts, recLine, gaps,
167
221
  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
222
  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
223
  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',
224
+ live: { state: recLine ? recLine.text : '', app: app.label, appId: app.id, shots: Number(D.frames) || 0, shotsPaused: capture.shots === 'paused',
171
225
  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
226
  nowSub: topics.length ? (cur >= 0 ? 'topic ' + (cur + 1) + ' of ' + topics.length : plural(topics.length, 'topic') + ' planned') : '',
173
227
  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') : '',
228
+ focus,
229
+ notes: { summary: S ? S.overview : '', track: trk, replay, 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
230
  facts: factsOf(n), questions: S ? S.questions : [], lines, trTitle: 'Transcript · ' + plural(lines.length, 'line') + ' · press a speaker to name them' },
176
231
  };
177
232
  }
@@ -187,101 +242,192 @@ export function mdOf(m) {
187
242
  return out.join('\n').replace(/\n{3,}/g, '\n\n');
188
243
  }
189
244
 
245
+ /** What it is about (MtAfter): the choices for a calendar meeting (row + its week W) or a note (aboutChoices of the boards), with the
246
+ * initiatives whose name the notes mention suggested first. → { suggested, initiatives, boards, portfolio, none, cur } each { v, label, sub } */
247
+ export function aboutOptions(row, W, choices, text = '', cur = '') {
248
+ const said = ' ' + norm(text).replace(/[^a-z0-9 ]+/g, ' ') + ' ';
249
+ const hit = (name) => { const ws = norm(name).replace(/[^a-z0-9 ]+/g, ' ').split(' ').filter((w) => w.length > 3); const got = ws.filter((w) => said.includes(' ' + w)); return ws.length && got.length ? '“' + got.slice(0, 2).join(' ') + '” matches' : ''; };
250
+ let inis = [], boards = [], portfolio = 'p', none = 'none';
251
+ if (row) {
252
+ inis = ((W && W.initiatives) || []).map((i) => ({ v: 'initiative|' + i.id, label: clip(i.name || i.id, 70), sub: clip(i.stage || i.board || '', 40) }));
253
+ boards = ((W && W.boards) || []).map((b) => ({ v: 'board|' + b.ws + '|' + b.id, label: clip(b.name || b.id, 60) + ' · product' }));
254
+ portfolio = 'portfolio';
255
+ } else {
256
+ for (const c of choices || []) {
257
+ if (c.v[0] === 'i') inis.push({ v: c.v, label: c.label.replace(/^Initiative: /, ''), sub: c.body && c.body.board ? clip(c.body.board.title, 40) : '' });
258
+ else if (c.v[0] === 'b') boards.push({ v: c.v, label: c.label.replace(/^Board: /, '') + ' · product' });
259
+ }
260
+ }
261
+ const suggested = text ? inis.map((i) => ({ ...i, sub: [i.sub, hit(i.label)].filter(Boolean).join(' · '), m: hit(i.label) })).filter((i) => i.m).slice(0, 3) : [];
262
+ return { suggested, initiatives: inis, boards, portfolio: { v: portfolio, label: 'The whole portfolio' }, none: { v: none, label: 'Leave it out of an initiative' }, cur };
263
+ }
264
+
190
265
  /* ── 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"/>' };
266
+ const SV = { 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"/>',
267
+ 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"/>', flag: '<path d="M5 21V4h11l-2 4 2 4H5"/>',
268
+ ser: '<path d="M4 6h16M4 12h16M4 18h10"/>', plus: '<path d="M12 5v14M5 12h14"/>', x: '<path d="M6 6l12 12M18 6L6 18"/>', find: '<path d="M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14M20 20l-4-4"/>',
269
+ pause: '<path d="M8 5v14M16 5v14"/>', stop: '<path d="M7 7h10v10H7z"/>', play: '<path d="M8 5v14l11-7z"/>', check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
270
+ doc: '<path d="M7 3h7l5 5v13H7zM14 3v5h5"/>', deck: '<path d="M4 5h16v11H4zM12 16v4M8 20h8"/>', board: '<path d="M4 4h4v16H4zM10 4h4v10h-4zM16 4h4v13h-4z"/>',
271
+ prod: '<path d="M5 20V11M12 20V5M19 20v-6"/>', ticket: '<path d="M4 7h16v4a2 2 0 0 0 0 4v4H4v-4a2 2 0 0 0 0-4z"/>', warn: '<path d="M12 4l9 16H3zM12 10v4M12 17v.01"/>', rec: '<circle cx="12" cy="12" r="6"/>' };
193
272
  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) {
273
+ const dots = '<svg aria-hidden="true" width="16" height="16" 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>';
274
+ /* bars split by weight (live topics): an SVG, so each length is an attribute and not an inline style */
275
+ function weightBar(cls, parts) {
197
276
  const tot = parts.reduce((a, x) => a + x.w, 0) || 1, gap = 1.2, room = 100 - gap * Math.max(0, parts.length - 1);
198
277
  let x = 0;
199
278
  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>`;
279
+ return `<svg class="${cls}" aria-hidden="true" width="100%" height="100%">${rects}</svg>`;
201
280
  }
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) => {
281
+ const fillBar = (f, k) => `<svg class="vzm-fb" aria-hidden="true" width="100%" height="8"><rect width="100%" height="8" rx="4" class="bg"/>${f > 0 ? `<rect width="${(Math.min(1, f) * 100).toFixed(1)}%" height="8" rx="4" class="fg" data-k="${k}"/>` : ''}</svg>`;
282
+ const lineHtml = (l, i, ui, seek) => {
205
283
  const naming = ui.naming === i;
206
284
  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
285
  : `<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>`;
286
+ const t = seek && Number.isFinite(l.t) ? `<button type="button" class="vzm-t vz-hv" data-a="trseek" data-t="${l.t}" aria-label="Play from ${esc(mmss(l.t))}">${esc(mmss(l.t))}</button>` : `<time>${esc(mmss(l.t))}</time>`;
287
+ return `<div class="vz-line">${t}<span>${who} ${esc(l.text)}</span></div>`;
209
288
  };
289
+ const matIcon = (m) => svg(m.deck ? 'deck' : 'doc', 16);
210
290
 
211
- function prepHtml(P) {
291
+ function prepHtml(P, m) {
212
292
  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>`);
293
+ if (m.noNotes) h.push(`<div class="vzm-box vzm-mut">${esc(NO_NOTES)} <button type="button" class="vzm-btn vzm-card" data-a="m-fresh">New note</button></div>`);
294
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Prepared for you <small>${esc(P.readyText)}</small></p>${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>`);
295
+ if (P.purpose) h.push(`<div><p class="vzm-lbl">What it is for</p><p class="vz-p">${esc(P.purpose)}</p></div>`);
296
+ if (P.gist) h.push(`<div><p class="vzm-lbl">In short</p><p class="vz-p">${esc(P.gist)}</p></div>`);
297
+ if (P.matters.length) h.push(`<div class="vz-col"><p class="vzm-lbl">What matters today</p>${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>`);
298
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Agenda <small>${esc(P.agendaSub)}</small></p>${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>`);
299
+ if (P.toBeReady) h.push(`<div><p class="vzm-lbl">To be ready</p><p class="vz-p">${esc(P.toBeReady)}</p></div>`);
300
+ h.push(materialHtml(P.material, m, false));
301
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Previous meetings <small>${P.prev.length ? P.prev.length + ' before this' : 'none kept'}</small></p>${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
302
  return `<div class="vz-col14">${h.join('')}</div>`;
222
303
  }
223
- function liveHtml(m, ui) {
304
+ /** Material (MtFocus, MtMaterial): each row with Present (a deck) or Open, and Remove; then Add material and its popover. */
305
+ function materialHtml(mats, m, focus) {
306
+ const rows = mats.map((x, i) => `<div class="vzm-trow"><span class="vzm-mi" aria-hidden="true">${matIcon(x)}</span><span class="vzm-mt"><b>${esc(x.title)}</b> <span class="vzm-mut">· ${esc(x.deck && x.slides ? plural(x.slides, 'slide') : x.sub)}</span></span>`
307
+ + (x.deck ? `<button type="button" class="vzm-btn vzm-soft" data-a="present" data-i="${i}">Present</button>${focus ? '<span class="vzm-mut vzm-sm">opens the presenter view</span>' : ''}` : `<button type="button" class="vzm-btn vzm-soft" data-a="mat" data-i="${i}">Open</button>`)
308
+ + `<button type="button" class="vzm-ib vz-hv" data-a="matrm" data-i="${i}" aria-label="${esc('Remove ' + x.title)}">${svg('x', 14)}</button></div>`).join('');
309
+ return `<div class="vz-col"><p class="vzm-lbl">Material${mats.length ? '' : ' <small>none linked</small>'}</p>${rows}<button type="button" class="vzm-btn vzm-ghost" data-a="addmat" aria-expanded="${m.ui && m.ui.pop === 'mat'}">${svg('plus', 14)}Add material</button><div class="vzm-anc" data-pop="mat"></div></div>`;
310
+ }
311
+ function liveNotesHtml(m, ui) {
224
312
  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>`);
313
+ 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>`);
314
+ if (ui.src) h.push(appsHtml(L));
315
+ h.push(`<label class="vz-priv"><input type="checkbox" data-a="priv"${m.private ? ' checked disabled' : ''}>${esc(PRIVATE_TEXT)}</label>`);
316
+ 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>`);
317
+ if (L.topics.length) h.push(`<div class="vz-col"><p class="vzm-lbl">Now on <small>${esc(L.nowSub)}</small></p>${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>`);
318
+ h.push(`<p class="vz-caught"><b>Caught so far:</b> ${esc(L.caught)}</p>`);
319
+ h.push(mineHtml(m, L));
320
+ const off = L.total - L.lines.length;
321
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Said last <small>${plural(L.total, 'line')} · all of them in Transcript</small></p>${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
322
  return `<div class="vz-col14">${h.join('')}</div>`;
242
323
  }
324
+ const appsHtml = (L) => `<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>`;
325
+ function mineHtml(m, L) {
326
+ return `<div class="vz-col"><p class="vzm-lbl">Your notes</p><textarea class="vz-mine" data-a="mine" aria-label="Your notes" placeholder="${esc(MINE_HINT)}">${esc(L.mine)}</textarea></div>`
327
+ + `<div class="vz-col"><p class="vzm-lbl">Highlights <small>${L.hl.length} kept</small></p>${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>`;
328
+ }
329
+ function focusHtml(m, ui) {
330
+ const Fo = m.focus, h = [];
331
+ h.push(`<div class="vzm-now"><div class="vzm-r"><p class="vzm-lbl vzm-grow">${esc(Fo.nowLine)}</p>${Fo.topics.length ? `<button type="button" class="vzm-btn" data-a="topic" aria-expanded="${ui.pop === 'topic'}">Change topic</button>` : ''}</div>`
332
+ + (ui.pop === 'topic' ? `<div class="vzm-topics" role="group" aria-label="Make it the topic">${Fo.topics.map((t, i) => `<button type="button" class="vzm-chip${t.now ? ' on' : ''}" data-a="topicgo" data-i="${i}"${t.now ? ' aria-current="true"' : ''}>${esc(t.text)}</button>`).join('')}</div>` : '')
333
+ + `<p class="vzm-h1">${esc(Fo.now || (Fo.error ? 'Focus could not read this meeting' : 'No topic is current yet'))}</p><p class="vzm-sm">${esc(Fo.error ? Fo.error : Fo.gist ? 'So far: ' + Fo.gist : 'What was said on the topic shows here while the note records.')}</p></div>`);
334
+ h.push(`<div><p class="vzm-lbl">Agenda${Fo.agendaSub ? ' · ' + esc(Fo.agendaSub) : ''}</p>${Fo.agenda.length ? Fo.agenda.map((a) => `<div class="vzm-ag" data-k="${a.k}"><span>${a.k === 'now' || a.k === 'late' ? `<b>${a.n} ${esc(a.text)}</b>` : esc(a.n + ' ' + a.text)}</span>${fillBar(a.fill, a.k)}<small>${esc(a.say)}</small></div>`).join('') : '<p class="vz-empty">The invite lists no topics yet.</p>'}</div>`);
335
+ h.push(materialHtml(Fo.material, m, true));
336
+ return `<div class="vz-col14">${h.join('')}</div>`;
337
+ }
338
+ function stepHtml(a, ui) {
339
+ const made = ui.made && ui.made[a.i];
340
+ const act = a.made ? `<span class="vzm-pill" data-k="${a.ticket ? 'you' : ''}">${esc(a.ticket ? a.made : 'Task')}</span>`
341
+ : `<button type="button" class="vzm-btn vzm-soft" data-a="maketask" data-i="${a.i}">Make task</button><button type="button" class="vzm-ib vz-hv" data-a="makewi" data-i="${a.i}" aria-label="Make it a work-item" title="A ticket Drafted in PMOS, shown on the Board. It goes to Jira only through the Commit gate.">${svg('ticket', 15)}</button>`;
342
+ return `<div class="vzm-step"><span class="vzm-grow">${esc(a.text)}</span><span class="vzm-mut vzm-sm">${esc(a.meta.replace('No owner · No date', 'No owner, no date'))}</span>${act}</div>`
343
+ + (made ? `<div class="vzm-made" role="status">${svg('check', 14)}<span>${made.html}</span>${made.undo ? `<button type="button" class="vzm-btn vzm-ghost" data-a="madeundo" data-i="${a.i}">Undo</button>` : ''}</div>` : '');
344
+ }
243
345
  function notesHtml(m, ui) {
244
346
  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
347
  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
- }
348
+ if (N.since) h.push(`<div class="vz-col"><p class="vzm-lbl">Since the last one <small>${esc(N.since.sub)}</small></p>${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>`);
349
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Decisions</p>${N.decisions.length ? N.decisions.map((d) => `<div class="vzm-trow vzm-top"><span class="vzm-grow">${esc(d.text)}</span>${d.why ? `<span class="vzm-mut vzm-sm vzm-why">${esc(d.why)}</span>` : ''}</div>`).join('') : '<p class="vz-empty">No decisions were caught.</p>'}</div>`);
350
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Next steps <small>${esc(N.stepsSub)}</small></p>${N.steps.length ? N.steps.map((a) => stepHtml(a, ui)).join('') : '<p class="vz-empty">No next steps were caught.</p>'}</div>`);
351
+ if (N.facts.length) h.push(`<div class="vz-col"><p class="vzm-lbl">Facts mentioned <small>checked against the repository</small></p>${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>`);
352
+ h.push(`<div class="vz-col"><p class="vzm-lbl">Open questions</p>${N.questions.length ? N.questions.map((q) => `<div class="vzm-trow"><span class="vzm-grow">${esc(q.text)}</span></div>`).join('') : '<p class="vz-empty">No question was left open.</p>'}</div>`);
353
+ h.push(`<button type="button" class="vzm-fold vz-hv" data-a="prepfold" aria-expanded="${!!ui.prepOpen}">${svg('next', 14)}<b>Prep and material</b><span class="vzm-mut">${esc(m.parts[0].sub)}</span></button>`);
354
+ if (ui.prepOpen) h.push(prepHtml(m.prep, m));
261
355
  return `<div class="vz-col vz-g16">${h.join('')}</div>`;
262
356
  }
263
- /** The card's body. ui = { open: { part: bool }, more, ppl, why, ask, src, tr, naming, pos, playing, stepMenu, msg, about (html), sheet (html) } */
357
+ function transcriptHtml(m, ui) {
358
+ const L = m.mk === 'live' ? m.live : null, lines = m.notes.lines, h = [];
359
+ if (m.mk === 'notes') h.push(mineHtml(m, m.live));
360
+ h.push(`<div class="vz-col"><p class="vzm-lbl">${esc(m.notes.trTitle)}</p>${lines.length ? lines.map((l, i) => lineHtml(l, i, ui, m.mk === 'notes' && !!m.notes.replay)).join('') : `<p class="vz-empty">${m.private ? 'This note is private: only what you type is kept.' : L ? 'Nothing has been said yet.' : 'Nothing was transcribed.'}</p>`}<p class="vz-note vz-fine">${esc(LIVE_FOOT)}</p></div>`);
361
+ return `<div class="vz-col14">${h.join('')}</div>`;
362
+ }
363
+ function recHtml(m, ui) {
364
+ const R = m.recLine; if (!R) return '';
365
+ const h = [];
366
+ const lead = R.k === 'rec' ? '<span class="vzm-dot" aria-hidden="true"></span>' : svg(R.k === 'paused' ? 'pause' : 'warn', 16, ' class="vzm-ink3"');
367
+ const acts = R.k === 'rec' ? `<button type="button" class="vzm-btn vzm-card" data-a="hl" title="Keep the last 30 seconds and the next ones">Highlight</button><button type="button" class="vzm-btn vzm-card" data-a="pause" title="Pause listening; resume within an hour">Pause</button>`
368
+ : `<button type="button" class="vzm-btn vzm-dark" data-a="resume">Resume</button>`;
369
+ h.push(`<div class="vzm-box vzm-rec" role="group" aria-label="Recording" data-k="${R.k}">${lead}<b class="vzm-grow vzm-sm" data-clk="state">${esc(R.text)}</b>${acts}<button type="button" class="vzm-ib vz-hv" data-a="stop" aria-label="Stop the recording" title="Stop and write the notes">${svg('stop', 12, ' class="vzm-fill"')}</button></div>`);
370
+ 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>`);
371
+ for (const g of m.gaps) h.push(`<div class="vzm-warn vzm-sm"><span class="vzm-grow">${g.kind === 'off' ? '<b>Earlier:</b> ' + esc(g.text.replace(/^Earlier: /, '')) : esc(g.text)}</span>${g.kind === 'quiet' ? '<button type="button" class="vzm-btn vzm-card" data-a="src">Listen to another app</button>' : ''}</div>`);
372
+ if (ui.src && m.gaps.some((g) => g.kind === 'quiet')) h.push(appsHtml(m.live));
373
+ return h.join('');
374
+ }
375
+ /** The card's body. ui = { tab, pop, more, why, ask, src, naming, pos, playing, speed, filter, sel, leftOpen, made, prepOpen, msg, popHtml } */
264
376
  export function meetHtml(m, ui = {}) {
265
- if (ui.sheet) return `<div class="vz">${ui.sheet}</div>`;
266
377
  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>');
378
+ m.ui = ui;
379
+ const ser = m.series ? `<span class="vzm-ser"><button type="button" class="vzm-sb 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', 14)}</button><button type="button" class="vzm-sb vzm-sn vz-hv" data-a="sermenu" aria-expanded="${ui.pop === 'ser'}" title="${esc(m.series.title)}">${esc(m.series.pos + ' of ' + m.series.count)}</button><button type="button" class="vzm-sb 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', 14)}</button></span>`
380
+ : m.seriesOff ? `<button type="button" class="vzm-chip" data-a="sermenu" aria-expanded="${ui.pop === 'ser'}">${svg('ser', 14)}Not in a series</button>` : '';
381
+ const about = m.about ? `<button type="button" class="vzm-chip on" data-a="m-about" aria-expanded="${ui.pop === 'about'}" title="What it is about. Change">${svg('flag', 14)}${esc(m.about)}</button>`
382
+ : `<button type="button" class="vzm-chip vzm-dash" data-a="m-about" aria-expanded="${ui.pop === 'about'}">${svg('link', 14)}What it is about</button>`;
383
+ const state = m.mk === 'notes' ? '' : `<span class="vzm-chip vzm-state" data-tone="${c.tone}">${c.tone === 'rec' ? '<span class="vzm-dot" aria-hidden="true"></span>' : ''}${esc(c.text)}</span>`;
384
+ const pri = m.primary ? `<button type="button" class="vzm-btn vzm-dark" data-a="record" title="${esc(RECORD_LINE)}"><span class="vzm-dot" aria-hidden="true"></span>Record</button>` : '';
385
+ h.push(`<div class="vzm-hd"><div class="vzm-ht"><h2 class="vzm-h2">${esc(m.title)}</h2><p class="vzm-sub" data-clk="when">${esc(m.sub)}</p></div><div class="vzm-hc">${state}${ser}${about}${pri}<button type="button" class="vzm-ib vz-hv" data-a="more" aria-label="More for this meeting" aria-expanded="${!!ui.more}">${dots}</button></div></div>`);
386
+ h.push('<div class="vzm-anc" data-pop="head"></div>');
387
+ if (ui.more) h.push(`<div class="vz-menu vzm-menu" role="menu">${m.menu.map((x) => `<button type="button" role="menuitem" class="vz-hv" data-a="m-${x.k}"><b>${esc(x.label)}</b><small>${esc(x.sub)}</small></button>`).join('')}</div>`);
388
+ if (m.seriesOff) h.push(`<div class="vzm-box vzm-sm"><span class="vzm-grow">Taken out of the series “${esc(m.title)}”. Its notes no longer compare with the others.</span><button type="button" class="vzm-btn vzm-card" data-a="m-serback">Put it back</button></div>`);
389
+ h.push(recHtml(m, ui));
275
390
  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
391
  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
392
  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>`;
393
+ const tab = m.tabs.some(([k]) => k === ui.tab) ? ui.tab : m.tabs.length ? m.tabs[0][0] : '';
394
+ if (m.tabs.length) h.push(`<div class="vzm-tabs" role="tablist" aria-label="${esc(m.title)}">${m.tabs.map(([k, l]) => `<button type="button" role="tab" class="vzm-tab" data-a="tab" data-k="${k}" aria-selected="${k === tab}">${l}</button>`).join('')}</div>`);
395
+ const PANE = { focus: () => focusHtml(m, ui), replay: () => replayHtml(m.notes.replay, ui), tr: () => transcriptHtml(m, ui) };
396
+ const body = !tab ? prepHtml(m.prep, m) : PANE[tab] ? PANE[tab]() : m.mk === 'live' ? liveNotesHtml(m, ui) : notesHtml(m, ui);
397
+ h.push(`<div class="vzm-pane" role="${tab ? 'tabpanel' : 'region'}" data-tab="${tab || 'prep'}">${body}</div>`);
398
+ return `<div class="vz vz-mtg" data-mk="${m.mk}" data-tab="${tab || 'prep'}">${h.join('')}</div>`;
399
+ }
400
+
401
+ /** Add material's popover (MtMaterial). P = { row, sug, found, q, topics, series, err, busy } */
402
+ export function matPopHtml(P) {
403
+ if (!P.row) return `<div class="vzm-pop" role="dialog" aria-label="Add material"><p class="vzm-h3">Add material</p><p class="vzm-sm vzm-mut">Material is kept per calendar meeting. This note has no calendar event.</p></div>`;
404
+ return `<div class="vzm-pop" role="dialog" aria-label="Add material"><div class="vzm-r"><p class="vzm-h3 vzm-grow">Add material</p><button type="button" class="vzm-ib vz-hv" data-a="popx" aria-label="Close">${svg('x', 14)}</button></div>`
405
+ + `<div data-pl="list">${matListHtml(P)}</div>`
406
+ + `<div class="vzm-in">${svg('find', 16)}<input data-a="matq" type="search" placeholder="Find in PMOS" aria-label="Find in PMOS" value="${esc(P.q || '')}"></div>`
407
+ + `<div class="vzm-in">${svg('link', 16)}<input data-a="matlink" type="url" placeholder="Paste a link" aria-label="Paste a link"></div>`
408
+ + `<div class="vzm-r vzm-sm">${P.topics && P.topics.length ? `<select class="vz-in" data-a="mattopic" aria-label="Topic"><option value="">For the whole meeting</option>${P.topics.map((t) => `<option value="${esc(t)}">For ${esc(clip(t, 60))}</option>`).join('')}</select>` : ''}<label class="vz-priv"><input type="checkbox" data-a="matser">For every meeting in the series</label></div>`
409
+ + '<p class="vzm-sm vzm-mut">The invite in your calendar is not changed.</p>'
410
+ + `<p class="vz-msg" data-tone="bad" role="alert" data-pl="err"${P.err ? '' : ' hidden'}>${esc(P.err || '')}</p></div>`;
411
+ }
412
+ export function matListHtml(P) {
413
+ const items = P.q ? P.found : P.sug;
414
+ if (!items) return `<p class="vzm-mlbl">${P.q ? 'Looking in PMOS' : 'Suggested for this meeting'}</p><p class="vz-empty">Looking in PMOS.</p>`;
415
+ return `<p class="vzm-mlbl">${P.q ? 'Found in PMOS' : 'Suggested for this meeting'}</p>` + (items.length ? items.map((it, i) => `<button type="button" class="vzm-mi2 vz-hv" data-a="matadd" data-i="${i}">${svg(it.kind === 'pmos-deck' ? 'deck' : it.kind === 'board' ? 'board' : 'doc', 16)}<span class="vzm-grow">${esc(clip(it.title, 80))}${it.meta ? `<br><span class="vzm-sm vzm-mut">${esc(clip(it.meta, 80))}</span>` : ''}</span><span class="vzm-k">${svg('plus', 16)}</span></button>`).join('')
416
+ : `<p class="vz-empty">${P.q ? 'Nothing in PMOS matches. Paste a link instead.' : 'Nothing to suggest yet. Find it in PMOS or paste a link.'}</p>`);
417
+ }
418
+ /** What it is about's popover (MtAfter). O = aboutOptions(), q = the find text */
419
+ export function aboutPopHtml(O, q = '', note = '') {
420
+ return `<div class="vzm-pop" role="dialog" aria-label="What it is about"><div class="vzm-in">${svg('find', 16)}<input data-a="aboutq" type="search" placeholder="Find an initiative" aria-label="Find an initiative" value="${esc(q)}"></div><div data-pl="list">${aboutListHtml(O, q)}</div><p class="vzm-sm vzm-mut">${esc(note)}</p></div>`;
421
+ }
422
+ export function aboutListHtml(O, q = '') {
423
+ const words = norm(q).split(' ').filter(Boolean), hit = (x) => words.every((w) => norm(x.label).includes(w));
424
+ const item = (x, ic, hl) => `<button type="button" class="vzm-mi2 vz-hv${hl ? ' hl' : ''}" data-a="aboutpick" data-v="${esc(x.v)}"${x.v === O.cur ? ' aria-current="true"' : ''}>${svg(ic, 16)}<span class="vzm-grow">${esc(x.label)}${x.sub ? `<br><span class="vzm-sm vzm-mut">${esc(x.sub)}</span>` : ''}</span>${x.v === O.cur ? svg('check', 14) : ''}</button>`;
425
+ const h = [];
426
+ if (words.length) { const f = O.initiatives.filter(hit).slice(0, 8); h.push(`<p class="vzm-mlbl">Initiatives</p>${f.length ? f.map((x) => item(x, 'flag')).join('') : '<p class="vz-empty">No initiative has that name.</p>'}`); }
427
+ else if (O.suggested.length) h.push(`<p class="vzm-mlbl">Suggested from the notes</p>${O.suggested.map((x) => item(x, 'flag', true)).join('')}`);
428
+ else if (O.initiatives.length) h.push(`<p class="vzm-mlbl">Initiatives</p>${O.initiatives.slice(0, 5).map((x) => item(x, 'flag')).join('')}`);
429
+ h.push(`<p class="vzm-mlbl">Or</p>${O.boards.filter((x) => !words.length || hit(x)).map((x) => item(x, 'prod')).join('')}${item(O.portfolio, 'board')}${item(O.none, 'x')}`);
430
+ return h.join('');
285
431
  }
286
432
 
287
433
  /* ── the page half ── */
@@ -289,6 +435,11 @@ let MT = null; // the meeting shown
289
435
  let WEEKS = new Map(); // date → weekView, read once per open
290
436
  const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
291
437
  const toast = (t) => { try { if (typeof window !== 'undefined' && window.pmToast) window.pmToast(t); } catch { /* none */ } };
438
+ /** This module's sheet (the redesign's parts), added to the page once. */
439
+ const CSS = '/pm/cozy-vw-mtg.css';
440
+ export function mtgStyle() { if (typeof document === 'undefined' || document.querySelector(`link[href="${CSS}"]`)) return; const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.append(l); }
441
+ /** The Viewer is wider for a meeting (MtReplay: 780px) while it shows one; the page's own rule sizes it otherwise. */
442
+ export function widen(k) { const v = typeof document !== 'undefined' && document.getElementById('czViewer'); if (v) { if (k) v.dataset.vzw = k; else delete v.dataset.vzw; } }
292
443
  /** The recorder of the page: the one Home mounted (premium-meeting.js mountMeeting), else one made here. */
293
444
  const rec = () => recCore({ pmGet, pmPost, ws: () => (MT && MT.ws) || new URLSearchParams(location.search).get('ws') });
294
445
  async function weekOf(date, ws) {
@@ -314,21 +465,24 @@ export function refOf(ref) {
314
465
  }
315
466
 
316
467
  export async function openMeeting(ref, o = {}) {
468
+ mtgStyle();
317
469
  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 };
470
+ const me = { R, ws: o.ws || new URLSearchParams(location.search).get('ws') || '', ui: { tab: o.tab || '', sel: new Set(), made: {} }, D: null, n: null, row: null, alive: true, timers: [], play: null };
319
471
  if (MT) { MT.alive = false; MT.timers.forEach(clearInterval); stopPlay(MT); }
320
472
  MT = me;
321
473
  const id = 'meeting:' + (R.note || R.event || R.title || 'new');
322
474
  const draw0 = (body) => { body.innerHTML = '<div class="vz"><p class="vz-empty" role="status">Reading the meeting.</p></div>'; };
323
475
  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; } } });
476
+ vOpen({ id, kind: 'Meeting', title: R.title || 'Meeting', icon: CLOCK_ICON, url: meetingUrl({ ...R, ws: me.ws }), render: draw0, onClose: () => closed(me) });
477
+ widen('mtg');
325
478
  await load(me);
326
479
  if (MT !== me) return;
327
- if (o.about) await aboutPicker(me);
480
+ if (o.about) await openAbout(me);
328
481
  me.timers.push(setInterval(() => tick(me), 1000));
329
482
  me.timers.push(setInterval(() => { if (me.model && me.model.mk === 'live') load(me, true); }, 4000));
330
483
  me.timers.push(setInterval(() => { if (me.model && me.model.mk !== 'live') load(me, true); }, 30000));
331
484
  }
485
+ function closed(me) { if (MT === me && !me.reopen) { me.alive = false; me.timers.forEach(clearInterval); stopPlay(me); MT = null; widen(''); } }
332
486
 
333
487
  /** Read everything the card shows, then draw it. */
334
488
  async function load(me, quiet) {
@@ -355,11 +509,13 @@ async function load(me, quiet) {
355
509
  const date = row ? row.day : n && n.meeting && ok(n.meeting.start) ? dayKey(Date.parse(n.meeting.start)) : me.R.date || '';
356
510
  const evId = row ? row.id : n && n.meeting && n.meeting.event_id ? n.meeting.event_id : me.R.event || '';
357
511
  const fq = evId ? { event: evId, date } : n ? { note: n.id } : null;
512
+ me.fq = fq;
358
513
  const done = n && (n.state === 'ended' || (S && S.from === 'final'));
359
- const [F, rp, ser] = await Promise.all([
514
+ const [F, rp, ser, pts] = await Promise.all([
360
515
  fq ? pmGet('/api/meeting-focus?' + q(fq)) : null,
361
516
  n && done && !n.private ? pmGet('/api/meeting-replay?' + q({ note: n.id })) : null,
362
517
  !quiet && S && S.series && S.series.key ? pmGet('/api/notes/series?key=' + encodeURIComponent(S.series.key)) : null,
518
+ n && done && !n.private ? pmGet('/api/meeting-points?' + q({ note: n.id })) : null,
363
519
  ]);
364
520
  if (MT !== me) return;
365
521
  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);
@@ -376,10 +532,12 @@ async function load(me, quiet) {
376
532
  const about = level ? (level.kind === 'portfolio' ? 'Portfolio' : clip(level.name || level.id, 60)) : S && S.about ? S.about : '';
377
533
  const held = !!(window.__premiumHolding && n && window.__premiumHolding.id === n.id);
378
534
  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,
535
+ const rep = rp && rp.ok ? replayModel(rp) : null;
536
+ if (rep) rep.raw = rp.keys || [];
537
+ me.D = { row, n, S, F: F && F.ok ? F : F && F.ok === false ? { ok: false, error: F.error } : null, rep, vm: vm && vm.ok ? vm : null, prev: me.prev || [], about, level,
380
538
  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
539
  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 };
540
+ canRecord: row ? recordable(row) : !!(n && (n.state === 'idle' || !n.state)), app: recall(safeStorage()).app, steps, points: pts && pts.ok ? pts.points || {} : (me.D && me.D.points) || {} };
383
541
  draw(me);
384
542
  }
385
543
  async function keyOf(text) {
@@ -397,11 +555,11 @@ function draw(me) {
397
555
  const body = vCur() && vCur().id === me.vid ? document.querySelector('#czViewer .cz-vw-body') : null;
398
556
  const m = me.model = meetModel({ ...me.D, elapsed: elapsedOf(me) });
399
557
  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
558
  if (!body || me.kind !== m.kind || me.head !== m.head) { // the header names the state: open again when it changed
402
559
  me.kind = m.kind; me.head = m.head; me.reopen = true;
403
560
  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; } } });
561
+ 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: () => closed(me) });
562
+ widen('mtg');
405
563
  me.reopen = false;
406
564
  return;
407
565
  }
@@ -412,46 +570,66 @@ function paint(me, body) {
412
570
  const top = body.scrollTop;
413
571
  body.innerHTML = meetHtml(me.model, me.ui);
414
572
  body.scrollTop = top;
415
- if (!body.dataset.vzWired) { body.dataset.vzWired = '1'; }
573
+ placePop(me, body);
574
+ body.querySelectorAll('.vzp-top[data-w]').forEach((b) => b.style.setProperty('flex-grow', b.dataset.w)); // the topic names under the strip, as wide as their stretch
416
575
  body.onclick = (e) => press(me, e);
417
576
  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); } };
577
+ body.oninput = (e) => input(me, e);
578
+ body.onkeydown = (e) => keydown(me, e, body);
579
+ }
580
+ /** The open popover goes in its anchor, drawn once per paint (its list is redrawn on its own while the PM types). */
581
+ function placePop(me, body) {
582
+ const P = me.ui.pop; if (P !== 'mat' && P !== 'about' && P !== 'ser') return;
583
+ const anc = P === 'mat' ? body.querySelector('[data-pop="mat"]') : body.querySelector('[data-pop="head"]'); if (!anc) return;
584
+ if (P === 'mat') { anc.innerHTML = matPopHtml(me.mat || { row: me.row }); if (!me.matShown && anc.scrollIntoView) { me.matShown = true; anc.scrollIntoView({ block: 'nearest' }); } }
585
+ else if (P === 'about') anc.innerHTML = me.about ? aboutPopHtml(me.about, me.aboutQ || '', me.row ? 'Applies to every meeting of “' + me.row.title + '”. The calendar itself is never written.' : 'Applies to this note.') : '<div class="vzm-pop"><p class="vz-empty">Reading what it can be about.</p></div>';
586
+ else anc.innerHTML = `<div class="vzm-pop vzm-pop-s" role="menu"><button type="button" role="menuitem" class="vzm-mi2 vz-hv" data-a="${me.model.seriesOff ? 'm-serback' : 'm-serout'}">${me.model.seriesOff ? 'Put it back in its series' : 'Not part of this series'}<br><span class="vzm-sm vzm-mut">${me.model.seriesOff ? 'Join the meetings with the same title again' : 'Keep this note on its own'}</span></button></div>`;
587
+ }
588
+ function keydown(me, e, body) {
589
+ const a = e.target.dataset && e.target.dataset.a;
590
+ if (e.key === 'Enter' && a === 'namein') { e.preventDefault(); nameIt(me, +e.target.dataset.i, e.target.value); }
591
+ if (e.key === 'Enter' && a === 'minin') { e.preventDefault(); setMin(me, +e.target.dataset.i, e.target.value); }
592
+ if (e.key === 'Enter' && a === 'matlink') { e.preventDefault(); addLink(me, e.target.value); }
593
+ if (e.key === 'Escape' && me.ui.naming != null) { me.ui.naming = null; paint(me, body); }
594
+ if (e.key === 'Escape' && me.ui.pop) { e.stopPropagation(); me.ui.pop = ''; paint(me, body); }
595
+ if (a === 'seek' && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) { e.preventDefault(); const P = ensurePlay(me); if (P) seek(me, P.pos + (e.key === 'ArrowRight' ? 10000 : -10000), false); }
420
596
  }
421
597
  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); };
598
+ const repaint = (me) => { const b = bodyEl(); if (b && MT === me) paint(me, b); };
423
599
  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
600
  function tick(me) {
425
601
  if (MT !== me || !me.model) return;
426
602
  const b = bodyEl(); if (!b) return;
427
603
  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');
604
+ const el = elapsedOf(me), s = b.querySelector('[data-clk="state"]');
605
+ if (s && me.model.liveK === 'rec') s.textContent = 'Recording · ' + mmss(el);
431
606
  }
432
607
  }
433
608
 
434
609
  /* the presses */
435
610
  async function press(me, e) {
436
- const t = e.target.closest('[data-a]'); if (!t || t.disabled) return;
611
+ const t = e.target.closest('[data-a]');
612
+ if (!t) { if (me.ui.pop && !e.target.closest('.vzm-pop')) { me.ui.pop = ''; repaint(me); } return; }
613
+ if (t.disabled) return;
437
614
  const a = t.dataset.a, ui = me.ui, m = me.model, C = rec();
438
615
  if (a !== 'more' && !a.startsWith('m-')) ui.more = false;
616
+ if (ui.pop && !t.closest('.vzm-pop') && !['addmat', 'm-about', 'sermenu', 'topic'].includes(a)) ui.pop = '';
439
617
  switch (a) {
440
- case 'part': ui.open[t.dataset.k] = !(t.getAttribute('aria-expanded') === 'true'); return repaint(me);
618
+ case 'tab': ui.tab = t.dataset.k; ui.pop = ''; return repaint(me);
441
619
  case 'more': ui.more = !ui.more; return repaint(me);
442
- case 'ppl': ui.ppl = !ui.ppl; return repaint(me);
620
+ case 'popx': ui.pop = ''; return repaint(me);
443
621
  case 'askno': ui.ask = null; return repaint(me);
444
622
  case 'record': ui.ask = 'consent'; return repaint(me);
445
623
  case 'recgo': {
446
624
  ui.ask = null; t.disabled = true;
447
625
  const res = me.n && !me.row ? await C.resume(me.n.id) : await C.record(me.row);
448
626
  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);
627
+ ui.tab = ''; return load(me);
450
628
  }
451
629
  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
630
  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
631
  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); }
632
+ 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.tab = ''; return load(me); }
455
633
  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
634
  case 'src': ui.src = !ui.src; return repaint(me);
457
635
  case 'app': {
@@ -478,32 +656,46 @@ async function press(me, e) {
478
656
  }
479
657
  case 'note': if (t.dataset.id) return openMeeting({ note: t.dataset.id }, { ws: me.ws }); return;
480
658
  case 'mat': {
481
- const x = m.prep.material[+t.dataset.i]; if (!x) return;
659
+ const x = matAt(me, +t.dataset.i); if (!x) return;
482
660
  if (x.url && /^https:\/\//.test(x.url)) { window.open(x.url, '_blank', 'noopener'); return; }
483
661
  return say(me, '“' + x.title + '” is a PMOS ' + x.kind.toLowerCase() + '. Open it from its initiative.');
484
662
  }
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);
663
+ case 'present': return presentIt(me, matAt(me, +t.dataset.i));
664
+ case 'matrm': return removeMat(me, matAt(me, +t.dataset.i));
665
+ case 'addmat': if (ui.pop === 'mat') { ui.pop = ''; return repaint(me); } return openMat(me);
666
+ case 'matadd': { const P = me.mat; const it = P && (P.q ? P.found : P.sug)[+t.dataset.i]; if (it) return addMat(me, it.url && !it.ref ? { url: it.url, title: it.title } : { kind: it.kind, ref: it.ref, title: it.title, ...(it.ws ? { ws: it.ws } : {}) }); return; }
667
+ case 'topic': ui.pop = ui.pop === 'topic' ? '' : 'topic'; return repaint(me);
668
+ case 'topicgo': return changeTopic(me, m.focus.topics[+t.dataset.i]);
488
669
  case 'maketask': return makeTask(me, +t.dataset.i);
489
670
  case 'makewi': return makeWorkItem(me, +t.dataset.i);
671
+ case 'madeundo': { const md = ui.made[+t.dataset.i]; delete ui.made[+t.dataset.i]; repaint(me); if (md && md.undo) await md.undo(); return; }
490
672
  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);
673
+ case 'prepfold': ui.prepOpen = !ui.prepOpen; return repaint(me);
674
+ /* Replay */
675
+ case 'play': return togglePlay(me);
676
+ case 'speed': { const P = ensurePlay(me); const sp = [1, 1.5, 2]; ui.speed = sp[(sp.indexOf(ui.speed || 1) + 1) % sp.length]; if (P && P.aud) P.aud.playbackRate = ui.speed; return repaint(me); }
677
+ case 'seekto': if (t.dataset.t !== '') return seek(me, +t.dataset.t, true); return;
678
+ case 'trseek': ui.tab = 'replay'; repaint(me); return seek(me, +t.dataset.t, true);
679
+ case 'seek': { const r = t.getBoundingClientRect(); return seek(me, Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)) * m.notes.replay.len, false); }
680
+ case 'shotbig': if (m.notes.replay && m.notes.replay.noteId) window.open('/api/notes/screen?id=' + encodeURIComponent(m.notes.replay.noteId) + '&t=' + t.dataset.t, '_blank', 'noopener'); return;
681
+ case 'pf': ui.filter = t.dataset.k; return repaint(me);
682
+ case 'tick': { const id = t.dataset.id; if (ui.sel.has(id)) ui.sel.delete(id); else ui.sel.add(id); return repaint(me); }
683
+ case 'leftout': ui.leftOpen = !ui.leftOpen; return repaint(me);
684
+ case 'bulk': return bulk(me, t.dataset.k, [...ui.sel]);
685
+ case 'confirmall': return bulk(me, 'confirmed', m.notes.replay.points.filter((p) => !p.verdict).map((p) => p.id));
686
+ case 'unwrong': return verdict(me, [t.dataset.id], null, 'It is back in the kept points.');
687
+ case 'ptask': return bulk(me, 'task', [t.dataset.id]);
688
+ /* the head */
689
+ case 'sermenu': ui.pop = ui.pop === 'ser' ? '' : 'ser'; return repaint(me);
690
+ case 'm-about': if (ui.pop === 'about') { ui.pop = ''; return repaint(me); } return openAbout(me);
691
+ case 'aboutpick': return saveAbout(me, t.dataset.v);
497
692
  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
693
  case 'm-fresh': { ui.more = false; return newNote(me.ws); }
499
694
  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 });
695
+ ui.more = false; ui.pop = ''; const r = await pmPost('/api/notes/series-member', { id: me.n.id, key: a === 'm-serout' ? 'off' : null });
501
696
  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
697
  }
503
- case 'm-replay': ui.more = false; return fullReplay(me);
504
698
  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
699
  default:
508
700
  }
509
701
  }
@@ -511,6 +703,12 @@ function change(me, e) {
511
703
  const t = e.target;
512
704
  if (t.dataset.a === 'priv' && t.checked) { t.checked = false; me.ui.ask = 'priv'; repaint(me); }
513
705
  }
706
+ function input(me, e) {
707
+ const a = e.target.dataset.a, v = e.target.value;
708
+ if (a === 'mine') return saveMine(me, v);
709
+ if (a === 'matq') { clearTimeout(me.matT); me.matT = setTimeout(() => findMat(me, v.trim()), 220); return; }
710
+ if (a === 'aboutq') { me.aboutQ = v; const l = bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="list"]'); if (l && me.about) l.innerHTML = aboutListHtml(me.about, v); }
711
+ }
514
712
  let mineT = null;
515
713
  function saveMine(me, v) {
516
714
  if (!me.n) return;
@@ -518,8 +716,7 @@ function saveMine(me, v) {
518
716
  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
717
  }
520
718
  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];
719
+ const all = linesOf(me.n), l = all[i];
523
720
  me.ui.naming = null;
524
721
  if (!l || !String(name).trim()) return repaint(me);
525
722
  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() };
@@ -537,24 +734,42 @@ async function setMin(me, i, v) {
537
734
  if (!r || !r.ok) say(me, 'The minutes were not saved: ' + ((r && r.error) || 'no answer'), 'bad');
538
735
  return load(me, true);
539
736
  }
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');
737
+ /** Change topic (Focus): the topic now, for this meeting (POST /api/meeting-focus/topic). */
738
+ async function changeTopic(me, tp) {
739
+ me.ui.pop = '';
740
+ const ev = me.row ? me.row.id : me.n && me.n.meeting && me.n.meeting.event_id;
741
+ if (!tp || !ev) { say(me, 'The topic can be changed on a calendar meeting only.', 'bad'); return; }
742
+ const r = await pmPost('/api/meeting-focus/topic', { event: ev, date: me.fq ? me.fq.date : '', action: 'set', topic: tp.text });
743
+ say(me, r && r.ok ? 'The topic now is “' + clip(tp.text, 60) + '”.' : 'Not changed: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
744
+ return load(me, true);
745
+ }
746
+ /** Make task: the step goes into the first stage of the note's initiative (POST /api/plan-items); the made line has Undo, which withdraws it. */
747
+ async function makeTask(me, i, quiet) {
748
+ const S = me.D.S, step = S && S.actions[i]; if (!step) return { ok: false };
749
+ const r = await taskOf(me, step);
750
+ if (!r.ok) { if (!quiet) say(me, 'The task was not made: ' + r.error, 'bad'); return r; }
751
+ me.ui.made[i] = { html: 'Task made · added to <b>' + esc(r.ini) + '</b>, under ' + esc(r.stage), undo: r.undo };
752
+ await load(me, true);
753
+ return r;
754
+ }
755
+ async function taskOf(me, step) {
756
+ const S = me.D.S;
757
+ if (!S || !S.initiative) return { ok: false, error: 'link the meeting to an initiative first' };
758
+ const lay = await pmGet('/api/plan-items?' + q({ ladder: 0, ws: S.initiative.ws, id: S.initiative.id }));
759
+ const stage = lay && lay.ok && (lay.stages || [])[0];
760
+ const plan = taskEvent(S, step, stage);
761
+ if (!plan.ok) return { ok: false, error: plan.reason };
546
762
  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');
763
+ if (!r || r.ok !== true) return { ok: false, error: (r && r.error) || 'no answer' };
548
764
  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 () => {
765
+ return { ok: true, ini: S.initiative.name, stage: stage.label || stage.id, undo: item ? async () => {
551
766
  const u = await pmPost('/api/plan-items', { ws: plan.ws, events: [{ ev: 'withdrawn', item, initiative: S.initiative.id }] });
552
767
  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);
768
+ } : null };
554
769
  }
555
770
  /** A work-item: the step becomes a ticket Drafted in PMOS on the note's initiative (POST /api/viewer-meeting/work-item). */
556
771
  async function makeWorkItem(me, i) {
557
- const S = me.D.S, step = S && S.actions[i]; me.ui.stepMenu = null; if (!step) return;
772
+ const S = me.D.S, step = S && S.actions[i]; if (!step) return;
558
773
  const r = await workItem(me.n.id, step);
559
774
  if (!r.ok) return say(me, 'The work-item was not made: ' + r.error, 'bad');
560
775
  await load(me, true);
@@ -573,33 +788,57 @@ export async function newNote(ws) {
573
788
  return r;
574
789
  }
575
790
 
576
- /* the replay track */
791
+ /* Replay's bulk bar: Make tasks (the To do points), Confirm and Not right (POST /api/meeting-points) */
792
+ async function bulk(me, k, ids) {
793
+ const V = me.model.notes.replay; if (!V || !ids.length) return;
794
+ if (k === 'task') {
795
+ const S = me.D.S, pts = V.points.filter((p) => ids.includes(p.id) && p.kind === 'action');
796
+ if (!pts.length) return say(me, 'Only a To do point can become a task.', 'bad');
797
+ let made = 0, err = '';
798
+ for (const p of pts) {
799
+ const i = S ? S.actions.findIndex((x) => norm(x.text) === norm(p.text)) : -1;
800
+ const r = i >= 0 ? await makeTask(me, i, true) : await taskOf(me, { text: p.text, owner: p.owner, due: p.due });
801
+ if (r.ok) { made++; (me.ui.pmade = me.ui.pmade || {})[p.id] = true; } else err = r.error;
802
+ }
803
+ me.ui.sel = new Set(); me.ui.made = { ...me.ui.made };
804
+ return say(me, made ? plural(made, 'task') + ' made in ' + (S && S.initiative ? S.initiative.name : 'the initiative') + '.' + (err ? ' One was not: ' + err : '') : 'No task was made: ' + err, made ? '' : 'bad');
805
+ }
806
+ return verdict(me, ids, k, k === 'confirmed' ? plural(ids.length, 'point') + ' confirmed.' : plural(ids.length, 'point') + ' moved to Left out.', k === 'wrong');
807
+ }
808
+ async function verdict(me, ids, v, text, undo) {
809
+ const r = await pmPost('/api/meeting-points', { note: me.n.id, ids, verdict: v });
810
+ if (!r || !r.ok) return say(me, 'Not saved: ' + ((r && r.error) || 'no answer'), 'bad');
811
+ me.D.points = r.points || {}; me.ui.sel = new Set(); draw(me);
812
+ say(me, text, '', undo ? async () => verdict(me, ids, null, 'Put back.') : null);
813
+ }
814
+
815
+ /* the replay player */
577
816
  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
817
  function ensurePlay(me) {
579
- const T = me.model.notes.track; if (!T) return null;
818
+ const T = me.model && me.model.notes.replay; if (!T) return null;
580
819
  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
820
  return me.play;
582
821
  }
583
822
  function playUi(me) {
584
- const P = me.play, T = me.model.notes.track; me.ui.pos = P.pos; me.ui.playing = P.on;
823
+ const P = me.play, T = me.model.notes.replay; me.ui.pos = P.pos; me.ui.playing = P.on;
585
824
  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'); }
825
+ const sh = T.shotAt(P.pos);
826
+ if (sh !== me.shotNow || P.on !== me.wasOn) { me.shotNow = sh; me.wasOn = P.on; return repaint(me); } // a new capture or Play/Pause: draw the tab again
827
+ b.querySelectorAll('[data-clk="head"]').forEach((h) => h.setAttribute('x', Math.min(100, P.pos / T.len * 100).toFixed(2) + '%')); // an SVG attribute: where the replay is
828
+ b.querySelectorAll('[data-clk="pos"]').forEach((p) => { p.textContent = mmss(P.pos); });
829
+ b.querySelectorAll('.vzp-top').forEach((x) => { const on = T.stretchAt(P.pos) && +x.dataset.t === T.stretchAt(P.pos).from; if (on) x.setAttribute('aria-current', 'true'); else x.removeAttribute('aria-current'); });
590
830
  }
591
- function togglePlay(me, fromHead) {
831
+ function togglePlay(me) {
592
832
  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;
833
+ const T = me.model.notes.replay;
595
834
  if (P.on) { stopPlay(me); playUi(me); return; }
596
835
  if (P.pos >= T.len - 200) P.pos = 0;
597
836
  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(); }); }
837
+ if (P.aud) { try { P.aud.currentTime = P.pos / 1000; P.aud.playbackRate = me.ui.speed || 1; } catch { /* not loaded */ } const pr = P.aud.play(); if (pr && pr.catch) pr.catch(() => { P.aud = null; P.last = performance.now(); }); }
599
838
  P.tm = setInterval(() => {
600
839
  if (MT !== me) { stopPlay(me); return; }
601
840
  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;
841
+ if (P.aud && !P.aud.paused) P.pos = P.aud.currentTime * 1000; else P.pos += (now - P.last) * (me.ui.speed || 1); P.last = now;
603
842
  if (P.pos >= T.len) { P.pos = T.len; stopPlay(me); }
604
843
  playUi(me);
605
844
  }, 250);
@@ -607,125 +846,113 @@ function togglePlay(me, fromHead) {
607
846
  }
608
847
  function seek(me, ms, play) {
609
848
  const P = ensurePlay(me); if (!P) return;
610
- P.pos = Math.max(0, Math.min(me.model.notes.track.len, ms));
849
+ P.pos = Math.max(0, Math.min(me.model.notes.replay.len, ms));
611
850
  if (P.aud) { try { P.aud.currentTime = P.pos / 1000; } catch { /* not loaded */ } }
612
851
  if (play && !P.on) togglePlay(me); else playUi(me);
613
852
  }
614
853
 
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(); }; });
854
+ /* Present (MtFocus → MtPresent): a PMOS deck in the presenter view */
855
+ async function presentIt(me, x) {
856
+ if (!x || !x.deck || !x.ref) return;
857
+ const M = await import('./premium-mtg-present.js');
858
+ const meetingNow = () => {
859
+ const m = me.model, Fo = m ? m.focus : null, cur = Fo ? Fo.agenda.findIndex((a) => a.k === 'now' || a.k === 'late') : -1, a = cur >= 0 ? Fo.agenda[cur] : null;
860
+ const F = me.D && me.D.F, qs = F && F.captured && Array.isArray(F.captured.questions) ? F.captured.questions.filter((z) => z && z.text && !z.answered) : [];
861
+ const last = qs[qs.length - 1];
862
+ return { title: m ? m.title : '', rec: !!(m && m.liveK === 'rec'), at: m && m.at, end: m && m.end, topic: a ? { n: a.n, of: Fo.agenda.length, text: a.text, left: a.plan ? (a.plan - a.used) * 60000 : null } : null, question: last ? last.text : '', asker: last ? last.who || last.by || '' : '' };
640
863
  };
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;
864
+ const r = await M.presentDeck({ ws: x.ws || me.ws, path: x.ref, title: x.title, meeting: meetingNow(), getMeeting: meetingNow,
865
+ onKeep: async (text) => { if (!me.n || !text) return { ok: false, error: 'the meeting has no note yet' }; const body = String(me.n.body || '').replace(/\s+$/, '') + (me.n.body ? '\n' : '') + 'Question: ' + text; const s = await pmPost('/api/notes/save', { id: me.n.id, body }); if (s && s.ok) me.n.body = body; return s; } });
866
+ if (r && r.ok === false) say(me, r.error, 'bad');
867
+ }
868
+
869
+ /* Add material (MtMaterial): a popover under the Material list */
870
+ const matAt = (me, i) => { const tab = me.model && (me.ui.tab && me.model.focus && me.ui.tab in { focus: 1 } ? me.model.focus.material : me.model.prep.material); return tab ? tab[i] : null; };
871
+ async function openMat(me) {
872
+ const row = me.row;
873
+ me.ui.pop = 'mat'; me.matShown = false; me.mat = { row, sug: null, found: null, q: '', topics: [], err: '' };
874
+ repaint(me);
875
+ if (!row) return;
876
+ const [s, t] = await Promise.all([
877
+ pmGet('/api/meeting-material/suggest?' + q({ ws: me.ws, initiative: row.level && row.level.kind === 'initiative' ? row.level.id : '' })),
878
+ pmGet('/api/meeting-material?' + q({ event: row.id, title: row.title, series: row.series, date: row.day, topics: 1, ws: me.ws })),
879
+ ]);
880
+ if (MT !== me || me.ui.pop !== 'mat') return;
881
+ me.mat.sug = s && s.ok ? s.suggested || [] : []; me.matShown = false;
882
+ me.mat.topics = t && t.ok && Array.isArray(t.topics) ? t.topics.map((x) => x.text).filter(Boolean) : [];
883
+ const b = bodyEl(), l = b && b.querySelector('.vzm-pop [data-pl="list"]');
884
+ if (b && b.contains(document.activeElement) && l) { l.innerHTML = matListHtml(me.mat); } else repaint(me);
885
+ }
886
+ async function findMat(me, v) {
887
+ const P = me.mat; if (!P || !P.row) return;
888
+ P.q = v.length >= 2 ? v : ''; P.found = null;
889
+ const l = () => bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="list"]');
890
+ if (l()) l().innerHTML = matListHtml(P);
891
+ if (!P.q) return;
892
+ const r = await pmGet('/api/meeting-material/suggest?' + q({ ws: me.ws, q: P.q }));
893
+ if (MT !== me || P !== me.mat || P.q !== v) return;
894
+ P.found = r && r.ok ? r.found || [] : [];
895
+ if (l()) l().innerHTML = matListHtml(P);
896
+ }
897
+ const matErr = (me, text) => { if (me.mat) me.mat.err = text; const e = bodyEl() && bodyEl().querySelector('.vzm-pop [data-pl="err"]'); if (e) { e.textContent = text; e.hidden = !text; } };
898
+ const matEv = (row) => ({ id: row.id || undefined, title: row.title, ...(row.series ? { series: row.series } : {}) });
899
+ async function addMat(me, item) {
900
+ const row = me.row; if (!row) return;
901
+ const b = bodyEl(), ser = b && b.querySelector('[data-a="matser"]'), tsel = b && b.querySelector('[data-a="mattopic"]');
902
+ const scope = ser && ser.checked ? 'series' : 'meeting', topic = tsel ? tsel.value : '';
903
+ matErr(me, '');
904
+ const r = await pmPost('/api/meeting-material', { op: 'add', event: matEv(row), scope, item, ...(topic ? { topic } : {}) });
905
+ if (!r || !r.ok) return matErr(me, 'Not added: ' + ((r && r.error) || 'no answer'));
906
+ me.ui.pop = ''; say(me, 'Added “' + clip(item.title, 60) + '”' + (scope === 'series' ? ' for every meeting of the series.' : ' for this meeting.')); load(me, true);
907
+ }
908
+ function addLink(me, v) {
909
+ let u = null;
910
+ try { u = new URL(String(v).trim()); } catch { /* not an address */ }
911
+ if (!u || u.protocol !== 'https:') return matErr(me, 'Only an https link can be added.');
912
+ return addMat(me, { url: u.href, title: u.hostname });
913
+ }
914
+ async function removeMat(me, x) {
915
+ const row = me.row; if (!x) return;
916
+ if (!row) return say(me, 'Material is kept per calendar meeting. This note has no calendar event.', 'bad');
917
+ const scope = x.scope || 'meeting', item = 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 } : {}) };
918
+ const r = await pmPost('/api/meeting-material', { op: 'remove', event: matEv(row), scope, item });
919
+ if (!r || !r.ok) return say(me, 'Not removed: ' + ((r && r.error) || 'no answer'), 'bad');
920
+ await load(me, true);
921
+ say(me, 'Removed “' + clip(x.title, 60) + '”.', '', async () => { const u = await pmPost('/api/meeting-material', { op: 'add', event: matEv(row), scope, item, ...(x.topic ? { topic: x.topic } : {}) }); say(me, u && u.ok ? 'It is back.' : 'Not added back: ' + ((u && u.error) || 'no answer'), u && u.ok ? '' : 'bad'); load(me, true); });
922
+ }
923
+
924
+ /* What it is about (MtAfter): the initiative, the product, the whole portfolio, or none. A calendar meeting is linked for its whole series
925
+ * (POST /api/calendar-links); a note with no calendar event is linked itself (POST /api/notes/link). */
926
+ async function openAbout(me) {
927
+ me.ui.pop = 'about'; me.about = null; me.aboutQ = ''; repaint(me);
928
+ const S = me.D && me.D.S, text = S ? [S.overview, ...S.actions.map((a) => a.text), ...S.decisions.map((d) => d.text), ...S.questions.map((x) => x.text)].join(' ') : '';
655
929
  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']]);
930
+ const W = me.W || (me.row.day ? await weekOf(me.row.day, me.ws) : null); me.W = W;
931
+ const lv = me.row.level, cur = lv ? (lv.kind === 'portfolio' ? 'portfolio' : lv.kind === 'board' ? 'board|' + lv.ws + '|' + lv.id : 'initiative|' + lv.id) : '';
932
+ me.about = aboutOptions(me.row, W, null, text, cur);
658
933
  } else if (me.n) {
659
934
  const r = await pmGet('/api/boards'), list = r && r.ok && Array.isArray(r.boards) ? r.boards.filter((b) => b && b.id && !b.error) : [];
660
935
  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
936
  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);
937
+ me.about = aboutOptions(null, null, me.choices, text, aboutNow(me.n));
938
+ } else { me.ui.pop = ''; return say(me, 'There is nothing to link yet.', 'bad'); }
939
+ if (MT === me && me.ui.pop === 'about') { repaint(me); const i = bodyEl() && bodyEl().querySelector('[data-a="aboutq"]'); if (i) i.focus(); }
667
940
  }
668
- async function saveAbout(me) {
669
- const sel = bodyEl() && bodyEl().querySelector('[data-a="aboutsel"]'), v = sel ? sel.value : '';
941
+ async function saveAbout(me, v) {
670
942
  if (!v) return;
671
943
  let r;
672
944
  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
945
  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');
946
+ me.ui.pop = '';
947
+ say(me, r && r.ok ? (v === 'none' ? 'Left out of an initiative.' : 'Linked.') : 'Not saved: ' + ((r && r.error) || 'no answer'), r && r.ok ? '' : 'bad');
676
948
  return load(me);
677
949
  }
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
950
 
728
951
  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); } });
952
+ document.addEventListener('click', (e) => {
953
+ if (!MT || !e.target.isConnected) return; // the press repainted the card: its own handler already decided
954
+ if (MT.ui.more && !e.target.closest('.vz-menu,[data-a="more"]')) { MT.ui.more = false; repaint(MT); }
955
+ if (MT.ui.pop && !e.target.closest('#czViewer')) { MT.ui.pop = ''; repaint(MT); }
956
+ });
730
957
  }
731
- export const _test = { refOf, linesOf, factsOf };
958
+ export const _test = { refOf, linesOf, factsOf, gapsOf };