@aquera/nile-elements 2.0.19 → 2.0.21

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 (208) hide show
  1. package/README.md +8 -0
  2. package/demo/index.js +0 -1
  3. package/dist/floating-ui.dom-9df9f37b.cjs.js +2 -0
  4. package/dist/floating-ui.dom-9df9f37b.cjs.js.map +1 -0
  5. package/dist/floating-ui.dom-c4ea6a32.esm.js +1 -0
  6. package/dist/index.cjs.js +1 -1
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.js +1326 -523
  9. package/dist/nile-auto-complete/index.cjs.js +1 -1
  10. package/dist/nile-auto-complete/index.esm.js +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
  12. package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
  13. package/dist/nile-auto-complete/portal-manager.cjs.js +1 -1
  14. package/dist/nile-auto-complete/portal-manager.esm.js +1 -1
  15. package/dist/nile-badge/index.cjs.js +1 -1
  16. package/dist/nile-badge/index.esm.js +1 -1
  17. package/dist/nile-badge/nile-badge.cjs.js +1 -1
  18. package/dist/nile-badge/nile-badge.cjs.js.map +1 -1
  19. package/dist/nile-badge/nile-badge.css.cjs.js +1 -1
  20. package/dist/nile-badge/nile-badge.css.cjs.js.map +1 -1
  21. package/dist/nile-badge/nile-badge.css.esm.js +24 -3
  22. package/dist/nile-badge/nile-badge.esm.js +5 -3
  23. package/dist/nile-button/nile-button.cjs.js +1 -1
  24. package/dist/nile-button/nile-button.cjs.js.map +1 -1
  25. package/dist/nile-button/nile-button.css.cjs.js +1 -1
  26. package/dist/nile-button/nile-button.css.cjs.js.map +1 -1
  27. package/dist/nile-button/nile-button.css.esm.js +46 -9
  28. package/dist/nile-button/nile-button.esm.js +6 -6
  29. package/dist/nile-calendar/index.cjs.js +1 -1
  30. package/dist/nile-calendar/index.esm.js +1 -1
  31. package/dist/nile-calendar/nile-calendar.cjs.js +2 -1
  32. package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
  33. package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
  34. package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
  35. package/dist/nile-calendar/nile-calendar.css.esm.js +357 -2
  36. package/dist/nile-calendar/nile-calendar.esm.js +365 -41
  37. package/dist/nile-calendar/timezones.cjs.js +1 -1
  38. package/dist/nile-calendar/timezones.cjs.js.map +1 -1
  39. package/dist/nile-calendar/timezones.esm.js +1 -1
  40. package/dist/nile-color-picker/index.cjs.js +1 -1
  41. package/dist/nile-color-picker/index.esm.js +1 -1
  42. package/dist/nile-color-picker/nile-color-picker.cjs.js +1 -1
  43. package/dist/nile-color-picker/nile-color-picker.esm.js +1 -1
  44. package/dist/nile-combobox/index.cjs.js +1 -1
  45. package/dist/nile-combobox/index.esm.js +1 -1
  46. package/dist/nile-combobox/nile-combobox.cjs.js +1 -1
  47. package/dist/nile-combobox/nile-combobox.esm.js +1 -1
  48. package/dist/nile-combobox/portal-manager.cjs.js +1 -1
  49. package/dist/nile-combobox/portal-manager.esm.js +1 -1
  50. package/dist/nile-date-time-picker/index.cjs.js +2 -0
  51. package/dist/nile-date-time-picker/index.cjs.js.map +1 -0
  52. package/dist/nile-date-time-picker/index.esm.js +1 -0
  53. package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js +2 -0
  54. package/dist/nile-date-time-picker/nile-date-time-picker.cjs.js.map +1 -0
  55. package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js +2 -0
  56. package/dist/nile-date-time-picker/nile-date-time-picker.css.cjs.js.map +1 -0
  57. package/dist/nile-date-time-picker/nile-date-time-picker.css.esm.js +13 -0
  58. package/dist/nile-date-time-picker/nile-date-time-picker.esm.js +53 -0
  59. package/dist/nile-dropdown/index.cjs.js +1 -1
  60. package/dist/nile-dropdown/index.esm.js +1 -1
  61. package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
  62. package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
  63. package/dist/nile-dropdown/portal-manager.cjs.js +1 -1
  64. package/dist/nile-dropdown/portal-manager.esm.js +1 -1
  65. package/dist/nile-markdown-editor/index.cjs.js +1 -1
  66. package/dist/nile-markdown-editor/index.esm.js +1 -1
  67. package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +1 -1
  68. package/dist/nile-markdown-editor/nile-markdown-editor.esm.js +1 -1
  69. package/dist/nile-popover/index.cjs.js +1 -1
  70. package/dist/nile-popover/index.esm.js +1 -1
  71. package/dist/nile-popover/nile-popover.cjs.js +1 -1
  72. package/dist/nile-popover/nile-popover.esm.js +1 -1
  73. package/dist/nile-popover/portal-manager.cjs.js +1 -1
  74. package/dist/nile-popover/portal-manager.esm.js +1 -1
  75. package/dist/nile-popup/index.cjs.js +1 -1
  76. package/dist/nile-popup/index.esm.js +1 -1
  77. package/dist/nile-popup/nile-popup.cjs.js +1 -1
  78. package/dist/nile-popup/nile-popup.esm.js +1 -1
  79. package/dist/nile-select/index.cjs.js +1 -1
  80. package/dist/nile-select/index.esm.js +1 -1
  81. package/dist/nile-select/nile-select.cjs.js +1 -1
  82. package/dist/nile-select/nile-select.esm.js +1 -1
  83. package/dist/nile-select/portal-manager.cjs.js +1 -1
  84. package/dist/nile-select/portal-manager.esm.js +1 -1
  85. package/dist/nile-side-bar-action/index.cjs.js +1 -1
  86. package/dist/nile-side-bar-action/index.esm.js +1 -1
  87. package/dist/nile-side-bar-action/nile-side-bar-action.cjs.js +1 -1
  88. package/dist/nile-side-bar-action/nile-side-bar-action.esm.js +1 -1
  89. package/dist/nile-side-bar-action/portal-manager.cjs.js +1 -1
  90. package/dist/nile-side-bar-action/portal-manager.esm.js +1 -1
  91. package/dist/nile-tooltip/index.cjs.js +1 -1
  92. package/dist/nile-tooltip/index.esm.js +1 -1
  93. package/dist/nile-tooltip/nile-tooltip.cjs.js +1 -1
  94. package/dist/nile-tooltip/nile-tooltip.esm.js +1 -1
  95. package/dist/nile-virtual-select/index.cjs.js +1 -1
  96. package/dist/nile-virtual-select/index.esm.js +1 -1
  97. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
  98. package/dist/nile-virtual-select/nile-virtual-select.esm.js +1 -1
  99. package/dist/nile-virtual-select/portal-manager.cjs.js +1 -1
  100. package/dist/nile-virtual-select/portal-manager.esm.js +1 -1
  101. package/dist/nile-wysiwyg-editor/index.cjs.js +1 -1
  102. package/dist/nile-wysiwyg-editor/index.esm.js +1 -1
  103. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
  104. package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
  105. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.cjs.js +1 -1
  106. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/index.esm.js +1 -1
  107. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.cjs.js +1 -1
  108. package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.esm.js +1 -1
  109. package/dist/src/index.d.ts +1 -0
  110. package/dist/src/index.js +1 -0
  111. package/dist/src/index.js.map +1 -1
  112. package/dist/src/nile-badge/nile-badge.css.js +24 -3
  113. package/dist/src/nile-badge/nile-badge.css.js.map +1 -1
  114. package/dist/src/nile-badge/nile-badge.d.ts +7 -4
  115. package/dist/src/nile-badge/nile-badge.js +22 -5
  116. package/dist/src/nile-badge/nile-badge.js.map +1 -1
  117. package/dist/src/nile-badge/nile-badge.test.js +88 -0
  118. package/dist/src/nile-badge/nile-badge.test.js.map +1 -1
  119. package/dist/src/nile-button/nile-button.css.js +46 -9
  120. package/dist/src/nile-button/nile-button.css.js.map +1 -1
  121. package/dist/src/nile-button/nile-button.d.ts +2 -2
  122. package/dist/src/nile-button/nile-button.js +13 -5
  123. package/dist/src/nile-button/nile-button.js.map +1 -1
  124. package/dist/src/nile-button/nile-button.test.js +140 -2
  125. package/dist/src/nile-button/nile-button.test.js.map +1 -1
  126. package/dist/src/nile-calendar/nile-calendar.css.js +355 -0
  127. package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
  128. package/dist/src/nile-calendar/nile-calendar.d.ts +175 -0
  129. package/dist/src/nile-calendar/nile-calendar.js +1726 -26
  130. package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
  131. package/dist/src/nile-calendar/nile-calendar.test.d.ts +1 -0
  132. package/dist/src/nile-calendar/nile-calendar.test.js +3580 -0
  133. package/dist/src/nile-calendar/nile-calendar.test.js.map +1 -1
  134. package/dist/src/nile-calendar/timezones.d.ts +21 -0
  135. package/dist/src/nile-calendar/timezones.js +49 -0
  136. package/dist/src/nile-calendar/timezones.js.map +1 -1
  137. package/dist/src/nile-date-time-picker/index.d.ts +1 -0
  138. package/dist/src/nile-date-time-picker/index.js +2 -0
  139. package/dist/src/nile-date-time-picker/index.js.map +1 -0
  140. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.d.ts +11 -0
  141. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js +49 -0
  142. package/dist/src/nile-date-time-picker/nile-date-time-picker.css.js.map +1 -0
  143. package/dist/src/nile-date-time-picker/nile-date-time-picker.d.ts +173 -0
  144. package/dist/src/nile-date-time-picker/nile-date-time-picker.js +1270 -0
  145. package/dist/src/nile-date-time-picker/nile-date-time-picker.js.map +1 -0
  146. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.d.ts +47 -0
  147. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.js +578 -0
  148. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.js.map +1 -0
  149. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.d.ts +3 -0
  150. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.js +109 -0
  151. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.js.map +1 -0
  152. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.d.ts +3 -0
  153. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.js +356 -0
  154. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.js.map +1 -0
  155. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.d.ts +4 -0
  156. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.js +339 -0
  157. package/dist/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.js.map +1 -0
  158. package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.d.ts +3 -0
  159. package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.js +1472 -0
  160. package/dist/src/nile-date-time-picker/nile-date-time-picker.regressions.test.js.map +1 -0
  161. package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.d.ts +103 -0
  162. package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.js +331 -0
  163. package/dist/src/nile-date-time-picker/nile-date-time-picker.test-helpers.js.map +1 -0
  164. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.d.ts +3 -0
  165. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js +2783 -0
  166. package/dist/src/nile-date-time-picker/nile-date-time-picker.test.js.map +1 -0
  167. package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.d.ts +3 -0
  168. package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.js +1440 -0
  169. package/dist/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.js.map +1 -0
  170. package/dist/src/version.js +1 -1
  171. package/dist/src/version.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/dist/utilities/animation-registry.cjs.js +1 -1
  174. package/dist/utilities/animation-registry.cjs.js.map +1 -1
  175. package/dist/utilities/animation-registry.esm.js +1 -1
  176. package/package.json +4 -2
  177. package/rollup.config.js +1 -0
  178. package/scripts/component-metrics.mjs +145 -0
  179. package/scripts/coverage-report.mjs +96 -0
  180. package/scripts/merge-coverage.cjs +33 -0
  181. package/src/index.ts +1 -0
  182. package/src/nile-badge/nile-badge.css.ts +24 -3
  183. package/src/nile-badge/nile-badge.test.ts +102 -0
  184. package/src/nile-badge/nile-badge.ts +28 -5
  185. package/src/nile-button/nile-button.css.ts +46 -9
  186. package/src/nile-button/nile-button.test.ts +162 -2
  187. package/src/nile-button/nile-button.ts +13 -4
  188. package/src/nile-calendar/nile-calendar.css.ts +355 -0
  189. package/src/nile-calendar/nile-calendar.test.ts +3793 -0
  190. package/src/nile-calendar/nile-calendar.ts +1760 -28
  191. package/src/nile-calendar/timezones.ts +57 -0
  192. package/src/nile-date-time-picker/index.ts +1 -0
  193. package/src/nile-date-time-picker/nile-date-time-picker.css.ts +54 -0
  194. package/src/nile-date-time-picker/nile-date-time-picker.phases-1.test.ts +607 -0
  195. package/src/nile-date-time-picker/nile-date-time-picker.phases-2.test.ts +112 -0
  196. package/src/nile-date-time-picker/nile-date-time-picker.phases-3.test.ts +389 -0
  197. package/src/nile-date-time-picker/nile-date-time-picker.phases-4.test.ts +329 -0
  198. package/src/nile-date-time-picker/nile-date-time-picker.regressions.test.ts +1618 -0
  199. package/src/nile-date-time-picker/nile-date-time-picker.test-helpers.ts +381 -0
  200. package/src/nile-date-time-picker/nile-date-time-picker.test.ts +3116 -0
  201. package/src/nile-date-time-picker/nile-date-time-picker.ts +1153 -0
  202. package/src/nile-date-time-picker/nile-date-time-picker.year-handling.test.ts +1499 -0
  203. package/test-timings.json +41 -0
  204. package/vscode-html-custom-data.json +180 -7
  205. package/web-test-runner.config.mjs +72 -2
  206. package/dist/floating-ui.dom-007bbe96.cjs.js +0 -2
  207. package/dist/floating-ui.dom-007bbe96.cjs.js.map +0 -1
  208. package/dist/floating-ui.dom-cc9126da.esm.js +0 -1
@@ -0,0 +1,607 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { TIMEZONES, utcFromFields } from '../nile-calendar/timezones';
3
+ import './nile-date-time-picker';
4
+ import '../nile-calendar';
5
+ import '../nile-input';
6
+ import type { Wall } from './nile-date-time-picker.test-helpers';
7
+ import {
8
+ offsetAt,
9
+ wallAt,
10
+ parseBracketed,
11
+ fmtWall,
12
+ makePicker,
13
+ apply,
14
+ checkPayload,
15
+ roundTrip,
16
+ instantsFor,
17
+ findTransitions,
18
+ runtimeZones,
19
+ selectAndApply,
20
+ HOST_TZ,
21
+ Failures,
22
+ } from './nile-date-time-picker.test-helpers';
23
+
24
+ /*
25
+ * Section K (adversarial audit), part 1 of 4: PHASE 1 (oracle + driver smoke), PHASE 2, FOCUS A/B, PHASE 3.
26
+ * Split out of nile-date-time-picker.test.ts so CI can run it on its own shard;
27
+ * helpers shared across the split files live in nile-date-time-picker.test-helpers.ts.
28
+ */
29
+
30
+ /*****************************************************************************
31
+ * SECTION K — ADVERSARIAL AUDIT
32
+ * Merged in from src/_audit/nile-date-time-picker.adversarial.test.ts so the
33
+ * component has a single test file. Original header follows verbatim.
34
+ ****************************************************************************/
35
+
36
+ /**
37
+ * ADVERSARIAL AUDIT — nile-date-time-picker (variant="date-time-picker")
38
+ * ============================================================================
39
+ * A single self-contained adversarial suite, consolidated from the 10-file
40
+ * working set. It answers one question: can the component ever silently
41
+ * produce or persist the WRONG INSTANT?
42
+ *
43
+ * Structure:
44
+ * PART 1 independent oracle — Intl `longOffset` + explicit UTC arithmetic
45
+ * PART 2 driver + invariant checker (the PHASE 16 payload contract)
46
+ * PART 3 PHASE 1 oracle validation + driver smoke test
47
+ * PART 4 PHASE 2 year range / calendar arithmetic (+ focused follow-ups)
48
+ * PART 5 PHASE 3 timezone sweep (every runtime zone + static fallback)
49
+ * PART 6 PHASE 4/5 DST transitions, gaps, overlaps
50
+ * PART 7 PHASE 7/8/9/11/12 ms, boundaries, formats, round-trips, fuzzing
51
+ * PART 8 PHASE 6 host-timezone independence digest
52
+ * PART 9 PHASE 10/14/15 UI sequences, Set to now, Apply semantics
53
+ *
54
+ * THE ORACLE RULE: nothing below may validate the component with the
55
+ * component's own helpers. `zoneOffsetMs`, `composeValueISO`, `wallClockInZone`
56
+ * and `wallClockToInstant` are never used to compute an expected value. The
57
+ * oracle reads Intl's PRINTED offset and does its own UTC arithmetic, which is
58
+ * a different mechanism from the implementation's part-differencing.
59
+ *
60
+ * RUNTIME: this is an exhaustive sweep (hundreds of zones, every DST
61
+ * transition, thousands of randomised cases), not a unit suite. See the note
62
+ * at the bottom of this file about keeping it out of the default `yarn test`.
63
+ *
64
+ * Some checks are DIAGNOSTIC: they record current behaviour via console.warn
65
+ * (grep for `[audit-`) rather than asserting a policy. Those are labelled.
66
+ */
67
+
68
+
69
+ /* ==========================================================================
70
+ PART 1 — INDEPENDENT ORACLE
71
+ (was oracle.ts)
72
+ ========================================================================== */
73
+
74
+ /* Wall, offsetAt, wallAt, wallEquals, parseBracketed, fmtWall, wallToUTCms,
75
+ instantsFor, findTransitions, runtimeZones, wallFromUTCms and transitionShape
76
+ now live in nile-date-time-picker.test-helpers.ts (shared with the other split files). */
77
+
78
+ /** Temporal, only if the runtime genuinely has it. Never faked. */
79
+ export const TEMPORAL: any =
80
+ typeof (globalThis as any).Temporal !== 'undefined' ? (globalThis as any).Temporal : null;
81
+
82
+ /* ── D. independent parsers ───────────────────────────────────────────────── */
83
+
84
+ /** `...Z` / `...±HH:MM` -> exact instant. Built by hand, not via `new Date`. */
85
+ export function parseInstantString(raw: string): number | null {
86
+ const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,3}))?(Z|[+-]\d{2}:?\d{2})$/
87
+ .exec(raw.trim());
88
+ if (!m) return null;
89
+ const [, y, mo, d, h, mi, s, frac, zulu] = m;
90
+ const ms = frac === undefined ? 0 : Number(frac.padEnd(3, '0'));
91
+ const base = utcFromFields(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s ?? 0), ms);
92
+ if (zulu === 'Z') return base;
93
+ const om = /^([+-])(\d{2}):?(\d{2})$/.exec(zulu)!;
94
+ const off = (om[1] === '-' ? -1 : 1) * (Number(om[2]) * 3600000 + Number(om[3]) * 60000);
95
+ return base - off;
96
+ }
97
+
98
+ /** Offset-less datetime -> wall clock digits only (no zone applied). */
99
+ export function parseOffsetLess(raw: string): Wall | null {
100
+ const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d{1,3}))?$/.exec(raw.trim());
101
+ if (!m) return null;
102
+ const [, y, mo, d, h, mi, s, frac] = m;
103
+ return {
104
+ year: Number(y), month: Number(mo), day: Number(d),
105
+ hours: Number(h), minutes: Number(mi), seconds: Number(s ?? 0),
106
+ // NOTE: read as written, NOT scaled — ".25" is 25ms. Records current intent.
107
+ ms: frac === undefined ? 0 : Number(frac),
108
+ };
109
+ }
110
+
111
+ export function isResolvable(zone: string): boolean {
112
+ try { new Intl.DateTimeFormat('en-US', { timeZone: zone }); return true; }
113
+ catch { return false; }
114
+ }
115
+
116
+ /* ==========================================================================
117
+ PART 2 — DRIVER + INVARIANT CHECKER
118
+ (was harness.ts)
119
+ ========================================================================== */
120
+
121
+ /* Payload, Violation, makePicker, settle/settle2, applyButton, apply,
122
+ checkPayload, roundTrip, selectAndApply, HOST_TZ and Failures now live in
123
+ nile-date-time-picker.test-helpers.ts. The PART 6 DST helpers (YEAR_FROM,
124
+ YEAR_TO, Tr, allTransitions) moved there too, and mulberry32 is in phases-4. */
125
+
126
+ /* ==========================================================================
127
+ PART 3 — PHASE 1: oracle validation + driver smoke test
128
+ (was p1-oracle.test.ts)
129
+ ========================================================================== */
130
+
131
+ describe('PHASE 1 — oracle validation', () => {
132
+ it('P1.0 reports the environment (host zone, Temporal, zone count)', () => {
133
+ const zones = runtimeZones();
134
+ // eslint-disable-next-line no-console
135
+ console.warn(`[audit-env] hostTZ=${HOST_TZ} temporal=${TEMPORAL ? 'YES' : 'NO'} ` +
136
+ `zones=${zones.length} ua=${navigator.userAgent.slice(0, 60)}`);
137
+ expect(zones.length, 'runtime must expose a timezone list').to.be.greaterThan(100);
138
+ });
139
+
140
+ it('P1.1 offsetAt matches known fixed offsets', () => {
141
+ const t = Date.UTC(2026, 5, 15, 12, 0, 0);
142
+ expect(offsetAt(t, 'UTC')).to.equal(0);
143
+ expect(offsetAt(t, 'Asia/Kolkata')).to.equal(5.5 * 3600000);
144
+ expect(offsetAt(t, 'Asia/Kathmandu')).to.equal(5.75 * 3600000);
145
+ expect(offsetAt(t, 'Australia/Eucla')).to.equal(8.75 * 3600000);
146
+ expect(offsetAt(t, 'Pacific/Kiritimati')).to.equal(14 * 3600000);
147
+ expect(offsetAt(t, 'Pacific/Marquesas')).to.equal(-9.5 * 3600000);
148
+ expect(offsetAt(t, 'America/St_Johns')).to.equal(-2.5 * 3600000); // NDT in June
149
+ });
150
+
151
+ it('P1.2 wallAt round-trips against instantsFor on unambiguous times', () => {
152
+ const zones = ['UTC', 'Asia/Kolkata', 'America/New_York', 'Pacific/Auckland', 'Australia/Lord_Howe'];
153
+ for (const z of zones) {
154
+ for (const t of [Date.UTC(2026, 0, 15, 3, 7, 11, 123), Date.UTC(2026, 6, 15, 18, 44, 2, 9)]) {
155
+ const w = wallAt(t, z);
156
+ const back = instantsFor(w, z);
157
+ expect(back, `${z} ${fmtWall(w)}`).to.include(t);
158
+ }
159
+ }
160
+ });
161
+
162
+ it('P1.3 instantsFor returns 0 for a gap and 2 for an overlap (New York 2026)', () => {
163
+ const gap = instantsFor(
164
+ { year: 2026, month: 3, day: 8, hours: 2, minutes: 30, seconds: 0, ms: 0 }, 'America/New_York');
165
+ expect(gap, 'spring-forward 02:30 must not exist').to.have.lengthOf(0);
166
+
167
+ const dup = instantsFor(
168
+ { year: 2026, month: 11, day: 1, hours: 1, minutes: 30, seconds: 0, ms: 0 }, 'America/New_York');
169
+ expect(dup, 'fall-back 01:30 occurs twice').to.have.lengthOf(2);
170
+ expect(dup[1] - dup[0], 'occurrences are 1h apart').to.equal(3600000);
171
+ });
172
+
173
+ it('P1.4 Temporal agrees with the oracle — or is explicitly absent (never silent)', () => {
174
+ if (!TEMPORAL) {
175
+ // eslint-disable-next-line no-console
176
+ console.warn('[audit-env] TEMPORAL UNAVAILABLE — P1.4 cross-check NOT PERFORMED. ' +
177
+ 'Oracle rests on Intl longOffset + UTC arithmetic alone.');
178
+ expect(TEMPORAL, 'recorded as not-tested, not as passed').to.equal(null);
179
+ return;
180
+ }
181
+ // Current Temporal: Temporal.TimeZone was removed; zones are plain strings
182
+ // reached through ZonedDateTime. Probe the shape rather than assume it.
183
+ const probe = TEMPORAL.Instant && TEMPORAL.Instant.fromEpochMilliseconds;
184
+ if (!probe) {
185
+ // eslint-disable-next-line no-console
186
+ console.warn('[audit-env] Temporal present but Instant.fromEpochMilliseconds missing — NOT TESTED');
187
+ expect.fail('Temporal present but unusable — investigate rather than silently pass');
188
+ }
189
+ let checked = 0;
190
+ for (const z of ['UTC', 'Asia/Kolkata', 'Asia/Kathmandu', 'America/New_York',
191
+ 'Australia/Lord_Howe', 'Pacific/Chatham', 'Pacific/Kiritimati', 'America/St_Johns']) {
192
+ for (const t of [Date.UTC(2026, 0, 15, 12, 0, 0), Date.UTC(2026, 6, 15, 12, 0, 0)]) {
193
+ const zdt = TEMPORAL.Instant.fromEpochMilliseconds(t).toZonedDateTimeISO(z);
194
+ expect(Number(zdt.offsetNanoseconds) / 1e6, `Temporal vs oracle ${z} @${t}`)
195
+ .to.equal(offsetAt(t, z));
196
+ const w = wallAt(t, z);
197
+ expect(zdt.year, `Temporal year ${z}`).to.equal(w.year);
198
+ expect(zdt.month, `Temporal month ${z}`).to.equal(w.month);
199
+ expect(zdt.day, `Temporal day ${z}`).to.equal(w.day);
200
+ expect(zdt.hour, `Temporal hour ${z}`).to.equal(w.hours);
201
+ expect(zdt.minute, `Temporal minute ${z}`).to.equal(w.minutes);
202
+ checked += 1;
203
+ }
204
+ }
205
+ // eslint-disable-next-line no-console
206
+ console.warn(`[audit-env] Temporal cross-check PERFORMED on ${checked} zone/date pairs`);
207
+ });
208
+
209
+ it('P1.5 findTransitions locates the two US 2026 transitions', () => {
210
+ const ts = findTransitions('America/New_York', Date.UTC(2026, 0, 1), Date.UTC(2027, 0, 1));
211
+ expect(ts, 'two transitions in 2026').to.have.lengthOf(2);
212
+ expect(wallAt(ts[0], 'America/New_York').month).to.equal(3);
213
+ expect(wallAt(ts[1], 'America/New_York').month).to.equal(11);
214
+ });
215
+
216
+ it('P1.6 independent parsers agree with hand-computed instants', () => {
217
+ expect(parseInstantString('2026-06-15T09:00:00.000Z')).to.equal(Date.UTC(2026, 5, 15, 9, 0, 0, 0));
218
+ expect(parseInstantString('2026-06-15T14:30:00.000+05:30')).to.equal(Date.UTC(2026, 5, 15, 9, 0, 0, 0));
219
+ expect(parseInstantString('2026-06-15T14:30:00.000')).to.equal(null);
220
+ const b = parseBracketed('2026-06-15T14:30:00.000[GMT+05:30 Asia/Kolkata]')!;
221
+ expect(b.zone).to.equal('Asia/Kolkata');
222
+ expect(b.offsetMs).to.equal(5.5 * 3600000);
223
+ const o = parseOffsetLess('2026-06-15T14:30:00.250')!;
224
+ expect(o.ms, 'fractional read as written').to.equal(250);
225
+ });
226
+ });
227
+
228
+ describe('PHASE 1 — driver smoke test (real component, real Apply)', () => {
229
+ it('P1.7 a Z value applies and yields a self-consistent payload', async () => {
230
+ const el = await makePicker({ value: '2026-06-15T09:00:00.000Z', timezone: 'Asia/Kolkata' });
231
+ const p = await apply(el);
232
+ // eslint-disable-next-line no-console
233
+ console.warn(`[audit-drive] payload=${JSON.stringify({
234
+ value: p!.value, unixEpoch: p!.unixEpoch, timezone: p!.timezone,
235
+ })}`);
236
+ expect(p, 'Apply emitted a payload').to.exist;
237
+ expect(p!.unixEpoch, 'instant preserved').to.equal(Date.UTC(2026, 5, 15, 9, 0, 0, 0));
238
+ expect(checkPayload(p, 'Asia/Kolkata'), 'invariant violations').to.deep.equal([]);
239
+ });
240
+ });
241
+
242
+ /* ==========================================================================
243
+ PART 4 — PHASE 2: year range and calendar arithmetic
244
+ (was p2-years.test.ts)
245
+ ========================================================================== */
246
+
247
+ /** An offset a real tzdb zone could have: |offset| <= 26h, whole minutes. */
248
+ function offsetIsSane(offsetMs: number): boolean {
249
+ return Number.isFinite(offsetMs) && Math.abs(offsetMs) <= 26 * 3600000 && offsetMs % 60000 === 0;
250
+ }
251
+
252
+ const RE_BRACKET = /\[GMT([+-])(\d+):(\d{2})\s+([^\]]+)\]$/;
253
+
254
+ function printedOffsetMs(value: string): number | null {
255
+ const m = RE_BRACKET.exec(value);
256
+ if (!m) return null;
257
+ return (m[1] === '-' ? -1 : 1) * (Number(m[2]) * 3600000 + Number(m[3]) * 60000);
258
+ }
259
+
260
+ describe('PHASE 2 — year range and calendar arithmetic', () => {
261
+ it('P2.0 finds the lowest year whose emitted offset is still sane (UTC)', async () => {
262
+ const rows: string[] = [];
263
+ let firstBad: number | null = null;
264
+ for (const y of [1, 50, 100, 200, 500, 1000, 1500, 1600, 1700, 1800, 1850,
265
+ 1875, 1880, 1890, 1900, 1901, 1910, 1950, 2000, 2026, 2100]) {
266
+ const el = await makePicker({});
267
+ const w: Wall = { year: y, month: 6, day: 15, hours: 12, minutes: 0, seconds: 0, ms: 0 };
268
+ const p = await selectAndApply(el, w, 'UTC');
269
+ const off = p && p.value ? printedOffsetMs(p.value) : null;
270
+ const sane = off !== null && offsetIsSane(off);
271
+ if (!sane && firstBad === null) firstBad = y;
272
+ rows.push(`year=${String(y).padStart(4)} sane=${sane ? 'YES' : 'NO '} ` +
273
+ `printedOffset=${off === null ? 'unparsable' : off / 3600000 + 'h'} ` +
274
+ `epoch=${p && p.unixEpoch} value=${p && p.value}`);
275
+ }
276
+ // eslint-disable-next-line no-console
277
+ console.warn(`[audit-p2] host=${HOST_TZ} emitted-offset sanity by year:\n ${rows.join('\n ')}`);
278
+ expect(rows.length).to.be.greaterThan(0);
279
+ }).timeout(600000);
280
+
281
+ it('P2.1 1900-2100 (every year, mid-month) emits sane offsets and round-trips', async () => {
282
+ const f = new Failures();
283
+ let n = 0;
284
+ const subMinute: Array<{ y: number; z: string }> = [];
285
+ for (let y = 1900; y <= 2100; y++) {
286
+ for (const z of ['UTC', 'Asia/Kolkata', 'America/New_York']) {
287
+ const w: Wall = { year: y, month: 6, day: 15, hours: 12, minutes: 30, seconds: 15, ms: 250 };
288
+ const insts = instantsFor(w, z);
289
+ if (insts.length !== 1) continue;
290
+ // The bracket is `[GMT±hh:mm]`: it cannot carry a historical sub-minute (LMT) offset, so a value in such
291
+ // an era is rounded by design (see FA.1). Skip only those, and pin below that they are all pre-1972.
292
+ if (offsetAt(insts[0], z) % 60000 !== 0) { subMinute.push({ y, z }); continue; }
293
+ const el = await makePicker({});
294
+ const p = await selectAndApply(el, w, z);
295
+ const ctx = `year=${y} tz=${z}`;
296
+ f.add(ctx, checkPayload(p, z));
297
+ if (p && p.value) {
298
+ const off = printedOffsetMs(p.value);
299
+ if (off === null || !offsetIsSane(off)) {
300
+ f.add(ctx, [{ code: 'P2_INSANE_OFFSET', detail: `value=${p.value}` }]);
301
+ }
302
+ }
303
+ if (p && p.unixEpoch !== null) f.add(ctx, (await roundTrip(p)).violations);
304
+ n += 1;
305
+ }
306
+ }
307
+ // eslint-disable-next-line no-console
308
+ console.warn(`[audit-p2] 1900-2100 probes=${n} skipped(sub-minute offset)=${subMinute.length} violations=${f.count}`);
309
+ expect(f.count, `year-range violations:${f.report()}`).to.equal(0);
310
+ expect(subMinute.every((x) => x.y < 1972), 'only pre-1972 LMT-era instants are exempt').to.be.true;
311
+ expect(n, 'the sweep still covers (nearly) every modern year').to.be.greaterThan(500);
312
+ }).timeout(2400000);
313
+
314
+ it('P2.2 month lengths, leap rules, 1900/2000/2100, Jan<->Dec edges', async () => {
315
+ const f = new Failures();
316
+ const cases: Array<[number, number, number, string]> = [
317
+ [2024, 2, 29, 'leap 2024 valid'], [2000, 2, 29, 'century leap 2000 valid'],
318
+ [2026, 1, 31, '31-day'], [2026, 4, 30, '30-day'], [2026, 2, 28, '28-day'],
319
+ [2026, 12, 31, 'Dec 31'], [2026, 1, 1, 'Jan 1'],
320
+ [1900, 3, 1, '1900 non-leap: Mar 1'], [2100, 3, 1, '2100 non-leap: Mar 1'],
321
+ ];
322
+ for (const [y, mo, d, label] of cases) {
323
+ for (const z of ['UTC', 'Asia/Kolkata']) {
324
+ const w: Wall = { year: y, month: mo, day: d, hours: 10, minutes: 0, seconds: 0, ms: 0 };
325
+ const insts = instantsFor(w, z);
326
+ if (insts.length !== 1) continue;
327
+ // 1900 Asia/Kolkata is +05:21:10 (LMT): not representable in `[GMT±hh:mm]` (rounded by design, see FA.1).
328
+ // UTC covers the 1900 non-leap case; the Kolkata 1900 row is exempt only for that sub-minute reason.
329
+ if (offsetAt(insts[0], z) % 60000 !== 0) { expect(y, 'exempt only for LMT-era years').to.be.lessThan(1972); continue; }
330
+ const el = await makePicker({});
331
+ const p = await selectAndApply(el, w, z);
332
+ const ctx = `${label} tz=${z} ${fmtWall(w)}`;
333
+ f.add(ctx, checkPayload(p, z));
334
+ if (p && p.unixEpoch !== null) {
335
+ const back = wallAt(p.unixEpoch, z);
336
+ if (back.year !== y || back.month !== mo || back.day !== d) {
337
+ f.add(ctx, [{ code: 'P2_DATE_CHANGED', detail: `got ${back.year}-${back.month}-${back.day}` }]);
338
+ }
339
+ }
340
+ }
341
+ }
342
+ expect(f.count, `calendar violations:${f.report()}`).to.equal(0);
343
+ }).timeout(600000);
344
+
345
+ it('P2.3 classifies impossible dates supplied as a value (REJECT/CLAMP/NORMALIZE)', async () => {
346
+ const notes: string[] = [];
347
+ for (const raw of ['2026-02-31T10:00:00.000', '2026-02-30', '2025-02-29T10:00:00.000',
348
+ '2026-04-31T10:00:00.000', '2026-00-10T10:00:00.000', '2026-06-00T10:00:00.000']) {
349
+ const el = await makePicker({ value: raw, timezone: 'UTC' });
350
+ const p = await apply(el);
351
+ let cls = 'REJECT(no payload)';
352
+ if (p && p.unixEpoch !== null) {
353
+ const w = wallAt(p.unixEpoch, 'UTC');
354
+ const askedDay = Number(raw.slice(8, 10));
355
+ cls = w.day === askedDay ? 'PRESERVE' : `CLAMP/NORMALIZE -> day ${w.day}`;
356
+ } else if (p) cls = 'REJECT(null epoch)';
357
+ notes.push(`${raw.padEnd(26)} ${cls.padEnd(28)} value=${p && p.value}`);
358
+ }
359
+ // eslint-disable-next-line no-console
360
+ console.warn(`[audit-p2] impossible-date classification:\n ${notes.join('\n ')}`);
361
+ expect(notes.length).to.equal(6);
362
+ }).timeout(300000);
363
+ });
364
+
365
+ /* ==========================================================================
366
+ PART 4b — focused: sub-minute offsets and extreme years
367
+ (was p2b-suboffset.test.ts)
368
+ ========================================================================== */
369
+
370
+ describe('FOCUS A — sub-minute zone offsets', () => {
371
+ it('FA.0 measures how many zones have sub-minute offsets, and until when', () => {
372
+ const zones = runtimeZones();
373
+ const offenders: string[] = [];
374
+ let latestSubMinute = -Infinity;
375
+ for (const z of zones) {
376
+ // probe one instant per decade 1880..2100
377
+ for (let y = 1880; y <= 2100; y += 10) {
378
+ const t = Date.UTC(y, 5, 15, 12, 0, 0);
379
+ const off = offsetAt(t, z);
380
+ if (off % 60000 !== 0) {
381
+ if (offenders.indexOf(z) === -1) offenders.push(z);
382
+ if (t > latestSubMinute) latestSubMinute = t;
383
+ }
384
+ }
385
+ }
386
+ // eslint-disable-next-line no-console
387
+ console.warn(`[audit-focusA] zonesWithSubMinuteOffset=${offenders.length}/${zones.length} ` +
388
+ `latestSubMinuteInstant=${latestSubMinute === -Infinity ? 'none' : new Date(latestSubMinute).toISOString()} ` +
389
+ `sample=${offenders.slice(0, 15).join(',')}`);
390
+ expect(zones.length).to.be.greaterThan(0);
391
+ }).timeout(600000);
392
+
393
+ it('FA.1 REPRODUCTION: Asia/Kolkata 1900-06-15 12:30:15.250 — value != its own epoch', async () => {
394
+ const z = 'Asia/Kolkata';
395
+ const w: Wall = { year: 1900, month: 6, day: 15, hours: 12, minutes: 30, seconds: 15, ms: 250 };
396
+ const el = await makePicker({});
397
+ const p = await selectAndApply(el, w, z);
398
+ expect(p, 'payload').to.exist;
399
+ const epoch = p!.unixEpoch!;
400
+ const trueOff = offsetAt(epoch, z);
401
+ const viol = checkPayload(p, z);
402
+
403
+ // parse the printed bracket independently
404
+ const m = /\[GMT([+-])(\d{2}):(\d{2})\s+([^\]]+)\]$/.exec(p!.value!)!;
405
+ const printed = (m[1] === '-' ? -1 : 1) * (Number(m[2]) * 3600000 + Number(m[3]) * 60000);
406
+ const digits = p!.value!.slice(0, 23);
407
+ const fromValue = Date.parse(digits + 'Z') - printed;
408
+
409
+ // does a RELOAD still land on the same epoch?
410
+ const rt = await roundTrip(p!);
411
+
412
+ // eslint-disable-next-line no-console
413
+ console.warn(`[audit-focusA] REPRO host=${HOST_TZ} tz=${z}\n` +
414
+ ` selected = ${fmtWall(w)}\n` +
415
+ ` unixEpoch = ${epoch}\n` +
416
+ ` true offset = ${trueOff}ms (${trueOff / 60000} min, i.e. ${trueOff / 1000}s)\n` +
417
+ ` printed offset= ${printed}ms (${printed / 60000} min)\n` +
418
+ ` offset lost = ${trueOff - printed}ms\n` +
419
+ ` emitted value = ${p!.value}\n` +
420
+ ` value resolves to ${fromValue} (delta vs epoch = ${fromValue - epoch}ms)\n` +
421
+ ` reload epoch = ${rt.second && rt.second.unixEpoch} ` +
422
+ `(${rt.second && rt.second.unixEpoch === epoch ? 'PRESERVED' : 'DRIFTED'})\n` +
423
+ ` violations = ${viol.map(v => v.code).join(',') || 'none'}`);
424
+
425
+ expect(trueOff % 60000, 'this zone/date genuinely has a sub-minute offset').to.not.equal(0);
426
+ expect(fromValue - epoch, 'the emitted value does NOT describe its own epoch').to.not.equal(0);
427
+ }).timeout(300000);
428
+
429
+ // Start at 1972: Africa/Monrovia genuinely used -00:44:30 until 1972-01-07, so 1970-71 is not 'modern' (tzdata history).
430
+ it('FA.2 modern era (1972-2100) has NO sub-minute offsets in any zone', () => {
431
+ const zones = runtimeZones();
432
+ const bad: string[] = [];
433
+ for (const z of zones) {
434
+ for (let y = 1972; y <= 2100; y += 5) {
435
+ for (const mo of [0, 6]) {
436
+ const off = offsetAt(Date.UTC(y, mo, 15, 12), z);
437
+ if (off % 60000 !== 0) bad.push(`${z}@${y}-${mo + 1}`);
438
+ }
439
+ }
440
+ }
441
+ // eslint-disable-next-line no-console
442
+ console.warn(`[audit-focusA] modern-era sub-minute offsets=${bad.length} ${bad.slice(0, 10).join(',')}`);
443
+ expect(bad, 'no modern zone has a sub-minute offset').to.deep.equal([]);
444
+ }).timeout(600000);
445
+ });
446
+
447
+ describe('FOCUS B — extreme years through the Z-instant path', () => {
448
+ it('FB.1 records emitted offset sanity for extreme years (no harness Date() involved)', async () => {
449
+ const rows: string[] = [];
450
+ for (const raw of [
451
+ '0001-01-01T00:00:00.000Z', '0100-06-15T12:00:00.000Z', '1000-06-15T12:00:00.000Z',
452
+ '1700-06-15T12:00:00.000Z', '1900-06-15T12:00:00.000Z', '2026-06-15T12:00:00.000Z',
453
+ '2100-06-15T12:00:00.000Z', '9999-12-31T23:59:59.999Z',
454
+ ]) {
455
+ const el = await makePicker({ value: raw, timezone: 'UTC' });
456
+ const p = await apply(el);
457
+ const m = p && p.value ? /\[GMT([+-])(\d+):(\d{2})/.exec(p.value) : null;
458
+ const hours = m ? Number(m[2]) : NaN;
459
+ rows.push(`${raw} -> epoch=${p && p.unixEpoch} offsetHours=${m ? (m[1] + String(hours)) : 'n/a'} ` +
460
+ `${Number.isFinite(hours) && hours > 26 ? '<<< INSANE' : ''} value=${p && p.value}`);
461
+ }
462
+ // eslint-disable-next-line no-console
463
+ console.warn(`[audit-focusB] extreme-year Z inputs:\n ${rows.join('\n ')}`);
464
+ expect(rows.length).to.equal(8);
465
+ }).timeout(300000);
466
+
467
+ it('FB.2 records the component date-only path for 2-digit-looking years', async () => {
468
+ const rows: string[] = [];
469
+ for (const raw of ['0050-06-15', '0099-06-15', '0100-06-15', '1950-06-15']) {
470
+ const el = await makePicker({ value: raw, timezone: 'UTC' });
471
+ const p = await apply(el);
472
+ const w = p && p.unixEpoch !== null ? wallAt(p.unixEpoch, 'UTC') : null;
473
+ rows.push(`${raw} -> epoch=${p && p.unixEpoch} readsBackAsYear=${w && w.year} value=${p && p.value}`);
474
+ }
475
+ // eslint-disable-next-line no-console
476
+ console.warn(`[audit-focusB] date-only low years (component path):\n ${rows.join('\n ')}`);
477
+ expect(rows.length).to.equal(4);
478
+ }).timeout(300000);
479
+ });
480
+
481
+ /* ==========================================================================
482
+ PART 5 — PHASE 3: timezone sweep
483
+ (was p3-zones.test.ts)
484
+ ========================================================================== */
485
+
486
+ const NAMED = [
487
+ 'UTC', 'Asia/Kolkata', 'Asia/Calcutta', 'Asia/Kathmandu', 'Australia/Eucla',
488
+ 'Australia/Lord_Howe', 'America/St_Johns', 'America/New_York', 'Europe/London',
489
+ 'Pacific/Auckland', 'Pacific/Kiritimati', 'Pacific/Marquesas',
490
+ ];
491
+
492
+ // Representative wall clocks across the year, with awkward ms/seconds.
493
+ const PROBES: Wall[] = [
494
+ { year: 2026, month: 1, day: 15, hours: 9, minutes: 30, seconds: 0, ms: 0 },
495
+ { year: 2026, month: 7, day: 15, hours: 14, minutes: 45, seconds: 7, ms: 123 },
496
+ { year: 2026, month: 10, day: 31, hours: 23, minutes: 59, seconds: 59, ms: 999 },
497
+ ];
498
+
499
+ async function probeZone(zone: string, w: Wall, f: Failures): Promise<void> {
500
+ const el = await makePicker({});
501
+ const p = await selectAndApply(el, w, zone);
502
+ const ctx = `tz=${zone} want=${fmtWall(w)} host=${HOST_TZ}`;
503
+ f.add(ctx, checkPayload(p, zone));
504
+ if (!p || p.unixEpoch === null) { f.add(ctx, [{ code: 'NO_EPOCH', detail: 'apply produced none' }]); return; }
505
+ const rt = await roundTrip(p);
506
+ f.add(`${ctx} value=${p.value}`, rt.violations);
507
+ }
508
+
509
+ describe('PHASE 3 — timezone sweep', () => {
510
+ it('P3.0 records both zone sources and their divergence (diagnostic, no spelling assumed)', () => {
511
+ const runtime = runtimeZones();
512
+ const onlyRuntime = runtime.filter(z => TIMEZONES.indexOf(z) === -1);
513
+ const onlyStatic = TIMEZONES.filter(z => runtime.indexOf(z) === -1);
514
+ const unresolvableStatic = TIMEZONES.filter(z => !isResolvable(z));
515
+ // eslint-disable-next-line no-console
516
+ console.warn(`[audit-p3] host=${HOST_TZ} runtimeZones=${runtime.length} staticList=${TIMEZONES.length} ` +
517
+ `onlyRuntime=${onlyRuntime.length} onlyStatic=${onlyStatic.length} ` +
518
+ `staticUnresolvableByIntl=${unresolvableStatic.length} ` +
519
+ `india(runtime)=${runtime.filter(z => /Kolkata|Calcutta/.test(z)).join('|')} ` +
520
+ `india(static)=${TIMEZONES.filter(z => /Kolkata|Calcutta/.test(z)).join('|')}`);
521
+ expect(runtime.length, 'runtime exposes a zone list').to.be.greaterThan(100);
522
+ // Any static-list entry Intl cannot resolve would be offered by the legacy
523
+ // fallback dropdown yet rejected by isValidTimezone — record it explicitly.
524
+ expect(unresolvableStatic, 'static fallback entries Intl rejects').to.deep.equal([]);
525
+ });
526
+
527
+ it('P3.1 explicitly named zones round-trip with no invariant violation', async () => {
528
+ const f = new Failures();
529
+ for (const z of NAMED) for (const w of PROBES) await probeZone(z, w, f);
530
+ expect(f.count, `named-zone violations:${f.report()}`).to.equal(0);
531
+ }).timeout(180000);
532
+
533
+ it('P3.2 EVERY runtime zone round-trips (one probe each)', async () => {
534
+ const f = new Failures();
535
+ const zones = runtimeZones();
536
+ let n = 0;
537
+ for (const z of zones) { await probeZone(z, PROBES[1], f); n += 1; }
538
+ // eslint-disable-next-line no-console
539
+ console.warn(`[audit-p3] swept ${n} zones, violations=${f.count}`);
540
+ expect(f.count, `all-zone violations:${f.report()}`).to.equal(0);
541
+ }).timeout(900000);
542
+
543
+ it('P3.3 a valid alias is never silently downgraded to UTC', async () => {
544
+ const f = new Failures();
545
+ const aliases: Array<[string, string]> = [
546
+ ['Asia/Calcutta', 'Asia/Kolkata'], ['Asia/Saigon', 'Asia/Ho_Chi_Minh'],
547
+ ['Europe/Kiev', 'Europe/Kyiv'], ['America/Godthab', 'America/Nuuk'],
548
+ ['Asia/Rangoon', 'Asia/Yangon'], ['Pacific/Ponape', 'Pacific/Pohnpei'],
549
+ ];
550
+ for (const [alias, canonical] of aliases) {
551
+ let resolvable = true;
552
+ try { new Intl.DateTimeFormat('en-US', { timeZone: alias }); } catch { resolvable = false; }
553
+ if (!resolvable) continue;
554
+ const w = PROBES[1];
555
+ const el = await makePicker({});
556
+ const p = await selectAndApply(el, w, alias);
557
+ const ctx = `alias=${alias} canonical=${canonical}`;
558
+ f.add(ctx, checkPayload(p));
559
+ if (p && p.unixEpoch !== null) {
560
+ // the epoch must match the canonical zone's resolution, never UTC's
561
+ const el2 = await makePicker({});
562
+ const pc = await selectAndApply(el2, w, canonical);
563
+ if (pc && pc.unixEpoch !== p.unixEpoch) {
564
+ f.add(ctx, [{ code: 'ALIAS_EPOCH_DIVERGES', detail: `alias=${p.unixEpoch} canonical=${pc.unixEpoch}` }]);
565
+ }
566
+ if (offsetAt(p.unixEpoch, alias) === 0 && offsetAt(p.unixEpoch, canonical) !== 0) {
567
+ f.add(ctx, [{ code: 'ALIAS_DOWNGRADED_TO_UTC', detail: `value=${p.value}` }]);
568
+ }
569
+ }
570
+ }
571
+ expect(f.count, `alias violations:${f.report()}`).to.equal(0);
572
+ }).timeout(180000);
573
+
574
+ it('P3.5 EVERY static-fallback zone round-trips (legacy dropdown path)', async () => {
575
+ const f = new Failures();
576
+ let n = 0;
577
+ for (const z of TIMEZONES) {
578
+ if (!isResolvable(z)) continue;
579
+ await probeZone(z, PROBES[1], f); n += 1;
580
+ }
581
+ // eslint-disable-next-line no-console
582
+ console.warn(`[audit-p3] swept ${n} static-fallback zones, violations=${f.count}`);
583
+ expect(f.count, `static-list violations:${f.report()}`).to.equal(0);
584
+ }).timeout(900000);
585
+
586
+ it('P3.4 sub-hour zones (:30 / :45 / :15) keep exact offsets', async () => {
587
+ const f = new Failures();
588
+ for (const z of ['Asia/Kolkata', 'Asia/Kathmandu', 'Australia/Eucla',
589
+ 'America/St_Johns', 'Pacific/Chatham', 'Pacific/Marquesas', 'Australia/Lord_Howe']) {
590
+ for (const w of PROBES) {
591
+ const el = await makePicker({});
592
+ const p = await selectAndApply(el, w, z);
593
+ const ctx = `subhour tz=${z} want=${fmtWall(w)}`;
594
+ f.add(ctx, checkPayload(p, z));
595
+ if (p && p.unixEpoch !== null) {
596
+ const off = offsetAt(p.unixEpoch, z);
597
+ if (off % 3600000 === 0 && ['Asia/Kolkata', 'Asia/Kathmandu'].indexOf(z) !== -1) {
598
+ f.add(ctx, [{ code: 'SUBHOUR_LOST', detail: `offset became whole hours: ${off}` }]);
599
+ }
600
+ const rt = await roundTrip(p);
601
+ f.add(ctx, rt.violations);
602
+ }
603
+ }
604
+ }
605
+ expect(f.count, `sub-hour violations:${f.report()}`).to.equal(0);
606
+ }).timeout(300000);
607
+ });