create-pmos 0.397.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 (195) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +105 -52
  8. package/workspace/briefing-premium-board-test.js +284 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +85 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +99 -83
  13. package/workspace/briefing-premium-initiative-test.js +175 -290
  14. package/workspace/briefing-premium-insights-test.js +414 -219
  15. package/workspace/briefing-premium-metrics-test.js +55 -97
  16. package/workspace/briefing-premium-products-test.js +44 -28
  17. package/workspace/briefing-premium-sources-test.js +70 -49
  18. package/workspace/briefing-premium-test.js +155 -648
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +24 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/board-premium-trail.js +32 -0
  23. package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
  24. package/workspace/guide/briefing-premium.md +3 -1
  25. package/workspace/guide/home.md +68 -0
  26. package/workspace/guide/index.md +1 -0
  27. package/workspace/lib/agent-roles.js +71 -0
  28. package/workspace/lib/board-grill.js +63 -0
  29. package/workspace/lib/board-premium.js +121 -24
  30. package/workspace/lib/board-trail.js +223 -0
  31. package/workspace/lib/home-work-item.js +58 -0
  32. package/workspace/lib/initiative-layout.js +77 -0
  33. package/workspace/lib/insights-goals.js +196 -0
  34. package/workspace/lib/insights-premium.js +64 -15
  35. package/workspace/lib/insights-records.js +115 -0
  36. package/workspace/lib/jira-tickets.js +1 -1
  37. package/workspace/lib/meeting-points.js +52 -0
  38. package/workspace/lib/news-for-you.js +88 -0
  39. package/workspace/lib/notes-series.js +29 -6
  40. package/workspace/lib/report-confirm.js +48 -0
  41. package/workspace/lib/route-modules.js +12 -0
  42. package/workspace/lib/routes-board-docs.js +46 -0
  43. package/workspace/lib/routes-board-grill.js +90 -0
  44. package/workspace/lib/routes-board-trail.js +33 -0
  45. package/workspace/lib/routes-home-desk.js +176 -0
  46. package/workspace/lib/routes-home-review.js +108 -0
  47. package/workspace/lib/routes-initiative-layout.js +57 -0
  48. package/workspace/lib/routes-insights-premium.js +16 -4
  49. package/workspace/lib/routes-insights-records.js +133 -0
  50. package/workspace/lib/routes-meeting-points.js +37 -0
  51. package/workspace/lib/routes-news.js +57 -0
  52. package/workspace/lib/routes-notes.js +3 -1
  53. package/workspace/lib/routes-report-confirm.js +31 -0
  54. package/workspace/lib/routes-search.js +38 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/search-index.js +176 -0
  57. package/workspace/lib/transcript-steps.js +123 -0
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-board-actions-test.js +128 -82
  63. package/workspace/premium-briefing-depth-test.js +104 -90
  64. package/workspace/premium-chat-attach-test.js +54 -63
  65. package/workspace/premium-chat-chart-tab-test.js +37 -37
  66. package/workspace/premium-chat-context-test.js +19 -18
  67. package/workspace/premium-chat-goal-view-test.js +23 -23
  68. package/workspace/premium-chat-notes-test.js +26 -31
  69. package/workspace/premium-chat-report-tab-test.js +46 -28
  70. package/workspace/premium-chat-term-test.js +16 -16
  71. package/workspace/premium-chat-viewer-test.js +60 -59
  72. package/workspace/premium-core-doc-issue-test.js +52 -43
  73. package/workspace/premium-html-viewer-test.js +14 -17
  74. package/workspace/premium-phone-card-test.js +10 -3
  75. package/workspace/premium-phone-room-test.js +41 -35
  76. package/workspace/premium-report-read-test.js +152 -197
  77. package/workspace/premium-viewer-download-test.js +19 -22
  78. package/workspace/premium-viewer-flicker-test.js +11 -16
  79. package/workspace/premium-viewer-share-test.js +6 -9
  80. package/workspace/premium-viewer-test.js +41 -60
  81. package/workspace/premium-vw-backlog-test.js +53 -33
  82. package/workspace/premium-vw-cal-test.js +97 -128
  83. package/workspace/premium-vw-copy-test.js +17 -33
  84. package/workspace/premium-vw-doc-test.js +17 -10
  85. package/workspace/premium-vw-item-test.js +50 -49
  86. package/workspace/premium-vw-jira-test.js +53 -27
  87. package/workspace/premium-vw-meet-test.js +115 -187
  88. package/workspace/premium-vw-notes-test.js +88 -109
  89. package/workspace/premium-vw-rec-test.js +71 -194
  90. package/workspace/premium-vw-slides-test.js +46 -50
  91. package/workspace/premium-welcome-test.js +3 -2
  92. package/workspace/premium-work-depth-test.js +61 -53
  93. package/workspace/public/pm/bd-acts.js +383 -0
  94. package/workspace/public/pm/bd-asks.js +261 -0
  95. package/workspace/public/pm/bd-pop.js +59 -0
  96. package/workspace/public/pm/bd-span.js +222 -82
  97. package/workspace/public/pm/bd-stages.js +25 -11
  98. package/workspace/public/pm/bd-views.js +169 -0
  99. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  100. package/workspace/public/pm/c3-md.js +3 -395
  101. package/workspace/public/pm/c3-phone-detail.js +1 -1
  102. package/workspace/public/pm/c3-phone-model.js +3 -68
  103. package/workspace/public/pm/chat-term.js +3 -3
  104. package/workspace/public/pm/cozy-board.css +798 -230
  105. package/workspace/public/pm/cozy-ev.css +228 -0
  106. package/workspace/public/pm/cozy-evmodel.js +106 -0
  107. package/workspace/public/pm/cozy-evui.js +47 -0
  108. package/workspace/public/pm/cozy-home.css +570 -142
  109. package/workspace/public/pm/cozy-home.js +5 -3
  110. package/workspace/public/pm/cozy-insights.css +437 -170
  111. package/workspace/public/pm/cozy-md.js +396 -0
  112. package/workspace/public/pm/cozy-nav.js +104 -29
  113. package/workspace/public/pm/cozy-news.js +140 -0
  114. package/workspace/public/pm/cozy-placeholder.js +26 -0
  115. package/workspace/public/pm/cozy-search.js +203 -0
  116. package/workspace/public/pm/cozy-settings.js +198 -0
  117. package/workspace/public/pm/cozy-sources.js +89 -0
  118. package/workspace/public/pm/cozy-today.css +217 -0
  119. package/workspace/public/pm/cozy-viewer.css +3 -3
  120. package/workspace/public/pm/cozy-viewer.js +145 -0
  121. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  122. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  123. package/workspace/public/pm/cozy-vw.css +485 -0
  124. package/workspace/public/pm/cozy.css +83 -1
  125. package/workspace/public/pm/home-adddoc.js +48 -0
  126. package/workspace/public/pm/home-app.js +1179 -0
  127. package/workspace/public/pm/home-around.js +413 -0
  128. package/workspace/public/pm/home-chat.js +512 -0
  129. package/workspace/public/pm/home-data.js +312 -0
  130. package/workspace/public/pm/home-dictate.js +54 -0
  131. package/workspace/public/pm/home-draft.js +68 -0
  132. package/workspace/public/pm/home-ini-model.js +190 -0
  133. package/workspace/public/pm/home-ini.css +171 -0
  134. package/workspace/public/pm/home-ini.js +456 -0
  135. package/workspace/public/pm/home-list.js +276 -0
  136. package/workspace/public/pm/home-more.js +132 -0
  137. package/workspace/public/pm/home-phone-card.js +109 -0
  138. package/workspace/public/pm/home-review.js +104 -0
  139. package/workspace/public/pm/home-task.js +67 -0
  140. package/workspace/public/pm/home-today.js +144 -0
  141. package/workspace/public/pm/home-work.js +547 -0
  142. package/workspace/public/pm/phone-moment.js +69 -0
  143. package/workspace/public/pm/pm-work-view.js +1 -1
  144. package/workspace/public/pm/premium-attach.js +4 -0
  145. package/workspace/public/pm/premium-board.js +548 -395
  146. package/workspace/public/pm/premium-chart-tab.js +109 -62
  147. package/workspace/public/pm/premium-deck.js +3 -3
  148. package/workspace/public/pm/premium-first.js +23 -21
  149. package/workspace/public/pm/premium-insights.js +1102 -581
  150. package/workspace/public/pm/premium-meeting.js +61 -549
  151. package/workspace/public/pm/premium-mtg-present.js +138 -0
  152. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  153. package/workspace/public/pm/premium-notes.js +1 -1
  154. package/workspace/public/pm/premium-report-frame.css +20 -0
  155. package/workspace/public/pm/premium-report-read.js +669 -476
  156. package/workspace/public/pm/premium-report-tab.js +116 -67
  157. package/workspace/public/pm/premium-shell.js +76 -123
  158. package/workspace/public/pm/premium-viewer.js +22 -1
  159. package/workspace/public/pm/premium-vw-cal.js +277 -48
  160. package/workspace/public/pm/premium-vw-doc.css +6 -0
  161. package/workspace/public/pm/premium-vw-doc.js +40 -2
  162. package/workspace/public/pm/premium-vw-file.js +2 -2
  163. package/workspace/public/pm/premium-vw-meet.js +6 -83
  164. package/workspace/public/pm/premium-vw-mtg.js +958 -0
  165. package/workspace/public/pm/premium-vw-notes.js +116 -68
  166. package/workspace/public/pm/premium-vw-open.js +35 -0
  167. package/workspace/public/pm/premium-vw-page.js +16 -0
  168. package/workspace/public/pm/premium-vw-rec.js +11 -218
  169. package/workspace/public/pm/premium-vw-slides.css +5 -0
  170. package/workspace/public/pm/premium-vw-slides.js +44 -8
  171. package/workspace/public/pm/rp-parts.js +269 -0
  172. package/workspace/public/pm/term-view.js +22 -0
  173. package/workspace/public/premium-board.html +29 -70
  174. package/workspace/public/premium-initiative.html +8 -48
  175. package/workspace/public/premium-insights.html +26 -64
  176. package/workspace/public/premium-viewer.html +20 -0
  177. package/workspace/public/premium.html +18 -107
  178. package/workspace/r/m1.png +0 -0
  179. package/workspace/r/m2.png +0 -0
  180. package/workspace/r/m3.png +0 -0
  181. package/workspace/r/nl.png +0 -0
  182. package/workspace/server.js +18 -3
  183. package/workspace/test-files.json +1 -0
  184. package/workspace/test-lists/home-libs.json +9 -0
  185. package/workspace/test-lists/initiative-layout.json +9 -0
  186. package/workspace/test-lists/premium-report-read.json +1 -1
  187. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  188. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  189. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  190. package/workspace/test-lists/premium-vw-notes.json +1 -1
  191. package/workspace/test-lists/uf-everywhere.json +15 -0
  192. package/workspace/test-lists/uf-home.json +9 -0
  193. package/workspace/test-lists/uncovered-board.json +9 -0
  194. package/workspace/public/pm/premium-work.js +0 -729
  195. package/workspace/public/pm/premium.js +0 -1146
@@ -112,8 +112,8 @@ export function present(deck, ws, start, opt = {}) {
112
112
  if (!w || w.closed) { toast('The browser blocked the audience window. Allow pop-ups for PMOS, then press Audience window again.'); return; }
113
113
  const d = w.document;
114
114
  d.title = 'Audience · ' + deck.title;
115
- if (!d.querySelector('link[data-sl]')) for (const h of ['/pm/premium.css', '/pm/premium-vw-slides.css']) { const l = d.createElement('link'); l.rel = 'stylesheet'; l.href = location.origin + h; l.dataset.sl = ''; d.head.append(l); }
116
- d.documentElement.dataset.theme = 'dark'; d.body.className = 'sl-audw';
115
+ if (!d.querySelector('link[data-sl]')) for (const h of ['/pm/cozy.css', '/pm/premium-vw-slides.css']) { const l = d.createElement('link'); l.rel = 'stylesheet'; l.href = location.origin + h; l.dataset.sl = ''; d.head.append(l); }
116
+ d.documentElement.dataset.theme = 'dark'; d.body.className = 'cz sl-audw';
117
117
  w.onkeydown = (e) => key(e); w.onresize = drawWin; w.onclick = () => go(1);
118
118
  P.win = w; drawWin(); o.focus();
119
119
  };
@@ -147,10 +147,10 @@ export function present(deck, ws, start, opt = {}) {
147
147
  /* ── the editor ── */
148
148
  const OPEN = new Map(); // path -> editor state, so the test hook can read it
149
149
 
150
- export async function openSlides({ ws, path, title, readOnly, onSaved, host, onClose } = {}) {
150
+ export async function openSlides({ ws, path, title, readOnly, onSaved, host, onClose, onState } = {}) {
151
151
  if (!path) return null;
152
152
  vwStyle('slides');
153
- const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, onClose: host ? onClose : null, text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
153
+ const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, onClose: host ? onClose : null, cozy: !!host, onState: host ? onState : null, note: '', text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
154
154
  OPEN.set(path, S);
155
155
  const el = host || vwOpen({ id: 'slides:' + path, title: S.title + ' slides', icon: 'doc', html: '<p class="note">Reading the slides.</p>' });
156
156
  if (host) host.innerHTML = '<p class="note">Reading the slides.</p>';
@@ -171,11 +171,28 @@ function load(S, text) {
171
171
  S.deck = d; S.i = Math.min(S.i, d.slides.length - 1); S.sel = null; S.editing = null; S.hist = []; S.fut = []; S.dirty = false;
172
172
  const ch = d.slides.map((s, k) => (s.changed ? k + 1 : 0)).filter(Boolean);
173
173
  S.msg = ch.length ? `The text of slide ${ch.join(', ')} was changed in the file outside the editor, so it now shows the file's text. Its layout is kept.` : (!d.blocks && !S.ro ? 'This document has no slide layout yet. It is shown as a title slide and one slide for each section. Saving adds the layout to the file.' : '');
174
+ S.note = !ch.length && !d.blocks && !S.ro ? 'nolayout' : ''; // the report panel's edit mode does not show this note (ReportPanel.dc.html draws none)
174
175
  }
175
176
 
177
+ /* The report panel's edit mode (ReportPanel.dc.html, pane "edit"): the slide with a dashed outline, "Slides ‹ n of N ›" and a strip of
178
+ * thumbnails, five to a row. The panel's own toolbar drives the editor (the editor's toolbar is in the DOM but not shown). The slide tools,
179
+ * the selected item's tools and the speaker notes are not in the design: they stay usable, marked "Waiting for design". */
180
+ function cozySkeleton(S) {
181
+ const ro = S.ro, W8 = (f) => `<span class="vz-wait" data-cz-placeholder="${esc(f)}">Waiting for design</span>`;
182
+ return `<div class="sl sl-cz${ro ? ' ro' : ''}" data-sl>`
183
+ + `<div class="sl-tb" role="toolbar" aria-label="Slides">${ro ? '' : `${tb('undo', 'Undo', 'undo', ' disabled')}${tb('redo', 'Redo', 'redo', ' disabled')}${tbl('text', 'Text', 'txt')}${tbl('img', 'Image', 'img')}${tbl('chart', 'Chart', 'chart')}${tbl('table', 'Table', 'tbl')}${tbl('shape', 'Shape', 'shape')}${tbl('layout', 'Layout', 'lay', ' aria-haspopup="menu"')}${tbl('theme', 'Theme', 'pal', ' aria-haspopup="menu"')}`}`
184
+ + `${S.onClose ? '<button type="button" class="sl-b sl-bl" data-c="close"><span>Cancel</span></button>' : ''}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
185
+ + `<p class="sl-msg" role="status"></p>`
186
+ + `<div class="sl-body"><div class="sl-main"><div class="sl-stage" tabindex="0" aria-label="Slide"></div></div>`
187
+ + `<div class="sl-snav"><b>Slides</b><span class="sl-gap"></span><button type="button" class="sl-b sl-nv" data-rel="-1" aria-label="Previous slide" title="Previous slide">${I('lt')}</button><span class="sl-cnt" aria-live="polite"></span><button type="button" class="sl-b sl-nv" data-rel="1" aria-label="Next slide" title="Next slide">${I('rt')}</button></div>`
188
+ + `<nav class="sl-rail" aria-label="Slides"></nav>`
189
+ + (ro ? '' : '<div class="sl-ctx" role="toolbar" aria-label="Change the selected item"></div><div class="sl-tools" role="toolbar" aria-label="This slide"></div>')
190
+ + `<details class="sl-notes"><summary>Speaker notes ${W8('Speaker notes')}</summary><textarea rows="3" aria-label="Speaker notes" placeholder="${ro ? 'No notes' : 'What you will say on this slide. Only you see it.'}"${ro ? ' readonly' : ''}></textarea></details></div></div>`;
191
+ }
176
192
  function build(S) {
177
193
  const el = S.root, ro = S.ro;
178
- el.innerHTML = `<div class="sl${ro ? ' ro' : ''}" data-sl>`
194
+ if (S.cozy) el.innerHTML = cozySkeleton(S);
195
+ else el.innerHTML = `<div class="sl${ro ? ' ro' : ''}" data-sl>`
179
196
  + `<div class="sl-tb" role="toolbar" aria-label="Slides">`
180
197
  + (ro ? '' : `${tb('undo', 'Undo', 'undo', ' disabled')}${tb('redo', 'Redo', 'redo', ' disabled')}<span class="sl-sep"></span>${tbl('text', 'Text', 'txt')}${tbl('img', 'Image', 'img')}${tbl('chart', 'Chart', 'chart')}${tbl('table', 'Table', 'tbl')}${tbl('shape', 'Shape', 'shape')}<span class="sl-sep"></span>${tbl('layout', 'Layout', 'lay', ' aria-haspopup="menu"')}${tbl('theme', 'Theme', 'pal', ' aria-haspopup="menu"')}`)
181
198
  + `<span class="sl-gap"></span>${tbl('present', 'Present', 'play')}${S.onClose ? `<button type="button" class="sl-b sl-bl" data-c="close"><span>Cancel</span></button>` : ''}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
@@ -195,6 +212,7 @@ function build(S) {
195
212
  top.onclick = (e) => { const b = e.target.closest('[data-c]'); if (b && !b.disabled) onTop(S, b.dataset.c, b); };
196
213
  if (ctx) { ctx.onmousedown = (e) => { if (e.target.closest('button')) e.preventDefault(); }; ctx.onclick = (e) => { const b = e.target.closest('[data-c]'); if (b) onCtx(S, b.dataset.c, b.dataset.v, b); }; }
197
214
  rail.onclick = (e) => onRail(S, e);
215
+ for (const x of [$('.sl-snav'), $('.sl-tools')]) if (x) x.onclick = (e) => onRail(S, e);
198
216
  if (!ro) {
199
217
  stage.onpointerdown = (e) => onDown(S, e);
200
218
  stage.onpointermove = (e) => onMove(S, e);
@@ -226,10 +244,24 @@ function drawBar(S) {
226
244
  const u = S.$('[data-c="undo"]'), r = S.$('[data-c="redo"]'), m = S.$('.sl-msg'), sv = S.$('[data-c="save"]');
227
245
  if (u) u.disabled = !S.hist.length; if (r) r.disabled = !S.fut.length;
228
246
  if (sv) { sv.disabled = S.busy; sv.classList.toggle('on', S.dirty); }
229
- if (m) { m.textContent = S.ro ? 'This report is issued, so its slides are read-only.' + (S.msg ? ' ' + S.msg : '') : S.msg; m.hidden = !m.textContent; }
247
+ if (m) { m.textContent = S.ro ? 'This report is issued, so its slides are read-only.' + (S.msg ? ' ' + S.msg : '') : S.cozy && S.note === 'nolayout' ? '' : S.msg; m.hidden = !m.textContent; }
248
+ if (S.onState) { try { S.onState(S); } catch (x) { console.error(x); } }
230
249
  }
231
250
  function drawRail(S) {
232
251
  const rail = S.$('.sl-rail'), n = S.deck.slides.length;
252
+ if (S.cozy) {
253
+ rail.innerHTML = S.deck.slides.map((s, k) => `<div class="sl-th" draggable="${!S.ro}" data-k="${k}" aria-current="${k === S.i}">`
254
+ + `<button type="button" class="sl-mini" data-go="${k}" aria-label="Slide ${k + 1}: ${esc(railName(s, k))}">${slideHtml(s, S.deck.theme, S.ws, false)}</button><span class="sl-cap" data-go="${k}" aria-hidden="true">${k + 1} · ${esc(railName(s, k))}</span></div>`).join('');
255
+ rail.querySelectorAll('.sl-mini').forEach((m) => { fit(m); place(m); });
256
+ const c = S.$('.sl-cnt'); if (c) c.textContent = (S.i + 1) + ' of ' + n;
257
+ S.root.querySelectorAll('.sl-snav [data-rel]').forEach((b) => { b.disabled = b.dataset.rel === '-1' ? S.i === 0 : S.i === n - 1; });
258
+ const t = S.$('.sl-tools'), k = S.i;
259
+ if (t) t.innerHTML = `<span class="vz-wait" data-cz-placeholder="Slide tools">Waiting for design</span><span class="sl-tl">Slide ${k + 1}</span>`
260
+ + `<button type="button" class="sl-b sl-bl" data-up="${k}" aria-label="Move slide ${k + 1} earlier"${k === 0 ? ' disabled' : ''}><span>Earlier</span></button><button type="button" class="sl-b sl-bl" data-dn="${k}" aria-label="Move slide ${k + 1} later"${k === n - 1 ? ' disabled' : ''}><span>Later</span></button>`
261
+ + `<button type="button" class="sl-b sl-bl" data-dup="${k}" aria-label="Duplicate slide ${k + 1}"><span>Duplicate</span></button><button type="button" class="sl-b sl-bl" data-del="${k}" aria-label="Delete slide ${k + 1}"${n < 2 ? ' disabled' : ''}><span>Delete</span></button>`
262
+ + `<button type="button" class="sl-b sl-bl" data-add aria-haspopup="menu">${I('plus')}<span>Slide</span></button><button type="button" class="sl-b sl-bl" data-c="present" title="The slide, the next one, your notes and a timer">${I('play')}<span>Presenter view</span></button>`;
263
+ return;
264
+ }
233
265
  rail.innerHTML = S.deck.slides.map((s, k) => `<div class="sl-th" draggable="${!S.ro}" data-k="${k}" aria-current="${k === S.i}"><i class="sl-num">${k + 1}</i>`
234
266
  + `<button type="button" class="sl-mini" data-go="${k}" aria-label="Slide ${k + 1}: ${esc(railName(s, k))}">${slideHtml(s, S.deck.theme, S.ws, false)}</button>`
235
267
  + (S.ro ? '' : `<span class="sl-tha"><button type="button" class="sl-b" data-up="${k}" aria-label="Move slide ${k + 1} up" title="Move up"${k === 0 ? ' disabled' : ''}>${I('up')}</button><button type="button" class="sl-b" data-dn="${k}" aria-label="Move slide ${k + 1} down" title="Move down"${k === n - 1 ? ' disabled' : ''}>${I('down')}</button><button type="button" class="sl-b" data-dup="${k}" aria-label="Duplicate slide ${k + 1}" title="Duplicate">${I('dup')}</button><button type="button" class="sl-b" data-del="${k}" aria-label="Delete slide ${k + 1}" title="Delete"${n < 2 ? ' disabled' : ''}>${I('trash')}</button></span>`)
@@ -248,7 +280,7 @@ const ROLE_NAME = (r) => (D.ROLES.find((x) => x[0] === r) || D.ROLES[2])[1];
248
280
  function drawCtx(S) {
249
281
  const ctx = S.$('.sl-ctx'); if (!ctx) return;
250
282
  const it = S.sel && find(S, S.sel); let h = '';
251
- if (!it) h = `<span class="sl-hint">Slide ${S.i + 1} of ${S.deck.slides.length}. Click an item to change it. Double-click text to type.</span>`;
283
+ if (!it) h = S.cozy ? '' : `<span class="sl-hint">Slide ${S.i + 1} of ${S.deck.slides.length}. Click an item to change it. Double-click text to type.</span>`;
252
284
  else if (it.t === 'text') h = `<button type="button" class="sl-b sl-bl" data-c="role" aria-haspopup="menu"><span>${esc(ROLE_NAME(it.role))}</span></button><span class="sl-sep"></span>`
253
285
  + `<button type="button" class="sl-b" data-c="bold" aria-label="Bold" title="Bold"><b>B</b></button><button type="button" class="sl-b" data-c="italic" aria-label="Italic" title="Italic"><i>I</i></button><button type="button" class="sl-b" data-c="underline" aria-label="Underline" title="Underline"><u>U</u></button>${tb('list', 'Bulleted list', 'ul')}<span class="sl-sep"></span>`
254
286
  + ['left', 'center', 'right'].map((a) => tb('al', 'Align ' + a, 'a' + a[0], ` data-v="${a}" aria-pressed="${(it.align || 'left') === a}"`)).join('') + '<span class="sl-sep"></span>'
@@ -258,6 +290,7 @@ function drawCtx(S) {
258
290
  else if (it.t === 'img') h = tbl('pick', it.src ? 'Change image' : 'Choose image', 'img');
259
291
  else h = D.FILLS.map((c) => `<button type="button" class="sl-sw f-${c[0]}" data-c="fill" data-v="${c[0]}" aria-label="${c[1]}" title="${c[1]}" aria-pressed="${(it.fill || 'acc') === c[0]}"></button>`).join('') + `<button type="button" class="sl-b sl-bl" data-c="round" aria-pressed="${!!it.round}">Round</button>`;
260
292
  if (it) h += `<span class="sl-gap"></span>${tb('front', 'Bring to front', 'front')}${tb('back', 'Send to back', 'back')}${tb('dup', 'Duplicate', 'dup')}${tb('del', 'Delete', 'trash')}`;
293
+ if (it && S.cozy) h = '<span class="vz-wait" data-cz-placeholder="Item tools">Waiting for design</span>' + h;
261
294
  ctx.innerHTML = h;
262
295
  }
263
296
  function go(S, k) { commitEdit(S); closePop(S); S.i = Math.max(0, Math.min(S.deck.slides.length - 1, k)); S.sel = null; drawAll(S); }
@@ -299,10 +332,11 @@ function closePop(S) { if (S.pop) { S.pop.remove(); S.pop = null; } }
299
332
  function pop(S, anchor, html) {
300
333
  closePop(S);
301
334
  const p = document.createElement('div'); p.className = 'sl-pop'; p.dataset.escLayer = ''; p.innerHTML = html;
335
+ if (!anchor.getClientRects().length) anchor = S.$('.sl-stage') || anchor; // a press forwarded from the report panel: the menu opens over the slide
302
336
  const root = S.root.querySelector('.sl'), a = anchor.getBoundingClientRect(), r = root.getBoundingClientRect();
303
337
  root.append(p);
304
338
  const left = Math.max(0, Math.min(a.left - r.left, r.width - p.offsetWidth));
305
- p.style.setProperty('--bd-px', left + 'px'); p.style.setProperty('--bd-py', (a.bottom - r.top + 6) + 'px');
339
+ p.style.setProperty('--bd-px', left + 'px'); p.style.setProperty('--bd-py', ((anchor.classList.contains('sl-stage') ? a.top : a.bottom) - r.top + 6) + 'px');
306
340
  S.pop = p;
307
341
  const f = p.querySelector('input,button'); if (f) f.focus();
308
342
  p.onkeydown = (e) => { if (e.key === 'Escape') { e.stopPropagation(); closePop(S); anchor.focus(); } };
@@ -384,6 +418,8 @@ function redrawSel(S) { drawStage(S); drawThumb(S, S.i); drawCtx(S); drawBar(S);
384
418
  function onRail(S, e) {
385
419
  const t = (s) => e.target.closest(s);
386
420
  if (t('[data-go]')) return go(S, +t('[data-go]').dataset.go);
421
+ if (t('[data-rel]')) return go(S, S.i + +t('[data-rel]').dataset.rel);
422
+ if (t('[data-c="present"]')) return onTop(S, 'present');
387
423
  if (S.ro) return;
388
424
  if (t('[data-up]')) return move(S, +t('[data-up]').dataset.up, +t('[data-up]').dataset.up - 1);
389
425
  if (t('[data-dn]')) return move(S, +t('[data-dn]').dataset.dn, +t('[data-dn]').dataset.dn + 1);
@@ -0,0 +1,269 @@
1
+ /* pm/rp-parts.js — the pure halves of the report reader's designed parts (initiative premium-uncovered-features, workstream reports; canvas
2
+ * RpBrief, RpStates, RpDoc, RpLive, RpPhone). No DOM: Node tests every function here (premium-report-uncovered.test.js).
3
+ *
4
+ * cycleName(row, cadence) "October" for a monthly report, else "Oct 12"
5
+ * cycleGroups(cycles, cur) the cycle menu: [{ k: 'draft'|'issued'|'archived', t, rows: [{ path, name, when, cur }] }] (RpStates)
6
+ * confirmKey(item) the key a Confirm is kept under: the check and a hash of its words, so new words ask again
7
+ * briefModel(x) the Brief tab: { glance, confirm, why, earlier, count } (RpBrief) from the records the reader read
8
+ * briefHtml(B, o) the Brief tab as html
9
+ * paperModel(W, o) · paperHtml(P) the report as a paper document, cut into pages (RpDoc)
10
+ * liveModel(m, o) · liveHtml(L, s) the report as a live page, from GET /api/insights-premium (RpLive)
11
+ * presentHtml(o) the full-screen presenting view (RpPhone Present, MtPresent's strip)
12
+ *
13
+ * THE RULE (as the premium models): every number, date and chip comes from a field of a record. Where a record is silent the part says so or
14
+ * is left out; nothing is filled with a guess. */
15
+ import { tableStarts, readTable, tableHtml } from './md-table.js';
16
+
17
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
+ const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
19
+ const plain = (s) => String(s || '').replace(/\*\*([^*]+)\*\*/g, '$1').replace(/`([^`]+)`/g, '$1').trim();
20
+ const MONS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
21
+ const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
22
+ const SV = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
23
+ const slotOf = (s) => /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s || ''));
24
+ /** "19 Oct", from a YYYY-MM-DD day. */
25
+ export const dayMon = (s) => { const m = slotOf(String(s || '').slice(0, 10)); return m ? +m[3] + ' ' + MONS[+m[2] - 1] : ''; };
26
+
27
+ /* ── cycles (RpStates: the cycle menu in groups) ── */
28
+ /** A cycle's name: the month for a monthly report ("October"), else its day ("Oct 12"). */
29
+ export function cycleName(row, cadence) {
30
+ const m = slotOf(row && (row.slot || row.date));
31
+ if (!m) return String((row && (row.slot || row.date)) || 'This cycle');
32
+ return /month/i.test(String(cadence || '')) ? MONTHS[+m[2] - 1] : MONS[+m[2] - 1] + ' ' + +m[3];
33
+ }
34
+ /** The cycle menu's groups, newest first in each: Draft, Issued, Archived. `cur` is the open cycle's path. An empty group is left out. */
35
+ export function cycleGroups(cycles, cur, cadence) {
36
+ const L = (cycles || []).slice().sort((a, b) => String(b.slot || '').localeCompare(String(a.slot || '')));
37
+ const k = (x) => (x.state === 'issued' ? (x.archived ? 'archived' : 'issued') : 'draft');
38
+ const monthly = /month/i.test(String(cadence || '')); // "October · 19 Oct"; a weekly cycle's name is its day already, so it says its state
39
+ return [['draft', 'Draft'], ['issued', 'Issued'], ['archived', 'Archived']].map(([g, t]) => ({ k: g, t,
40
+ rows: L.filter((x) => k(x) === g).map((x) => ({ path: x.path, name: cycleName(x, cadence), when: g === 'draft' ? 'draft' : monthly ? dayMon(x.slot) : g, cur: x.path === cur })) }))
41
+ .filter((g) => g.rows.length);
42
+ }
43
+
44
+ /* ── the Brief (RpBrief) ── */
45
+ const hash = (s) => { let h = 5381; for (const c of String(s)) h = ((h << 5) + h + c.charCodeAt(0)) >>> 0; return h.toString(36); };
46
+ /** The key a Confirm is kept under. The words are part of it, so a check that says something new asks again. */
47
+ export const confirmKey = (it) => it.id + ':' + hash(it.text);
48
+ const WHERE = { sources: 'Sources', sections: 'Sections', figures: 'Figures' };
49
+ /** The names a report's Sources section lists ("- Jira: …" → "Jira"), for "Built from" when no structure names its sources. */
50
+ export function sourcesOf(W) {
51
+ const s = ((W && W.sections) || []).find((x) => /^sources\b/i.test(x.h));
52
+ const out = [];
53
+ for (const l of (s && s.lines) || []) {
54
+ const b = /^\s*[-*]\s+(.*)$/.exec(l); if (!b) continue;
55
+ const n = plain(b[1]).split(/[:(—–]| - /)[0].trim();
56
+ if (n && !/^none\.?$/i.test(n) && !out.includes(n)) out.push(n.slice(0, 40));
57
+ }
58
+ return out.slice(0, 8);
59
+ }
60
+ /**
61
+ * The Brief tab. x = { setup, structure, design, checks, confirms: [key], W, issued, archived, goesOut, hasTemplate }
62
+ * glance { for, readBy, goesOut, built: [names] } each '' when no record says it
63
+ * confirm [{ key, where, text, acts: [[act, label]] }] the checks that did not pass, then the structure's open questions; a kept Confirm drops out
64
+ * why [string] the saved look in words: its description, the samples it follows, its rules; [] when no look is saved
65
+ * earlier [{ n, name, at }] the design versions that are not the saved one, newest first (Go back to it)
66
+ */
67
+ export function briefModel(x = {}) {
68
+ const su = x.setup || null, S = x.structure || null, plan = S && S.plan, pu = (plan && plan.purpose) || {}, D = x.design || null;
69
+ const kept = new Set(x.confirms || []);
70
+ const built = plan && (plan.sources || []).length ? plan.sources.map((s) => s.name).filter(Boolean).slice(0, 8) : sourcesOf(x.W);
71
+ const glance = { for: (su && su.purpose) || pu.decision || '', readBy: pu.readers || (su && su.audience) || '', goesOut: x.goesOut || '', built };
72
+ const confirm = [];
73
+ if (!x.issued) {
74
+ for (const c of (x.checks && x.checks.ok ? x.checks.checks : []) || []) {
75
+ if (c.ok) continue;
76
+ const it = { id: 'check-' + c.id, where: WHERE[c.id] || 'Check', text: c.text };
77
+ it.key = confirmKey(it);
78
+ it.acts = c.id === 'figures' ? [['use', 'Use it']].concat(x.hasTemplate ? [['again', 'Read again']] : []) : [['ok', 'Confirm'], ['fix', 'Correct']];
79
+ if (!kept.has(it.key)) confirm.push(it);
80
+ }
81
+ if (plan) {
82
+ const q = [];
83
+ if (!pu.readers) q.push('Who reads it?');
84
+ if (!pu.decision) q.push('What decision does it help make?');
85
+ if (!(pu.questions || []).length) q.push('Which questions should it answer?');
86
+ for (const t of q) { const it = { id: 'brief', where: 'Brief', text: t, acts: [['fix', 'Answer']] }; it.key = confirmKey(it); if (!kept.has(it.key)) confirm.push(it); }
87
+ }
88
+ }
89
+ const why = [];
90
+ const saved = D && D.saved ? D.saved.version : null;
91
+ if (D) {
92
+ if (D.description) why.push(D.description);
93
+ for (const s of D.samples || []) why.push('Follows ' + s.name + (s.took ? ': ' + (typeof s.took === 'string' ? s.took : s.took.took || '') : ''));
94
+ const r = D.rules || {};
95
+ for (const t of (r.same || []).slice(0, 3)) why.push(t);
96
+ for (const t of (r.learned || []).slice(0, 2)) why.push(t);
97
+ }
98
+ const earlier = D ? (D.versions || []).filter((v) => v.n !== saved).slice().sort((a, b) => b.n - a.n).slice(0, 4)
99
+ .map((v) => ({ n: v.n, name: v.turn ? clip(v.turn, 40) : 'Look D' + v.n, at: dayMon(String(v.made_at || '').slice(0, 10)) })) : [];
100
+ return { glance, confirm, why, earlier, saved, count: confirm.length };
101
+ }
102
+ const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
103
+ const NS = '<span class="rp-ns">not said</span>';
104
+ /** The Brief tab as html. o = { issued, busy, msg } */
105
+ export function briefHtml(B, o = {}) {
106
+ if (!B) return '<p class="vz-empty" role="status">Reading how this report is made.</p>';
107
+ const g = B.glance;
108
+ const kv = `<dl class="rp-kv"><dt>For</dt><dd>${g.for ? esc(g.for) : NS}</dd><dt>Read by</dt><dd>${g.readBy ? esc(g.readBy) : NS}</dd><dt>Goes out</dt><dd>${g.goesOut ? esc(g.goesOut) : NS}</dd>`
109
+ + `<dt>Built from</dt><dd class="rp-chips">${g.built.length ? g.built.map((s) => `<span class="rp-chip">${esc(s)}</span>`).join('') : NS}</dd></dl>`;
110
+ const conf = B.confirm.length ? B.confirm.map((c) => `<div class="rp-card" data-key="${esc(c.key)}"><i class="rp-dot" aria-hidden="true"></i><p><b>${esc(c.where)}:</b> ${esc(c.text)}</p>`
111
+ + c.acts.map(([a, l], i) => `<button type="button" class="rp-btn${i === 0 ? ' dark' : ''}" data-r="bf|${a}|${esc(c.key)}"${o.busy ? ' disabled' : ''}>${esc(l)}</button>`).join('') + '</div>').join('')
112
+ : `<p class="rp-mut">${o.issued ? 'Issued, so nothing is left to confirm. Changes go into the next cycle.' : 'Nothing to confirm. Every check passed.'}</p>`;
113
+ const why = B.why.length ? `<ul class="rp-ul">${B.why.map((t) => `<li>${esc(t)}</li>`).join('')}</ul>` : '<p class="rp-mut">No look is saved yet, so it uses the standard PMOS look. Say in the chat how it should look, or attach a sample.</p>';
114
+ const earlier = B.earlier.length ? `<p class="rp-lbl">Earlier looks</p><div class="rp-looks">${B.earlier.map((v) => `<div class="rp-box rp-look"><span class="rp-sw" aria-hidden="true"></span><span><b>${esc(v.name)}</b><br><span class="rp-mut">D${v.n}${v.at ? ' · ' + esc(v.at) : ''}</span></span>`
115
+ + (o.issued ? '' : `<button type="button" class="rp-btn" data-r="bf|back|${v.n}"${o.busy ? ' disabled' : ''}>Go back to it</button>`) + '</div>').join('')}</div>` : '';
116
+ return `<div class="rp-brief"><p class="rp-lbl">At a glance</p>${kv}<p class="rp-lbl">Please confirm</p>${conf}<p class="rp-lbl">Why it looks like this</p>${why}${earlier}`
117
+ + (o.msg ? `<p class="vz-msg" role="status">${esc(o.msg)}</p>` : '') + '</div>';
118
+ }
119
+
120
+ /* ── the paper document (RpDoc) ── */
121
+ /** A section's lines as blocks: paragraphs, lists, sub-headings and tables. Each block carries its weight in lines for the page cut. */
122
+ export function blocksOf(lines) {
123
+ const out = [], L = (lines || []).map((l) => String(l));
124
+ let list = [];
125
+ const flush = () => { if (list.length) { out.push({ html: '<ul>' + list.map((x) => '<li>' + inline(x) + '</li>').join('') + '</ul>', w: list.reduce((n, x) => n + Math.ceil((x.length + 4) / 90), 0) + 0.5 }); list = []; } };
126
+ for (let i = 0; i < L.length; i++) {
127
+ const l = L[i];
128
+ if (/^\s*<!--.*-->\s*$/.test(l)) continue;
129
+ if (tableStarts(L, i)) { flush(); const t = readTable(L, i); out.push({ html: tableHtml(t, inline, 'rp-tbl'), w: 1.4 * (t.rows.length + 1) + 0.5 }); i = t.end; continue; }
130
+ const b = /^\s*[-*]\s+(.*)$/.exec(l), h = /^#{3,6}\s+(.*)$/.exec(l);
131
+ if (b) { list.push(b[1]); continue; }
132
+ flush();
133
+ if (h) out.push({ html: '<p><b>' + inline(h[1]) + '</b></p>', w: 1.5 });
134
+ else if (l.trim()) out.push({ html: '<p>' + inline(l.trim()) + '</p>', w: Math.ceil(l.trim().length / 90) + 0.4 });
135
+ }
136
+ flush();
137
+ return out;
138
+ }
139
+ const PAGE_LINES = 34;
140
+ /**
141
+ * The report as paper: { eye, title, minute, pages: [[{ html, w }]], foot, n }. W = wordsOf(...). o = { audience, name, slot }
142
+ * minute the first section when it is a Summary or a Headline: the "In one minute" box
143
+ * foot the Sources section, said once at the end as the footnote line
144
+ * pages the numbered sections cut into pages of about 34 lines; a section's heading never ends a page
145
+ */
146
+ export function paperModel(W, o = {}) {
147
+ const secs = ((W && W.sections) || []).slice();
148
+ let minute = '';
149
+ if (secs[0] && /^(summary|headline|in one minute|tl;?dr)$/i.test(secs[0].h)) minute = blocksOf(secs.shift().lines).map((b) => b.html).join('');
150
+ const si = secs.findIndex((s) => /^sources\b/i.test(s.h));
151
+ const foot = si >= 0 ? blocksOf(secs.splice(si, 1)[0].lines).map((b) => b.html).join('') : '';
152
+ const m = slotOf(o.slot);
153
+ const eye = ['Report', o.audience || '', m ? MONTHS[+m[2] - 1] + ' ' + m[1] : ''].filter(Boolean).join(' · ').toUpperCase();
154
+ const pages = [[]];
155
+ let used = 5 + (minute ? 4 : 0); // the eyebrow, the title and the minute box sit on page 1
156
+ secs.forEach((s, k) => {
157
+ const head = { html: `<h2>${k + 1} · ${esc(s.h)}</h2>`, w: 2 };
158
+ const body = blocksOf(s.lines);
159
+ if (!body.length) body.push({ html: '<p class="rp-mut">This section is empty.</p>', w: 1 });
160
+ if (used + head.w + body[0].w > PAGE_LINES && pages[pages.length - 1].length) { pages.push([]); used = 0; }
161
+ pages[pages.length - 1].push(head); used += head.w;
162
+ for (const b of body) {
163
+ if (used + b.w > PAGE_LINES && used > 0) { pages.push([]); used = 0; }
164
+ pages[pages.length - 1].push(b); used += b.w;
165
+ }
166
+ });
167
+ return { eye, title: (W && W.title) || o.name || 'Report', minute, pages, foot, n: pages.length };
168
+ }
169
+ /** The paper as html: one sheet per page. o = { state, issuedOn } */
170
+ export function paperHtml(P, o = {}) {
171
+ const st = o.state === 'issued' ? 'Issued' + (o.issuedOn ? ' ' + o.issuedOn : '') : o.state === 'archived' ? 'Archived' : 'Draft';
172
+ return `<div class="rp-paperwell"><div class="rp-paperbar"><span data-rp-page aria-live="polite">Page 1 of ${P.n}</span><span class="rp-pill">${esc(st)}</span><span class="vz-sp"></span>`
173
+ + `<button type="button" class="rp-linkbtn" data-r="dlm" aria-haspopup="menu">Download as PDF or Word</button></div>`
174
+ + P.pages.map((pg, i) => `<article class="rp-pg" data-pg="${i + 1}" aria-label="Page ${i + 1} of ${P.n}">`
175
+ + (i === 0 ? `<p class="rp-eye">${esc(P.eye)}</p><h1>${esc(P.title)}</h1>${P.minute ? `<div class="rp-minute"><p class="rp-mh">In one minute</p>${P.minute}</div>` : ''}` : '')
176
+ + pg.map((b) => b.html).join('')
177
+ + (i === P.n - 1 && P.foot ? `<div class="rp-fn">${P.foot}</div>` : '')
178
+ + `<p class="rp-pno">${i + 1} / ${P.n}</p></article>`).join('') + '</div>';
179
+ }
180
+
181
+ /* ── the live page (RpLive) ── */
182
+ const DAY = 86400000;
183
+ const ms = (d) => Date.parse(String(d).slice(0, 10) + 'T00:00:00Z');
184
+ const RANGE = { '4w': 28, '8w': 56, q: 92 };
185
+ /**
186
+ * The live page from the Insights model (GET /api/insights-premium). o = { upTo, range, pick, open, now }
187
+ * upTo 'YYYY-MM-DD': an issued cycle reads only the readings up to its day, so a shared page of it never changes later
188
+ * tiles the picked goal and the next ones (up to 2 goals), Goals on track, Shipped, At risk
189
+ * chart the picked goal's readings in the range, its target line, and each point to hover
190
+ * rows the shipped work (Deliver, Monitor, Evaluate or done) with its stage, its goal's move and its state
191
+ */
192
+ export function liveModel(m, o = {}) {
193
+ if (!m) return { none: 'The numbers could not be read.' };
194
+ const upTo = o.upTo ? ms(o.upTo) : null;
195
+ const goals = (m.goals || []).map((g) => {
196
+ const s = (g.series || []).filter((p) => upTo == null || ms(p.at) <= upTo);
197
+ return { ...g, s };
198
+ });
199
+ const withData = goals.filter((g) => g.s.length);
200
+ if (!goals.length) return { none: 'No goal is recorded for this product yet, so the live page has no numbers. Add a goal in Insights.' };
201
+ const pick = withData.find((g) => g.id === o.pick) || withData[0] || goals[0];
202
+ const delta = (g) => {
203
+ if (g.s.length < 2) return { txt: g.s.length ? 'one reading so far' : 'no reading yet', tone: '' };
204
+ const a = g.s[g.s.length - 2].v, b = g.s[g.s.length - 1].v, d = Math.round((b - a) * 100) / 100;
205
+ const good = g.direction === 'down' ? d < 0 : d > 0;
206
+ return { txt: d === 0 ? 'same as the reading before' : (d > 0 ? 'up ' : 'down ') + Math.abs(d) + (g.unit === '%' ? ' pts' : '') + ' since ' + dayMon(g.s[g.s.length - 2].at), tone: d === 0 ? '' : good ? 'ok' : 'risk' };
207
+ };
208
+ const fmt = (g, v) => (v == null ? '—' : v + (g.unit === '%' ? '%' : g.unit && g.unit.length <= 3 ? ' ' + g.unit : ''));
209
+ const ok = goals.filter((g) => g.tone === 'ok').length, risk = goals.filter((g) => g.tone === 'late' || g.tone === 'red');
210
+ const shipped = (m.outcomes || []).filter((r) => upTo == null || !r.endAt || ms(r.endAt) <= upTo);
211
+ const tiles = [pick].concat(withData.filter((g) => g !== pick).slice(0, 1)).filter(Boolean).map((g) => {
212
+ const d = delta(g), v = g.s.length ? g.s[g.s.length - 1].v : null;
213
+ return { k: 'goal', id: g.id, label: g.title, value: fmt(g, v), sub: d.txt, tone: d.tone, on: g === pick };
214
+ });
215
+ tiles.push({ k: 'track', label: 'Goals on track', value: ok + ' of ' + goals.length, sub: goals.length - ok ? goals.length - ok + ' not on track' : 'all on track', tone: '' });
216
+ tiles.push({ k: 'shipped', label: 'Shipped', value: String(shipped.length), sub: shipped.filter((r) => r.group === 'decided').length + ' decided', tone: '' });
217
+ tiles.push({ k: 'risk', label: 'At risk', value: String(risk.length), sub: risk.length ? clip(risk[0].title, 28) : 'none', tone: risk.length ? 'risk' : '' });
218
+ const range = RANGE[o.range] ? o.range : '8w';
219
+ const end = upTo != null ? upTo : (o.now != null ? o.now : (pick.s.length ? ms(pick.s[pick.s.length - 1].at) : Date.now()));
220
+ const pts = pick.s.filter((p) => ms(p.at) >= end - RANGE[range] * DAY && ms(p.at) <= end);
221
+ const chart = { title: pick.title, range, unit: pick.unit, target: pick.target, pts: pts.map((p) => ({ at: p.at, v: p.v, txt: fmt(pick, p.v) })), empty: pts.length < 2 ? (pts.length ? 'Only one reading in this range. Pick a longer range.' : 'No reading in this range.') : '' };
222
+ const rows = shipped.map((r) => ({ id: r.id, title: r.title, stage: r.stageLabel || r.stage || '', moved: r.goal ? (r.goal.baseTxt && r.goal.nowTxt ? r.goal.baseTxt + ' → ' + r.goal.nowTxt : r.goal.nowTxt || '') : '',
223
+ state: r.group === 'decided' ? (r.verdict ? r.verdict.verdict : 'Decided') : r.group === 'verdict' ? 'Needs a verdict' : 'In window', tone: r.group === 'decided' ? 'ok' : r.group === 'verdict' ? 'you' : 'q',
224
+ detail: [r.end ? 'Shipped ' + r.end : '', r.goal ? 'moves ' + r.goal.title : 'no goal named', r.owner ? 'owner ' + r.owner : ''].filter(Boolean).join(' · '), open: o.open === r.id }));
225
+ return { tiles, chart, rows, pick: pick.id, board: m.board || {}, asOf: m.as_of || null };
226
+ }
227
+ /** The chart: the readings as a line in a 760 x 170 box, the target dashed, each point a press that names its value. */
228
+ function chartSvg(c, hover) {
229
+ if (c.empty) return `<p class="rp-mut rp-empty">${esc(c.empty)}</p>`;
230
+ const vs = c.pts.map((p) => p.v).concat(c.target != null ? [c.target] : []);
231
+ let lo = Math.min(...vs), hi = Math.max(...vs); if (hi === lo) { hi += 1; lo -= 1; }
232
+ const pad = (hi - lo) * 0.12, y = (v) => Math.round(150 - ((v - lo + pad) / (hi - lo + 2 * pad)) * 130), n = c.pts.length;
233
+ const x = (i) => Math.round(20 + (i * 720) / Math.max(1, n - 1));
234
+ const line = c.pts.map((p, i) => (i ? 'L' : 'M') + x(i) + ' ' + y(p.v)).join('');
235
+ const tgt = c.target != null ? `<path d="M0 ${y(c.target)}H760" class="rp-tgt"/>` : '';
236
+ const h = hover != null && c.pts[hover] ? hover : null;
237
+ const pop = h != null ? `<div class="rp-pop" style="left:min(${((x(h) / 760) * 100 + 1.5).toFixed(1)}%, calc(100% - 214px))"><b>${esc(dayMon(c.pts[h].at))} · ${esc(c.pts[h].txt)}</b><a class="rp-linkbtn" href="/premium-insights.html" data-r="ins">Open in Insights</a></div>` : '';
238
+ return `<div class="rp-chart"><svg viewBox="0 0 760 170" preserveAspectRatio="none" role="img" aria-label="${esc(c.title)}: ${esc(c.pts[0].txt)} to ${esc(c.pts[n - 1].txt)}"><path d="M0 150H760" class="rp-axis"/>${tgt}<path d="${line}" class="rp-line"/>`
239
+ + (h != null ? `<path d="M${x(h)} 20V150" class="rp-axis"/>` : '') + '</svg>'
240
+ + c.pts.map((p, i) => `<button type="button" class="rp-pt${i === h ? ' on' : ''}" style="left:${(x(i) / 760) * 100}%;top:${(y(p.v) / 170) * 100}%" data-r="lv|pt|${i}" aria-label="${esc(dayMon(p.at))}: ${esc(p.txt)}"></button>`).join('') + pop + '</div>';
241
+ }
242
+ /** The live page as html. s = { name, audience, period, issued, readAgo, hover, products } */
243
+ export function liveHtml(L, s = {}) {
244
+ if (!L) return '<p class="vz-empty" role="status">Reading the numbers.</p>';
245
+ const head = `<div class="rp-lvh"><div class="rp-grow"><p class="rp-lbl">${esc((s.audience ? s.audience + ' · ' : '') + 'live')}</p><h2 class="rp-h2">${esc(s.name || 'Report')}</h2></div>`
246
+ + `<span class="rp-per" title="${s.issued ? 'An issued cycle shows its numbers as they were on its day' : 'The numbers as they are now'}">${esc(s.period || 'Now')}</span>`
247
+ + `<button type="button" class="cz-pick" data-r="lv|prod" aria-haspopup="menu" aria-expanded="${!!s.prodOpen}">${esc((L.board && L.board.name) || 'This product')}${SV('M7 10l5 5 5-5', 14)}</button>`
248
+ + `<span class="cz-pill ${s.issued ? 'q' : 'ok'}">${s.issued ? 'Frozen as issued' : '<i class="rp-okdot" aria-hidden="true"></i>Numbers read ' + esc(s.readAgo || 'just now')}</span>`
249
+ + (s.prodOpen && (s.products || []).length ? `<div class="vz-pop rp-prodpop" role="menu" aria-label="Products">${s.products.map((b) => `<button type="button" class="vz-mi vz-hv" role="menuitemradio" aria-checked="${b.id === (L.board && L.board.id)}" data-r="lv|board|${esc(b.ws || '')}~${esc(b.id)}">${esc(b.name)}</button>`).join('')}</div>` : '') + '</div>';
250
+ if (L.none) return `<div class="rp-live">${head}<p class="rp-mut rp-empty">${esc(L.none)}</p></div>`;
251
+ const tiles = `<div class="rp-kps">${L.tiles.map((t) => `<button type="button" class="rp-kp${t.on ? ' on' : ''}" data-r="${t.k === 'goal' ? 'lv|goal|' + esc(t.id) : 'lv|tile'}"${t.k === 'goal' ? ` aria-pressed="${!!t.on}"` : ' disabled'}><span class="rp-mut">${esc(t.label)}</span><b${t.tone === 'risk' && t.k === 'risk' ? ' class="rp-risk"' : ''}>${esc(t.value)}</b><span class="rp-sub${t.tone ? ' ' + t.tone : ''}">${esc(t.sub)}</span></button>`).join('')}</div>`;
252
+ const C = L.chart;
253
+ const ch = `<div class="rp-chh"><b class="rp-grow">${esc(C.title)}</b><div class="cz-seg" role="group" aria-label="Range">${[['4w', '4 wk'], ['8w', '8 wk'], ['q', 'Q']].map(([k, l]) => `<button type="button" data-r="lv|range|${k}" aria-pressed="${C.range === k}">${l}</button>`).join('')}</div></div>${chartSvg(C, s.hover)}`;
254
+ const rows = L.rows.length ? `<div class="rp-ex rp-exh"><span></span><span>Initiative</span><span>Stage</span><span>Goal moved</span><span>Status</span></div>`
255
+ + L.rows.map((r) => `<button type="button" class="rp-ex" data-r="lv|row|${esc(r.id)}" aria-expanded="${r.open}">${SV(r.open ? 'M7 10l5 5 5-5' : 'M10 7l5 5-5 5', 14)}<b>${esc(r.title)}</b><span>${esc(r.stage)}</span><span class="rp-mv">${esc(r.moved || '—')}</span><span class="cz-pill ${r.tone}">${esc(r.state)}</span></button>`
256
+ + (r.open ? `<p class="rp-exd rp-mut">${esc(r.detail)}</p>` : '')).join('') : '<p class="rp-mut">Nothing has shipped in this period.</p>';
257
+ return `<div class="rp-live">${head}${tiles}${ch}<p class="rp-lbl">Shipped · press a row for detail</p><div class="rp-rows">${rows}</div></div>`;
258
+ }
259
+
260
+ /* ── presenting (RpPhone Present; the strip and the hint of MtPresent) ── */
261
+ /** o = { name, i, n, slide (html), blank } */
262
+ export function presentHtml(o) {
263
+ const nums = Array.from({ length: o.n }, (_, k) => `<button type="button" class="rp-tb${k === o.i ? ' on' : ''}" data-r="go|${k}" aria-label="Slide ${k + 1}"${k === o.i ? ' aria-current="true"' : ''}>${k + 1}</button>`).join('');
264
+ return `<div class="rp-prh"><span class="rp-rec" aria-hidden="true"></span><b>${esc(o.name)} · presenting</b><span class="rp-mut" aria-live="polite">Slide ${o.i + 1} of ${o.n}</span><span class="vz-sp"></span>`
265
+ + `<button type="button" class="rp-btn dark" data-r="end">Stop presenting</button></div>`
266
+ + `<div class="rp-prs">${o.blank ? '<div class="vz-slide rp-blank"><p>The screen is blank. Press B to show the slide.</p></div>' : `<div class="vz-slide">${o.slide}</div>`}</div>`
267
+ + `<div class="vz-snav rp-prn"><button type="button" class="vz-ib vz-hv" data-r="prev" aria-label="Previous slide"${o.i === 0 ? ' disabled' : ''}>${SV('m15 6-6 6 6 6', 18)}</button>${nums}`
268
+ + `<button type="button" class="vz-ib vz-hv" data-r="next" aria-label="Next slide"${o.i === o.n - 1 ? ' disabled' : ''}>${SV('m9 6 6 6-6 6', 18)}</button><span class="vz-sp"></span><span class="rp-mut rp-hint">← → to move · B to blank the screen</span></div>`;
269
+ }
@@ -0,0 +1,22 @@
1
+ /* pm/term-view.js — a running session's terminal, read only, in the Viewer card (initiative premium-agreed-design: nothing links to the console).
2
+ * openTermView(sid, { title }) → the Viewer body. It reads GET /api/sessions/transcript?id=<sid> (what the session printed, ANSI taken out)
3
+ * every 2 s while the card shows it, and keeps the view at the end unless the PM scrolled up. It writes nothing. */
4
+ import { open, current } from './cozy-viewer.js';
5
+ import { pmGet } from './http.js';
6
+
7
+ export function openTermView(sid, o = {}) {
8
+ if (!/^sess-\d+$/.test(String(sid || ''))) return null;
9
+ const id = 'term:' + sid;
10
+ const body = open({ id, kind: 'Terminal · read only', title: o.title || sid, icon: 'M4 5h16v14H4zM7 9l3 3-3 3M12 15h5', html: '<pre class="hv-term" role="log" aria-live="off">Reading the terminal.</pre>' });
11
+ const tick = async () => {
12
+ const c = current(); if (!c || c.id !== id) return;
13
+ const r = await pmGet('/api/sessions/transcript?id=' + encodeURIComponent(sid) + '&max=12000');
14
+ const pre = body.querySelector('.hv-term'); if (!pre) return;
15
+ const end = pre.scrollHeight - pre.scrollTop - pre.clientHeight < 40;
16
+ pre.textContent = r && r.ok ? r.text || '(nothing printed yet)' : (r && r.error) || 'The terminal could not be read.';
17
+ if (end) pre.scrollTop = pre.scrollHeight;
18
+ setTimeout(tick, 2000);
19
+ };
20
+ tick();
21
+ return body;
22
+ }