create-pmos 0.441.0 → 0.443.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 (87) 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-board-test.js +19 -17
  9. package/workspace/briefing-premium-initiative-test.js +7 -4
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/goals-clear-ui-test.js +249 -0
  12. package/workspace/guide/adler.md +10 -0
  13. package/workspace/guide/home.md +8 -1
  14. package/workspace/guide/metric-drafts.md +8 -2
  15. package/workspace/home-railcard-test.js +193 -0
  16. package/workspace/ini-workflow-test.js +6 -2
  17. package/workspace/intelligence-gaps-ui-test.js +16 -14
  18. package/workspace/lib/engine/records/index.js +9 -2
  19. package/workspace/lib/initiative-layout.js +3 -1
  20. package/workspace/lib/insights-premium.js +22 -1
  21. package/workspace/lib/metric-drafts.js +37 -10
  22. package/workspace/lib/metric-read-runs.js +20 -13
  23. package/workspace/lib/metric-reads.js +208 -23
  24. package/workspace/lib/metrics-cli.js +62 -5
  25. package/workspace/lib/routes-goal-status.js +89 -6
  26. package/workspace/lib/routes-insights-premium.js +1 -1
  27. package/workspace/lib/routes-metric-drafts.js +26 -3
  28. package/workspace/lib/settings-store.js +38 -0
  29. package/workspace/metric-drafts-ui-test.js +7 -4
  30. package/workspace/okr-goals-ui-test.js +7 -5
  31. package/workspace/package-lock.json +2 -2
  32. package/workspace/package.json +1 -1
  33. package/workspace/premium-board-actions-test.js +2 -1
  34. package/workspace/premium-chat-attach-test.js +2 -0
  35. package/workspace/program-panel-test.js +1 -1
  36. package/workspace/public/pm/bd-ini-panel.js +2 -2
  37. package/workspace/public/pm/c3-ini-ui.js +1 -1
  38. package/workspace/public/pm/cozy-adler.css +21 -0
  39. package/workspace/public/pm/cozy-adler.js +415 -8
  40. package/workspace/public/pm/cozy-ev.css +16 -1
  41. package/workspace/public/pm/cozy-home.css +8 -0
  42. package/workspace/public/pm/cozy-insights.css +82 -0
  43. package/workspace/public/pm/cozy-live-pill.css +5 -0
  44. package/workspace/public/pm/cozy-news.js +1 -1
  45. package/workspace/public/pm/cozy-seasons.js +318 -0
  46. package/workspace/public/pm/cozy-settings.js +88 -5
  47. package/workspace/public/pm/cozy-today.css +15 -0
  48. package/workspace/public/pm/cozy-viewer.js +50 -18
  49. package/workspace/public/pm/cozy-vw-shell.css +4 -0
  50. package/workspace/public/pm/cozy.css +65 -0
  51. package/workspace/public/pm/dash-view.js +4 -2
  52. package/workspace/public/pm/goals-clear.js +258 -0
  53. package/workspace/public/pm/home-app.js +59 -5
  54. package/workspace/public/pm/home-chat.js +1 -1
  55. package/workspace/public/pm/home-day.js +7 -4
  56. package/workspace/public/pm/home-ini.js +2 -2
  57. package/workspace/public/pm/home-mentions.js +1 -1
  58. package/workspace/public/pm/home-today.js +51 -10
  59. package/workspace/public/pm/impact.js +1 -1
  60. package/workspace/public/pm/ini-groups.js +28 -17
  61. package/workspace/public/pm/ini-links.js +1 -1
  62. package/workspace/public/pm/ini-tasks.js +246 -48
  63. package/workspace/public/pm/ini-view-model.js +45 -16
  64. package/workspace/public/pm/ini-view.css +330 -1
  65. package/workspace/public/pm/ini-view.js +196 -83
  66. package/workspace/public/pm/metric-drafts.js +4 -1
  67. package/workspace/public/pm/mission.js +238 -0
  68. package/workspace/public/pm/premium-board.js +1 -1
  69. package/workspace/public/pm/premium-insights.js +178 -24
  70. package/workspace/public/pm/premium-welcome.js +2 -2
  71. package/workspace/public/pm/split-merge.js +1 -1
  72. package/workspace/public/pm/stage-line.js +2 -2
  73. package/workspace/server.js +6 -2
  74. package/workspace/skills/metric-read.skill +7 -5
  75. package/workspace/split-merge-ui-test.js +1 -1
  76. package/workspace/stage-card-test.js +56 -11
  77. package/workspace/task-links-test.js +2 -0
  78. package/workspace/task-milestones-test.js +5 -1
  79. package/workspace/task-plans-test.js +3 -3
  80. package/workspace/task-views-test.js +279 -37
  81. package/workspace/test-lists/adler-seasons-art.json +13 -0
  82. package/workspace/test-lists/batch18-adler-seasons.json +13 -0
  83. package/workspace/test-lists/goals-clear.json +15 -0
  84. package/workspace/test-lists/home-railcard.json +9 -0
  85. package/workspace/test-lists/mission.json +5 -0
  86. package/workspace/test-lists/viewer-tasks.json +5 -0
  87. package/workspace/tk-tasks-test.js +27 -32
@@ -560,6 +560,14 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
560
560
  .vwgoal .gpts li.sk s { color: var(--cz-ink3); }
561
561
  .hm-chat .atrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
562
562
  .hm-chat .atc { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 10px; background: var(--cz-card); font-size: var(--fs-2); cursor: pointer; border: 1px solid var(--cz-hair); }
563
+ /* batch 18 item 13: the chip's picture is a 36 px thumbnail (premium.css is not loaded on Home, so a pasted screenshot drew at full size out of
564
+ the bubble); the chip opens the file beside the conversation */
565
+ .hm-chat .atc { max-width: min(260px, 100%); min-width: 0; }
566
+ .atc .ath { width: 36px; height: 36px; border-radius: 8px; flex: none; object-fit: cover; background: var(--cz-well); display: block; }
567
+ .atc .atx { display: grid; place-items: center; font-size: var(--fs-1); font-weight: 700; letter-spacing: .04em; color: var(--cz-ink3); }
568
+ .atc .atn { display: grid; min-width: 0; text-align: left; }
569
+ .atc .atn b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
570
+ .atc .atn em { font-style: normal; font-size: var(--fs-1); color: var(--cz-ink3); }
563
571
  .hm-peek { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-top: 8px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--cz-bluebg); color: var(--cz-ink); font-size: var(--fs-2); cursor: pointer; text-align: left; }
564
572
  .hm-peek[hidden] { display: none; }
565
573
  .hm-peek span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -768,3 +768,85 @@ body.ins-trv #goalTbl { border: 0; background: none; border-radius: 0; overflow:
768
768
  .okr-pld .okr-dot { margin-top: 0; width: 8px; height: 8px; }
769
769
  @media (prefers-reduced-motion: reduce) { .okr-dot.m-crit::after { animation: none; } }
770
770
  textarea.ins-dri { height: auto; padding: 6px 8px; font-weight: 500; resize: vertical; }
771
+ /* ── goals made clear (batch 18 item 11, 11-B; frames Gc*): the drafts table, the check panel, first readings, failed and held ── */
772
+ .ins-dr .gc-tbl + .okr-card { margin-top: 12px; }
773
+ .gc-tbl { border: 1px solid var(--cz-hair); border-radius: 18px; overflow: hidden; background: var(--cz-card); }
774
+ .gc-th, .gc-tr { display: grid; grid-template-columns: minmax(150px, 1.25fr) minmax(170px, 1.9fr) minmax(70px, .6fr) minmax(90px, .75fr) minmax(120px, .95fr) 84px; gap: 14px; align-items: center; padding: 0 14px 0 16px; }
775
+ .gc-th { background: var(--cz-well); min-height: 38px; font-size: var(--fs-2); font-weight: 800; color: var(--cz-ink2); }
776
+ .gc-th .note { font-weight: 600; color: var(--cz-ink3); }
777
+ .gc-grp { padding: 8px 16px; background: var(--cz-well); border-top: 1px solid var(--cz-hair); font-size: var(--fs-2); }
778
+ .gc-grp b { font-weight: 800; color: var(--cz-ink2); }
779
+ .gc-grp .note { color: var(--cz-ink3); }
780
+ .gc-tr { border-top: 1px solid var(--cz-hair); min-height: 60px; padding-top: 8px; padding-bottom: 8px; cursor: pointer; }
781
+ .gc-tr:hover { background: var(--cz-well); }
782
+ .gc-tr.sel, .gc-tr.sel:hover { background: var(--cz-bluebg); }
783
+ .gc-tr:focus-visible { outline: 2px solid var(--cz-blueink); outline-offset: -2px; }
784
+ .gc-nm { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
785
+ .gc-nm b { font-size: var(--fs-3); font-weight: 800; line-height: 1.25; }
786
+ .gc-type { font-size: var(--fs-1); font-weight: 700; color: var(--cz-ink2); background: var(--cz-well2); border-radius: 8px; padding: 1px 7px; }
787
+ .gc-hw { font-size: var(--fs-2); color: var(--cz-ink2); line-height: 1.4; min-width: 0; }
788
+ .gc-now b { font-size: var(--fs-4); font-weight: 800; }
789
+ .gc-tg b { font-size: var(--fs-3); font-weight: 800; }
790
+ .gc-from { display: flex; flex-direction: column; gap: 1px; font-size: var(--fs-2); min-width: 0; }
791
+ .gc-src { display: inline-flex; align-items: center; gap: 6px; }
792
+ .gc-src b { font-weight: 700; }
793
+ .gc-src .cz-dot { width: 7px; height: 7px; }
794
+ .gc-from .note { color: var(--cz-ink2); font-weight: 600; }
795
+ .gc-acts { display: flex; gap: 4px; justify-content: flex-end; }
796
+ .gc-acts .cz-ib svg, .gc-panel svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
797
+ @media (max-width: 760px) {
798
+ .gc-th { display: none; }
799
+ .gc-tr { grid-template-columns: 1fr auto; grid-template-areas: "nm now" "hw hw" "tg from" "acts acts"; gap: 6px 12px; padding: 12px 14px; }
800
+ .gc-nm { grid-area: nm; } .gc-hw { grid-area: hw; } .gc-now { grid-area: now; text-align: right; } .gc-tg { grid-area: tg; } .gc-from { grid-area: from; text-align: right; align-items: flex-end; } .gc-acts { grid-area: acts; }
801
+ .gc-tg::before { content: 'Target '; font-size: var(--fs-2); color: var(--cz-ink3); }
802
+ }
803
+ /* the check panel and the key result's part of the goal Viewer */
804
+ .gc-panel { display: flex; flex-direction: column; gap: 12px; }
805
+ .gc-kr { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
806
+ .gc-box { background: var(--cz-well); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
807
+ .gc-k { font-size: var(--fs-2); font-weight: 800; color: var(--cz-ink2); }
808
+ .gc-what { margin: 0; font-size: var(--fs-3); font-weight: 700; line-height: 1.45; color: var(--cz-ink); }
809
+ .gc-big { margin: 2px 0 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
810
+ .gc-big b { font-size: var(--fs-6); font-weight: 800; letter-spacing: -.01em; }
811
+ .gc-frac { display: flex; flex-direction: column; font-size: var(--fs-3); }
812
+ .gc-frac > div { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
813
+ .gc-frac b { font-weight: 800; min-width: 3ch; }
814
+ .gc-frac .n { border-bottom: 1.5px solid var(--cz-ink3); }
815
+ .gc-frac .r { font-weight: 800; }
816
+ .gc-sec { display: flex; flex-direction: column; gap: 6px; }
817
+ .gc-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-3); }
818
+ .gc-checks li { display: flex; gap: 8px; align-items: flex-start; }
819
+ .gc-checks li svg { flex: none; margin-top: 2px; width: 16px; height: 16px; padding: 1px; border-radius: 50%; box-sizing: border-box; }
820
+ .gc-checks li.ok svg { color: var(--cz-ok); background: var(--cz-okbg); }
821
+ .gc-checks li.warn svg { color: var(--cz-risk); }
822
+ .gc-cmp { display: flex; align-items: center; gap: 8px; border: 1px solid var(--cz-hair); border-radius: 14px; padding: 6px 6px 6px 14px; background: var(--cz-card); }
823
+ .gc-cmp input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: var(--fs-3); color: var(--cz-ink); outline: none; }
824
+ .gc-line, .gc-fl { margin: 0; font-size: var(--fs-3); color: var(--cz-ink2); line-height: 1.45; }
825
+ .gc-line b { color: var(--cz-ink); font-weight: 800; margin-right: 4px; }
826
+ .gc-fl b { color: var(--cz-ink); }
827
+ .gc-q { background: var(--cz-well); border-radius: 16px; padding: 10px 14px; }
828
+ .gc-q summary { cursor: pointer; font-size: var(--fs-3); list-style: none; }
829
+ .gc-q summary::-webkit-details-marker { display: none; }
830
+ .gc-q summary b { font-weight: 800; }
831
+ .gc-q pre { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--cz-card); font-family: var(--cz-mono); font-size: var(--fs-2); white-space: pre-wrap; word-break: break-word; }
832
+ .gc-foot { display: flex; align-items: center; gap: 4px; }
833
+ .gc-sp { flex: 1; }
834
+ .gc-msg:empty { display: none; }
835
+ .gc-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
836
+ .gc-card { background: var(--cz-well); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
837
+ .gc-card b { font-size: var(--fs-6); font-weight: 800; }
838
+ .gc-say { margin: 0; font-size: var(--fs-3); line-height: 1.5; }
839
+ .gc-sg { display: flex; flex-wrap: wrap; gap: 8px 10px; background: var(--cz-well); border-radius: 16px; padding: 12px 14px; }
840
+ .gc-sg .sp { color: var(--cz-blueink); display: inline-flex; margin-top: 2px; }
841
+ .gc-sg p { flex: 1; margin: 0; font-size: var(--fs-3); line-height: 1.45; min-width: 0; }
842
+ .gc-sg .acts { display: flex; gap: 4px; width: 100%; justify-content: flex-end; }
843
+ .gc-warnbox { background: var(--cz-riskbg); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-3); }
844
+ .gc-warnbox > b:first-child { color: var(--cz-risk); font-size: var(--fs-2); font-weight: 800; }
845
+ .gc-warnbox p { margin: 0; line-height: 1.45; }
846
+ .gc-fix { display: flex; align-items: center; gap: 10px; }
847
+ .gc-fix > b { flex: 1; font-weight: 800; }
848
+ .gc-fix .acts { display: flex; gap: 4px; }
849
+ .gc-file { display: flex; justify-content: flex-end; }
850
+ .gc-wait { border: 1.5px dashed var(--cz-hair); border-color: var(--cz-dot-q); border-radius: 14px; min-height: 120px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 14px; font-size: var(--fs-3); color: var(--cz-ink2); }
851
+ .gc-ed { display: flex; flex-direction: column; gap: 10px; }
852
+ .ins-dr.gc-on { border: 0; padding: 0; background: none; gap: 12px; }
@@ -45,6 +45,11 @@
45
45
  @media (min-width: 761px) {
46
46
  body.cz-home .cz-live { left: 8px; bottom: 68px; }
47
47
  body.cz-home .lv-tray { bottom: 116px; }
48
+ /* the list folded to its rail (Wawan 12:09): the pill stacks its marks in a column as wide as the menu button, so it never reaches
49
+ into the page beside the rail */
50
+ body.cz-home.hm-folded .cz-live { flex-direction: column; height: auto; min-width: 40px; padding: 10px 6px; gap: 8px; border-radius: 20px; }
51
+ body.cz-home.hm-folded .cz-live .lv-ms, body.cz-home.hm-folded .cz-live .lv-g { flex-direction: column; }
52
+ body.cz-home.hm-folded .cz-live .lv-sp { width: 16px; height: 1px; }
48
53
  }
49
54
  /* a phone: the menu button is bottom right, so the pill sits to its left, and the list is a short sheet */
50
55
  @media (max-width: 760px) {
@@ -168,7 +168,7 @@ function openOverlap(it, o = {}) {
168
168
  ['merge', 'Merge into ' + nameOf(one), 'Opens Merge with both set. You see what moves first.', false],
169
169
  ['not', 'Not an overlap', 'I stop flagging this pair.', false],
170
170
  ];
171
- const opts = `<div class="nv-opts" role="radiogroup" aria-label="What to do">${choices.map(([k, l, w, rec]) => `<button type="button" role="radio" class="nv-opt${V.pick === k ? ' on' : ''}" aria-checked="${V.pick === k}" data-nv-pick="${k}"><span class="nv-rd" aria-hidden="true"></span><span class="nv-tx"><b>${esc(l)}${rec ? ' <span class="nv-rec">I’d do this</span>' : ''}</b><em>${esc(w)}</em></span></button>`).join('')}</div>`;
171
+ const opts = `<div class="nv-opts" role="radiogroup" aria-label="What to do">${choices.map(([k, l, w, rec]) => `<button type="button" role="radio" class="nv-opt${V.pick === k ? ' on' : ''}" aria-checked="${V.pick === k}" data-nv-pick="${k}"><span class="nv-rd" aria-hidden="true"></span><span class="nv-tx"><b>${esc(l)}${rec ? ' <span class="nv-idd">I’d do this</span>' : ''}</b><em>${esc(w)}</em></span></button>`).join('')}</div>`;
172
172
  const lbl = choices.find((c) => c[0] === V.pick)[1];
173
173
  const go = `<div class="nv-go"><button type="button" class="czs-pri nv-pri" data-nv-go${V.busy ? ' disabled' : ''}>${svg(P.check, 16)}<span>${esc(lbl)}</span></button></div>`;
174
174
  const items = Array.isArray(O.items) && O.items.length ? czSections([{ id: 'parts', title: O.items.length === 1 ? 'The part that overlaps' : 'The ' + O.items.length + ' parts that overlap', count: O.items.length,
@@ -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
+ }