create-pmos 0.397.0 → 0.398.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -0,0 +1,396 @@
1
+ /* pm/cozy-md.js — markdown for the console3 document sheet (initiative c3-doc-sheet-rich): read it as rich text, edit it as rich
2
+ * text, and show a change as a rendered diff.
3
+ * Moved here from pm/c3-md.js (premium-agreed-design), so premium pages load no c3-* module; c3-md.js re-exports it.
4
+ *
5
+ * parseMd(md) → blocks the subset PMOS documents use: headings, paragraphs, quotes, bulleted, numbered and
6
+ * checklist lists, tables, dividers and fenced code; inline bold, italic, code and links
7
+ * toMd(blocks) → md the canonical markdown of blocks; toMd(parseMd(toMd(b))) === toMd(b)
8
+ * canonMd(md) → md toMd(parseMd(md)): two texts that read the same compare equal
9
+ * diffMd(before, after) → md `after`, with the words removed and added since `before` wrapped in markers that
10
+ * toDom draws as <del> and <ins>; a line or sentence rewritten in most of its words is
11
+ * shown whole, removed then added
12
+ * toDom(blocks, doc?) → Node[] the blocks as elements (no innerHTML: every text is a text node); links are http(s),
13
+ * mailto or relative only
14
+ * fromDom(root) → blocks what the rich-text editor holds, read back as blocks
15
+ *
16
+ * parseMd, toMd, canonMd and diffMd are pure (Node-testable: c3-md.test.js); toDom and fromDom need a document.
17
+ */
18
+
19
+ export const INS = '\uE000';
20
+ export const INS_END = '\uE001';
21
+ export const DEL = '\uE002';
22
+ export const DEL_END = '\uE003';
23
+ const MARK = /[\uE000-\uE003]/g;
24
+
25
+ /* ── inline ── */
26
+
27
+ /** Inline markdown → [{ t:'text', s } | { t:'b'|'i', c:[…] } | { t:'code', s } | { t:'a', href, c:[…] }]. */
28
+ export function parseInline(src) {
29
+ const s = String(src == null ? '' : src);
30
+ const out = [];
31
+ let buf = '';
32
+ const flush = () => { if (buf) { out.push({ t: 'text', s: buf }); buf = ''; } };
33
+ let i = 0;
34
+ while (i < s.length) {
35
+ const c = s[i];
36
+ if (c === '\\' && i + 1 < s.length && /[\\`*_[\]()#|>-]/.test(s[i + 1])) { buf += s[i + 1]; i += 2; continue; }
37
+ if (c === '`') {
38
+ const j = s.indexOf('`', i + 1);
39
+ if (j > i) { flush(); out.push({ t: 'code', s: s.slice(i + 1, j) }); i = j + 1; continue; }
40
+ }
41
+ if (c === '[') {
42
+ const m = /^\[((?:[^\]\\]|\\.)+)\]\(([^)\s]+)\)/.exec(s.slice(i));
43
+ if (m) { flush(); out.push({ t: 'a', href: m[2], c: parseInline(m[1]) }); i += m[0].length; continue; }
44
+ }
45
+ if ((c === '*' || c === '_') && s[i + 1] === c) {
46
+ const j = s.indexOf(c + c, i + 2);
47
+ if (j > i + 2) { flush(); out.push({ t: 'b', c: parseInline(s.slice(i + 2, j)) }); i = j + 2; continue; }
48
+ }
49
+ if ((c === '*' || c === '_') && s[i + 1] !== c && s[i + 1] !== ' ' && (c === '*' || !/\w/.test(s[i - 1] || ''))) {
50
+ let j = i + 1;
51
+ while (j < s.length && !(s[j] === c && s[j + 1] !== c && s[j - 1] !== ' ' && s[j - 1] !== c)) j++;
52
+ if (j < s.length && j > i + 1 && (c === '*' || !/\w/.test(s[j + 1] || ''))) { flush(); out.push({ t: 'i', c: parseInline(s.slice(i + 1, j)) }); i = j + 1; continue; }
53
+ }
54
+ buf += c; i++;
55
+ }
56
+ flush();
57
+ return out;
58
+ }
59
+
60
+ // Text is escaped only where markdown would read it as syntax: a backslash before punctuation, `, *, [ and ], and an _ that
61
+ // is not inside a word (snake_case stays as written).
62
+ const escText = (s) => String(s).replace(/\\(?=[\\`*_[\]()#|>-])/g, '\\\\').replace(/[`*[\]]/g, '\\$&').replace(/(^|\W)_|_(?=\W|$)/g, (m) => m.replace('_', '\\_'));
63
+ /** Inline nodes → markdown. `raw`: text as it is, unescaped (for a plain-text label). */
64
+ export function inlineMd(nodes, raw) {
65
+ return (nodes || []).map((n) => {
66
+ if (n.t === 'text') return raw ? n.s : escText(n.s);
67
+ if (n.t === 'code') return raw ? n.s : '`' + n.s + '`';
68
+ const inner = inlineMd(n.c, raw);
69
+ if (raw || !inner.trim()) return inner;
70
+ const lead = inner.match(/^\s*/)[0]; const tail = inner.match(/\s*$/)[0]; const core = inner.trim();
71
+ if (n.t === 'b') return lead + '**' + core + '**' + tail;
72
+ if (n.t === 'i') return lead + '*' + core + '*' + tail;
73
+ if (n.t === 'a') return lead + '[' + core + '](' + n.href + ')' + tail;
74
+ return inner;
75
+ }).join('');
76
+ }
77
+ // a paragraph or list item whose text would start a heading, quote, list or rule is escaped at its start
78
+ const lineSafe = (s) => s.replace(/^(#{1,6}\s|>|[-+]\s|\d+[.)]\s|-{3,}\s*$)/, '\\$1');
79
+
80
+ /* ── blocks ── */
81
+
82
+ const LIST = /^(\s*)([-*+]|\d+[.)])\s+/;
83
+ const TASK = /^\[( |x|X)\]\s+/;
84
+ const cells = (r) => {
85
+ const t = r.trim().replace(/^\|/, '').replace(/\|\s*$/, '');
86
+ const out = []; let cur = ''; for (let i = 0; i < t.length; i++) { if (t[i] === '\\' && t[i + 1] === '|') { cur += '|'; i++; } else if (t[i] === '|') { out.push(cur.trim()); cur = ''; } else cur += t[i]; }
87
+ out.push(cur.trim()); return out;
88
+ };
89
+ const isRule = (l) => /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(l);
90
+ const startsBlock = (l) => /^(#{1,6}\s|>|```|~~~|\s*(-{3,}|\*{3,}|_{3,})\s*$)/.test(l) || LIST.test(l) || /^\s*\|/.test(l);
91
+
92
+ /** Markdown → blocks: { t:'h', level, c } · { t:'p', c } · { t:'quote', blocks } · { t:'list', ordered, items:[{ task, c }] } ·
93
+ * { t:'table', head:[c], rows:[[c]] } · { t:'hr' } · { t:'code', lang, s }. Marker characters (diffMd) pass through as text. */
94
+ export function parseMd(md) {
95
+ const L = String(md == null ? '' : md).replace(/\r\n?/g, '\n').split('\n');
96
+ const out = []; let i = 0;
97
+ const bare = (l) => l.replace(MARK, '');
98
+ while (i < L.length) {
99
+ const l = L[i]; const b = bare(l); let m;
100
+ if (!b.trim()) { i++; continue; }
101
+ if ((m = /^(```|~~~)\s*([\w-]*)/.exec(b))) {
102
+ const fence = m[1]; const body = []; i++;
103
+ while (i < L.length && !bare(L[i]).startsWith(fence)) body.push(L[i++]);
104
+ i++; out.push({ t: 'code', lang: m[2] || '', s: body.join('\n') }); continue;
105
+ }
106
+ if ((m = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(l))) { out.push({ t: 'h', level: m[1].length, c: parseInline(m[2]) }); i++; continue; }
107
+ if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(b)) { out.push({ t: 'hr' }); i++; continue; }
108
+ if (/^\s*>/.test(b)) {
109
+ const body = [];
110
+ while (i < L.length && /^\s*>/.test(bare(L[i]))) body.push(L[i++].replace(/^(\s*[\uE000-\uE003]*)\s*>\s?/, '$1'));
111
+ out.push({ t: 'quote', blocks: parseMd(body.join('\n')) }); continue;
112
+ }
113
+ if (/^\s*\|/.test(b) && i + 1 < L.length && isRule(bare(L[i + 1]))) {
114
+ const head = cells(l); i += 2; const rows = [];
115
+ while (i < L.length && /^\s*\|/.test(bare(L[i]))) rows.push(cells(L[i++]));
116
+ out.push({ t: 'table', head: head.map(parseInline), rows: rows.map((r) => head.map((_, k) => parseInline(r[k] || ''))) }); continue;
117
+ }
118
+ if (LIST.test(b)) {
119
+ const ordered = /^\s*\d/.test(b); const items = [];
120
+ while (i < L.length && LIST.test(bare(L[i])) && /^\s*\d/.test(bare(L[i])) === ordered) {
121
+ const lead = (/^[\uE000-\uE003]*/.exec(L[i]) || [''])[0];
122
+ let t = lead + L[i].slice(lead.length).replace(LIST, ''); i++;
123
+ while (i < L.length && /^\s{2,}\S/.test(L[i]) && !LIST.test(bare(L[i]))) t += ' ' + L[i++].trim();
124
+ const tk = TASK.exec(t.replace(MARK, ''));
125
+ if (tk) { const k = t.indexOf('['); t = t.slice(0, k) + t.slice(k).replace(TASK, ''); }
126
+ items.push({ task: tk ? tk[1] !== ' ' : null, c: parseInline(t) });
127
+ }
128
+ out.push({ t: 'list', ordered, items }); continue;
129
+ }
130
+ const body = [];
131
+ while (i < L.length && bare(L[i]).trim() && (!body.length || !startsBlock(bare(L[i])))) body.push(L[i++].trim());
132
+ out.push({ t: 'p', c: parseInline(body.join(' ')) });
133
+ }
134
+ return out;
135
+ }
136
+
137
+ /** Blocks → markdown, one blank line between blocks. */
138
+ export function toMd(blocks) {
139
+ return (blocks || []).map((b) => {
140
+ if (b.t === 'h') return '#'.repeat(b.level || 2) + ' ' + inlineMd(b.c).trim();
141
+ if (b.t === 'p') return lineSafe(inlineMd(b.c).trim());
142
+ if (b.t === 'hr') return '---';
143
+ if (b.t === 'code') return '```' + (b.lang || '') + '\n' + b.s + '\n```';
144
+ if (b.t === 'quote') return toMd(b.blocks).split('\n').map((x) => (x ? '> ' + x : '>')).join('\n');
145
+ if (b.t === 'list') return b.items.map((it, k) => (b.ordered ? (k + 1) + '. ' : '- ') + (it.task == null ? '' : it.task ? '[x] ' : '[ ] ') + inlineMd(it.c).trim()).join('\n');
146
+ if (b.t === 'table') {
147
+ const cell = (c) => inlineMd(c).trim().replace(/\|/g, '\\|');
148
+ const w = Math.max(b.head.length, ...b.rows.map((r) => r.length));
149
+ const line = (r) => '| ' + Array.from({ length: w }, (_, k) => (r[k] ? cell(r[k]) : '')).join(' | ') + ' |';
150
+ return [line(b.head), '|' + Array.from({ length: w }, () => '---').join('|') + '|', ...b.rows.map(line)].join('\n');
151
+ }
152
+ return '';
153
+ }).filter((x) => x !== '').join('\n\n');
154
+ }
155
+
156
+ export const canonMd = (md) => toMd(parseMd(md));
157
+
158
+ /* ── the rendered diff ── */
159
+
160
+ function lcs(a, b) {
161
+ const n = a.length, m = b.length;
162
+ if (n * m > 400000) return [...a.map((x) => ['-', x]), ...b.map((x) => ['+', x])];
163
+ const T = Array.from({ length: n + 1 }, () => new Int32Array(m + 1));
164
+ for (let i = n - 1; i >= 0; i--) for (let j = m - 1; j >= 0; j--) T[i][j] = a[i] === b[j] ? T[i + 1][j + 1] + 1 : Math.max(T[i + 1][j], T[i][j + 1]);
165
+ const ops = []; let i = 0, j = 0;
166
+ while (i < n && j < m) { if (a[i] === b[j]) { ops.push(['=', a[i]]); i++; j++; } else if (T[i + 1][j] >= T[i][j + 1]) ops.push(['-', a[i++]]); else ops.push(['+', b[j++]]); }
167
+ while (i < n) ops.push(['-', a[i++]]); while (j < m) ops.push(['+', b[j++]]);
168
+ return ops;
169
+ }
170
+ /** Runs of ops: [{ eq:true, items } | { eq:false, del:[…], add:[…] }]. */
171
+ function runs(ops) {
172
+ const out = [];
173
+ for (const [op, x] of ops) {
174
+ const last = out[out.length - 1];
175
+ if (op === '=') { if (last && last.eq) last.items.push(x); else out.push({ eq: true, items: [x] }); }
176
+ else { if (!last || last.eq) out.push({ eq: false, del: [], add: [] }); out[out.length - 1][op === '-' ? 'del' : 'add'].push(x); }
177
+ }
178
+ return out;
179
+ }
180
+ const wrap = (s, a, z) => (s && s.trim() ? a + s + z : s);
181
+ function words(a, b) {
182
+ const tok = (x) => x.match(/\s+|[^\s]+/g) || [];
183
+ const A = tok(a), B = tok(b); const ops = lcs(A, B);
184
+ const real = (x) => /\S/.test(x);
185
+ const same = ops.filter(([o, x]) => o === '=' && real(x)).length;
186
+ const tot = Math.max(A.filter(real).length, B.filter(real).length);
187
+ if (tot > 4 && same / tot < 0.6) return wrap(a, DEL, DEL_END) + ' ' + wrap(b, INS, INS_END);
188
+ return runs(ops).map((r) => (r.eq ? r.items.join('') : wrap(r.del.join(''), DEL, DEL_END) + (r.del.length && r.add.length ? ' ' : '') + wrap(r.add.join(''), INS, INS_END))).join('');
189
+ }
190
+ function sentences(a, b) {
191
+ const cut = (x) => x.split(/(?<=[.;!?])\s+/);
192
+ const A = cut(a), B = cut(b);
193
+ if (A.length < 2 && B.length < 2) return words(a, b);
194
+ return runs(lcs(A, B)).map((r) => {
195
+ if (r.eq) return r.items.join(' ');
196
+ const n = Math.min(r.del.length, r.add.length); const parts = [];
197
+ for (let k = 0; k < n; k++) parts.push(words(r.del[k], r.add[k]));
198
+ r.del.slice(n).forEach((x) => parts.push(wrap(x, DEL, DEL_END)));
199
+ r.add.slice(n).forEach((x) => parts.push(wrap(x, INS, INS_END)));
200
+ return parts.join(' ');
201
+ }).join(' ');
202
+ }
203
+ const PREFIX = /^(\s*(?:[-*+]|\d+[.)])\s+(?:\[[ xX]\]\s+)?|\s*>\s?|#{1,6}\s+)/;
204
+ function wrapLine(l, a, z) {
205
+ if (!l.trim() || isRule(l)) return l;
206
+ if (/^\s*\|/.test(l)) return '| ' + cells(l).map((c) => wrap(c, a, z)).join(' | ') + ' |';
207
+ if (/^(```|~~~)/.test(l) || /^\s*(-{3,}|\*{3,})\s*$/.test(l)) return l;
208
+ const p = (PREFIX.exec(l) || [''])[0];
209
+ return p + wrap(l.slice(p.length), a, z);
210
+ }
211
+ function lineDiff(a, b) {
212
+ const pa = (PREFIX.exec(a) || [''])[0], pb = (PREFIX.exec(b) || [''])[0];
213
+ if (/^\s*\|/.test(a) && /^\s*\|/.test(b) && !isRule(a) && !isRule(b)) {
214
+ const ca = cells(a), cb = cells(b);
215
+ return '| ' + cb.map((c, k) => (ca[k] === c ? c : sentences(ca[k] || '', c))).join(' | ') + ' |';
216
+ }
217
+ if (pa === pb) return pb + sentences(a.slice(pa.length), b.slice(pb.length));
218
+ return null;
219
+ }
220
+
221
+ /** `after` with the change since `before` marked. `before` null: the whole of `after` is new. */
222
+ export function diffMd(before, after) {
223
+ const B = String(after == null ? '' : after).split('\n');
224
+ if (before == null) return B.map((l) => wrapLine(l, INS, INS_END)).join('\n');
225
+ const A = String(before).split('\n');
226
+ const out = [];
227
+ for (const r of runs(lcs(A, B))) {
228
+ if (r.eq) { out.push(...r.items); continue; }
229
+ const n = Math.min(r.del.length, r.add.length);
230
+ const removed = []; const added = [];
231
+ for (let k = 0; k < n; k++) {
232
+ const d = lineDiff(r.del[k], r.add[k]);
233
+ if (d == null) { removed.push(wrapLine(r.del[k], DEL, DEL_END)); added.push(wrapLine(r.add[k], INS, INS_END)); } else added.push(d);
234
+ }
235
+ r.del.slice(n).forEach((l) => removed.push(wrapLine(l, DEL, DEL_END)));
236
+ r.add.slice(n).forEach((l) => added.push(wrapLine(l, INS, INS_END)));
237
+ // a removed table row or list item stays in its table or list: put it with the rows after it
238
+ out.push(...removed.filter((l) => l.trim()), ...added);
239
+ }
240
+ return out.join('\n');
241
+ }
242
+
243
+ /** Words added and removed between two texts: [added, removed]. */
244
+ export function wordCounts(before, after) {
245
+ const A = String(before || '').match(/\S+/g) || [], B = String(after || '').match(/\S+/g) || [];
246
+ let add = 0, del = 0;
247
+ for (const [o] of lcs(A, B)) { if (o === '+') add++; else if (o === '-') del++; }
248
+ return [add, del];
249
+ }
250
+
251
+ /* ── DOM ── */
252
+
253
+ /** A safe href: http(s), mailto, a fragment or a relative path; anything else (javascript:, data:) is dropped. */
254
+ export function safeHref(h) {
255
+ const s = String(h || '').trim();
256
+ if (/^(https?:|mailto:)/i.test(s)) return s;
257
+ if (/^[a-z][\w+.-]*:/i.test(s)) return null;
258
+ return s;
259
+ }
260
+
261
+ /** Text with diff markers → nodes: the marked runs inside <ins> and <del>. `st` carries an open marker across inline nodes. */
262
+ function textNodes(doc, s, st) {
263
+ const out = []; let buf = '';
264
+ const push = () => {
265
+ if (!buf) return;
266
+ const t = doc.createTextNode(buf); buf = '';
267
+ if (st.mode) { const w = doc.createElement(st.mode); w.appendChild(t); out.push(w); } else out.push(t);
268
+ };
269
+ for (const ch of String(s)) {
270
+ if (ch === INS || ch === DEL) { push(); st.mode = ch === INS ? 'ins' : 'del'; }
271
+ else if (ch === INS_END || ch === DEL_END) { push(); st.mode = null; }
272
+ else buf += ch;
273
+ }
274
+ push();
275
+ return out;
276
+ }
277
+ function inlineDom(doc, nodes, st) {
278
+ const out = [];
279
+ for (const n of nodes || []) {
280
+ if (n.t === 'text') { out.push(...textNodes(doc, n.s, st)); continue; }
281
+ if (n.t === 'code') { const c = doc.createElement('code'); c.append(...textNodes(doc, n.s, st)); out.push(c); continue; }
282
+ const tag = n.t === 'b' ? 'strong' : n.t === 'i' ? 'em' : 'a';
283
+ const e = doc.createElement(tag);
284
+ if (n.t === 'a') {
285
+ const h = safeHref(n.href);
286
+ if (h != null) { e.setAttribute('href', h); if (/^https?:/i.test(h)) { e.setAttribute('target', '_blank'); e.setAttribute('rel', 'noopener'); } }
287
+ }
288
+ e.append(...inlineDom(doc, n.c, st));
289
+ out.push(e);
290
+ }
291
+ return out;
292
+ }
293
+
294
+ /** Blocks → elements. `opts.editable` draws checklist boxes that can be ticked (the editor). */
295
+ export function toDom(blocks, doc, opts = {}) {
296
+ const d = doc || document;
297
+ const mk = (tag, cls) => { const e = d.createElement(tag); if (cls) e.className = cls; return e; };
298
+ return (blocks || []).map((b) => {
299
+ const st = { mode: null };
300
+ if (b.t === 'h') { const e = mk('h' + Math.min(6, Math.max(1, b.level || 2))); e.append(...inlineDom(d, b.c, st)); return e; }
301
+ if (b.t === 'p') { const e = mk('p'); e.append(...inlineDom(d, b.c, st)); return e; }
302
+ if (b.t === 'hr') return mk('hr');
303
+ if (b.t === 'code') { const p = mk('pre'); if (b.lang) p.setAttribute('data-lang', b.lang); const c = mk('code'); c.append(...textNodes(d, b.s, st)); p.appendChild(c); return p; }
304
+ if (b.t === 'quote') { const q = mk('blockquote'); q.append(...toDom(b.blocks, d, opts)); return q; }
305
+ if (b.t === 'list') {
306
+ const l = mk(b.ordered ? 'ol' : 'ul', b.items.some((it) => it.task != null) ? 'tasks' : '');
307
+ for (const it of b.items) {
308
+ const li = mk('li');
309
+ if (it.task != null) {
310
+ li.className = 'task' + (it.task ? ' done' : '');
311
+ const box = mk('input'); box.type = 'checkbox'; box.checked = !!it.task; box.setAttribute('aria-label', 'Done');
312
+ if (opts.editable) box.setAttribute('contenteditable', 'false'); else box.disabled = true;
313
+ const sp = mk('span'); sp.append(...inlineDom(d, it.c, st));
314
+ li.append(box, sp);
315
+ } else li.append(...inlineDom(d, it.c, st));
316
+ l.appendChild(li);
317
+ }
318
+ return l;
319
+ }
320
+ if (b.t === 'table') {
321
+ const w = mk('div', 'tw'); const t = mk('table'); const th = mk('thead'); const tr = mk('tr');
322
+ for (const c of b.head) { const x = mk('th'); x.append(...inlineDom(d, c, st)); tr.appendChild(x); }
323
+ th.appendChild(tr); const tb = mk('tbody');
324
+ for (const r of b.rows) { const row = mk('tr'); for (const c of r) { const x = mk('td'); x.append(...inlineDom(d, c, st)); row.appendChild(x); } tb.appendChild(row); }
325
+ t.append(th, tb); w.appendChild(t); return w;
326
+ }
327
+ return d.createTextNode('');
328
+ });
329
+ }
330
+
331
+ /* reading the editor back */
332
+ function inlineOf(n) {
333
+ const out = [];
334
+ const text = (s) => { if (!s) return; const last = out[out.length - 1]; if (last && last.t === 'text') last.s += s; else out.push({ t: 'text', s }); };
335
+ for (const c of Array.from(n.childNodes || [])) {
336
+ if (c.nodeType === 3) { text(c.textContent.replace(/\u00a0/g, ' ').replace(/\u200b/g, '').replace(/\s+/g, ' ')); continue; }
337
+ if (c.nodeType !== 1) continue;
338
+ const t = c.tagName;
339
+ if (t === 'BR') { text(' '); continue; }
340
+ if (t === 'INPUT' || t === 'UL' || t === 'OL') continue;
341
+ if (t === 'CODE') { out.push({ t: 'code', s: c.textContent.replace(/\u200b/g, '') }); continue; }
342
+ if (t === 'STRONG' || t === 'B') { out.push({ t: 'b', c: inlineOf(c) }); continue; }
343
+ if (t === 'EM' || t === 'I') { out.push({ t: 'i', c: inlineOf(c) }); continue; }
344
+ if (t === 'A') { out.push({ t: 'a', href: c.getAttribute('href') || '', c: inlineOf(c) }); continue; }
345
+ if (t === 'SPAN' && /font-weight:\s*(bold|[6-9]00)/.test(c.getAttribute('style') || '')) { out.push({ t: 'b', c: inlineOf(c) }); continue; }
346
+ if (t === 'SPAN' && /font-style:\s*italic/.test(c.getAttribute('style') || '')) { out.push({ t: 'i', c: inlineOf(c) }); continue; }
347
+ for (const x of inlineOf(c)) { if (x.t === 'text') text(x.s); else out.push(x); }
348
+ }
349
+ return out;
350
+ }
351
+ const trimInline = (c) => {
352
+ const a = c.slice();
353
+ while (a.length && a[0].t === 'text' && !a[0].s.trim()) a.shift();
354
+ while (a.length && a[a.length - 1].t === 'text' && !a[a.length - 1].s.trim()) a.pop();
355
+ if (a.length && a[0].t === 'text') a[0] = { ...a[0], s: a[0].s.replace(/^\s+/, '') };
356
+ if (a.length && a[a.length - 1].t === 'text') a[a.length - 1] = { ...a[a.length - 1], s: a[a.length - 1].s.replace(/\s+$/, '') };
357
+ return a;
358
+ };
359
+ const BLOCK = /^(P|DIV|H[1-6]|BLOCKQUOTE|UL|OL|TABLE|PRE|HR|SECTION)$/;
360
+ /** The editor's children → blocks. Loose text and inline nodes between blocks become a paragraph. */
361
+ export function fromDom(root) {
362
+ const out = []; let loose = null;
363
+ const endLoose = () => { if (loose) { const c = trimInline(inlineOf(loose)); if (c.length) out.push({ t: 'p', c }); loose = null; } };
364
+ for (const n of Array.from(root.childNodes || [])) {
365
+ if (n.nodeType === 1 && BLOCK.test(n.tagName)) { endLoose(); out.push(...blockOf(n)); continue; }
366
+ if (n.nodeType === 3 && !n.textContent.trim() && !loose) continue;
367
+ if (!loose) loose = (root.ownerDocument || document).createElement('p');
368
+ loose.appendChild(n.cloneNode(true));
369
+ }
370
+ endLoose();
371
+ return out;
372
+ }
373
+ function blockOf(n) {
374
+ const t = n.tagName;
375
+ if (/^H[1-6]$/.test(t)) return [{ t: 'h', level: +t[1], c: trimInline(inlineOf(n)) }];
376
+ if (t === 'HR') return [{ t: 'hr' }];
377
+ if (t === 'PRE') return [{ t: 'code', lang: n.getAttribute('data-lang') || '', s: n.textContent.replace(/\n$/, '') }];
378
+ if (t === 'BLOCKQUOTE') { const b = fromDom(n); return b.length ? [{ t: 'quote', blocks: b }] : []; }
379
+ if (t === 'UL' || t === 'OL') {
380
+ const items = Array.from(n.children).filter((li) => li.tagName === 'LI').map((li) => {
381
+ const box = li.querySelector(':scope > input[type=checkbox]');
382
+ return { task: box ? !!box.checked : null, c: trimInline(inlineOf(li)) };
383
+ });
384
+ const nested = Array.from(n.querySelectorAll(':scope > li > ul, :scope > li > ol')).flatMap(blockOf);
385
+ return [{ t: 'list', ordered: t === 'OL', items }, ...nested];
386
+ }
387
+ if (t === 'TABLE' || (t === 'DIV' && n.querySelector(':scope > table'))) {
388
+ const tb = t === 'TABLE' ? n : n.querySelector(':scope > table');
389
+ const rows = Array.from(tb.querySelectorAll('tr')).map((r) => Array.from(r.children).map((c) => trimInline(inlineOf(c))));
390
+ if (!rows.length) return [];
391
+ return [{ t: 'table', head: rows[0], rows: rows.slice(1) }];
392
+ }
393
+ if ((t === 'DIV' || t === 'SECTION') && Array.from(n.children).some((c) => BLOCK.test(c.tagName))) return fromDom(n);
394
+ const c = trimInline(inlineOf(n));
395
+ return c.length ? [{ t: 'p', c }] : [];
396
+ }
@@ -2,9 +2,10 @@
2
2
  * cozy-nav.js — the floating place menu of the Agreed design (initiative premium-agreed-design).
3
3
  *
4
4
  * One button, bottom left on desktop and bottom right on a phone, opens Home, Board, Insights and Settings.
5
- * It replaces the rail on screen; the rail stays in the markup (hidden by cozy.css) so premium-shell.js keeps its wiring.
6
- * Settings presses the shell's own Settings button when the page has one, and opens the console's settings otherwise.
5
+ * It is the one way between places: the old five-place rail is gone (premium-shell.js takes it out of the page).
6
+ * Settings has no design yet, so it opens the Viewer on its placeholder (cozy-viewer.js). Nothing here leads to the console.
7
7
  */
8
+ import { placeholder } from './cozy-viewer.js';
8
9
 
9
10
  export const PLACES = [
10
11
  { key: 'home', label: 'Home', href: '/premium.html', d: 'M4 11l8-7 8 7v9h-5v-6h-6v6H4z' },
@@ -13,6 +14,7 @@ export const PLACES = [
13
14
  ];
14
15
  const MENU = 'M4 7h16M4 12h16M4 17h16';
15
16
  const CLOSE = 'M6 6l12 12M18 6L6 18';
17
+ const MORE = 'M5 12h.01M12 12h.01M19 12h.01';
16
18
  const GEAR = 'M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M16.9 16.9l2.1 2.1M4.9 19.1l2.1-2.1M16.9 7.1l2.1-2.1';
17
19
  const svg = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
18
20
 
@@ -25,11 +27,12 @@ export function fabLabel(here, open) {
25
27
  /** The menu's markup for one place; pure, so a unit test can read it. */
26
28
  export function menuHtml(here) {
27
29
  return PLACES.map((p) => `<a href="${p.href}"${p.key === here ? ' aria-current="page"' : ''}>${svg(p.d)}<span>${p.label}</span></a>`).join('')
30
+ + `<button type="button" class="cz-set" data-cz-more>${svg(MORE)}<span>More</span></button>`
28
31
  + `<button type="button" class="cz-set" data-cz-settings>${svg(GEAR)}<span>Settings</span></button>`;
29
32
  }
30
33
 
31
34
  /** Mount the menu once. `here` is home | board | insights. Returns the wrapper. */
32
- export function mountNav(here, doc = document) {
35
+ export function mountNav(here, doc = document, opts = {}) {
33
36
  const old = doc.getElementById('czNav'); if (old) return old;
34
37
  doc.body.classList.add('cz');
35
38
  const w = doc.createElement('div'); w.className = 'cz-fabw'; w.id = 'czNav';
@@ -45,10 +48,18 @@ export function mountNav(here, doc = document) {
45
48
  doc.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { set(false); fab.focus(); } });
46
49
  // set() redraws the button's icon, so the pressed icon may be gone from the page by now: only a press still on the page closes the menu
47
50
  doc.addEventListener('click', (e) => { if (!menu.hidden && e.target.isConnected && !w.contains(e.target)) set(false); });
48
- menu.querySelector('[data-cz-settings]').addEventListener('click', () => {
51
+ // Settings and More: the minimal versions of the features the design does not draw yet (home-more.js), each with "Waiting for design"
52
+ menu.querySelector('[data-cz-settings]').addEventListener('click', () => { set(false); import('./home-more.js').then((M) => M.openSettings()).catch(() => placeholder('Settings', { icon: 'gear' })); });
53
+ menu.querySelector('[data-cz-more]').addEventListener('click', () => {
49
54
  set(false);
50
- const b = doc.getElementById('settingsBtn');
51
- if (b) b.click(); else location.assign('/console.html?tab=settings');
55
+ if (opts.more) { opts.more()(fab); return; }
56
+ import('./home-more.js').then((M) => moreList(M, doc)).catch(() => placeholder('More', { icon: 'list' }));
52
57
  });
53
58
  return w;
54
59
  }
60
+ /** The features with no design yet, as one list in the Viewer, on a page that has no menu of its own for them. */
61
+ function moreList(M, doc) {
62
+ const go = { work: M.openMyWork, around: M.openAround, inbox: () => M.openInbox(), eod: M.openEndOfDay, rec: M.openRecorder, search: () => M.openSearch(), products: M.openProducts, sources: M.openSources, settings: M.openSettings,
63
+ cal: () => (doc.defaultView.czViews && doc.defaultView.czViews.openCalendar ? doc.defaultView.czViews.openCalendar({ view: 'day' }) : placeholder('Calendar', { icon: 'cal' })) };
64
+ return M.listCard(M.moreItems.map(([k, l]) => [l, go[k]]));
65
+ }
@@ -0,0 +1,26 @@
1
+ /* pm/cozy-placeholder.js — the card for a feature the Agreed design does not draw yet (initiative premium-agreed-design).
2
+ *
3
+ * The rebuilt pages show only what the design draws. Where a feature has no design yet, a page draws this small calm card in its place,
4
+ * so the feature is named and nothing old is shown instead:
5
+ * czPlaceholder(el, featureName, note?) → el. It puts the card in el (it replaces what el held) and returns el.
6
+ * placeholderHtml(featureName, note?) → the same card as a string, for a page that builds its markup as text.
7
+ * The card reads "<featureName> · Waiting for design". note is one optional short line under it. The look is in cozy.css (.cz-ph). */
8
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
9
+ const ICON = 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7v5l3 2';
10
+
11
+ /** The words of the card's line; pure, for a unit test. */
12
+ export const placeholderText = (featureName) => (String(featureName || '').trim() || 'This part') + ' · Waiting for design';
13
+
14
+ export function placeholderHtml(featureName, note) {
15
+ return `<div class="cz-ph" role="note" data-cz-placeholder="${esc(String(featureName || '').trim())}">`
16
+ + `<span class="cz-ph-ic" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="${ICON}"/></svg></span>`
17
+ + `<div class="cz-ph-t"><p class="cz-ph-l">${esc(placeholderText(featureName))}</p>${note ? `<p class="cz-ph-n">${esc(note)}</p>` : ''}</div></div>`;
18
+ }
19
+
20
+ export function czPlaceholder(el, featureName, note) {
21
+ if (!el) return el;
22
+ el.innerHTML = placeholderHtml(featureName, note);
23
+ return el;
24
+ }
25
+
26
+ if (typeof window !== 'undefined') { window.czPlaceholder = czPlaceholder; window.czPlaceholderHtml = placeholderHtml; }
@@ -4,7 +4,7 @@
4
4
  * this file does the same for the dialog, its Viewer tabs, its menus and the toast, so every view (doc, slides, Jira, meeting, notes,
5
5
  * calendar, report) takes the cozy look from the tokens it already reads. Motion: only the cz-dot levels move (cozy.css). */
6
6
 
7
- .cz .dlg, .cz .veil, .cz .toast, .cz .vmenu, .cz .crmenu, .cz .tbmenu, .cz .czi-tok {
7
+ .cz .dlg, .cz .veil, .cz .toast, .cz .vmenu, .cz .crmenu, .cz .tbmenu, .cz .czi-tok, .cz .cz-vw { /* .cz-vw: the Home Viewer (cozy-viewer.js), whose views read the same tokens */
8
8
  --sans: 'Nunito', ui-sans-serif, system-ui, sans-serif;
9
9
  --ink: var(--cz-c-2a2e35); --ink-2: var(--cz-c-4a4f58); --ink-3: var(--cz-c-646a74);
10
10
  --card: var(--cz-c-ffffff); --card-solid: var(--cz-c-ffffff); --well: var(--cz-c-f4f3f0); --hair: rgba(42,46,53,.1);
@@ -17,7 +17,7 @@
17
17
  font-family: var(--sans);
18
18
  }
19
19
  :root[data-theme="dark"] .cz .dlg, :root[data-theme="dark"] .cz .veil, :root[data-theme="dark"] .cz .toast, :root[data-theme="dark"] .cz .vmenu,
20
- :root[data-theme="dark"] .cz .crmenu, :root[data-theme="dark"] .cz .tbmenu, :root[data-theme="dark"] .cz .czi-tok {
20
+ :root[data-theme="dark"] .cz .crmenu, :root[data-theme="dark"] .cz .tbmenu, :root[data-theme="dark"] .cz .czi-tok, :root[data-theme="dark"] .cz .cz-vw {
21
21
  --ink: var(--cz-c-eceef1); --ink-2: var(--cz-c-c5c9d0); --ink-3: var(--cz-c-9ea4ad); --card: var(--cz-c-24262b); --card-solid: var(--cz-c-24262b); --well: var(--cz-c-1b1d21); --hair: rgba(236,238,241,.1);
22
22
  --ember: var(--cz-c-6aaaf0); --ember-ink: var(--cz-c-9bc7f4); --solid: var(--cz-c-6aaaf0); --on-solid: var(--cz-c-17191c); --spot: rgba(106,170,240,.14);
23
23
  --ok: var(--cz-c-7fc79a); --bad: var(--cz-c-f2948c); --warn: var(--cz-c-e8c27a); --warn-bg: rgba(212,161,58,.14); --ok-bg: rgba(94,156,106,.16); --live: var(--cz-c-f2a27a); --live-bg: rgba(217,119,63,.16);
@@ -25,7 +25,7 @@
25
25
  }
26
26
  @media (prefers-color-scheme: dark) {
27
27
  :root:not([data-theme="light"]) .cz .dlg, :root:not([data-theme="light"]) .cz .veil, :root:not([data-theme="light"]) .cz .toast, :root:not([data-theme="light"]) .cz .vmenu,
28
- :root:not([data-theme="light"]) .cz .crmenu, :root:not([data-theme="light"]) .cz .tbmenu, :root:not([data-theme="light"]) .cz .czi-tok {
28
+ :root:not([data-theme="light"]) .cz .crmenu, :root:not([data-theme="light"]) .cz .tbmenu, :root:not([data-theme="light"]) .cz .czi-tok, :root:not([data-theme="light"]) .cz .cz-vw {
29
29
  --ink: var(--cz-c-eceef1); --ink-2: var(--cz-c-c5c9d0); --ink-3: var(--cz-c-9ea4ad); --card: var(--cz-c-24262b); --card-solid: var(--cz-c-24262b); --well: var(--cz-c-1b1d21); --hair: rgba(236,238,241,.1);
30
30
  --ember: var(--cz-c-6aaaf0); --ember-ink: var(--cz-c-9bc7f4); --solid: var(--cz-c-6aaaf0); --on-solid: var(--cz-c-17191c); --spot: rgba(106,170,240,.14);
31
31
  --ok: var(--cz-c-7fc79a); --bad: var(--cz-c-f2948c); --warn: var(--cz-c-e8c27a); --warn-bg: rgba(212,161,58,.14); --ok-bg: rgba(94,156,106,.16); --live: var(--cz-c-f2a27a); --live-bg: rgba(217,119,63,.16);