@rotorsoft/act-diagram 0.4.0 → 1.0.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 (60) hide show
  1. package/README.md +110 -171
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/cli/colors.d.ts +1 -1
  4. package/dist/@types/cli/colors.d.ts.map +1 -1
  5. package/dist/@types/cli/contract-index.d.ts +6 -6
  6. package/dist/@types/cli/contract-index.d.ts.map +1 -1
  7. package/dist/@types/cli/format.d.ts +9 -9
  8. package/dist/@types/cli/format.d.ts.map +1 -1
  9. package/dist/@types/cli/index.d.ts +9 -9
  10. package/dist/@types/cli/index.d.ts.map +1 -1
  11. package/dist/@types/cli/json-schema.d.ts +1 -1
  12. package/dist/@types/cli/json-schema.d.ts.map +1 -1
  13. package/dist/@types/cli/load-project.d.ts +3 -3
  14. package/dist/@types/cli/load-project.d.ts.map +1 -1
  15. package/dist/@types/cli/markdown.d.ts +1 -1
  16. package/dist/@types/cli/markdown.d.ts.map +1 -1
  17. package/dist/@types/cli/open-editor.d.ts +4 -4
  18. package/dist/@types/cli/open-editor.d.ts.map +1 -1
  19. package/dist/@types/cli/repl.d.ts +1 -1
  20. package/dist/@types/cli/repl.d.ts.map +1 -1
  21. package/dist/@types/cli/vim-keys.d.ts +1 -1
  22. package/dist/@types/cli/vim-keys.d.ts.map +1 -1
  23. package/dist/@types/client/components/ActDiagram.d.ts +1 -1
  24. package/dist/@types/client/components/ActDiagram.d.ts.map +1 -1
  25. package/dist/@types/client/components/AiBar.d.ts +1 -1
  26. package/dist/@types/client/components/AiBar.d.ts.map +1 -1
  27. package/dist/@types/client/components/CodePreview.d.ts +2 -2
  28. package/dist/@types/client/components/CodePreview.d.ts.map +1 -1
  29. package/dist/@types/client/components/Diagram.d.ts +1 -1
  30. package/dist/@types/client/components/Diagram.d.ts.map +1 -1
  31. package/dist/@types/client/components/Logo.d.ts +1 -1
  32. package/dist/@types/client/components/Logo.d.ts.map +1 -1
  33. package/dist/@types/client/components/Tooltip.d.ts +1 -1
  34. package/dist/@types/client/components/Tooltip.d.ts.map +1 -1
  35. package/dist/@types/client/lib/build-model.d.ts +2 -2
  36. package/dist/@types/client/lib/build-model.d.ts.map +1 -1
  37. package/dist/@types/client/lib/evaluate.d.ts +2 -2
  38. package/dist/@types/client/lib/evaluate.d.ts.map +1 -1
  39. package/dist/@types/client/lib/layout.d.ts +1 -1
  40. package/dist/@types/client/lib/layout.d.ts.map +1 -1
  41. package/dist/@types/client/lib/mock-builders.d.ts +6 -6
  42. package/dist/@types/client/lib/mock-builders.d.ts.map +1 -1
  43. package/dist/@types/client/lib/navigate.d.ts +1 -1
  44. package/dist/@types/client/lib/navigate.d.ts.map +1 -1
  45. package/dist/@types/client/lib/schema-extract.d.ts +4 -4
  46. package/dist/@types/client/lib/schema-extract.d.ts.map +1 -1
  47. package/dist/@types/client/lib/sort.d.ts +1 -1
  48. package/dist/@types/client/lib/sort.d.ts.map +1 -1
  49. package/dist/@types/client/lib/strip-fences.d.ts +3 -3
  50. package/dist/@types/client/lib/strip-fences.d.ts.map +1 -1
  51. package/dist/@types/index.d.ts +0 -6
  52. package/dist/@types/index.d.ts.map +1 -1
  53. package/dist/cli/act.js +1515 -1310
  54. package/dist/cli/act.js.map +1 -1
  55. package/dist/index.cjs +640 -704
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.js +640 -696
  58. package/dist/index.js.map +1 -1
  59. package/dist/styles.css +1 -1
  60. package/package.json +12 -12
package/dist/cli/act.js CHANGED
@@ -30,68 +30,68 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  var require_picocolors = __commonJS({
31
31
  "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
32
32
  "use strict";
33
- var p2 = process || {};
34
- var argv = p2.argv || [];
35
- var env = p2.env || {};
36
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
33
+ var p = process || {};
34
+ var argv = p.argv || [];
35
+ var env = p.env || {};
36
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
37
37
  var formatter = (open, close, replace = open) => (input) => {
38
38
  let string = "" + input, index = string.indexOf(close, open.length);
39
39
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
40
40
  };
41
41
  var replaceClose = (string, close, replace, index) => {
42
- let result = "", cursor = 0;
42
+ let result = "", cursor3 = 0;
43
43
  do {
44
- result += string.substring(cursor, index) + replace;
45
- cursor = index + close.length;
46
- index = string.indexOf(close, cursor);
44
+ result += string.substring(cursor3, index) + replace;
45
+ cursor3 = index + close.length;
46
+ index = string.indexOf(close, cursor3);
47
47
  } while (~index);
48
- return result + string.substring(cursor);
48
+ return result + string.substring(cursor3);
49
49
  };
50
50
  var createColors = (enabled = isColorSupported) => {
51
- let f2 = enabled ? formatter : () => String;
51
+ let f = enabled ? formatter : () => String;
52
52
  return {
53
53
  isColorSupported: enabled,
54
- reset: f2("\x1B[0m", "\x1B[0m"),
55
- bold: f2("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
56
- dim: f2("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
57
- italic: f2("\x1B[3m", "\x1B[23m"),
58
- underline: f2("\x1B[4m", "\x1B[24m"),
59
- inverse: f2("\x1B[7m", "\x1B[27m"),
60
- hidden: f2("\x1B[8m", "\x1B[28m"),
61
- strikethrough: f2("\x1B[9m", "\x1B[29m"),
62
- black: f2("\x1B[30m", "\x1B[39m"),
63
- red: f2("\x1B[31m", "\x1B[39m"),
64
- green: f2("\x1B[32m", "\x1B[39m"),
65
- yellow: f2("\x1B[33m", "\x1B[39m"),
66
- blue: f2("\x1B[34m", "\x1B[39m"),
67
- magenta: f2("\x1B[35m", "\x1B[39m"),
68
- cyan: f2("\x1B[36m", "\x1B[39m"),
69
- white: f2("\x1B[37m", "\x1B[39m"),
70
- gray: f2("\x1B[90m", "\x1B[39m"),
71
- bgBlack: f2("\x1B[40m", "\x1B[49m"),
72
- bgRed: f2("\x1B[41m", "\x1B[49m"),
73
- bgGreen: f2("\x1B[42m", "\x1B[49m"),
74
- bgYellow: f2("\x1B[43m", "\x1B[49m"),
75
- bgBlue: f2("\x1B[44m", "\x1B[49m"),
76
- bgMagenta: f2("\x1B[45m", "\x1B[49m"),
77
- bgCyan: f2("\x1B[46m", "\x1B[49m"),
78
- bgWhite: f2("\x1B[47m", "\x1B[49m"),
79
- blackBright: f2("\x1B[90m", "\x1B[39m"),
80
- redBright: f2("\x1B[91m", "\x1B[39m"),
81
- greenBright: f2("\x1B[92m", "\x1B[39m"),
82
- yellowBright: f2("\x1B[93m", "\x1B[39m"),
83
- blueBright: f2("\x1B[94m", "\x1B[39m"),
84
- magentaBright: f2("\x1B[95m", "\x1B[39m"),
85
- cyanBright: f2("\x1B[96m", "\x1B[39m"),
86
- whiteBright: f2("\x1B[97m", "\x1B[39m"),
87
- bgBlackBright: f2("\x1B[100m", "\x1B[49m"),
88
- bgRedBright: f2("\x1B[101m", "\x1B[49m"),
89
- bgGreenBright: f2("\x1B[102m", "\x1B[49m"),
90
- bgYellowBright: f2("\x1B[103m", "\x1B[49m"),
91
- bgBlueBright: f2("\x1B[104m", "\x1B[49m"),
92
- bgMagentaBright: f2("\x1B[105m", "\x1B[49m"),
93
- bgCyanBright: f2("\x1B[106m", "\x1B[49m"),
94
- bgWhiteBright: f2("\x1B[107m", "\x1B[49m")
54
+ reset: f("\x1B[0m", "\x1B[0m"),
55
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
56
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
57
+ italic: f("\x1B[3m", "\x1B[23m"),
58
+ underline: f("\x1B[4m", "\x1B[24m"),
59
+ inverse: f("\x1B[7m", "\x1B[27m"),
60
+ hidden: f("\x1B[8m", "\x1B[28m"),
61
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
62
+ black: f("\x1B[30m", "\x1B[39m"),
63
+ red: f("\x1B[31m", "\x1B[39m"),
64
+ green: f("\x1B[32m", "\x1B[39m"),
65
+ yellow: f("\x1B[33m", "\x1B[39m"),
66
+ blue: f("\x1B[34m", "\x1B[39m"),
67
+ magenta: f("\x1B[35m", "\x1B[39m"),
68
+ cyan: f("\x1B[36m", "\x1B[39m"),
69
+ white: f("\x1B[37m", "\x1B[39m"),
70
+ gray: f("\x1B[90m", "\x1B[39m"),
71
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
72
+ bgRed: f("\x1B[41m", "\x1B[49m"),
73
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
74
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
75
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
76
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
77
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
78
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
79
+ blackBright: f("\x1B[90m", "\x1B[39m"),
80
+ redBright: f("\x1B[91m", "\x1B[39m"),
81
+ greenBright: f("\x1B[92m", "\x1B[39m"),
82
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
83
+ blueBright: f("\x1B[94m", "\x1B[39m"),
84
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
85
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
86
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
87
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
88
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
89
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
90
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
91
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
92
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
93
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
94
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
95
95
  };
96
96
  };
97
97
  module.exports = createColors();
@@ -106,15 +106,15 @@ var require_src = __commonJS({
106
106
  var ESC3 = "\x1B";
107
107
  var CSI2 = `${ESC3}[`;
108
108
  var beep = "\x07";
109
- var cursor = {
110
- to(x3, y) {
111
- if (!y) return `${CSI2}${x3 + 1}G`;
112
- return `${CSI2}${y + 1};${x3 + 1}H`;
109
+ var cursor3 = {
110
+ to(x, y) {
111
+ if (!y) return `${CSI2}${x + 1}G`;
112
+ return `${CSI2}${y + 1};${x + 1}H`;
113
113
  },
114
- move(x3, y) {
114
+ move(x, y) {
115
115
  let ret = "";
116
- if (x3 < 0) ret += `${CSI2}${-x3}D`;
117
- else if (x3 > 0) ret += `${CSI2}${x3}C`;
116
+ if (x < 0) ret += `${CSI2}${-x}D`;
117
+ else if (x > 0) ret += `${CSI2}${x}C`;
118
118
  if (y < 0) ret += `${CSI2}${-y}A`;
119
119
  else if (y > 0) ret += `${CSI2}${y}B`;
120
120
  return ret;
@@ -135,7 +135,7 @@ var require_src = __commonJS({
135
135
  up: (count = 1) => `${CSI2}S`.repeat(count),
136
136
  down: (count = 1) => `${CSI2}T`.repeat(count)
137
137
  };
138
- var erase = {
138
+ var erase3 = {
139
139
  screen: `${CSI2}2J`,
140
140
  up: (count = 1) => `${CSI2}1J`.repeat(count),
141
141
  down: (count = 1) => `${CSI2}J`.repeat(count),
@@ -144,14 +144,14 @@ var require_src = __commonJS({
144
144
  lineStart: `${CSI2}1K`,
145
145
  lines(count) {
146
146
  let clear = "";
147
- for (let i = 0; i < count; i++)
148
- clear += this.line + (i < count - 1 ? cursor.up() : "");
147
+ for (let i2 = 0; i2 < count; i2++)
148
+ clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
149
149
  if (count)
150
- clear += cursor.left;
150
+ clear += cursor3.left;
151
151
  return clear;
152
152
  }
153
153
  };
154
- module.exports = { cursor, scroll, erase, beep };
154
+ module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
155
155
  }
156
156
  });
157
157
 
@@ -162,350 +162,350 @@ import { resolve as resolve4 } from "path";
162
162
  import { transform } from "sucrase";
163
163
 
164
164
  // src/client/lib/schema-extract.ts
165
- var isWS = (c) => c === " " || c === " " || c === "\n" || c === "\r";
166
- var isIdent = (c) => !!c && /[\w$]/.test(c);
167
- function skipTrivia(src, from) {
168
- let i = from;
169
- while (i < src.length) {
170
- const c = src[i];
171
- if (isWS(c)) {
172
- i++;
165
+ var is_w_s = (c2) => c2 === " " || c2 === " " || c2 === "\n" || c2 === "\r";
166
+ var is_ident = (c2) => !!c2 && /[\w$]/.test(c2);
167
+ function skip_trivia(src, from) {
168
+ let i2 = from;
169
+ while (i2 < src.length) {
170
+ const c2 = src[i2];
171
+ if (is_w_s(c2)) {
172
+ i2++;
173
173
  continue;
174
174
  }
175
- if (c === "/" && src[i + 1] === "/") {
176
- while (i < src.length && src[i] !== "\n") i++;
175
+ if (c2 === "/" && src[i2 + 1] === "/") {
176
+ while (i2 < src.length && src[i2] !== "\n") i2++;
177
177
  continue;
178
178
  }
179
- if (c === "/" && src[i + 1] === "*") {
180
- i += 2;
181
- while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
182
- i++;
179
+ if (c2 === "/" && src[i2 + 1] === "*") {
180
+ i2 += 2;
181
+ while (i2 < src.length && !(src[i2 - 1] === "*" && src[i2] === "/")) i2++;
182
+ i2++;
183
183
  continue;
184
184
  }
185
185
  break;
186
186
  }
187
- return i;
187
+ return i2;
188
188
  }
189
- function readValue(src, start) {
190
- let i = start;
189
+ function read_value(src, start) {
190
+ let i2 = start;
191
191
  let depth = 0;
192
- while (i < src.length) {
193
- const c = src[i];
194
- if (c === '"' || c === "'") {
195
- const q2 = c;
196
- i++;
197
- while (i < src.length && src[i] !== q2) {
198
- if (src[i] === "\\") {
199
- i += 2;
192
+ while (i2 < src.length) {
193
+ const c2 = src[i2];
194
+ if (c2 === '"' || c2 === "'") {
195
+ const q = c2;
196
+ i2++;
197
+ while (i2 < src.length && src[i2] !== q) {
198
+ if (src[i2] === "\\") {
199
+ i2 += 2;
200
200
  continue;
201
201
  }
202
- i++;
202
+ i2++;
203
203
  }
204
- i++;
204
+ i2++;
205
205
  continue;
206
206
  }
207
- if (c === "`") {
208
- i++;
209
- while (i < src.length && src[i] !== "`") {
210
- if (src[i] === "\\") {
211
- i += 2;
207
+ if (c2 === "`") {
208
+ i2++;
209
+ while (i2 < src.length && src[i2] !== "`") {
210
+ if (src[i2] === "\\") {
211
+ i2 += 2;
212
212
  continue;
213
213
  }
214
- if (src[i] === "$" && src[i + 1] === "{") {
214
+ if (src[i2] === "$" && src[i2 + 1] === "{") {
215
215
  let td = 1;
216
- i += 2;
217
- while (i < src.length && td > 0) {
218
- if (src[i] === "{") td++;
219
- else if (src[i] === "}") td--;
220
- if (td > 0) i++;
216
+ i2 += 2;
217
+ while (i2 < src.length && td > 0) {
218
+ if (src[i2] === "{") td++;
219
+ else if (src[i2] === "}") td--;
220
+ if (td > 0) i2++;
221
221
  }
222
- i++;
222
+ i2++;
223
223
  continue;
224
224
  }
225
- i++;
225
+ i2++;
226
226
  }
227
- i++;
227
+ i2++;
228
228
  continue;
229
229
  }
230
- if (c === "/" && src[i + 1] === "/") {
231
- while (i < src.length && src[i] !== "\n") i++;
230
+ if (c2 === "/" && src[i2 + 1] === "/") {
231
+ while (i2 < src.length && src[i2] !== "\n") i2++;
232
232
  continue;
233
233
  }
234
- if (c === "/" && src[i + 1] === "*") {
235
- i += 2;
236
- while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
237
- i++;
234
+ if (c2 === "/" && src[i2 + 1] === "*") {
235
+ i2 += 2;
236
+ while (i2 < src.length && !(src[i2 - 1] === "*" && src[i2] === "/")) i2++;
237
+ i2++;
238
238
  continue;
239
239
  }
240
- if (c === "(" || c === "{" || c === "[") {
240
+ if (c2 === "(" || c2 === "{" || c2 === "[") {
241
241
  depth++;
242
- i++;
242
+ i2++;
243
243
  continue;
244
244
  }
245
- if (c === ")" || c === "]") {
245
+ if (c2 === ")" || c2 === "]") {
246
246
  depth--;
247
- i++;
247
+ i2++;
248
248
  continue;
249
249
  }
250
- if (c === "}") {
251
- if (depth === 0) return i;
250
+ if (c2 === "}") {
251
+ if (depth === 0) return i2;
252
252
  depth--;
253
- i++;
253
+ i2++;
254
254
  continue;
255
255
  }
256
- if (c === "," && depth === 0) return i;
257
- i++;
256
+ if (c2 === "," && depth === 0) return i2;
257
+ i2++;
258
258
  }
259
- return i;
259
+ return i2;
260
260
  }
261
- function parseObjectLiteral(src, startBrace) {
261
+ function parse_object_literal(src, start_brace) {
262
262
  const entries = [];
263
- let i = startBrace + 1;
264
- while (i < src.length) {
265
- i = skipTrivia(src, i);
266
- if (src[i] === "}") return { entries, endBrace: i };
263
+ let i2 = start_brace + 1;
264
+ while (i2 < src.length) {
265
+ i2 = skip_trivia(src, i2);
266
+ if (src[i2] === "}") return { entries, end_brace: i2 };
267
267
  let key = "";
268
- let keyStart = i;
269
- let keyEnd = i;
270
- let keyWasIdentifier = false;
271
- if (src[i] === '"' || src[i] === "'") {
272
- const q2 = src[i];
273
- keyStart = ++i;
274
- while (i < src.length && src[i] !== q2) {
275
- if (src[i] === "\\") {
276
- i += 2;
268
+ let key_start = i2;
269
+ let key_end = i2;
270
+ let key_was_identifier = false;
271
+ if (src[i2] === '"' || src[i2] === "'") {
272
+ const q = src[i2];
273
+ key_start = ++i2;
274
+ while (i2 < src.length && src[i2] !== q) {
275
+ if (src[i2] === "\\") {
276
+ i2 += 2;
277
277
  continue;
278
278
  }
279
- i++;
280
- }
281
- key = src.slice(keyStart, i);
282
- keyEnd = i;
283
- i++;
284
- } else if (isIdent(src[i])) {
285
- keyStart = i;
286
- while (isIdent(src[i])) i++;
287
- key = src.slice(keyStart, i);
288
- keyEnd = i;
289
- keyWasIdentifier = true;
279
+ i2++;
280
+ }
281
+ key = src.slice(key_start, i2);
282
+ key_end = i2;
283
+ i2++;
284
+ } else if (is_ident(src[i2])) {
285
+ key_start = i2;
286
+ while (is_ident(src[i2])) i2++;
287
+ key = src.slice(key_start, i2);
288
+ key_end = i2;
289
+ key_was_identifier = true;
290
290
  } else {
291
291
  return null;
292
292
  }
293
- i = skipTrivia(src, i);
294
- if (src[i] !== ":") {
295
- if (keyWasIdentifier) {
296
- entries.push({ key, valueStart: keyStart, valueEnd: keyEnd });
293
+ i2 = skip_trivia(src, i2);
294
+ if (src[i2] !== ":") {
295
+ if (key_was_identifier) {
296
+ entries.push({ key, value_start: key_start, value_end: key_end });
297
297
  }
298
- while (i < src.length && src[i] !== "," && src[i] !== "}") i++;
299
- if (src[i] === ",") i++;
298
+ while (i2 < src.length && src[i2] !== "," && src[i2] !== "}") i2++;
299
+ if (src[i2] === ",") i2++;
300
300
  continue;
301
301
  }
302
- i++;
303
- i = skipTrivia(src, i);
304
- const valueStart = i;
305
- const valueEnd = readValue(src, i);
306
- entries.push({ key, valueStart, valueEnd });
307
- i = valueEnd;
308
- if (src[i] === ",") i++;
302
+ i2++;
303
+ i2 = skip_trivia(src, i2);
304
+ const value_start = i2;
305
+ const value_end = read_value(src, i2);
306
+ entries.push({ key, value_start, value_end });
307
+ i2 = value_end;
308
+ if (src[i2] === ",") i2++;
309
309
  }
310
310
  return null;
311
311
  }
312
- function readTopLevelExpression(src, start) {
313
- let i = start;
312
+ function read_top_level_expression(src, start) {
313
+ let i2 = start;
314
314
  let depth = 0;
315
- while (i < src.length) {
316
- const c = src[i];
317
- if (c === '"' || c === "'") {
318
- const q2 = c;
319
- i++;
320
- while (i < src.length && src[i] !== q2) {
321
- if (src[i] === "\\") {
322
- i += 2;
315
+ while (i2 < src.length) {
316
+ const c2 = src[i2];
317
+ if (c2 === '"' || c2 === "'") {
318
+ const q = c2;
319
+ i2++;
320
+ while (i2 < src.length && src[i2] !== q) {
321
+ if (src[i2] === "\\") {
322
+ i2 += 2;
323
323
  continue;
324
324
  }
325
- i++;
325
+ i2++;
326
326
  }
327
- i++;
327
+ i2++;
328
328
  continue;
329
329
  }
330
- if (c === "`") {
331
- i++;
332
- while (i < src.length && src[i] !== "`") {
333
- if (src[i] === "\\") {
334
- i += 2;
330
+ if (c2 === "`") {
331
+ i2++;
332
+ while (i2 < src.length && src[i2] !== "`") {
333
+ if (src[i2] === "\\") {
334
+ i2 += 2;
335
335
  continue;
336
336
  }
337
- if (src[i] === "$" && src[i + 1] === "{") {
337
+ if (src[i2] === "$" && src[i2 + 1] === "{") {
338
338
  let td = 1;
339
- i += 2;
340
- while (i < src.length && td > 0) {
341
- if (src[i] === "{") td++;
342
- else if (src[i] === "}") td--;
343
- if (td > 0) i++;
339
+ i2 += 2;
340
+ while (i2 < src.length && td > 0) {
341
+ if (src[i2] === "{") td++;
342
+ else if (src[i2] === "}") td--;
343
+ if (td > 0) i2++;
344
344
  }
345
- i++;
345
+ i2++;
346
346
  continue;
347
347
  }
348
- i++;
348
+ i2++;
349
349
  }
350
- i++;
350
+ i2++;
351
351
  continue;
352
352
  }
353
- if (c === "/" && src[i + 1] === "/") {
354
- while (i < src.length && src[i] !== "\n") i++;
353
+ if (c2 === "/" && src[i2 + 1] === "/") {
354
+ while (i2 < src.length && src[i2] !== "\n") i2++;
355
355
  continue;
356
356
  }
357
- if (c === "/" && src[i + 1] === "*") {
358
- i += 2;
359
- while (i < src.length && !(src[i - 1] === "*" && src[i] === "/")) i++;
360
- i++;
357
+ if (c2 === "/" && src[i2 + 1] === "*") {
358
+ i2 += 2;
359
+ while (i2 < src.length && !(src[i2 - 1] === "*" && src[i2] === "/")) i2++;
360
+ i2++;
361
361
  continue;
362
362
  }
363
- if (c === "(" || c === "{" || c === "[") {
363
+ if (c2 === "(" || c2 === "{" || c2 === "[") {
364
364
  depth++;
365
- i++;
365
+ i2++;
366
366
  continue;
367
367
  }
368
- if (c === ")" || c === "}" || c === "]") {
368
+ if (c2 === ")" || c2 === "}" || c2 === "]") {
369
369
  depth--;
370
- i++;
370
+ i2++;
371
371
  continue;
372
372
  }
373
- if (c === ";" && depth === 0) return i;
374
- i++;
373
+ if (c2 === ";" && depth === 0) return i2;
374
+ i2++;
375
375
  }
376
- return i;
376
+ return i2;
377
377
  }
378
- function extractIdentifierAssignments(src) {
378
+ function extract_identifier_assignments(src) {
379
379
  const out = /* @__PURE__ */ new Map();
380
380
  const re = /(?:^|[^\w$])(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=\n;]{1,256})?=\s*/gm;
381
- let m2;
382
- while ((m2 = re.exec(src)) !== null) {
383
- const ident = m2[1];
381
+ let m;
382
+ while ((m = re.exec(src)) !== null) {
383
+ const ident = m[1];
384
384
  if (out.has(ident)) {
385
385
  continue;
386
386
  }
387
- const start = m2.index + m2[0].length;
388
- const end = readTopLevelExpression(src, start);
389
- const text = src.slice(start, end).trim();
390
- if (text) out.set(ident, text);
387
+ const start = m.index + m[0].length;
388
+ const end = read_top_level_expression(src, start);
389
+ const text2 = src.slice(start, end).trim();
390
+ if (text2) out.set(ident, text2);
391
391
  re.lastIndex = end;
392
392
  }
393
393
  return out;
394
394
  }
395
- function findIdentifierObjectLiteral(src, ident) {
395
+ function find_identifier_object_literal(src, ident) {
396
396
  const re = new RegExp(
397
397
  `(?:^|[^\\w$])(?:const|let|var)\\s+${ident}\\b\\s*(?::[^=\\n;]+)?=\\s*`,
398
398
  "m"
399
399
  );
400
- const m2 = re.exec(src);
401
- if (!m2) return -1;
402
- const after = m2.index + m2[0].length;
403
- const skipped = skipTrivia(src, after);
400
+ const m = re.exec(src);
401
+ if (!m) return -1;
402
+ const after = m.index + m[0].length;
403
+ const skipped = skip_trivia(src, after);
404
404
  return src[skipped] === "{" ? skipped : -1;
405
405
  }
406
406
  var BARE_IDENT_RE = /^[A-Za-z_$][\w$]*$/;
407
- function extractSchemasFromSource(src, eventNames, external) {
407
+ function extract_schemas_from_source(src, event_names, external) {
408
408
  const out = /* @__PURE__ */ new Map();
409
- if (!src || eventNames.size === 0) return out;
410
- const localIdents = extractIdentifierAssignments(src);
411
- const deref = (text) => BARE_IDENT_RE.test(text) ? localIdents.get(text) ?? external?.get(text) ?? text : text;
412
- const emitsRe = /\.emits\s*\(/g;
413
- let m2;
414
- while ((m2 = emitsRe.exec(src)) !== null) {
415
- let i = skipTrivia(src, emitsRe.lastIndex);
416
- if (isIdent(src[i])) {
417
- const start = i;
418
- while (isIdent(src[i])) i++;
419
- const ident = src.slice(start, i);
420
- const objStart = findIdentifierObjectLiteral(src, ident);
421
- if (objStart < 0) continue;
422
- i = objStart;
423
- }
424
- if (src[i] !== "{") continue;
425
- const parsed = parseObjectLiteral(src, i);
409
+ if (!src || event_names.size === 0) return out;
410
+ const local_idents = extract_identifier_assignments(src);
411
+ const deref = (text2) => BARE_IDENT_RE.test(text2) ? local_idents.get(text2) ?? external?.get(text2) ?? text2 : text2;
412
+ const emits_re = /\.emits\s*\(/g;
413
+ let m;
414
+ while ((m = emits_re.exec(src)) !== null) {
415
+ let i2 = skip_trivia(src, emits_re.lastIndex);
416
+ if (is_ident(src[i2])) {
417
+ const start = i2;
418
+ while (is_ident(src[i2])) i2++;
419
+ const ident = src.slice(start, i2);
420
+ const obj_start = find_identifier_object_literal(src, ident);
421
+ if (obj_start < 0) continue;
422
+ i2 = obj_start;
423
+ }
424
+ if (src[i2] !== "{") continue;
425
+ const parsed = parse_object_literal(src, i2);
426
426
  if (!parsed) continue;
427
- for (const e2 of parsed.entries) {
428
- if (!eventNames.has(e2.key)) continue;
429
- const raw = src.slice(e2.valueStart, e2.valueEnd).trim();
430
- const text = deref(raw);
431
- if (text) out.set(e2.key, text);
427
+ for (const e of parsed.entries) {
428
+ if (!event_names.has(e.key)) continue;
429
+ const raw = src.slice(e.value_start, e.value_end).trim();
430
+ const text2 = deref(raw);
431
+ if (text2) out.set(e.key, text2);
432
432
  }
433
- emitsRe.lastIndex = Math.max(emitsRe.lastIndex, parsed.endBrace + 1);
433
+ emits_re.lastIndex = Math.max(emits_re.lastIndex, parsed.end_brace + 1);
434
434
  }
435
435
  return out;
436
436
  }
437
437
 
438
438
  // src/client/lib/build-model.ts
439
439
  var _stateIdx = 0;
440
- function buildState(model, st2) {
441
- const events = st2.events ?? {};
440
+ function build_state(model, st) {
441
+ const events = st.events ?? {};
442
442
  for (const [name, schema] of Object.entries(events)) {
443
443
  if (schema === void 0)
444
444
  return { error: `Event "${name}" has undefined schema` };
445
445
  }
446
- const rawActions = st2.actions ?? {};
447
- for (const [name, schema] of Object.entries(rawActions)) {
446
+ const raw_actions = st.actions ?? {};
447
+ for (const [name, schema] of Object.entries(raw_actions)) {
448
448
  if (name.startsWith("__emits_")) continue;
449
449
  if (schema === void 0)
450
450
  return { error: `Action "${name}" has undefined schema` };
451
451
  }
452
- const domainName = st2.name;
453
- const uniqueKey = `${domainName}:${_stateIdx++}`;
454
- const eventNodes = [];
455
- for (const eventName of Object.keys(events)) {
456
- eventNodes.push({
457
- name: eventName,
458
- hasCustomPatch: st2.patches?.has(eventName) ?? false,
452
+ const domain_name = st.name;
453
+ const unique_key = `${domain_name}:${_stateIdx++}`;
454
+ const event_nodes = [];
455
+ for (const event_name of Object.keys(events)) {
456
+ event_nodes.push({
457
+ name: event_name,
458
+ hasCustomPatch: st.patches?.has(event_name) ?? false,
459
459
  // Stash the runtime Zod schema so the JSON Schema exporter can
460
460
  // call `z.toJSONSchema(zod)` later without re-running the parser.
461
- zod: events[eventName]
461
+ zod: events[event_name]
462
462
  });
463
463
  }
464
- const actionNodes = [];
465
- for (const actionName of Object.keys(rawActions)) {
466
- if (actionName.startsWith("__emits_")) continue;
467
- const emits = rawActions[`__emits_${actionName}`] ?? [];
468
- const invariants = (st2.given?.[actionName] ?? []).map(
464
+ const action_nodes = [];
465
+ for (const action_name of Object.keys(raw_actions)) {
466
+ if (action_name.startsWith("__emits_")) continue;
467
+ const emits = raw_actions[`__emits_${action_name}`] ?? [];
468
+ const invariants = (st.given?.[action_name] ?? []).map(
469
469
  (inv) => inv.description ?? ""
470
470
  );
471
- actionNodes.push({ name: actionName, emits, invariants });
471
+ action_nodes.push({ name: action_name, emits, invariants });
472
472
  }
473
473
  const node = {
474
- name: domainName,
475
- varName: uniqueKey,
476
- events: eventNodes,
477
- actions: actionNodes,
478
- file: st2._sourceFile
474
+ name: domain_name,
475
+ varName: unique_key,
476
+ events: event_nodes,
477
+ actions: action_nodes,
478
+ file: st._sourceFile
479
479
  };
480
480
  model.states.push(node);
481
- st2._modelKey = uniqueKey;
482
- return { key: uniqueKey, node };
481
+ st._modelKey = unique_key;
482
+ return { key: unique_key, node };
483
483
  }
484
- function fixupReactions(reactions, files, sourceFile) {
485
- const fallbacks = reactions.filter((r) => r.handlerName.startsWith("on "));
484
+ function fixup_reactions(reactions, files, source_file) {
485
+ const fallbacks = reactions.filter((r2) => r2.handlerName.startsWith("on "));
486
486
  if (fallbacks.length === 0) return;
487
- const src = sourceFile ? files.find((f2) => f2.path === sourceFile)?.content : files.map((f2) => f2.content).join("\n");
487
+ const src = source_file ? files.find((f) => f.path === source_file)?.content : files.map((f) => f.content).join("\n");
488
488
  if (!src) return;
489
- const doRe = /\.on\(\s*["'`](\w+)["'`]\s*\)\s*\.do\(\s*(?:async\s+)?(?:function\s+(\w+)|(?:\w+\.)?(\w+))?/g;
489
+ const do_re = /\.on\(\s*["'`](\w+)["'`]\s*\)\s*\.do\(\s*(?:async\s+)?(?:function\s+(\w+)|(?:\w+\.)?(\w+))?/g;
490
490
  let dm;
491
- while ((dm = doRe.exec(src)) !== null) {
492
- const eventName = dm[1];
491
+ while ((dm = do_re.exec(src)) !== null) {
492
+ const event_name = dm[1];
493
493
  const handlerName = dm[2] || dm[3];
494
494
  if (!handlerName) continue;
495
- const r = fallbacks.find(
496
- (r2) => r2.event === eventName && r2.handlerName === `on ${eventName}`
495
+ const r2 = fallbacks.find(
496
+ (r3) => r3.event === event_name && r3.handlerName === `on ${event_name}`
497
497
  );
498
- if (r) r.handlerName = handlerName;
498
+ if (r2) r2.handlerName = handlerName;
499
499
  }
500
500
  }
501
- function buildModel(result, files, expectedSlices) {
502
- const rawStates = result.states.filter((s) => s && s._tag === "State");
503
- const rawSlices = result.slices.filter((s) => s && s._tag === "Slice");
504
- const rawProjections = result.projections.filter(
505
- (p2) => p2 && p2._tag === "Projection"
501
+ function build_model(result, files, expected_slices) {
502
+ const raw_states = result.states.filter((s) => s && s._tag === "State");
503
+ const raw_slices = result.slices.filter((s) => s && s._tag === "Slice");
504
+ const raw_projections = result.projections.filter(
505
+ (p) => p && p._tag === "Projection"
506
506
  );
507
- const rawActs = result.acts.filter((a) => a && a._tag === "Act");
508
- const stateByRef = /* @__PURE__ */ new Map();
507
+ const raw_acts = result.acts.filter((a2) => a2 && a2._tag === "Act");
508
+ const state_by_ref = /* @__PURE__ */ new Map();
509
509
  const model = {
510
510
  entries: [],
511
511
  states: [],
@@ -513,89 +513,89 @@ function buildModel(result, files, expectedSlices) {
513
513
  projections: [],
514
514
  reactions: []
515
515
  };
516
- for (const st2 of rawStates) {
517
- if (stateByRef.has(st2)) continue;
516
+ for (const st of raw_states) {
517
+ if (state_by_ref.has(st)) continue;
518
518
  try {
519
- stateByRef.set(st2, buildState(model, st2));
520
- } catch (e2) {
521
- stateByRef.set(st2, {
522
- error: e2 instanceof Error ? e2.message : String(e2)
519
+ state_by_ref.set(st, build_state(model, st));
520
+ } catch (e) {
521
+ state_by_ref.set(st, {
522
+ error: e instanceof Error ? e.message : String(e)
523
523
  });
524
524
  }
525
525
  }
526
- for (const a of rawActs) {
527
- for (const st2 of a.states ?? []) {
528
- if (!st2 || st2._tag !== "State" || stateByRef.has(st2)) continue;
526
+ for (const a2 of raw_acts) {
527
+ for (const st of a2.states ?? []) {
528
+ if (!st || st._tag !== "State" || state_by_ref.has(st)) continue;
529
529
  try {
530
- stateByRef.set(st2, buildState(model, st2));
531
- } catch (e2) {
532
- stateByRef.set(st2, {
533
- error: e2 instanceof Error ? e2.message : String(e2)
530
+ state_by_ref.set(st, build_state(model, st));
531
+ } catch (e) {
532
+ state_by_ref.set(st, {
533
+ error: e instanceof Error ? e.message : String(e)
534
534
  });
535
535
  }
536
536
  }
537
537
  }
538
- const builtSliceNames = /* @__PURE__ */ new Set();
539
- for (const s of rawSlices) {
540
- const sliceName = s._varName ?? "slice";
541
- builtSliceNames.add(sliceName);
538
+ const built_slice_names = /* @__PURE__ */ new Set();
539
+ for (const s of raw_slices) {
540
+ const slice_name = s._varName ?? "slice";
541
+ built_slice_names.add(slice_name);
542
542
  try {
543
543
  try {
544
- fixupReactions(s.reactions, files);
544
+ fixup_reactions(s.reactions, files);
545
545
  } catch {
546
546
  }
547
- const sliceStateKeys = [];
547
+ const slice_state_keys = [];
548
548
  const errors = [];
549
- for (const st2 of s.states ?? []) {
550
- if (!st2 || typeof st2 !== "object") {
551
- const fileErr = [...result.fileErrors.values()][0];
549
+ for (const st of s.states ?? []) {
550
+ if (!st || typeof st !== "object") {
551
+ const fileErr = [...result.file_errors.values()][0];
552
552
  errors.push(fileErr ?? "Missing state (broken import)");
553
553
  continue;
554
554
  }
555
- const built = stateByRef.get(st2);
555
+ const built = state_by_ref.get(st);
556
556
  if (built) {
557
557
  if ("error" in built) {
558
558
  errors.push(built.error);
559
559
  } else {
560
- sliceStateKeys.push(built.key);
560
+ slice_state_keys.push(built.key);
561
561
  }
562
562
  } else {
563
563
  try {
564
- const result2 = buildState(model, st2);
565
- stateByRef.set(st2, result2);
564
+ const result2 = build_state(model, st);
565
+ state_by_ref.set(st, result2);
566
566
  if ("error" in result2) {
567
567
  errors.push(result2.error);
568
568
  } else {
569
- sliceStateKeys.push(result2.key);
569
+ slice_state_keys.push(result2.key);
570
570
  }
571
- } catch (e2) {
572
- const msg = e2 instanceof Error ? e2.message : String(e2);
573
- stateByRef.set(st2, { error: msg });
571
+ } catch (e) {
572
+ const msg = e instanceof Error ? e.message : String(e);
573
+ state_by_ref.set(st, { error: msg });
574
574
  errors.push(msg);
575
575
  }
576
576
  }
577
577
  }
578
- const projNames = [];
579
- for (const p2 of s.projections ?? []) {
580
- if (p2 && p2._tag === "Projection") projNames.push(p2.target);
578
+ const proj_names = [];
579
+ for (const p of s.projections ?? []) {
580
+ if (p && p._tag === "Projection") proj_names.push(p.target);
581
581
  }
582
- const sliceFile = s._sourceFile;
582
+ const slice_file = s._sourceFile;
583
583
  model.slices.push({
584
- name: sliceName,
585
- states: sliceStateKeys,
586
- stateVars: sliceStateKeys,
587
- projections: projNames,
588
- reactions: (s.reactions ?? []).map((r) => ({
589
- ...r,
590
- file: r.file ?? sliceFile
584
+ name: slice_name,
585
+ states: slice_state_keys,
586
+ stateVars: slice_state_keys,
587
+ projections: proj_names,
588
+ reactions: (s.reactions ?? []).map((r2) => ({
589
+ ...r2,
590
+ file: r2.file ?? slice_file
591
591
  })),
592
- file: sliceFile,
592
+ file: slice_file,
593
593
  error: errors.length > 0 ? errors.join("; ") : void 0
594
594
  });
595
- } catch (e2) {
596
- const msg = e2 instanceof Error ? e2.message : String(e2);
595
+ } catch (e) {
596
+ const msg = e instanceof Error ? e.message : String(e);
597
597
  model.slices.push({
598
- name: sliceName,
598
+ name: slice_name,
599
599
  states: [],
600
600
  stateVars: [],
601
601
  projections: [],
@@ -605,109 +605,111 @@ function buildModel(result, files, expectedSlices) {
605
605
  });
606
606
  }
607
607
  }
608
- for (const [name, filePath] of expectedSlices) {
609
- if (!builtSliceNames.has(name)) {
608
+ for (const [name, file_path] of expected_slices) {
609
+ if (!built_slice_names.has(name)) {
610
610
  model.slices.push({
611
611
  name,
612
612
  states: [],
613
613
  stateVars: [],
614
614
  projections: [],
615
615
  reactions: [],
616
- error: result.fileErrors.get(filePath) ?? result.error ?? "Failed to build slice",
617
- file: filePath
616
+ error: result.file_errors.get(file_path) ?? result.error ?? "Failed to build slice",
617
+ file: file_path
618
618
  });
619
619
  }
620
620
  }
621
- const sourceByPath = /* @__PURE__ */ new Map();
622
- const externalIdents = /* @__PURE__ */ new Map();
623
- for (const f2 of files) {
624
- sourceByPath.set(f2.path, f2.content);
625
- for (const [ident, expr] of extractIdentifierAssignments(f2.content)) {
626
- if (!externalIdents.has(ident)) externalIdents.set(ident, expr);
621
+ const source_by_path = /* @__PURE__ */ new Map();
622
+ const external_idents = /* @__PURE__ */ new Map();
623
+ for (const f of files) {
624
+ source_by_path.set(f.path, f.content);
625
+ for (const [ident, expr] of extract_identifier_assignments(f.content)) {
626
+ if (!external_idents.has(ident)) external_idents.set(ident, expr);
627
627
  }
628
628
  }
629
- for (const stNode of model.states) {
630
- if (!stNode.file) continue;
631
- const src = sourceByPath.get(stNode.file);
632
- const names = new Set(stNode.events.map((e2) => e2.name));
629
+ for (const st_node of model.states) {
630
+ if (!st_node.file) continue;
631
+ const src = source_by_path.get(st_node.file);
632
+ const names = new Set(st_node.events.map((e) => e.name));
633
633
  if (names.size === 0) continue;
634
- const schemas = extractSchemasFromSource(src, names, externalIdents);
635
- for (const ev of stNode.events) {
634
+ const schemas = extract_schemas_from_source(src, names, external_idents);
635
+ for (const ev of st_node.events) {
636
636
  ev.schema = schemas.get(ev.name);
637
637
  }
638
638
  }
639
- for (const p2 of rawProjections) {
639
+ for (const p of raw_projections) {
640
640
  model.projections.push({
641
- name: p2.target,
642
- varName: p2.target,
643
- handles: p2.handles,
644
- file: p2._sourceFile
641
+ name: p.target,
642
+ varName: p.target,
643
+ handles: p.handles,
644
+ file: p._sourceFile
645
645
  });
646
646
  }
647
- const statesInSlices = new Set(model.slices.flatMap((s) => s.states));
648
- const globalStateKeys = model.states.filter((s) => !statesInSlices.has(s.varName)).map((s) => s.varName);
649
- for (const a of rawActs) {
647
+ const states_in_slices = new Set(model.slices.flatMap((s) => s.states));
648
+ const global_state_keys = model.states.filter((s) => !states_in_slices.has(s.varName)).map((s) => s.varName);
649
+ for (const a2 of raw_acts) {
650
650
  try {
651
- fixupReactions(
652
- a.reactions ?? [],
651
+ fixup_reactions(
652
+ a2.reactions ?? [],
653
653
  files,
654
- a._sourceFile
654
+ a2._sourceFile
655
655
  );
656
656
  } catch {
657
657
  }
658
658
  model.orchestrator = {
659
659
  slices: model.slices.map((s) => s.name),
660
- projections: model.projections.map((p2) => p2.name),
660
+ projections: model.projections.map((p) => p.name),
661
661
  states: model.states.map((s) => s.name)
662
662
  };
663
- const actFile = a._sourceFile;
664
- for (const r of a.reactions ?? []) {
665
- model.reactions.push({ ...r, file: r.file ?? actFile });
663
+ const act_file = a2._sourceFile;
664
+ for (const r2 of a2.reactions ?? []) {
665
+ model.reactions.push({ ...r2, file: r2.file ?? act_file });
666
666
  }
667
- const entryPath = a._sourceFile ?? "app.ts";
668
- const actSliceNames = new Set(
669
- (a.slices ?? []).filter((s) => s != null).map((s) => s._varName ?? "").filter(Boolean)
667
+ const entry_path = a2._sourceFile ?? "app.ts";
668
+ const act_slice_names = new Set(
669
+ (a2.slices ?? []).filter((s) => s != null).map((s) => s._varName ?? "").filter(Boolean)
670
670
  );
671
671
  for (const sl of model.slices) {
672
- if (sl.error && !actSliceNames.has(sl.name)) {
673
- const actSrc = files.find((f2) => f2.path === entryPath)?.content ?? "";
674
- if (actSrc.includes(sl.name)) {
675
- actSliceNames.add(sl.name);
672
+ if (sl.error && !act_slice_names.has(sl.name)) {
673
+ const act_src = files.find((f) => f.path === entry_path)?.content ?? "";
674
+ if (act_src.includes(sl.name)) {
675
+ act_slice_names.add(sl.name);
676
676
  }
677
677
  }
678
678
  }
679
- const entrySlices = model.slices.filter((s) => actSliceNames.has(s.name));
680
- const sliceStateKeys = new Set(entrySlices.flatMap((s) => s.states));
681
- const actStateKeys = /* @__PURE__ */ new Set();
682
- for (const s of a.states ?? []) {
679
+ const entry_slices = model.slices.filter(
680
+ (s) => act_slice_names.has(s.name)
681
+ );
682
+ const slice_state_keys = new Set(entry_slices.flatMap((s) => s.states));
683
+ const act_state_keys = /* @__PURE__ */ new Set();
684
+ for (const s of a2.states ?? []) {
683
685
  try {
684
686
  if (s && s._tag === "State") {
685
- actStateKeys.add(s._modelKey ?? s.name);
687
+ act_state_keys.add(s._modelKey ?? s.name);
686
688
  }
687
689
  } catch {
688
690
  }
689
691
  }
690
- const allStateKeys = /* @__PURE__ */ new Set([...actStateKeys, ...sliceStateKeys]);
691
- const actProjNames = new Set(
692
- (a.projections ?? []).filter((p2) => p2 && p2._tag === "Projection").map((p2) => p2.target)
692
+ const all_state_keys = /* @__PURE__ */ new Set([...act_state_keys, ...slice_state_keys]);
693
+ const act_proj_names = new Set(
694
+ (a2.projections ?? []).filter((p) => p && p._tag === "Projection").map((p) => p.target)
693
695
  );
694
- for (const sl of entrySlices) {
695
- for (const pn of sl.projections) actProjNames.add(pn);
696
+ for (const sl of entry_slices) {
697
+ for (const pn of sl.projections) act_proj_names.add(pn);
696
698
  }
697
699
  model.entries.push({
698
- path: entryPath,
699
- states: model.states.filter((s) => allStateKeys.has(s.varName)),
700
- slices: entrySlices,
701
- projections: model.projections.filter((p2) => actProjNames.has(p2.name)),
702
- reactions: a.reactions ?? []
700
+ path: entry_path,
701
+ states: model.states.filter((s) => all_state_keys.has(s.varName)),
702
+ slices: entry_slices,
703
+ projections: model.projections.filter((p) => act_proj_names.has(p.name)),
704
+ reactions: a2.reactions ?? []
703
705
  });
704
706
  }
705
- if (globalStateKeys.length > 0 || model.reactions.length > 0) {
707
+ if (global_state_keys.length > 0 || model.reactions.length > 0) {
706
708
  model.slices.push({
707
709
  name: "global",
708
- states: globalStateKeys,
709
- stateVars: globalStateKeys,
710
- projections: model.projections.map((p2) => p2.name),
710
+ states: global_state_keys,
711
+ stateVars: global_state_keys,
712
+ projections: model.projections.map((p) => p.name),
711
713
  reactions: model.reactions
712
714
  });
713
715
  }
@@ -728,42 +730,42 @@ function buildModel(result, files, expectedSlices) {
728
730
 
729
731
  // src/client/lib/mock-builders.ts
730
732
  import { z } from "zod";
731
- function proxyTarget() {
733
+ function proxy_target() {
732
734
  }
733
- function attachEmit(info, actionName, handler) {
735
+ function attach_emit(info, action_name, handler) {
734
736
  const emits = [];
735
737
  if (typeof handler === "string") {
736
738
  emits.push(handler);
737
739
  } else if (typeof handler === "function") {
738
740
  const src = String(handler);
739
- for (const eventName of Object.keys(info.events)) {
740
- if (src.includes(`"${eventName}"`) || src.includes(`'${eventName}'`) || src.includes(`\`${eventName}\``)) {
741
- emits.push(eventName);
741
+ for (const event_name of Object.keys(info.events)) {
742
+ if (src.includes(`"${event_name}"`) || src.includes(`'${event_name}'`) || src.includes(`\`${event_name}\``)) {
743
+ emits.push(event_name);
742
744
  }
743
745
  }
744
746
  if (emits.length === 0) {
745
747
  try {
746
- const deepProxy = new Proxy(
748
+ const deep_proxy = new Proxy(
747
749
  {},
748
750
  {
749
- get: () => deepProxy,
751
+ get: () => deep_proxy,
750
752
  has: () => true
751
753
  }
752
754
  );
753
- const proxyFn = new Proxy(proxyTarget, {
754
- get: () => deepProxy,
755
- apply: () => deepProxy
755
+ const proxy_fn = new Proxy(proxy_target, {
756
+ get: () => deep_proxy,
757
+ apply: () => deep_proxy
756
758
  });
757
- const dummyArg = new Proxy(
759
+ const dummy_arg = new Proxy(
758
760
  {},
759
761
  {
760
- get: (_t2, prop) => {
761
- if (typeof prop === "string") return proxyFn;
762
+ get: (_t, prop) => {
763
+ if (typeof prop === "string") return proxy_fn;
762
764
  return void 0;
763
765
  }
764
766
  }
765
767
  );
766
- const result = handler(dummyArg, dummyArg, dummyArg);
768
+ const result = handler(dummy_arg, dummy_arg, dummy_arg);
767
769
  if (Array.isArray(result) && typeof result[0] === "string") {
768
770
  emits.push(result[0]);
769
771
  }
@@ -771,9 +773,9 @@ function attachEmit(info, actionName, handler) {
771
773
  }
772
774
  }
773
775
  }
774
- info.actions[`__emits_${actionName}`] = emits;
776
+ info.actions[`__emits_${action_name}`] = emits;
775
777
  }
776
- function mockState(entry, onBuild) {
778
+ function mock_state(entry, on_build) {
777
779
  const name = Object.keys(entry)[0];
778
780
  const info = {
779
781
  name,
@@ -783,29 +785,29 @@ function mockState(entry, onBuild) {
783
785
  patches: /* @__PURE__ */ new Set(),
784
786
  _tag: "State"
785
787
  };
786
- const actionBuilder = (_currentAction) => ({
787
- on(actionEntry) {
788
- const actionName = Object.keys(actionEntry)[0];
789
- info.actions[actionName] = actionEntry[actionName];
788
+ const action_builder = (_currentAction) => ({
789
+ on(action_entry) {
790
+ const action_name = Object.keys(action_entry)[0];
791
+ info.actions[action_name] = action_entry[action_name];
790
792
  return {
791
793
  given(rules) {
792
- if (rules) info.given[actionName] = rules;
794
+ if (rules) info.given[action_name] = rules;
793
795
  return {
794
796
  emit(handler) {
795
- attachEmit(info, actionName, handler);
796
- return actionBuilder(actionName);
797
+ attach_emit(info, action_name, handler);
798
+ return action_builder(action_name);
797
799
  }
798
800
  };
799
801
  },
800
802
  emit(handler) {
801
- attachEmit(info, actionName, handler);
802
- return actionBuilder(actionName);
803
+ attach_emit(info, action_name, handler);
804
+ return action_builder(action_name);
803
805
  }
804
806
  };
805
807
  },
806
- snap: () => actionBuilder(_currentAction),
808
+ snap: () => action_builder(_currentAction),
807
809
  build: () => {
808
- onBuild?.(info);
810
+ on_build?.(info);
809
811
  return info;
810
812
  }
811
813
  });
@@ -815,36 +817,36 @@ function mockState(entry, onBuild) {
815
817
  emits(events) {
816
818
  info.events = events ?? {};
817
819
  return {
818
- ...actionBuilder(),
820
+ ...action_builder(),
819
821
  patch(patches) {
820
822
  if (patches)
821
- for (const k2 of Object.keys(patches)) info.patches.add(k2);
822
- return actionBuilder();
823
+ for (const k of Object.keys(patches)) info.patches.add(k);
824
+ return action_builder();
823
825
  }
824
826
  };
825
827
  }
826
828
  })
827
829
  };
828
830
  }
829
- function captureDispatches(handler) {
831
+ function capture_dispatches(handler) {
830
832
  const dispatches = [];
831
833
  if (typeof handler !== "function") return dispatches;
832
834
  try {
833
- const safeProxy = () => new Proxy({}, { get: () => "" });
834
- const mockApp = {
835
- do: (actionName) => {
836
- if (typeof actionName === "string" && !dispatches.includes(actionName))
837
- dispatches.push(actionName);
835
+ const safe_proxy = () => new Proxy({}, { get: () => "" });
836
+ const mock_app = {
837
+ do: (action_name) => {
838
+ if (typeof action_name === "string" && !dispatches.includes(action_name))
839
+ dispatches.push(action_name);
838
840
  return Promise.resolve([]);
839
841
  },
840
- load: () => Promise.resolve({ state: safeProxy(), version: 0 }),
842
+ load: () => Promise.resolve({ state: safe_proxy(), version: 0 }),
841
843
  query: () => Promise.resolve({ count: 0 }),
842
844
  query_array: () => Promise.resolve([])
843
845
  };
844
- const mockEvent = new Proxy({}, {
846
+ const mock_event = new Proxy({}, {
845
847
  get: (_, prop) => prop === "stream" ? "mock" : prop === "data" ? new Proxy({}, { get: () => "" }) : ""
846
848
  });
847
- const result = handler(mockEvent, "mock", mockApp);
849
+ const result = handler(mock_event, "mock", mock_app);
848
850
  if (result && typeof result.catch === "function") {
849
851
  result.catch(() => {
850
852
  });
@@ -854,14 +856,14 @@ function captureDispatches(handler) {
854
856
  if (dispatches.length === 0) {
855
857
  const src = String(handler);
856
858
  const re = /\.do\(\s*["'](\w+)["']/g;
857
- let m2;
858
- while ((m2 = re.exec(src)) !== null) {
859
- if (!dispatches.includes(m2[1])) dispatches.push(m2[1]);
859
+ let m;
860
+ while ((m = re.exec(src)) !== null) {
861
+ if (!dispatches.includes(m[1])) dispatches.push(m[1]);
860
862
  }
861
863
  }
862
864
  return dispatches;
863
865
  }
864
- function mockSlice(onBuild) {
866
+ function mock_slice(on_build) {
865
867
  const info = {
866
868
  _tag: "Slice",
867
869
  states: [],
@@ -873,17 +875,17 @@ function mockSlice(onBuild) {
873
875
  info.states.push(s ?? null);
874
876
  return builder;
875
877
  },
876
- withProjection(p2) {
877
- if (p2) info.projections.push(p2);
878
+ withProjection(p) {
879
+ if (p) info.projections.push(p);
878
880
  return builder;
879
881
  },
880
- on(eventName) {
882
+ on(event_name) {
881
883
  return {
882
884
  do(handler) {
883
- const dispatches = captureDispatches(handler);
885
+ const dispatches = capture_dispatches(handler);
884
886
  const reaction = {
885
- event: eventName,
886
- handlerName: typeof handler?.name === "string" && handler.name || `on ${eventName}`,
887
+ event: event_name,
888
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
887
889
  dispatches
888
890
  };
889
891
  info.reactions.push(reaction);
@@ -897,22 +899,22 @@ function mockSlice(onBuild) {
897
899
  };
898
900
  },
899
901
  build: () => {
900
- onBuild?.(info);
902
+ on_build?.(info);
901
903
  return info;
902
904
  }
903
905
  };
904
906
  return builder;
905
907
  }
906
- function mockProjection(target, onBuild) {
908
+ function mock_projection(target, on_build) {
907
909
  const info = {
908
910
  _tag: "Projection",
909
911
  target: target || "projection",
910
912
  handles: []
911
913
  };
912
914
  const builder = {
913
- on(eventEntry) {
914
- const eventName = Object.keys(eventEntry)[0];
915
- info.handles.push(eventName);
915
+ on(event_entry) {
916
+ const event_name = Object.keys(event_entry)[0];
917
+ info.handles.push(event_name);
916
918
  return {
917
919
  do() {
918
920
  return {
@@ -926,13 +928,13 @@ function mockProjection(target, onBuild) {
926
928
  };
927
929
  },
928
930
  build: () => {
929
- onBuild?.(info);
931
+ on_build?.(info);
930
932
  return info;
931
933
  }
932
934
  };
933
935
  return builder;
934
936
  }
935
- function mockAct(onBuild) {
937
+ function mock_act(on_build) {
936
938
  const info = {
937
939
  _tag: "Act",
938
940
  states: [],
@@ -949,18 +951,18 @@ function mockAct(onBuild) {
949
951
  info.slices.push(s ?? null);
950
952
  return builder;
951
953
  },
952
- withProjection(p2) {
953
- if (p2) info.projections.push(p2);
954
+ withProjection(p) {
955
+ if (p) info.projections.push(p);
954
956
  return builder;
955
957
  },
956
958
  withActor: () => builder,
957
- on(eventName) {
959
+ on(event_name) {
958
960
  return {
959
961
  do(handler) {
960
- const dispatches = captureDispatches(handler);
962
+ const dispatches = capture_dispatches(handler);
961
963
  const reaction = {
962
- event: eventName,
963
- handlerName: typeof handler?.name === "string" && handler.name || `on ${eventName}`,
964
+ event: event_name,
965
+ handlerName: typeof handler?.name === "string" && handler.name || `on ${event_name}`,
964
966
  dispatches
965
967
  };
966
968
  info.reactions.push(reaction);
@@ -974,10 +976,10 @@ function mockAct(onBuild) {
974
976
  };
975
977
  },
976
978
  build: () => {
977
- const noop = () => actStub;
978
- const actStub = {
979
+ const noop = () => act_stub;
980
+ const act_stub = {
979
981
  ...info,
980
- on: () => actStub,
982
+ on: () => act_stub,
981
983
  do: () => Promise.resolve([]),
982
984
  load: () => Promise.resolve({}),
983
985
  drain: () => Promise.resolve(),
@@ -986,8 +988,8 @@ function mockAct(onBuild) {
986
988
  start_correlations: noop,
987
989
  query_array: () => Promise.resolve([])
988
990
  };
989
- onBuild?.(actStub);
990
- return actStub;
991
+ on_build?.(act_stub);
992
+ return act_stub;
991
993
  }
992
994
  };
993
995
  return builder;
@@ -998,13 +1000,13 @@ var InvariantError = class extends Error {
998
1000
  this.name = "InvariantError";
999
1001
  }
1000
1002
  };
1001
- var cryptoMock = { randomUUID: () => "mock-uuid" };
1003
+ var crypto_mock = { randomUUID: () => "mock-uuid" };
1002
1004
  var MODULES = {
1003
1005
  "@rotorsoft/act": {
1004
- state: mockState,
1005
- slice: mockSlice,
1006
- projection: mockProjection,
1007
- act: mockAct,
1006
+ state: mock_state,
1007
+ slice: mock_slice,
1008
+ projection: mock_projection,
1009
+ act: mock_act,
1008
1010
  store: () => ({
1009
1011
  seed: () => Promise.resolve(),
1010
1012
  drop: () => Promise.resolve(),
@@ -1017,10 +1019,10 @@ var MODULES = {
1017
1019
  InvariantError
1018
1020
  },
1019
1021
  zod: { z, ...z },
1020
- crypto: cryptoMock,
1021
- "node:crypto": cryptoMock
1022
+ crypto: crypto_mock,
1023
+ "node:crypto": crypto_mock
1022
1024
  };
1023
- function unknownModuleProxy() {
1025
+ function unknown_module_proxy() {
1024
1026
  const handler = {
1025
1027
  get(_target, prop) {
1026
1028
  if (prop === Symbol.toPrimitive) return () => "";
@@ -1037,97 +1039,97 @@ function unknownModuleProxy() {
1037
1039
  return true;
1038
1040
  }
1039
1041
  };
1040
- const proxy = new Proxy(proxyTarget, handler);
1042
+ const proxy = new Proxy(proxy_target, handler);
1041
1043
  return proxy;
1042
1044
  }
1043
1045
 
1044
1046
  // src/client/lib/sort.ts
1045
- function topoSort(tsFiles) {
1046
- if (tsFiles.length <= 1) return tsFiles;
1047
- const strip = (p2) => p2.replace(/\.tsx?$/, "");
1048
- const byKey = /* @__PURE__ */ new Map();
1049
- for (const f2 of tsFiles) {
1050
- byKey.set(strip(f2.path), f2);
1047
+ function topo_sort(ts_files) {
1048
+ if (ts_files.length <= 1) return ts_files;
1049
+ const strip = (p) => p.replace(/\.tsx?$/, "");
1050
+ const by_key = /* @__PURE__ */ new Map();
1051
+ for (const f of ts_files) {
1052
+ by_key.set(strip(f.path), f);
1051
1053
  }
1052
1054
  const deps = /* @__PURE__ */ new Map();
1053
- for (const f2 of tsFiles) {
1054
- const key = strip(f2.path);
1055
- const fileDeps = /* @__PURE__ */ new Set();
1056
- deps.set(key, fileDeps);
1057
- const fromRe = /from\s+["']([^"']+)["']/g;
1058
- let m2;
1059
- while ((m2 = fromRe.exec(f2.content)) !== null) {
1060
- const imp = m2[1];
1061
- const resolved = resolve(imp, key, byKey);
1062
- if (resolved && byKey.has(resolved)) fileDeps.add(resolved);
1055
+ for (const f of ts_files) {
1056
+ const key = strip(f.path);
1057
+ const file_deps = /* @__PURE__ */ new Set();
1058
+ deps.set(key, file_deps);
1059
+ const from_re = /from\s+["']([^"']+)["']/g;
1060
+ let m;
1061
+ while ((m = from_re.exec(f.content)) !== null) {
1062
+ const imp = m[1];
1063
+ const resolved = resolve(imp, key, by_key);
1064
+ if (resolved && by_key.has(resolved)) file_deps.add(resolved);
1063
1065
  }
1064
1066
  }
1065
- const inDegree = /* @__PURE__ */ new Map();
1066
- for (const f2 of tsFiles) inDegree.set(strip(f2.path), 0);
1067
- for (const [, fileDeps] of deps) {
1068
- for (const dep of fileDeps) {
1069
- inDegree.set(dep, inDegree.get(dep) + 1);
1067
+ const in_degree = /* @__PURE__ */ new Map();
1068
+ for (const f of ts_files) in_degree.set(strip(f.path), 0);
1069
+ for (const [, file_deps] of deps) {
1070
+ for (const dep of file_deps) {
1071
+ in_degree.set(dep, in_degree.get(dep) + 1);
1070
1072
  }
1071
1073
  }
1072
1074
  const queue = [];
1073
- for (const [key, _deg] of inDegree) {
1075
+ for (const [key, _deg] of in_degree) {
1074
1076
  if (deps.get(key)?.size === 0) queue.push(key);
1075
1077
  }
1076
1078
  const order = [];
1077
1079
  while (queue.length > 0) {
1078
1080
  const key = queue.shift();
1079
1081
  order.push(key);
1080
- for (const [other, fileDeps] of deps) {
1081
- if (fileDeps.has(key)) {
1082
- fileDeps.delete(key);
1083
- if (fileDeps.size === 0) queue.push(other);
1082
+ for (const [other, file_deps] of deps) {
1083
+ if (file_deps.has(key)) {
1084
+ file_deps.delete(key);
1085
+ if (file_deps.size === 0) queue.push(other);
1084
1086
  }
1085
1087
  }
1086
1088
  }
1087
- for (const f2 of tsFiles) {
1088
- const key = strip(f2.path);
1089
+ for (const f of ts_files) {
1090
+ const key = strip(f.path);
1089
1091
  if (!order.includes(key)) order.push(key);
1090
1092
  }
1091
- return order.map((k2) => byKey.get(k2)).filter(Boolean);
1093
+ return order.map((k) => by_key.get(k)).filter(Boolean);
1092
1094
  }
1093
- function resolve(imp, fromPath, byKey) {
1095
+ function resolve(imp, from_path, by_key) {
1094
1096
  if (imp.startsWith(".")) {
1095
- const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
1097
+ const dir = from_path.includes("/") ? from_path.slice(0, from_path.lastIndexOf("/")) : "";
1096
1098
  const parts = (dir ? dir + "/" + imp : imp).split("/");
1097
1099
  const resolved = [];
1098
- for (const p2 of parts) {
1099
- if (p2 === "." || p2 === "") continue;
1100
- if (p2 === "..") resolved.pop();
1101
- else resolved.push(p2);
1100
+ for (const p of parts) {
1101
+ if (p === "." || p === "") continue;
1102
+ if (p === "..") resolved.pop();
1103
+ else resolved.push(p);
1102
1104
  }
1103
1105
  return resolved.join("/").replace(/\.js$/, "").replace(/\.ts$/, "");
1104
1106
  }
1105
1107
  if (imp.startsWith("@") && !imp.startsWith("@rotorsoft/")) {
1106
- const pkgName = imp.split("/")[1];
1107
- if (pkgName) {
1108
+ const pkg_name = imp.split("/")[1];
1109
+ if (pkg_name) {
1108
1110
  for (const candidate of [
1109
- `packages/${pkgName}/src/index`,
1110
- `${pkgName}/src/index`,
1111
- `${pkgName}/index`
1111
+ `packages/${pkg_name}/src/index`,
1112
+ `${pkg_name}/src/index`,
1113
+ `${pkg_name}/index`
1112
1114
  ]) {
1113
- if (byKey?.has(candidate)) return candidate;
1115
+ if (by_key?.has(candidate)) return candidate;
1114
1116
  }
1115
- return `packages/${pkgName}/src/index`;
1117
+ return `packages/${pkg_name}/src/index`;
1116
1118
  }
1117
1119
  }
1118
1120
  return void 0;
1119
1121
  }
1120
1122
 
1121
1123
  // src/client/lib/evaluate.ts
1122
- var stripNonCode = (src, level = "full") => {
1123
- const blank = (m2) => m2.replace(/[^\n]/g, " ");
1124
+ var strip_non_code = (src, level = "full") => {
1125
+ const blank = (m) => m.replace(/[^\n]/g, " ");
1124
1126
  let result = src.replace(/\/\/[^\n]*/g, blank).replace(/\/\*[\s\S]*?\*\//g, blank).replace(/`(?:\\[\s\S]|[^`\\])*`/g, blank);
1125
1127
  if (level === "full") {
1126
1128
  result = result.replace(/"(?:\\[\s\S]|[^"\\])*"/g, blank).replace(/'(?:\\[\s\S]|[^'\\])*'/g, blank);
1127
1129
  }
1128
1130
  return result;
1129
1131
  };
1130
- var isSourceFile = (f2) => f2.path.endsWith(".ts") && !f2.path.endsWith(".d.ts") && !f2.path.endsWith(".tsx") && !f2.path.endsWith(".spec.ts") && !f2.path.endsWith(".test.ts") && !f2.path.includes("node_modules/") && !f2.path.includes("__tests__/") && !f2.path.includes("/test/") && !f2.path.startsWith("test/");
1132
+ var is_source_file = (f) => f.path.endsWith(".ts") && !f.path.endsWith(".d.ts") && !f.path.endsWith(".tsx") && !f.path.endsWith(".spec.ts") && !f.path.endsWith(".test.ts") && !f.path.includes("node_modules/") && !f.path.includes("__tests__/") && !f.path.includes("/test/") && !f.path.startsWith("test/");
1131
1133
  function transpile(code) {
1132
1134
  try {
1133
1135
  const safe = code.replace(/\bimport\.meta\.\w+/g, "'__import_meta__'");
@@ -1149,8 +1151,8 @@ function execute(files) {
1149
1151
  projections: [],
1150
1152
  acts: [],
1151
1153
  error: void 0,
1152
- fileErrors: /* @__PURE__ */ new Map(),
1153
- expectedSlices: /* @__PURE__ */ new Map()
1154
+ file_errors: /* @__PURE__ */ new Map(),
1155
+ expected_slices: /* @__PURE__ */ new Map()
1154
1156
  };
1155
1157
  try {
1156
1158
  const __built__ = {
@@ -1164,69 +1166,70 @@ function execute(files) {
1164
1166
  info._sourceFile = _currentFile;
1165
1167
  __built__[type + "s"].push(info);
1166
1168
  };
1167
- const actModule = { ...MODULES["@rotorsoft/act"] };
1168
- actModule.state = (entry) => MODULES["@rotorsoft/act"].state(entry, capture("state"));
1169
- actModule.slice = () => MODULES["@rotorsoft/act"].slice(capture("slice"));
1170
- actModule.projection = (target) => MODULES["@rotorsoft/act"].projection(
1169
+ const act_module = { ...MODULES["@rotorsoft/act"] };
1170
+ act_module.state = (entry) => MODULES["@rotorsoft/act"].state(entry, capture("state"));
1171
+ act_module.slice = () => MODULES["@rotorsoft/act"].slice(capture("slice"));
1172
+ act_module.projection = (target) => MODULES["@rotorsoft/act"].projection(
1171
1173
  target,
1172
1174
  capture("projection")
1173
1175
  );
1174
- actModule.act = () => MODULES["@rotorsoft/act"].act(capture("act"));
1175
- const pkgModules = {
1176
+ act_module.act = () => MODULES["@rotorsoft/act"].act(capture("act"));
1177
+ const pkg_modules = {
1176
1178
  ...MODULES,
1177
- "@rotorsoft/act": actModule
1179
+ "@rotorsoft/act": act_module
1178
1180
  };
1179
- const fileExports = /* @__PURE__ */ new Map();
1180
- const strip = (p2) => p2.replace(/\.tsx?$/, "");
1181
- const resolveModule = (mod, fromPath) => {
1182
- if (pkgModules[mod]) return pkgModules[mod];
1181
+ const file_exports = /* @__PURE__ */ new Map();
1182
+ const strip = (p) => p.replace(/\.tsx?$/, "");
1183
+ const resolve_module = (mod, from_path) => {
1184
+ if (pkg_modules[mod]) return pkg_modules[mod];
1183
1185
  if (mod.startsWith(".")) {
1184
- const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
1186
+ const dir = from_path.includes("/") ? from_path.slice(0, from_path.lastIndexOf("/")) : "";
1185
1187
  const parts = (dir ? dir + "/" + mod : mod).split("/");
1186
1188
  const resolved = [];
1187
- for (const p2 of parts) {
1188
- if (p2 === "." || p2 === "") continue;
1189
- if (p2 === "..") resolved.pop();
1190
- else resolved.push(p2);
1189
+ for (const p of parts) {
1190
+ if (p === "." || p === "") continue;
1191
+ if (p === "..") resolved.pop();
1192
+ else resolved.push(p);
1191
1193
  }
1192
1194
  const rp = resolved.join("/").replace(/\.js$/, "").replace(/\.ts$/, "");
1193
- return fileExports.get(rp) ?? fileExports.get(rp + "/index") ?? {};
1195
+ return file_exports.get(rp) ?? file_exports.get(rp + "/index") ?? {};
1194
1196
  }
1195
1197
  if (mod.startsWith("@") && !mod.startsWith("@rotorsoft/")) {
1196
- const pkgName = mod.split("/")[1];
1197
- const subPath = mod.split("/").slice(2).join("/");
1198
- if (pkgName) {
1199
- const suffix = subPath ? `/${subPath.replace(/\.js$/, "")}` : "/src/index";
1200
- return fileExports.get(`packages/${pkgName}${suffix}`) ?? fileExports.get(`${pkgName}${suffix}`) ?? fileExports.get(`packages/${pkgName}/src/index`) ?? fileExports.get(`${pkgName}/src/index`) ?? fileExports.get(`${pkgName}/index`) ?? fileExports.get(pkgName) ?? unknownModuleProxy();
1198
+ const pkg_name = mod.split("/")[1];
1199
+ const sub_path = mod.split("/").slice(2).join("/");
1200
+ if (pkg_name) {
1201
+ const suffix = sub_path ? `/${sub_path.replace(/\.js$/, "")}` : "/src/index";
1202
+ return file_exports.get(`packages/${pkg_name}${suffix}`) ?? file_exports.get(`${pkg_name}${suffix}`) ?? file_exports.get(`packages/${pkg_name}/src/index`) ?? file_exports.get(`${pkg_name}/src/index`) ?? file_exports.get(`${pkg_name}/index`) ?? file_exports.get(pkg_name) ?? unknown_module_proxy();
1201
1203
  }
1202
1204
  }
1203
- return unknownModuleProxy();
1205
+ return unknown_module_proxy();
1204
1206
  };
1205
- const sorted = topoSort(files.filter(isSourceFile));
1207
+ const sorted = topo_sort(files.filter(is_source_file));
1206
1208
  for (const file of sorted) {
1207
1209
  _currentFile = file.path;
1208
1210
  const js = transpile(file.content);
1209
1211
  const key = strip(file.path);
1210
1212
  const fileExp = {};
1211
- fileExports.set(key, fileExp);
1212
- const sliceNamesInAct = [];
1213
- const wsRe = /\.withSlice\(\s*(?:\w+\.)*(\w+)\s*\)/g;
1213
+ file_exports.set(key, fileExp);
1214
+ const slice_names_in_act = [];
1215
+ const ws_re = /\.withSlice\(\s*(?:\w+\.)*(\w+)\s*\)/g;
1214
1216
  let wsm;
1215
- const codeOnly = stripNonCode(js);
1216
- while ((wsm = wsRe.exec(codeOnly)) !== null) {
1217
- if (!sliceNamesInAct.includes(wsm[1])) sliceNamesInAct.push(wsm[1]);
1217
+ const code_only = strip_non_code(js);
1218
+ while ((wsm = ws_re.exec(code_only)) !== null) {
1219
+ if (!slice_names_in_act.includes(wsm[1]))
1220
+ slice_names_in_act.push(wsm[1]);
1218
1221
  }
1219
- for (const m2 of codeOnly.matchAll(
1222
+ for (const m of code_only.matchAll(
1220
1223
  /(?:exports\.)?(\w+)\s*=\s*(?:\w+\.)?slice(?:\s*\(\s*\)|\.call\(void 0,\s*\))/g
1221
1224
  )) {
1222
- result.expectedSlices.set(m2[1], file.path);
1225
+ result.expected_slices.set(m[1], file.path);
1223
1226
  }
1224
- const fileRequire = Object.assign(
1225
- (mod) => resolveModule(mod, key),
1227
+ const file_require = Object.assign(
1228
+ (mod) => resolve_module(mod, key),
1226
1229
  { resolve: (mod) => mod, cache: {}, main: void 0 }
1227
1230
  );
1228
1231
  try {
1229
- const cleanJs = js.replace(/\bconst\s+__dirname\b/g, "var __dirname").replace(/\bconst\s+__filename\b/g, "var __filename");
1232
+ const clean_js = js.replace(/\bconst\s+__dirname\b/g, "var __dirname").replace(/\bconst\s+__filename\b/g, "var __filename");
1230
1233
  const fn = new Function(
1231
1234
  // lgtm[js/code-injection]
1232
1235
  "require",
@@ -1239,21 +1242,21 @@ function execute(files) {
1239
1242
  var process = { env: {}, cwd: function() { return "/"; }, exit: function() {}, on: function() {}, off: function() {} };
1240
1243
  var Buffer = { from: function() { return ""; } };
1241
1244
  var console = { log: function() {}, error: function() {}, warn: function() {}, info: function() {}, debug: function() {} };
1242
- ${cleanJs}
1245
+ ${clean_js}
1243
1246
  `
1244
1247
  );
1245
- fn(fileRequire, fileExp, { exports: fileExp });
1248
+ fn(file_require, fileExp, { exports: fileExp });
1246
1249
  } catch (evalErr) {
1247
1250
  const errMsg = evalErr instanceof Error ? evalErr.message : String(evalErr);
1248
- result.fileErrors.set(file.path, errMsg);
1249
- }
1250
- if (sliceNamesInAct.length > 0) {
1251
- for (const actObj of __built__.acts) {
1252
- if (actObj._sourceFile !== file.path) continue;
1253
- const actSlices = actObj.slices;
1254
- for (let ai = 0; ai < Math.min(sliceNamesInAct.length, actSlices.length); ai++) {
1255
- if (actSlices[ai]) {
1256
- actSlices[ai]._varName = sliceNamesInAct[ai];
1251
+ result.file_errors.set(file.path, errMsg);
1252
+ }
1253
+ if (slice_names_in_act.length > 0) {
1254
+ for (const act_obj of __built__.acts) {
1255
+ if (act_obj._sourceFile !== file.path) continue;
1256
+ const act_slices = act_obj.slices;
1257
+ for (let ai = 0; ai < Math.min(slice_names_in_act.length, act_slices.length); ai++) {
1258
+ if (act_slices[ai]) {
1259
+ act_slices[ai]._varName = slice_names_in_act[ai];
1257
1260
  }
1258
1261
  }
1259
1262
  }
@@ -1263,62 +1266,62 @@ function execute(files) {
1263
1266
  result.slices = __built__.slices;
1264
1267
  result.projections = __built__.projections;
1265
1268
  result.acts = __built__.acts;
1266
- } catch (e2) {
1267
- result.error = e2 instanceof Error ? e2.message : String(e2);
1269
+ } catch (e) {
1270
+ result.error = e instanceof Error ? e.message : String(e);
1268
1271
  }
1269
1272
  return result;
1270
1273
  }
1271
- function extractModel(files) {
1274
+ function extract_model(files) {
1272
1275
  const result = execute(files);
1273
- return buildModel(result, files, result.expectedSlices);
1276
+ return build_model(result, files, result.expected_slices);
1274
1277
  }
1275
1278
 
1276
1279
  // src/cli/contract-index.ts
1277
- function decomposeEventName(name) {
1278
- const m2 = name.match(/^(.+)_v(\d+)$/);
1279
- if (m2) return { base: m2[1], version: Number.parseInt(m2[2], 10) };
1280
+ function decompose_event_name(name) {
1281
+ const m = name.match(/^(.+)_v(\d+)$/);
1282
+ if (m) return { base: m[1], version: Number.parseInt(m[2], 10) };
1280
1283
  return { base: name, version: 1 };
1281
1284
  }
1282
- function eventStatus(name, allNames) {
1283
- const me = decomposeEventName(name);
1284
- let bestVersion = me.version;
1285
- let bestName;
1286
- for (const other of allNames) {
1285
+ function event_status(name, all_names) {
1286
+ const me = decompose_event_name(name);
1287
+ let best_version = me.version;
1288
+ let best_name;
1289
+ for (const other of all_names) {
1287
1290
  if (other === name) continue;
1288
- const dec = decomposeEventName(other);
1289
- if (dec.base === me.base && dec.version > bestVersion) {
1290
- bestVersion = dec.version;
1291
- bestName = other;
1291
+ const dec = decompose_event_name(other);
1292
+ if (dec.base === me.base && dec.version > best_version) {
1293
+ best_version = dec.version;
1294
+ best_name = other;
1292
1295
  }
1293
1296
  }
1294
- return bestName ? { status: "deprecated", supersededBy: bestName } : { status: "active" };
1297
+ return best_name ? { status: "deprecated", superseded_by: best_name } : { status: "active" };
1295
1298
  }
1296
- function buildContractIndex(model) {
1299
+ function build_contract_index(model) {
1297
1300
  const entries = [];
1298
- const allEventNames = /* @__PURE__ */ new Set();
1299
- for (const st2 of model.states) {
1301
+ const all_event_names = /* @__PURE__ */ new Set();
1302
+ for (const st of model.states) {
1300
1303
  entries.push({
1301
1304
  kind: "state",
1302
- name: st2.name,
1303
- file: st2.file,
1304
- line: st2.line
1305
+ name: st.name,
1306
+ file: st.file,
1307
+ line: st.line
1305
1308
  });
1306
- for (const ev of st2.events) {
1307
- allEventNames.add(ev.name);
1309
+ for (const ev of st.events) {
1310
+ all_event_names.add(ev.name);
1308
1311
  entries.push({
1309
1312
  kind: "event",
1310
1313
  name: ev.name,
1311
- qualifier: st2.name,
1312
- file: st2.file,
1314
+ qualifier: st.name,
1315
+ file: st.file,
1313
1316
  line: ev.line
1314
1317
  });
1315
1318
  }
1316
- for (const act of st2.actions) {
1319
+ for (const act of st.actions) {
1317
1320
  entries.push({
1318
1321
  kind: "action",
1319
1322
  name: act.name,
1320
- qualifier: st2.name,
1321
- file: st2.file,
1323
+ qualifier: st.name,
1324
+ file: st.file,
1322
1325
  line: act.line
1323
1326
  });
1324
1327
  }
@@ -1330,14 +1333,14 @@ function buildContractIndex(model) {
1330
1333
  file: sl.file,
1331
1334
  line: sl.line
1332
1335
  });
1333
- for (const r of sl.reactions) {
1334
- allEventNames.add(r.event);
1336
+ for (const r2 of sl.reactions) {
1337
+ all_event_names.add(r2.event);
1335
1338
  entries.push({
1336
1339
  kind: "reaction",
1337
- name: r.handlerName,
1338
- qualifier: `${sl.name}::${r.event}`,
1339
- file: r.file ?? sl.file,
1340
- line: r.line
1340
+ name: r2.handlerName,
1341
+ qualifier: `${sl.name}::${r2.event}`,
1342
+ file: r2.file ?? sl.file,
1343
+ line: r2.line
1341
1344
  });
1342
1345
  }
1343
1346
  }
@@ -1348,19 +1351,19 @@ function buildContractIndex(model) {
1348
1351
  file: pr.file,
1349
1352
  line: pr.line
1350
1353
  });
1351
- for (const ev of pr.handles) allEventNames.add(ev);
1354
+ for (const ev of pr.handles) all_event_names.add(ev);
1352
1355
  }
1353
- for (const r of model.reactions) {
1354
- allEventNames.add(r.event);
1356
+ for (const r2 of model.reactions) {
1357
+ all_event_names.add(r2.event);
1355
1358
  entries.push({
1356
1359
  kind: "reaction",
1357
- name: r.handlerName,
1358
- qualifier: `*::${r.event}`,
1359
- file: r.file,
1360
- line: r.line
1360
+ name: r2.handlerName,
1361
+ qualifier: `*::${r2.event}`,
1362
+ file: r2.file,
1363
+ line: r2.line
1361
1364
  });
1362
1365
  }
1363
- return { entries, model, allEventNames };
1366
+ return { entries, model, all_event_names };
1364
1367
  }
1365
1368
  var CATEGORY_KEYWORDS = {
1366
1369
  event: "event",
@@ -1376,27 +1379,27 @@ var CATEGORY_KEYWORDS = {
1376
1379
  reaction: "reaction",
1377
1380
  reactions: "reaction"
1378
1381
  };
1379
- function listByKind(idx, kind) {
1380
- return idx.entries.filter((e2) => e2.kind === kind).sort((a, b2) => a.name.localeCompare(b2.name));
1382
+ function list_by_kind(idx, kind) {
1383
+ return idx.entries.filter((e) => e.kind === kind).sort((a2, b) => a2.name.localeCompare(b.name));
1381
1384
  }
1382
1385
  function search(idx, query, limit = 20) {
1383
- const q2 = query.trim().toLowerCase();
1384
- if (!q2) return [];
1386
+ const q = query.trim().toLowerCase();
1387
+ if (!q) return [];
1385
1388
  const scored = [];
1386
1389
  for (const entry of idx.entries) {
1387
1390
  const name = entry.name.toLowerCase();
1388
1391
  let score;
1389
- if (name === q2) score = 0;
1390
- else if (name.startsWith(q2)) score = 1;
1391
- else if (name.includes(q2)) score = 2;
1392
+ if (name === q) score = 0;
1393
+ else if (name.startsWith(q)) score = 1;
1394
+ else if (name.includes(q)) score = 2;
1392
1395
  else continue;
1393
1396
  scored.push({ entry, score });
1394
1397
  }
1395
- scored.sort((a, b2) => {
1396
- if (a.score !== b2.score) return a.score - b2.score;
1397
- if (a.entry.kind !== b2.entry.kind)
1398
- return a.entry.kind.localeCompare(b2.entry.kind);
1399
- return a.entry.name.localeCompare(b2.entry.name);
1398
+ scored.sort((a2, b) => {
1399
+ if (a2.score !== b.score) return a2.score - b.score;
1400
+ if (a2.entry.kind !== b.entry.kind)
1401
+ return a2.entry.kind.localeCompare(b.entry.kind);
1402
+ return a2.entry.name.localeCompare(b.entry.name);
1400
1403
  });
1401
1404
  return scored.slice(0, limit).map((s) => s.entry);
1402
1405
  }
@@ -1419,7 +1422,7 @@ var violet = (s) => ext(141, s);
1419
1422
  var emerald = (s) => ext(41, s);
1420
1423
  var fuchsia = (s) => ext(207, s);
1421
1424
  var pink = cornflower;
1422
- var kindColor = {
1425
+ var kind_color = {
1423
1426
  event: orange,
1424
1427
  action: cornflower,
1425
1428
  state: amber,
@@ -1433,36 +1436,36 @@ var loc = (file, line) => {
1433
1436
  if (!file) return "";
1434
1437
  return line ? `${file}:${line}` : file;
1435
1438
  };
1436
- var fileNote = (file, line) => {
1437
- const l = loc(file, line);
1438
- return l ? ` ${dim(l)}` : "";
1439
+ var file_note = (file, line) => {
1440
+ const l2 = loc(file, line);
1441
+ return l2 ? ` ${dim(l2)}` : "";
1439
1442
  };
1440
- var kindLabel = (kind) => {
1441
- const k2 = kindColor[kind];
1442
- return (k2 ?? dim)(kind.padEnd(10));
1443
+ var kind_label = (kind) => {
1444
+ const k = kind_color[kind];
1445
+ return (k ?? dim)(kind.padEnd(10));
1443
1446
  };
1444
- function formatMatches(query, matches2) {
1447
+ function format_matches(query, matches2) {
1445
1448
  if (matches2.length === 0) return dim(`no matches for "${query}"`);
1446
1449
  const head = dim(`matches (${matches2.length}) \u2014 type a number to pick:`);
1447
1450
  const width = String(matches2.length).length;
1448
- const lines = matches2.map((m2, i) => {
1449
- const idx = dim(`[${String(i + 1).padStart(width)}]`);
1450
- const where = loc(m2.file, m2.line);
1451
- const q2 = m2.qualifier ? dim(` (${m2.qualifier})`) : "";
1452
- const w3 = where ? ` ${dim(where)}` : "";
1453
- return ` ${idx} ${kindLabel(m2.kind)} ${m2.name}${q2}${w3}`;
1451
+ const lines = matches2.map((m, i2) => {
1452
+ const idx = dim(`[${String(i2 + 1).padStart(width)}]`);
1453
+ const where = loc(m.file, m.line);
1454
+ const q = m.qualifier ? dim(` (${m.qualifier})`) : "";
1455
+ const w = where ? ` ${dim(where)}` : "";
1456
+ return ` ${idx} ${kind_label(m.kind)} ${m.name}${q}${w}`;
1454
1457
  });
1455
1458
  return [head, ...lines].join("\n");
1456
1459
  }
1457
- var findActionsEmitting = (model, eventName) => {
1460
+ var find_actions_emitting = (model, event_name) => {
1458
1461
  const out = [];
1459
- for (const st2 of model.states) {
1460
- for (const act of st2.actions) {
1461
- if (act.emits.includes(eventName)) {
1462
+ for (const st of model.states) {
1463
+ for (const act of st.actions) {
1464
+ if (act.emits.includes(event_name)) {
1462
1465
  out.push({
1463
- state: st2.name,
1466
+ state: st.name,
1464
1467
  action: act.name,
1465
- file: st2.file,
1468
+ file: st.file,
1466
1469
  line: act.line
1467
1470
  });
1468
1471
  }
@@ -1470,108 +1473,110 @@ var findActionsEmitting = (model, eventName) => {
1470
1473
  }
1471
1474
  return out;
1472
1475
  };
1473
- var findReactionsFor = (model, eventName) => {
1476
+ var find_reactions_for = (model, event_name) => {
1474
1477
  const out = [];
1475
1478
  for (const sl of model.slices) {
1476
- for (const r of sl.reactions) {
1477
- if (r.event === eventName) {
1479
+ for (const r2 of sl.reactions) {
1480
+ if (r2.event === event_name) {
1478
1481
  out.push({
1479
1482
  slice: sl.name,
1480
- handler: r.handlerName,
1481
- dispatches: r.dispatches,
1482
- file: r.file ?? sl.file,
1483
- line: r.line
1483
+ handler: r2.handlerName,
1484
+ dispatches: r2.dispatches,
1485
+ file: r2.file ?? sl.file,
1486
+ line: r2.line
1484
1487
  });
1485
1488
  }
1486
1489
  }
1487
1490
  }
1488
- for (const r of model.reactions) {
1489
- if (r.event === eventName) {
1491
+ for (const r2 of model.reactions) {
1492
+ if (r2.event === event_name) {
1490
1493
  out.push({
1491
- handler: r.handlerName,
1492
- dispatches: r.dispatches,
1493
- file: r.file,
1494
- line: r.line
1494
+ handler: r2.handlerName,
1495
+ dispatches: r2.dispatches,
1496
+ file: r2.file,
1497
+ line: r2.line
1495
1498
  });
1496
1499
  }
1497
1500
  }
1498
1501
  return out;
1499
1502
  };
1500
- var findProjectionsFor = (model, eventName) => model.projections.filter((p2) => p2.handles.includes(eventName)).map((p2) => ({ name: p2.name, file: p2.file }));
1501
- function formatEvent(idx, entry) {
1503
+ var find_projections_for = (model, event_name) => model.projections.filter((p) => p.handles.includes(event_name)).map((p) => ({ name: p.name, file: p.file }));
1504
+ function format_event(idx, entry) {
1502
1505
  const model = idx.model;
1503
1506
  let schema;
1504
- let owningState;
1505
- for (const st2 of model.states) {
1506
- const ev = st2.events.find((e2) => e2.name === entry.name);
1507
+ let owning_state;
1508
+ for (const st of model.states) {
1509
+ const ev = st.events.find((e) => e.name === entry.name);
1507
1510
  if (ev) {
1508
1511
  schema = ev.schema;
1509
- owningState = { name: st2.name, file: st2.file };
1512
+ owning_state = { name: st.name, file: st.file };
1510
1513
  break;
1511
1514
  }
1512
1515
  }
1513
- const file = entry.file ?? owningState?.file;
1514
- const status = eventStatus(entry.name, idx.allEventNames);
1515
- const statusLine = status.status === "active" ? green("active") : (
1516
- // `supersededBy` is always set on deprecated entries — see eventStatus.
1517
- `${red("deprecated")} (superseded by ${orange(status.supersededBy)})`
1516
+ const file = entry.file ?? owning_state?.file;
1517
+ const status = event_status(entry.name, idx.all_event_names);
1518
+ const status_line = status.status === "active" ? green("active") : (
1519
+ // `superseded_by` is always set on deprecated entries — see event_status.
1520
+ `${red("deprecated")} (superseded by ${orange(status.superseded_by)})`
1518
1521
  );
1519
1522
  const lines = [];
1520
1523
  lines.push(bold(orange(entry.name)));
1521
1524
  if (file) lines.push(` in: ${dim(loc(file, entry.line))}`);
1522
- if (owningState && owningState.name !== entry.name)
1523
- lines.push(` on: ${amber(owningState.name)}`);
1525
+ if (owning_state && owning_state.name !== entry.name)
1526
+ lines.push(` on: ${amber(owning_state.name)}`);
1524
1527
  lines.push(` schema: ${schema ?? dim("(not captured)")}`);
1525
- lines.push(` status: ${statusLine}`);
1526
- const producers = findActionsEmitting(model, entry.name);
1528
+ lines.push(` status: ${status_line}`);
1529
+ const producers = find_actions_emitting(model, entry.name);
1527
1530
  if (producers.length > 0) {
1528
1531
  lines.push(" producers:");
1529
- for (const p2 of producers) {
1532
+ for (const p of producers) {
1530
1533
  lines.push(
1531
- ` - ${pink(p2.action)} ${dim(`(on ${p2.state})`)}${fileNote(p2.file, p2.line)}`
1534
+ ` - ${pink(p.action)} ${dim(`(on ${p.state})`)}${file_note(p.file, p.line)}`
1532
1535
  );
1533
1536
  }
1534
1537
  } else {
1535
1538
  lines.push(` producers: ${dim("(none)")}`);
1536
1539
  }
1537
- const reactions = findReactionsFor(model, entry.name);
1538
- const projections = findProjectionsFor(model, entry.name);
1540
+ const reactions = find_reactions_for(model, entry.name);
1541
+ const projections = find_projections_for(model, entry.name);
1539
1542
  if (reactions.length === 0 && projections.length === 0) {
1540
1543
  lines.push(` consumers: ${dim("(none)")}`);
1541
1544
  } else {
1542
1545
  lines.push(" consumers:");
1543
- for (const r of reactions) {
1544
- const slice = r.slice ? `${violet(r.slice)}${dim("::")}` : "";
1545
- const triggers = r.dispatches.length > 0 ? ` \u2192 ${r.dispatches.map((d) => pink(d)).join(", ")}` : "";
1546
+ for (const r2 of reactions) {
1547
+ const slice = r2.slice ? `${violet(r2.slice)}${dim("::")}` : "";
1548
+ const triggers = r2.dispatches.length > 0 ? ` \u2192 ${r2.dispatches.map((d) => pink(d)).join(", ")}` : "";
1546
1549
  lines.push(
1547
- ` - ${slice}${fuchsia(r.handler)}${triggers}${fileNote(r.file, r.line)}`
1550
+ ` - ${slice}${fuchsia(r2.handler)}${triggers}${file_note(r2.file, r2.line)}`
1548
1551
  );
1549
1552
  }
1550
- for (const p2 of projections) {
1551
- lines.push(` - ${emerald(p2.name)}${fileNote(p2.file)}`);
1553
+ for (const p of projections) {
1554
+ lines.push(` - ${emerald(p.name)}${file_note(p.file)}`);
1552
1555
  }
1553
1556
  }
1554
1557
  return lines.join("\n");
1555
1558
  }
1556
- function formatAction(idx, entry) {
1559
+ function format_action(idx, entry) {
1557
1560
  const model = idx.model;
1558
- const ownerName = entry.qualifier;
1561
+ const owner_name = entry.qualifier;
1559
1562
  let action;
1560
- let stateFile;
1561
- for (const st2 of model.states) {
1562
- if (ownerName && st2.name !== ownerName) continue;
1563
- const a = st2.actions.find((x3) => x3.name === entry.name);
1564
- if (a) {
1565
- action = a;
1566
- stateFile = st2.file;
1563
+ let state_file;
1564
+ for (const st of model.states) {
1565
+ if (owner_name && st.name !== owner_name) continue;
1566
+ const a2 = st.actions.find((x) => x.name === entry.name);
1567
+ if (a2) {
1568
+ action = a2;
1569
+ state_file = st.file;
1567
1570
  break;
1568
1571
  }
1569
1572
  }
1570
1573
  const lines = [];
1571
1574
  lines.push(bold(pink(entry.name)));
1572
- if (ownerName) lines.push(` on: ${amber(ownerName)}`);
1573
- if (stateFile)
1574
- lines.push(` in: ${dim(loc(stateFile, action?.line ?? entry.line))}`);
1575
+ if (owner_name) lines.push(` on: ${amber(owner_name)}`);
1576
+ if (state_file)
1577
+ lines.push(
1578
+ ` in: ${dim(loc(state_file, action?.line ?? entry.line))}`
1579
+ );
1575
1580
  if (action) {
1576
1581
  if (action.invariants.length > 0) {
1577
1582
  lines.push(" invariants:");
@@ -1579,36 +1584,36 @@ function formatAction(idx, entry) {
1579
1584
  }
1580
1585
  if (action.emits.length > 0) {
1581
1586
  lines.push(" emits:");
1582
- for (const e2 of action.emits) lines.push(` - ${orange(e2)}`);
1587
+ for (const e of action.emits) lines.push(` - ${orange(e)}`);
1583
1588
  } else {
1584
1589
  lines.push(` emits: ${dim("(none)")}`);
1585
1590
  }
1586
1591
  }
1587
1592
  return lines.join("\n");
1588
1593
  }
1589
- function formatState(idx, entry) {
1590
- const st2 = idx.model.states.find((s) => s.name === entry.name);
1594
+ function format_state(idx, entry) {
1595
+ const st = idx.model.states.find((s) => s.name === entry.name);
1591
1596
  const lines = [];
1592
1597
  lines.push(bold(amber(entry.name)));
1593
1598
  if (entry.file) lines.push(` in: ${dim(loc(entry.file, entry.line))}`);
1594
- if (!st2) return lines.join("\n");
1595
- if (st2.actions.length > 0) {
1599
+ if (!st) return lines.join("\n");
1600
+ if (st.actions.length > 0) {
1596
1601
  lines.push(" actions:");
1597
- for (const a of st2.actions) {
1598
- const emits = a.emits.length > 0 ? ` \u2192 ${a.emits.join(", ")}` : "";
1599
- lines.push(` - ${pink(a.name)}${emits}`);
1602
+ for (const a2 of st.actions) {
1603
+ const emits = a2.emits.length > 0 ? ` \u2192 ${a2.emits.join(", ")}` : "";
1604
+ lines.push(` - ${pink(a2.name)}${emits}`);
1600
1605
  }
1601
1606
  }
1602
- if (st2.events.length > 0) {
1607
+ if (st.events.length > 0) {
1603
1608
  lines.push(" events:");
1604
- for (const e2 of st2.events) {
1605
- const schema = e2.schema ? ` ${dim(e2.schema)}` : "";
1606
- lines.push(` - ${orange(e2.name)}${schema}`);
1609
+ for (const e of st.events) {
1610
+ const schema = e.schema ? ` ${dim(e.schema)}` : "";
1611
+ lines.push(` - ${orange(e.name)}${schema}`);
1607
1612
  }
1608
1613
  }
1609
1614
  return lines.join("\n");
1610
1615
  }
1611
- function formatSlice(idx, entry) {
1616
+ function format_slice(idx, entry) {
1612
1617
  const sl = idx.model.slices.find((s) => s.name === entry.name);
1613
1618
  const lines = [];
1614
1619
  lines.push(bold(violet(entry.name)));
@@ -1621,21 +1626,21 @@ function formatSlice(idx, entry) {
1621
1626
  }
1622
1627
  if (sl.projections.length > 0) {
1623
1628
  lines.push(" projections:");
1624
- for (const p2 of sl.projections) lines.push(` - ${emerald(p2)}`);
1629
+ for (const p of sl.projections) lines.push(` - ${emerald(p)}`);
1625
1630
  }
1626
1631
  if (sl.reactions.length > 0) {
1627
1632
  lines.push(" reactions:");
1628
- for (const r of sl.reactions) {
1629
- const triggers = r.dispatches.length > 0 ? ` \u2192 ${r.dispatches.map((d) => pink(d)).join(", ")}` : "";
1633
+ for (const r2 of sl.reactions) {
1634
+ const triggers = r2.dispatches.length > 0 ? ` \u2192 ${r2.dispatches.map((d) => pink(d)).join(", ")}` : "";
1630
1635
  lines.push(
1631
- ` - ${orange(r.event)} \u2192 ${fuchsia(r.handlerName)}${triggers}${fileNote(r.file, r.line)}`
1636
+ ` - ${orange(r2.event)} \u2192 ${fuchsia(r2.handlerName)}${triggers}${file_note(r2.file, r2.line)}`
1632
1637
  );
1633
1638
  }
1634
1639
  }
1635
1640
  return lines.join("\n");
1636
1641
  }
1637
- function formatProjection(idx, entry) {
1638
- const pr = idx.model.projections.find((p2) => p2.name === entry.name);
1642
+ function format_projection(idx, entry) {
1643
+ const pr = idx.model.projections.find((p) => p.name === entry.name);
1639
1644
  const lines = [];
1640
1645
  lines.push(bold(emerald(entry.name)));
1641
1646
  if (pr?.file) lines.push(` in: ${dim(loc(pr.file, pr.line))}`);
@@ -1646,72 +1651,72 @@ function formatProjection(idx, entry) {
1646
1651
  }
1647
1652
  return lines.join("\n");
1648
1653
  }
1649
- function formatReaction(idx, entry) {
1650
- const [sliceName, eventName] = (entry.qualifier ?? "::").split("::");
1654
+ function format_reaction(idx, entry) {
1655
+ const [slice_name, event_name] = (entry.qualifier ?? "::").split("::");
1651
1656
  const lines = [];
1652
- const slice = sliceName && sliceName !== "*" ? violet(sliceName) : "";
1657
+ const slice = slice_name && slice_name !== "*" ? violet(slice_name) : "";
1653
1658
  const header = slice ? `${bold(fuchsia(entry.name))} ${dim(`(in ${slice})`)}` : bold(fuchsia(entry.name));
1654
1659
  lines.push(header);
1655
- if (eventName) lines.push(` on: ${orange(eventName)}`);
1660
+ if (event_name) lines.push(` on: ${orange(event_name)}`);
1656
1661
  if (entry.file) lines.push(` in: ${dim(loc(entry.file, entry.line))}`);
1657
- const sliceReaction = idx.model.slices.find((s) => s.name === sliceName)?.reactions.find(
1658
- (r2) => r2.handlerName === entry.name && r2.event === eventName
1662
+ const slice_reaction = idx.model.slices.find((s) => s.name === slice_name)?.reactions.find(
1663
+ (r3) => r3.handlerName === entry.name && r3.event === event_name
1659
1664
  );
1660
- const orchReaction = idx.model.reactions.find(
1661
- (r2) => r2.handlerName === entry.name && r2.event === eventName
1665
+ const orch_reaction = idx.model.reactions.find(
1666
+ (r3) => r3.handlerName === entry.name && r3.event === event_name
1662
1667
  );
1663
- const r = sliceReaction ?? orchReaction;
1664
- if (eventName) {
1665
- const producers = findActionsEmitting(idx.model, eventName);
1668
+ const r2 = slice_reaction ?? orch_reaction;
1669
+ if (event_name) {
1670
+ const producers = find_actions_emitting(idx.model, event_name);
1666
1671
  if (producers.length > 0) {
1667
1672
  lines.push(" producers (of triggering event):");
1668
- for (const p2 of producers) {
1673
+ for (const p of producers) {
1669
1674
  lines.push(
1670
- ` - action ${pink(p2.action)} (state ${p2.state})${fileNote(p2.file, p2.line)}`
1675
+ ` - action ${pink(p.action)} (state ${p.state})${file_note(p.file, p.line)}`
1671
1676
  );
1672
1677
  }
1673
1678
  }
1674
1679
  }
1675
- if (r && r.dispatches.length > 0) {
1680
+ if (r2 && r2.dispatches.length > 0) {
1676
1681
  lines.push(" triggers:");
1677
- for (const d of r.dispatches) lines.push(` - action ${pink(d)}`);
1682
+ for (const d of r2.dispatches) lines.push(` - action ${pink(d)}`);
1678
1683
  }
1679
1684
  return lines.join("\n");
1680
1685
  }
1681
1686
  var formatters = {
1682
- event: formatEvent,
1683
- action: formatAction,
1684
- state: formatState,
1685
- slice: formatSlice,
1686
- projection: formatProjection,
1687
- reaction: formatReaction
1687
+ event: format_event,
1688
+ action: format_action,
1689
+ state: format_state,
1690
+ slice: format_slice,
1691
+ projection: format_projection,
1692
+ reaction: format_reaction
1688
1693
  };
1689
- function formatDetail(idx, entry) {
1694
+ function format_detail(idx, entry) {
1690
1695
  const fmt = formatters[entry.kind];
1691
1696
  return fmt ? fmt(idx, entry) : "";
1692
1697
  }
1693
- function formatSummary(idx) {
1694
- const m2 = idx.model;
1698
+ function format_summary(idx) {
1699
+ const m = idx.model;
1695
1700
  const parts = [
1696
- `${m2.states.length} ${m2.states.length === 1 ? "state" : "states"}`,
1697
- `${m2.slices.length} ${m2.slices.length === 1 ? "slice" : "slices"}`,
1698
- `${m2.projections.length} ${m2.projections.length === 1 ? "projection" : "projections"}`,
1699
- `${idx.allEventNames.size} ${idx.allEventNames.size === 1 ? "event" : "events"}`
1701
+ `${m.states.length} ${m.states.length === 1 ? "state" : "states"}`,
1702
+ `${m.slices.length} ${m.slices.length === 1 ? "slice" : "slices"}`,
1703
+ `${m.projections.length} ${m.projections.length === 1 ? "projection" : "projections"}`,
1704
+ `${idx.all_event_names.size} ${idx.all_event_names.size === 1 ? "event" : "events"}`
1700
1705
  ];
1701
1706
  return dim(`loaded ${parts.join(", ")}`);
1702
1707
  }
1703
1708
 
1704
1709
  // src/cli/json-schema.ts
1705
1710
  import { z as z2 } from "zod";
1706
- var findProducers = (model, eventName) => {
1711
+ var find_producers = (model, event_name) => {
1707
1712
  const out = [];
1708
- for (const st2 of model.states) {
1709
- for (const act of st2.actions) {
1710
- if (act.emits.includes(eventName)) {
1713
+ for (const st of model.states) {
1714
+ for (const act of st.actions) {
1715
+ if (act.emits.includes(event_name)) {
1711
1716
  out.push({
1712
1717
  action: act.name,
1713
- state: st2.name,
1714
- file: st2.file,
1718
+ state: st.name,
1719
+ file: st.file,
1715
1720
  line: act.line
1716
1721
  });
1717
1722
  }
@@ -1719,36 +1724,36 @@ var findProducers = (model, eventName) => {
1719
1724
  }
1720
1725
  return out;
1721
1726
  };
1722
- var findConsumers = (model, eventName) => {
1727
+ var find_consumers = (model, event_name) => {
1723
1728
  const out = [];
1724
1729
  for (const sl of model.slices) {
1725
- for (const r of sl.reactions) {
1726
- if (r.event === eventName) {
1730
+ for (const r2 of sl.reactions) {
1731
+ if (r2.event === event_name) {
1727
1732
  out.push({
1728
1733
  type: "reaction",
1729
1734
  slice: sl.name,
1730
- handler: r.handlerName,
1731
- dispatches: r.dispatches,
1732
- file: r.file ?? sl.file,
1733
- line: r.line
1735
+ handler: r2.handlerName,
1736
+ dispatches: r2.dispatches,
1737
+ file: r2.file ?? sl.file,
1738
+ line: r2.line
1734
1739
  });
1735
1740
  }
1736
1741
  }
1737
1742
  }
1738
- for (const r of model.reactions) {
1739
- if (r.event === eventName) {
1743
+ for (const r2 of model.reactions) {
1744
+ if (r2.event === event_name) {
1740
1745
  out.push({
1741
1746
  type: "reaction",
1742
- handler: r.handlerName,
1743
- dispatches: r.dispatches,
1744
- file: r.file,
1745
- line: r.line
1747
+ handler: r2.handlerName,
1748
+ dispatches: r2.dispatches,
1749
+ file: r2.file,
1750
+ line: r2.line
1746
1751
  });
1747
1752
  }
1748
1753
  }
1749
- for (const p2 of model.projections) {
1750
- if (p2.handles.includes(eventName)) {
1751
- out.push({ type: "projection", name: p2.name, file: p2.file });
1754
+ for (const p of model.projections) {
1755
+ if (p.handles.includes(event_name)) {
1756
+ out.push({ type: "projection", name: p.name, file: p.file });
1752
1757
  }
1753
1758
  }
1754
1759
  return out;
@@ -1764,37 +1769,37 @@ function toJsonSchemaSafe(zod) {
1764
1769
  return { error: err instanceof Error ? err.message : String(err) };
1765
1770
  }
1766
1771
  }
1767
- function formatJsonSchema(idx) {
1768
- const m2 = idx.model;
1772
+ function format_json_schema(idx) {
1773
+ const m = idx.model;
1769
1774
  const events = {};
1770
- for (const st2 of m2.states) {
1771
- for (const ev of st2.events) {
1772
- const status = eventStatus(ev.name, idx.allEventNames);
1775
+ for (const st of m.states) {
1776
+ for (const ev of st.events) {
1777
+ const status = event_status(ev.name, idx.all_event_names);
1773
1778
  const conv = toJsonSchemaSafe(ev.zod);
1774
1779
  const report = {
1775
1780
  name: ev.name,
1776
- file: st2.file,
1781
+ file: st.file,
1777
1782
  line: ev.line,
1778
1783
  status: status.status,
1779
- supersededBy: status.supersededBy,
1780
- schemaText: ev.schema,
1781
- producers: findProducers(m2, ev.name),
1782
- consumers: findConsumers(m2, ev.name)
1784
+ superseded_by: status.superseded_by,
1785
+ schema_text: ev.schema,
1786
+ producers: find_producers(m, ev.name),
1787
+ consumers: find_consumers(m, ev.name)
1783
1788
  };
1784
1789
  if ("schema" in conv) report.schema = conv.schema;
1785
- else report.schemaError = conv.error;
1790
+ else report.schema_error = conv.error;
1786
1791
  events[ev.name] = report;
1787
1792
  }
1788
1793
  }
1789
1794
  const out = {
1790
1795
  $schema: "https://json-schema.org/draft/2020-12/schema",
1791
1796
  generator: "act-diagram/act-contracts",
1792
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1797
+ generated_at: (/* @__PURE__ */ new Date()).toISOString(),
1793
1798
  counts: {
1794
- states: m2.states.length,
1795
- slices: m2.slices.length,
1796
- projections: m2.projections.length,
1797
- events: idx.allEventNames.size
1799
+ states: m.states.length,
1800
+ slices: m.slices.length,
1801
+ projections: m.projections.length,
1802
+ events: idx.all_event_names.size
1798
1803
  },
1799
1804
  events
1800
1805
  };
@@ -1828,14 +1833,14 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
1828
1833
  "scripts"
1829
1834
  ]);
1830
1835
  var SKIP_FILE_RE = /\.(?:d\.ts|tsx|test\.ts|spec\.ts|bench\.ts|perf\.ts)$/;
1831
- async function loadProject(rootDir, opts = {}) {
1832
- const max = opts.maxFiles ?? 5e3;
1836
+ async function load_project(root_dir, opts = {}) {
1837
+ const max = opts.max_files ?? 5e3;
1833
1838
  const files = [];
1834
1839
  let truncated = false;
1835
- const visit = async (absDir, relDir) => {
1840
+ const visit = async (abs_dir, rel_dir) => {
1836
1841
  let entries;
1837
1842
  try {
1838
- entries = await readdir(absDir, { withFileTypes: true });
1843
+ entries = await readdir(abs_dir, { withFileTypes: true });
1839
1844
  } catch {
1840
1845
  return;
1841
1846
  }
@@ -1846,28 +1851,28 @@ async function loadProject(rootDir, opts = {}) {
1846
1851
  }
1847
1852
  const name = entry.name;
1848
1853
  if (name.startsWith(".") && name !== ".") continue;
1849
- const absPath = posix.join(absDir.replace(/\\/g, "/"), name);
1850
- const relPath = relDir ? posix.join(relDir, name) : name;
1854
+ const abs_path = posix.join(abs_dir.replace(/\\/g, "/"), name);
1855
+ const rel_path = rel_dir ? posix.join(rel_dir, name) : name;
1851
1856
  if (entry.isDirectory()) {
1852
1857
  if (SKIP_DIRS.has(name)) continue;
1853
- await visit(absPath, relPath);
1858
+ await visit(abs_path, rel_path);
1854
1859
  continue;
1855
1860
  }
1856
1861
  if (!entry.isFile()) continue;
1857
1862
  if (!name.endsWith(".ts")) continue;
1858
1863
  if (SKIP_FILE_RE.test(name)) continue;
1859
1864
  try {
1860
- const content = await readFile(absPath, "utf8");
1861
- files.push({ path: relPath, content });
1865
+ const content = await readFile(abs_path, "utf8");
1866
+ files.push({ path: rel_path, content });
1862
1867
  } catch {
1863
1868
  }
1864
1869
  }
1865
1870
  };
1866
- const rootStat = await stat(rootDir).catch(() => null);
1867
- if (!rootStat || !rootStat.isDirectory()) {
1871
+ const root_stat = await stat(root_dir).catch(() => null);
1872
+ if (!root_stat || !root_stat.isDirectory()) {
1868
1873
  return { files, truncated };
1869
1874
  }
1870
- await visit(rootDir.replace(/\\/g, "/"), "");
1875
+ await visit(root_dir.replace(/\\/g, "/"), "");
1871
1876
  return { files, truncated };
1872
1877
  }
1873
1878
 
@@ -1876,15 +1881,15 @@ var loc2 = (file, line) => {
1876
1881
  if (!file) return "";
1877
1882
  return line ? `${file}:${line}` : file;
1878
1883
  };
1879
- var findActionsEmitting2 = (model, eventName) => {
1884
+ var find_actions_emitting2 = (model, event_name) => {
1880
1885
  const out = [];
1881
- for (const st2 of model.states) {
1882
- for (const act of st2.actions) {
1883
- if (act.emits.includes(eventName)) {
1886
+ for (const st of model.states) {
1887
+ for (const act of st.actions) {
1888
+ if (act.emits.includes(event_name)) {
1884
1889
  out.push({
1885
- state: st2.name,
1890
+ state: st.name,
1886
1891
  action: act.name,
1887
- file: st2.file,
1892
+ file: st.file,
1888
1893
  line: act.line
1889
1894
  });
1890
1895
  }
@@ -1892,129 +1897,129 @@ var findActionsEmitting2 = (model, eventName) => {
1892
1897
  }
1893
1898
  return out;
1894
1899
  };
1895
- var findReactionsFor2 = (model, eventName) => {
1900
+ var find_reactions_for2 = (model, event_name) => {
1896
1901
  const out = [];
1897
1902
  for (const sl of model.slices) {
1898
- for (const r of sl.reactions) {
1899
- if (r.event === eventName) {
1903
+ for (const r2 of sl.reactions) {
1904
+ if (r2.event === event_name) {
1900
1905
  out.push({
1901
1906
  slice: sl.name,
1902
- handler: r.handlerName,
1903
- dispatches: r.dispatches,
1904
- file: r.file ?? sl.file,
1905
- line: r.line
1907
+ handler: r2.handlerName,
1908
+ dispatches: r2.dispatches,
1909
+ file: r2.file ?? sl.file,
1910
+ line: r2.line
1906
1911
  });
1907
1912
  }
1908
1913
  }
1909
1914
  }
1910
- for (const r of model.reactions) {
1911
- if (r.event === eventName) {
1915
+ for (const r2 of model.reactions) {
1916
+ if (r2.event === event_name) {
1912
1917
  out.push({
1913
- handler: r.handlerName,
1914
- dispatches: r.dispatches,
1915
- file: r.file,
1916
- line: r.line
1918
+ handler: r2.handlerName,
1919
+ dispatches: r2.dispatches,
1920
+ file: r2.file,
1921
+ line: r2.line
1917
1922
  });
1918
1923
  }
1919
1924
  }
1920
1925
  return out;
1921
1926
  };
1922
- var findProjectionsFor2 = (model, eventName) => model.projections.filter((p2) => p2.handles.includes(eventName)).map((p2) => ({ name: p2.name, file: p2.file }));
1923
- var fileSuffix = (file, line) => {
1924
- const l = loc2(file, line);
1925
- return l ? ` *(${l})*` : "";
1927
+ var find_projections_for2 = (model, event_name) => model.projections.filter((p) => p.handles.includes(event_name)).map((p) => ({ name: p.name, file: p.file }));
1928
+ var file_suffix = (file, line) => {
1929
+ const l2 = loc2(file, line);
1930
+ return l2 ? ` *(${l2})*` : "";
1926
1931
  };
1927
- var renderSchema = (s) => {
1932
+ var render_schema = (s) => {
1928
1933
  if (!s) return "_(not captured)_";
1929
1934
  if (!s.includes("\n")) return `\`${s}\``;
1930
- const indented = s.split("\n").map((l) => ` ${l}`).join("\n");
1935
+ const indented = s.split("\n").map((l2) => ` ${l2}`).join("\n");
1931
1936
  return `
1932
1937
 
1933
1938
  \`\`\`ts
1934
1939
  ${indented}
1935
1940
  \`\`\``;
1936
1941
  };
1937
- function formatMarkdown(idx) {
1938
- const m2 = idx.model;
1942
+ function format_markdown(idx) {
1943
+ const m = idx.model;
1939
1944
  const lines = [];
1940
1945
  lines.push("# Act Contracts Registry");
1941
1946
  lines.push("");
1942
1947
  lines.push(
1943
- `_Generated by \`act --markdown\`. ${m2.states.length} states, ${m2.slices.length} slices, ${m2.projections.length} projections, ${idx.allEventNames.size} events._`
1948
+ `_Generated by \`act --markdown\`. ${m.states.length} states, ${m.slices.length} slices, ${m.projections.length} projections, ${idx.all_event_names.size} events._`
1944
1949
  );
1945
1950
  lines.push("");
1946
1951
  lines.push("## Events");
1947
1952
  lines.push("");
1948
- const events = listByKind(idx, "event");
1953
+ const events = list_by_kind(idx, "event");
1949
1954
  if (events.length === 0) lines.push("_(none)_\n");
1950
- for (const e2 of events) {
1955
+ for (const e of events) {
1951
1956
  let schema;
1952
- let owningState;
1953
- for (const st2 of m2.states) {
1954
- const ev = st2.events.find((x3) => x3.name === e2.name);
1957
+ let owning_state;
1958
+ for (const st of m.states) {
1959
+ const ev = st.events.find((x) => x.name === e.name);
1955
1960
  if (ev) {
1956
1961
  schema = ev.schema;
1957
- owningState = st2.name;
1962
+ owning_state = st.name;
1958
1963
  break;
1959
1964
  }
1960
1965
  }
1961
- const status = eventStatus(e2.name, idx.allEventNames);
1962
- const statusLabel = status.status === "active" ? "active" : `deprecated \u2014 superseded by **${status.supersededBy}**`;
1963
- lines.push(`### \`${e2.name}\``);
1964
- if (e2.file) lines.push(`- **defined in:** \`${loc2(e2.file, e2.line)}\``);
1965
- if (owningState && owningState !== e2.name)
1966
- lines.push(`- **on state:** \`${owningState}\``);
1967
- lines.push(`- **schema:** ${renderSchema(schema)}`);
1968
- lines.push(`- **status:** ${statusLabel}`);
1969
- const producers = findActionsEmitting2(m2, e2.name);
1966
+ const status = event_status(e.name, idx.all_event_names);
1967
+ const status_label = status.status === "active" ? "active" : `deprecated \u2014 superseded by **${status.superseded_by}**`;
1968
+ lines.push(`### \`${e.name}\``);
1969
+ if (e.file) lines.push(`- **defined in:** \`${loc2(e.file, e.line)}\``);
1970
+ if (owning_state && owning_state !== e.name)
1971
+ lines.push(`- **on state:** \`${owning_state}\``);
1972
+ lines.push(`- **schema:** ${render_schema(schema)}`);
1973
+ lines.push(`- **status:** ${status_label}`);
1974
+ const producers = find_actions_emitting2(m, e.name);
1970
1975
  if (producers.length > 0) {
1971
1976
  lines.push("- **producers:**");
1972
- for (const p2 of producers)
1977
+ for (const p of producers)
1973
1978
  lines.push(
1974
- ` - \`${p2.action}\` (state \`${p2.state}\`)${fileSuffix(p2.file, p2.line)}`
1979
+ ` - \`${p.action}\` (state \`${p.state}\`)${file_suffix(p.file, p.line)}`
1975
1980
  );
1976
1981
  } else {
1977
1982
  lines.push("- **producers:** _(none)_");
1978
1983
  }
1979
- const reactions2 = findReactionsFor2(m2, e2.name);
1980
- const projections2 = findProjectionsFor2(m2, e2.name);
1984
+ const reactions2 = find_reactions_for2(m, e.name);
1985
+ const projections2 = find_projections_for2(m, e.name);
1981
1986
  if (reactions2.length === 0 && projections2.length === 0) {
1982
1987
  lines.push("- **consumers:** _(none)_");
1983
1988
  } else {
1984
1989
  lines.push("- **consumers:**");
1985
- for (const r of reactions2) {
1986
- const slice = r.slice ? `\`${r.slice}\`::` : "";
1987
- const triggers = r.dispatches.length > 0 ? ` \u2192 triggers ${r.dispatches.map((d) => `\`${d}\``).join(", ")}` : "";
1990
+ for (const r2 of reactions2) {
1991
+ const slice = r2.slice ? `\`${r2.slice}\`::` : "";
1992
+ const triggers = r2.dispatches.length > 0 ? ` \u2192 triggers ${r2.dispatches.map((d) => `\`${d}\``).join(", ")}` : "";
1988
1993
  lines.push(
1989
- ` - reaction ${slice}\`${r.handler}\`${triggers}${fileSuffix(r.file, r.line)}`
1994
+ ` - reaction ${slice}\`${r2.handler}\`${triggers}${file_suffix(r2.file, r2.line)}`
1990
1995
  );
1991
1996
  }
1992
- for (const p2 of projections2)
1993
- lines.push(` - projection \`${p2.name}\`${fileSuffix(p2.file)}`);
1997
+ for (const p of projections2)
1998
+ lines.push(` - projection \`${p.name}\`${file_suffix(p.file)}`);
1994
1999
  }
1995
2000
  lines.push("");
1996
2001
  }
1997
2002
  lines.push("## Actions");
1998
2003
  lines.push("");
1999
- const actions = listByKind(idx, "action");
2004
+ const actions = list_by_kind(idx, "action");
2000
2005
  if (actions.length === 0) lines.push("_(none)_\n");
2001
- for (const a of actions) {
2006
+ for (const a2 of actions) {
2002
2007
  let action;
2003
- let stateFile;
2004
- for (const st2 of m2.states) {
2005
- if (a.qualifier && st2.name !== a.qualifier) continue;
2006
- const found = st2.actions.find((x3) => x3.name === a.name);
2008
+ let state_file;
2009
+ for (const st of m.states) {
2010
+ if (a2.qualifier && st.name !== a2.qualifier) continue;
2011
+ const found = st.actions.find((x) => x.name === a2.name);
2007
2012
  if (found) {
2008
2013
  action = found;
2009
- stateFile = st2.file;
2014
+ state_file = st.file;
2010
2015
  break;
2011
2016
  }
2012
2017
  }
2013
- lines.push(`### \`${a.name}\``);
2014
- if (a.qualifier) lines.push(`- **on state:** \`${a.qualifier}\``);
2015
- if (stateFile)
2018
+ lines.push(`### \`${a2.name}\``);
2019
+ if (a2.qualifier) lines.push(`- **on state:** \`${a2.qualifier}\``);
2020
+ if (state_file)
2016
2021
  lines.push(
2017
- `- **defined in:** \`${loc2(stateFile, action?.line ?? a.line)}\``
2022
+ `- **defined in:** \`${loc2(state_file, action?.line ?? a2.line)}\``
2018
2023
  );
2019
2024
  if (action) {
2020
2025
  if (action.invariants.length > 0) {
@@ -2032,48 +2037,48 @@ function formatMarkdown(idx) {
2032
2037
  }
2033
2038
  lines.push("## States");
2034
2039
  lines.push("");
2035
- const states = listByKind(idx, "state");
2040
+ const states = list_by_kind(idx, "state");
2036
2041
  if (states.length === 0) lines.push("_(none)_\n");
2037
2042
  for (const s of states) {
2038
- const st2 = m2.states.find((x3) => x3.name === s.name);
2043
+ const st = m.states.find((x) => x.name === s.name);
2039
2044
  lines.push(`### \`${s.name}\``);
2040
2045
  if (s.file) lines.push(`- **defined in:** \`${loc2(s.file, s.line)}\``);
2041
- if (st2) {
2042
- if (st2.actions.length > 0)
2046
+ if (st) {
2047
+ if (st.actions.length > 0)
2043
2048
  lines.push(
2044
- `- **actions:** ${st2.actions.map((x3) => `\`${x3.name}\``).join(", ")}`
2049
+ `- **actions:** ${st.actions.map((x) => `\`${x.name}\``).join(", ")}`
2045
2050
  );
2046
- if (st2.events.length > 0)
2051
+ if (st.events.length > 0)
2047
2052
  lines.push(
2048
- `- **events:** ${st2.events.map((x3) => `\`${x3.name}\``).join(", ")}`
2053
+ `- **events:** ${st.events.map((x) => `\`${x.name}\``).join(", ")}`
2049
2054
  );
2050
2055
  }
2051
2056
  lines.push("");
2052
2057
  }
2053
2058
  lines.push("## Slices");
2054
2059
  lines.push("");
2055
- const slices = listByKind(idx, "slice");
2060
+ const slices = list_by_kind(idx, "slice");
2056
2061
  if (slices.length === 0) lines.push("_(none)_\n");
2057
2062
  for (const s of slices) {
2058
- const sl = m2.slices.find((x3) => x3.name === s.name);
2063
+ const sl = m.slices.find((x) => x.name === s.name);
2059
2064
  lines.push(`### \`${s.name}\``);
2060
2065
  if (s.file) lines.push(`- **defined in:** \`${loc2(s.file, s.line)}\``);
2061
2066
  if (sl) {
2062
2067
  if (sl.error) lines.push(`- **error:** ${sl.error}`);
2063
2068
  if (sl.states.length > 0)
2064
2069
  lines.push(
2065
- `- **states:** ${sl.states.map((x3) => `\`${x3}\``).join(", ")}`
2070
+ `- **states:** ${sl.states.map((x) => `\`${x}\``).join(", ")}`
2066
2071
  );
2067
2072
  if (sl.projections.length > 0)
2068
2073
  lines.push(
2069
- `- **projections:** ${sl.projections.map((x3) => `\`${x3}\``).join(", ")}`
2074
+ `- **projections:** ${sl.projections.map((x) => `\`${x}\``).join(", ")}`
2070
2075
  );
2071
2076
  if (sl.reactions.length > 0) {
2072
2077
  lines.push("- **reactions:**");
2073
- for (const r of sl.reactions) {
2074
- const triggers = r.dispatches.length > 0 ? ` \u2192 ${r.dispatches.map((d) => `\`${d}\``).join(", ")}` : "";
2078
+ for (const r2 of sl.reactions) {
2079
+ const triggers = r2.dispatches.length > 0 ? ` \u2192 ${r2.dispatches.map((d) => `\`${d}\``).join(", ")}` : "";
2075
2080
  lines.push(
2076
- ` - \`${r.event}\` \u2192 \`${r.handlerName}\`${triggers}${fileSuffix(r.file, r.line)}`
2081
+ ` - \`${r2.event}\` \u2192 \`${r2.handlerName}\`${triggers}${file_suffix(r2.file, r2.line)}`
2077
2082
  );
2078
2083
  }
2079
2084
  }
@@ -2082,36 +2087,36 @@ function formatMarkdown(idx) {
2082
2087
  }
2083
2088
  lines.push("## Projections");
2084
2089
  lines.push("");
2085
- const projections = listByKind(idx, "projection");
2090
+ const projections = list_by_kind(idx, "projection");
2086
2091
  if (projections.length === 0) lines.push("_(none)_\n");
2087
- for (const p2 of projections) {
2088
- const pr = m2.projections.find((x3) => x3.name === p2.name);
2089
- lines.push(`### \`${p2.name}\``);
2092
+ for (const p of projections) {
2093
+ const pr = m.projections.find((x) => x.name === p.name);
2094
+ lines.push(`### \`${p.name}\``);
2090
2095
  if (pr?.file) lines.push(`- **defined in:** \`${loc2(pr.file, pr.line)}\``);
2091
2096
  if (pr && pr.handles.length > 0)
2092
2097
  lines.push(
2093
- `- **handles:** ${pr.handles.map((x3) => `\`${x3}\``).join(", ")}`
2098
+ `- **handles:** ${pr.handles.map((x) => `\`${x}\``).join(", ")}`
2094
2099
  );
2095
2100
  lines.push("");
2096
2101
  }
2097
2102
  lines.push("## Reactions");
2098
2103
  lines.push("");
2099
- const reactions = listByKind(idx, "reaction");
2104
+ const reactions = list_by_kind(idx, "reaction");
2100
2105
  if (reactions.length === 0) lines.push("_(none)_\n");
2101
- for (const r of reactions) {
2102
- const [sliceName, eventName] = (r.qualifier ?? "::").split("::");
2103
- lines.push(`### \`${r.name}\``);
2104
- if (sliceName && sliceName !== "*")
2105
- lines.push(`- **in slice:** \`${sliceName}\``);
2106
- if (eventName) lines.push(`- **on event:** \`${eventName}\``);
2107
- if (r.file) lines.push(`- **defined in:** \`${loc2(r.file, r.line)}\``);
2108
- const sliceReaction = m2.slices.find((x3) => x3.name === sliceName)?.reactions.find(
2109
- (rr) => rr.handlerName === r.name && rr.event === eventName
2106
+ for (const r2 of reactions) {
2107
+ const [slice_name, event_name] = (r2.qualifier ?? "::").split("::");
2108
+ lines.push(`### \`${r2.name}\``);
2109
+ if (slice_name && slice_name !== "*")
2110
+ lines.push(`- **in slice:** \`${slice_name}\``);
2111
+ if (event_name) lines.push(`- **on event:** \`${event_name}\``);
2112
+ if (r2.file) lines.push(`- **defined in:** \`${loc2(r2.file, r2.line)}\``);
2113
+ const slice_reaction = m.slices.find((x) => x.name === slice_name)?.reactions.find(
2114
+ (rr) => rr.handlerName === r2.name && rr.event === event_name
2110
2115
  );
2111
- const orchReaction = m2.reactions.find(
2112
- (rr) => rr.handlerName === r.name && rr.event === eventName
2116
+ const orch_reaction = m.reactions.find(
2117
+ (rr) => rr.handlerName === r2.name && rr.event === event_name
2113
2118
  );
2114
- const inner = sliceReaction ?? orchReaction;
2119
+ const inner = slice_reaction ?? orch_reaction;
2115
2120
  if (inner && inner.dispatches.length > 0) {
2116
2121
  lines.push(
2117
2122
  `- **triggers:** ${inner.dispatches.map((d) => `\`${d}\``).join(", ")}`
@@ -2126,11 +2131,11 @@ function formatMarkdown(idx) {
2126
2131
  import { writeFile } from "fs/promises";
2127
2132
  import { resolve as resolve3 } from "path";
2128
2133
 
2129
- // ../../node_modules/.pnpm/@clack+core@1.3.1/node_modules/@clack/core/dist/index.mjs
2130
- import { styleText as v } from "util";
2131
- import { stdout as x, stdin as D } from "process";
2132
- import * as b from "readline";
2133
- import E from "readline";
2134
+ // ../../node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
2135
+ import { styleText } from "util";
2136
+ import { stdout, stdin } from "process";
2137
+ import * as l from "readline";
2138
+ import l__default from "readline";
2134
2139
 
2135
2140
  // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
2136
2141
  var getCodePointsLength = /* @__PURE__ */ (() => {
@@ -2144,11 +2149,11 @@ var getCodePointsLength = /* @__PURE__ */ (() => {
2144
2149
  return input.length - surrogatePairsNr;
2145
2150
  };
2146
2151
  })();
2147
- var isFullWidth = (x3) => {
2148
- return x3 === 12288 || x3 >= 65281 && x3 <= 65376 || x3 >= 65504 && x3 <= 65510;
2152
+ var isFullWidth = (x) => {
2153
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
2149
2154
  };
2150
- var isWideNotCJKTNotEmoji = (x3) => {
2151
- return x3 === 8987 || x3 === 9001 || x3 >= 12272 && x3 <= 12287 || x3 >= 12289 && x3 <= 12350 || x3 >= 12441 && x3 <= 12543 || x3 >= 12549 && x3 <= 12591 || x3 >= 12593 && x3 <= 12686 || x3 >= 12688 && x3 <= 12771 || x3 >= 12783 && x3 <= 12830 || x3 >= 12832 && x3 <= 12871 || x3 >= 12880 && x3 <= 19903 || x3 >= 65040 && x3 <= 65049 || x3 >= 65072 && x3 <= 65106 || x3 >= 65108 && x3 <= 65126 || x3 >= 65128 && x3 <= 65131 || x3 >= 127488 && x3 <= 127490 || x3 >= 127504 && x3 <= 127547 || x3 >= 127552 && x3 <= 127560 || x3 >= 131072 && x3 <= 196605 || x3 >= 196608 && x3 <= 262141;
2155
+ var isWideNotCJKTNotEmoji = (x) => {
2156
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
2152
2157
  };
2153
2158
 
2154
2159
  // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
@@ -2218,8 +2223,8 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
2218
2223
  if (index >= length) {
2219
2224
  break outer;
2220
2225
  }
2221
- for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
2222
- const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
2226
+ for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
2227
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
2223
2228
  BLOCK_RE.lastIndex = index;
2224
2229
  if (BLOCK_RE.test(input)) {
2225
2230
  lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
@@ -2422,8 +2427,8 @@ var exec = (string, columns, options = {}) => {
2422
2427
  }
2423
2428
  const preString = rows.join("\n");
2424
2429
  let inSurrogate = false;
2425
- for (let i = 0; i < preString.length; i++) {
2426
- const character = preString[i];
2430
+ for (let i2 = 0; i2 < preString.length; i2++) {
2431
+ const character = preString[i2];
2427
2432
  returnValue += character;
2428
2433
  if (!inSurrogate) {
2429
2434
  inSurrogate = character >= "\uD800" && character <= "\uDBFF";
@@ -2434,7 +2439,7 @@ var exec = (string, columns, options = {}) => {
2434
2439
  inSurrogate = false;
2435
2440
  }
2436
2441
  if (character === ESC || character === CSI) {
2437
- GROUP_REGEX.lastIndex = i + 1;
2442
+ GROUP_REGEX.lastIndex = i2 + 1;
2438
2443
  const groupsResult = GROUP_REGEX.exec(preString);
2439
2444
  const groups = groupsResult?.groups;
2440
2445
  if (groups?.code !== void 0) {
@@ -2444,7 +2449,7 @@ var exec = (string, columns, options = {}) => {
2444
2449
  escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
2445
2450
  }
2446
2451
  }
2447
- if (preString[i + 1] === "\n") {
2452
+ if (preString[i2 + 1] === "\n") {
2448
2453
  if (escapeUrl) {
2449
2454
  returnValue += wrapAnsiHyperlink("");
2450
2455
  }
@@ -2468,51 +2473,115 @@ function wrapAnsi(string, columns, options) {
2468
2473
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
2469
2474
  }
2470
2475
 
2471
- // ../../node_modules/.pnpm/@clack+core@1.3.1/node_modules/@clack/core/dist/index.mjs
2476
+ // ../../node_modules/.pnpm/@clack+core@1.4.1/node_modules/@clack/core/dist/index.mjs
2472
2477
  var import_sisteransi = __toESM(require_src(), 1);
2473
- import { ReadStream as O } from "tty";
2474
- function f(r, t, s) {
2475
- if (!s.some((o) => !o.disabled)) return r;
2476
- const e2 = r + t, i = Math.max(s.length - 1, 0), n = e2 < 0 ? i : e2 > i ? 0 : e2;
2477
- return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
2478
- }
2479
- var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
2480
- var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
2481
- var h = { actions: new Set(G), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
2482
- function C(r, t) {
2483
- if (typeof r == "string") return h.aliases.get(r) === t;
2484
- for (const s of r) if (s !== void 0 && C(s, t)) return true;
2478
+ import { ReadStream } from "tty";
2479
+ function findCursor(s, o2, l2) {
2480
+ if (!l2.some((r2) => !r2.disabled))
2481
+ return s;
2482
+ const t2 = s + o2, n2 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n2 : t2 > n2 ? 0 : t2;
2483
+ return l2[e].disabled ? findCursor(e, o2 < 0 ? -1 : 1, l2) : e;
2484
+ }
2485
+ var a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"];
2486
+ var t = [
2487
+ "January",
2488
+ "February",
2489
+ "March",
2490
+ "April",
2491
+ "May",
2492
+ "June",
2493
+ "July",
2494
+ "August",
2495
+ "September",
2496
+ "October",
2497
+ "November",
2498
+ "December"
2499
+ ];
2500
+ var settings = {
2501
+ actions: new Set(a$2),
2502
+ aliases: /* @__PURE__ */ new Map([
2503
+ // vim support
2504
+ ["k", "up"],
2505
+ ["j", "down"],
2506
+ ["h", "left"],
2507
+ ["l", "right"],
2508
+ ["", "cancel"],
2509
+ // opinionated defaults!
2510
+ ["escape", "cancel"]
2511
+ ]),
2512
+ messages: {
2513
+ cancel: "Canceled",
2514
+ error: "Something went wrong"
2515
+ },
2516
+ withGuide: true,
2517
+ date: {
2518
+ monthNames: [...t],
2519
+ messages: {
2520
+ required: "Please enter a valid date",
2521
+ invalidMonth: "There are only 12 months in a year",
2522
+ invalidDay: (n2, e) => `There are only ${n2} days in ${e}`,
2523
+ afterMin: (n2) => `Date must be on or after ${n2.toISOString().slice(0, 10)}`,
2524
+ beforeMax: (n2) => `Date must be on or before ${n2.toISOString().slice(0, 10)}`
2525
+ }
2526
+ }
2527
+ };
2528
+ function isActionKey(n2, e) {
2529
+ if (typeof n2 == "string")
2530
+ return settings.aliases.get(n2) === e;
2531
+ for (const s of n2)
2532
+ if (s !== void 0 && isActionKey(s, e))
2533
+ return true;
2485
2534
  return false;
2486
2535
  }
2487
- function z3(r, t) {
2488
- if (r === t) return;
2489
- const s = r.split(`
2490
- `), e2 = t.split(`
2491
- `), i = Math.max(s.length, e2.length), n = [];
2492
- for (let o = 0; o < i; o++) s[o] !== e2[o] && n.push(o);
2493
- return { lines: n, numLinesBefore: s.length, numLinesAfter: e2.length, numLines: i };
2494
- }
2495
- var Y = globalThis.process.platform.startsWith("win");
2496
- var k = /* @__PURE__ */ Symbol("clack:cancel");
2497
- function q(r) {
2498
- return r === k;
2499
- }
2500
- function w(r, t) {
2501
- const s = r;
2502
- s.isTTY && s.setRawMode(t);
2503
- }
2504
- var A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80;
2505
- var L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
2506
- function W(r, t, s, e2 = s, i = s, n) {
2507
- const o = A(r ?? x);
2508
- return wrapAnsi(t, o - s.length, { hard: true, trim: false }).split(`
2509
- `).map((u, a, l) => {
2510
- const c = n ? n(u, a) : u;
2511
- return a === 0 ? `${e2}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
2536
+ function diffLines(i2, s) {
2537
+ if (i2 === s) return;
2538
+ const e = i2.split(`
2539
+ `), t2 = s.split(`
2540
+ `), r2 = Math.max(e.length, t2.length), f = [];
2541
+ for (let n2 = 0; n2 < r2; n2++)
2542
+ e[n2] !== t2[n2] && f.push(n2);
2543
+ return {
2544
+ lines: f,
2545
+ numLinesBefore: e.length,
2546
+ numLinesAfter: t2.length,
2547
+ numLines: r2
2548
+ };
2549
+ }
2550
+ var R = globalThis.process.platform.startsWith("win");
2551
+ var CANCEL_SYMBOL = /* @__PURE__ */ Symbol("clack:cancel");
2552
+ function isCancel(e) {
2553
+ return e === CANCEL_SYMBOL;
2554
+ }
2555
+ function setRawMode(e, r2) {
2556
+ const o2 = e;
2557
+ o2.isTTY && o2.setRawMode(r2);
2558
+ }
2559
+ var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
2560
+ var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
2561
+ function wrapTextWithPrefix(e, r2, o2, t2 = o2, s = o2, n2) {
2562
+ const f = getColumns(e ?? stdout);
2563
+ return wrapAnsi(r2, f - o2.length, {
2564
+ hard: true,
2565
+ trim: false
2566
+ }).split(`
2567
+ `).map((c2, i2, m) => {
2568
+ const d = n2 ? n2(c2, i2) : c2;
2569
+ return i2 === 0 ? `${t2}${d}` : i2 === m.length - 1 ? `${s}${d}` : `${o2}${d}`;
2512
2570
  }).join(`
2513
2571
  `);
2514
2572
  }
2515
- var m = class {
2573
+ function runValidation(e, n2) {
2574
+ if ("~standard" in e) {
2575
+ const a2 = e["~standard"].validate(n2);
2576
+ if (a2 instanceof Promise)
2577
+ throw new TypeError(
2578
+ "Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
2579
+ );
2580
+ return a2.issues?.at(0)?.message;
2581
+ }
2582
+ return e(n2);
2583
+ }
2584
+ var V = class {
2516
2585
  input;
2517
2586
  output;
2518
2587
  _abortSignal;
@@ -2527,117 +2596,157 @@ var m = class {
2527
2596
  error = "";
2528
2597
  value;
2529
2598
  userInput = "";
2530
- constructor(t, s = true) {
2531
- const { input: e2 = D, output: i = x, render: n, signal: o, ...u } = t;
2532
- this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e2, this.output = i;
2599
+ constructor(t2, e = true) {
2600
+ const { input: i2 = stdin, output: n2 = stdout, render: s, signal: r2, ...o2 } = t2;
2601
+ this.opts = o2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r2, this.input = i2, this.output = n2;
2533
2602
  }
2603
+ /**
2604
+ * Unsubscribe all listeners
2605
+ */
2534
2606
  unsubscribe() {
2535
2607
  this._subscribers.clear();
2536
2608
  }
2537
- setSubscriber(t, s) {
2538
- const e2 = this._subscribers.get(t) ?? [];
2539
- e2.push(s), this._subscribers.set(t, e2);
2540
- }
2541
- on(t, s) {
2542
- this.setSubscriber(t, { cb: s });
2543
- }
2544
- once(t, s) {
2545
- this.setSubscriber(t, { cb: s, once: true });
2546
- }
2547
- emit(t, ...s) {
2548
- const e2 = this._subscribers.get(t) ?? [], i = [];
2549
- for (const n of e2) n.cb(...s), n.once && i.push(() => e2.splice(e2.indexOf(n), 1));
2550
- for (const n of i) n();
2609
+ /**
2610
+ * Set a subscriber with opts
2611
+ * @param event - The event name
2612
+ */
2613
+ setSubscriber(t2, e) {
2614
+ const i2 = this._subscribers.get(t2) ?? [];
2615
+ i2.push(e), this._subscribers.set(t2, i2);
2616
+ }
2617
+ /**
2618
+ * Subscribe to an event
2619
+ * @param event - The event name
2620
+ * @param cb - The callback
2621
+ */
2622
+ on(t2, e) {
2623
+ this.setSubscriber(t2, { cb: e });
2624
+ }
2625
+ /**
2626
+ * Subscribe to an event once
2627
+ * @param event - The event name
2628
+ * @param cb - The callback
2629
+ */
2630
+ once(t2, e) {
2631
+ this.setSubscriber(t2, { cb: e, once: true });
2632
+ }
2633
+ /**
2634
+ * Emit an event with data
2635
+ * @param event - The event name
2636
+ * @param data - The data to pass to the callback
2637
+ */
2638
+ emit(t2, ...e) {
2639
+ const i2 = this._subscribers.get(t2) ?? [], n2 = [];
2640
+ for (const s of i2)
2641
+ s.cb(...e), s.once && n2.push(() => i2.splice(i2.indexOf(s), 1));
2642
+ for (const s of n2)
2643
+ s();
2551
2644
  }
2552
2645
  prompt() {
2553
- return new Promise((t) => {
2646
+ return new Promise((t2) => {
2554
2647
  if (this._abortSignal) {
2555
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
2556
- this._abortSignal.addEventListener("abort", () => {
2557
- this.state = "cancel", this.close();
2558
- }, { once: true });
2648
+ if (this._abortSignal.aborted)
2649
+ return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
2650
+ this._abortSignal.addEventListener(
2651
+ "abort",
2652
+ () => {
2653
+ this.state = "cancel", this.close();
2654
+ },
2655
+ { once: true }
2656
+ );
2559
2657
  }
2560
- this.rl = E.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
2561
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
2658
+ this.rl = l__default.createInterface({
2659
+ input: this.input,
2660
+ tabSize: 2,
2661
+ prompt: "",
2662
+ escapeCodeTimeout: 50,
2663
+ terminal: true
2664
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
2665
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
2562
2666
  }), this.once("cancel", () => {
2563
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(k);
2667
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
2564
2668
  });
2565
2669
  });
2566
2670
  }
2567
- _isActionKey(t, s) {
2568
- return t === " ";
2671
+ _isActionKey(t2, e) {
2672
+ return t2 === " ";
2569
2673
  }
2570
- _shouldSubmit(t, s) {
2674
+ _shouldSubmit(t2, e) {
2571
2675
  return true;
2572
2676
  }
2573
- _setValue(t) {
2574
- this.value = t, this.emit("value", this.value);
2677
+ _setValue(t2) {
2678
+ this.value = t2, this.emit("value", this.value);
2575
2679
  }
2576
- _setUserInput(t, s) {
2577
- this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
2680
+ _setUserInput(t2, e) {
2681
+ this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
2578
2682
  }
2579
2683
  _clearUserInput() {
2580
2684
  this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
2581
2685
  }
2582
- onKeypress(t, s) {
2583
- if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
2686
+ onKeypress(t2, e) {
2687
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
2584
2688
  if (this.opts.validate) {
2585
- const e2 = this.opts.validate(this.value);
2586
- e2 && (this.error = e2 instanceof Error ? e2.message : e2, this.state = "error", this.rl?.write(this.userInput));
2689
+ const i2 = runValidation(this.opts.validate, this.value);
2690
+ i2 && (this.error = i2 instanceof Error ? i2.message : i2, this.state = "error", this.rl?.write(this.userInput));
2587
2691
  }
2588
2692
  this.state !== "error" && (this.state = "submit");
2589
2693
  }
2590
- C([t, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
2694
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
2591
2695
  }
2592
2696
  close() {
2593
2697
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
2594
- `), w(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
2698
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
2595
2699
  }
2596
2700
  restoreCursor() {
2597
- const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
2701
+ const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
2598
2702
  `).length - 1;
2599
- this.output.write(import_sisteransi.cursor.move(-999, t * -1));
2703
+ this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
2600
2704
  }
2601
2705
  render() {
2602
- const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
2603
- if (t !== this._prevFrame) {
2604
- if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
2706
+ const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
2707
+ hard: true,
2708
+ trim: false
2709
+ });
2710
+ if (t2 !== this._prevFrame) {
2711
+ if (this.state === "initial")
2712
+ this.output.write(import_sisteransi.cursor.hide);
2605
2713
  else {
2606
- const s = z3(this._prevFrame, t), e2 = L(this.output);
2607
- if (this.restoreCursor(), s) {
2608
- const i = Math.max(0, s.numLinesAfter - e2), n = Math.max(0, s.numLinesBefore - e2);
2609
- let o = s.lines.find((u) => u >= i);
2610
- if (o === void 0) {
2611
- this._prevFrame = t;
2714
+ const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
2715
+ if (this.restoreCursor(), e) {
2716
+ const n2 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
2717
+ let r2 = e.lines.find((o2) => o2 >= n2);
2718
+ if (r2 === void 0) {
2719
+ this._prevFrame = t2;
2612
2720
  return;
2613
2721
  }
2614
- if (s.lines.length === 1) {
2615
- this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
2616
- const u = t.split(`
2722
+ if (e.lines.length === 1) {
2723
+ this.output.write(import_sisteransi.cursor.move(0, r2 - s)), this.output.write(import_sisteransi.erase.lines(1));
2724
+ const o2 = t2.split(`
2617
2725
  `);
2618
- this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
2726
+ this.output.write(o2[r2]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - r2 - 1));
2619
2727
  return;
2620
- } else if (s.lines.length > 1) {
2621
- if (i < n) o = i;
2728
+ } else if (e.lines.length > 1) {
2729
+ if (n2 < s)
2730
+ r2 = n2;
2622
2731
  else {
2623
- const a = o - n;
2624
- a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
2732
+ const h2 = r2 - s;
2733
+ h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
2625
2734
  }
2626
2735
  this.output.write(import_sisteransi.erase.down());
2627
- const u = t.split(`
2628
- `).slice(o);
2629
- this.output.write(u.join(`
2630
- `)), this._prevFrame = t;
2736
+ const f = t2.split(`
2737
+ `).slice(r2);
2738
+ this.output.write(f.join(`
2739
+ `)), this._prevFrame = t2;
2631
2740
  return;
2632
2741
  }
2633
2742
  }
2634
2743
  this.output.write(import_sisteransi.erase.down());
2635
2744
  }
2636
- this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
2745
+ this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
2637
2746
  }
2638
2747
  }
2639
2748
  };
2640
- var ut = class extends m {
2749
+ var a = class extends V {
2641
2750
  options;
2642
2751
  cursor = 0;
2643
2752
  get _selectedValue() {
@@ -2646,270 +2755,366 @@ var ut = class extends m {
2646
2755
  changeValue() {
2647
2756
  this.value = this._selectedValue.value;
2648
2757
  }
2649
- constructor(t) {
2650
- super(t, false), this.options = t.options;
2651
- const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e2 = s === -1 ? 0 : s;
2652
- this.cursor = this.options[e2].disabled ? f(e2, 1, this.options) : e2, this.changeValue(), this.on("cursor", (i) => {
2653
- switch (i) {
2758
+ constructor(t2) {
2759
+ super(t2, false), this.options = t2.options;
2760
+ const i2 = this.options.findIndex(({ value: s }) => s === t2.initialValue), e = i2 === -1 ? 0 : i2;
2761
+ this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
2762
+ switch (s) {
2654
2763
  case "left":
2655
2764
  case "up":
2656
- this.cursor = f(this.cursor, -1, this.options);
2765
+ this.cursor = findCursor(this.cursor, -1, this.options);
2657
2766
  break;
2658
2767
  case "down":
2659
2768
  case "right":
2660
- this.cursor = f(this.cursor, 1, this.options);
2769
+ this.cursor = findCursor(this.cursor, 1, this.options);
2661
2770
  break;
2662
2771
  }
2663
2772
  this.changeValue();
2664
2773
  });
2665
2774
  }
2666
2775
  };
2667
- var ht = class extends m {
2776
+ var n = class extends V {
2668
2777
  get userInputWithCursor() {
2669
- if (this.state === "submit") return this.userInput;
2670
- const t = this.userInput;
2671
- if (this.cursor >= t.length) return `${this.userInput}\u2588`;
2672
- const s = t.slice(0, this.cursor), [e2, ...i] = t.slice(this.cursor);
2673
- return `${s}${v("inverse", e2)}${i.join("")}`;
2778
+ if (this.state === "submit")
2779
+ return this.userInput;
2780
+ const t2 = this.userInput;
2781
+ if (this.cursor >= t2.length)
2782
+ return `${this.userInput}\u2588`;
2783
+ const e = t2.slice(0, this.cursor), [s, ...r2] = t2.slice(this.cursor);
2784
+ return `${e}${styleText("inverse", s)}${r2.join("")}`;
2674
2785
  }
2675
2786
  get cursor() {
2676
2787
  return this._cursor;
2677
2788
  }
2678
- constructor(t) {
2679
- super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
2680
- this._setValue(s);
2789
+ constructor(t2) {
2790
+ super({
2791
+ ...t2,
2792
+ initialUserInput: t2.initialUserInput ?? t2.initialValue
2793
+ }), this.on("userInput", (e) => {
2794
+ this._setValue(e);
2681
2795
  }), this.on("finalize", () => {
2682
- this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
2796
+ this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
2683
2797
  });
2684
2798
  }
2685
2799
  };
2686
2800
 
2687
- // ../../node_modules/.pnpm/@clack+prompts@1.4.0/node_modules/@clack/prompts/dist/index.mjs
2688
- import { styleText as e, stripVTControlCharacters as nt2 } from "util";
2689
- import V2 from "process";
2801
+ // ../../node_modules/.pnpm/@clack+prompts@1.5.1/node_modules/@clack/prompts/dist/index.mjs
2802
+ import { styleText as styleText2, stripVTControlCharacters } from "util";
2803
+ import process$1 from "process";
2690
2804
  var import_sisteransi2 = __toESM(require_src(), 1);
2691
- import { existsSync as Qt, lstatSync as wt, readdirSync as Zt } from "fs";
2692
- import { dirname as bt, join as te } from "path";
2693
- function ee() {
2694
- return V2.platform !== "win32" ? V2.env.TERM !== "linux" : !!V2.env.CI || !!V2.env.WT_SESSION || !!V2.env.TERMINUS_SUBLIME || V2.env.ConEmuTask === "{cmd::Cmder}" || V2.env.TERM_PROGRAM === "Terminus-Sublime" || V2.env.TERM_PROGRAM === "vscode" || V2.env.TERM === "xterm-256color" || V2.env.TERM === "alacritty" || V2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2695
- }
2696
- var tt = ee();
2697
- var w2 = (t, i) => tt ? t : i;
2698
- var Tt = w2("\u25C6", "*");
2699
- var at2 = w2("\u25A0", "x");
2700
- var ut2 = w2("\u25B2", "x");
2701
- var H = w2("\u25C7", "o");
2702
- var lt = w2("\u250C", "T");
2703
- var $ = w2("\u2502", "|");
2704
- var x2 = w2("\u2514", "\u2014");
2705
- var _t = w2("\u2510", "T");
2706
- var xt = w2("\u2518", "\u2014");
2707
- var z4 = w2("\u25CF", ">");
2708
- var U = w2("\u25CB", " ");
2709
- var et2 = w2("\u25FB", "[\u2022]");
2710
- var K2 = w2("\u25FC", "[+]");
2711
- var Y2 = w2("\u25FB", "[ ]");
2712
- var Et = w2("\u25AA", "\u2022");
2713
- var st = w2("\u2500", "-");
2714
- var ct = w2("\u256E", "+");
2715
- var Gt = w2("\u251C", "+");
2716
- var $t = w2("\u256F", "+");
2717
- var dt = w2("\u2570", "+");
2718
- var Mt = w2("\u256D", "+");
2719
- var ht2 = w2("\u25CF", "\u2022");
2720
- var pt = w2("\u25C6", "*");
2721
- var mt = w2("\u25B2", "!");
2722
- var gt = w2("\u25A0", "x");
2723
- var P = (t) => {
2724
- switch (t) {
2805
+ import { existsSync, lstatSync, readdirSync } from "fs";
2806
+ import { dirname, join } from "path";
2807
+ function isUnicodeSupported() {
2808
+ if (process$1.platform !== "win32") {
2809
+ return process$1.env.TERM !== "linux";
2810
+ }
2811
+ return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2812
+ }
2813
+ var unicode = isUnicodeSupported();
2814
+ var unicodeOr = (e, o2) => unicode ? e : o2;
2815
+ var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
2816
+ var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
2817
+ var S_STEP_ERROR = unicodeOr("\u25B2", "x");
2818
+ var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
2819
+ var S_BAR_START = unicodeOr("\u250C", "T");
2820
+ var S_BAR = unicodeOr("\u2502", "|");
2821
+ var S_BAR_END = unicodeOr("\u2514", "\u2014");
2822
+ var S_BAR_START_RIGHT = unicodeOr("\u2510", "T");
2823
+ var S_BAR_END_RIGHT = unicodeOr("\u2518", "\u2014");
2824
+ var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
2825
+ var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
2826
+ var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
2827
+ var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
2828
+ var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
2829
+ var S_PASSWORD_MASK = unicodeOr("\u25AA", "\u2022");
2830
+ var S_BAR_H = unicodeOr("\u2500", "-");
2831
+ var S_CORNER_TOP_RIGHT = unicodeOr("\u256E", "+");
2832
+ var S_CONNECT_LEFT = unicodeOr("\u251C", "+");
2833
+ var S_CORNER_BOTTOM_RIGHT = unicodeOr("\u256F", "+");
2834
+ var S_CORNER_BOTTOM_LEFT = unicodeOr("\u2570", "+");
2835
+ var S_CORNER_TOP_LEFT = unicodeOr("\u256D", "+");
2836
+ var S_INFO = unicodeOr("\u25CF", "\u2022");
2837
+ var S_SUCCESS = unicodeOr("\u25C6", "*");
2838
+ var S_WARN = unicodeOr("\u25B2", "!");
2839
+ var S_ERROR = unicodeOr("\u25A0", "x");
2840
+ var symbol = (e) => {
2841
+ switch (e) {
2725
2842
  case "initial":
2726
2843
  case "active":
2727
- return e("cyan", Tt);
2844
+ return styleText2("cyan", S_STEP_ACTIVE);
2728
2845
  case "cancel":
2729
- return e("red", at2);
2846
+ return styleText2("red", S_STEP_CANCEL);
2730
2847
  case "error":
2731
- return e("yellow", ut2);
2848
+ return styleText2("yellow", S_STEP_ERROR);
2732
2849
  case "submit":
2733
- return e("green", H);
2850
+ return styleText2("green", S_STEP_SUBMIT);
2734
2851
  }
2735
2852
  };
2736
- var yt = (t) => {
2737
- switch (t) {
2853
+ var symbolBar = (e) => {
2854
+ switch (e) {
2738
2855
  case "initial":
2739
2856
  case "active":
2740
- return e("cyan", $);
2857
+ return styleText2("cyan", S_BAR);
2741
2858
  case "cancel":
2742
- return e("red", $);
2859
+ return styleText2("red", S_BAR);
2743
2860
  case "error":
2744
- return e("yellow", $);
2861
+ return styleText2("yellow", S_BAR);
2745
2862
  case "submit":
2746
- return e("green", $);
2863
+ return styleText2("green", S_BAR);
2747
2864
  }
2748
2865
  };
2749
- var Ot = (t, i, s, r, u, n = false) => {
2750
- let a = i, c = 0;
2751
- if (n) for (let o = r - 1; o >= s && (a -= t[o].length, c++, !(a <= u)); o--) ;
2752
- else for (let o = s; o < r && (a -= t[o].length, c++, !(a <= u)); o++) ;
2753
- return { lineCount: a, removals: c };
2866
+ var E$1 = (l2, o2, g, c2, h2, O = false) => {
2867
+ let r2 = o2, w = 0;
2868
+ if (O)
2869
+ for (let i2 = c2 - 1; i2 >= g && (r2 -= l2[i2].length, w++, !(r2 <= h2)); i2--)
2870
+ ;
2871
+ else
2872
+ for (let i2 = g; i2 < c2 && (r2 -= l2[i2].length, w++, !(r2 <= h2)); i2++)
2873
+ ;
2874
+ return { lineCount: r2, removals: w };
2754
2875
  };
2755
- var F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
2756
- const c = A(r) - n, o = L(r), l = e("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
2757
- let p2 = 0;
2758
- t >= g - 3 && (p2 = Math.max(Math.min(t - g + 3, i.length - g), 0));
2759
- let f2 = g < i.length && p2 > 0, h2 = g < i.length && p2 + g < i.length;
2760
- const I = Math.min(p2 + g, i.length), m2 = [];
2761
- let y = 0;
2762
- f2 && y++, h2 && y++;
2763
- const v2 = p2 + (f2 ? 1 : 0), C2 = I - (h2 ? 1 : 0);
2764
- for (let b2 = v2; b2 < C2; b2++) {
2765
- const G2 = wrapAnsi(s(i[b2], b2 === t), c, { hard: true, trim: false }).split(`
2876
+ var limitOptions = ({
2877
+ cursor: l2,
2878
+ options: o2,
2879
+ style: g,
2880
+ output: c2 = process.stdout,
2881
+ maxItems: h2 = Number.POSITIVE_INFINITY,
2882
+ columnPadding: O = 0,
2883
+ rowPadding: r2 = 4
2884
+ }) => {
2885
+ const i2 = getColumns(c2) - O, I = getRows(c2), C = styleText2("dim", "..."), x = Math.max(I - r2, 0), m = Math.max(Math.min(h2, x), 5);
2886
+ let p = 0;
2887
+ l2 >= m - 3 && (p = Math.max(
2888
+ Math.min(l2 - m + 3, o2.length - m),
2889
+ 0
2890
+ ));
2891
+ let f = m < o2.length && p > 0, u3 = m < o2.length && p + m < o2.length;
2892
+ const W = Math.min(
2893
+ p + m,
2894
+ o2.length
2895
+ ), e = [];
2896
+ let d = 0;
2897
+ f && d++, u3 && d++;
2898
+ const v = p + (f ? 1 : 0), P = W - (u3 ? 1 : 0);
2899
+ for (let t2 = v; t2 < P; t2++) {
2900
+ const n2 = wrapAnsi(g(o2[t2], t2 === l2), i2, {
2901
+ hard: true,
2902
+ trim: false
2903
+ }).split(`
2766
2904
  `);
2767
- m2.push(G2), y += G2.length;
2768
- }
2769
- if (y > d) {
2770
- let b2 = 0, G2 = 0, M = y;
2771
- const N = t - v2;
2772
- let O2 = d;
2773
- const j2 = () => Ot(m2, M, 0, N, O2), k2 = () => Ot(m2, M, N + 1, m2.length, O2, true);
2774
- f2 ? ({ lineCount: M, removals: b2 } = j2(), M > O2 && (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2())) : (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2(), M > O2 && (O2 -= 1, { lineCount: M, removals: b2 } = j2())), b2 > 0 && (f2 = true, m2.splice(0, b2)), G2 > 0 && (h2 = true, m2.splice(m2.length - G2, G2));
2775
- }
2776
- const S = [];
2777
- f2 && S.push(l);
2778
- for (const b2 of m2) for (const G2 of b2) S.push(G2);
2779
- return h2 && S.push(l), S;
2905
+ e.push(n2), d += n2.length;
2906
+ }
2907
+ if (d > x) {
2908
+ let t2 = 0, n2 = 0, s = d;
2909
+ const M = l2 - v;
2910
+ let a2 = x;
2911
+ const T = () => E$1(e, s, 0, M, a2), L = () => E$1(
2912
+ e,
2913
+ s,
2914
+ M + 1,
2915
+ e.length,
2916
+ a2,
2917
+ true
2918
+ );
2919
+ f ? ({ lineCount: s, removals: t2 } = T(), s > a2 && (u3 || (a2 -= 1), { lineCount: s, removals: n2 } = L())) : (u3 || (a2 -= 1), { lineCount: s, removals: n2 } = L(), s > a2 && (a2 -= 1, { lineCount: s, removals: t2 } = T())), t2 > 0 && (f = true, e.splice(0, t2)), n2 > 0 && (u3 = true, e.splice(e.length - n2, n2));
2920
+ }
2921
+ const b = [];
2922
+ f && b.push(C);
2923
+ for (const t2 of e)
2924
+ for (const n2 of t2)
2925
+ b.push(n2);
2926
+ return u3 && b.push(C), b;
2780
2927
  };
2781
- var R2 = { message: (t = [], { symbol: i = e("gray", $), secondarySymbol: s = e("gray", $), output: r = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
2782
- const a = [], c = n ?? h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
2783
- for (let p2 = 0; p2 < u; p2++) a.push(o);
2784
- const g = Array.isArray(t) ? t : t.split(`
2928
+ var log = {
2929
+ message: (s = [], {
2930
+ symbol: e = styleText2("gray", S_BAR),
2931
+ secondarySymbol: r2 = styleText2("gray", S_BAR),
2932
+ output: m = process.stdout,
2933
+ spacing: l2 = 1,
2934
+ withGuide: c2
2935
+ } = {}) => {
2936
+ const t2 = [], o2 = c2 ?? settings.withGuide, f = o2 ? r2 : "", O = o2 ? `${e} ` : "", u3 = o2 ? `${r2} ` : "";
2937
+ for (let i2 = 0; i2 < l2; i2++)
2938
+ t2.push(f);
2939
+ const g = Array.isArray(s) ? s : s.split(`
2785
2940
  `);
2786
- if (g.length > 0) {
2787
- const [p2, ...f2] = g;
2788
- p2.length > 0 ? a.push(`${l}${p2}`) : a.push(c ? i : "");
2789
- for (const h2 of f2) h2.length > 0 ? a.push(`${d}${h2}`) : a.push(c ? s : "");
2790
- }
2791
- r.write(`${a.join(`
2941
+ if (g.length > 0) {
2942
+ const [i2, ...y] = g;
2943
+ i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o2 ? e : "");
2944
+ for (const p of y)
2945
+ p.length > 0 ? t2.push(`${u3}${p}`) : t2.push(o2 ? r2 : "");
2946
+ }
2947
+ m.write(`${t2.join(`
2792
2948
  `)}
2793
2949
  `);
2794
- }, info: (t, i) => {
2795
- R2.message(t, { ...i, symbol: e("blue", ht2) });
2796
- }, success: (t, i) => {
2797
- R2.message(t, { ...i, symbol: e("green", pt) });
2798
- }, step: (t, i) => {
2799
- R2.message(t, { ...i, symbol: e("green", H) });
2800
- }, warn: (t, i) => {
2801
- R2.message(t, { ...i, symbol: e("yellow", mt) });
2802
- }, warning: (t, i) => {
2803
- R2.warn(t, i);
2804
- }, error: (t, i) => {
2805
- R2.message(t, { ...i, symbol: e("red", gt) });
2806
- } };
2807
- var ge = (t = "", i) => {
2808
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", lt)} ` : "";
2809
- s.write(`${r}${t}
2950
+ },
2951
+ info: (s, e) => {
2952
+ log.message(s, { ...e, symbol: styleText2("blue", S_INFO) });
2953
+ },
2954
+ success: (s, e) => {
2955
+ log.message(s, { ...e, symbol: styleText2("green", S_SUCCESS) });
2956
+ },
2957
+ step: (s, e) => {
2958
+ log.message(s, { ...e, symbol: styleText2("green", S_STEP_SUBMIT) });
2959
+ },
2960
+ warn: (s, e) => {
2961
+ log.message(s, { ...e, symbol: styleText2("yellow", S_WARN) });
2962
+ },
2963
+ /** alias for `log.warn()`. */
2964
+ warning: (s, e) => {
2965
+ log.warn(s, e);
2966
+ },
2967
+ error: (s, e) => {
2968
+ log.message(s, { ...e, symbol: styleText2("red", S_ERROR) });
2969
+ }
2970
+ };
2971
+ var intro = (o2 = "", t2) => {
2972
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
2973
+ i2.write(`${e}${o2}
2810
2974
  `);
2811
2975
  };
2812
- var ye = (t = "", i) => {
2813
- const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", $)}
2814
- ${e("gray", x2)} ` : "";
2815
- s.write(`${r}${t}
2976
+ var outro = (o2 = "", t2) => {
2977
+ const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
2978
+ ${styleText2("gray", S_BAR_END)} ` : "";
2979
+ i2.write(`${e}${o2}
2816
2980
 
2817
2981
  `);
2818
2982
  };
2819
- var jt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
2820
- var it2 = (t, i) => t.includes(`
2821
- `) ? t.split(`
2822
- `).map((s) => i(s)).join(`
2823
- `) : i(t);
2824
- var xe = (t) => {
2825
- const i = (s, r) => {
2826
- const u = s.label ?? String(s.value);
2827
- switch (r) {
2983
+ var u2 = {
2984
+ light: unicodeOr("\u2500", "-"),
2985
+ heavy: unicodeOr("\u2501", "="),
2986
+ block: unicodeOr("\u2588", "#")
2987
+ };
2988
+ var c = (e, a2) => e.includes(`
2989
+ `) ? e.split(`
2990
+ `).map((t2) => a2(t2)).join(`
2991
+ `) : a2(e);
2992
+ var select = (e) => {
2993
+ const a2 = (t2, d) => {
2994
+ const s = t2.label ?? String(t2.value);
2995
+ switch (d) {
2828
2996
  case "disabled":
2829
- return `${e("gray", U)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
2997
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (n2) => styleText2("gray", n2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}`;
2830
2998
  case "selected":
2831
- return `${it2(u, (n) => e("dim", n))}`;
2999
+ return `${c(s, (n2) => styleText2("dim", n2))}`;
2832
3000
  case "active":
2833
- return `${e("green", z4)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
3001
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}`;
2834
3002
  case "cancelled":
2835
- return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
3003
+ return `${c(s, (n2) => styleText2(["strikethrough", "dim"], n2))}`;
2836
3004
  default:
2837
- return `${e("dim", U)} ${it2(u, (n) => e("dim", n))}`;
3005
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (n2) => styleText2("dim", n2))}`;
2838
3006
  }
2839
3007
  };
2840
- return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
2841
- const s = t.withGuide ?? h.withGuide, r = `${P(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, r), a = `${s ? `${e("gray", $)}
2842
- ` : ""}${n}
3008
+ return new a({
3009
+ options: e.options,
3010
+ signal: e.signal,
3011
+ input: e.input,
3012
+ output: e.output,
3013
+ initialValue: e.initialValue,
3014
+ render() {
3015
+ const t2 = e.withGuide ?? settings.withGuide, d = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, n2 = wrapTextWithPrefix(
3016
+ e.output,
3017
+ e.message,
3018
+ s,
3019
+ d
3020
+ ), u3 = `${t2 ? `${styleText2("gray", S_BAR)}
3021
+ ` : ""}${n2}
2843
3022
  `;
3023
+ switch (this.state) {
3024
+ case "submit": {
3025
+ const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(
3026
+ e.output,
3027
+ a2(this.options[this.cursor], "selected"),
3028
+ r2
3029
+ );
3030
+ return `${u3}${l2}`;
3031
+ }
3032
+ case "cancel": {
3033
+ const r2 = t2 ? `${styleText2("gray", S_BAR)} ` : "", l2 = wrapTextWithPrefix(
3034
+ e.output,
3035
+ a2(this.options[this.cursor], "cancelled"),
3036
+ r2
3037
+ );
3038
+ return `${u3}${l2}${t2 ? `
3039
+ ${styleText2("gray", S_BAR)}` : ""}`;
3040
+ }
3041
+ default: {
3042
+ const r2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = t2 ? styleText2("cyan", S_BAR_END) : "", g = u3.split(`
3043
+ `).length, h2 = t2 ? 2 : 1;
3044
+ return `${u3}${r2}${limitOptions({
3045
+ output: e.output,
3046
+ cursor: this.cursor,
3047
+ options: this.options,
3048
+ maxItems: e.maxItems,
3049
+ columnPadding: r2.length,
3050
+ rowPadding: g + h2,
3051
+ style: (p, b) => a2(p, p.disabled ? "disabled" : b ? "active" : "inactive")
3052
+ }).join(`
3053
+ ${r2}`)}
3054
+ ${l2}
3055
+ `;
3056
+ }
3057
+ }
3058
+ }
3059
+ }).prompt();
3060
+ };
3061
+ var i = `${styleText2("gray", S_BAR)} `;
3062
+ var text = (t2) => new n({
3063
+ validate: t2.validate,
3064
+ placeholder: t2.placeholder,
3065
+ defaultValue: t2.defaultValue,
3066
+ initialValue: t2.initialValue,
3067
+ output: t2.output,
3068
+ signal: t2.signal,
3069
+ input: t2.input,
3070
+ render() {
3071
+ const i2 = t2?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
3072
+ ` : ""}${symbol(this.state)} `}${t2.message}
3073
+ `, c2 = t2.placeholder ? styleText2("inverse", t2.placeholder[0]) + styleText2("dim", t2.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o2 = this.userInput ? this.userInputWithCursor : c2, a2 = this.value ?? "";
2844
3074
  switch (this.state) {
3075
+ case "error": {
3076
+ const n2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d = i2 ? styleText2("yellow", S_BAR_END) : "";
3077
+ return `${s.trim()}
3078
+ ${r2}${o2}
3079
+ ${d}${n2}
3080
+ `;
3081
+ }
2845
3082
  case "submit": {
2846
- const c = s ? `${e("gray", $)} ` : "", o = W(t.output, i(this.options[this.cursor], "selected"), c);
2847
- return `${a}${o}`;
3083
+ const n2 = a2 ? ` ${styleText2("dim", a2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
3084
+ return `${s}${r2}${n2}`;
2848
3085
  }
2849
3086
  case "cancel": {
2850
- const c = s ? `${e("gray", $)} ` : "", o = W(t.output, i(this.options[this.cursor], "cancelled"), c);
2851
- return `${a}${o}${s ? `
2852
- ${e("gray", $)}` : ""}`;
3087
+ const n2 = a2 ? ` ${styleText2(["strikethrough", "dim"], a2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
3088
+ return `${s}${r2}${n2}${a2.trim() ? `
3089
+ ${r2}` : ""}`;
2853
3090
  }
2854
3091
  default: {
2855
- const c = s ? `${e("cyan", $)} ` : "", o = s ? e("cyan", x2) : "", l = a.split(`
2856
- `).length, d = s ? 2 : 1;
2857
- return `${a}${c}${F({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c.length, rowPadding: l + d, style: (g, p2) => i(g, g.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
2858
- ${c}`)}
2859
- ${o}
3092
+ const n2 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
3093
+ return `${s}${n2}${o2}
3094
+ ${r2}
2860
3095
  `;
2861
3096
  }
2862
3097
  }
2863
- } }).prompt();
2864
- };
2865
- var Nt = `${e("gray", $)} `;
2866
- var Pe = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
2867
- const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $)}
2868
- ` : ""}${P(this.state)} `}${t.message}
2869
- `, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
2870
- switch (this.state) {
2871
- case "error": {
2872
- const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $)} ` : "", o = i ? e("yellow", x2) : "";
2873
- return `${s.trim()}
2874
- ${c}${u}
2875
- ${o}${a}
2876
- `;
2877
- }
2878
- case "submit": {
2879
- const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $) : "";
2880
- return `${s}${c}${a}`;
2881
- }
2882
- case "cancel": {
2883
- const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $) : "";
2884
- return `${s}${c}${a}${n.trim() ? `
2885
- ${c}` : ""}`;
2886
- }
2887
- default: {
2888
- const a = i ? `${e("cyan", $)} ` : "", c = i ? e("cyan", x2) : "";
2889
- return `${s}${a}${u}
2890
- ${c}
2891
- `;
2892
- }
2893
3098
  }
2894
- } }).prompt();
3099
+ }).prompt();
2895
3100
 
2896
3101
  // src/cli/open-editor.ts
2897
3102
  import { spawn } from "child_process";
2898
3103
  import { resolve as resolve2 } from "path";
2899
- var isCodeFamily = (cmd) => /(^|\/)code(-insiders)?(\.exe)?$/i.test(cmd) || /(^|\/)cursor(\.exe)?$/i.test(cmd);
2900
- function pickEditor(env, override) {
3104
+ var is_code_family = (cmd) => /(^|\/)code(-insiders)?(\.exe)?$/i.test(cmd) || /(^|\/)cursor(\.exe)?$/i.test(cmd);
3105
+ function pick_editor(env, override) {
2901
3106
  if (override) return override;
2902
3107
  return env.VISUAL || env.EDITOR || "vi";
2903
3108
  }
2904
- function editorArgs(editor, file, line) {
2905
- if (line && isCodeFamily(editor)) return ["--goto", `${file}:${line}`];
3109
+ function editor_args(editor, file, line) {
3110
+ if (line && is_code_family(editor)) return ["--goto", `${file}:${line}`];
2906
3111
  if (line) return [`+${line}`, file];
2907
3112
  return [file];
2908
3113
  }
2909
- async function openInEditor(file, line, deps) {
2910
- const editor = pickEditor(process.env, deps.editor);
2911
- const absPath = resolve2(deps.rootDir, file);
2912
- const args = editorArgs(editor, absPath, line);
3114
+ async function open_in_editor(file, line, deps) {
3115
+ const editor = pick_editor(process.env, deps.editor);
3116
+ const abs_path = resolve2(deps.root_dir, file);
3117
+ const args = editor_args(editor, abs_path, line);
2913
3118
  return await new Promise((resolveP) => {
2914
3119
  const child = spawn(editor, args, {
2915
3120
  /* c8 ignore next — "inherit" path runs only inside a real TTY. */
@@ -2939,30 +3144,30 @@ function classify(chunk) {
2939
3144
  if (matches(chunk, "/")) return "slash";
2940
3145
  return null;
2941
3146
  }
2942
- function enableVimKeys(stdin) {
2943
- const origEmit = stdin.emit.bind(stdin);
3147
+ function enableVimKeys(stdin2) {
3148
+ const orig_emit = stdin2.emit.bind(stdin2);
2944
3149
  let active = true;
2945
- const slashListeners = [];
3150
+ const slash_listeners = [];
2946
3151
  const patched = (event, ...args) => {
2947
3152
  if (active && event === "data" && args[0] instanceof Buffer) {
2948
3153
  const direction = classify(args[0]);
2949
- if (direction === "down") return origEmit("data", DOWN);
2950
- if (direction === "up") return origEmit("data", UP);
2951
- if (direction === "cancel") return origEmit("data", ESC2);
3154
+ if (direction === "down") return orig_emit("data", DOWN);
3155
+ if (direction === "up") return orig_emit("data", UP);
3156
+ if (direction === "cancel") return orig_emit("data", ESC2);
2952
3157
  if (direction === "slash") {
2953
- for (const cb of slashListeners) cb();
2954
- return origEmit("data", ESC2);
3158
+ for (const cb of slash_listeners) cb();
3159
+ return orig_emit("data", ESC2);
2955
3160
  }
2956
3161
  }
2957
- return origEmit(event, ...args);
3162
+ return orig_emit(event, ...args);
2958
3163
  };
2959
- stdin.emit = patched;
3164
+ stdin2.emit = patched;
2960
3165
  let restored = false;
2961
3166
  return {
2962
3167
  restore: () => {
2963
3168
  if (restored) return;
2964
3169
  restored = true;
2965
- if (stdin.emit === patched) stdin.emit = origEmit;
3170
+ if (stdin2.emit === patched) stdin2.emit = orig_emit;
2966
3171
  },
2967
3172
  pause: () => {
2968
3173
  active = false;
@@ -2970,19 +3175,19 @@ function enableVimKeys(stdin) {
2970
3175
  resume: () => {
2971
3176
  active = true;
2972
3177
  },
2973
- onSlash: (cb) => {
2974
- slashListeners.push(cb);
3178
+ on_slash: (cb) => {
3179
+ slash_listeners.push(cb);
2975
3180
  return () => {
2976
- const i = slashListeners.indexOf(cb);
2977
- if (i >= 0) slashListeners.splice(i, 1);
3181
+ const i2 = slash_listeners.indexOf(cb);
3182
+ if (i2 >= 0) slash_listeners.splice(i2, 1);
2978
3183
  };
2979
3184
  }
2980
3185
  };
2981
3186
  }
2982
3187
 
2983
3188
  // src/cli/repl.ts
2984
- var vimKeys = null;
2985
- var searchRequested = false;
3189
+ var vim_keys = null;
3190
+ var search_requested = false;
2986
3191
  var NAV_LEGEND = dim("j/k or \u2191/\u2193 move \xB7 enter pick \xB7 / search \xB7 esc/q back");
2987
3192
  var KIND_LABELS = {
2988
3193
  event: "events",
@@ -3000,39 +3205,39 @@ var KIND_ORDER = [
3000
3205
  "projection",
3001
3206
  "reaction"
3002
3207
  ];
3003
- var countByKind = (idx, kind) => {
3004
- if (kind === "event") return idx.allEventNames.size;
3005
- return idx.entries.filter((e2) => e2.kind === kind).length;
3208
+ var count_by_kind = (idx, kind) => {
3209
+ if (kind === "event") return idx.all_event_names.size;
3210
+ return idx.entries.filter((e) => e.kind === kind).length;
3006
3211
  };
3007
- var labelEntry = (e2) => {
3008
- const loc3 = e2.file ? `${e2.file}${e2.line ? `:${e2.line}` : ""}` : "";
3212
+ var label_entry = (e) => {
3213
+ const loc3 = e.file ? `${e.file}${e.line ? `:${e.line}` : ""}` : "";
3009
3214
  const where = loc3 ? ` ${dim(loc3)}` : "";
3010
- const qual = e2.qualifier ? dim(` (${e2.qualifier})`) : "";
3011
- const colored = kindColor[e2.kind](e2.name);
3215
+ const qual = e.qualifier ? dim(` (${e.qualifier})`) : "";
3216
+ const colored = kind_color[e.kind](e.name);
3012
3217
  return `${colored}${qual}${where}`;
3013
3218
  };
3014
- async function pickFromList(idx, rootDir, message, entries) {
3219
+ async function pick_from_list(idx, root_dir, message, entries) {
3015
3220
  if (entries.length === 0) {
3016
- R2.warn("nothing to show.");
3221
+ log.warn("nothing to show.");
3017
3222
  return;
3018
3223
  }
3019
- const pick = await xe({
3224
+ const pick = await select({
3020
3225
  message: `${message} ${NAV_LEGEND}`,
3021
- options: entries.map((e2) => ({
3022
- value: e2,
3023
- label: labelEntry(e2),
3024
- hint: e2.kind
3226
+ options: entries.map((e) => ({
3227
+ value: e,
3228
+ label: label_entry(e),
3229
+ hint: e.kind
3025
3230
  })),
3026
3231
  maxItems: 12
3027
3232
  });
3028
- if (q(pick)) return;
3029
- await showDetail(idx, rootDir, pick);
3233
+ if (isCancel(pick)) return;
3234
+ await show_detail(idx, root_dir, pick);
3030
3235
  }
3031
- async function showDetail(idx, rootDir, entry) {
3032
- R2.message(formatDetail(idx, entry));
3236
+ async function show_detail(idx, root_dir, entry) {
3237
+ log.message(format_detail(idx, entry));
3033
3238
  if (!entry.file) return;
3034
- const editor = pickEditor(process.env);
3035
- const action = await xe({
3239
+ const editor = pick_editor(process.env);
3240
+ const action = await select({
3036
3241
  message: `now what? ${NAV_LEGEND}`,
3037
3242
  options: [
3038
3243
  {
@@ -3042,16 +3247,16 @@ async function showDetail(idx, rootDir, entry) {
3042
3247
  }
3043
3248
  ]
3044
3249
  });
3045
- if (q(action)) return;
3046
- const result = await openInEditor(entry.file, entry.line, { rootDir });
3047
- if (!result.ok) R2.warn(`editor exited: ${result.reason ?? "unknown"}`);
3250
+ if (isCancel(action)) return;
3251
+ const result = await open_in_editor(entry.file, entry.line, { root_dir });
3252
+ if (!result.ok) log.warn(`editor exited: ${result.reason ?? "unknown"}`);
3048
3253
  }
3049
3254
  var DEFAULT_PATHS = {
3050
3255
  markdown: "act-contracts.md",
3051
3256
  "json-schema": "act-contracts.schema.json"
3052
3257
  };
3053
- async function exportRegistry(idx, rootDir) {
3054
- const format = await xe({
3258
+ async function export_registry(idx, root_dir) {
3259
+ const format = await select({
3055
3260
  message: `Export as ${NAV_LEGEND}`,
3056
3261
  options: [
3057
3262
  {
@@ -3066,85 +3271,85 @@ async function exportRegistry(idx, rootDir) {
3066
3271
  }
3067
3272
  ]
3068
3273
  });
3069
- if (q(format)) return;
3070
- vimKeys?.pause();
3071
- const path = await Pe({
3072
- message: `Save to (relative to ${dim(rootDir)}) ${dim("(esc to cancel)")}`,
3274
+ if (isCancel(format)) return;
3275
+ vim_keys?.pause();
3276
+ const path = await text({
3277
+ message: `Save to (relative to ${dim(root_dir)}) ${dim("(esc to cancel)")}`,
3073
3278
  placeholder: DEFAULT_PATHS[format],
3074
3279
  initialValue: DEFAULT_PATHS[format]
3075
3280
  });
3076
- vimKeys?.resume();
3077
- if (q(path) || !path || !path.trim()) return;
3078
- const content = format === "markdown" ? formatMarkdown(idx) : formatJsonSchema(idx);
3079
- const abs = resolve3(rootDir, path.trim());
3281
+ vim_keys?.resume();
3282
+ if (isCancel(path) || !path || !path.trim()) return;
3283
+ const content = format === "markdown" ? format_markdown(idx) : format_json_schema(idx);
3284
+ const abs = resolve3(root_dir, path.trim());
3080
3285
  try {
3081
3286
  await writeFile(abs, `${content}
3082
3287
  `, "utf8");
3083
- R2.success(`wrote ${abs}`);
3288
+ log.success(`wrote ${abs}`);
3084
3289
  } catch (err) {
3085
- R2.error(
3290
+ log.error(
3086
3291
  /* c8 ignore next — the `String(err)` arm fires only on non-Error
3087
3292
  throws, which Node fs.writeFile doesn't produce. */
3088
3293
  `could not write ${abs}: ${err instanceof Error ? err.message : String(err)}`
3089
3294
  );
3090
3295
  }
3091
3296
  }
3092
- async function searchByName(idx, rootDir) {
3093
- vimKeys?.pause();
3094
- const q2 = await Pe({
3297
+ async function search_by_name(idx, root_dir) {
3298
+ vim_keys?.pause();
3299
+ const q = await text({
3095
3300
  message: `Partial name to search ${dim("(esc to cancel)")}`,
3096
3301
  placeholder: "e.g. order, ticket, place"
3097
3302
  });
3098
- vimKeys?.resume();
3099
- if (q(q2) || !q2 || !q2.trim()) return;
3100
- const lower = q2.trim().toLowerCase();
3303
+ vim_keys?.resume();
3304
+ if (isCancel(q) || !q || !q.trim()) return;
3305
+ const lower = q.trim().toLowerCase();
3101
3306
  const kind = CATEGORY_KEYWORDS[lower];
3102
3307
  if (kind) {
3103
- await pickFromList(
3308
+ await pick_from_list(
3104
3309
  idx,
3105
- rootDir,
3310
+ root_dir,
3106
3311
  `${KIND_LABELS[kind]}`,
3107
- listByKind(idx, kind)
3312
+ list_by_kind(idx, kind)
3108
3313
  );
3109
3314
  return;
3110
3315
  }
3111
- const matches2 = search(idx, q2.trim(), 200);
3316
+ const matches2 = search(idx, q.trim(), 200);
3112
3317
  if (matches2.length === 0) {
3113
- R2.warn(`no matches for "${q2}"`);
3318
+ log.warn(`no matches for "${q}"`);
3114
3319
  return;
3115
3320
  }
3116
- await pickFromList(idx, rootDir, `matches for "${q2}"`, matches2);
3321
+ await pick_from_list(idx, root_dir, `matches for "${q}"`, matches2);
3117
3322
  }
3118
- async function runInteractive(idx, rootDir) {
3119
- vimKeys = enableVimKeys(process.stdin);
3120
- const unsub = vimKeys.onSlash(() => {
3121
- searchRequested = true;
3323
+ async function run_interactive(idx, root_dir) {
3324
+ vim_keys = enableVimKeys(process.stdin);
3325
+ const unsub = vim_keys.on_slash(() => {
3326
+ search_requested = true;
3122
3327
  });
3123
3328
  try {
3124
- await driveInteractive(idx, rootDir);
3329
+ await drive_interactive(idx, root_dir);
3125
3330
  } finally {
3126
3331
  unsub();
3127
- vimKeys.restore();
3128
- vimKeys = null;
3129
- searchRequested = false;
3332
+ vim_keys.restore();
3333
+ vim_keys = null;
3334
+ search_requested = false;
3130
3335
  }
3131
3336
  }
3132
- async function driveInteractive(idx, rootDir) {
3133
- ge("act \u2014 contracts explorer");
3134
- R2.message(formatSummary(idx));
3337
+ async function drive_interactive(idx, root_dir) {
3338
+ intro("act \u2014 contracts explorer");
3339
+ log.message(format_summary(idx));
3135
3340
  while (true) {
3136
- if (searchRequested) {
3137
- searchRequested = false;
3138
- await searchByName(idx, rootDir);
3341
+ if (search_requested) {
3342
+ search_requested = false;
3343
+ await search_by_name(idx, root_dir);
3139
3344
  continue;
3140
3345
  }
3141
- const choice = await xe({
3346
+ const choice = await select({
3142
3347
  message: `What do you want to inspect? ${NAV_LEGEND}`,
3143
3348
  options: [
3144
- ...KIND_ORDER.map((k2) => ({
3145
- value: k2,
3146
- label: kindColor[k2](KIND_LABELS[k2]),
3147
- hint: `${countByKind(idx, k2)}`
3349
+ ...KIND_ORDER.map((k) => ({
3350
+ value: k,
3351
+ label: kind_color[k](KIND_LABELS[k]),
3352
+ hint: `${count_by_kind(idx, k)}`
3148
3353
  })),
3149
3354
  {
3150
3355
  value: "export",
@@ -3154,48 +3359,48 @@ async function driveInteractive(idx, rootDir) {
3154
3359
  ],
3155
3360
  maxItems: 10
3156
3361
  });
3157
- if (q(choice)) {
3158
- if (searchRequested) continue;
3159
- ye("bye.");
3362
+ if (isCancel(choice)) {
3363
+ if (search_requested) continue;
3364
+ outro("bye.");
3160
3365
  return;
3161
3366
  }
3162
3367
  if (choice === "export") {
3163
- await exportRegistry(idx, rootDir);
3368
+ await export_registry(idx, root_dir);
3164
3369
  continue;
3165
3370
  }
3166
- await pickFromList(
3371
+ await pick_from_list(
3167
3372
  idx,
3168
- rootDir,
3373
+ root_dir,
3169
3374
  `${KIND_LABELS[choice]}`,
3170
- listByKind(idx, choice)
3375
+ list_by_kind(idx, choice)
3171
3376
  );
3172
3377
  }
3173
3378
  }
3174
3379
 
3175
3380
  // src/cli/index.ts
3176
- function parseArgs(argv) {
3381
+ function parse_args(argv) {
3177
3382
  let cwd;
3178
3383
  let help = false;
3179
3384
  let version = false;
3180
- let maxFiles;
3385
+ let max_files;
3181
3386
  let query;
3182
3387
  let markdown = false;
3183
- let jsonSchema = false;
3184
- for (let i = 0; i < argv.length; i++) {
3185
- const a = argv[i];
3186
- if (a === "-h" || a === "--help") help = true;
3187
- else if (a === "-v" || a === "--version") version = true;
3188
- else if (a === "--cwd") cwd = argv[++i] ?? cwd;
3189
- else if (a === "-q" || a === "--query") query = argv[++i] ?? query;
3190
- else if (a === "-m" || a === "--markdown" || a === "--md") markdown = true;
3191
- else if (a === "-j" || a === "--json-schema" || a === "--json")
3192
- jsonSchema = true;
3193
- else if (a === "--max-files") {
3194
- const n = Number.parseInt(argv[++i] ?? "", 10);
3195
- if (Number.isFinite(n) && n > 0) maxFiles = n;
3196
- } else if (!a.startsWith("-")) cwd = a;
3197
- }
3198
- return { cwd, help, version, maxFiles, query, markdown, jsonSchema };
3388
+ let json_schema = false;
3389
+ for (let i2 = 0; i2 < argv.length; i2++) {
3390
+ const a2 = argv[i2];
3391
+ if (a2 === "-h" || a2 === "--help") help = true;
3392
+ else if (a2 === "-v" || a2 === "--version") version = true;
3393
+ else if (a2 === "--cwd") cwd = argv[++i2] ?? cwd;
3394
+ else if (a2 === "-q" || a2 === "--query") query = argv[++i2] ?? query;
3395
+ else if (a2 === "-m" || a2 === "--markdown" || a2 === "--md") markdown = true;
3396
+ else if (a2 === "-j" || a2 === "--json-schema" || a2 === "--json")
3397
+ json_schema = true;
3398
+ else if (a2 === "--max-files") {
3399
+ const n2 = Number.parseInt(argv[++i2] ?? "", 10);
3400
+ if (Number.isFinite(n2) && n2 > 0) max_files = n2;
3401
+ } else if (!a2.startsWith("-")) cwd = a2;
3402
+ }
3403
+ return { cwd, help, version, max_files, query, markdown, json_schema };
3199
3404
  }
3200
3405
  var USAGE = [
3201
3406
  "Usage: act [dir] [-q <name>] [-m | -j] [--cwd <dir>] [--max-files <n>] [--help] [--version]",
@@ -3216,76 +3421,76 @@ var USAGE = [
3216
3421
  "file path you choose."
3217
3422
  ].join("\n");
3218
3423
  async function main(deps) {
3219
- const args = parseArgs(deps.argv);
3424
+ const args = parse_args(deps.argv);
3220
3425
  if (args.help) {
3221
3426
  deps.output.write(USAGE + "\n");
3222
3427
  return 0;
3223
3428
  }
3224
3429
  if (args.version) {
3225
- deps.output.write(deps.versionString + "\n");
3430
+ deps.output.write(deps.version_string + "\n");
3226
3431
  return 0;
3227
3432
  }
3228
- const rootDir = resolve4(args.cwd ?? deps.defaultDir ?? ".");
3229
- const { files, truncated } = await loadProject(rootDir, {
3230
- maxFiles: args.maxFiles
3433
+ const root_dir = resolve4(args.cwd ?? deps.default_dir ?? ".");
3434
+ const { files, truncated } = await load_project(root_dir, {
3435
+ max_files: args.max_files
3231
3436
  });
3232
3437
  if (files.length === 0) {
3233
- deps.errorOutput.write(
3234
- `act: no TypeScript source files found under ${rootDir}
3438
+ deps.error_output.write(
3439
+ `act: no TypeScript source files found under ${root_dir}
3235
3440
  `
3236
3441
  );
3237
3442
  return 1;
3238
3443
  }
3239
3444
  if (truncated) {
3240
- deps.errorOutput.write(
3445
+ deps.error_output.write(
3241
3446
  "act: scan was truncated (file cap reached); some sources may be missing.\n"
3242
3447
  );
3243
3448
  }
3244
- const { model, error } = extractModel(files);
3449
+ const { model, error } = extract_model(files);
3245
3450
  if (error) {
3246
- deps.errorOutput.write(`act: parse error \u2014 ${error}
3451
+ deps.error_output.write(`act: parse error \u2014 ${error}
3247
3452
  `);
3248
3453
  }
3249
- const idx = buildContractIndex(model);
3454
+ const idx = build_contract_index(model);
3250
3455
  if (args.markdown) {
3251
- deps.output.write(`${formatMarkdown(idx)}
3456
+ deps.output.write(`${format_markdown(idx)}
3252
3457
  `);
3253
3458
  return 0;
3254
3459
  }
3255
- if (args.jsonSchema) {
3256
- deps.output.write(`${formatJsonSchema(idx)}
3460
+ if (args.json_schema) {
3461
+ deps.output.write(`${format_json_schema(idx)}
3257
3462
  `);
3258
3463
  return 0;
3259
3464
  }
3260
3465
  if (args.query) {
3261
3466
  const matches2 = search(idx, args.query);
3262
3467
  if (matches2.length === 0) {
3263
- deps.errorOutput.write(`act: no matches for "${args.query}"
3468
+ deps.error_output.write(`act: no matches for "${args.query}"
3264
3469
  `);
3265
3470
  return 1;
3266
3471
  }
3267
3472
  const exact = matches2.filter(
3268
- (m2) => m2.name.toLowerCase() === args.query.toLowerCase()
3473
+ (m) => m.name.toLowerCase() === args.query.toLowerCase()
3269
3474
  );
3270
- const equivKey = (m2) => `${m2.kind}\0${m2.name}\0${m2.qualifier ?? ""}`;
3271
- const uniqExact = Array.from(
3272
- new Map(exact.map((m2) => [equivKey(m2), m2])).values()
3475
+ const equiv_key = (m) => `${m.kind}\0${m.name}\0${m.qualifier ?? ""}`;
3476
+ const uniq_exact = Array.from(
3477
+ new Map(exact.map((m) => [equiv_key(m), m])).values()
3273
3478
  );
3274
- if (uniqExact.length === 1) {
3275
- deps.output.write(formatDetail(idx, uniqExact[0]) + "\n");
3479
+ if (uniq_exact.length === 1) {
3480
+ deps.output.write(format_detail(idx, uniq_exact[0]) + "\n");
3276
3481
  return 0;
3277
3482
  }
3278
- const uniqMatches = Array.from(
3279
- new Map(matches2.map((m2) => [equivKey(m2), m2])).values()
3483
+ const uniq_matches = Array.from(
3484
+ new Map(matches2.map((m) => [equiv_key(m), m])).values()
3280
3485
  );
3281
- if (uniqMatches.length === 1) {
3282
- deps.output.write(formatDetail(idx, uniqMatches[0]) + "\n");
3486
+ if (uniq_matches.length === 1) {
3487
+ deps.output.write(format_detail(idx, uniq_matches[0]) + "\n");
3283
3488
  return 0;
3284
3489
  }
3285
- deps.output.write(formatMatches(args.query, uniqMatches) + "\n");
3490
+ deps.output.write(format_matches(args.query, uniq_matches) + "\n");
3286
3491
  return 0;
3287
3492
  }
3288
- await (deps.runInteractive ?? runInteractive)(idx, rootDir);
3493
+ await (deps.run_interactive ?? run_interactive)(idx, root_dir);
3289
3494
  return 0;
3290
3495
  }
3291
3496
  var isMain = (() => {
@@ -3301,11 +3506,11 @@ if (isMain) {
3301
3506
  main({
3302
3507
  input: process.stdin,
3303
3508
  output: process.stdout,
3304
- errorOutput: process.stderr,
3509
+ error_output: process.stderr,
3305
3510
  isTTY: !!process.stdout.isTTY,
3306
3511
  argv: process.argv.slice(2),
3307
- versionString: "act (act-diagram)",
3308
- defaultDir: process.env.INIT_CWD ?? process.cwd()
3512
+ version_string: "act (act-diagram)",
3513
+ default_dir: process.env.INIT_CWD ?? process.cwd()
3309
3514
  }).then(
3310
3515
  (code) => process.exit(code),
3311
3516
  (err) => {
@@ -3319,6 +3524,6 @@ if (isMain) {
3319
3524
  }
3320
3525
  export {
3321
3526
  main,
3322
- parseArgs
3527
+ parse_args
3323
3528
  };
3324
3529
  //# sourceMappingURL=act.js.map