@demlik/tea 0.6.0 → 0.8.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 (158) hide show
  1. package/dist/agent/index.d.ts +6 -5
  2. package/dist/agent/index.js +10 -10
  3. package/dist/authed-call/index.d.ts +2 -2
  4. package/dist/authed-call/index.js +7 -7
  5. package/dist/await-terminal/index.d.ts +3 -2
  6. package/dist/await-terminal/index.js +2 -2
  7. package/dist/batch-window/index.d.ts +4 -3
  8. package/dist/batch-window/index.js +3 -3
  9. package/dist/cache/index.d.ts +2 -2
  10. package/dist/cache/index.js +4 -4
  11. package/dist/chart/index.d.ts +217 -0
  12. package/dist/chart/index.js +16 -0
  13. package/dist/chart/index.js.map +1 -0
  14. package/dist/chart/inspect/index.d.ts +85 -0
  15. package/dist/chart/inspect/index.js +5 -0
  16. package/dist/chart/inspect/index.js.map +1 -0
  17. package/dist/chart/inspect/react.d.ts +112 -0
  18. package/dist/chart/inspect/react.js +11 -0
  19. package/dist/chart/inspect/react.js.map +1 -0
  20. package/dist/chart/inspect/styles.css +286 -0
  21. package/dist/chart/lane/index.d.ts +361 -0
  22. package/dist/chart/lane/index.js +9 -0
  23. package/dist/chart/lane/index.js.map +1 -0
  24. package/dist/chart/lane/react.d.ts +83 -0
  25. package/dist/chart/lane/react.js +559 -0
  26. package/dist/chart/lane/react.js.map +1 -0
  27. package/dist/chart/lane/styles.css +498 -0
  28. package/dist/chart/report/index.d.ts +116 -0
  29. package/dist/chart/report/index.js +32 -0
  30. package/dist/chart/report/index.js.map +1 -0
  31. package/dist/{chunk-2UGTDYOK.js → chunk-3JU6657S.js} +3 -3
  32. package/dist/{chunk-2UGTDYOK.js.map → chunk-3JU6657S.js.map} +1 -1
  33. package/dist/{chunk-AZ3NHUPD.js → chunk-4KTWLPL5.js} +3 -3
  34. package/dist/{chunk-AZ3NHUPD.js.map → chunk-4KTWLPL5.js.map} +1 -1
  35. package/dist/{chunk-ZH454CR5.js → chunk-5EHLEUTL.js} +24 -4
  36. package/dist/chunk-5EHLEUTL.js.map +1 -0
  37. package/dist/chunk-5KJKJOFC.js +758 -0
  38. package/dist/chunk-5KJKJOFC.js.map +1 -0
  39. package/dist/{chunk-WF46FABO.js → chunk-7SVIRMC6.js} +3 -3
  40. package/dist/{chunk-WF46FABO.js.map → chunk-7SVIRMC6.js.map} +1 -1
  41. package/dist/{chunk-XMHZ44QC.js → chunk-7V4EVLZA.js} +4 -4
  42. package/dist/{chunk-XMHZ44QC.js.map → chunk-7V4EVLZA.js.map} +1 -1
  43. package/dist/{chunk-IVHQCVFX.js → chunk-A56OR5RF.js} +3 -3
  44. package/dist/{chunk-IVHQCVFX.js.map → chunk-A56OR5RF.js.map} +1 -1
  45. package/dist/{chunk-O7ED34JH.js → chunk-B5VXOFMZ.js} +47 -15
  46. package/dist/chunk-B5VXOFMZ.js.map +1 -0
  47. package/dist/chunk-E6GEDSF4.js +307 -0
  48. package/dist/chunk-E6GEDSF4.js.map +1 -0
  49. package/dist/{chunk-EC6FO42Q.js → chunk-EUF7XOEE.js} +6 -6
  50. package/dist/{chunk-EC6FO42Q.js.map → chunk-EUF7XOEE.js.map} +1 -1
  51. package/dist/{chunk-XOAP3LOT.js → chunk-I5OV65MS.js} +3 -3
  52. package/dist/{chunk-XOAP3LOT.js.map → chunk-I5OV65MS.js.map} +1 -1
  53. package/dist/chunk-JER5O7PQ.js +416 -0
  54. package/dist/chunk-JER5O7PQ.js.map +1 -0
  55. package/dist/{chunk-ASX7PL2K.js → chunk-JGVL3WPL.js} +3 -3
  56. package/dist/{chunk-ASX7PL2K.js.map → chunk-JGVL3WPL.js.map} +1 -1
  57. package/dist/{chunk-S6Y3RNX4.js → chunk-JP5D6GSL.js} +4 -4
  58. package/dist/{chunk-S6Y3RNX4.js.map → chunk-JP5D6GSL.js.map} +1 -1
  59. package/dist/{chunk-ERYY5P6W.js → chunk-ND3DH6KM.js} +3 -3
  60. package/dist/{chunk-ERYY5P6W.js.map → chunk-ND3DH6KM.js.map} +1 -1
  61. package/dist/{chunk-A7USKARI.js → chunk-SUST46KO.js} +3 -3
  62. package/dist/{chunk-A7USKARI.js.map → chunk-SUST46KO.js.map} +1 -1
  63. package/dist/{chunk-2KBEIGYP.js → chunk-TP5UPGLY.js} +3 -3
  64. package/dist/{chunk-2KBEIGYP.js.map → chunk-TP5UPGLY.js.map} +1 -1
  65. package/dist/chunk-UOC2PL46.js +13 -0
  66. package/dist/chunk-UOC2PL46.js.map +1 -0
  67. package/dist/{chunk-66S2KEQQ.js → chunk-WLGO64WC.js} +4 -4
  68. package/dist/{chunk-66S2KEQQ.js.map → chunk-WLGO64WC.js.map} +1 -1
  69. package/dist/chunk-WRAA7GVZ.js +209 -0
  70. package/dist/chunk-WRAA7GVZ.js.map +1 -0
  71. package/dist/chunk-ZCL7SCBK.js +685 -0
  72. package/dist/chunk-ZCL7SCBK.js.map +1 -0
  73. package/dist/chunk-ZD6PNZBK.js +457 -0
  74. package/dist/chunk-ZD6PNZBK.js.map +1 -0
  75. package/dist/{chunk-UV7VCTNC.js → chunk-ZF6WDK2D.js} +7 -7
  76. package/dist/{chunk-UV7VCTNC.js.map → chunk-ZF6WDK2D.js.map} +1 -1
  77. package/dist/{core-CUN5HDKL.d.ts → core-Bjc0bS8j.d.ts} +22 -1
  78. package/dist/deadline/index.d.ts +2 -2
  79. package/dist/deadline/index.js +3 -3
  80. package/dist/devtools/index.js +2 -207
  81. package/dist/devtools/index.js.map +1 -1
  82. package/dist/do/index.d.ts +7 -6
  83. package/dist/do/index.js +10 -10
  84. package/dist/{durable-effects-CXMOi-sp.d.ts → durable-effects-D8SqU_if.d.ts} +1 -1
  85. package/dist/extension/index.d.ts +3 -2
  86. package/dist/extension/index.js +3 -3
  87. package/dist/extension/react.js +3 -3
  88. package/dist/extension/subs/index.d.ts +2 -2
  89. package/dist/fan-out/index.d.ts +3 -2
  90. package/dist/fold-Blbhru48.d.ts +435 -0
  91. package/dist/graph-CcjWZVrd.d.ts +923 -0
  92. package/dist/idempotent-intake/index.d.ts +3 -2
  93. package/dist/index.d.ts +5 -4
  94. package/dist/index.js +2 -2
  95. package/dist/llm-call/index.d.ts +2 -2
  96. package/dist/llm-call/index.js +7 -7
  97. package/dist/{machine-CoWpvp8x.d.ts → machine-0OmPvsy_.d.ts} +1 -1
  98. package/dist/machine-viz/index.d.ts +19 -2
  99. package/dist/machine-viz/index.js +4 -10
  100. package/dist/machine-viz/index.js.map +1 -1
  101. package/dist/mem/index.d.ts +3 -2
  102. package/dist/monitored-run/index.d.ts +4 -3
  103. package/dist/monitored-run/index.js +5 -5
  104. package/dist/node/index.d.ts +3 -2
  105. package/dist/paginated-walk/index.d.ts +2 -2
  106. package/dist/paginated-walk/index.js +7 -7
  107. package/dist/parity/index.d.ts +3 -2
  108. package/dist/parity/index.js +3 -3
  109. package/dist/pbt/arbitraries/index.d.ts +1 -1
  110. package/dist/pbt/index.d.ts +1 -1
  111. package/dist/pbt/index.js +3 -3
  112. package/dist/pbt/runners/index.d.ts +1 -1
  113. package/dist/pbt/runners/index.js +3 -3
  114. package/dist/poller/index.d.ts +28 -7
  115. package/dist/poller/index.js +3 -3
  116. package/dist/poller/index.js.map +1 -1
  117. package/dist/prediction/index.d.ts +1 -1
  118. package/dist/prediction/index.js +2 -2
  119. package/dist/pure/index.d.ts +1 -1
  120. package/dist/pure/index.js +2 -2
  121. package/dist/react/index.d.ts +3 -2
  122. package/dist/react/index.js +2 -2
  123. package/dist/reconciler/index.d.ts +2 -2
  124. package/dist/reconciler/index.js +7 -7
  125. package/dist/recorder/index.d.ts +3 -2
  126. package/dist/reducer-BqyoVyBG.d.ts +447 -0
  127. package/dist/resilient-call/index.d.ts +2 -2
  128. package/dist/resilient-call/index.js +6 -6
  129. package/dist/run-BVeqJDBF.d.ts +713 -0
  130. package/dist/{runtime-types-BD3ZFfdw.d.ts → runtime-types-Bxc637bp.d.ts} +53 -2
  131. package/dist/saga/index.d.ts +3 -2
  132. package/dist/samples-DCt6nF8H.d.ts +59 -0
  133. package/dist/snapshot/index.d.ts +1 -1
  134. package/dist/snapshot/index.js +3 -3
  135. package/dist/subs/index.d.ts +4 -3
  136. package/dist/subs/index.js +3 -3
  137. package/dist/testing/index.d.ts +3 -2
  138. package/dist/testing/index.js +2 -2
  139. package/dist/throttled-input/index.d.ts +2 -2
  140. package/dist/throttled-input/index.js +6 -6
  141. package/dist/token-refresh/index.d.ts +1 -1
  142. package/dist/token-refresh/index.js +3 -3
  143. package/dist/trace-replay/index.d.ts +3 -2
  144. package/dist/trace-replay/index.js +3 -3
  145. package/dist/{types-CjAkI83U.d.ts → types-D7u9DkH7.d.ts} +1 -1
  146. package/dist/with-deadline/index.d.ts +1 -1
  147. package/dist/with-deadline/index.js +2 -2
  148. package/dist/with-resilience/index.d.ts +2 -2
  149. package/dist/with-resilience/index.js +6 -6
  150. package/dist/with-telemetry/index.d.ts +1 -1
  151. package/dist/with-telemetry/index.js +2 -2
  152. package/dist/work-queue/adapter.d.ts +3 -2
  153. package/dist/work-queue/index.d.ts +3 -2
  154. package/dist/work-queue/ops.d.ts +3 -2
  155. package/dist/workflow/index.d.ts +3 -3
  156. package/package.json +31 -1
  157. package/dist/chunk-O7ED34JH.js.map +0 -1
  158. package/dist/chunk-ZH454CR5.js.map +0 -1
@@ -0,0 +1,307 @@
1
+ import { safeId, safeLabel } from './chunk-UOC2PL46.js';
2
+ import { Cmd, NoCellError } from './chunk-B5VXOFMZ.js';
3
+
4
+ // src/chart/compile.ts
5
+ var CellTargetError = class extends Error {
6
+ constructor(at, cell, returned, declared) {
7
+ super(
8
+ `@demlik/tea: cell "${cell}" at edge "${at}" returned state "${returned}", which is not among that edge's declared targets [${declared.map((t) => `"${t}"`).join(", ")}] \u2014 either the cell is wrong, or the edge's \`to\` is missing a target the code can reach (in which case add it, so the chart still draws the whole fan-out).`
9
+ );
10
+ this.at = at;
11
+ this.cell = cell;
12
+ this.returned = returned;
13
+ this.declared = declared;
14
+ }
15
+ at;
16
+ cell;
17
+ returned;
18
+ declared;
19
+ name = "CellTargetError";
20
+ _tag = "CellTargetError";
21
+ };
22
+ function cmdNames(ref) {
23
+ if (ref === void 0) return [];
24
+ return typeof ref === "string" ? [ref] : ref;
25
+ }
26
+ function flatten(c) {
27
+ const out = /* @__PURE__ */ new Map();
28
+ for (const group of Object.keys(c.states)) {
29
+ const members = c.states[group] ?? {};
30
+ for (const s of Object.keys(members)) {
31
+ const node = members[s];
32
+ if (node !== void 0) out.set(s, { node, group });
33
+ }
34
+ }
35
+ return out;
36
+ }
37
+ function scopeList(scope) {
38
+ return typeof scope === "string" ? [scope] : scope;
39
+ }
40
+ function rtParts(parts) {
41
+ const p = parts;
42
+ return {
43
+ assign: p.assign ?? {},
44
+ guards: p.guards ?? {},
45
+ cmds: p.cmds ?? {},
46
+ cells: p.cells ?? {}
47
+ };
48
+ }
49
+ function buildCell(spec, bare, at, p, parking) {
50
+ const edge = typeof spec === "string" ? { target: spec } : spec;
51
+ const cell = p.assign[at];
52
+ if (edge.cell !== void 0) {
53
+ const name = edge.cell;
54
+ const impl = p.cells[name];
55
+ if (impl === void 0) {
56
+ throw new Error(
57
+ `@demlik/tea: edge "${at}" names cell "${name}" with no implementation`
58
+ );
59
+ }
60
+ const hand = typeof impl === "function" ? impl : impl[at];
61
+ if (hand === void 0) {
62
+ throw new Error(
63
+ `@demlik/tea: cell "${name}" is written in the per-site form but has no entry for edge "${at}"`
64
+ );
65
+ }
66
+ const to = edge.to ?? [];
67
+ return (st, nsMsg) => {
68
+ const out = hand(st, { ...nsMsg, type: bare }, at);
69
+ if (!to.includes(out[0].type)) {
70
+ throw new CellTargetError(at, name, out[0].type, to);
71
+ }
72
+ return out;
73
+ };
74
+ }
75
+ const guard = edge.when === void 0 ? void 0 : p.guards[edge.when];
76
+ if (edge.when !== void 0 && guard === void 0) {
77
+ throw new Error(
78
+ `@demlik/tea: edge "${at}" names guard "${edge.when}" with no implementation`
79
+ );
80
+ }
81
+ return (st, nsMsg) => {
82
+ const msg = { ...nsMsg, type: bare };
83
+ let target;
84
+ let payloadFn;
85
+ let fired = true;
86
+ if (edge.resume !== void 0) {
87
+ target = st.was ?? edge.resume.fallback;
88
+ payloadFn = cell;
89
+ } else if (guard !== void 0) {
90
+ fired = guard(st, msg, at) === true;
91
+ const branch = cell;
92
+ target = fired ? edge.target : edge.otherwise;
93
+ payloadFn = fired ? branch.then : branch.else;
94
+ } else {
95
+ target = edge.target;
96
+ payloadFn = cell;
97
+ }
98
+ const data = payloadFn(st, msg);
99
+ const next = parking.has(target) ? { ...data, type: target, was: st.type } : { ...data, type: target };
100
+ const emitted = cmdNames(fired ? edge.cmd : edge.otherwiseCmd).map(
101
+ (n) => {
102
+ const build = p.cmds[n];
103
+ if (build === void 0) {
104
+ throw new Error(
105
+ `@demlik/tea: edge "${at}" names cmd "${n}" with no builder`
106
+ );
107
+ }
108
+ return { ...build(st, msg, at), type: n };
109
+ }
110
+ );
111
+ return [next, emitted];
112
+ };
113
+ }
114
+ function keyOf(c, e, ns) {
115
+ return ns === void 0 || c.events[e]?.foreign === true ? e : `${ns}.${e}`;
116
+ }
117
+ var NO_PARKING = /* @__PURE__ */ new Set();
118
+ function compileTable(chart, parts, ns) {
119
+ const c = chart;
120
+ const p = rtParts(parts);
121
+ const flat = flatten(c);
122
+ const events = Object.keys(c.events);
123
+ const parking = /* @__PURE__ */ new Set();
124
+ for (const [s, { node }] of flat) {
125
+ for (const spec of Object.values(node.on ?? {})) {
126
+ if (typeof spec === "object" && spec.resume !== void 0) parking.add(s);
127
+ }
128
+ }
129
+ const table = {};
130
+ for (const [s, { node, group }] of flat) {
131
+ const row = {};
132
+ const on = node.on ?? {};
133
+ for (const e of events) {
134
+ const key = keyOf(c, e, ns);
135
+ const spec = on[e];
136
+ if (spec === void 0) {
137
+ const scope = scopeList(c.events[e]?.scope ?? "edges");
138
+ const live = scope.includes("all") || scope.includes(group);
139
+ const refused = node.end !== void 0 || !live || (node.ignore ?? []).includes(e);
140
+ row[key] = refused ? (st) => [st, []] : () => {
141
+ throw new NoCellError(key, s);
142
+ };
143
+ continue;
144
+ }
145
+ row[key] = buildCell(spec, e, `${s}.${e}`, p, parking);
146
+ }
147
+ table[s] = row;
148
+ }
149
+ return table;
150
+ }
151
+ function compile(chart, parts, ns) {
152
+ return compileTable(chart, parts, ns);
153
+ }
154
+ function compileReducer(chart, parts, ns) {
155
+ const c = chart;
156
+ const p = rtParts(parts);
157
+ const out = {};
158
+ for (const e of Object.keys(c.events)) {
159
+ const spec = c.on[e];
160
+ if (spec === void 0) {
161
+ throw new Error(`@demlik/tea: reducer chart declares no edge for "${e}"`);
162
+ }
163
+ out[keyOf(c, e, ns)] = buildCell(spec, e, e, p, NO_PARKING);
164
+ }
165
+ return out;
166
+ }
167
+ function reducerInitFrom(chart, boot) {
168
+ const type = chart.initial;
169
+ return (loaded) => [
170
+ loaded ?? { ...boot(), type },
171
+ Cmd.none
172
+ ];
173
+ }
174
+ function reducerMermaid(chart) {
175
+ const c = chart;
176
+ const lines = [
177
+ "stateDiagram-v2",
178
+ " direction TB",
179
+ ` [*] --> ${safeId(c.initial)}`
180
+ ];
181
+ for (const [e, spec] of Object.entries(c.on)) {
182
+ lines.push(...edgeLines("any", "any", e, spec, NO_MARKS));
183
+ }
184
+ return lines.join("\n");
185
+ }
186
+ function initialStateOf(chart) {
187
+ const flat = flatten(chart);
188
+ const marked = [...flat].filter(([, f]) => f.node.initial === true);
189
+ const only = marked[0];
190
+ if (marked.length !== 1 || only === void 0) {
191
+ throw new Error(
192
+ `@demlik/tea: chart must mark exactly one state \`initial: true\` (found ${marked.length})`
193
+ );
194
+ }
195
+ return only[0];
196
+ }
197
+ function initFrom(chart, boot) {
198
+ const type = initialStateOf(chart);
199
+ return (loaded) => [
200
+ // The one cast this helper needs: `{ ...InitialData, type: <the initial
201
+ // name> }` IS `Extract<S, { type: InitialState<C> }>`, but tsc cannot
202
+ // rebuild a union member from a spread plus a `string`-typed discriminant.
203
+ loaded ?? { ...boot(), type },
204
+ Cmd.none
205
+ ];
206
+ }
207
+ var edgeKey = (from, event, to) => `${from}|${event}|${to}`;
208
+ var ACTIVE_CLASS = "teaActive";
209
+ var ACTIVE_ERROR_CLASS = "teaActiveError";
210
+ var TRIPPED_CLASS = "teaTripped";
211
+ var SHIPPED_CLASS = "teaShipped";
212
+ function nodeDecl(raw, indent) {
213
+ const id = safeId(raw);
214
+ return id === raw ? void 0 : `${indent}${id} : ${safeLabel(raw)}`;
215
+ }
216
+ function edgeLines(from, at, e, spec, mark) {
217
+ const edge = typeof spec === "string" ? { target: spec } : spec;
218
+ const out = [];
219
+ const arrow = (to, label) => {
220
+ out.push(
221
+ ` ${from} --> ${safeId(to)} : ${safeLabel(`${label}${mark(at, e, to)}`)}`
222
+ );
223
+ };
224
+ if (edge.cell !== void 0) {
225
+ for (const t of edge.to ?? []) arrow(t, `${e} / ${edge.cell}()`);
226
+ return out;
227
+ }
228
+ if (edge.resume !== void 0) {
229
+ arrow(edge.resume.fallback, `${e} (resume)`);
230
+ return out;
231
+ }
232
+ const guard = edge.when === void 0 ? "" : ` [${edge.when}]`;
233
+ if (edge.target !== void 0) arrow(edge.target, `${e}${guard}`);
234
+ if (edge.otherwise !== void 0)
235
+ arrow(edge.otherwise, `${e} [!${edge.when ?? ""}]`);
236
+ return out;
237
+ }
238
+ var NO_MARKS = () => "";
239
+ function chartMermaid(chart, opts = {}) {
240
+ const c = chart;
241
+ const flat = flatten(c);
242
+ const lines = [];
243
+ if (opts.title !== void 0)
244
+ lines.push("---", `title: ${opts.title}`, "---");
245
+ lines.push("stateDiagram-v2", ` direction ${opts.direction ?? "TB"}`);
246
+ const walked = opts.walked;
247
+ const mark = (from, event, to) => {
248
+ const n = walked?.get(edgeKey(from, event, to)) ?? 0;
249
+ return n === 0 ? "" : n === 1 ? " \xBB" : ` \xBB\xD7${n}`;
250
+ };
251
+ if (opts.phases === true) {
252
+ for (const [group, members] of Object.entries(c.states)) {
253
+ lines.push(` state ${safeId(group)} {`);
254
+ for (const s of Object.keys(members)) {
255
+ lines.push(nodeDecl(s, " ") ?? ` ${safeId(s)}`);
256
+ }
257
+ lines.push(" }");
258
+ }
259
+ }
260
+ for (const [s, { node }] of flat) {
261
+ const from = safeId(s);
262
+ if (opts.phases !== true) {
263
+ const decl = nodeDecl(s, " ");
264
+ if (decl !== void 0) lines.push(decl);
265
+ }
266
+ if (node.initial === true) lines.push(` [*] --> ${from}`);
267
+ for (const [e, spec] of Object.entries(node.on ?? {})) {
268
+ lines.push(...edgeLines(from, s, e, spec, mark));
269
+ }
270
+ if (node.end !== void 0) lines.push(` ${from} --> [*]`);
271
+ }
272
+ if (opts.polarity === true) {
273
+ const tripped = [];
274
+ const shipped = [];
275
+ for (const [s, { node }] of flat) {
276
+ if (node.end === "error") tripped.push(safeId(s));
277
+ if (node.end === true) shipped.push(safeId(s));
278
+ }
279
+ if (tripped.length > 0) {
280
+ lines.push(
281
+ ` classDef ${TRIPPED_CLASS} stroke-dasharray:4 4`,
282
+ ` class ${tripped.join(",")} ${TRIPPED_CLASS}`
283
+ );
284
+ }
285
+ if (shipped.length > 0) {
286
+ lines.push(
287
+ ` classDef ${SHIPPED_CLASS} stroke-width:2px`,
288
+ ` class ${shipped.join(",")} ${SHIPPED_CLASS}`
289
+ );
290
+ }
291
+ }
292
+ if (opts.highlight !== void 0 && flat.has(opts.highlight)) {
293
+ const lit = flat.get(opts.highlight)?.node;
294
+ const died = opts.polarity === true && lit?.end === "error";
295
+ const cls = died ? ACTIVE_ERROR_CLASS : ACTIVE_CLASS;
296
+ const paint = died ? "#f85149" : "#2f81f7";
297
+ lines.push(
298
+ ` classDef ${cls} fill:${paint},stroke:${paint},color:#fff,font-weight:bold`,
299
+ ` class ${safeId(opts.highlight)} ${cls}`
300
+ );
301
+ }
302
+ return lines.join("\n");
303
+ }
304
+
305
+ export { CellTargetError, chartMermaid, compile, compileReducer, compileTable, edgeKey, initFrom, initialStateOf, reducerInitFrom, reducerMermaid };
306
+ //# sourceMappingURL=ch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jC,IAAA,KAAA,CAAM,IAAA;AAAA,MACJ,CAAA,WAAA,EAAc,GAAG,CAAA,MAAA,EAAS,KAAK,WAAW,KAAK,CAAA,4BAAA,CAAA;AAAA,MAC/C,WAAW,MAAA,CAAO,IAAA,CAAK,SAAS,CAAC,IAAI,GAAG,CAAA;AAAA,KAC1C;AAAA,EACF;AACA,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAAA;AACxB","file":"chunk-E6GEDSF4.js","sourcesContent":["// ═══════════════════════════════════════════════════════════════════════════\n// RUNTIME — the chart walk that emits a real `Transitions<S, M, C>`.\n// ═══════════════════════════════════════════════════════════════════════════\nimport { safeId, safeLabel } from \"../machine-viz/mermaid-id\";\nimport { Cmd, NoCellError, type Reducer, type Transitions } from \"../pure/core\";\nimport type {\n Assigns,\n CellName,\n Cells,\n Chart,\n CmdOf,\n Cmds,\n GuardName,\n Guards,\n InitialData,\n InitialState,\n MsgIn,\n MsgOf,\n RAssigns,\n RCellName,\n RCells,\n RCmds,\n ReducerChart,\n RGuardName,\n RGuards,\n RStateOf,\n RUsedCmdName,\n StateOf,\n UsedCmdName,\n} from \"./graph\";\n\n/**\n * A cell returned a state OUTSIDE its edge's declared `to`.\n *\n * The escape hatch's bargain is that code may pick the target but only from the\n * set the chart admits — otherwise the drawing stops being a truthful picture\n * of the machine. For a SINGLE-site cell, and for the per-site form of a\n * multi-site one, the clamp is a compile error and this never fires. For the\n * function form of a MULTI-SITE cell it is the only enforcement there is: the\n * return of one rest signature over a union of tuples cannot be made to depend\n * on `at`, so the union of every site's `to` is the tightest static clamp\n * available and this closes the difference at the moment it is violated.\n *\n * It sits inside `buildCell`, so BOTH chart forms — the grid and the reducer —\n * get the same net from the same three lines.\n */\nexport class CellTargetError extends Error {\n override readonly name = \"CellTargetError\";\n readonly _tag = \"CellTargetError\" as const;\n constructor(\n public readonly at: string,\n public readonly cell: string,\n public readonly returned: string,\n public readonly declared: readonly string[],\n ) {\n super(\n `@demlik/tea: cell \"${cell}\" at edge \"${at}\" returned state ` +\n `\"${returned}\", which is not among that edge's declared targets ` +\n `[${declared.map((t) => `\"${t}\"`).join(\", \")}] — either the cell is ` +\n `wrong, or the edge's \\`to\\` is missing a target the code can reach ` +\n `(in which case add it, so the chart still draws the whole fan-out).`,\n );\n }\n}\n\n/** `undefined` → none; `\"x\"` → one; `[\"x\",\"y\"]` → both, in order. */\nfunction cmdNames(\n ref: string | readonly string[] | undefined,\n): readonly string[] {\n if (ref === undefined) return [];\n return typeof ref === \"string\" ? [ref] : ref;\n}\n\n// There is no `unhandled` policy any more. A pair is DECLARED (an edge), or\n// REFUSED — by the event's `scope`, or by this state's `ignore`, or by\n// `end: true` — and `Total<C>` refuses to compile on any third case. The\n// refusal is a self-loop with no cmds; the throw below is the safety net under\n// the compile-time refusal (`.decisions/0011`), reached only when the mapped\n// types were bypassed with a cast.\nexport type Parts<C, S extends { type: string }, M extends { type: string }> = {\n readonly assign: Assigns<C, S, M>;\n} & ([GuardName<C>] extends [never]\n ? { readonly guards?: undefined }\n : { readonly guards: Guards<C, S, M> }) &\n ([UsedCmdName<C>] extends [never]\n ? { readonly cmds?: undefined }\n : { readonly cmds: Cmds<C, S, M> }) &\n // the escape hatch's bag — demanded exactly when an edge names a cell.\n ([CellName<C>] extends [never]\n ? { readonly cells?: undefined }\n : { readonly cells: Cells<C, S, M> });\n\n// ── runtime views of the chart (the shapes the walk actually reads) ────────\ntype RtEdge =\n | string\n | {\n readonly target?: string;\n readonly when?: string;\n readonly otherwise?: string;\n readonly cmd?: string | readonly string[];\n readonly otherwiseCmd?: string | readonly string[];\n readonly resume?: { readonly fallback: string };\n readonly to?: readonly string[];\n readonly cell?: string;\n };\ntype RtNode = {\n readonly initial?: true;\n readonly on?: Record<string, RtEdge>;\n readonly ignore?: readonly string[];\n // BOTH polarities, because both are final and only one of them is a success.\n // The walk reads `!== undefined` (either is terminal); the drawing reads the\n // value, which is the whole reason it is not narrowed to `true` here.\n readonly end?: true | \"error\";\n};\ntype RtChart = {\n readonly events: Record<\n string,\n { readonly scope: string | readonly string[]; readonly foreign?: true }\n >;\n readonly states: Record<string, Record<string, RtNode>>;\n};\ntype RtState = { readonly type: string; readonly was?: string };\ntype RtMsg = { readonly type: string };\ntype RtCell = (s: RtState, m: RtMsg) => readonly [RtState, readonly Cmd[]];\ntype RtCellFn = (\n s: RtState,\n m: RtMsg,\n at: string,\n) => readonly [RtState, readonly Cmd[]];\n/** Either form: one body for every site, or one body PER site keyed by `at`. */\ntype RtCellImpl = RtCellFn | Record<string, RtCellFn | undefined>;\ntype RtFn = (s: RtState, m: RtMsg) => object;\ntype RtGuard = (s: RtState, m: RtMsg, at: string) => boolean;\ntype RtAssign = RtFn | { readonly then: RtFn; readonly else: RtFn };\n\n/** State name → its node and its phase, flattened out of the grouped shape. */\ntype Flat = { readonly node: RtNode; readonly group: string };\n\nfunction flatten(c: RtChart): Map<string, Flat> {\n const out = new Map<string, Flat>();\n for (const group of Object.keys(c.states)) {\n const members = c.states[group] ?? {};\n for (const s of Object.keys(members)) {\n const node = members[s];\n if (node !== undefined) out.set(s, { node, group });\n }\n }\n return out;\n}\n\nfunction scopeList(scope: string | readonly string[]): readonly string[] {\n return typeof scope === \"string\" ? [scope] : scope;\n}\n\n/** The code parts, after the type layer has been erased. Shared by both forms. */\ntype RtParts = {\n readonly assign: Record<string, RtAssign | undefined>;\n readonly guards: Record<string, RtGuard | undefined>;\n readonly cmds: Record<\n string,\n ((s: RtState, m: RtMsg, at: string) => object) | undefined\n >;\n readonly cells: Record<string, RtCellImpl | undefined>;\n};\n\nfunction rtParts(parts: object): RtParts {\n const p = parts as Record<string, object | undefined>;\n return {\n assign: (p.assign ?? {}) as RtParts[\"assign\"],\n guards: (p.guards ?? {}) as RtParts[\"guards\"],\n cmds: (p.cmds ?? {}) as RtParts[\"cmds\"],\n cells: (p.cells ?? {}) as RtParts[\"cells\"],\n };\n}\n\n/**\n * ONE edge → one transition cell. This is the whole walk, and it is shared\n * verbatim by both chart forms: a `Transitions` cell and a `Reducer` cell\n * differ only in what `at` is (`\"state.event\"` vs `\"event\"`) and in whether a\n * parking set exists to inject `was` from — both parameters here, not branches.\n *\n * `bare` is the un-namespaced event name the author's parts are written\n * against; the compiled cell restores it before calling them.\n */\nfunction buildCell(\n spec: RtEdge,\n bare: string,\n at: string,\n p: RtParts,\n parking: ReadonlySet<string>,\n): RtCell {\n const edge = typeof spec === \"string\" ? { target: spec } : spec;\n const cell = p.assign[at];\n\n // ── THE ESCAPE HATCH ────────────────────────────────────────────────────\n // A `{ to, cell }` edge is the whole transition: the cell picks the target\n // from `to` and returns its own cmds, so there is no assign to call, no\n // guard to evaluate, no cmd list to rebuild and no `was` to inject (a cell\n // landing on a parking state supplies `was` itself — its return type demands\n // it). The other fields are compile errors beside `cell`, so this branch is\n // not silently skipping anything.\n if (edge.cell !== undefined) {\n const name = edge.cell;\n const impl = p.cells[name];\n if (impl === undefined) {\n throw new Error(\n `@demlik/tea: edge \"${at}\" names cell \"${name}\" with no implementation`,\n );\n }\n // the two forms: one body for every site, or one body per site. A\n // multi-site cell may be written either way (`Cells`/`RCells` offer both);\n // a single-site one is always the plain function.\n const hand = typeof impl === \"function\" ? impl : impl[at];\n if (hand === undefined) {\n throw new Error(\n `@demlik/tea: cell \"${name}\" is written in the per-site form but has no entry for edge \"${at}\"`,\n );\n }\n const to = edge.to ?? [];\n return (st, nsMsg) => {\n const out = hand(st, { ...nsMsg, type: bare }, at);\n // the runtime half of the `to` clamp — see `CellTargetError`.\n if (!to.includes(out[0].type)) {\n throw new CellTargetError(at, name, out[0].type, to);\n }\n return out;\n };\n }\n\n // A guarded edge is resolved HERE, not at dispatch — same as `cell` above and\n // for the same reason: an unimplemented name is a wiring mistake, and a\n // wiring mistake should surface when the chart is compiled rather than on the\n // first message that happens to reach this edge.\n //\n // It is the only one of the three that ever read a missing part as a VALUE.\n // A missing cmd builder throws, a missing cell throws, and a missing guard\n // used to quietly evaluate to `false` — which is not an error, it is the\n // `otherwise` arm. On the imported door (`chart/lane`) the guard alphabet is\n // `string`, so no type ever checked the name either: a typo in an operator's\n // parts routed the whole lane down its failure arm in silence.\n const guard = edge.when === undefined ? undefined : p.guards[edge.when];\n if (edge.when !== undefined && guard === undefined) {\n throw new Error(\n `@demlik/tea: edge \"${at}\" names guard \"${edge.when}\" with no implementation`,\n );\n }\n\n return (st, nsMsg) => {\n // strip the namespace so the author's parts see the bare event.\n const msg: RtMsg = { ...nsMsg, type: bare };\n\n let target: string;\n let payloadFn: RtFn;\n let fired = true;\n\n if (edge.resume !== undefined) {\n target = st.was ?? edge.resume.fallback;\n payloadFn = cell as RtFn;\n } else if (guard !== undefined) {\n fired = guard(st, msg, at) === true;\n const branch = cell as { then: RtFn; else: RtFn };\n target = fired ? (edge.target as string) : (edge.otherwise as string);\n payloadFn = fired ? branch.then : branch.else;\n } else {\n target = edge.target as string;\n payloadFn = cell as RtFn;\n }\n\n const data = payloadFn(st, msg);\n // `was` is INJECTED, never authored: entering a parking state records where\n // you came from. The type of `was` is `ResumeTargets<C, target>`, and\n // `st.type` is in that set by construction.\n const next: RtState = parking.has(target)\n ? { ...data, type: target, was: st.type }\n : { ...data, type: target };\n\n // 0..n Cmds, in declaration order. A guarded edge picks its arm's list —\n // `Cmd.when` lifted onto the edge, so which effects fire is visible in the\n // chart rather than buried in a cell body.\n const emitted = cmdNames(fired ? edge.cmd : edge.otherwiseCmd).map(\n (n): Cmd => {\n const build = p.cmds[n];\n if (build === undefined) {\n throw new Error(\n `@demlik/tea: edge \"${at}\" names cmd \"${n}\" with no builder`,\n );\n }\n return { ...build(st, msg, at), type: n };\n },\n );\n\n return [next, emitted];\n };\n}\n\n/** `undefined` → bare; a foreign event → bare; otherwise `${ns}.${event}`. */\nfunction keyOf(\n c: {\n readonly events: Record<string, { readonly foreign?: true } | undefined>;\n },\n e: string,\n ns: string | undefined,\n): string {\n return ns === undefined || c.events[e]?.foreign === true ? e : `${ns}.${e}`;\n}\n\nconst NO_PARKING: ReadonlySet<string> = new Set<string>();\n\n/**\n * One compiled table, BEFORE the typed boundary — `state.type` → the event key\n * → the cell.\n *\n * The shape `compile` builds and then declares as a `Transitions<S, M, C>`. It\n * is named because a second caller needs the walk without the declaration:\n * `chart/lane/run` compiles ONE region per task and the tables it holds are\n * keyed by task id, so the per-region `Transitions` type is never the type of\n * anything it stores.\n */\nexport type CompiledTable = Readonly<\n Record<string, Readonly<Record<string, RtCell | undefined>> | undefined>\n>;\n\n/**\n * THE WALK, with no type layer over it — `compile`'s body, callable by a second\n * compiler that has already done its own type checking.\n *\n * `chart`/`parts` are `object` rather than the F-bounded `Chart<C>`/`Parts<…>`\n * because this entry is not where the checking happens; it is where the\n * checking has ALREADY happened. The erasing cast lives here, exactly once, at\n * the top of the walk — which is where it lived before this function had a\n * name, so nothing gained a cast by being reachable from two places.\n */\nexport function compileTable(\n chart: object,\n parts: object,\n ns: string | undefined,\n): CompiledTable {\n const c = chart as unknown as RtChart;\n const p = rtParts(parts);\n\n const flat = flatten(c);\n const events = Object.keys(c.events);\n const parking = new Set<string>();\n for (const [s, { node }] of flat) {\n for (const spec of Object.values(node.on ?? {})) {\n if (typeof spec === \"object\" && spec.resume !== undefined) parking.add(s);\n }\n }\n\n const table: Record<string, Record<string, RtCell>> = {};\n\n for (const [s, { node, group }] of flat) {\n const row: Record<string, RtCell> = {};\n const on = node.on ?? {};\n\n for (const e of events) {\n // the one runtime consequence of per-event namespacing.\n const key = keyOf(c, e, ns);\n const spec = on[e];\n\n if (spec === undefined) {\n // the mirror of `MissingAt<C, S>`: live-but-undecided is the only case\n // the type layer forbids, so it is the only case that throws.\n const scope = scopeList(c.events[e]?.scope ?? \"edges\");\n const live = scope.includes(\"all\") || scope.includes(group);\n // `end` is `true` (success) or `\"error\"`; BOTH are final, and the type\n // layer's `IsEndOf` reads both. Testing `=== true` here would put an\n // error final back under the totality obligation at runtime only.\n const refused =\n node.end !== undefined || !live || (node.ignore ?? []).includes(e);\n row[key] = refused\n ? (st) => [st, []]\n : () => {\n throw new NoCellError(key, s);\n };\n continue;\n }\n\n // the site tag, passed to guards/cmds/cells as their last argument — it is\n // what lets a multi-site helper discriminate (see `SiteArgs` in graph.ts).\n row[key] = buildCell(spec, e, `${s}.${e}`, p, parking);\n }\n table[s] = row;\n }\n\n return table;\n}\n\n/**\n * Compile a chart + the code parts into a genuine `Transitions<S, M, C>`.\n *\n * `ns` is OPTIONAL and PER-EVENT. Omitted, nothing is decorated and the table\n * is keyed by the bare event names — a single-instance machine carries no\n * namespace and passes no dummy string. Given, the author's own events are\n * keyed `${ns}.${event}` (so N instances share one dispatch surface with\n * genuinely disjoint literal unions), while every event the chart marks\n * `foreign: true` keeps its BARE name: a library-minted Msg like\n * `deadline_exceeded` is the same event for every instance, and its name was\n * never the author's to rename.\n *\n * The returned type is `Transitions<S, MsgIn<C, NS>, K>` — literal keys, never\n * `string`. The parts are authored against the BARE msg union; the compiled\n * cell restores the bare event name before calling them.\n *\n * `S`/`M`/`K` DEFAULT to the chart's own derivations, so the common call is\n * `compile(chart, parts)` with no type arguments at all.\n */\nexport function compile<\n const C extends Chart<C>,\n S extends { type: string } = StateOf<C>,\n M extends { type: string } = MsgOf<C>,\n K extends Cmd = CmdOf<C>,\n const NS extends string | undefined = undefined,\n>(chart: C, parts: Parts<C, S, M>, ns?: NS): Transitions<S, MsgIn<C, NS>, K> {\n // ── THE ONE CAST ────────────────────────────────────────────────────────\n // Inside the library, at the construction boundary. `Transitions` is a\n // mapped type over `S[\"type\"] × M[\"type\"]`; the walk builds the same keys\n // from the flattened chart × the per-event keys, but tsc cannot see that a\n // string-keyed record built in a loop is total over those unions.\n return compileTable(chart, parts, ns) as unknown as Transitions<\n S,\n MsgIn<C, NS>,\n K\n >;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// REDUCER FORM — the same walk, one loop shallower.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * The reducer form's parts bag. Structurally identical to `Parts`, over the\n * reducer chart's derivations — `assign` is total over the DECLARATIVE events\n * (a cell event owes none), and each of `guards`/`cmds`/`cells` is demanded\n * exactly when the chart names one.\n */\nexport type RParts<\n C,\n S extends { type: string },\n M extends { type: string },\n> = {\n readonly assign: RAssigns<C, S, M>;\n} & ([RGuardName<C>] extends [never]\n ? { readonly guards?: undefined }\n : { readonly guards: RGuards<C, S, M> }) &\n ([RUsedCmdName<C>] extends [never]\n ? { readonly cmds?: undefined }\n : { readonly cmds: RCmds<C, S, M> }) &\n ([RCellName<C>] extends [never]\n ? { readonly cells?: undefined }\n : { readonly cells: RCells<C, S, M> });\n\ntype RtReducerChart = {\n readonly events: Record<string, { readonly foreign?: true }>;\n readonly initial: string;\n readonly on: Record<string, RtEdge>;\n};\n\n/**\n * Compile a reducer-form chart into a genuine `Reducer<S, M, K>` — the flat,\n * msg-keyed `update` shape `defineMachine` already accepts (`src/pure/core.ts`).\n *\n * There is no `NoCellError` branch and no refusal branch here, and that is not\n * an omission: `on` is a TOTAL mapped type over the event alphabet, so an\n * undeclared event cannot exist to be missing. The safety the grid form buys\n * with `scope` + `ignore` + `Total<C>`, this form gets from the mapped type.\n *\n * `ns` behaves exactly as in `compile`: per-event, optional, and never applied\n * to an event the chart marks `foreign`.\n */\nexport function compileReducer<\n const C extends ReducerChart<C>,\n S extends { type: string } = RStateOf<C>,\n M extends { type: string } = MsgOf<C>,\n K extends Cmd = CmdOf<C>,\n const NS extends string | undefined = undefined,\n>(chart: C, parts: RParts<C, S, M>, ns?: NS): Reducer<S, MsgIn<C, NS>, K> {\n const c = chart as unknown as RtReducerChart;\n const p = rtParts(parts);\n const out: Record<string, RtCell> = {};\n\n for (const e of Object.keys(c.events)) {\n const spec = c.on[e];\n if (spec === undefined) {\n // unreachable through the typed door — `on` is total over `events`. The\n // safety net under the compile-time obligation, as `NoCellError` is\n // under `Total<C>`.\n throw new Error(`@demlik/tea: reducer chart declares no edge for \"${e}\"`);\n }\n // the site tag IS the event: one dimension, so `SiteArgs`'s `at` is the\n // bare name and a multi-site cell discriminates on it exactly as before.\n out[keyOf(c, e, ns)] = buildCell(spec, e, e, p, NO_PARKING);\n }\n\n // The same one cast, for the same reason: a string-keyed record built in a\n // loop is total over `M[\"type\"]`, and tsc cannot see it.\n return out as unknown as Reducer<S, MsgIn<C, NS>, K>;\n}\n\n/**\n * `init` for a reducer chart. The entry state is the chart's `initial` field —\n * one word, still never repeated by the author — and `boot()` supplies `ctx`,\n * which for this form IS the whole state minus its tag.\n */\nexport function reducerInitFrom<\n const C extends ReducerChart<C>,\n S extends { type: string } = RStateOf<C>,\n K extends Cmd = CmdOf<C>,\n>(\n chart: C,\n boot: () => Omit<RStateOf<C>, \"type\">,\n): (loaded: S | null) => readonly [S, readonly K[]] {\n const type: string = (chart as unknown as RtReducerChart).initial;\n return (loaded) => [\n loaded ?? ({ ...boot(), type } as unknown as S),\n Cmd.none,\n ];\n}\n\n/**\n * The reducer chart, drawn. There is no per-state routing to show, so the\n * honest picture is one `any` node — every edge is reachable from every state,\n * which is what having no phase dimension MEANS — plus each event's full\n * fan-out, cell edges included.\n */\nexport function reducerMermaid<const C extends ReducerChart<C>>(\n chart: C,\n): string {\n const c = chart as unknown as RtReducerChart;\n const lines = [\n \"stateDiagram-v2\",\n \" direction TB\",\n ` [*] --> ${safeId(c.initial)}`,\n ];\n // The SAME edge grammar `chartMermaid` draws — see {@link edgeLines}. The one\n // difference this form has is `from`, which is `any` at every edge, because\n // having no phase dimension MEANS every edge is reachable from every state.\n for (const [e, spec] of Object.entries(c.on)) {\n lines.push(...edgeLines(\"any\", \"any\", e, spec, NO_MARKS));\n }\n return lines.join(\"\\n\");\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// `init`, DERIVED FROM THE CHART\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * The name of the state marked `initial: true`. Throws unless EXACTLY one is\n * marked — the runtime half of what `InitialData`'s marker types say at the\n * type level.\n */\nexport function initialStateOf<const C extends Chart<C>>(\n chart: C,\n): InitialState<C> {\n const flat = flatten(chart as unknown as RtChart);\n const marked = [...flat].filter(([, f]) => f.node.initial === true);\n const only = marked[0];\n if (marked.length !== 1 || only === undefined) {\n throw new Error(\n `@demlik/tea: chart must mark exactly one state \\`initial: true\\` (found ${marked.length})`,\n );\n }\n // `Object.keys` yields `string`; the type-level answer is the same key.\n return only[0] as InitialState<C>;\n}\n\n/**\n * Build a `Machine[\"init\"]` from the chart's declared entry state plus a\n * `boot()` that supplies ONLY that state's data. The state NAME is never\n * repeated by the author — it comes from the same `initial: true` that\n * `machine-viz` reads to draw the `[*] -->` edge.\n *\n * Rehydrate is honoured verbatim: a non-null `loaded` is returned untouched\n * with NO cmds, which is exactly Invariant 2's contract.\n */\nexport function initFrom<\n const C extends Chart<C>,\n S extends { type: string },\n K extends Cmd,\n>(\n chart: C,\n boot: () => InitialData<C, S>,\n): (loaded: S | null) => readonly [S, readonly K[]] {\n const type: string = initialStateOf(chart);\n return (loaded) => [\n // The one cast this helper needs: `{ ...InitialData, type: <the initial\n // name> }` IS `Extract<S, { type: InitialState<C> }>`, but tsc cannot\n // rebuild a union member from a spread plus a `string`-typed discriminant.\n loaded ?? ({ ...boot(), type } as unknown as S),\n Cmd.none,\n ];\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// DRAWING THE CHART — every declared edge, including a cell edge's fan-out.\n//\n// `machine-viz`'s `toMermaid` works on a COMPILED machine and resolves a cell\n// by executing it against a sample, so it draws the ONE edge that sample takes\n// — true of a guarded edge before the escape hatch existed, and equally true\n// of a `{ to, cell }` edge now. The chart, though, still knows every possible\n// target, which is the whole point of declaring `to`. This reads the chart\n// directly and draws the full fan-out, no samples and no execution needed.\n//\n// THIS IS THE ONLY CHART RENDERER. `chart/report/draw.ts` used to carry a\n// second one, written in parallel against the same mermaid grammar while this\n// one was growing its options bag; the two diverged before the swap its banner\n// promised ever happened (a guarded then-arm drawn bare here and labelled\n// there, two spellings of the highlight class, sanitizing on one side only).\n// How a chart is drawn is ONE fact, so there is one body and the report enters\n// it through `drawTask`, which is now nothing but a translation of its option\n// names into these.\n//\n// WHAT MERMAID CAN AND CANNOT DO, stated so `walked` is judged fairly:\n// `stateDiagram-v2` supports `classDef`/`class`, so LIGHTING A NODE is real\n// styling. It supports no per-edge styling at all — there is no `linkStyle` for\n// a state diagram — so a walked edge is marked ON ITS LABEL (`»`, plus the\n// visit count) rather than thickened. Still true as of mermaid 11.\n// ═══════════════════════════════════════════════════════════════════════════\n\n/** How many times each {@link edgeKey} was walked. */\nexport type WalkCounts = ReadonlyMap<string, number>;\n\n/**\n * The key a {@link ChartMermaidOptions.walked} map is read by.\n *\n * One spelling, shared by whoever counts the walk and the drawing that marks\n * it — the names are the chart's OWN, unsanitized, because the counter reads\n * them off a log and has no business knowing what mermaid can spell.\n *\n * NOT `EdgeKey<C>` (`graph.ts`), despite the casing. That one is the SITE tag\n * — `\"state.event\"` — which is what a guard or a cmd builder is keyed by,\n * because a site is where code hangs. This one names a drawn ARROW, and a\n * guarded site draws two of them, so it needs the target as well.\n */\nexport const edgeKey = (from: string, event: string, to: string): string =>\n `${from}|${event}|${to}`;\n\n/**\n * Options for {@link chartMermaid}. Every field is optional and every default\n * reproduces the drawing this function emitted before options existed — a flat\n * node set, `direction TB`, no title, no highlight, no polarity and no walk —\n * so an existing caller is untouched.\n *\n * Shaped after `MachineVizOptions` (`../machine-viz`) where the two overlap\n * (`direction`, `title`), because the two drawings are read side by side and a\n * second spelling of the same knob is a fact said twice. What is NOT shared is\n * `samples`: `toMermaid` needs them because it must EXECUTE a compiled cell to\n * learn a target; the chart declares its targets, so there is nothing to\n * resolve and nothing to sample.\n */\nexport interface ChartMermaidOptions {\n /**\n * Draw this state as the ACTIVE node — a `classDef`/`class` pair Mermaid\n * renders with the highlight fill. Pass the live `state.type`. A name that is\n * not in the chart is ignored rather than drawn as a phantom node.\n */\n readonly highlight?: string;\n /**\n * Draw each phase as a Mermaid COMPOSITE state (`state working { … }`).\n *\n * The chart groups its states into named phases and the flat drawing throws\n * that away — which is the one structural fact `chartMermaid` knew and did\n * not show. Off by default: turning it on changes the emitted text, and the\n * drawing is something a reviewer approves rather than something that moves\n * under them.\n */\n readonly phases?: boolean;\n /**\n * Draw the two ENDINGS differently — a dashed outline on every `end:\n * \"error\"` final, a heavier one on every `end: true`.\n *\n * A success final and an error final both terminate, so both draw the `[*]`\n * edge, and a picture that stopped there paints `shipped` and `frozen` alike\n * in the one place a reader looks first. Off by default for the same reason\n * `phases` is: it changes the emitted text.\n */\n readonly polarity?: boolean;\n /**\n * Edges the caller actually WALKED, keyed by {@link edgeKey} — each drawn\n * edge that has a count picks up a `»` (or `»×N`) on its label.\n *\n * A missing or zero count marks nothing, so a chart nobody has run through\n * draws exactly as it does without this option.\n */\n readonly walked?: WalkCounts;\n /** Mermaid layout direction. Default `\"TB\"`. */\n readonly direction?: \"TB\" | \"LR\";\n /** Optional title, emitted as a Mermaid front-matter `title:` block. */\n readonly title?: string;\n}\n\n/** The CSS class Mermaid applies to the highlighted node. */\nconst ACTIVE_CLASS = \"teaActive\";\n/** The highlighted node when it is where a task DIED — see `chartMermaid`. */\nconst ACTIVE_ERROR_CLASS = \"teaActiveError\";\n/** …and to the two endings, when `polarity` asks for them. */\nconst TRIPPED_CLASS = \"teaTripped\";\nconst SHIPPED_CLASS = \"teaShipped\";\n\n/**\n * A node's declaration line, or `undefined` when the sanitized id already IS\n * the name and the bare id carries the whole fact. Emitting the label only for\n * a renamed node is what keeps the default drawing byte-identical for charts\n * whose names were already Mermaid-safe.\n */\nfunction nodeDecl(raw: string, indent: string): string | undefined {\n const id = safeId(raw);\n return id === raw ? undefined : `${indent}${id} : ${safeLabel(raw)}`;\n}\n\n/**\n * ONE edge, as the arrows that draw it — the whole edge grammar, in one place.\n *\n * Both drawings in this file come through here: the grid form draws it from\n * each state, the reducer form from the single `any` node, and the two forms\n * differ in what `from` is and in nothing else. That is not tidiness — the\n * guarded arm's labelling was wrong in both of them, in the same way, and one\n * of them was fixed once already without the other moving.\n *\n * `at` is the UNSANITIZED source-state name the walk counter keyed by; `from`\n * is what mermaid will read.\n */\nfunction edgeLines(\n from: string,\n at: string,\n e: string,\n spec: RtEdge,\n mark: (from: string, event: string, to: string) => string,\n): readonly string[] {\n const edge = typeof spec === \"string\" ? { target: spec } : spec;\n const out: string[] = [];\n // ONE arrow-writer for every edge form, so the walk mark cannot be\n // remembered on three of the four and forgotten on the fourth.\n const arrow = (to: string, label: string): void => {\n out.push(\n ` ${from} --> ${safeId(to)} : ${safeLabel(`${label}${mark(at, e, to)}`)}`,\n );\n };\n if (edge.cell !== undefined) {\n // one real edge per DECLARED target — the fan-out, labelled with the cell\n // that picks among them.\n for (const t of edge.to ?? []) arrow(t, `${e} / ${edge.cell}()`);\n return out;\n }\n if (edge.resume !== undefined) {\n arrow(edge.resume.fallback, `${e} (resume)`);\n return out;\n }\n // A GUARDED edge labels BOTH arms. Drawing the then-arm bare — `review -->\n // build : FAIL` beside `review --> frozen : FAIL [!retriesRemaining]` —\n // reads as an unconditional edge racing a conditional one, which is not what\n // the chart says: the then-arm is exactly as conditional as the else-arm,\n // and the reader is left to infer its guard from a sibling arrow.\n const guard = edge.when === undefined ? \"\" : ` [${edge.when}]`;\n if (edge.target !== undefined) arrow(edge.target, `${e}${guard}`);\n if (edge.otherwise !== undefined)\n arrow(edge.otherwise, `${e} [!${edge.when ?? \"\"}]`);\n return out;\n}\n\n/** No walk to mark — the drawings that take no `walked` map. */\nconst NO_MARKS = (): string => \"\";\n\nexport function chartMermaid<const C extends Chart<C>>(\n chart: C,\n opts: ChartMermaidOptions = {},\n): string {\n const c = chart as unknown as RtChart;\n const flat = flatten(c);\n const lines: string[] = [];\n if (opts.title !== undefined)\n lines.push(\"---\", `title: ${opts.title}`, \"---\");\n lines.push(\"stateDiagram-v2\", ` direction ${opts.direction ?? \"TB\"}`);\n\n // The walk mark, keyed by the chart's OWN names — `walked` is counted off a\n // log, so it never saw a sanitized id.\n const walked = opts.walked;\n const mark = (from: string, event: string, to: string): string => {\n const n = walked?.get(edgeKey(from, event, to)) ?? 0;\n return n === 0 ? \"\" : n === 1 ? \" »\" : ` »×${n}`;\n };\n\n // Phases, as composite states. Declared BEFORE the edges so every node is\n // already inside its phase by the time an arrow references it — Mermaid\n // otherwise hoists the first mention to the top level.\n if (opts.phases === true) {\n for (const [group, members] of Object.entries(c.states)) {\n lines.push(` state ${safeId(group)} {`);\n for (const s of Object.keys(members)) {\n lines.push(nodeDecl(s, \" \") ?? ` ${safeId(s)}`);\n }\n lines.push(\" }\");\n }\n }\n\n for (const [s, { node }] of flat) {\n const from = safeId(s);\n // A renamed node needs its human name shown once. In `phases` mode the\n // declaration already went inside the composite block.\n if (opts.phases !== true) {\n const decl = nodeDecl(s, \" \");\n if (decl !== undefined) lines.push(decl);\n }\n if (node.initial === true) lines.push(` [*] --> ${from}`);\n for (const [e, spec] of Object.entries(node.on ?? {})) {\n lines.push(...edgeLines(from, s, e, spec, mark));\n }\n // Both polarities terminate, so both draw the `[*]` edge — an error final\n // that stopped drawing one would read as a state the machine can leave.\n if (node.end !== undefined) lines.push(` ${from} --> [*]`);\n }\n\n // The classes, last: a `classDef` must exist before the `class` line that\n // uses it, and both must sit outside any composite block. Each pair is\n // emitted only when something wears it, so an unused `classDef` never lands.\n if (opts.polarity === true) {\n const tripped: string[] = [];\n const shipped: string[] = [];\n for (const [s, { node }] of flat) {\n if (node.end === \"error\") tripped.push(safeId(s));\n if (node.end === true) shipped.push(safeId(s));\n }\n if (tripped.length > 0) {\n lines.push(\n ` classDef ${TRIPPED_CLASS} stroke-dasharray:4 4`,\n ` class ${tripped.join(\",\")} ${TRIPPED_CLASS}`,\n );\n }\n if (shipped.length > 0) {\n lines.push(\n ` classDef ${SHIPPED_CLASS} stroke-width:2px`,\n ` class ${shipped.join(\",\")} ${SHIPPED_CLASS}`,\n );\n }\n }\n if (opts.highlight !== undefined && flat.has(opts.highlight)) {\n // The lit node carries POLARITY too, when polarity is on. `polarity` draws\n // the two endings apart by STROKE and the highlight then painted a fill\n // over the top, so an error final and a success final were the same picture\n // at the exact moment one of them is where a task DIED. Every other surface\n // — the chip, the badge, the stuck panel — says which; the drawing is the\n // thing a reader looks at first and it was the one saying nothing.\n const lit = flat.get(opts.highlight)?.node;\n const died = opts.polarity === true && lit?.end === \"error\";\n const cls = died ? ACTIVE_ERROR_CLASS : ACTIVE_CLASS;\n const paint = died ? \"#f85149\" : \"#2f81f7\";\n lines.push(\n ` classDef ${cls} fill:${paint},stroke:${paint},color:#fff,font-weight:bold`,\n ` class ${safeId(opts.highlight)} ${cls}`,\n );\n }\n return lines.join(\"\\n\");\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { MsgType } from './chunk-JELSZN25.js';
2
- import { deadlineSub } from './chunk-ASX7PL2K.js';
2
+ import { deadlineSub } from './chunk-JGVL3WPL.js';
3
3
  import { asRng, recordFailure, shouldRetry, nextDelayMs, initRetry } from './chunk-Q2UM7BXU.js';
4
4
  import { initBucket, tryConsume } from './chunk-S2EGRPCM.js';
5
5
  import { initCircuit, onSuccess, onFailure, canPass } from './chunk-UF4MZSLT.js';
6
- import { initCache, set, get } from './chunk-WF46FABO.js';
7
- import { tryInterpret } from './chunk-ZH454CR5.js';
8
- import { without } from './chunk-O7ED34JH.js';
6
+ import { initCache, set, get } from './chunk-7SVIRMC6.js';
7
+ import { tryInterpret } from './chunk-5EHLEUTL.js';
8
+ import { without } from './chunk-B5VXOFMZ.js';
9
9
 
10
10
  // src/resilient-call/index.ts
11
11
  function circuitPolicy(config) {
@@ -219,5 +219,5 @@ function liftResilience(state, [slice, cmds]) {
219
219
  }
220
220
 
221
221
  export { createResilientCall, liftResilience };
222
- //# sourceMappingURL=chunk-EC6FO42Q.js.map
223
- //# sourceMappingURL=chunk-EC6FO42Q.js.map
222
+ //# sourceMappingURL=chunk-EUF7XOEE.js.map
223
+ //# sourceMappingURL=chunk-EUF7XOEE.js.map