create-pmos 0.610.0 → 0.612.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 (164) hide show
  1. package/package.json +135 -27
  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-columns-test.js +2 -1
  8. package/workspace/board-deliveries-test.js +2 -1
  9. package/workspace/board-programs-test.js +7 -3
  10. package/workspace/board-publish-ui-test.js +2 -1
  11. package/workspace/board-shared-ui-test.js +2 -1
  12. package/workspace/board-workflows-test.js +2 -1
  13. package/workspace/briefing-premium-board-test.js +3 -2
  14. package/workspace/briefing-premium-calendar-2-test.js +3 -2
  15. package/workspace/briefing-premium-calendar-3-test.js +1 -1
  16. package/workspace/briefing-premium-calendar-test.js +1 -1
  17. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  18. package/workspace/briefing-premium-insights-test.js +4 -3
  19. package/workspace/briefing-premium-test.js +3 -2
  20. package/workspace/calm-timeline-test.js +2 -1
  21. package/workspace/changelog.json +134 -0
  22. package/workspace/core-docs-workflow-test.js +2 -1
  23. package/workspace/ev-everywhere-test.js +3 -2
  24. package/workspace/guide/home.md +2 -2
  25. package/workspace/guide/index.md +4 -0
  26. package/workspace/guide/layout.md +97 -3
  27. package/workspace/guide/programs.md +16 -2
  28. package/workspace/guide/routine.md +65 -0
  29. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  30. package/workspace/guide/settings-and-switches.md +2 -2
  31. package/workspace/impact-screens-test.js +3 -1
  32. package/workspace/ini-workflow-test.js +2 -1
  33. package/workspace/lib/board-premium.js +12 -4
  34. package/workspace/lib/classic-board.js +15 -0
  35. package/workspace/lib/cos-chat.js +1 -0
  36. package/workspace/lib/doc-library.js +43 -12
  37. package/workspace/lib/doc-path.js +30 -0
  38. package/workspace/lib/engine/boards.js +4 -2
  39. package/workspace/lib/events-place.js +368 -0
  40. package/workspace/lib/events-stated.js +129 -0
  41. package/workspace/lib/initiative-chat.js +1 -0
  42. package/workspace/lib/insights-premium.js +13 -1
  43. package/workspace/lib/library-find.js +162 -0
  44. package/workspace/lib/library-items.js +250 -0
  45. package/workspace/lib/notes.js +9 -1
  46. package/workspace/lib/plan-items.js +17 -3
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-artefacts.js +5 -2
  49. package/workspace/lib/routes-boards.js +6 -2
  50. package/workspace/lib/routes-doc-sheet.js +1 -0
  51. package/workspace/lib/routes-events-place.js +203 -0
  52. package/workspace/lib/routes-library.js +155 -0
  53. package/workspace/lib/routes-pop-work.js +39 -0
  54. package/workspace/lib/routes-report-setups.js +32 -1
  55. package/workspace/lib/routes-today-log.js +48 -0
  56. package/workspace/lib/routine-reports.js +84 -0
  57. package/workspace/lib/status-when.js +36 -0
  58. package/workspace/lib/task-items.js +5 -3
  59. package/workspace/lib/today-log.js +131 -0
  60. package/workspace/live-pill-round-test.js +10 -7
  61. package/workspace/metric-drafts-ui-test.js +3 -1
  62. package/workspace/milestone-pins-test.js +2 -1
  63. package/workspace/milestone-suggest-test.js +3 -1
  64. package/workspace/package-lock.json +2 -2
  65. package/workspace/package.json +1 -1
  66. package/workspace/panels-test.js +2 -1
  67. package/workspace/premium-board-actions-test.js +3 -1
  68. package/workspace/premium-rec-tab-test.js +2 -1
  69. package/workspace/premium-vw-backlog-test.js +3 -1
  70. package/workspace/premium-vw-item-test.js +3 -1
  71. package/workspace/premium-vw-jira-test.js +3 -1
  72. package/workspace/premium-vw-meet-test.js +2 -1
  73. package/workspace/premium-vw-notes-test.js +3 -2
  74. package/workspace/product-lane-test.js +2 -1
  75. package/workspace/program-charter-test.js +3 -1
  76. package/workspace/program-leave-test.js +2 -1
  77. package/workspace/program-order-test.js +2 -1
  78. package/workspace/program-panel-test.js +3 -1
  79. package/workspace/public/pm/artefact-kind.js +87 -0
  80. package/workspace/public/pm/bd-ini-panel.js +77 -12
  81. package/workspace/public/pm/bd-prog-panel.js +55 -8
  82. package/workspace/public/pm/bd-span.js +5 -0
  83. package/workspace/public/pm/bd-work.css +192 -0
  84. package/workspace/public/pm/bd-work.js +483 -0
  85. package/workspace/public/pm/cozy-bar.css +11 -0
  86. package/workspace/public/pm/cozy-bar.js +99 -0
  87. package/workspace/public/pm/cozy-day-pick.css +27 -0
  88. package/workspace/public/pm/cozy-day-pick.js +97 -0
  89. package/workspace/public/pm/cozy-ev.css +2 -5
  90. package/workspace/public/pm/cozy-events-view.js +274 -0
  91. package/workspace/public/pm/cozy-events.css +179 -0
  92. package/workspace/public/pm/cozy-events.js +278 -0
  93. package/workspace/public/pm/cozy-evmodel.js +1 -1
  94. package/workspace/public/pm/cozy-goals.css +172 -0
  95. package/workspace/public/pm/cozy-library.css +125 -0
  96. package/workspace/public/pm/cozy-live-pill.js +1 -0
  97. package/workspace/public/pm/cozy-nav.js +6 -7
  98. package/workspace/public/pm/cozy-pick.css +3 -0
  99. package/workspace/public/pm/cozy-pop-work.css +224 -0
  100. package/workspace/public/pm/cozy-pop-work.js +668 -0
  101. package/workspace/public/pm/cozy-popup.css +11 -2
  102. package/workspace/public/pm/cozy-popup.js +67 -9
  103. package/workspace/public/pm/cozy-routine-job.js +203 -0
  104. package/workspace/public/pm/cozy-routine-model.js +219 -0
  105. package/workspace/public/pm/cozy-routine-pop.js +318 -0
  106. package/workspace/public/pm/cozy-routine.css +155 -0
  107. package/workspace/public/pm/cozy-routine.js +335 -0
  108. package/workspace/public/pm/cozy-schedwork.js +6 -5
  109. package/workspace/public/pm/cozy-settings.js +1 -5
  110. package/workspace/public/pm/cozy-status-when.js +48 -0
  111. package/workspace/public/pm/cozy-today-app.js +236 -0
  112. package/workspace/public/pm/cozy-today-model.js +176 -0
  113. package/workspace/public/pm/cozy-today-page.css +100 -0
  114. package/workspace/public/pm/cozy-today-view.js +76 -0
  115. package/workspace/public/pm/cozy-viewer.js +19 -8
  116. package/workspace/public/pm/cozy-vw-mtg.css +39 -0
  117. package/workspace/public/pm/goals-model.js +205 -0
  118. package/workspace/public/pm/goals-open.js +124 -0
  119. package/workspace/public/pm/home-app.js +18 -3
  120. package/workspace/public/pm/home-chat.js +4 -2
  121. package/workspace/public/pm/home-ini.js +43 -10
  122. package/workspace/public/pm/ini-edit.js +3 -1
  123. package/workspace/public/pm/ini-view-model.js +1 -1
  124. package/workspace/public/pm/library-model.js +197 -0
  125. package/workspace/public/pm/library-open.js +37 -0
  126. package/workspace/public/pm/page-chat.js +12 -2
  127. package/workspace/public/pm/pop-work-model.js +493 -0
  128. package/workspace/public/pm/premium-board.js +204 -17
  129. package/workspace/public/pm/premium-goals.js +213 -0
  130. package/workspace/public/pm/premium-library.js +436 -0
  131. package/workspace/public/pm/premium-shell.js +1 -1
  132. package/workspace/public/pm/premium-vw-mtg.js +79 -1
  133. package/workspace/public/pm/scope-chip.js +204 -0
  134. package/workspace/public/premium-board.html +1 -0
  135. package/workspace/public/premium-events.html +44 -0
  136. package/workspace/public/premium-goals.html +37 -0
  137. package/workspace/public/premium-library.html +39 -0
  138. package/workspace/public/premium-routine.html +33 -0
  139. package/workspace/public/today.html +50 -0
  140. package/workspace/ready-dash-ui-test.js +3 -1
  141. package/workspace/rename-test.js +2 -1
  142. package/workspace/run-tests.js +4 -1
  143. package/workspace/server.js +4 -2
  144. package/workspace/sort-order-test.js +2 -1
  145. package/workspace/split-merge-ui-test.js +3 -1
  146. package/workspace/stage-card-tasks-test.js +3 -1
  147. package/workspace/stage-card-test.js +2 -1
  148. package/workspace/task-delete-test.js +2 -1
  149. package/workspace/task-links-test.js +2 -1
  150. package/workspace/task-milestones-test.js +4 -2
  151. package/workspace/task-plans-test.js +3 -1
  152. package/workspace/task-press-test.js +3 -1
  153. package/workspace/task-views-test.js +3 -1
  154. package/workspace/test-lists/doc-path.json +9 -0
  155. package/workspace/test-lists/events-place.json +11 -0
  156. package/workspace/test-lists/goals-place.json +9 -0
  157. package/workspace/test-lists/library-place.json +9 -0
  158. package/workspace/test-lists/pop-work.json +9 -0
  159. package/workspace/test-lists/routine-place.json +9 -0
  160. package/workspace/test-lists/status-when.json +9 -0
  161. package/workspace/test-lists/today-log.json +9 -0
  162. package/workspace/test-lists/work-view.json +9 -0
  163. package/workspace/timeline-holds-test.js +3 -1
  164. package/workspace/tk-tasks-test.js +2 -1
@@ -0,0 +1,27 @@
1
+ /* pm/day-pick.css — the app's own day field and its small calendar (pm/cozy-day-pick.js), and the "When did this happen?" line (pm/cozy-status-when.js) */
2
+ .dp { display: flex; flex-direction: column; gap: 4px; }
3
+ .dp-box { position: relative; display: block; }
4
+ .hi-field .dp-in { padding-right: 44px; }
5
+ .dp-box .dp-tg { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
6
+ .dp-tg, .dp-nav { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--cz-ink2); cursor: pointer; }
7
+ .dp-tg:hover, .dp-nav:hover, .dp-tg[aria-expanded="true"] { background: var(--cz-well); color: var(--cz-ink); }
8
+ .dp-msg { margin: 2px 0 0; color: var(--cz-late); }
9
+ .dp-cal { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; width: 224px; }
10
+ .dp-mh { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-meta); }
11
+ .dp-mh b { font-weight: var(--fw-strong); color: var(--cz-ink); }
12
+ .dp-wk, .dp-row { display: grid; grid-template-columns: repeat(7, 32px); }
13
+ .dp-wk i { font-style: normal; text-align: center; font-size: var(--fs-meta); color: var(--cz-ink3); padding: 2px 0; }
14
+ .dp-d { height: 28px; border: 0; border-radius: 6px; background: none; font: inherit; font-size: var(--fs-meta); color: var(--cz-ink); cursor: pointer; font-variant-numeric: tabular-nums; }
15
+ .dp-d:hover:not(:disabled) { background: var(--cz-well); }
16
+ .dp-d.out { color: var(--cz-ink3); }
17
+ .dp-d.td { box-shadow: 0 0 0 1px var(--cz-blue) inset; }
18
+ .dp-d.on { background: var(--cz-blue); color: var(--cz-onsolid); font-weight: var(--fw-strong); }
19
+ .dp-d:disabled { color: var(--cz-hair); cursor: default; }
20
+ .sw { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--cz-hair); }
21
+ .sw-q { margin: 0 0 6px; font-size: var(--fs-meta); color: var(--cz-ink2); }
22
+ .sw-ch { display: flex; flex-wrap: wrap; gap: 6px; }
23
+ .sw-b { border: 0; border-radius: 999px; background: var(--cz-card); box-shadow: 0 0 0 1px var(--cz-hair) inset; font: inherit; font-size: var(--fs-meta); color: var(--cz-ink); padding: 4px 11px; cursor: pointer; white-space: nowrap; }
24
+ .sw-b:hover { background: var(--cz-well); }
25
+ .sw-b[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--cz-blue) inset; font-weight: var(--fw-strong); }
26
+ .sw-day:not(:empty) { margin-top: 8px; }
27
+ .pw-dp + .pw-dp { margin-top: 8px; }
@@ -0,0 +1,97 @@
1
+ /* pm/cozy-day-pick.js — one day field in the app's own form, "15 Oct 2026", with a small month calendar under it (popup round 3: the browser's
2
+ * own date field shows 10/15/2026, month first, which a reader outside the US reads wrong). Pure helpers and one mount; the look is in
3
+ * cozy-day-pick.css.
4
+ *
5
+ * dayText(iso) → "15 Oct 2026" ('' when not a day)
6
+ * parseDay(text, today) → 'YYYY-MM-DD' or null: "15 Oct 2026", "15 oct", "Oct 15 2026", "2026-10-15", "15/10/2026" (day first)
7
+ * monthGrid(iso, o) → { title, weeks: [[{ iso, n, out, off, on, today }]] } for the month of iso; o: { value, min, max, today }
8
+ * mountDay(el, o) draws the field into el. o: { label, value, min, max, today, onPick(iso), open } — onPick runs on Enter, on a
9
+ * change of the field, and on a press in the calendar. A day outside min..max is refused in plain words.
10
+ * Its own presses stop at its root, so a popup's click handler around it does not see them. */
11
+ const CSS = new URL('./cozy-day-pick.css', import.meta.url).href;
12
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l); }
13
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
14
+ const FULL = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
15
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
16
+ const ms = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
17
+ const iso = (n) => new Date(n).toISOString().slice(0, 10);
18
+ const valid = (y, m, d) => { const n = Date.UTC(y, m, d), t = new Date(n); return t.getUTCFullYear() === y && t.getUTCMonth() === m && t.getUTCDate() === d ? iso(n) : null; };
19
+ export const localToday = () => { const d = new Date(); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
20
+
21
+ export function dayText(v) { const n = ms(v); if (n == null) return ''; const d = new Date(n); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()] + ' ' + d.getUTCFullYear(); }
22
+
23
+ export function parseDay(text, today = localToday()) {
24
+ const s = String(text || '').trim().toLowerCase().replace(/,/g, ' ').replace(/\s+/g, ' ');
25
+ if (!s) return null;
26
+ let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
27
+ if (m) return valid(+m[1], +m[2] - 1, +m[3]);
28
+ m = /^(\d{1,2})[/.](\d{1,2})[/.](\d{4})$/.exec(s); // day first, the app's order
29
+ if (m) return valid(+m[3], +m[2] - 1, +m[1]);
30
+ const mon = (w) => MON.findIndex((x) => w.startsWith(x.toLowerCase()));
31
+ const y0 = +String(today).slice(0, 4);
32
+ m = /^(\d{1,2}) ([a-z]+)(?: (\d{4}))?$/.exec(s);
33
+ if (m && mon(m[2]) >= 0) return valid(m[3] ? +m[3] : y0, mon(m[2]), +m[1]);
34
+ m = /^([a-z]+) (\d{1,2})(?: (\d{4}))?$/.exec(s);
35
+ if (m && mon(m[1]) >= 0) return valid(m[3] ? +m[3] : y0, mon(m[1]), +m[2]);
36
+ return null;
37
+ }
38
+
39
+ export function monthGrid(at, o = {}) {
40
+ const n = ms(at) ?? ms(o.today) ?? ms(localToday()), d = new Date(n), y = d.getUTCFullYear(), m = d.getUTCMonth();
41
+ const first = Date.UTC(y, m, 1), lead = (new Date(first).getUTCDay() + 6) % 7; // weeks start on Monday
42
+ const weeks = []; let cur = first - lead * 864e5;
43
+ for (let w = 0; w < 6; w++) {
44
+ const row = [];
45
+ for (let k = 0; k < 7; k++, cur += 864e5) {
46
+ const v = iso(cur);
47
+ row.push({ iso: v, n: new Date(cur).getUTCDate(), out: new Date(cur).getUTCMonth() !== m, off: (o.min && v < o.min) || (o.max && v > o.max) || false, on: v === o.value, today: v === o.today });
48
+ }
49
+ weeks.push(row);
50
+ if (new Date(cur).getUTCMonth() !== m) break;
51
+ }
52
+ return { title: FULL[m] + ' ' + y, y, m, weeks };
53
+ }
54
+
55
+ const CAL = 'M7 3v3M17 3v3M4 8h16M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z';
56
+ const ARR = { prev: 'M14 7l-5 5 5 5', next: 'M10 7l5 5-5 5' };
57
+ const svg = (d) => `<svg aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
58
+
59
+ export function mountDay(el, o = {}) {
60
+ const today = o.today || localToday();
61
+ let value = ms(o.value) != null ? o.value : '', shown = value || (o.max && today > o.max ? o.max : today), open = !!o.open;
62
+ const say = (t) => { const p = el.querySelector('.dp-msg'); if (p) { p.textContent = t || ''; p.hidden = !t; } };
63
+ const limit = (v) => (o.min && v < o.min ? 'Pick ' + dayText(o.min) + ' or later.' : o.max && v > o.max ? (o.max === today ? 'Not a day in the future.' : 'Pick ' + dayText(o.max) + ' or earlier.') : '');
64
+ const pick = (v) => { const why = limit(v); if (why) { say(why); return; } value = v; shown = v; say(''); draw(); if (o.onPick) o.onPick(v); };
65
+ const grid = () => {
66
+ const G = monthGrid(shown, { value, min: o.min, max: o.max, today });
67
+ return `<div class="dp-cal" role="group" aria-label="${esc(G.title)}"><div class="dp-mh"><button type="button" class="dp-nav" data-dp-step="-1" aria-label="Previous month">${svg(ARR.prev)}</button><b>${esc(G.title)}</b><button type="button" class="dp-nav" data-dp-step="1" aria-label="Next month">${svg(ARR.next)}</button></div>`
68
+ + '<div class="dp-wk" aria-hidden="true"><i>M</i><i>T</i><i>W</i><i>T</i><i>F</i><i>S</i><i>S</i></div>'
69
+ + G.weeks.map((w) => '<div class="dp-row">' + w.map((c) => `<button type="button" class="dp-d${c.out ? ' out' : ''}${c.on ? ' on' : ''}${c.today ? ' td' : ''}" data-dp-day="${c.iso}"${c.off ? ' disabled' : ''} aria-pressed="${c.on}" aria-label="${esc(dayText(c.iso))}">${c.n}</button>`).join('') + '</div>').join('') + '</div>';
70
+ };
71
+ const draw = () => {
72
+ const f = el.querySelector('.dp-in'), had = f && document.activeElement === f;
73
+ el.innerHTML = `<label class="hi-field dp"><span>${esc(o.label || 'Date')}</span><span class="dp-box"><input class="dp-in" type="text" inputmode="text" autocomplete="off" placeholder="15 Oct 2026" value="${esc(dayText(value))}"><button type="button" class="dp-tg" data-dp-open aria-expanded="${open}" aria-label="Calendar">${svg(CAL)}</button></span></label>`
74
+ + '<p class="hi-small dp-msg" role="status" hidden></p>' + (open ? grid() : '');
75
+ const inp = el.querySelector('.dp-in');
76
+ const take = () => { const t = inp.value.trim(); if (!t || t === dayText(value)) return; const v = parseDay(t, today); if (!v) { say('Write a day like 15 Oct 2026.'); return; } pick(v); };
77
+ inp.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); take(); } });
78
+ inp.addEventListener('change', take);
79
+ if (had) inp.focus();
80
+ fit();
81
+ };
82
+ // a popup that grew (the calendar opened) moves up to stay inside the window (pm/hi-pop.js places it once, by two custom properties)
83
+ const fit = () => {
84
+ const pop = el.closest('.hi-pop:not(.sheet)'); if (!pop) return;
85
+ const r = pop.getBoundingClientRect();
86
+ if (r.bottom > innerHeight - 12) pop.style.setProperty('--hi-y', Math.round(Math.max(12, innerHeight - 12 - r.height)) + 'px');
87
+ };
88
+ el.addEventListener('click', (e) => {
89
+ const b = e.target.closest('button'); if (!b || !el.contains(b)) return;
90
+ e.stopPropagation();
91
+ if ('dpOpen' in b.dataset) { open = !open; draw(); return; }
92
+ if (b.dataset.dpStep) { const d = new Date(ms(shown)); shown = iso(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + +b.dataset.dpStep, 1)); draw(); el.querySelector(`[data-dp-step="${b.dataset.dpStep}"]`)?.focus(); return; }
93
+ if (b.dataset.dpDay && !b.disabled) pick(b.dataset.dpDay);
94
+ });
95
+ draw();
96
+ return { get value() { return value; }, focus() { el.querySelector('.dp-in')?.focus(); } };
97
+ }
@@ -268,10 +268,6 @@
268
268
  .ev-st .ev-seg button { min-height: 40px; }
269
269
  }
270
270
 
271
- /* ── Settings › Viewer opens as Popup: the Viewer floats over the page instead of taking a column ── */
272
- @media (min-width: 761px) {
273
- body.ev-vw-popup .cz-vw:not(.cz-vw-float) { position: fixed; z-index: 70; top: 16px; right: 16px; bottom: 16px; width: min(500px, calc(100vw - 32px)); box-shadow: var(--cz-sheet); }
274
- }
275
271
  .cz .ev-ad-hd { display: flex; align-items: center; gap: 12px; padding: 4px 4px 10px; }
276
272
  .cz .ev-sp-ad { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
277
273
  .cz .ev-sp-ad p { margin: 0; }
@@ -436,6 +432,7 @@
436
432
  * job's page like the Claude app's scheduled task: Active, Next run, Repeats in one card, PMOS's ✦ rhythm, History, ▶ Read now */
437
433
  .ev-st .ev-sw-ic { color: var(--cz-ink3); display: inline-flex; flex: none; }
438
434
  .ev-st .ev-sw-entry .ev-sw-ic { margin-left: -16px; }
435
+ .ev-st a.ev-sw-entry { color: inherit; text-decoration: none; }
439
436
  .ev-st .ev-sw-grp { padding: 14px 0 4px; }
440
437
  .ev-st .ev-sw-what { margin: 0 0 10px; }
441
438
  .ev-st .ev-sw-warn { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 10px; }
@@ -490,7 +487,7 @@
490
487
  /* the round Live button and its list, until the popup's chat holds the sessions: at the foot of the rail, above the chat icon */
491
488
  body.cz-railon .cz-fabw .cz-live { position: fixed; left: 26px; bottom: 228px; visibility: visible !important; } /* the rail is never a menu that covers it */
492
489
  body.cz-railon .cz-fabw .lv-tray:not(.lv-r) { position: fixed; left: calc(var(--cz-railx) - 8px); bottom: 16px; }
493
- body.cz-railon.cz-chatpop .cz-fabw .cz-live { display: none; }
490
+ body.cz-railon.cz-chatpop .cz-fabw .cz-live:not(.lv-away) { display: none; } /* a panel put away keeps it: its row is the only way back */
494
491
  /* the pages start after the rail */
495
492
  body.cz-railon .hm-desk { left: var(--cz-railx); }
496
493
  body.cz.cz-railon main.cz-panel.stage { margin-left: var(--cz-railx); }
@@ -0,0 +1,274 @@
1
+ /* pm/cozy-events-view.js — the markup of Events (slice 6 of the six-place navigation, initiative events-place; board 2, StEvPlan). PURE: no
2
+ * DOM, no fetch, so a unit test reads it (events-view.test.mjs).
3
+ *
4
+ * groupsOf(items, { show, day }) → { late, today, coming, later } the items the page shows, by group; show = the kinds on; day = one day
5
+ * listHtml(model, o) the left side: Late (with Yes to all; the newest LATE_SHOWN, then one fold line), Today, Coming up, and the
6
+ * later delivery milestones as one fold line. o.open: Set of the folds open ('late', 'later')
7
+ * calHtml(model, o) the full calendar in the left column: Month | Week, a back arrow to the list. o: { view, ym, day, show }
8
+ * rowHtml(x, today, o) one date: the day, its mark (a diamond for a delivery milestone, round for the rest), what and its kind,
9
+ * then what PMOS suggests with ✓ ✕, the act of today, or nothing (a date that needs nothing shows nothing)
10
+ * monthHtml(ym, items, o) the small month: a mark under each day that has a date, today ringed, the day picked filled
11
+ * showHtml(show, { counts, unread }) Show: the six types (TYPES) with their counts as the filter, which is also the key to the marks; a type whose
12
+ * source is not read says so and opens Connectors. countsOf(items, o) · hiddenHtml(items, o): the "Showing …
13
+ * only · N more hidden · Show all" line. visible(items, o): the types on and the chip (o.scopeOk)
14
+ * Round 2: each row's grey line starts with its type word (lineOf); a coming day with BUSY meetings or more is one line that opens them;
15
+ * a date stated in a source opens the line that states it under the row (o.open has 'src:<key>').
16
+ * KINDS · KIND_LABEL · LATE_SHOWN · shiftMonth(ym, n) · weekOf(day)
17
+ * Text from records goes through esc(). Every icon-only button has an aria-label. The words say PMOS. */
18
+
19
+ export const TYPES = ['meeting', 'focus', 'milestone', 'task', 'report', 'deadline'];
20
+ export const KINDS = TYPES; // the filter is by type since round 2
21
+ export const LATE_SHOWN = 5;
22
+ export const BUSY = 3; // a coming day with this many meetings or more shows as one line that opens them
23
+ export const TYPE_WORD = { meeting: 'Meeting', focus: 'Focus time', milestone: 'Milestone', task: 'Task', report: 'Report', deadline: 'Deadline' };
24
+ export const TYPE_LABEL = { meeting: 'Meetings', focus: 'Focus time', milestone: 'Milestones', task: 'Tasks', report: 'Reports', deadline: 'Deadlines' };
25
+ export const KIND_LABEL = TYPE_LABEL;
26
+ const typeOf = (x) => x.type || x.kind;
27
+ /** The grey line: the type word first, then what the model says. */
28
+ export const lineOf = (x) => TYPE_WORD[typeOf(x)] + (x.line ? ' · ' + x.line : '');
29
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
30
+ const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
31
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
32
+
33
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
34
+ const svg = (d, w = 16) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
35
+ export const ICON = {
36
+ yes: 'M5 12.5l4.5 4.5L19 7.5', no: 'M6 6l12 12M18 6L6 18', go: 'M9 6l6 6-6 6', back: 'M15 6l-6 6 6 6', plus: 'M12 5v14M5 12h14',
37
+ lock: 'M7 11V8a5 5 0 0 1 10 0v3M5.5 11h13v9h-13z', date: 'M7 5.5h10a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3v-8a3 3 0 0 1 3-3zM4 10h16M8.5 3.5v4M15.5 3.5v4',
38
+ done: 'M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17M8.5 12.2l2.4 2.4 4.6-5', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
39
+ };
40
+
41
+ const ms = (d) => Date.parse(String(d).slice(0, 10) + 'T00:00:00Z');
42
+ const between = (a, b) => Math.round((ms(b) - ms(a)) / 86400000);
43
+ const plural = (n, one, many) => (n === 1 ? one : many);
44
+ export function shortDay(d, today) {
45
+ const [y, m, dd] = String(d).slice(0, 10).split('-').map(Number);
46
+ return dd + ' ' + MON[m - 1] + (today && String(y) !== String(today).slice(0, 4) ? ' ' + y : '');
47
+ }
48
+ const weekday = (d) => WD[new Date(ms(d)).getUTCDay()];
49
+
50
+ /** The items the filters let through. o: { show: the types on, scopeOk(item) → bool (the product, program and project chip) } */
51
+ export function visible(items, o = {}) {
52
+ const on = new Set(o.show || TYPES);
53
+ return (items || []).filter((x) => on.has(typeOf(x)) && (!o.scopeOk || o.scopeOk(x)));
54
+ }
55
+ /** The items the page shows, by group. show: the types that are on; day: 'YYYY-MM-DD' to show only that day; scopeOk: the chip. */
56
+ export function groupsOf(items, o = {}) {
57
+ const day = o.day || null;
58
+ const list = visible(items, o).filter((x) => !day || x.date === day);
59
+ const g = (k) => list.filter((x) => x.group === k);
60
+ return { late: g('late'), today: g('today'), coming: g('coming'), later: g('later') };
61
+ }
62
+
63
+ /** The day column: what the date is and how far it is. */
64
+ function dayCell(x, today) {
65
+ if (x.group === 'today' && x.time) return { b: x.time, s: x.until ? 'to ' + x.until : 'Today' };
66
+ if (x.group === 'today') return { b: 'Today', s: weekday(x.date) + ' ' + shortDay(x.date, today) };
67
+ const n = between(today, x.date);
68
+ if (x.group === 'late') return { b: shortDay(x.date, today), s: -n + ' ' + plural(-n, 'day', 'days') + ' late' };
69
+ return { b: shortDay(x.date, today), s: x.time ? weekday(x.date) + ' ' + x.time : 'in ' + n + ' ' + plural(n, 'day', 'days') };
70
+ }
71
+ /** The mark: a diamond for a delivery milestone, round for the rest; the tone says late or at risk. */
72
+ const MARK = { milestone: 'evp-dm', meeting: 'evp-mt', focus: 'evp-fo', task: 'evp-rd', report: 'evp-rp', deadline: 'evp-dl' };
73
+ export const markOf = (type, tone) => `<i class="evp-k ${MARK[type] || 'evp-rd'}${tone ? ' ' + tone : ''}" aria-hidden="true"></i>`;
74
+ export const markHtml = (x) => markOf(typeOf(x), x.tone);
75
+
76
+ /** One date. o: { today, busy: Set<key> of rows whose press is on its way } */
77
+ export function rowHtml(x, o = {}) {
78
+ const today = o.today;
79
+ // a meeting under an opened busy day: only its time, the day row above names the day
80
+ const d = o.child ? { b: x.time || 'All day', s: x.until ? 'to ' + x.until : '' } : dayCell(x, today);
81
+ const kindWord = TYPE_WORD[typeOf(x)];
82
+ const what = `<b>${esc(x.title)}</b><small><em class="evp-ty">${esc(kindWord)}</em>${x.line ? ' · ' + esc(x.line) : ''}</small>`;
83
+ const srcOpen = x.source && o.open && o.open.has('src:' + x.key);
84
+ const t = x.source ? `<button type="button" class="evp-t" data-evp-src aria-expanded="${srcOpen ? 'true' : 'false'}" aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Show what was said">${what}</button>`
85
+ : x.work || x.task || x.own || x.link ? `<button type="button" class="evp-t" data-evp-open aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Open it">${what}</button>` : `<span class="evp-t">${what}</span>`;
86
+ let a = '';
87
+ if (x.suggest) {
88
+ const s = x.suggest;
89
+ a = `<span class="evp-sg"><i class="evp-sp" aria-hidden="true">${svg(ICON.spark, 14)}</i><span title="${esc(s.why || '')}">${esc(s.text)}</span></span>`
90
+ + `<button type="button" class="evp-ib evp-yes" data-evp-yes aria-label="Yes: ${esc(s.text)}" title="Yes">${svg(ICON.yes, 15)}</button>`
91
+ + `<button type="button" class="evp-ib" data-evp-no aria-label="No: ${esc(s.text)}" title="No">${svg(ICON.no, 15)}</button>`;
92
+ } else if (x.act && x.act.href) {
93
+ a = `<a class="evp-go" href="${esc(x.act.href)}">${esc(x.act.label)}${svg(ICON.go, 14)}</a>`;
94
+ } else if (x.group === 'today' && x.kind === 'meeting' && x.work && x.work.title) {
95
+ // a meeting or focus time about a piece of work: one press to that work (no record says more, so PMOS does not name the act)
96
+ a = `<button type="button" class="evp-go" data-evp-open aria-label="Open the work: ${esc(x.work.title)}">Open the work${svg(ICON.go, 14)}</button>`;
97
+ } else if (x.group === 'today' && (x.task || x.own)) {
98
+ a = `<button type="button" class="evp-ib" data-evp-done aria-label="Mark it done: ${esc(x.title)}" title="Mark it done">${svg(ICON.done, 16)}</button>`;
99
+ }
100
+ // the tools show on a row you point at or step to: a new day (edit in place) and Fixed
101
+ const tools = (x.editable && !(x.fixed && x.kind === 'milestone') ? `<label class="evp-ib evp-dt" title="Set a date"><span class="vh">Set a date for ${esc(x.title)}</span>${svg(ICON.date, 15)}<input type="date" data-evp-date value="${esc(x.date)}" /></label>` : '')
102
+ + (x.canFix ? `<button type="button" class="evp-ib evp-fx" data-evp-fix aria-pressed="${x.fixed ? 'true' : 'false'}" aria-label="${x.fixed ? 'Fixed date. Press to let PMOS suggest a new date' : 'Mark as a fixed date'}" title="${x.fixed ? 'Fixed date' : 'Fixed date: never move it'}">${svg(ICON.lock, 15)}</button>` : '');
103
+ // a date stated in a source opens the line that states it, under the row: who said it, when, and a link to the source
104
+ // the sentence from the source only when it says more than the title; else who and when, and the link (say it once)
105
+ const said = x.source && x.source.text && x.source.text.trim().toLowerCase() !== String(x.title).trim().toLowerCase() ? `<q>${esc(x.source.text)}</q>` : '';
106
+ const src = srcOpen ? `<div class="evp-src" data-key="${esc(x.key)}">${said}<span>${esc([x.source.who, x.source.said ? shortDay(x.source.said, today) : ''].filter(Boolean).join(', '))}</span>`
107
+ + (x.source.link ? `<a class="evp-go" href="${esc(x.source.link)}" target="_blank" rel="noopener">Open in ${esc(x.source.from)}${svg(ICON.go, 14)}</a>` : '')
108
+ + (x.work ? `<button type="button" class="evp-go" data-evp-open>Open the work${svg(ICON.go, 14)}</button>` : '') + '</div>' : '';
109
+ return `<div class="evp-r${o.child ? ' evp-kid' : ''}${x.fixed ? ' fixed' : ''}${o.busy && o.busy.has(x.key) ? ' busy' : ''}" data-key="${esc(x.key)}" data-kind="${esc(x.kind)}" data-type="${esc(typeOf(x))}" aria-label="${esc(kindWord)}">`
110
+ + `<span class="evp-d ${x.tone || ''}"><b>${esc(d.b)}</b><small>${esc(d.s)}${x.fixed ? ' · fixed' : ''}</small></span>${markHtml(x)}${t}`
111
+ + `<span class="evp-a">${a}</span><span class="evp-tl">${tools}</span></div>${src}`;
112
+ }
113
+
114
+ function groupHtml(key, label, rows, o, head = '', tail = '', n = rows.length, body = null) {
115
+ if (!rows.length) return ''; // zero is silence
116
+ return `<section class="evp-g evp-${key}" aria-label="${esc(label)}"><h2>${esc(label)}<small>${n}</small>${head}</h2><div class="evp-b">${body != null ? body : rows.map((x) => rowHtml(x, o)).join('')}</div>${tail}</section>`;
117
+ }
118
+ const isMeet = (x) => x.kind === 'meeting';
119
+ /** Coming up: a day with BUSY meetings or more is one line, "Fri 20 Nov · 5 meetings", that opens them; every other date keeps its row. */
120
+ function comingBody(rows, o) {
121
+ const per = new Map();
122
+ for (const x of rows) if (isMeet(x)) per.set(x.date, (per.get(x.date) || 0) + 1);
123
+ const open = o.open || new Set();
124
+ const done = new Set();
125
+ let html = '';
126
+ for (const x of rows) {
127
+ const n = per.get(x.date) || 0;
128
+ if (!isMeet(x) || n < BUSY) { html += rowHtml(x, o); continue; }
129
+ if (done.has(x.date)) continue;
130
+ done.add(x.date);
131
+ const k = 'day:' + x.date, isOpen = open.has(k), dayRows = rows.filter((y) => y.date === x.date && isMeet(y));
132
+ const word = dayRows.every((y) => typeOf(y) === 'focus') ? plural(n, 'focus time', 'focus times') : plural(n, 'meeting', 'meetings');
133
+ html += `<button type="button" class="evp-r evp-day" data-evp-fold="${esc(k)}" aria-expanded="${isOpen ? 'true' : 'false'}"><span class="evp-d"><b>${esc(shortDay(x.date, o.today))}</b><small>${esc(weekday(x.date))}</small></span>${markOf('meeting')}<span class="evp-t"><b>${esc(weekday(x.date) + ' ' + shortDay(x.date, o.today))} · ${n} ${word}</b><small>${esc(dayRows.slice(0, 3).map((y) => (y.time ? y.time + ' ' : '') + y.title).join(', ') + (n > 3 ? ', …' : ''))}</small></span><i class="evp-fi" aria-hidden="true">${svg(ICON.go, 14)}</i></button>`;
134
+ if (isOpen) html += dayRows.map((y) => rowHtml(y, { ...o, child: true })).join('');
135
+ }
136
+ return html;
137
+ }
138
+ /** The line over the list when a filter hides dates: "Showing milestones only · 14 more hidden · Show all". o: { show, scopeOk, scopeWords } */
139
+ export function hiddenHtml(items, o = {}) {
140
+ const on = new Set(o.show || TYPES);
141
+ const typesCut = TYPES.some((t) => !on.has(t));
142
+ const scoped = !!(o.scopeOk && o.scopeWords);
143
+ if (!typesCut && !scoped) return '';
144
+ const all = (items || []).filter((x) => x.group !== 'later' || x.kind === 'milestone');
145
+ const shown = visible(all, o).length, hidden = all.length - shown;
146
+ if (!hidden) return '';
147
+ const and = (L) => (L.length > 1 ? L.slice(0, -1).join(', ') + ' and ' + L[L.length - 1] : L[0] || 'nothing');
148
+ const onL = TYPES.filter((t) => on.has(t)).map((t) => TYPE_LABEL[t].toLowerCase()), offL = TYPES.filter((t) => !on.has(t)).map((t) => TYPE_LABEL[t].toLowerCase());
149
+ // few types on: name them ("milestones only"); most on: name what is off ("all but meetings")
150
+ const tw = !typesCut ? (scoped ? 'the dates' : '') : onL.length <= 3 ? and(onL) : 'all but ' + and(offL);
151
+ const what = tw + (scoped ? ' of ' + o.scopeWords : '') + (typesCut && onL.length > 3 ? '' : ' only');
152
+ return `<p class="evp-hid" role="status">Showing ${esc(what)} · ${hidden} more hidden · <button type="button" data-evp-showall>Show all</button></p>`;
153
+ }
154
+ const fold = (key, open, text) => `<button type="button" class="evp-fold" data-evp-fold="${key}" aria-expanded="${open ? 'true' : 'false'}"><i aria-hidden="true">${svg(ICON.go, 14)}</i><span>${text}</span></button>`;
155
+
156
+ /** The left side. model: { today, items, later }; o: { show, day, busy } */
157
+ export function listHtml(model, o = {}) {
158
+ const today = model.today;
159
+ const G = groupsOf(model.items, o);
160
+ const yes = G.late.filter((x) => x.suggest).length;
161
+ const all = yes > 1 ? `<button type="button" class="evp-all" data-evp-all>Yes to all ${yes}</button>` : '';
162
+ const open = o.open || new Set();
163
+ const ro = { today, busy: o.busy, open };
164
+ let later = '';
165
+ const on = new Set(o.show || TYPES);
166
+ if (o.day) {
167
+ later = G.later.length ? groupHtml('later', 'Later', G.later, ro) : '';
168
+ } else if (on.has('milestone') && G.later.some((x) => x.kind === 'milestone')) {
169
+ // the far milestones the filters let through (the chip narrows this line too)
170
+ const far = G.later.filter((x) => x.kind === 'milestone'), n = far.length, nx = far[0];
171
+ const years = [...new Set(far.map((x) => x.date.slice(0, 4)))], year = years.length === 1 && years[0] !== String(today).slice(0, 4) ? years[0] : null;
172
+ later = fold('later', open.has('later'), `${n} ${plural(n, 'delivery milestone', 'delivery milestones')} ${year ? 'in ' + esc(year) : 'after the next 30 days'}. The next is ${esc(year ? shortDay(nx.date) : shortDay(nx.date, today))}: ${esc(nx.title)}`)
173
+ + (open.has('later') && far.length ? `<div class="evp-b evp-far">${far.map((x) => rowHtml(x, ro)).join('')}</div>` : '');
174
+ }
175
+ // Late: the newest first (the model sorts them), LATE_SHOWN of them, then one line that opens the rest
176
+ let lateRows = G.late, lateTail = '';
177
+ if (!o.day && G.late.length > LATE_SHOWN + 1) {
178
+ const rest = G.late.length - LATE_SHOWN, oldest = -between(today, G.late[G.late.length - 1].date);
179
+ if (!open.has('late')) lateRows = G.late.slice(0, LATE_SHOWN);
180
+ lateTail = fold('late', open.has('late'), open.has('late') ? 'Show only the newest ' + LATE_SHOWN : `${rest} more late, the oldest ${oldest} ${plural(oldest, 'day', 'days')}`);
181
+ }
182
+ const body = groupHtml('late', 'Late', lateRows, ro, all, lateTail, G.late.length) + groupHtml('now', 'Today', G.today, ro) + groupHtml('coming', 'Coming up', G.coming, ro, '', '', G.coming.length, o.day ? null : comingBody(G.coming, ro)) + later;
183
+ if (body) return body;
184
+ if (o.day) return `<p class="evp-quiet">Nothing has a date on ${esc(weekday(o.day) + ' ' + shortDay(o.day, today))}.</p>`;
185
+ return '<p class="evp-quiet">Nothing is late, and nothing has a date in the next 30 days.</p>';
186
+ }
187
+
188
+ /** 'YYYY-MM' moved by n months. */
189
+ export function shiftMonth(ym, n) {
190
+ const [y, m] = ym.split('-').map(Number);
191
+ const t = y * 12 + (m - 1) + n;
192
+ return Math.floor(t / 12) + '-' + String((t % 12) + 1).padStart(2, '0');
193
+ }
194
+ /** The small month of ym ('YYYY-MM'), Monday first. o: { today, day, show } */
195
+ export function monthHtml(ym, items, o = {}) {
196
+ const [y, m] = ym.split('-').map(Number);
197
+ const byDay = new Map();
198
+ for (const x of visible(items, o)) { if (!byDay.has(x.date)) byDay.set(x.date, []); byDay.get(x.date).push(x); }
199
+ const first = Date.UTC(y, m - 1, 1);
200
+ const lead = (new Date(first).getUTCDay() + 6) % 7;
201
+ let cells = ['M', 'T', 'W', 'T', 'F', 'S', 'S'].map((d) => `<span class="evp-mh" aria-hidden="true">${d}</span>`).join('');
202
+ for (let i = 0; i < 42; i++) {
203
+ const t = new Date(first + (i - lead) * 86400000);
204
+ const k = t.toISOString().slice(0, 10), out = t.getUTCMonth() !== m - 1;
205
+ const xs = byDay.get(k) || [];
206
+ // one mark per kind and tone, at most three: the day is the map, not the list
207
+ const seen = new Set(), marks = [];
208
+ for (const x of xs) { const sig = typeOf(x) + '|' + (x.tone || ''); if (!seen.has(sig) && marks.length < 3) { seen.add(sig); marks.push(markHtml(x)); } }
209
+ const lab = `${t.getUTCDate()} ${MONTH[t.getUTCMonth()]}${xs.length ? ', ' + xs.length + ' ' + plural(xs.length, 'date', 'dates') : ''}`;
210
+ cells += `<button type="button" class="evp-md${out ? ' out' : ''}${k === o.today ? ' now' : ''}${k === o.day ? ' on' : ''}" data-evp-day="${k}" aria-pressed="${k === o.day ? 'true' : 'false'}" aria-label="${esc(lab)}">${t.getUTCDate()}<em>${marks.join('')}</em></button>`;
211
+ }
212
+ return `<div class="evp-mt-top"><button type="button" class="evp-mn" data-evp-full aria-label="${MONTH[m - 1]} ${y}. Open the full calendar">${MONTH[m - 1]} ${y}</button><button type="button" class="evp-ib" data-evp-month="-1" aria-label="The month before" title="The month before">${svg(ICON.back, 16)}</button><button type="button" class="evp-ib" data-evp-month="1" aria-label="The month after" title="The month after">${svg(ICON.go, 16)}</button></div>`
213
+ + `<div class="evp-mg" role="group" aria-label="${MONTH[m - 1]} ${y}">${cells}</div>`;
214
+ }
215
+
216
+ /** The key: each type with its mark and how many dates it has, each a switch (every type is on until the PM presses it). A type whose
217
+ * source PMOS does not read says so ("Meetings · calendar not connected") and its press opens Settings › Connectors. o: { counts, unread } */
218
+ export function showHtml(show, o = {}) {
219
+ const on = new Set(show || TYPES), counts = o.counts || {}, unread = o.unread || {};
220
+ const rows = TYPES.map((k) => {
221
+ if (unread[k] && !counts[k]) return `<button type="button" class="evp-un" data-evp-connect aria-label="${esc(TYPE_LABEL[k])}: ${esc(unread[k])}. Open Connectors">${markOf(k)}<span>${esc(TYPE_LABEL[k])} · ${esc(unread[k])}</span><span class="evp-on" aria-hidden="true">${svg(ICON.go, 14)}</span></button>`;
222
+ return `<button type="button" data-evp-show="${k}" aria-pressed="${on.has(k) ? 'true' : 'false'}">${markOf(k)}${esc(TYPE_LABEL[k])}${counts[k] ? `<small>${counts[k]}</small>` : ''}<span class="evp-on" aria-hidden="true">${on.has(k) ? svg(ICON.yes, 14) : ''}</span></button>`;
223
+ });
224
+ return `<h3 class="evp-sh">Show</h3><div class="evp-f" role="group" aria-label="Show">${rows.join('')}</div>`
225
+ + '<div class="evp-key"><span><i class="evp-k evp-rd late" aria-hidden="true"></i>Late</span><span><i class="evp-k evp-rd risk" aria-hidden="true"></i>At risk</span></div>';
226
+ }
227
+ /** How many dates of each type the page lists (Late, Today, Coming up and the far milestones), under the chip. */
228
+ export function countsOf(items, o = {}) {
229
+ const c = {};
230
+ for (const x of items || []) { if (x.group === 'later' && x.kind !== 'milestone') continue; if (o.scopeOk && !o.scopeOk(x)) continue; c[typeOf(x)] = (c[typeOf(x)] || 0) + 1; }
231
+ return c;
232
+ }
233
+
234
+ /** The Monday of the week of day ('YYYY-MM-DD'). */
235
+ export function weekOf(day) {
236
+ const t = ms(day);
237
+ return new Date(t - ((new Date(t).getUTCDay() + 6) % 7) * 86400000).toISOString().slice(0, 10);
238
+ }
239
+ const addDays = (d, n) => new Date(ms(d) + n * 86400000).toISOString().slice(0, 10);
240
+ /** One date in a calendar cell: its mark and its title; a press opens it, as a row does. */
241
+ const chipHtml = (x) => `<button type="button" class="evp-cc${x.tone ? ' ' + x.tone : ''}" data-key="${esc(x.key)}" data-evp-open aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Open it">${markHtml(x)}<span>${x.time ? esc(x.time) + ' ' : ''}${esc(x.title)}</span></button>`;
242
+
243
+ /** The full calendar in the left column. model: { today, items }; o: { view: 'month' | 'week', ym, day, show } */
244
+ export function calHtml(model, o = {}) {
245
+ const today = model.today, view = o.view === 'week' ? 'week' : 'month';
246
+ const byDay = new Map();
247
+ for (const x of visible(model.items, o)) { if (!byDay.has(x.date)) byDay.set(x.date, []); byDay.get(x.date).push(x); }
248
+ const seg = `<div class="cz-seg" role="group" aria-label="Calendar view">${['month', 'week'].map((v) => `<button type="button" data-evp-view="${v}" aria-pressed="${v === view ? 'true' : 'false'}">${v === 'month' ? 'Month' : 'Week'}</button>`).join('')}</div>`;
249
+ const back = `<button type="button" class="evp-ib" data-evp-list aria-label="Back to the list" title="Back to the list">${svg(ICON.back, 18)}</button>`;
250
+ const dayBtn = (k, label) => `<button type="button" class="evp-cd${k === today ? ' now' : ''}" data-evp-day="${k}" aria-label="${esc(label)}. See only this day">${new Date(ms(k)).getUTCDate()}</button>`;
251
+ if (view === 'week') {
252
+ const mon = weekOf(o.day || today);
253
+ const cols = [];
254
+ for (let i = 0; i < 7; i++) {
255
+ const k = addDays(mon, i), xs = byDay.get(k) || [];
256
+ cols.push(`<div class="evp-wc${k === today ? ' now' : ''}"><div class="evp-wh"><span>${WD[(i + 1) % 7]}</span>${dayBtn(k, weekday(k) + ' ' + shortDay(k, today))}</div>${xs.map(chipHtml).join('')}</div>`);
257
+ }
258
+ const end = addDays(mon, 6);
259
+ return `<div class="evp-ch">${back}<h2>${esc(shortDay(mon, today))} to ${esc(shortDay(end, today))}</h2><button type="button" class="evp-ib" data-evp-week="-1" aria-label="The week before" title="The week before">${svg(ICON.back, 16)}</button><button type="button" class="evp-ib" data-evp-week="1" aria-label="The week after" title="The week after">${svg(ICON.go, 16)}</button>${seg}</div>`
260
+ + `<div class="evp-wk" role="group" aria-label="The week of ${esc(shortDay(mon, today))}">${cols.join('')}</div>`;
261
+ }
262
+ const ym = o.ym || String(today).slice(0, 7);
263
+ const [y, m] = ym.split('-').map(Number);
264
+ const first = Date.UTC(y, m - 1, 1), lead = (new Date(first).getUTCDay() + 6) % 7;
265
+ let cells = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].map((d) => `<span class="evp-mh" aria-hidden="true">${d}</span>`).join('');
266
+ const len = new Date(Date.UTC(y, m, 0)).getUTCDate(), cellsN = Math.ceil((lead + len) / 7) * 7; // whole weeks, no row of the next month only
267
+ for (let i = 0; i < cellsN; i++) {
268
+ const t = new Date(first + (i - lead) * 86400000), k = t.toISOString().slice(0, 10), xs = byDay.get(k) || [];
269
+ const more = xs.length > 3 ? `<button type="button" class="evp-cm" data-evp-day="${k}">${xs.length - 3} more</button>` : '';
270
+ cells += `<div class="evp-mc${t.getUTCMonth() !== m - 1 ? ' out' : ''}${k === today ? ' now' : ''}">${dayBtn(k, t.getUTCDate() + ' ' + MONTH[t.getUTCMonth()] + (xs.length ? ', ' + xs.length + ' ' + plural(xs.length, 'date', 'dates') : ''))}${xs.slice(0, 3).map(chipHtml).join('')}${more}</div>`;
271
+ }
272
+ return `<div class="evp-ch">${back}<h2>${MONTH[m - 1]} ${y}</h2><button type="button" class="evp-ib" data-evp-month="-1" aria-label="The month before" title="The month before">${svg(ICON.back, 16)}</button><button type="button" class="evp-ib" data-evp-month="1" aria-label="The month after" title="The month after">${svg(ICON.go, 16)}</button>${seg}</div>`
273
+ + `<div class="evp-fm" role="group" aria-label="${MONTH[m - 1]} ${y}">${cells}</div>`;
274
+ }