create-pmos 0.400.0 → 0.402.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 (57) hide show
  1. package/package.json +25 -30
  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/board-programs-test.js +226 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-board-test.js +23 -16
  10. package/workspace/briefing-premium-calendar-test.js +6 -3
  11. package/workspace/briefing-premium-sources-test.js +17 -10
  12. package/workspace/briefing-premium-test.js +41 -16
  13. package/workspace/changelog.json +24 -0
  14. package/workspace/fixtures/board-premium-facts.js +20 -3
  15. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  16. package/workspace/fixtures/program-ascent.js +101 -0
  17. package/workspace/guide/home.md +15 -8
  18. package/workspace/guide/index.md +1 -0
  19. package/workspace/guide/programs.md +37 -0
  20. package/workspace/lib/briefing-premium-products.js +4 -4
  21. package/workspace/lib/briefing-premium.js +2 -2
  22. package/workspace/lib/core-docs.js +2 -2
  23. package/workspace/lib/programs.js +129 -0
  24. package/workspace/lib/route-modules.js +1 -0
  25. package/workspace/lib/routes-briefing-premium.js +1 -1
  26. package/workspace/lib/routes-programs.js +122 -0
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +1 -1
  30. package/workspace/premium-phone-card-test.js +6 -1
  31. package/workspace/premium-vw-cal-test.js +10 -4
  32. package/workspace/program-panel-test.js +143 -0
  33. package/workspace/public/pm/bd-acts.js +23 -14
  34. package/workspace/public/pm/bd-asks.js +89 -23
  35. package/workspace/public/pm/bd-prog-panel.js +451 -0
  36. package/workspace/public/pm/bd-prog.js +191 -0
  37. package/workspace/public/pm/bd-span.js +98 -15
  38. package/workspace/public/pm/bd-views.js +93 -29
  39. package/workspace/public/pm/cozy-board.css +226 -9
  40. package/workspace/public/pm/cozy-home.css +27 -1
  41. package/workspace/public/pm/cozy-panel.css +178 -0
  42. package/workspace/public/pm/cozy-today.css +190 -3
  43. package/workspace/public/pm/home-app.js +93 -26
  44. package/workspace/public/pm/home-chat.js +35 -32
  45. package/workspace/public/pm/home-data.js +8 -2
  46. package/workspace/public/pm/home-ini.js +1 -1
  47. package/workspace/public/pm/home-list.js +100 -24
  48. package/workspace/public/pm/home-today.js +138 -61
  49. package/workspace/public/pm/home-work.js +1 -3
  50. package/workspace/public/pm/premium-board.js +225 -57
  51. package/workspace/public/pm/premium-vw-item.css +6 -0
  52. package/workspace/public/pm/program-model.js +192 -0
  53. package/workspace/public/premium-board.html +4 -1
  54. package/workspace/test-files.json +1 -0
  55. package/workspace/test-lists/board-programs.json +9 -0
  56. package/workspace/test-lists/program-hierarchy.json +11 -0
  57. package/workspace/test-lists/program-panel.json +9 -0
@@ -0,0 +1,191 @@
1
+ /* pm/bd-prog.js — programs on the Board (initiative program-hierarchy, P4, P6, P8; canvas PgBoard, PgBoardProduct, PgKanban, PgTimeline, PgList).
2
+ *
3
+ * groupsOf(programs, rows, M, byProduct) [group] | null pm/program-model.js groupRows for this board: programs first, then the product.
4
+ * null when no program holds a row here (then no group head is drawn: zero is silence)
5
+ * stateOf(p, M, XR) programState of one program, read from this board's rows and the other products' rows read (XR)
6
+ * folded(key) · fold(key) every group folds; the fold is remembered across reloads (localStorage pmos.board.fold)
7
+ * openProgram(id, from) a program band, swimlane or timeline row opens the program: the bd:program event, and nothing else
8
+ * tileHtml(name, cls) a product's initials tile (PgBoard .ti, .st2); progTile(cls) the program's layers tile
9
+ * yours(st) the program's open tasks that are the PM's: the blue count badge (PgBoard .yc)
10
+ * readyHtml(m, whole) a milestone's readiness as small diamonds, one per initiative it waits on
11
+ * mergeBoards(list) All products: one Board model from every product's model, each row keeping its own product
12
+ * bandHtml(g, st, o) the stage track's program row: tile, title, products, your count, its spread, its next milestones
13
+ * prodHtml(g, o) · subHtml(name) a product group's head row (tile, name, goal dots, chevron) and a program's product sub-row
14
+ * goalsFrom(fn) · goalsHtml(name) the goal dots of a product head, from Home's source (pm/home-list.js goalsOf); fn(name) gives its rows
15
+ *
16
+ * A program has no stage of its own (PM, 2026-10-23): the band shows only what its initiatives say. With one product picked, the program shows
17
+ * that product's initiatives (PRD decision 5); its other products count in its line and its readiness, and their initiatives are not drawn here.
18
+ * With All products picked, the program holds a sub-row per product with that product's initiatives, then one group per product follows. */
19
+ import { programState, groupRows, mergeClose } from './program-model.js';
20
+ import { goalsOf } from './home-list.js';
21
+
22
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
23
+ const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
24
+ export const PROG = 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5';
25
+ const CHEV_D = 'M7 10l5 5 5-5', CHEV_R = 'M10 7l5 5-5 5';
26
+ const plural = (n, a, b) => (n === 1 ? a : b);
27
+
28
+ /* ── fold, remembered (every group folds; the fold survives a reload) ── */
29
+ const FOLD_KEY = 'pmos.board.fold';
30
+ let FOLD = null;
31
+ const foldSet = () => { if (!FOLD) { let v = null; try { v = JSON.parse(localStorage.getItem(FOLD_KEY) || 'null'); } catch { v = null; } FOLD = new Set(Array.isArray(v) ? v : []); } return FOLD; };
32
+ export const folded = (key) => foldSet().has(key);
33
+ export function fold(key, on) {
34
+ const S = foldSet(); if (on === undefined ? !S.has(key) : on) S.add(key); else S.delete(key);
35
+ try { localStorage.setItem(FOLD_KEY, JSON.stringify([...S])); } catch { /* no storage: the fold lasts until the reload */ }
36
+ }
37
+
38
+ /** The bd:program event: the program panel (pm/bd-prog-panel.js) listens for it. `from` is the row pressed, where the focus goes back on close. */
39
+ export function openProgram(id, from) { document.dispatchEvent(new CustomEvent('bd:program', { detail: { id, from: from || null } })); }
40
+
41
+ const prodName = (M) => (M && M.board && (M.board.product || M.board.name)) || '';
42
+ export function groupsOf(programs, rows, M, byProduct) {
43
+ const ws = (M && M.board && M.board.ws) || '', product = prodName(M);
44
+ const G = groupRows(rows, programs, { ws, product, byProduct: !!byProduct });
45
+ const any = byProduct ? G.some((g) => g.rows.some((r) => r.inProgram)) : G.some((g) => g.kind === 'program');
46
+ // All products: the product groups head the rows of each product, with a program or without one
47
+ return any || (M && M.board && M.board.all && G.length > 1) ? G : null;
48
+ }
49
+
50
+ /** M is the Board model; XR { [ws]: { name, rows } } the other products' rows the page read (each row: id, title, stage). A member no read
51
+ * row holds stays `missing`, never guessed. */
52
+ export function stateOf(p, M, XR, now = Date.now()) {
53
+ const ws = (M && M.board && M.board.ws) || '';
54
+ const steps = (M && M.steps) || [];
55
+ const rows = ((M && M.rows) || []).filter((r) => r.id).map((r) => ({ id: r.id, title: r.title, stage: r.track && r.track.k >= 0 && steps[r.track.k] ? steps[r.track.k].key : r.stage, anchor: r.anchor, ws: r.ws, product: r.product }));
56
+ // All products: every product's rows are on this board, each with its own workspace
57
+ if (M && M.board && M.board.all) return programState(p, (w) => { const R = rows.filter((r) => r.ws === w); return R.length ? { name: R[0].product, rows: R } : null; }, now);
58
+ return programState(p, (w) => (!w || !ws || w === ws ? { name: prodName(M), rows } : (XR && XR[w]) || null), now);
59
+ }
60
+
61
+ /** All products (PgBoard, PgKanban, PgTimeline, PgList, PgBoardProduct): one model from every product's Board model. list is
62
+ * [{ ws, id, name, model }], the first one the board the page was opened on. Each row keeps its own workspace, board and product
63
+ * (r.ws, r.boardId, r.product), so a write and a link go to the product the row belongs to; its key is prefixed with the workspace so two
64
+ * products never share one. The counts are added up. The documents and the new asks of every product are listed, each tagged with its product
65
+ * (r.ws, r.boardId, r.product), so a draft, an accept or a decline goes to that product's board. Jira's read time is the oldest of the
66
+ * products'. The sprint and the release belong to one product's Jira, so they are left out: pick the product to see them. */
67
+ export function mergeBoards(list) {
68
+ const home = list[0].model, steps = home.steps || [];
69
+ const tagged = (b) => {
70
+ const m = b.model, product = (m.board && (m.board.product || m.board.name)) || b.name || b.ws;
71
+ return (r) => ({ ...r, key: b.ws + '/' + r.key, ws: b.ws, boardId: b.id, product });
72
+ };
73
+ const rows = [], list2 = [], gone = { cancelled: [], archived: [] }, docs = [], asks = [];
74
+ const sum = (f) => list.reduce((n, b) => n + (Number(f(b.model)) || 0), 0);
75
+ for (const b of list) {
76
+ const m = b.model, tag = tagged(b), I = m.initiatives || {}, G = I.gone || {};
77
+ for (const r of m.rows || []) if (r.id) rows.push(tag(r));
78
+ for (const r of (I.list && I.list.rows) || []) list2.push(tag(r));
79
+ gone.cancelled.push(...(G.cancelled || []).map(tag)); gone.archived.push(...(G.archived || []).map(tag));
80
+ // each product's core documents and new asks, tagged with their product so a press goes to that product's board
81
+ const pn = (m.board && (m.board.product || m.board.name)) || b.name || b.ws, own = { ws: b.ws, boardId: b.id, product: pn };
82
+ for (const d of (m.docs && m.docs.rows) || []) docs.push({ ...d, ...own, scope: m.docs.scope || null });
83
+ for (const a of (m.asks && m.asks.rows) || []) asks.push({ ...a, ws: b.ws, boardId: b.id, forProduct: pn, stages: (m.board && m.board.stages) || [] });
84
+ }
85
+ // Jira: the oldest read of any product, so the chip never says fresher than the stalest board; unread while any product is unread
86
+ const reads = list.map((b) => (b.model.jira || {}).readAt || null);
87
+ const readAt = reads.every(Boolean) ? reads.slice().sort()[0] : null;
88
+ const asksRead = list.some((b) => b.model.chips && b.model.chips.asks != null);
89
+ const missing = [...new Set(list.flatMap((b) => (b.model.header && b.model.header.missing) || []))];
90
+ const I = home.initiatives || {};
91
+ const n = (k) => sum((m) => m.initiatives && m.initiatives[k]);
92
+ const C = (k) => sum((m) => m.chips && m.chips[k]);
93
+ return {
94
+ ...home,
95
+ header: { ...home.header, missing },
96
+ board: { ...home.board, all: true, name: 'All products', product: '', self: false, id: null, ws: null, products: list.map((b) => ({ ws: b.ws, id: b.id, name: (b.model.board && (b.model.board.product || b.model.board.name)) || b.name, self: !!(b.model.board && b.model.board.self), stages: (b.model.board && b.model.board.stages) || [], readAt: (b.model.jira || {}).readAt || null })) },
97
+ initiatives: { ...I, open: n('open'), on: n('on'), risk: n('risk'), late: n('late'), hold: n('hold'), total: n('total'), cap: null, note: '', list: { rows: list2, total: list2.length }, gone, stages: [], timeline: I.timeline },
98
+ sprint: null, release: null, docs: { cap: '', rows: docs, counts: { all: docs.length, none: 0, draft: 0, ok: 0 }, scope: null, missing: list.some((b) => b.model.docs && b.model.docs.missing) },
99
+ steps: steps.map((st, i) => ({ ...st, count: sum((m) => m.steps && m.steps[i] && m.steps[i].count) })),
100
+ jira: { ...(home.jira || {}), readAt, sprint: null, release: null, sprints: [], backlog: [] },
101
+ chips: { late: C('late'), risk: C('risk'), blocked: C('blocked'), idle: C('idle'), asks: asksRead ? asks.length : null },
102
+ asks: asksRead ? { rows: asks } : null,
103
+ rows,
104
+ };
105
+ }
106
+ /** The products a program spans: its members' workspaces, once each. */
107
+ export const productsOf = (p) => new Set((p.members || []).map((m) => m.ws || '')).size;
108
+
109
+ /** A product's two letters: "IDPF" → "ID", "Microsites" → "MI", "Data Platform" → "DP". */
110
+ export const initialsOf = (name) => { const w = String(name || '').trim().split(/\s+/).filter(Boolean); return (w.length > 1 ? w[0][0] + w[1][0] : (w[0] || '?').slice(0, 2)).toUpperCase(); };
111
+ /** One of four calm tones per product name, stable across views. */
112
+ const toneOf = (name) => { let h = 0; for (const c of String(name || '')) h = (h * 31 + c.charCodeAt(0)) >>> 0; return 'tn' + (h % 4); };
113
+ export const tileHtml = (name, cls = 'bd-ti') => `<span class="${cls} ${toneOf(name)}" aria-hidden="true">${esc(initialsOf(name))}</span>`;
114
+ export const progTile = (cls = 'bd-pti') => `<span class="${cls}" aria-hidden="true">${SV(PROG)}</span>`;
115
+
116
+ /** The program's open tasks that are the PM's: no owner, "pm" or "you", or the PM's own first name once the page has read it (setMe; Home
117
+ * reads the same name from GET /api/brief-page `me`). */
118
+ let ME = '';
119
+ export function setMe(name) { ME = String(name || '').trim().toLowerCase(); }
120
+ const isMe = (who) => { const w = String(who || '').trim().toLowerCase(); return !w || /^(pm|you)(\b|:)/.test(w) || (!!ME && (w === ME || w.startsWith(ME + ' '))); };
121
+ export const yours = (st) => (st.openTasks || []).filter((t) => isMe(t.owner)).length;
122
+ export const yoursHtml = (st) => { const n = yours(st), all = (st.openTasks || []).length; return n ? `<span class="bd-yc" role="img" aria-label="${n} program ${plural(n, 'task is', 'tasks are')} yours" title="${n} of ${all} program ${plural(all, 'task', 'tasks')} ${plural(n, 'is', 'are')} yours">${n}</span>` : ''; };
123
+
124
+ /** A milestone's readiness: a small diamond per initiative it waits on, filled once that initiative is past Deliver. Drawn only when every one
125
+ * it waits on was read (`whole`): a count of the rows read would understate it. */
126
+ export function readyHtml(m, whole) {
127
+ if (!m || !m.n || !whole) return '';
128
+ return `<span class="bd-rdy" role="img" aria-label="${m.ready} of ${m.n} ${plural(m.n, 'initiative', 'initiatives')} ready">${Array.from({ length: m.n }, (_, i) => `<i${i < m.ready ? ' class="on"' : ''}></i>`).join('')}</span>`;
129
+ }
130
+ const whole = (st) => !st.missing.length;
131
+ /** The open milestones in date order: the next merged with the ones close to it (PgKanban "Pilot live +2 · Nov 18–21"). */
132
+ export const nextCluster = (st) => mergeClose((st.milestones || []).filter((m) => !m.done), 7)[0] || null;
133
+
134
+ /** The stage track's program row (PgBoard .pg). g: the program group; o: { steps, rows (this board's rows in it) }. */
135
+ export function bandHtml(g, st, o) {
136
+ const p = g.program, steps = o.steps || [], open = !folded(g.key);
137
+ const n = productsOf(p);
138
+ const sp = st.spread, nI = st.inis.length;
139
+ const N = steps.length || 8, pc = (n) => ((n / N) * 100).toFixed(3) + '%'; // a step's share of the cells, so the band follows their width
140
+ const band = sp ? `<span class="bd-spb" style="left:calc(${pc(sp.lo)} + 4px);width:calc(${pc(sp.hi - sp.lo + 1)} - 8px)"></span>` : '';
141
+ const words = sp ? nI + ' ' + plural(nI, 'initiative', 'initiatives') + ', ' + (sp.from === sp.to ? sp.from : sp.from + ' to ' + sp.to) : 'No stage on record';
142
+ // the words sit right of the band, else left of it, else inside it when the band spans nearly every step
143
+ const lab = !sp || sp.hi < N - 3 ? `<span class="bd-spl" style="left:calc(${pc(sp ? sp.hi + 1 : 0)} + 8px)">${esc(words)}</span>`
144
+ : sp.lo >= 3 ? `<span class="bd-spl" style="right:calc(${pc(N - sp.lo)} + 8px)">${esc(words)}</span>` : `<span class="bd-spl" style="left:calc(${pc(sp.lo)} + 14px)">${esc(words)}</span>`;
145
+ const open2 = (st.milestones || []).filter((m) => !m.done).sort((a, b) => String(a.date || '9999').localeCompare(String(b.date || '9999')));
146
+ const nx = open2[0], af = open2[1];
147
+ const late = nx && nx.late;
148
+ const ms = nx ? `<div class="bd-pm${late ? ' late' : ''}"${nx.titles && nx.titles.length ? ` title="${esc('Waits on ' + nx.titles.join(' and ') + ' reaching Deliver')}"` : ''}><i class="bd-dm"></i><b>${esc(nx.name)}</b>${esc(nx.day || '')}${readyHtml(nx, whole(st))}</div>` : '<div class="bd-pm q">No milestone on record</div>';
149
+ const tasks = (st.openTasks || []).length;
150
+ const t3 = [af ? `<i class="bd-dm o"></i>${esc(af.name + (af.day ? ' ' + af.day : ''))}` : '', tasks ? tasks + ' program ' + plural(tasks, 'task', 'tasks') : ''].filter(Boolean).join(' · ');
151
+ const meta = n > 1 ? n + ' products' : st.state;
152
+ return `<div class="bt-r bt-pg" role="row" data-prow="${esc(p.id)}">`
153
+ + `<div class="bt-pgn" role="rowheader"><button type="button" class="bt-pgo" data-prog="${esc(p.id)}" aria-haspopup="dialog" aria-label="${esc(p.title)}, a program: ${esc([meta, words].join(', '))}. Open the program">${progTile()}<span class="tt"><b>${esc(p.title)}</b><span class="m">${esc(meta)}</span></span></button>${yoursHtml(st)}`
154
+ + `<button type="button" class="bd-ib sm bd-fold" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${open ? 'Fold' : 'Show'} ${esc(p.title)}" title="${open ? 'Fold' : 'Show'}">${SV(open ? CHEV_D : CHEV_R)}</button></div>`
155
+ + `<div class="bt-spread" role="cell">${band}${lab}</div>`
156
+ + `<div class="bt-dl" role="cell">${ms}${t3 ? `<div class="t3">${t3}</div>` : ''}</div></div>`;
157
+ }
158
+ /** A product group's head row (PgBoard .prd): the tile, the name and the fold chevron; folded, the count of its initiatives. */
159
+ export function prodHtml(g, cls = 'bt-prd') {
160
+ const open = !folded(g.key), gl = open ? goalsHtml(g.name) : '';
161
+ return `<div class="${cls}${open ? '' : ' closed'}" role="row"><button type="button" class="bd-prdb" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}, ${g.rows.length} ${plural(g.rows.length, 'initiative', 'initiatives')}. ${open ? 'Fold' : 'Show'}">${tileHtml(g.name)}<span>${esc(g.name)}</span>${gl}${open ? '' : `<span class="n">${g.rows.length}</span>`}${SV(open ? CHEV_D : CHEV_R)}</button></div>`;
162
+ }
163
+ /** The goal dots of a product's head (PgBoard .gd), from the same source as Home's product header (pm/home-list.js goalsOf): one per KR or
164
+ * budget its open initiatives anchor to, green on track, amber at risk. With no goal anchored, nothing is drawn. The page sets the rows. */
165
+ let ROWS_OF = null;
166
+ export function goalsFrom(fn) { ROWS_OF = fn; }
167
+ export function goalsHtml(name) {
168
+ const rows = ROWS_OF ? ROWS_OF(name) : null; if (!rows) return '';
169
+ const G = goalsOf({ initiatives: { list: { rows } }, board: { product: name } });
170
+ return G.n ? `<span class="bd-gd" role="img" aria-label="${esc(G.text)}">${G.dots.map((ok) => `<i${ok ? '' : ' class="off"'}></i>`).join('')}</span>` : '';
171
+ }
172
+ /** A program's product sub-row (PgBoard .psb): drawn only when the program shows more than one product here. */
173
+ export const subHtml = (name, cls = 'bt-psb') => `<div class="${cls}" role="row"><span role="rowheader">${tileHtml(name, 'bd-ti s')}${esc(name)}</span></div>`;
174
+ /** The small layers icon on a program member in "By product" (PgBoardProduct .pgi). */
175
+ export const memberIcon = (programs, id) => { const p = (programs || []).find((x) => x.id === id); return p ? `<span class="bd-pgi" role="img" aria-label="In ${esc(p.title)}" title="In ${esc(p.title)}">${SV(PROG)}</span>` : ''; };
176
+
177
+ /** A Kanban swimlane's head (PgKanban .lh): a program's tile, title, your count and its next milestones merged into one counted diamond with
178
+ * the readiness of the first; a product's tile and name. Both fold with the chevron; the program's title opens the program. */
179
+ export function laneHtml(g, st) {
180
+ const open = !folded(g.key);
181
+ const fb = (label) => `<button type="button" class="bd-ib sm bd-fold" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${open ? 'Fold' : 'Show'} ${esc(label)}" title="${open ? 'Fold' : 'Show'}">${SV(open ? CHEV_D : CHEV_R)}</button>`;
182
+ if (g.kind !== 'program') return `<button type="button" class="bd-lho" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}, ${g.rows.length} ${plural(g.rows.length, 'initiative', 'initiatives')}. ${open ? 'Fold' : 'Show'}">${tileHtml(g.name)}<span>${esc(g.name)}</span></button><span class="bd-sp"></span>${open ? goalsHtml(g.name) : ''}${fb(g.name)}`;
183
+ const p = g.program, c = nextCluster(st);
184
+ const ms = c ? `<span class="bd-pm2${c.late ? ' late' : ''}" title="${esc(c.items.map((m) => m.name + (m.day ? ' ' + m.day : '')).join(' · '))}"><i class="bd-dm"></i><b>${esc(c.label)}</b>${esc(c.range)}${readyHtml(c.first, whole(st))}</span>` : '';
185
+ return `<button type="button" class="bd-lho" data-prog="${esc(p.id)}" aria-haspopup="dialog" aria-label="${esc(p.title)}, a program. Open the program">${progTile()}<span>${esc(p.title)}</span></button>${yoursHtml(st)}<span class="bd-sp"></span>${ms}${fb(p.title)}`;
186
+ }
187
+ /** The fold chevron of a group head that also opens something (a program's title): its own small button. */
188
+ export function foldBtn(key, label) {
189
+ const open = !folded(key);
190
+ return `<button type="button" class="bd-ib sm bd-fold" data-fold="${esc(key)}" aria-expanded="${open}" aria-label="${open ? 'Fold' : 'Show'} ${esc(label)}" title="${open ? 'Fold' : 'Show'}">${SV(open ? CHEV_D : CHEV_R)}</button>`;
191
+ }
@@ -12,6 +12,7 @@
12
12
  * wait on the Commit, and "after <initiative>" where a dependency is not done. A bar is drawn only from dates a record holds. Pure: rows and the
13
13
  * model in, markup out. */
14
14
  import { esc } from './premium-shell.js';
15
+ import { mergeClose } from './program-model.js';
15
16
 
16
17
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
17
18
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
@@ -80,11 +81,15 @@ function qBar(r, X, now, phone) {
80
81
  let out = marks(r, X, now, phone);
81
82
  if (s && e) {
82
83
  const l = X(s), w = Math.max(0.8, X(e) - l);
83
- out += `<span class="tg-bar t-${tone}${r.track && r.track.ms ? ' ms' : ''}" style="left:${P(l)};width:${P(w)}" title="PMOS plan ${esc(md(s))} to ${esc(md(e))}"><b style="width:${doneOf(r).toFixed(1)}%"></b></span>`;
84
+ out += `<span class="tg-bar t-${tone}" style="left:${P(l)};width:${P(w)}" title="PMOS plan ${esc(md(s))} to ${esc(md(e))}"><b style="width:${doneOf(r).toFixed(1)}%"></b></span>`;
84
85
  const over = r.over && now > e, late = fc && fc > e, words = [];
85
86
  if (over) { out += `<span class="tg-over" style="left:${P(X(e))};width:${P(Math.max(0.5, X(now) - X(e)))}"></span>`; words.push(r.overDays + ' ' + (r.overDays === 1 ? 'day' : 'days') + ' over'); }
86
87
  if (late) { out += `<span class="tg-fc" style="left:${P(X(e))};width:${P(X(fc) - X(e))}" title="Jira forecast ${esc(md(fc))}"></span>`; words.push('Jira forecast ' + md(fc)); }
87
- if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc(words.join(' · '))}</span>`;
88
+ // the committed end is the Deliver or Evaluate ◇ (PgTimeline), with its date right of it; filled while the initiative is at that milestone
89
+ const inW = X(e) > 0 && X(e) < 100;
90
+ if (inW) out += `<i class="tg-end${r.track && r.track.ms ? ' ms' : ''}${over ? ' late' : ''}" style="left:${P(X(e))}" title="${esc((r.track && r.track.k >= 6 ? 'Committed evaluation date ' : 'Committed delivery date ') + md(e))}"></i>`;
91
+ if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc((inW ? md(e) + ' · ' : '') + words.join(' · '))}</span>`;
92
+ else if (inW && !phone) out += `<span class="tg-endl${X(e) > 94 ? ' l' : ''}" style="left:${P(X(e))}">${esc(md(e))}</span>`;
88
93
  } else if (fc) {
89
94
  out += `<span class="tg-fc solo" style="left:${P(Math.max(0, X(fc) - 3))};width:3%" title="Jira forecast ${esc(md(fc))}"></span>${phone ? '' : `<span class="tg-lab fc" style="left:${P(X(fc))}">Jira forecast ${esc(md(fc))}</span>`}`;
90
95
  } else {
@@ -115,6 +120,10 @@ function overlay(W, X, now, sprint, rel) {
115
120
  return tl + band + rl + tn;
116
121
  }
117
122
 
123
+ /** The legend (PgTimeline), in the chip row at Quarter: done, planned, the Jira forecast, a program milestone where a program is
124
+ * drawn, Deliver or Evaluate, today. */
125
+ export const legendHtml = (prog) => `<span class="tg-lgd" role="group" aria-label="Legend"><span><i class="k dn"></i>Done in Jira</span><span><i class="k pl"></i>Planned</span><span><i class="k fc"></i>Jira forecast</span>${prog ? '<span><i class="k pdm"></i>Program milestone</span>' : ''}<span><i class="k dlv"></i>Deliver or Evaluate</span><span><i class="k td"></i>Today</span></span>`;
126
+
118
127
  /** The quarter's markup. o: { now, phone, sel, status(r) → { tone, text }, hiddenCount, askHref } */
119
128
  function quarter(rows, M, o) {
120
129
  const now = o.now, sprint = M.jira && M.jira.sprint, rel = M.jira && M.jira.release;
@@ -131,13 +140,59 @@ function quarter(rows, M, o) {
131
140
  return { html: `<div class="tgp" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tgp-b">${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${foot}</div>${below}`, none };
132
141
  }
133
142
  const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>Initiative</b></button><div class="tg-p">${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b></span>`).join('')}</div></div>`;
134
- const lgd = '<div class="tg-lgd" aria-hidden="true"><span><i class="k dn"></i>done in Jira (points)</span><span><i class="k pl"></i>PMOS plan</span><span><i class="k fc"></i>Jira forecast</span></div>';
135
- const body = list.map((r) => `<div class="tg-r${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}"><b>${esc(r.title)}</b><small>${esc([r.owner, r.track ? r.track.label : r.stage].filter(Boolean).join(' · '))}</small></button><div class="tg-p">${ov}${qBar(r, X, now, false)}</div></div>`).join('');
143
+ // one line per initiative (PgTimeline): its status dot and its name; the owner and the step stay in the row's title for a pointer and a reader
144
+ const one = (r, cls) => { const s = o.status(r), sub = [r.owner, r.track ? r.track.label : r.stage, s.text].filter(Boolean).join(' · ');
145
+ return `<div class="tg-r${cls || ''}${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}" title="${esc(sub)}" aria-label="${esc(r.title + ', ' + sub)}"><i class="cz-dot ${toneOf(r)}${toneOf(r) === 'you' ? ' m-info' : toneOf(r) === 'late' || toneOf(r) === 'risk' ? ' m-warn' : ''}" aria-hidden="true"></i><b>${r.inProgram && o.memberIcon ? o.memberIcon(r.inProgram) : ''}${esc(r.title)}</b></button><div class="tg-p">${ov}${qBar(r, X, now, false)}</div></div>`; };
146
+ // programs first, then the product (PgTimeline): the program's row brackets its initiatives' bars and draws its milestones as diamonds
147
+ const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.map((x) => ({ ...x, rows: x.rows.filter((r) => list.includes(r)) })).filter((x) => x.rows.length), rows: g.rows.filter((r) => list.includes(r)) } : { ...g, rows: g.rows.filter((r) => list.includes(r)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
148
+ const body = G ? G.map((g) => {
149
+ if (g.kind !== 'program') return o.prodHtml(g) + (o.folded(g.key) ? '' : g.rows.map((r) => one(r, ' tg-gr')).join(''));
150
+ const last = g.rows[g.rows.length - 1];
151
+ return progRow(g, o.progState(g.program), X, W, ov, o) + (o.folded(g.key) ? '' : g.products.map((x) => (g.products.length > 1 ? o.subHtml(x.name) : '') + x.rows.map((r) => one(r, ' tg-kid' + (r === last ? ' last' : ''))).join('')).join(''));
152
+ }).join('') : list.map((r) => one(r)).join('');
136
153
  const axis = `<div class="tg-ax"><span></span><div class="tg-p">${now > W.from && now < W.to ? `<span class="tg-axl td" style="left:${P(X(now))}">Today</span>` : ''}${sa && sb && sb > W.from && sa < W.to ? `<span class="tg-axl sb" style="left:${P(X(sa))}">Jira ${esc(sprint.name.toLowerCase())} · ${esc(md(sa))} – ${esc(md(sb))}</span>` : ''}${ra && ra > W.from && ra < W.to ? `<span class="tg-axl rl" style="left:${P(X(ra))}">${SV(FLAG)}${esc(rel.name)} · ${esc(md(ra))}</span>` : ''}</div></div>`;
137
154
  const foot = `<div class="tg-ft">${none.length ? `<span class="tg-none"><b>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates:</b> <span>${esc(none.slice(0, 4).map((r) => r.title).join(', '))}${none.length > 4 ? ' and ' + (none.length - 4) + ' more' : ''}</span>${askBtn}</span>` : '<span></span>'}${o.hiddenCount ? `<span class="tg-hid">Monitor and Evaluate hidden · ${o.hiddenCount}</span>` : ''}</div>`;
138
- return { html: `<div class="tg tg-q" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tg-body">${lgd}${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${axis}${foot}</div>`, none };
155
+ return { html: `<div class="tg tg-q" data-span="${o.span === 'sprint' ? 'sprint' : 'quarter'}">${head}<div class="tg-body">${body || '<p class="tg-empty">No initiative on screen has a date on record.</p>'}</div>${axis}${foot}</div>`, none };
139
156
  }
140
157
 
158
+ /** A program's row on the quarter (PgTimeline .r.pg): its tile, title and products; a thin span from the first start to the last end of its
159
+ * initiatives' dates on record; its milestones in the window as diamonds (filled once done, open while ahead, amber when late), the ones
160
+ * within a week of each other merged into one counted diamond (pm/program-model.js mergeClose) whose label reads "Pilot live +2 · Nov 18–21".
161
+ * The title opens the program (bd:program); a counted diamond names its milestones in its label and its title. */
162
+ function progRow(g, st, X, W, ov, o) {
163
+ const p = g.program, sp = progSpan(g);
164
+ const br = sp && sp.hi > W.from && sp.lo < W.to ? `<span class="tg-span" style="left:${P(X(sp.lo))};width:${P(Math.max(0.8, X(sp.hi) - X(sp.lo)))}"></span>` : '';
165
+ return `<div class="tg-r tg-pg" data-prow="${esc(p.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${ov}${br}${progMarks(g, st, X, W, 7)}</div></div>`;
166
+ }
167
+ /** The first start and the last end of a program's initiatives' dates on record (its own start and target where the charter holds them). */
168
+ function progSpan(g, own) {
169
+ const p = g.program, ds = g.rows.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast)]).filter(Boolean);
170
+ if (own) { const a = day(p.start), b = day(p.target); if (a) ds.push(a); if (b) ds.push(b); }
171
+ return ds.length ? { lo: new Date(Math.min(...ds)), hi: new Date(Math.max(...ds)) } : null;
172
+ }
173
+ /** A program's milestones in the window as diamonds (filled once done, open while ahead, amber when late); the ones within `days` of each
174
+ * other merge into one counted diamond (pm/program-model.js mergeClose) whose label reads "Pilot live +2 · Nov 18–21". A counted diamond
175
+ * opens the program and names its milestones in its label and its title. The long spans merge over a longer reach: a week is a hair there. */
176
+ function progMarks(g, st, X, W, days) {
177
+ // the reach: about a label's width (160 of ~1100 px) in the window's days, at least a week (the quarter's rule, PgTimeline)
178
+ if (days == null) days = Math.max(7, Math.round(((W.to - W.from) / 86400000) * 0.145));
179
+ const p = g.program, inW = (m) => { const d = day(m.date); return d && d >= W.from && d <= W.to; };
180
+ return mergeClose((st.milestones || []).filter(inW), days).map((c) => {
181
+ const x = P(X(day(c.date))), tone = c.late ? ' late' : c.done ? '' : ' o', names = c.items.map((m) => m.name + (m.day ? ' ' + m.day : '')).join(' · ');
182
+ const mark = c.n > 1
183
+ ? `<button type="button" class="tg-clu${c.late ? ' late' : ''}" data-prog="${esc(p.id)}" style="left:${x}" aria-label="${esc(c.n + ' program milestones from ' + c.range.replace('–', ' to ') + ': ' + c.items.map((m) => m.name).join(', ') + '. Open the program')}" title="${esc(names)}"><b aria-hidden="true">${c.n}</b></button>`
184
+ : `<span class="tg-pdm${tone}" style="left:${x}" title="${esc(names + (c.first.titles && c.first.titles.length ? ' · waits on ' + c.first.titles.join(', ') : ''))}"></span>`;
185
+ return mark + `<span class="tg-pdl${c.late ? ' late' : ''}" style="left:${x}">${esc(c.label)}${c.n > 1 ? ' · ' + esc(c.range) : ' ' + esc(c.range)}</span>`;
186
+ }).join('');
187
+ }
188
+ /** A program's name cell: the tile, the title and its products (or its state), the fold; the title opens the program (bd:program). */
189
+ function progName(g, st, o) {
190
+ const p = g.program, n = o.productsOf ? o.productsOf(p) : 0;
191
+ return `<button type="button" class="tg-pgo" data-prog="${esc(p.id)}" aria-haspopup="dialog" aria-label="${esc(p.title)}, a program. Open the program">${o.progTile ? o.progTile() : ''}<span class="tt"><b>${esc(p.title)}</b><small>${esc(n > 1 ? n + ' products' : st.state)}</small></span></button>${o.foldBtn ? o.foldBtn(g) : ''}`;
192
+ }
193
+ /** The program groups among the page's groups (programs first, PgTimeline), with their state; [] in By product or with no program here. */
194
+ const progGroups = (o) => (o.groups || []).filter((g) => g.kind === 'program').map((g) => ({ g, st: o.progState ? o.progState(g.program) : { milestones: [], state: '' } }));
195
+
141
196
  /** Sprint (BdSpans): the sprint's working days as columns; per initiative with work in the sprint, its row (the release sign-off ◆, "Push
142
197
  * tickets" ◆ where drafted tickets wait on the Commit) and one row per ticket with its state and who has it. A Jira reading holds no dates per
143
198
  * ticket, so a bar runs from the sprint's first day to today; a drafted ticket runs from today to the sprint's end, dashed. The backlog row counts
@@ -153,7 +208,7 @@ function sprintSpan(rows, M, o) {
153
208
  const head = `<div class="sp-r sp-h"><div class="sp-n">Initiative and ticket</div><div class="sp-g" style="--n:${n}">${days.map((d) => `<span${same(d, now) ? ' class="td"' : ''}>${WD[d.getDay()]} ${d.getDate()}</span>`).join('')}</div></div>`;
154
209
  // the label sits right of the ◆, or left of it in the last third of the sprint so it stays inside the row
155
210
  const dia = (i, label, cls) => `<i class="sp-dia${cls ? ' ' + cls : ''}" style="left:${at(i + 0.5)}"></i><span class="sp-dl${cls ? ' ' + cls : ''}" style="${i > n * 0.66 ? `right:calc(${P(100 - ((i + 0.5) / n) * 100)} + 14px)` : `left:calc(${at(i + 0.5)} + 14px)`}">${esc(label)}</span>`;
156
- const groups = rows.map((r) => {
211
+ const one = (r) => {
157
212
  const t = r.track || {}, tk = (t.tickets || []).filter((k) => sp && k.sprint === sp.name), dr = ((r.trail && r.trail.drafted) || []).filter((x) => !x.key);
158
213
  if (!tk.length && !dr.length) return '';
159
214
  const ra = r.release && day(r.release.iso), ri = ra ? idx(ra) : -1;
@@ -165,7 +220,18 @@ function sprintSpan(rows, M, o) {
165
220
  }).join('');
166
221
  const drafted = dr.length ? `<div class="sp-r"><span class="sp-n sp-k">${esc(dr.length === 1 ? (dr[0].id || 'A ticket') : (dr[0].id && dr[dr.length - 1].id ? dr[0].id + ' to ' + dr[dr.length - 1].id : dr.length + ' tickets'))} · drafted</span><div class="sp-g sp-t" style="--n:${n}"><span class="sp-b d" style="left:${at(Math.max(0, n - Math.max(3, n - ti)))};width:${at(Math.min(n, Math.max(3, n - ti)))}"><span>Draft · not pushed · waits on your Commit</span></span></div></div>` : '';
167
222
  return ini + tks + drafted;
168
- }).join('');
223
+ };
224
+ // programs first, then each product (PgTimeline's rule on every span): the program's row carries its milestones in the sprint, merged when
225
+ // they sit within two days; a group with nothing in the sprint is left out
226
+ const X = (d) => ((Math.min(n, Math.max(0, idx(d))) + 0.5) / n) * 100;
227
+ const G = o.groups && o.groups.length ? o.groups : null;
228
+ const groups = G ? G.map((g) => {
229
+ const kids = g.kind === 'program' ? g.products.map((x) => { const h = x.rows.map(one).join(''); return h && g.products.length > 1 && o.subHtml ? o.subHtml(x.name) + h : h; }).join('') : g.rows.map(one).join('');
230
+ if (g.kind !== 'program') return kids ? o.prodHtml(g) + (o.folded(g.key) ? '' : kids) : '';
231
+ const st = o.progState ? o.progState(g.program) : { milestones: [], state: '' }, ms = progMarks(g, st, X, W, 2);
232
+ if (!kids && !ms) return '';
233
+ return `<div class="sp-r sp-pg" data-prow="${esc(g.program.id)}"><div class="sp-n tg-pgn">${progName(g, st, o)}</div><div class="sp-g sp-t" style="--n:${n}">${ms}</div></div>` + (o.folded(g.key) ? '' : kids);
234
+ }).join('') : rows.map(one).join('');
169
235
  const bl = (J.backlog || []).length;
170
236
  const back = `<div class="sp-r sp-bk"><span class="sp-n">Backlog · ${bl} not in ${sp ? esc(sp.name) : 'a sprint'}</span><div class="sp-g sp-bkg"><button type="button" class="bd-btn sm" data-backlog${bl ? '' : ' disabled'}>Show backlog</button></div></div>`;
171
237
  const cap = sp ? `${esc(sp.name)} · ${esc(String(days[0] ? days[0].getDate() : ''))} to ${esc(days.length ? days[n - 1].getDate() + ' ' + MON[days[n - 1].getMonth()] : '')} · tickets with who has them` : 'No sprint is in the Jira reading. These are the next two weeks.';
@@ -211,16 +277,25 @@ function releasesOf(rows) {
211
277
  /** Year: themes with their initiatives as bars inside. */
212
278
  function year(rows, o) {
213
279
  const sp = o.span === 'half' ? 'half' : 'year';
214
- const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows, o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
280
+ // programs first (PgTimeline's rule on every span): each program is a row that brackets its initiatives' bars, with its milestones; the
281
+ // rest group by theme, lane or owner as before
282
+ const PG = progGroups(o), inPg = new Set(PG.flatMap((x) => x.g.rows));
283
+ const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows.filter((r) => !inPg.has(r)), o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
215
284
  const tn = now > W.from && now < W.to ? X(now) : null;
216
285
  const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>${T.length} ${T.length === 1 ? G.toLowerCase() : G.toLowerCase() + 's'} · ${rows.length} ${rows.length === 1 ? 'initiative' : 'initiatives'}</small></button><div class="tg-p">${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b>${k.sub ? `<small>${esc(k.sub)}</small>` : ''}</span>`).join('')}</div></div>`;
217
286
  // AgBoardTlYear draws no release line or flag: a release shows as the ◆ at the end of a bar that rides on it
218
287
  const grid = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('') + (tn != null ? `<u class="tg-td" style="left:${P(tn)}"></u>` : '');
219
- const body = T.map((t) => {
220
- const lines = t.rows.filter(dated).map((r) => {
221
- const s = day(r.start) || day(r.end) || day(r.track && r.track.forecast), e = day(r.end) || s, l = X(s), w = Math.max(1.2, X(e) - l), st = o.status(r);
222
- return `<button type="button" class="tg-line" data-key="${esc(r.key)}" aria-label="${esc(r.title)}"><span class="tg-yb${r.track && r.track.ms ? ' ms' : ''}" style="left:${P(l)};width:${P(w)};--tone:${t.tone}"><b style="width:${doneOf(r).toFixed(1)}%"></b><em><i class="cz-dot ${toneOf(r)}"></i><strong>${esc(r.title)}</strong> ${esc([r.track ? r.track.label : '', st.tone === 'late' || st.tone === 'risk' ? st.text.toLowerCase() : ''].filter(Boolean).join(' · '))}</em></span></button>`;
223
- }).join('');
288
+ const line = (r, tone) => {
289
+ const s = day(r.start) || day(r.end) || day(r.track && r.track.forecast), e = day(r.end) || s, l = X(s), w = Math.max(1.2, X(e) - l), st = o.status(r);
290
+ return `<button type="button" class="tg-line" data-key="${esc(r.key)}" aria-label="${esc(r.title)}"><span class="tg-yb${r.track && r.track.ms ? ' ms' : ''}" style="left:${P(l)};width:${P(w)};--tone:${tone}"><b style="width:${doneOf(r).toFixed(1)}%"></b><em><i class="cz-dot ${toneOf(r)}"></i><strong>${esc(r.title)}</strong> ${esc([r.track ? r.track.label : '', st.tone === 'late' || st.tone === 'risk' ? st.text.toLowerCase() : ''].filter(Boolean).join(' · '))}</em></span></button>`;
291
+ };
292
+ const progs = PG.map(({ g, st }) => {
293
+ const sp2 = progSpan(g), br = sp2 && sp2.hi > W.from && sp2.lo < W.to ? `<span class="tg-span tg-ybr" style="left:${P(X(sp2.lo))};width:${P(Math.max(0.8, X(sp2.hi) - X(sp2.lo)))}"></span>` : '';
294
+ const lines = o.folded(g.key) ? '' : g.rows.filter(dated).map((r) => line(r, 'var(--bd-prog)')).join('');
295
+ return `<div class="tg-r tg-th tg-pg" data-prow="${esc(g.program.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p tg-stack">${grid}<div class="tg-pms">${br}${progMarks(g, st, X, W)}</div>${lines}</div></div>`;
296
+ }).join('');
297
+ const body = progs + T.map((t) => {
298
+ const lines = t.rows.filter(dated).map((r) => line(r, t.tone)).join('');
224
299
  return `<div class="tg-r tg-th">${themeCell(t, false)}<div class="tg-p tg-stack">${grid}${lines || '<span class="tg-nod">No dates on record</span>'}</div></div>`;
225
300
  }).join('');
226
301
  const pill = tn != null ? `<span class="tg-today" style="left:calc(230px + (100% - 230px) * ${(tn / 100).toFixed(4)})">Today · ${esc(md(now))}</span>` : '';
@@ -230,11 +305,19 @@ function year(rows, o) {
230
305
  /** 5 yr: themes only, as one phase each from the earliest date on record to the latest; past 18 months is directional (dashed). */
231
306
  function fiveYear(rows, o) {
232
307
  const sp = o.span === 'y2' ? 'y2' : 'y5';
233
- const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows, o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
308
+ const PG = progGroups(o), inPg = new Set(PG.flatMap((x) => x.g.rows)); // programs first, as one phase each; the rest by theme
309
+ const now = o.now, W = windowOf(sp, now), X = pctOf(W), T = themesOf(rows.filter((r) => !inPg.has(r)), o), G = (GROUPS.find((x) => x[0] === (o.group || 'theme')) || GROUPS[0])[1];
234
310
  const far = addMonths(now, 18), fx = X(far), tn = now > W.from && now < W.to ? X(now) : null;
235
311
  const head = `<div class="tg-r tg-h"><button type="button" class="tg-n tg-help" data-rules aria-haspopup="dialog" title="How the timeline groups by span"><b>${G}</b><small>what each ${G.toLowerCase()} is for</small></button><div class="tg-p">${fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : ''}${W.ticks.map((k) => `<span style="left:${P(X(k.at))}"><b>${esc(k.label)}</b><small>${esc(k.sub)}</small></span>`).join('')}</div></div>`;
236
312
  const grid = W.ticks.slice(1).map((k) => `<i class="tg-gl" style="left:${P(X(k.at))}"></i>`).join('') + (fx < 100 ? `<i class="tg-dir" style="left:${P(fx)}"></i>` : '') + (tn != null ? `<u class="tg-td" style="left:${P(tn)}"></u>` : '');
237
- const body = T.map((t) => {
313
+ // a program's phase runs over its own span where the charter holds one (a program can run for years), else over its initiatives' dates
314
+ const progs = PG.map(({ g, st }) => {
315
+ const sp2 = progSpan(g, true), n = g.rows.length;
316
+ const words = n + ' ' + (n === 1 ? 'initiative' : 'initiatives') + (o.productsOf && o.productsOf(g.program) > 1 ? ' · ' + o.productsOf(g.program) + ' products' : '');
317
+ const ph = sp2 ? `<button type="button" class="tg-phase pg${sp2.lo > far ? ' dir' : ''}" data-prog="${esc(g.program.id)}" style="left:${P(X(sp2.lo))};width:${P(Math.max(2, X(sp2.hi) - X(sp2.lo)))};--tone:var(--bd-prog)" aria-haspopup="dialog" aria-label="${esc(g.program.title + ', ' + words + '. Open the program')}"><b>${esc(g.program.title)}</b><small>${esc(words)}</small></button>` : '<span class="tg-nod">No dates on record</span>';
318
+ return `<div class="tg-r tg-th tg-5 tg-pg" data-prow="${esc(g.program.id)}"><div class="tg-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${grid}${ph}<div class="tg-pms">${progMarks(g, st, X, W)}</div></div></div>`;
319
+ }).join('');
320
+ const body = progs + T.map((t) => {
238
321
  const ds = t.rows.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast)]).filter(Boolean).sort((a, b) => a - b);
239
322
  const shipped = t.rows.filter((r) => r.track && r.track.k >= 6).length, planned = t.rows.filter((r) => !r.track || r.track.k < 4).length, active = t.rows.length - shipped - planned;
240
323
  const a = ds[0], b = ds[ds.length - 1];