create-pmos 0.440.0 → 0.442.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 (95) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/adler-seasons-art-test.js +106 -0
  7. package/workspace/adler-seasons-test.js +111 -0
  8. package/workspace/briefing-premium-adddoc-test.js +16 -13
  9. package/workspace/briefing-premium-board-test.js +19 -17
  10. package/workspace/briefing-premium-initiative-test.js +7 -4
  11. package/workspace/briefing-premium-products-test.js +4 -4
  12. package/workspace/briefing-premium-sources-test.js +2 -2
  13. package/workspace/briefing-premium-test.js +29 -23
  14. package/workspace/changelog.json +24 -0
  15. package/workspace/guide/adler.md +10 -0
  16. package/workspace/guide/core-documents.md +2 -2
  17. package/workspace/guide/data-freshness.md +7 -5
  18. package/workspace/guide/home.md +3 -1
  19. package/workspace/guide/horizon-scan.md +1 -1
  20. package/workspace/ini-workflow-test.js +6 -2
  21. package/workspace/lib/agent-inbox.js +20 -2
  22. package/workspace/lib/briefing-premium-sources.js +3 -0
  23. package/workspace/lib/briefing-premium.js +37 -7
  24. package/workspace/lib/driver-cli.js +1 -1
  25. package/workspace/lib/driver-run.js +15 -1
  26. package/workspace/lib/driver.js +31 -2
  27. package/workspace/lib/news-for-you.js +24 -9
  28. package/workspace/lib/pm-idle.js +12 -0
  29. package/workspace/lib/refresh.js +17 -8
  30. package/workspace/lib/routes-core-docs.js +1 -1
  31. package/workspace/lib/routes-news.js +15 -1
  32. package/workspace/lib/routes-phone-day.js +6 -4
  33. package/workspace/lib/settings-store.js +38 -0
  34. package/workspace/metric-drafts-ui-test.js +2 -2
  35. package/workspace/need-shot.js +57 -0
  36. package/workspace/news-viewers-test.js +183 -0
  37. package/workspace/package-lock.json +2 -2
  38. package/workspace/package.json +1 -1
  39. package/workspace/premium-board-actions-test.js +2 -1
  40. package/workspace/premium-chat-attach-test.js +2 -0
  41. package/workspace/premium-core-doc-issue-test.js +9 -8
  42. package/workspace/program-panel-test.js +1 -1
  43. package/workspace/public/pm/bd-ini-panel.js +6 -13
  44. package/workspace/public/pm/c3-ini-ui.js +1 -1
  45. package/workspace/public/pm/cozy-adler.css +21 -0
  46. package/workspace/public/pm/cozy-adler.js +415 -8
  47. package/workspace/public/pm/cozy-ev.css +44 -0
  48. package/workspace/public/pm/cozy-home.css +8 -0
  49. package/workspace/public/pm/cozy-news.js +186 -22
  50. package/workspace/public/pm/cozy-seasons.js +318 -0
  51. package/workspace/public/pm/cozy-settings.js +88 -5
  52. package/workspace/public/pm/cozy-today.css +5 -0
  53. package/workspace/public/pm/cozy-viewer.js +12 -7
  54. package/workspace/public/pm/cozy-vw-shell.css +49 -0
  55. package/workspace/public/pm/cozy.css +65 -0
  56. package/workspace/public/pm/dash-view.js +4 -2
  57. package/workspace/public/pm/home-adddoc.js +46 -26
  58. package/workspace/public/pm/home-app.js +142 -114
  59. package/workspace/public/pm/home-chat.js +1 -1
  60. package/workspace/public/pm/home-day.js +17 -9
  61. package/workspace/public/pm/home-draft.js +35 -23
  62. package/workspace/public/pm/home-ini.js +4 -4
  63. package/workspace/public/pm/home-mentions.js +1 -1
  64. package/workspace/public/pm/home-need.js +336 -0
  65. package/workspace/public/pm/home-today.js +2 -2
  66. package/workspace/public/pm/home-work.js +51 -4
  67. package/workspace/public/pm/impact.js +1 -1
  68. package/workspace/public/pm/ini-groups.js +15 -10
  69. package/workspace/public/pm/ini-links.js +1 -1
  70. package/workspace/public/pm/ini-tasks.js +208 -44
  71. package/workspace/public/pm/ini-view-model.js +8 -2
  72. package/workspace/public/pm/ini-view.css +305 -1
  73. package/workspace/public/pm/ini-view.js +190 -80
  74. package/workspace/public/pm/mission.js +234 -0
  75. package/workspace/public/pm/premium-board.js +1 -1
  76. package/workspace/public/pm/premium-welcome.js +2 -2
  77. package/workspace/public/pm/small-vw.js +128 -0
  78. package/workspace/public/pm/split-merge.js +1 -1
  79. package/workspace/public/pm/stage-line.js +2 -2
  80. package/workspace/server.js +10 -6
  81. package/workspace/skills/initiative-drive.skill +4 -1
  82. package/workspace/split-merge-ui-test.js +1 -1
  83. package/workspace/stage-card-test.js +48 -11
  84. package/workspace/task-links-test.js +2 -0
  85. package/workspace/task-milestones-test.js +5 -1
  86. package/workspace/task-plans-test.js +3 -3
  87. package/workspace/task-views-test.js +90 -37
  88. package/workspace/test-lists/adler-seasons-art.json +13 -0
  89. package/workspace/test-lists/batch18-adler-seasons.json +13 -0
  90. package/workspace/test-lists/batch18-asks.json +5 -0
  91. package/workspace/test-lists/mission.json +5 -0
  92. package/workspace/test-lists/news-viewers.json +13 -0
  93. package/workspace/test-lists/small-viewers.json +5 -0
  94. package/workspace/test-lists/viewer-tasks.json +5 -0
  95. package/workspace/tk-tasks-test.js +25 -30
@@ -0,0 +1,318 @@
1
+ /* pm/cozy-seasons.js — the calendar that dresses Adler for the day (feedback batch 18 item 8, slice 8-A; canvas frames AsCal, AsSet1,
2
+ * AsSet2Tap; brief next18/briefs/8-adler-seasons-build.md, the seam with 8-B in 8-adler-seasons-interface.md). Option A: the calendar
3
+ * dresses him. A date table that ships with the kit, read against your place. No network.
4
+ *
5
+ * DAYS the 44 days and seasons of AsCal: { key, name, group, kind, where, rule, win }
6
+ * charmToday(now, prefs) → { key, name, until, from, day, today, group, ...extra } | null. The one charm he wears now.
7
+ * nextCharm(now, prefs) → { key, name, from, day } | null. The next charm that starts after today (Settings' "Next:" line).
8
+ * placeOf(prefs, env) → { country, climate, auto }. Your country and climate from the computer (Intl), or the Settings override.
9
+ * enabled(entry, prefs, place) → is this day switched on for you
10
+ * skipThisYear(key, now, prefs) → { key: 'adler.dress.skip', value }: the setting row "Not this one" posts
11
+ * wearNow(key, now) → { key: 'adler.dress.wear', value }: Movie night or Music until midnight (key '' takes it off)
12
+ * dressPrefs(settings) the flat { key: value } map of adler.amount and adler.dress.* from GET /api/settings' rows
13
+ * moreDays(place) the rows of "More festivals and national days": one switch per day
14
+ *
15
+ * The rules (AsCal, Wawan 2026-10-28 09:55):
16
+ * Windows: most days run from 2 days before to 2 days after. Big festivals (New Year, Chinese New Year, Hari Raya Puasa, National Day,
17
+ * Mid-Autumn, Deepavali, Christmas) and big sports run from a week before to a week after (sports: before the opening, after the final).
18
+ * Seasons, the monsoon and exam season last the whole season. Movie night and Music last until midnight. Your days are the day itself.
19
+ * Overlap: the nearer day wins. On a tie: your days, then your pick, then festivals where you live, then other events, then the season.
20
+ * A season or exam season shows only on a day with nothing else. So Christmas runs 18-28 Dec and New Year runs from 29 Dec.
21
+ * Solemn days never get a charm, and nothing else is worn on them where they are kept: Good Friday, Qingming, Thaipusam, the seventh month.
22
+ * A date marked ~ in the table is not confirmed yet (the gazette or MUIS fixes it each year). Its charm waits until a kit carries it.
23
+ * Off: the master switch, or Settings > Adler > How much: Off or Face only. */
24
+
25
+ const BIG = [7, 7], DAY = [2, 2], NONE = [0, 0];
26
+ const SEA = ['SG', 'MY', 'ID', 'BN', 'TH', 'PH', 'VN'];
27
+ const CHINESE = ['SG', 'MY', 'ID', 'CN', 'TW', 'HK', 'MO', 'VN', 'KR'];
28
+ const MALAY = ['SG', 'MY', 'ID', 'BN'];
29
+ const TAMIL = ['SG', 'MY', 'IN', 'LK'];
30
+ /** The countries Settings offers for "Where you are", by name. */
31
+ export const PLACES = Object.freeze({ SG: 'Singapore', MY: 'Malaysia', ID: 'Indonesia', BN: 'Brunei', TH: 'Thailand', PH: 'Philippines', VN: 'Vietnam', IN: 'India', LK: 'Sri Lanka', CN: 'China', HK: 'Hong Kong', TW: 'Taiwan', KR: 'South Korea', JP: 'Japan', AU: 'Australia', NZ: 'New Zealand', GB: 'United Kingdom', IE: 'Ireland', DE: 'Germany', FR: 'France', NL: 'Netherlands', US: 'United States', CA: 'Canada', BR: 'Brazil', AR: 'Argentina', CL: 'Chile', ZA: 'South Africa', AE: 'United Arab Emirates' });
32
+ export const CLIMATES = Object.freeze({ tropics: 'tropics', north: 'north', south: 'south' });
33
+ const TROPICS = new Set(['SG', 'MY', 'ID', 'BN', 'TH', 'PH', 'VN', 'IN', 'LK', 'KH', 'MM', 'LA', 'AE']);
34
+ const SOUTH = new Set(['AU', 'NZ', 'AR', 'CL', 'ZA', 'UY']);
35
+ const ZONES = { 'Asia/Singapore': 'SG', 'Asia/Kuala_Lumpur': 'MY', 'Asia/Kuching': 'MY', 'Asia/Jakarta': 'ID', 'Asia/Makassar': 'ID', 'Asia/Jayapura': 'ID', 'Asia/Brunei': 'BN', 'Asia/Bangkok': 'TH', 'Asia/Manila': 'PH', 'Asia/Ho_Chi_Minh': 'VN', 'Asia/Saigon': 'VN', 'Asia/Kolkata': 'IN', 'Asia/Calcutta': 'IN', 'Asia/Colombo': 'LK', 'Asia/Shanghai': 'CN', 'Asia/Hong_Kong': 'HK', 'Asia/Taipei': 'TW', 'Asia/Seoul': 'KR', 'Asia/Tokyo': 'JP', 'Asia/Dubai': 'AE', 'Europe/London': 'GB', 'Europe/Dublin': 'IE', 'Europe/Berlin': 'DE', 'Europe/Paris': 'FR', 'Europe/Amsterdam': 'NL', 'Pacific/Auckland': 'NZ', 'Africa/Johannesburg': 'ZA', 'America/Sao_Paulo': 'BR', 'America/Argentina/Buenos_Aires': 'AR', 'America/Santiago': 'CL', 'America/Toronto': 'CA', 'America/Vancouver': 'CA' };
36
+ const NATIONAL = { PH: '06-12', US: '07-04', IN: '08-15', ID: '08-17', MY: '08-31' };
37
+
38
+ /* kind: on = on unless you turn it off, opt = off until you turn it on, qt = solemn (never a charm), me = your days, pick = worn on purpose.
39
+ * group: the Settings switch it follows (holidays, seasons, science, school, more, sports, exam, me, pick).
40
+ * rule: fixed 'MM-DD' | nth [month, weekday 0=Sun, n] | years { YYYY: 'YYYY-MM-DD' or ['from', 'to'] } (~ = not confirmed) | easter offset
41
+ * | season | span ['MM-DD', 'MM-DD'] (crosses the year when from > to) | national | yours
42
+ * where: the countries that keep it ('*' = everywhere). Holidays and festivals switch on by default only where they are kept. */
43
+ const D = (key, name, group, kind, where, rule, win = DAY, more = {}) => Object.freeze({ key, name, group, kind, where, rule, win, ...more });
44
+ export const DAYS = Object.freeze([
45
+ // January
46
+ D('newyear', 'New Year', 'holidays', 'on', '*', { fixed: '01-01' }, BIG),
47
+ D('pongal', 'Pongal', 'more', 'opt', TAMIL, { years: { 2026: '2026-01-14', 2027: '~2027-01-15' } }),
48
+ D('thaipusam', 'Thaipusam', 'holidays', 'qt', TAMIL, { years: { 2026: '2026-02-01', 2027: '~2027-01-22' } }, NONE),
49
+ // February
50
+ D('cny', 'Chinese New Year', 'holidays', 'on', CHINESE, { years: { 2026: '2026-02-17', 2027: '2027-02-06' } }, BIG),
51
+ D('ramadan', 'Ramadan evenings', 'more', 'opt', MALAY, { years: { 2026: ['2026-02-19', '2026-03-20'], 2027: ['~2027-02-08', '~2027-03-09'] } }, NONE, { evening: 19 }),
52
+ D('valentine', "Valentine's Day", 'more', 'on', '*', { fixed: '02-14' }),
53
+ D('lantern', 'Chap Goh Mei', 'more', 'on', CHINESE, { years: { 2026: '2026-03-03', 2027: '2027-02-20' } }),
54
+ // March
55
+ D('iwd', "International Women's Day", 'more', 'opt', '*', { fixed: '03-08' }),
56
+ D('raya', 'Hari Raya Puasa', 'holidays', 'on', MALAY, { years: { 2026: '2026-03-21', 2027: '~2027-03-10' } }, BIG),
57
+ D('pi', 'Pi Day', 'science', 'on', '*', { fixed: '03-14' }),
58
+ D('goodfriday', 'Good Friday', 'holidays', 'qt', ['SG', 'PH', 'AU', 'GB', 'IE', 'DE', 'CA', 'BR', 'ZA', 'NZ'], { easter: -2 }, NONE),
59
+ D('easter', 'Easter', 'more', 'opt', '*', { easter: 0 }),
60
+ D('spring', 'Spring', 'seasons', 'on', '*', { season: 'spring' }, NONE),
61
+ // April
62
+ D('qingming', 'Qingming', 'holidays', 'qt', CHINESE, { years: { 2026: '2026-04-05', 2027: '2027-04-05' } }, NONE),
63
+ D('earth', 'Earth Day', 'science', 'on', '*', { fixed: '04-22' }),
64
+ // May
65
+ D('labour', 'Labour Day', 'holidays', 'on', '*', { fixed: '05-01' }),
66
+ D('haji', 'Hari Raya Haji', 'holidays', 'on', MALAY, { years: { 2026: '2026-05-27', 2027: '~2027-05-17' } }),
67
+ D('vesak', 'Vesak Day', 'holidays', 'on', ['SG', 'MY', 'ID', 'TH', 'LK'], { years: { 2026: '2026-05-31', 2027: '~2027-05-20' } }),
68
+ // June
69
+ D('dragonboat', 'Dragon Boat Festival', 'more', 'on', CHINESE, { years: { 2026: '2026-06-19', 2027: '2027-06-09' } }),
70
+ D('natday', 'National Day', 'more', 'opt', Object.keys(NATIONAL), { national: true }),
71
+ D('football', 'The football finals', 'sports', 'opt', '*', { years: { 2026: ['2026-06-11', '2026-07-19'] } }, BIG),
72
+ D('summer', 'Summer', 'seasons', 'on', '*', { season: 'summer' }, NONE),
73
+ // July
74
+ D('moon', 'Moon landing day', 'science', 'on', '*', { fixed: '07-20' }),
75
+ D('games', 'The Games', 'sports', 'opt', '*', { years: { 2028: ['2028-07-14', '2028-07-30'] } }, BIG),
76
+ // August
77
+ D('ndp', 'National Day', 'holidays', 'on', ['SG'], { fixed: '08-09' }, [8, 7]),
78
+ D('seventh', 'The seventh month', 'holidays', 'qt', CHINESE, { years: { 2026: ['2026-08-12', '2026-09-10'], 2027: ['~2027-08-03', '~2027-08-31'] } }, NONE),
79
+ // September
80
+ D('teachers', "Teachers' Day", 'school', 'on', ['SG'], { nth: [9, 5, 1] }),
81
+ D('midautumn', 'Mid-Autumn Festival', 'more', 'on', CHINESE, { years: { 2026: '2026-09-25', 2027: '2027-09-15' } }, BIG),
82
+ D('exam', 'Exam season', 'exam', 'opt', ['SG'], { span: ['09-20', '11-15'] }, NONE),
83
+ D('autumn', 'Autumn', 'seasons', 'on', '*', { season: 'autumn' }, NONE),
84
+ // October
85
+ D('children', "Children's Day", 'school', 'on', ['SG'], { nth: [10, 5, 1] }),
86
+ D('nightrace', 'The night race', 'sports', 'opt', ['SG'], { years: { 2026: ['~2026-10-09', '~2026-10-11'] } }),
87
+ D('halloween', 'Halloween', 'more', 'opt', '*', { fixed: '10-31' }),
88
+ D('deepavali', 'Deepavali', 'holidays', 'on', TAMIL, { years: { 2026: '2026-11-08', 2027: '2027-10-29' } }, BIG),
89
+ // November
90
+ D('thanks', 'Thanksgiving', 'more', 'opt', ['US', 'CA'], { nth: [11, 4, 4] }),
91
+ // December
92
+ D('hanukkah', 'Hanukkah', 'more', 'opt', '*', { years: { 2026: ['2026-12-04', '2026-12-12'], 2027: ['2027-12-24', '2028-01-01'] } }),
93
+ D('christmas', 'Christmas', 'holidays', 'on', '*', { fixed: '12-25' }, BIG),
94
+ D('monsoon', 'Northeast monsoon', 'seasons', 'on', SEA, { span: ['12-01', '03-10'] }, NONE, { climate: 'tropics' }),
95
+ D('winter', 'Winter', 'seasons', 'on', '*', { season: 'winter' }, NONE),
96
+ D('dongzhi', 'Dongzhi', 'more', 'opt', CHINESE, { years: { 2026: '2026-12-22', 2027: '2027-12-22' } }),
97
+ // Any day
98
+ D('pmosday', 'PMOS day', 'me', 'me', '*', { yours: 'since' }, NONE),
99
+ D('birthday', 'Birthday', 'me', 'me', '*', { yours: 'birthday' }, NONE),
100
+ D('movie', 'Movie night', 'pick', 'pick', '*', { pick: true }, NONE),
101
+ D('music', 'Music', 'pick', 'pick', '*', { pick: true }, NONE),
102
+ ]);
103
+ const BY = new Map(DAYS.map((e) => [e.key, e]));
104
+ export const GROUPS = Object.freeze(['holidays', 'seasons', 'science', 'school', 'more', 'sports', 'exam']);
105
+ export const COLORS = Object.freeze(['blue', 'red', 'white', 'gold', 'green', 'ink']);
106
+ /** The defaults of Settings > Adler > Dress for the day (lib/settings-store.js keeps the same ones). */
107
+ export const DRESS_DEFAULTS = Object.freeze({
108
+ 'adler.dress.on': true, 'adler.dress.place': '', 'adler.dress.climate': 'auto',
109
+ 'adler.dress.holidays': true, 'adler.dress.seasons': true, 'adler.dress.science': true, 'adler.dress.school': true,
110
+ 'adler.dress.sports': false, 'adler.dress.colors': ['blue', 'green'], 'adler.dress.exam': false,
111
+ 'adler.dress.pmosday': true, 'adler.dress.birthday': '', 'adler.dress.days': {}, 'adler.dress.skip': {}, 'adler.dress.wear': null,
112
+ });
113
+
114
+ /* ── dates: a day is a whole number (days since 1970-01-01 of the local calendar), so no daylight-saving hour can move it ── */
115
+ const p2 = (n) => String(n).padStart(2, '0');
116
+ const dn = (y, m, d) => Math.floor(Date.UTC(y, m - 1, d) / 864e5);
117
+ const ymd = (n) => { const t = new Date(n * 864e5); return { y: t.getUTCFullYear(), m: t.getUTCMonth() + 1, d: t.getUTCDate(), w: t.getUTCDay() }; };
118
+ const iso = (n) => { const t = ymd(n); return `${t.y}-${p2(t.m)}-${p2(t.d)}`; };
119
+ const parse = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s); return m ? dn(+m[1], +m[2], +m[3]) : null; };
120
+ /** The wall clock of a moment in a time zone (Settings' time.zone, else the computer's), as the ms of that wall clock read as UTC. */
121
+ function wall(ms, zone) {
122
+ const t = new Date(ms);
123
+ if (zone) {
124
+ try {
125
+ const f = new Intl.DateTimeFormat('en-CA', { timeZone: zone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' });
126
+ const o = Object.fromEntries(f.formatToParts(t).map((x) => [x.type, x.value]));
127
+ return Date.UTC(+o.year, +o.month - 1, +o.day, +o.hour % 24, +o.minute);
128
+ } catch { /* an unknown zone: the computer's */ }
129
+ }
130
+ return Date.UTC(t.getFullYear(), t.getMonth(), t.getDate(), t.getHours(), t.getMinutes());
131
+ }
132
+ /** The local day (see dn) and hour of a moment. */
133
+ const localOf = (now, zone) => { const w = wall(now, zone); return { day: Math.floor(w / 864e5), hour: new Date(w).getUTCHours() }; };
134
+ /** The first millisecond of a local day, as a real moment. */
135
+ function startOf(day, zone) {
136
+ if (!zone) { const t = ymd(day); return new Date(t.y, t.m - 1, t.d).getTime(); }
137
+ const g = day * 864e5, s = g - (wall(g, zone) - g);
138
+ return s + (g - wall(s, zone)); // one more step when the offset changes between the guess and the answer
139
+ }
140
+ const endOf = (day, zone) => startOf(day + 1, zone) - 1;
141
+ function easter(y) {
142
+ const a = y % 19, b = Math.floor(y / 100), c = y % 100, d = Math.floor(b / 4), e = b % 4, f = Math.floor((b + 8) / 25), g = Math.floor((b - f + 1) / 3);
143
+ const h = (19 * a + b - d - g + 15) % 30, i = Math.floor(c / 4), k = c % 4, l = (32 + 2 * e + 2 * i - h - k) % 7, m = Math.floor((a + 11 * h + 22 * l) / 451);
144
+ const mo = Math.floor((h + l - 7 * m + 114) / 31), da = ((h + l - 7 * m + 114) % 31) + 1;
145
+ return dn(y, mo, da);
146
+ }
147
+ const nth = (y, m, wd, n) => { const first = dn(y, m, 1), w = ymd(first).w; return first + ((wd - w + 7) % 7) + (n - 1) * 7; };
148
+ const SEASON = { north: { spring: ['03-01', '05-31'], summer: ['06-01', '08-31'], autumn: ['09-01', '11-30'], winter: ['12-01', '02-29'] }, south: { spring: ['09-01', '11-30'], summer: ['12-01', '02-29'], autumn: ['03-01', '05-31'], winter: ['06-01', '08-31'] } };
149
+ const mmdd = (y, s) => dn(y, +s.slice(0, 2), Math.min(+s.slice(3, 5), ymd(dn(y, +s.slice(0, 2) + 1, 1) - 1).d));
150
+ /** A span 'MM-DD'..'MM-DD' as the core ranges that touch year y (one that crosses New Year gives the end of y-1 and the start of y). */
151
+ const spanOf = (y, [a, b]) => (a <= b ? [[mmdd(y, a), mmdd(y, b)]] : [[mmdd(y - 1, a), mmdd(y, b)], [mmdd(y, a), mmdd(y + 1, b)]]);
152
+
153
+ /** The occurrences of an entry near year y: { core: [from, to], day, sure } (day = the day itself; for a range, its first day). */
154
+ function occurrences(e, y, prefs, place) {
155
+ const r = e.rule, out = [];
156
+ const one = (n) => out.push({ core: [n, n], day: n, sure: true });
157
+ for (const Y of [y - 1, y, y + 1]) {
158
+ if (r.fixed) one(mmdd(Y, r.fixed));
159
+ else if (r.nth) one(nth(Y, r.nth[0], r.nth[1], r.nth[2]));
160
+ else if (r.easter !== undefined) one(easter(Y) + r.easter);
161
+ else if (r.national) { const s = NATIONAL[place.country]; if (s && place.country !== 'SG') one(mmdd(Y, s)); }
162
+ else if (r.years && r.years[Y] !== undefined) {
163
+ const v = r.years[Y], a = Array.isArray(v) ? v : [v, v];
164
+ const sure = !a.some((s) => s.startsWith('~')), f = parse(a[0].replace('~', '')), t = parse(a[1].replace('~', ''));
165
+ if (f !== null && t !== null) out.push({ core: [f, t], day: f, sure });
166
+ } else if (r.yours === 'birthday') {
167
+ const b = prefs['adler.dress.birthday'];
168
+ if (/^\d{2}-\d{2}$/.test(b || '')) one(mmdd(Y, b));
169
+ } else if (r.yours === 'since') {
170
+ const s = parse(prefs['adler.dress.since'] || '');
171
+ if (s !== null) { const t = ymd(s); if (Y > t.y) out.push({ core: [mmdd(Y, `${p2(t.m)}-${p2(t.d)}`), mmdd(Y, `${p2(t.m)}-${p2(t.d)}`)], day: mmdd(Y, `${p2(t.m)}-${p2(t.d)}`), sure: true, years: Y - t.y }); }
172
+ }
173
+ }
174
+ if (r.season && place.climate !== 'tropics') for (const [f, t] of spanOf(y, SEASON[place.climate][r.season])) out.push({ core: [f, t], day: f, sure: true });
175
+ if (r.span) for (const [f, t] of spanOf(y, r.span)) out.push({ core: [f, t], day: f, sure: true });
176
+ return out;
177
+ }
178
+
179
+ /* ── where you are ── */
180
+ const regionOfLocale = (l) => { const m = /[-_]([A-Z]{2})\b/.exec(String(l || '')); return m ? m[1] : ''; };
181
+ /** Your country and climate: Settings' override, else the computer's time zone, else its language region. */
182
+ export function placeOf(prefs = {}, env = {}) {
183
+ let country = prefs['adler.dress.place'] || '', auto = !country;
184
+ if (!country) {
185
+ let zone = env.zone, locale = env.locale;
186
+ try { const o = Intl.DateTimeFormat().resolvedOptions(); zone = zone || o.timeZone; locale = locale || o.locale; } catch { /* no Intl */ }
187
+ if (!locale && typeof navigator !== 'undefined') locale = navigator.language;
188
+ country = ZONES[zone] || regionOfLocale(locale) || '';
189
+ }
190
+ const cl = prefs['adler.dress.climate'];
191
+ const climate = CLIMATES[cl] ? cl : TROPICS.has(country) ? 'tropics' : SOUTH.has(country) ? 'south' : 'north';
192
+ return { country, climate, auto, name: PLACES[country] || country || 'Your place' };
193
+ }
194
+ const keptHere = (e, place) => e.where === '*' || e.where.includes(place.country);
195
+
196
+ /** Is this day switched on for you: its group's switch, then its own switch in "More festivals" (adler.dress.days) where it has one. */
197
+ export function enabled(e, prefs = {}, place = placeOf(prefs)) {
198
+ const P = { ...DRESS_DEFAULTS, ...prefs }, own = P['adler.dress.days'] || {};
199
+ if (e.kind === 'qt') return keptHere(e, place);
200
+ if (e.kind === 'me') return e.key === 'pmosday' ? P['adler.dress.pmosday'] !== false : /^\d{2}-\d{2}$/.test(P['adler.dress.birthday'] || '');
201
+ if (e.kind === 'pick') { const w = P['adler.dress.wear']; return !!(w && w.key === e.key); }
202
+ if (e.climate && e.climate !== place.climate) return false;
203
+ if (e.group === 'seasons' || e.group === 'science' || e.group === 'sports' || e.group === 'exam' || e.group === 'school') return P['adler.dress.' + e.group] === true && keptHere(e, place);
204
+ if (typeof own[e.key] === 'boolean') return own[e.key];
205
+ if (e.group === 'holidays') return P['adler.dress.holidays'] === true && keptHere(e, place);
206
+ return e.kind === 'on' && keptHere(e, place);
207
+ }
208
+ /** The rows of "More festivals and national days": the opt-in days and the festivals kept elsewhere, each with its own switch. */
209
+ export function moreDays(prefs = {}, place = placeOf(prefs)) {
210
+ return DAYS.filter((e) => e.group === 'more' || (e.group === 'holidays' && e.kind === 'on' && !keptHere(e, place)))
211
+ .map((e) => ({ key: e.key, name: e.key === 'natday' ? nationalName(place) : e.name, on: enabled(e, prefs, place), here: keptHere(e, place) }));
212
+ }
213
+ const nationalName = (place) => (NATIONAL[place.country] && place.country !== 'SG' ? `National Day (${PLACES[place.country]})` : 'Other national days');
214
+
215
+ /* ── the pick of the day ── */
216
+ // your days, your pick, festivals where you live, other events, the season
217
+ const rankOf = (e, place) => (e.kind === 'me' ? 0 : e.kind === 'pick' ? 1 : e.group === 'seasons' ? 4 : e.where !== '*' && e.where.includes(place.country) ? 2 : 3);
218
+ // the Your day greeting wishes "Happy <name>" on the day itself; not for a season, a pick, sports or Ramadan evenings
219
+ const WISH = (e) => !background(e) && e.kind !== 'pick' && e.group !== 'sports' && e.key !== 'ramadan';
220
+ const background = (e) => e.group === 'seasons' || e.group === 'exam';
221
+
222
+ /** Every charm that could be worn on local day `day`: { e, o, dist } (dist 0 inside the core, else days to its nearest edge). */
223
+ function candidates(day, hour, prefs, place) {
224
+ const out = [], y = ymd(day).y, P = { ...DRESS_DEFAULTS, ...prefs }, skip = P['adler.dress.skip'] || {};
225
+ for (const e of DAYS) {
226
+ if (e.kind === 'pick') { const w = P['adler.dress.wear']; if (w && w.key === e.key && parse(w.day) === day) out.push({ e, o: { core: [day, day], day, sure: true }, dist: 0 }); continue; }
227
+ if (!enabled(e, P, place)) continue;
228
+ for (const o of occurrences(e, y, P, place)) {
229
+ const [b, a] = e.win, from = o.core[0] - b, to = o.core[1] + a;
230
+ if (day < from || day > to) continue;
231
+ if (e.kind !== 'qt' && !o.sure) continue; // not confirmed yet: the charm waits
232
+ if (e.kind !== 'qt' && skip[e.key] === ymd(o.day).y) continue; // "Not this one", this year
233
+ if (e.evening && hour < e.evening) continue;
234
+ out.push({ e, o, from, to, dist: day < o.core[0] ? o.core[0] - day : day > o.core[1] ? day - o.core[1] : 0 });
235
+ }
236
+ }
237
+ return out;
238
+ }
239
+ function pick(day, hour, prefs, place) {
240
+ const all = candidates(day, hour, prefs, place);
241
+ if (all.some((c) => c.e.kind === 'qt' && c.dist === 0)) return null; // a solemn day: nothing is worn
242
+ const front = all.filter((c) => c.e.kind !== 'qt' && !background(c.e)), pool = front.length ? front : all.filter((c) => c.e.kind !== 'qt');
243
+ pool.sort((x, y) => (front.length ? x.dist - y.dist : 0) || rankOf(x.e, place) - rankOf(y.e, place) || x.o.day - y.o.day);
244
+ return pool[0] || null;
245
+ }
246
+ const off = (P) => P['adler.dress.on'] === false || (P['adler.amount'] && P['adler.amount'] !== 'full');
247
+ const zoneOf = (P) => P['time.zone'] || '';
248
+
249
+ /** The charm Adler wears now, or null. prefs: the flat settings map (adler.amount, adler.dress.*, time.zone), env: { zone, locale } for tests.
250
+ * → { key, name, until, from, day, today, group, colors?, country?, extra?, night?, years? } */
251
+ export function charmToday(now = Date.now(), prefs = {}, env = {}) {
252
+ const P = { ...DRESS_DEFAULTS, ...prefs };
253
+ if (off(P)) return null;
254
+ const place = placeOf(P, env), zone = zoneOf(P), L = localOf(now, zone), c = pick(L.day, L.hour, P, place);
255
+ if (!c) return null;
256
+ const e = c.e;
257
+ // until: the last day this same charm still wins (a nearer day can take over before the window ends)
258
+ let last = L.day;
259
+ if (e.kind !== 'pick') for (let d = L.day + 1, cap = L.day + 120; d <= cap; d++) { const n = pick(d, 23, P, place); if (!n || n.e.key !== e.key || n.o.day !== c.o.day) break; last = d; }
260
+ let first = L.day;
261
+ for (let d = L.day - 1, cap = L.day - 120; d >= cap; d--) { const n = pick(d, 23, P, place); if (!n || n.e.key !== e.key || n.o.day !== c.o.day) break; first = d; }
262
+ const out = { key: e.key, name: e.key === 'natday' ? nationalName(place) : e.name, group: e.group, from: startOf(first, zone), until: endOf(last, zone), day: iso(c.o.day), today: c.dist === 0 && WISH(e) };
263
+ if (e.group === 'sports') out.colors = cleanColors(P['adler.dress.colors']);
264
+ if (e.key === 'natday') out.country = place.country;
265
+ if (e.key === 'christmas' && L.day >= c.o.day - 1 && L.day <= c.o.day + 1) out.extra = 'gift'; // the gift shows 24-26 Dec only
266
+ if (e.key === 'ndp' && L.day === c.o.day && L.hour >= 19) out.extra = 'fireworks'; // fireworks on the evening of the 9th
267
+ if (e.key === 'hanukkah' && c.dist === 0) out.night = L.day - c.o.core[0] + 1; // one more candle each night
268
+ if (c.o.years) out.years = c.o.years;
269
+ return out;
270
+ }
271
+ /** The next charm that starts after today, within a year: Settings' "Next: Deepavali. He wears it from 1 Nov." */
272
+ export function nextCharm(now = Date.now(), prefs = {}, env = {}) {
273
+ const P = { ...DRESS_DEFAULTS, ...prefs };
274
+ if (off(P)) return null;
275
+ const place = placeOf(P, env), zone = zoneOf(P), L = localOf(now, zone), cur = pick(L.day, L.hour, P, place);
276
+ let prev = cur ? cur.e.key + cur.o.day : '';
277
+ for (let d = L.day + 1; d <= L.day + 400; d++) {
278
+ const n = pick(d, 23, P, place), k = n ? n.e.key + n.o.day : '';
279
+ if (n && k !== prev && !background(n.e)) return { key: n.e.key, name: n.e.key === 'natday' ? nationalName(place) : n.e.name, from: startOf(d, zone), day: iso(n.o.day) };
280
+ prev = k;
281
+ }
282
+ return null;
283
+ }
284
+ const cleanColors = (c) => (Array.isArray(c) && c.length === 2 && c.every((x) => COLORS.includes(x)) ? [...c] : [...DRESS_DEFAULTS['adler.dress.colors']]);
285
+
286
+ /* ── the setting rows the page posts ── */
287
+ /** "Not this one" (the eye-off in the tap popover): that day stays off for the rest of this year. Older years are dropped. */
288
+ export function skipThisYear(key, now = Date.now(), prefs = {}) {
289
+ const P = { ...DRESS_DEFAULTS, ...prefs }, L = localOf(now, zoneOf(P));
290
+ const c = pick(L.day, L.hour, P, placeOf(P));
291
+ const year = c && c.e.key === key ? ymd(c.o.day).y : ymd(L.day).y;
292
+ const was = P['adler.dress.skip'] || {}, value = {};
293
+ for (const [k, v] of Object.entries(was)) if (BY.has(k) && Number.isInteger(v) && v >= ymd(L.day).y - 1) value[k] = v;
294
+ if (BY.has(key)) value[key] = year;
295
+ return { key: 'adler.dress.skip', value };
296
+ }
297
+ /** "Wear now" Movie night or Music until midnight; '' takes it off. */
298
+ export function wearNow(key, now = Date.now(), prefs = {}) {
299
+ const P = { ...DRESS_DEFAULTS, ...prefs };
300
+ return { key: 'adler.dress.wear', value: key === 'movie' || key === 'music' ? { key, day: iso(localOf(now, zoneOf(P)).day) } : null };
301
+ }
302
+ /** The flat map from GET /api/settings' rows ({ key, value }): adler.amount, time.zone and every adler.dress.* key. */
303
+ export function dressPrefs(settings) {
304
+ const o = { ...DRESS_DEFAULTS };
305
+ for (const s of Array.isArray(settings) ? settings : []) if (s && (s.key in DRESS_DEFAULTS || s.key === 'adler.amount' || s.key === 'time.zone')) o[s.key] = s.value;
306
+ o['adler.dress.since'] = sinceDay();
307
+ return o;
308
+ }
309
+ /* Your PMOS day: a year since you started. PMOS keeps no first-initiative date a page can read yet, so this computer remembers the first
310
+ * day it ran this calendar (localStorage pmos.adler.since). */
311
+ function sinceDay() {
312
+ try {
313
+ const k = 'pmos.adler.since', v = localStorage.getItem(k);
314
+ if (/^\d{4}-\d{2}-\d{2}$/.test(v || '')) return v;
315
+ const t = new Date(), s = `${t.getFullYear()}-${p2(t.getMonth() + 1)}-${p2(t.getDate())}`;
316
+ localStorage.setItem(k, s); return s;
317
+ } catch { return ''; }
318
+ }
@@ -4,6 +4,9 @@
4
4
  * time.workEnd, POST /api/settings), Your impact (impact.on, POST /api/settings; canvas GmP1Switch, batch 16 item 7: the one switch
5
5
  * for Adler's leaf, the impact log and the weekly check; the page hears `pmos:impact`), Agents write to Jira (fixed: only after Commit)
6
6
  * Adler how much of Claude's face shows, Motion, Celebrations, Quiet after (adler.*, POST /api/settings; canvas AdM5, batch 16 item 2)
7
+ * › Dress for the day (adler.dress.*, canvas AsSet1, batch 18 item 8): the master switch, where you are, one switch per group,
8
+ * "More festivals" with one switch per day, big sports and your colours, exam season, your days, Wear now (pm/cozy-seasons.js).
9
+ * openSettings('dress') opens it straight away (the › in Adler's tap popover, AsSet2Tap).
7
10
  * Connectors each source's last read (GET /api/sources; was the Sources card, feedback batch 16 item 5, canvas FmA3Settings): the amber dot
8
11
  * and ↻ Read again on a stale or failed one (POST /api/sources/refresh), ↻ in the header reads every source
9
12
  * (POST /api/sources/refresh-all); then what PMOS reads on its own, and the connectors your sessions have (GET and POST
@@ -23,12 +26,13 @@ import { pmGet, pmPost } from './http.js';
23
26
  import { esc, svg, ICON, toast, wsParam, wsQ } from './cozy-evui.js';
24
27
  import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
25
28
  import * as AD from './cozy-adler.js';
29
+ import * as SE from './cozy-seasons.js';
26
30
 
27
31
  const SECTIONS = [['general', 'General'], ['adler', 'Adler'], ['connectors', 'Connectors'], ['workspaces', 'Workspaces'], ['workflows', 'Workflows'], ['updates', 'Updates'], ['whatsnew', "What's new"]];
28
32
  const PAGE_LINKS = { workflows: '/premium-workflows.html' }; // a section that is a page of its own: the row goes there
29
33
  const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
30
34
  const VIEWER_KEY = 'pmos.cz.viewer';
31
- const T = { el: null, sec: 'general', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, lines: null };
35
+ const T = { el: null, sec: 'general', ws: null, st: {}, src: null, con: {}, conn: [], set: null, prods: null, msg: '', busy: false, phase: '', say: '', back: null, fresh: null, reading: '', note: {}, lines: null, dress: false, more: false, bday: false, dset: {} };
32
36
  const cmpVer = (a, b) => { const x = String(a || '0').split('-')[0].split('.').map(Number), y = String(b || '0').split('-')[0].split('.').map(Number); for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) < (y[i] || 0) ? -1 : 1; return 0; };
33
37
  const home = () => (T.ws && T.ws[0] ? T.st[T.ws[0].id] : null);
34
38
  const latest = () => { const s = home(); return (s && (s.latest || (s.lastCheck && s.lastCheck.latest))) || null; };
@@ -69,14 +73,79 @@ function general() {
69
73
  }
70
74
  /* Your impact (GmP1Switch): on by default; off hides every impact surface and stops Claude's daily read */
71
75
  function impactOn() { const x = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((y) => y.key === 'impact.on') : null; return x ? x.value !== false : true; }
76
+ /** One Dress for the day press: POST /api/settings, keep the row, and tell the page (the event adler:dress) so Adler changes at once. */
77
+ async function saveDress(key, value, said = 'Saved.') {
78
+ const r = await pmPost('/api/settings', { key, value });
79
+ if (r && r.ok) {
80
+ T.dset[key] = r.value === undefined ? value : r.value;
81
+ const x = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((y) => y.key === key) : null; if (x) x.value = T.dset[key];
82
+ document.dispatchEvent(new CustomEvent('adler:dress', { detail: dp() }));
83
+ }
84
+ T.msg = r && r.ok ? said : (r && r.error) || 'Not saved.';
85
+ draw();
86
+ }
72
87
  /* Settings > Adler (AdM5): four choices, each saved for this computer the moment it is pressed */
73
88
  function adlerSec() {
89
+ if (T.dress) return dressSec();
74
90
  const P = AD.prefs();
75
91
  return `<div class="ev-ad-hd">${AD.adler('handled', 48)}<p class="ev-small ev-mut">Adler is how Claude shows its mood in PMOS. You choose how much of him you see.</p></div>`
76
92
  + trow('How much Adler', 'Face only keeps his face where Claude speaks and drops the scenes. Off shows the plain mood dot.', seg('How much Adler', 'adler.amount', P['adler.amount'], [['full', 'Full'], ['face', 'Face only'], ['off', 'Off']]))
77
93
  + trow('Motion', 'Still stops every animation. Reduced motion on your computer always stops it.', seg('Motion', 'adler.motion', P['adler.motion'], [['system', 'Follow my computer'], ['still', 'Still']]))
78
94
  + trow('Celebrations', 'At most once a week, and only for a real event.', seg('Celebrations', 'adler.celebrate', P['adler.celebrate'], [['real', 'Real wins only'], ['never', 'Never']]))
79
- + trow('Quiet after', 'After this time, opening PMOS shows Adler asleep and nothing urgent.', seg('Quiet after', 'adler.quiet', P['adler.quiet'], [['22', '22:00'], ['never', 'Never']]));
95
+ + trow('Quiet after', 'After this time, opening PMOS shows Adler asleep and nothing urgent.', seg('Quiet after', 'adler.quiet', P['adler.quiet'], [['22', '22:00'], ['never', 'Never']]))
96
+ + trow('Dress for the day', dressLine(), `<button type="button" class="ev-ib" data-ev-dress="open" aria-label="Dress for the day" title="Dress for the day">${svg(CHEV, 18)}</button>`);
97
+ }
98
+
99
+ /* ── Settings > Adler > Dress for the day (AsSet1): every switch is saved for this computer the moment it is pressed ── */
100
+ const CHEV = 'M10 7l5 5-5 5', BACK = 'M15 18l-6-6 6-6', PLUS = 'M12 5v14M5 12h14', CROSS = 'M6 6l12 12M18 6L6 18';
101
+ const COLOR_NAMES = { blue: 'Blue', red: 'Red', white: 'White', gold: 'Gold', green: 'Green', ink: 'Black' };
102
+ // T.dset: what was saved while this dialog is open, so a GET /api/settings that lands after a press never undoes it
103
+ const dp = () => ({ ...SE.dressPrefs(T.set && T.set.settings), ...T.dset, 'adler.amount': AD.prefs()['adler.amount'] });
104
+ const dmy = (ms) => new Date(ms).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' });
105
+ /** The Adler row's second line: what he wears now, or the next one, or why he does not dress. */
106
+ function dressLine() {
107
+ const P = dp();
108
+ if (P['adler.dress.on'] === false) return 'Off. He wears his hoodie every day.';
109
+ if (P['adler.amount'] !== 'full') return 'He dresses only when How much Adler is Full.';
110
+ const now = SE.charmToday(Date.now(), P), nx = now ? null : SE.nextCharm(Date.now(), P);
111
+ return now ? `Today: ${now.name}, until ${dmy(now.until)}.` : nx ? `Next: ${nx.name}, from ${dmy(nx.from)}.` : 'For festivals and seasons where you live.';
112
+ }
113
+ const dsw = (key, on, label) => sw(on, `data-ev-dsw="${key}"`, label);
114
+ function dressSec() {
115
+ const P = dp(), place = SE.placeOf(P), on = P['adler.dress.on'] !== false, full = P['adler.amount'] === 'full';
116
+ const now = on && full ? SE.charmToday(Date.now(), P) : null, nx = on && full && !now ? SE.nextCharm(Date.now(), P) : null, c = now || nx;
117
+ const head = `<div class="ev-dr-hd"><button type="button" class="ev-ib" data-ev-dress="back" aria-label="Back to Adler" title="Back">${svg(BACK, 18)}</button><h4 class="ev-grow">Dress for the day</h4>${dsw('adler.dress.on', on, 'Dress for the day')}</div>`;
118
+ if (!on) return head + '<p class="ev-small ev-mut">Adler wears his hoodie every day.</p>';
119
+ const banner = !full ? '<p class="ev-small ev-mut">How much Adler is not Full, so he does not dress up.</p>'
120
+ : c ? `<div class="ev-dr-now">${AD.adler('handled', 48, { charm: c.key, label: false })}<p><b>${esc(now ? 'Today: ' + now.name : 'Next: ' + nx.name)}</b><span class="ev-small ev-mut">${esc(now ? 'He wears it until ' + dmy(now.until) + '.' : 'He wears it from ' + dmy(nx.from) + '.')}</span></p></div>` : '';
121
+ const hol = SE.DAYS.filter((e) => e.group === 'holidays' && (e.where === '*' || e.where.includes(place.country)));
122
+ const quiet = hol.filter((e) => e.kind === 'qt' && e.key !== 'seventh').map((e) => e.name);
123
+ const sea = place.climate === 'tropics' ? (SE.DAYS.find((e) => e.key === 'monsoon').where.includes(place.country) ? 'Monsoon, Dec to early Mar' : 'None in the tropics where you are') : 'Spring, summer, autumn and winter';
124
+ const more = SE.moreDays(P, place), mOn = more.filter((x) => x.on);
125
+ const moreSub = (mOn.length ? mOn.length + ' on · ' : 'Off · ') + more.filter((x) => !x.on).slice(0, 4).map((x) => x.name).join(', ') + '…';
126
+ const cols = P['adler.dress.colors'] || ['blue', 'green'];
127
+ const colSel = (i) => `<label class="ev-vh" for="evCol${i}">Colour ${i + 1}</label><select id="evCol${i}" class="ev-inp" data-ev-dcol="${i}">${SE.COLORS.map((k) => `<option value="${k}"${cols[i] === k ? ' selected' : ''}>${COLOR_NAMES[k]}</option>`).join('')}</select>`;
128
+ const b = P['adler.dress.birthday'], bdate = b ? new Date(2000, +b.slice(0, 2) - 1, +b.slice(3)).toLocaleDateString('en-GB', { day: 'numeric', month: 'long' }) : '';
129
+ const bday = b ? `<span class="ev-small">${esc(bdate)}</span><button type="button" class="ev-ib" data-ev-dress="bday-off" aria-label="Remove your birthday" title="Remove your birthday">${svg(CROSS, 16)}</button>`
130
+ : T.bday ? `<label class="ev-vh" for="evBday">Your birthday</label><input id="evBday" type="date" class="ev-inp" data-ev-bday>`
131
+ : `<button type="button" class="ev-ib" data-ev-dress="bday" aria-label="Add your birthday" title="Add your birthday">${svg(PLUS, 18)}</button>`;
132
+ const w = P['adler.dress.wear'], today = SE.wearNow('movie', Date.now(), P).value.day;
133
+ const wear = (k, n) => { const worn = !!(w && w.key === k && w.day === today); return `<button type="button" class="ev-wear" data-ev-wear="${k}" aria-pressed="${worn}" aria-label="${esc((worn ? 'Take off ' : 'Wear ') + n + ' until midnight')}" title="${esc(n)}">${AD.adler('handled', 40, { charm: k, label: false })}<span class="ev-small">${esc(n)}</span></button>`; };
134
+ const placeOpts = `<option value="">From my computer${place.auto && place.country ? ' (' + esc(SE.PLACES[place.country] || place.country) + ')' : ''}</option>` + Object.entries(SE.PLACES).map(([k, n]) => `<option value="${k}"${P['adler.dress.place'] === k ? ' selected' : ''}>${esc(n)}</option>`).join('');
135
+ const clOpts = [['auto', 'Climate from the place'], ['tropics', 'Tropics'], ['north', 'North'], ['south', 'South']].map(([k, n]) => `<option value="${k}"${(P['adler.dress.climate'] || 'auto') === k ? ' selected' : ''}>${n}</option>`).join('');
136
+ return head + banner
137
+ + trow(place.name + ' · ' + place.climate, place.auto ? 'From your computer' : 'You chose it', `<span class="ev-dr-pl"><label class="ev-vh" for="evPlace">Where you are</label><select id="evPlace" class="ev-inp" data-ev-dsel="adler.dress.place">${placeOpts}</select><label class="ev-vh" for="evClimate">Climate</label><select id="evClimate" class="ev-inp" data-ev-dsel="adler.dress.climate">${clOpts}</select></span>`)
138
+ + trow('Public holidays in ' + place.name, hol.filter((e) => e.kind === 'on').length + ' days' + (quiet.length ? ' · ' + quiet.join(', ') + (quiet.length > 1 ? ' stay' : ' stays') + ' quiet' : ''), dsw('adler.dress.holidays', P['adler.dress.holidays'], 'Public holidays'))
139
+ + trow('Seasons', sea, dsw('adler.dress.seasons', P['adler.dress.seasons'], 'Seasons'))
140
+ + trow('Space and science days', 'Moon landing, Earth Day, Pi Day', dsw('adler.dress.science', P['adler.dress.science'], 'Space and science days'))
141
+ + trow('School days', place.country === 'SG' ? "Teachers' Day, Children's Day" : "Singapore's Teachers' Day and Children's Day", dsw('adler.dress.school', P['adler.dress.school'], 'School days'))
142
+ + trow('More festivals and national days', moreSub, `<button type="button" class="ev-ib" data-ev-dress="more" aria-expanded="${T.more}" aria-controls="evMore" aria-label="More festivals and national days" title="More festivals">${svg(T.more ? ICON.down : CHEV, 18)}</button>`)
143
+ + (T.more ? `<div class="ev-dr-more" id="evMore">${more.map((x) => trow(x.name, x.here ? '' : 'Kept elsewhere', sw(x.on, `data-ev-dday="${x.key}"`, x.name))).join('')}</div>` : '')
144
+ + trow('Big sports', (P['adler.dress.sports'] ? 'On' : 'Off') + ' · a scarf in your colours. No team marks', `<span class="ev-dr-pl">${colSel(0)}${colSel(1)}</span>${dsw('adler.dress.sports', P['adler.dress.sports'], 'Big sports')}`)
145
+ + trow('Exam season', 'PSLE, O and A levels, late Sep to mid Nov', dsw('adler.dress.exam', P['adler.dress.exam'], 'Exam season'))
146
+ + trow('Your PMOS day', 'A year since you started', dsw('adler.dress.pmosday', P['adler.dress.pmosday'] !== false, 'Your PMOS day'))
147
+ + trow('Your birthday', b ? 'First in line on the day' : 'Not added', bday)
148
+ + `<div class="ev-dr-wear"><div class="ev-trow"><b class="ev-grow">Wear now</b><span class="ev-small ev-mut">until midnight</span></div><div class="ev-dr-wbtns">${wear('movie', 'Movie night')}${wear('music', 'Music')}</div></div>`;
80
149
  }
81
150
  const firstLine = () => { const c = changes().find((e) => e.v === latest()); const p = c && c.prs && c.prs[0]; return p ? (p.t || p.s || '') : ''; };
82
151
  /* each source's last read (FmA3Settings): the name, "read 09:41", the amber dot and ↻ on a stale or failed one */
@@ -161,6 +230,10 @@ function mount() {
161
230
  // the dialog is modal: Escape closes it even when focus is outside it (a click on the scrim's edge, a redraw)
162
231
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && T.el && !T.el.hidden && !T.el.contains(e.target)) { e.preventDefault(); e.stopPropagation(); closeSettings(); } }, true);
163
232
  T.el.addEventListener('change', async (e) => {
233
+ const x = e.target;
234
+ if (x.matches('[data-ev-dsel]')) { await saveDress(x.dataset.evDsel, x.value); return; }
235
+ if (x.matches('[data-ev-dcol]')) { const c = [...(dp()['adler.dress.colors'] || ['blue', 'green'])]; c[Number(x.dataset.evDcol)] = x.value; await saveDress('adler.dress.colors', c); return; }
236
+ if (x.matches('[data-ev-bday]')) { if (!/^\d{4}-\d{2}-\d{2}$/.test(x.value)) return; T.bday = false; await saveDress('adler.dress.birthday', x.value.slice(5), 'Saved. He dresses up on your birthday.'); return; }
164
237
  if (!e.target.matches('[data-ev-day]')) return;
165
238
  const r = await pmPost('/api/settings', { key: 'time.workEnd', value: Number(e.target.value) });
166
239
  T.msg = r && r.ok ? 'Saved. The end-of-day card shows from ' + pad(Number(e.target.value)) + ':00.' : (r && r.error) || 'Not saved.';
@@ -172,11 +245,21 @@ function mount() {
172
245
  }
173
246
  async function press(e) {
174
247
  const t = e.target.closest('a[data-ev-sec], button'); if (!t) return;
175
- if (t.dataset.evSec) { e.preventDefault(); T.sec = t.dataset.evSec; T.msg = ''; draw(); const f = T.el.querySelector(`[data-ev-sec="${T.sec}"]`); if (f) f.focus(); return; }
248
+ if (t.dataset.evSec) { e.preventDefault(); T.sec = t.dataset.evSec; T.msg = ''; T.dress = false; draw(); const f = T.el.querySelector(`[data-ev-sec="${T.sec}"]`); if (f) f.focus(); return; }
176
249
  if ('evClose' in t.dataset) { closeSettings(); return; }
177
250
  if (t.dataset.evGo) { T.sec = t.dataset.evGo; draw(); return; }
178
251
  if (t.dataset.evSeg === 'theme') { const M = await import('./cozy-nav.js'); M.setTheme(t.dataset.v); draw(); return; }
179
252
  if (t.dataset.evSeg && t.dataset.evSeg.startsWith('adler.')) { const r = await AD.savePref(pmPost, t.dataset.evSeg, t.dataset.v); T.msg = r && r.ok ? 'Saved.' : (r && r.error) || 'Not saved.'; draw(); return; }
253
+ if (t.dataset.evDress) {
254
+ const a = t.dataset.evDress;
255
+ if (a === 'open' || a === 'back') { T.dress = a === 'open'; T.more = false; T.bday = false; T.msg = ''; draw(); const f = T.el.querySelector(a === 'open' ? '[data-ev-dress="back"]' : '[data-ev-dress="open"]'); if (f) f.focus(); return; }
256
+ if (a === 'more') { T.more = !T.more; draw(); return; }
257
+ if (a === 'bday') { T.bday = true; draw(); const f = T.el.querySelector('#evBday'); if (f) f.focus(); return; }
258
+ if (a === 'bday-off') { T.bday = false; await saveDress('adler.dress.birthday', '', 'Birthday removed.'); return; }
259
+ }
260
+ if (t.dataset.evDsw) { const k = t.dataset.evDsw, P = dp(), v = !(k === 'adler.dress.on' || k === 'adler.dress.pmosday' ? P[k] !== false : P[k] === true); await saveDress(k, v); return; }
261
+ if (t.dataset.evDday) { const P = dp(), x = SE.moreDays(P).find((y) => y.key === t.dataset.evDday); if (x) await saveDress('adler.dress.days', { ...(P['adler.dress.days'] || {}), [x.key]: !x.on }); return; }
262
+ if (t.dataset.evWear) { const P = dp(), k = t.dataset.evWear, w = P['adler.dress.wear'], worn = !!(w && w.key === k && w.day === SE.wearNow(k, Date.now(), P).value.day); const r = SE.wearNow(worn ? '' : k, Date.now(), P); await saveDress(r.key, r.value, worn ? 'Taken off.' : 'He wears it until midnight.'); return; }
180
263
  if ('evImpact' in t.dataset) {
181
264
  const on = !impactOn(), r = await pmPost('/api/settings', { key: 'impact.on', value: on });
182
265
  if (r && r.ok) { const x = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((y) => y.key === 'impact.on') : null; if (x) x.value = on; window.dispatchEvent(new CustomEvent('pmos:impact', { detail: { on } })); }
@@ -280,8 +363,8 @@ async function load() {
280
363
  }
281
364
  export function openSettings(section) {
282
365
  const el = mount();
283
- if (section && BODY[section]) T.sec = section;
284
- if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.fresh = null; T.note = {}; }
366
+ if (section === 'dress') { T.sec = 'adler'; T.dress = true; } else if (section && BODY[section]) { T.sec = section; T.dress = false; }
367
+ if (el.hidden) { const ae = document.activeElement; T.back = ae && ae !== document.body ? ae : null; T.ws = null; T.src = null; T.msg = ''; T.phase = ''; T.fresh = null; T.note = {}; T.dset = {}; }
285
368
  el.hidden = false; document.getElementById('evStScrim').hidden = false; el.setAttribute('data-esc-layer', '');
286
369
  draw();
287
370
  const f = el.querySelector('[aria-current="page"]'); if (f) f.focus();
@@ -444,6 +444,10 @@ body.cz-home .hv-r.sp-on + .hv-r::before { display: none; }
444
444
  .hv-card .hv-r.two .hm-rm { min-height: 58px; }
445
445
  }
446
446
  body.cz-home .hm-hd.hv-bar { padding: 0; }
447
+ /* batch 18 item 10: the greeting is never cut. When it and the controls do not fit on one line, the controls go to a second line on the right, together */
448
+ body.cz-home .hm-hd.hv-bar { flex-wrap: wrap; height: auto; min-height: 44px; }
449
+ body.cz-home .hm-hd.hv-bar > .hv-hi { flex: 1 0 auto; max-width: 100%; }
450
+ .hv-acts { display: flex; align-items: center; gap: inherit; margin-left: auto; }
447
451
 
448
452
  /* A session's context (batch 13 item 8, XctxA1Desk): the pie sits at the row's end. Claude's ✦ Compact uses item 7's ✦ and ✓ (.hm-sv, .hm-cls) */
449
453
  .hm-rm .cz-ctx { margin: 0 6px 0 8px; }
@@ -500,6 +504,7 @@ body.cz-home .hm-hd.hv-bar { padding: 0; }
500
504
  .yd-nd { width: 8px; height: 8px; border-radius: 4px; background: var(--cz-blue); flex: none; margin-top: 12px; }
501
505
  .yd-av { width: 32px; height: 32px; border-radius: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-1); font-weight: 800; }
502
506
  .yd-av.b { background: var(--cz-bluebg); color: var(--cz-blueink); }
507
+ .yd-av.sp { background: var(--cz-bluebg); color: var(--cz-blue); border-radius: 10px; }
503
508
  .yd-nw .yd-mt b { font-weight: 600; }
504
509
  .yd-more { align-self: flex-start; border: 0; background: none; padding: 6px 6px 8px 58px; min-height: 36px; font: inherit; font-size: var(--fs-3); font-weight: 700; color: var(--cz-blueink); cursor: pointer; }
505
510
  .yd-all { width: 40px; height: 40px; border-radius: 20px; border: 0; background: none; color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
@@ -36,8 +36,9 @@
36
36
  * sub one quiet line under the title: what the item is when the title is its parent's name (a program's "Charter", canvas MsBCharter)
37
37
  * chip { n, label, on(button) }: the blue ✦ with its count right after the title (what Claude proposes on an initiative, batch 12
38
38
  * items 2, 3 and 4, canvas In development PiA0/TpA1). Hidden at zero. setChip(id, chip) changes it while the item is shown.
39
- * presses [{ act, label, icon, text?, solid?, pressed? }]: the item's own presses before ⋯ (a program's charter icon, canvas MsB0Entry; the
40
- * charter's Save, MsBCharter). text draws the word beside the icon (not on a phone); solid is the one dark primary.
39
+ * presses [{ act, label, icon, text?, solid?, blue?, pressed? }]: the item's own presses before ⋯ (a program's charter icon, canvas MsB0Entry; the
40
+ * charter's Save, MsBCharter). text draws the word beside the icon (not on a phone); solid is the one dark primary; blue
41
+ * makes it the round blue ✓ a form saves with (batch 18 item 2-C, canvas OvA8People, OvA9Docs).
41
42
  * onPress(act, button) runs them. setPresses(id, list) changes them while the item is shown (Save shows only after a change).
42
43
  * guard (go, anchor) → true when the item holds unsaved changes and asks first: Close, ←, Escape and another open() call it, and
43
44
  * nothing leaves until the caller runs go() (canvas MsB5Leave: Save or Discard). false or none: it leaves at once.
@@ -131,10 +132,12 @@ export function headHtml(it) {
131
132
  const phone = !!o.phone;
132
133
  const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
133
134
  const disc = o.discuss && (!o.home || o.discussHome) ? ib('discuss', 'Discuss in chat', P.chat) : '';
134
- const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
135
+ // a press marked menu (the initiative's Dashboard, batch 18 item 1) goes into ⋯ on a phone, so the title keeps the room
136
+ const inMenu = phone && (o.presses || []).some((x) => x && x.menu && x.act && x.label);
137
+ const more = inMenu || typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
135
138
  const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
136
- const own = (o.presses || []).filter((x) => x && x.act && x.label).map((x) => x.solid
137
- ? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
139
+ const own = (o.presses || []).filter((x) => x && x.act && x.label && !(phone && x.menu)).map((x) => x.solid
140
+ ? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}${x.blue ? ' blue' : ''}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
138
141
  : `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}"${x.pressed != null ? ` aria-pressed="${x.pressed ? 'true' : 'false'}"` : ''}>${svg(path(x.icon), 18)}</button>`).join('');
139
142
  const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
140
143
  const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'Claude proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'Claude proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
@@ -142,7 +145,7 @@ export function headHtml(it) {
142
145
  + (o.fwdTo ? ib('fwd', 'Forward to ' + o.fwdTo, P.fwd) : '')
143
146
  + (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
144
147
  : `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
145
- + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
148
+ + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
146
149
  + disc + own + add + more
147
150
  + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
148
151
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
@@ -318,6 +321,8 @@ function moreMenu(b) {
318
321
  const old = V.el.querySelector('.cz-vw-menu');
319
322
  if (old) { old.remove(); b.setAttribute('aria-expanded', 'false'); return; }
320
323
  const items = ((typeof V.cur.more === 'function' ? V.cur.more() : V.cur.more) || []).filter(Boolean).slice(); // a function is asked each time ⋯ opens, so its notes are current
324
+ // on a phone the presses marked menu lead the menu (they left the header)
325
+ if (V.ph) { const mp = (V.cur.presses || []).filter((x) => x && x.menu && x.act && x.label); if (mp.length) items.unshift(...mp.map((x) => ({ label: x.label, icon: x.icon, on: () => { if (typeof V.cur.onPress === 'function') V.cur.onPress(x.act, b); } })), { sep: true }); }
321
326
  if (V.cur.url) { // the item's own address looks back, so it goes before the red stop-or-remove group, which stays last
322
327
  const at = items.findIndex((x) => x && x.danger), tab = { label: V.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(V.cur.url, '_blank', 'noopener') };
323
328
  if (at < 0) items.push({ sep: true }, tab); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, tab);
@@ -492,7 +497,7 @@ export function open(it) {
492
497
  V.drill = false; H.adopt = false;
493
498
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
494
499
  leave();
495
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
500
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, wrap: !!o.wrap, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
496
501
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
497
502
  redraw();
498
503
  el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());