@diagrammo/dgmo 0.49.0 → 0.50.1

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 (198) hide show
  1. package/.cursorrules +6 -2
  2. package/.github/copilot-instructions.md +6 -2
  3. package/.windsurfrules +6 -2
  4. package/SKILL.md +6 -2
  5. package/dist/advanced.js +557 -195
  6. package/dist/auto.js +129 -119
  7. package/dist/auto.mjs +19496 -12761
  8. package/dist/block.js +145 -48
  9. package/dist/{charts-d3-EW3YQTEA.js → charts-d3-LR6D3D7A.js} +5 -5
  10. package/dist/{chunk-5FGDJIJX.js → chunk-2C56LEML.js} +3 -3
  11. package/dist/{chunk-XJ7J6WOO.js → chunk-2KGXHFYK.js} +4 -4
  12. package/dist/{chunk-T7IKPCMI.js → chunk-3LH5CLP4.js} +3 -3
  13. package/dist/{chunk-ZDUQGL3N.js → chunk-3LKM6FMW.js} +2 -2
  14. package/dist/{chunk-4FIV4K4Z.js → chunk-3NODSS6A.js} +7 -7
  15. package/dist/{chunk-4BD7EVPK.js → chunk-3P2DKJCG.js} +2 -2
  16. package/dist/{chunk-TC3YWBFO.js → chunk-3UIKSPFB.js} +35 -9
  17. package/dist/{chunk-SJEGO2QL.js → chunk-3XGZF2QJ.js} +4 -4
  18. package/dist/chunk-3XPUDB7B.js +420 -0
  19. package/dist/{chunk-O5MQPK7E.js → chunk-3Y2DRD7S.js} +3 -3
  20. package/dist/chunk-3YPY3OXD.js +354 -0
  21. package/dist/{chunk-N4J5KGWG.js → chunk-4MJ7M6YL.js} +8 -8
  22. package/dist/{chunk-JFPY3UJ7.js → chunk-4S52SK6G.js} +8 -8
  23. package/dist/{chunk-ALRHIR6I.js → chunk-5GJYGP5Z.js} +4 -4
  24. package/dist/{chunk-SQDFK5ZQ.js → chunk-5OWVC2A6.js} +3 -3
  25. package/dist/{chunk-7VLUGEMJ.js → chunk-66NVRO4K.js} +4 -4
  26. package/dist/{chunk-ZREZOIGS.js → chunk-66RUL3XF.js} +6 -6
  27. package/dist/{chunk-MJCG5K2O.js → chunk-6BFZKBGD.js} +2 -2
  28. package/dist/{chunk-2WMBWZY2.js → chunk-6HJBFVLO.js} +3 -3
  29. package/dist/{chunk-XCC2RENT.js → chunk-6IAA2QQ2.js} +2 -2
  30. package/dist/{chunk-B57V3DWN.js → chunk-7L3R6I3U.js} +3 -3
  31. package/dist/chunk-7PQYTZMA.js +681 -0
  32. package/dist/{chunk-6SA7FJE4.js → chunk-7QKLIMRZ.js} +10 -10
  33. package/dist/{chunk-YTN572Q2.js → chunk-7TV5Y53Y.js} +2 -2
  34. package/dist/{chunk-6CLKNXVP.js → chunk-BBGDM4NQ.js} +457 -78
  35. package/dist/{chunk-3NFJWFNP.js → chunk-BDXC7MDK.js} +1045 -124
  36. package/dist/{chunk-D5AVQCDN.js → chunk-BH3UYK36.js} +3 -3
  37. package/dist/chunk-BTUTZMPT.js +482 -0
  38. package/dist/{chunk-LVHPTBO3.js → chunk-C2CVAM3U.js} +4 -4
  39. package/dist/{chunk-BCT5G2VN.js → chunk-DFTFPYUD.js} +5 -5
  40. package/dist/{chunk-KV6Y2HE6.js → chunk-DSWVNQVS.js} +4 -4
  41. package/dist/{chunk-4YNP6O47.js → chunk-DZXYF2F5.js} +13 -3
  42. package/dist/{chunk-FUCAB3KQ.js → chunk-EAMEADTV.js} +3 -3
  43. package/dist/chunk-FA6K3FWM.js +940 -0
  44. package/dist/{chunk-HBVD67XG.js → chunk-FJUNPCYI.js} +2 -2
  45. package/dist/{chunk-6VE3VLWM.js → chunk-GBE54KY6.js} +6 -5
  46. package/dist/{chunk-YRVLP7UU.js → chunk-GKC3HILQ.js} +4 -4
  47. package/dist/{chunk-ZXL6MB4R.js → chunk-GL5UZ6NY.js} +3 -3
  48. package/dist/{chunk-GB3YZTAM.js → chunk-H73FP42Q.js} +5 -5
  49. package/dist/{chunk-4UDKKGHH.js → chunk-HEVYAHLW.js} +2 -2
  50. package/dist/{chunk-DDTJ5N7Q.js → chunk-HLJVEAOF.js} +6 -6
  51. package/dist/{chunk-CLR4A2N2.js → chunk-HTMN2Z6U.js} +4 -4
  52. package/dist/{chunk-TLKMTQYL.js → chunk-I2WKW7C7.js} +3 -3
  53. package/dist/{chunk-IUK7AGD4.js → chunk-I7F2A35O.js} +2 -2
  54. package/dist/{chunk-IBC35BTK.js → chunk-IUMPEA64.js} +2 -2
  55. package/dist/{chunk-5XCM7UUW.js → chunk-J6K7RP6P.js} +100 -36
  56. package/dist/{chunk-AJ2PEY7J.js → chunk-JJUOHGX2.js} +2 -2
  57. package/dist/{chunk-CEHZOPGM.js → chunk-KFZYNWWO.js} +2 -2
  58. package/dist/{chunk-4NQ3IKUM.js → chunk-KHEYDLMT.js} +5 -5
  59. package/dist/{chunk-YM2BSPYW.js → chunk-LE4MYMLI.js} +2 -2
  60. package/dist/{chunk-PU3AUQPA.js → chunk-M5RXSRO2.js} +2 -2
  61. package/dist/{chunk-XKTN7CZF.js → chunk-MCZ5LBZD.js} +4 -4
  62. package/dist/{chunk-35BBZDFE.js → chunk-NU3XLTGP.js} +4 -4
  63. package/dist/{chunk-BPIJLRYE.js → chunk-NWED7CYO.js} +3 -3
  64. package/dist/{chunk-YYX3SU6H.js → chunk-OMNGQPEZ.js} +257 -101
  65. package/dist/{chunk-BGJV5ATD.js → chunk-ONA5KPV3.js} +2 -2
  66. package/dist/{chunk-ZNQX6QWH.js → chunk-OTAL43EH.js} +6 -2
  67. package/dist/{chunk-F743CM2N.js → chunk-OTQKUHRS.js} +3 -3
  68. package/dist/{chunk-KUBBJ2CD.js → chunk-P7CE7LXL.js} +6 -6
  69. package/dist/{chunk-UVCXZEGU.js → chunk-PFHVU7UA.js} +2 -2
  70. package/dist/{chunk-5ZZLLBFK.js → chunk-PGEGPSCZ.js} +2 -2
  71. package/dist/chunk-Q4V4XQWV.js +158 -0
  72. package/dist/{chunk-IHLSHCPZ.js → chunk-QJP6PG7F.js} +5 -5
  73. package/dist/{chunk-EYN7VFKL.js → chunk-QROYX7TT.js} +3 -3
  74. package/dist/chunk-QXKWYZNR.js +379 -0
  75. package/dist/{chunk-VC3TR4NL.js → chunk-RZ6YKEUJ.js} +3 -3
  76. package/dist/{chunk-K6HNAY5V.js → chunk-SCHXJTZL.js} +2 -2
  77. package/dist/{chunk-7OVSJI2V.js → chunk-SQLNBA64.js} +3 -3
  78. package/dist/{chunk-65RTDUZH.js → chunk-SXRTRMEE.js} +3 -3
  79. package/dist/{chunk-3BIAFYD2.js → chunk-T4VOVZT5.js} +2 -2
  80. package/dist/{chunk-UWDO3O52.js → chunk-TN35C5KM.js} +2 -2
  81. package/dist/{chunk-IFK3GIUW.js → chunk-TSA237IM.js} +2 -2
  82. package/dist/{chunk-DKEPS5LH.js → chunk-U2HGPLZS.js} +36 -2
  83. package/dist/{chunk-4HVNZ7WF.js → chunk-VBYSIOOY.js} +3 -3
  84. package/dist/{chunk-ZTLWVRNS.js → chunk-VDOOQZUD.js} +2 -2
  85. package/dist/{chunk-RTERS6S5.js → chunk-VUJGMJE6.js} +4 -4
  86. package/dist/{chunk-X2CH42BN.js → chunk-VVW3F3MD.js} +7 -7
  87. package/dist/{chunk-RI4NIMFP.js → chunk-VVZRV54S.js} +75 -35
  88. package/dist/{chunk-LG4TWW4U.js → chunk-WW32K72E.js} +8 -8
  89. package/dist/{chunk-NVT6C2VE.js → chunk-X6EZPSW6.js} +4 -4
  90. package/dist/{chunk-KQAEKMIX.js → chunk-XDXNDSKO.js} +2 -2
  91. package/dist/{chunk-FMKTYMP4.js → chunk-XJLKLU4D.js} +3 -3
  92. package/dist/chunk-Y4RNXEAO.js +952 -0
  93. package/dist/{chunk-26RVGM44.js → chunk-YIA4LEX4.js} +15 -7
  94. package/dist/chunk-YNRDWYZP.js +295 -0
  95. package/dist/{chunk-SGHSY3LU.js → chunk-Z6XJQ6KO.js} +81 -6
  96. package/dist/{chunk-SVDWQGX2.js → chunk-ZAD4HV2G.js} +139 -78
  97. package/dist/cli.cjs +153 -144
  98. package/dist/clock.d.ts +10 -0
  99. package/dist/clock.js +235 -0
  100. package/dist/countdown.d.ts +12 -0
  101. package/dist/countdown.js +450 -0
  102. package/dist/dgmo-router-YTU3ENAX.js +84 -0
  103. package/dist/{dimensions-WSIJXT5Q.js → dimensions-OTBKC5M6.js} +5 -5
  104. package/dist/editor.js +39 -1
  105. package/dist/element.js +131 -121
  106. package/dist/element.mjs +19496 -12761
  107. package/dist/{flowchart-parser-IVZN7CQN.js → flowchart-parser-OE4WHLTF.js} +4 -4
  108. package/dist/{flowchart-renderer-GMI2U3DD.js → flowchart-renderer-GPCSMTOR.js} +6 -6
  109. package/dist/highlight.d.ts +17 -1
  110. package/dist/highlight.js +156 -5
  111. package/dist/index.js +50 -45
  112. package/dist/{layout-HQMBPJVS.js → layout-46366KBT.js} +2 -2
  113. package/dist/{layout-D42XE4RE.js → layout-5BG6DFCU.js} +3 -3
  114. package/dist/{layout-K2ZN3Q42.js → layout-7MZ5NF2N.js} +4 -4
  115. package/dist/{layout-4Z5JM7PT.js → layout-FWODLIMP.js} +4 -4
  116. package/dist/{layout-GZ2CWONU.js → layout-J36454XU.js} +4 -4
  117. package/dist/{layout-S3EK4IYO.js → layout-LD6XTLD6.js} +4 -4
  118. package/dist/{parser-CLMFZWCC.js → parser-36HVKU5U.js} +5 -5
  119. package/dist/{parser-MCJWF5G3.js → parser-4AI5ZN5F.js} +3 -3
  120. package/dist/{parser-DERPY5KC.js → parser-4NO6VZ6S.js} +4 -4
  121. package/dist/parser-4WQQQXCG.js +13 -0
  122. package/dist/{parser-4ROBKVUR.js → parser-5OXGPNBF.js} +5 -5
  123. package/dist/{parser-XWUDFJ7P.js → parser-AGVYTQXV.js} +4 -4
  124. package/dist/{parser-TITK4YW6.js → parser-AXKBDGNO.js} +5 -5
  125. package/dist/parser-B5FVS7O6.js +11 -0
  126. package/dist/parser-CSFUN3CT.js +14 -0
  127. package/dist/parser-CVMEDULU.js +15 -0
  128. package/dist/{parser-KPMN5KKE.js → parser-D5VILGN2.js} +4 -4
  129. package/dist/{parser-IKZFTLOJ.js → parser-DFFEDKHH.js} +3 -3
  130. package/dist/{parser-JD7OQ2E6.js → parser-H3XEPFPV.js} +4 -4
  131. package/dist/{parser-UBGPTIZD.js → parser-HYRTF3DO.js} +3 -3
  132. package/dist/{parser-K647FRI4.js → parser-IBWNAPY4.js} +3 -3
  133. package/dist/{parser-4BKIFG2C.js → parser-IJBMRXMC.js} +5 -5
  134. package/dist/{parser-MBJSBTL5.js → parser-JJR52VAT.js} +5 -5
  135. package/dist/{parser-SMBJO3XN.js → parser-K3XXLMUW.js} +4 -4
  136. package/dist/{parser-OBQG655V.js → parser-KCR2WS3V.js} +4 -4
  137. package/dist/{parser-HVJFTOXL.js → parser-LWKKBNSA.js} +3 -3
  138. package/dist/{parser-ZYC3XGNS.js → parser-MPCE5JBG.js} +4 -4
  139. package/dist/{parser-QJYS7KQQ.js → parser-MTOMTWTD.js} +4 -4
  140. package/dist/{parser-GFSOPDB7.js → parser-O4HIUN6G.js} +4 -4
  141. package/dist/{parser-BL7Z72EY.js → parser-PSA4UBSP.js} +4 -4
  142. package/dist/{parser-TNYX5S7E.js → parser-RV4M6AS2.js} +4 -4
  143. package/dist/parser-RZPVAQVX.js +11 -0
  144. package/dist/{parser-UGA23PYK.js → parser-TGQZJ5OT.js} +4 -4
  145. package/dist/parser-TXND652E.js +13 -0
  146. package/dist/{parser-WISPH7LW.js → parser-VKOJM7KS.js} +4 -4
  147. package/dist/{parser-ZKF5K2H2.js → parser-W4PQUGX3.js} +4 -4
  148. package/dist/{parser-MRBPXXIV.js → parser-WAV5JRPT.js} +4 -4
  149. package/dist/{parser-D6ONJQFR.js → parser-YS7TOS2K.js} +3 -3
  150. package/dist/pert.d.ts +8 -0
  151. package/dist/{renderer-VFUVRNLK.js → renderer-2AZ5HJFK.js} +4 -4
  152. package/dist/{renderer-V3JEMWMM.js → renderer-2QPMJ2DA.js} +6 -6
  153. package/dist/renderer-45PSOL3E.js +19 -0
  154. package/dist/{renderer-BB5PREMY.js → renderer-4ITCHBT7.js} +4 -4
  155. package/dist/{renderer-XEKIRPI6.js → renderer-5DSEWF74.js} +5 -5
  156. package/dist/{renderer-QNHUXCRL.js → renderer-6OKF44KS.js} +9 -9
  157. package/dist/renderer-72LGR2YF.js +14 -0
  158. package/dist/{renderer-YHXPN3GF.js → renderer-7SD6MSBS.js} +7 -7
  159. package/dist/renderer-A5VE5BCI.js +24 -0
  160. package/dist/{renderer-A5VFZQQK.js → renderer-AUW2BE6G.js} +6 -6
  161. package/dist/{renderer-LWGJFT3D.js → renderer-B5TBNZJE.js} +5 -5
  162. package/dist/{renderer-4IUPINAE.js → renderer-BSR2O2H6.js} +7 -7
  163. package/dist/{renderer-DKESNMU5.js → renderer-CYB4LK3G.js} +6 -6
  164. package/dist/{renderer-MFJ7HY2H.js → renderer-FF24KZCI.js} +5 -5
  165. package/dist/{renderer-CGW7QPNA.js → renderer-FPE3J5VZ.js} +7 -7
  166. package/dist/{renderer-6T3KK4S3.js → renderer-FYSVXL7M.js} +7 -7
  167. package/dist/{renderer-THD6V5TL.js → renderer-HDCCZURL.js} +9 -7
  168. package/dist/{renderer-TPIBXNOS.js → renderer-JCCHNECZ.js} +6 -6
  169. package/dist/{renderer-QL5KO6SK.js → renderer-KS7YZJE2.js} +7 -7
  170. package/dist/{renderer-SQ3JUAI7.js → renderer-NGXZTRK6.js} +6 -6
  171. package/dist/{renderer-MJDDU27W.js → renderer-ODUUOPVT.js} +10 -10
  172. package/dist/renderer-PJM35LJN.js +17 -0
  173. package/dist/{renderer-TYXRHMRI.js → renderer-PPIHO5FI.js} +9 -9
  174. package/dist/{renderer-W5RMOURB.js → renderer-PSMMZCKH.js} +6 -6
  175. package/dist/{renderer-UZF3JROD.js → renderer-QAOBLRXV.js} +8 -8
  176. package/dist/{renderer-ROV756WT.js → renderer-R2WNIC2C.js} +5 -5
  177. package/dist/{renderer-VICQ4WNY.js → renderer-SBS3YWU5.js} +5 -5
  178. package/dist/{renderer-6L3NBEY5.js → renderer-UYMQQCJK.js} +6 -6
  179. package/dist/{renderer-radial-MHO2VDXN.js → renderer-radial-F7X5F2VU.js} +6 -6
  180. package/dist/{state-parser-RX3GXOIB.js → state-parser-3REXRK3R.js} +4 -4
  181. package/dist/{state-renderer-AJUKGNWU.js → state-renderer-XYLNRWXR.js} +6 -6
  182. package/docs/ai-integration.md +6 -2
  183. package/docs/language-reference.md +253 -22
  184. package/gallery/fixtures/body.dgmo +17 -0
  185. package/gallery/fixtures/bracket.dgmo +30 -0
  186. package/gallery/fixtures/clock.dgmo +8 -0
  187. package/gallery/fixtures/countdown.dgmo +3 -0
  188. package/gallery/fixtures/goal.dgmo +4 -0
  189. package/package.json +12 -4
  190. package/dist/advanced.d.ts +0 -6162
  191. package/dist/auto.d.ts +0 -54
  192. package/dist/block.d.ts +0 -123
  193. package/dist/dgmo-router-ODKPEJ3P.js +0 -79
  194. package/dist/element.d.ts +0 -62
  195. package/dist/index.d.ts +0 -166
  196. package/dist/parser-667RGSUW.js +0 -13
  197. package/dist/parser-J3P2D6IP.js +0 -13
  198. package/dist/themes-1-CuKpeH.d.ts +0 -908
@@ -0,0 +1,10 @@
1
+ /** Run one update pass over every clock row inside `root`. */
2
+ declare function tickClocks(root?: ParentNode): void;
3
+ /**
4
+ * Update `root` immediately, then (once per page) register a single 1s interval
5
+ * that re-scans the whole document. Idempotent — safe to call on every render /
6
+ * route change. No-op with no DOM.
7
+ */
8
+ declare function startClocks(root?: ParentNode): void;
9
+
10
+ export { startClocks, tickClocks };
package/dist/clock.js ADDED
@@ -0,0 +1,235 @@
1
+ // src/clock/resolve.ts
2
+ var SOON_MIN = 60;
3
+ var RAD = Math.PI / 180;
4
+ var DAY_MS = 864e5;
5
+ var J1970 = 2440588;
6
+ var J2000 = 2451545;
7
+ function zoneParts(zone, nowMs) {
8
+ const d = new Date(nowMs);
9
+ try {
10
+ const o = {};
11
+ new Intl.DateTimeFormat("en-US", {
12
+ timeZone: zone,
13
+ hour12: false,
14
+ hour: "2-digit",
15
+ minute: "2-digit",
16
+ second: "2-digit",
17
+ weekday: "short"
18
+ }).formatToParts(d).forEach((x) => {
19
+ o[x.type] = x.value;
20
+ });
21
+ const off = new Intl.DateTimeFormat("en-US", {
22
+ timeZone: zone,
23
+ timeZoneName: "shortOffset"
24
+ }).formatToParts(d).find((x) => x.type === "timeZoneName");
25
+ return {
26
+ h: parseInt(o["hour"], 10) % 24,
27
+ m: parseInt(o["minute"], 10),
28
+ s: parseInt(o["second"], 10),
29
+ weekday: o["weekday"],
30
+ offsetLabel: off ? off.value.replace("GMT", "UTC") : ""
31
+ };
32
+ } catch {
33
+ return {
34
+ h: d.getUTCHours(),
35
+ m: d.getUTCMinutes(),
36
+ s: d.getUTCSeconds(),
37
+ weekday: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][d.getUTCDay()],
38
+ offsetLabel: "UTC"
39
+ };
40
+ }
41
+ }
42
+ function pad2(n) {
43
+ return n < 10 ? "0" + n : String(n);
44
+ }
45
+ function formatTime(h, m, s, hours12) {
46
+ const sec = pad2(s);
47
+ if (hours12) {
48
+ const ap = h < 12 ? "am" : "pm";
49
+ let hr = h % 12;
50
+ if (hr === 0) hr = 12;
51
+ return { main: `${hr}:${pad2(m)}`, sec, ap };
52
+ }
53
+ return { main: `${pad2(h)}:${pad2(m)}`, sec, ap: "" };
54
+ }
55
+ function fmtDelta(ms) {
56
+ const m = Math.max(0, Math.round(ms / 6e4));
57
+ if (m < 90) return `${m}m`;
58
+ return `${Math.floor(m / 60)}h ${m % 60}m`;
59
+ }
60
+ function workStatus(parts, work) {
61
+ if (!work) return null;
62
+ const min = parts.h * 60 + parts.m;
63
+ if (!work.days[parts.weekday]) return { cls: "off", text: "Weekend" };
64
+ if (min < work.startMin) {
65
+ const d = work.startMin - min;
66
+ return {
67
+ cls: d <= SOON_MIN ? "soon" : "off",
68
+ text: `starts in ${fmtDelta(d * 6e4)}`
69
+ };
70
+ }
71
+ if (min < work.endMin) {
72
+ return { cls: "ok", text: `${fmtDelta((work.endMin - min) * 6e4)} left` };
73
+ }
74
+ return {
75
+ cls: "off",
76
+ text: `ended ${fmtDelta((min - work.endMin) * 6e4)} ago`
77
+ };
78
+ }
79
+ function toJulian(ms) {
80
+ return ms / DAY_MS - 0.5 + J1970;
81
+ }
82
+ function fromJulian(j) {
83
+ return (j + 0.5 - J1970) * DAY_MS;
84
+ }
85
+ function sunTimes(nowMs, lat, lon) {
86
+ const lw = -lon * RAD;
87
+ const phi = lat * RAD;
88
+ const J = toJulian(nowMs);
89
+ const n = Math.round(J - J2000 - 9e-4 - lw / (2 * Math.PI));
90
+ const Jn = J2000 + 9e-4 + lw / (2 * Math.PI) + n;
91
+ const M = (357.5291 + 0.98560028 * (Jn - J2000)) * RAD;
92
+ const C = (1.9148 * Math.sin(M) + 0.02 * Math.sin(2 * M) + 3e-4 * Math.sin(3 * M)) * RAD;
93
+ const L = M + C + Math.PI + 102.9372 * RAD;
94
+ const Jt = Jn + 53e-4 * Math.sin(M) - 69e-4 * Math.sin(2 * L);
95
+ const dec = Math.asin(Math.sin(L) * Math.sin(23.44 * RAD));
96
+ const cw = (Math.sin(-0.833 * RAD) - Math.sin(phi) * Math.sin(dec)) / (Math.cos(phi) * Math.cos(dec));
97
+ if (cw > 1) return { polar: "night" };
98
+ if (cw < -1) return { polar: "day" };
99
+ const w = Math.acos(cw);
100
+ const Jset = J2000 + 9e-4 + (w + lw) / (2 * Math.PI) + n + 53e-4 * Math.sin(M) - 69e-4 * Math.sin(2 * L);
101
+ return {
102
+ sunriseMs: fromJulian(Jt - (Jset - Jt)),
103
+ sunsetMs: fromJulian(Jset)
104
+ };
105
+ }
106
+ function sunLine(nowMs, lat, lon) {
107
+ const t = sunTimes(nowMs, lat, lon);
108
+ if (t.polar) {
109
+ return {
110
+ up: t.polar === "day",
111
+ text: t.polar === "day" ? "midnight sun" : "polar night"
112
+ };
113
+ }
114
+ if (nowMs < t.sunriseMs) {
115
+ return { up: false, text: `sunrise in ${fmtDelta(t.sunriseMs - nowMs)}` };
116
+ }
117
+ if (nowMs < t.sunsetMs) {
118
+ return { up: true, text: `sunset in ${fmtDelta(t.sunsetMs - nowMs)}` };
119
+ }
120
+ const tm = sunTimes(nowMs + DAY_MS, lat, lon);
121
+ if (tm.polar) return { up: false, text: "sunrise in \u2014" };
122
+ return { up: false, text: `sunrise in ${fmtDelta(tm.sunriseMs - nowMs)}` };
123
+ }
124
+ function handAngles(h, m, s) {
125
+ return {
126
+ hour: (h % 12 + m / 60) * 30,
127
+ minute: (m + s / 60) * 6,
128
+ second: s * 6
129
+ };
130
+ }
131
+
132
+ // src/clock/ticker.ts
133
+ function readWork(node) {
134
+ const start = node.getAttribute("data-dgmo-clock-work-start");
135
+ const end = node.getAttribute("data-dgmo-clock-work-end");
136
+ if (start === null || end === null) return null;
137
+ const days = {};
138
+ (node.getAttribute("data-dgmo-clock-work-days") ?? "").split(",").filter(Boolean).forEach((d) => {
139
+ days[d] = true;
140
+ });
141
+ return { startMin: Number(start), endMin: Number(end), days };
142
+ }
143
+ function setHand(group, which, angle) {
144
+ const hand = group.querySelector(`[data-dgmo-clock-hand="${which}"]`);
145
+ if (hand) hand.setAttribute("transform", `rotate(${angle} 50 50)`);
146
+ }
147
+ function setPart(group, sel, textContent) {
148
+ const el = group.querySelector(sel);
149
+ if (el && el.textContent !== textContent) el.textContent = textContent;
150
+ }
151
+ function updateRow(group, now) {
152
+ const zone = group.getAttribute("data-dgmo-clock-zone");
153
+ if (!zone) return;
154
+ const parts = zoneParts(zone, now);
155
+ const latAttr = group.getAttribute("data-dgmo-clock-lat");
156
+ const lonAttr = group.getAttribute("data-dgmo-clock-lon");
157
+ const sunOn = group.getAttribute("data-dgmo-clock-sun") === "1";
158
+ const hasCoords = latAttr !== null && lonAttr !== null;
159
+ const sun = sunOn && hasCoords ? sunLine(now, Number(latAttr), Number(lonAttr)) : null;
160
+ const up = sun ? sun.up : parts.h >= 6 && parts.h < 18;
161
+ const c = (name) => group.getAttribute(`data-dgmo-clock-c-${name}`) ?? "";
162
+ const stColor = up ? c("day") : c("night");
163
+ const stTint = up ? c("day-soft") : c("night-soft");
164
+ const hours12 = group.getAttribute("data-dgmo-clock-hours12") !== "0";
165
+ const ts = formatTime(parts.h, parts.m, parts.s, hours12);
166
+ const ang = handAngles(parts.h, parts.m, parts.s);
167
+ setHand(group, "h", ang.hour);
168
+ setHand(group, "m", ang.minute);
169
+ setHand(group, "s", ang.second);
170
+ const autoSolid = group.getAttribute("data-dgmo-clock-auto-solid");
171
+ const autoFace = group.getAttribute("data-dgmo-clock-auto-face");
172
+ const faceFill = autoFace ?? stTint;
173
+ const handColor = autoSolid ?? stColor;
174
+ const face = group.querySelector("[data-dgmo-clock-facebg]");
175
+ if (face) face.setAttribute("fill", faceFill);
176
+ const ring = group.querySelector("[data-dgmo-clock-facering]");
177
+ if (ring && autoSolid) ring.setAttribute("stroke", autoSolid);
178
+ const center = group.querySelector("[data-dgmo-clock-center]");
179
+ if (center) center.setAttribute("fill", handColor);
180
+ const secondHand = group.querySelector('[data-dgmo-clock-hand="s"]');
181
+ if (secondHand) secondHand.setAttribute("stroke", handColor);
182
+ setPart(group, '[data-dgmo-clock-digital-part="main"]', ts.main);
183
+ setPart(group, '[data-dgmo-clock-digital-part="sec"]', `:${ts.sec}`);
184
+ setPart(group, '[data-dgmo-clock-digital-part="ap"]', ` ${ts.ap}`);
185
+ setPart(group, "[data-dgmo-clock-ampm]", ts.ap.toUpperCase());
186
+ const work = readWork(group);
187
+ const status = workStatus(parts, work);
188
+ const statusEl = group.querySelector("[data-dgmo-clock-status]");
189
+ if (status && statusEl) {
190
+ const col = status.cls === "ok" ? c("ok") : status.cls === "soon" ? c("soon") : c("off");
191
+ if (statusEl.textContent !== status.text)
192
+ statusEl.textContent = status.text;
193
+ statusEl.setAttribute("fill", col);
194
+ const dot = group.querySelector("[data-dgmo-clock-status-dot]");
195
+ if (dot) {
196
+ if (status.cls === "off") {
197
+ dot.setAttribute("fill", "none");
198
+ dot.setAttribute("stroke", col);
199
+ dot.setAttribute("stroke-width", "1.4");
200
+ } else {
201
+ dot.setAttribute("fill", col);
202
+ dot.setAttribute("stroke", "none");
203
+ }
204
+ }
205
+ }
206
+ const sunEl = group.querySelector("[data-dgmo-clock-sun-line]");
207
+ if (sun && sunEl) {
208
+ if (sunEl.textContent !== sun.text) sunEl.textContent = sun.text;
209
+ const icon = group.querySelector("[data-dgmo-clock-sun-icon]");
210
+ if (icon) {
211
+ const sunG = icon.querySelector('[data-clock-glyph="sun"]');
212
+ const moonG = icon.querySelector('[data-clock-glyph="moon"]');
213
+ if (sunG) sunG.setAttribute("display", up ? "inline" : "none");
214
+ if (moonG) moonG.setAttribute("display", up ? "none" : "inline");
215
+ }
216
+ }
217
+ }
218
+ function tickClocks(root = document) {
219
+ if (typeof document === "undefined") return;
220
+ const now = Date.now();
221
+ root.querySelectorAll("[data-dgmo-clock]").forEach((group) => updateRow(group, now));
222
+ }
223
+ var intervalStarted = false;
224
+ function startClocks(root = document) {
225
+ if (typeof window === "undefined" || typeof document === "undefined") return;
226
+ tickClocks(root);
227
+ if (intervalStarted) return;
228
+ intervalStarted = true;
229
+ window.setInterval(() => tickClocks(document), 1e3);
230
+ }
231
+ export {
232
+ startClocks,
233
+ tickClocks
234
+ };
235
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1,12 @@
1
+ declare const DAY_MS = 86400000;
2
+
3
+ /** Run one update pass over every countdown node inside `root`. */
4
+ declare function tickCountdowns(root?: ParentNode): void;
5
+ /**
6
+ * Update `root` immediately, then (once per page) register a single 1s interval
7
+ * that re-scans the whole document. Idempotent — safe to call on every render /
8
+ * route change (mirrors remark's `clickHandlerBound` guard). No-op with no DOM.
9
+ */
10
+ declare function startCountdowns(root?: ParentNode): void;
11
+
12
+ export { DAY_MS, startCountdowns, tickCountdowns };