cvm-server 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/main.cjs +943 -529
  2. package/package.json +1 -1
package/main.cjs CHANGED
@@ -3,7 +3,7 @@ const mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
3
3
  const stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
4
4
  const zod = require("zod");
5
5
  const s$1 = require("typescript");
6
- const x$2 = require("fs");
6
+ const b$2 = require("fs");
7
7
  const r = require("path");
8
8
  const mongodb = require("mongodb");
9
9
  const promises = require("fs/promises");
@@ -11,31 +11,31 @@ const dotenv = require("dotenv");
11
11
  const url = require("url");
12
12
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
13
13
  function _interopNamespaceDefault(e2) {
14
- const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
14
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
15
  if (e2) {
16
16
  for (const k2 in e2) {
17
17
  if (k2 !== "default") {
18
18
  const d2 = Object.getOwnPropertyDescriptor(e2, k2);
19
- Object.defineProperty(n2, k2, d2.get ? d2 : {
19
+ Object.defineProperty(n, k2, d2.get ? d2 : {
20
20
  enumerable: true,
21
21
  get: () => e2[k2]
22
22
  });
23
23
  }
24
24
  }
25
25
  }
26
- n2.default = e2;
27
- return Object.freeze(n2);
26
+ n.default = e2;
27
+ return Object.freeze(n);
28
28
  }
29
29
  const s__namespace = /* @__PURE__ */ _interopNamespaceDefault(s$1);
30
- const x__namespace = /* @__PURE__ */ _interopNamespaceDefault(x$2);
30
+ const b__namespace = /* @__PURE__ */ _interopNamespaceDefault(b$2);
31
31
  const r__namespace = /* @__PURE__ */ _interopNamespaceDefault(r);
32
32
  const dotenv__namespace = /* @__PURE__ */ _interopNamespaceDefault(dotenv);
33
- var E$1 = Object.defineProperty;
34
- var _ = (e2, t2, i2) => t2 in e2 ? E$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: i2 }) : e2[t2] = i2;
35
- var x$1 = (e2, t2, i2) => _(e2, typeof t2 != "symbol" ? t2 + "" : t2, i2);
36
- var n = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.ARRAY_SLICE = "ARRAY_SLICE", e2.ARRAY_JOIN = "ARRAY_JOIN", e2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.STRING_INCLUDES = "STRING_INCLUDES", e2.STRING_ENDS_WITH = "STRING_ENDS_WITH", e2.STRING_STARTS_WITH = "STRING_STARTS_WITH", e2.STRING_TRIM = "STRING_TRIM", e2.STRING_TRIM_START = "STRING_TRIM_START", e2.STRING_TRIM_END = "STRING_TRIM_END", e2.STRING_REPLACE = "STRING_REPLACE", e2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", e2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", e2.STRING_REPEAT = "STRING_REPEAT", e2.STRING_PAD_START = "STRING_PAD_START", e2.STRING_PAD_END = "STRING_PAD_END", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(n || {});
37
- function f$3(e2) {
38
- const t2 = [], i2 = [];
33
+ var o$1 = Object.defineProperty;
34
+ var I = (e2, t2, n) => t2 in e2 ? o$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: n }) : e2[t2] = n;
35
+ var _$1 = (e2, t2, n) => I(e2, typeof t2 != "symbol" ? t2 + "" : t2, n);
36
+ var i$2 = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.ARRAY_SLICE = "ARRAY_SLICE", e2.ARRAY_JOIN = "ARRAY_JOIN", e2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.STRING_INCLUDES = "STRING_INCLUDES", e2.STRING_ENDS_WITH = "STRING_ENDS_WITH", e2.STRING_STARTS_WITH = "STRING_STARTS_WITH", e2.STRING_TRIM = "STRING_TRIM", e2.STRING_TRIM_START = "STRING_TRIM_START", e2.STRING_TRIM_END = "STRING_TRIM_END", e2.STRING_REPLACE = "STRING_REPLACE", e2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", e2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", e2.STRING_REPEAT = "STRING_REPEAT", e2.STRING_PAD_START = "STRING_PAD_START", e2.STRING_PAD_END = "STRING_PAD_END", e2.LOAD_REGEX = "LOAD_REGEX", e2.REGEX_TEST = "REGEX_TEST", e2.STRING_MATCH = "STRING_MATCH", e2.STRING_REPLACE_REGEX = "STRING_REPLACE_REGEX", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.OBJECT_ITER_START = "OBJECT_ITER_START", e2.OBJECT_ITER_NEXT = "OBJECT_ITER_NEXT", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.OBJECT_KEYS = "OBJECT_KEYS", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(i$2 || {});
37
+ function A$1(e2) {
38
+ const t2 = [], n = [];
39
39
  let r2 = false;
40
40
  const a2 = s__namespace.createSourceFile(
41
41
  "program.ts",
@@ -43,30 +43,31 @@ function f$3(e2) {
43
43
  s__namespace.ScriptTarget.Latest,
44
44
  true
45
45
  );
46
- function m2(T2) {
47
- if (s__namespace.isFunctionDeclaration(T2) && T2.name && T2.name.text === "main" && (r2 = true, T2.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(T2) && s__namespace.isIdentifier(T2.expression)) {
48
- const l2 = T2.expression.text;
49
- ["setTimeout", "fetch", "require", "import"].includes(l2) && t2.push(`Unsupported function: ${l2}`);
46
+ function m2(T) {
47
+ if (s__namespace.isFunctionDeclaration(T) && T.name && T.name.text === "main" && (r2 = true, T.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(T) && s__namespace.isIdentifier(T.expression)) {
48
+ const l = T.expression.text;
49
+ ["setTimeout", "fetch", "require", "import"].includes(l) && t2.push(`Unsupported function: ${l}`);
50
50
  }
51
- s__namespace.forEachChild(T2, m2);
51
+ s__namespace.forEachChild(T, m2);
52
52
  }
53
- return m2(a2), r2 || t2.push("Program must have a main() function"), t2.length === 0 && i2.push({ op: n.HALT }), {
54
- bytecode: i2,
53
+ return m2(a2), r2 || t2.push("Program must have a main() function"), t2.length === 0 && n.push({ op: i$2.HALT }), {
54
+ bytecode: n,
55
55
  errors: t2,
56
56
  hasMain: r2
57
57
  };
58
58
  }
59
- class I {
59
+ class g {
60
60
  constructor() {
61
- x$1(this, "bytecode", []);
62
- x$1(this, "contextStack", []);
61
+ _$1(this, "bytecode", []);
62
+ _$1(this, "contextStack", []);
63
+ _$1(this, "tempVarCounter", 0);
63
64
  }
64
65
  /**
65
66
  * Emit an instruction and return its index
66
67
  */
67
- emit(t2, i2) {
68
+ emit(t2, n) {
68
69
  const r2 = this.bytecode.length;
69
- return this.bytecode.push({ op: t2, arg: i2 }), r2;
70
+ return this.bytecode.push({ op: t2, arg: n }), r2;
70
71
  }
71
72
  /**
72
73
  * Get the current address (next instruction index)
@@ -77,14 +78,14 @@ class I {
77
78
  /**
78
79
  * Patch a jump instruction with the target address
79
80
  */
80
- patchJump(t2, i2) {
81
- t2 >= 0 && t2 < this.bytecode.length && (this.bytecode[t2].arg = i2);
81
+ patchJump(t2, n) {
82
+ t2 >= 0 && t2 < this.bytecode.length && (this.bytecode[t2].arg = n);
82
83
  }
83
84
  /**
84
85
  * Patch multiple jump instructions with the same target
85
86
  */
86
- patchJumps(t2, i2) {
87
- t2.forEach((r2) => this.patchJump(r2, i2));
87
+ patchJumps(t2, n) {
88
+ t2.forEach((r2) => this.patchJump(r2, n));
88
89
  }
89
90
  /**
90
91
  * Push a new jump context onto the stack
@@ -109,9 +110,9 @@ class I {
109
110
  */
110
111
  findLoopContext() {
111
112
  for (let t2 = this.contextStack.length - 1; t2 >= 0; t2--) {
112
- const i2 = this.contextStack[t2];
113
- if (i2.type === "loop" || i2.type === "foreach")
114
- return i2;
113
+ const n = this.contextStack[t2];
114
+ if (n.type === "loop" || n.type === "foreach")
115
+ return n;
115
116
  }
116
117
  return null;
117
118
  }
@@ -133,326 +134,444 @@ class I {
133
134
  getUnclosedContexts() {
134
135
  return [...this.contextStack];
135
136
  }
137
+ /**
138
+ * Generate a unique temporary variable name
139
+ */
140
+ generateTempVar() {
141
+ return `__temp${this.tempVarCounter++}`;
142
+ }
136
143
  }
137
- const A = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
138
- i2(e2.expression);
139
- const a2 = t2.emit(n.JUMP_IF_FALSE, -1), m2 = {
144
+ const P = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
145
+ n(e2.expression);
146
+ const a2 = t2.emit(i$2.JUMP_IF_FALSE, -1), m2 = {
140
147
  type: "if",
141
148
  endTargets: []
142
149
  };
143
150
  if (e2.elseStatement ? m2.elseTarget = a2 : m2.endTargets.push(a2), t2.pushContext(m2), r2(e2.thenStatement), e2.elseStatement) {
144
- const l2 = t2.emit(n.JUMP, -1);
145
- m2.endTargets.push(l2);
151
+ const l = t2.emit(i$2.JUMP, -1);
152
+ m2.endTargets.push(l);
146
153
  const S = t2.currentAddress();
147
154
  t2.patchJump(a2, S), r2(e2.elseStatement);
148
155
  }
149
- const T2 = t2.popContext();
150
- if (T2) {
151
- const l2 = t2.currentAddress();
152
- t2.patchJumps(T2.endTargets, l2);
156
+ const T = t2.popContext();
157
+ if (T) {
158
+ const l = t2.currentAddress();
159
+ t2.patchJumps(T.endTargets, l);
153
160
  }
154
- }, o$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
161
+ }, N = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
155
162
  const a2 = t2.currentAddress();
156
- i2(e2.expression);
157
- const T2 = {
163
+ n(e2.expression);
164
+ const T = {
158
165
  type: "loop",
159
- breakTargets: [t2.emit(n.JUMP_IF_FALSE, -1)],
166
+ breakTargets: [t2.emit(i$2.JUMP_IF_FALSE, -1)],
160
167
  continueTargets: [],
161
168
  endTargets: [],
162
169
  startAddress: a2
163
170
  };
164
- t2.pushContext(T2), r2(e2.statement), t2.emit(n.JUMP, a2);
165
- const l2 = t2.popContext();
166
- if (l2) {
171
+ t2.pushContext(T), r2(e2.statement), t2.emit(i$2.JUMP, a2);
172
+ const l = t2.popContext();
173
+ if (l) {
167
174
  const S = t2.currentAddress();
168
- t2.patchJumps(l2.breakTargets || [], S);
175
+ t2.patchJumps(l.breakTargets || [], S);
169
176
  }
170
- }, N = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
177
+ }, h$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
171
178
  const a2 = e2.initializer, m2 = e2.expression;
172
- let T2;
179
+ let T;
173
180
  if (s__namespace.isVariableDeclarationList(a2))
174
- T2 = a2.declarations[0].name.getText();
181
+ T = a2.declarations[0].name.getText();
175
182
  else if (s__namespace.isIdentifier(a2))
176
- T2 = a2.text;
183
+ T = a2.text;
177
184
  else
178
185
  throw new Error("Unsupported for-of variable declaration");
179
- i2(m2), t2.emit(n.ITER_START);
180
- const l2 = t2.currentAddress();
181
- t2.emit(n.ITER_NEXT);
182
- const S = t2.emit(n.JUMP_IF_FALSE, -1);
183
- t2.emit(n.STORE, T2);
184
- const c2 = {
186
+ n(m2), t2.emit(i$2.ITER_START);
187
+ const l = t2.currentAddress();
188
+ t2.emit(i$2.ITER_NEXT);
189
+ const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
190
+ t2.emit(i$2.STORE, T);
191
+ const u2 = {
185
192
  type: "foreach",
186
193
  breakTargets: [S],
187
194
  continueTargets: [],
188
195
  endTargets: [],
189
- startAddress: l2,
190
- iterVariable: T2
196
+ startAddress: l,
197
+ iterVariable: T
191
198
  };
192
- t2.pushContext(c2), r2(e2.statement), t2.emit(n.JUMP, l2);
193
- const R = t2.popContext();
194
- if (R) {
195
- const u2 = t2.currentAddress();
196
- t2.patchJumps(R.breakTargets || [], u2), t2.emit(n.ITER_END);
199
+ t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, l);
200
+ const c2 = t2.popContext();
201
+ if (c2) {
202
+ const R = t2.currentAddress();
203
+ t2.patchJumps(c2.breakTargets || [], R), t2.emit(i$2.ITER_END);
197
204
  }
198
- }, P$1 = (e2, t2, { compileStatement: i2 }) => {
205
+ }, p$2 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
206
+ const a2 = e2.initializer, m2 = e2.expression;
207
+ let T;
208
+ if (s__namespace.isVariableDeclarationList(a2))
209
+ T = a2.declarations[0].name.getText();
210
+ else if (s__namespace.isIdentifier(a2))
211
+ T = a2.text;
212
+ else
213
+ throw new Error("Unsupported for-in variable declaration");
214
+ n(m2), t2.emit(i$2.OBJECT_ITER_START);
215
+ const l = t2.currentAddress();
216
+ t2.emit(i$2.OBJECT_ITER_NEXT);
217
+ const S = t2.emit(i$2.JUMP_IF_FALSE, -1);
218
+ t2.emit(i$2.STORE, T);
219
+ const u2 = {
220
+ type: "foreach",
221
+ breakTargets: [S],
222
+ continueTargets: [],
223
+ endTargets: [],
224
+ startAddress: l,
225
+ iterVariable: T
226
+ };
227
+ t2.pushContext(u2), r2(e2.statement), t2.emit(i$2.JUMP, l);
228
+ const c2 = t2.popContext();
229
+ if (c2) {
230
+ const R = t2.currentAddress();
231
+ t2.patchJumps(c2.breakTargets || [], R), t2.emit(i$2.ITER_END);
232
+ }
233
+ }, U = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
234
+ if (e2.initializer)
235
+ if (s__namespace.isVariableDeclarationList(e2.initializer))
236
+ for (const S of e2.initializer.declarations)
237
+ S.initializer && (n(S.initializer), t2.emit(i$2.STORE, S.name.getText()));
238
+ else
239
+ n(e2.initializer), t2.emit(i$2.POP);
240
+ const a2 = t2.currentAddress();
241
+ let m2;
242
+ e2.condition && (n(e2.condition), m2 = t2.emit(i$2.JUMP_IF_FALSE, -1));
243
+ const T = {
244
+ type: "loop",
245
+ breakTargets: m2 ? [m2] : [],
246
+ continueTargets: [],
247
+ endTargets: [],
248
+ startAddress: a2
249
+ };
250
+ t2.pushContext(T), r2(e2.statement), e2.incrementor && (n(e2.incrementor), t2.emit(i$2.POP)), t2.emit(i$2.JUMP, a2);
251
+ const l = t2.popContext();
252
+ if (l) {
253
+ const S = t2.currentAddress();
254
+ t2.patchJumps(l.breakTargets || [], S);
255
+ }
256
+ }, y$1 = (e2, t2, { compileExpression: n, compileStatement: r2 }) => {
257
+ const a2 = t2.generateTempVar();
258
+ n(e2.expression), t2.emit(i$2.STORE, a2);
259
+ const m2 = [], T = [];
260
+ let l = null;
261
+ if (e2.caseBlock.clauses.forEach((c2, R) => {
262
+ if (s__namespace.isCaseClause(c2)) {
263
+ t2.emit(i$2.LOAD, a2), n(c2.expression), t2.emit(i$2.EQ_STRICT);
264
+ const E2 = t2.emit(i$2.JUMP_IF_TRUE, -1);
265
+ T.push(E2);
266
+ } else s__namespace.isDefaultClause(c2) && (l = t2.emit(i$2.JUMP, -1));
267
+ }), l === null) {
268
+ const c2 = t2.emit(i$2.JUMP, -1);
269
+ m2.push(c2);
270
+ }
271
+ let S = 0;
272
+ e2.caseBlock.clauses.forEach((c2, R) => {
273
+ if (s__namespace.isCaseClause(c2)) {
274
+ const E2 = t2.currentAddress();
275
+ t2.patchJumps([T[S]], E2), S++, c2.statements.forEach((x2) => {
276
+ if (s__namespace.isBreakStatement(x2)) {
277
+ const f3 = t2.emit(i$2.JUMP, -1);
278
+ m2.push(f3);
279
+ } else
280
+ r2(x2);
281
+ });
282
+ } else if (s__namespace.isDefaultClause(c2)) {
283
+ const E2 = t2.currentAddress();
284
+ l !== null && t2.patchJumps([l], E2), c2.statements.forEach((x2) => {
285
+ if (s__namespace.isBreakStatement(x2)) {
286
+ const f3 = t2.emit(i$2.JUMP, -1);
287
+ m2.push(f3);
288
+ } else
289
+ r2(x2);
290
+ });
291
+ }
292
+ });
293
+ const u2 = t2.currentAddress();
294
+ t2.patchJumps(m2, u2);
295
+ }, L = (e2, t2, { compileStatement: n }) => {
199
296
  e2.statements.forEach((r2) => {
200
- i2(r2);
297
+ n(r2);
201
298
  });
202
- }, g = (e2, t2, { compileExpression: i2 }) => {
299
+ }, k = (e2, t2, { compileExpression: n }) => {
203
300
  const r2 = e2.declarationList.declarations[0];
204
- r2.initializer && (i2(r2.initializer), t2.emit(n.STORE, r2.name.getText()));
205
- }, h$1 = (e2, t2, { compileExpression: i2 }) => {
301
+ r2.initializer && (n(r2.initializer), t2.emit(i$2.STORE, r2.name.getText()));
302
+ }, G = (e2, t2, { compileExpression: n }) => {
206
303
  const r2 = e2.expression;
207
304
  if (s__namespace.isBinaryExpression(r2)) {
208
305
  const a2 = r2.operatorToken.kind;
209
306
  if (a2 === s__namespace.SyntaxKind.PlusEqualsToken || a2 === s__namespace.SyntaxKind.MinusEqualsToken || a2 === s__namespace.SyntaxKind.AsteriskEqualsToken || a2 === s__namespace.SyntaxKind.SlashEqualsToken || a2 === s__namespace.SyntaxKind.PercentEqualsToken) {
210
307
  if (s__namespace.isIdentifier(r2.left)) {
211
- switch (t2.emit(n.LOAD, r2.left.text), i2(r2.right), a2) {
308
+ switch (t2.emit(i$2.LOAD, r2.left.text), n(r2.right), a2) {
212
309
  case s__namespace.SyntaxKind.PlusEqualsToken:
213
- t2.emit(n.ADD);
310
+ t2.emit(i$2.ADD);
214
311
  break;
215
312
  case s__namespace.SyntaxKind.MinusEqualsToken:
216
- t2.emit(n.SUB);
313
+ t2.emit(i$2.SUB);
217
314
  break;
218
315
  case s__namespace.SyntaxKind.AsteriskEqualsToken:
219
- t2.emit(n.MUL);
316
+ t2.emit(i$2.MUL);
220
317
  break;
221
318
  case s__namespace.SyntaxKind.SlashEqualsToken:
222
- t2.emit(n.DIV);
319
+ t2.emit(i$2.DIV);
223
320
  break;
224
321
  case s__namespace.SyntaxKind.PercentEqualsToken:
225
- t2.emit(n.MOD);
322
+ t2.emit(i$2.MOD);
226
323
  break;
227
324
  }
228
- t2.emit(n.STORE, r2.left.text);
325
+ t2.emit(i$2.STORE, r2.left.text);
229
326
  } else if (s__namespace.isElementAccessExpression(r2.left))
230
327
  throw new Error("Compound assignment to array elements not yet supported");
231
328
  return;
232
329
  } else if (a2 === s__namespace.SyntaxKind.EqualsToken) {
233
- if (i2(r2.right), s__namespace.isIdentifier(r2.left))
234
- t2.emit(n.STORE, r2.left.text);
330
+ if (n(r2.right), s__namespace.isIdentifier(r2.left))
331
+ t2.emit(i$2.STORE, r2.left.text);
235
332
  else if (s__namespace.isElementAccessExpression(r2.left)) {
236
333
  const m2 = `__temp_${t2.getBytecode().length}`;
237
- t2.emit(n.STORE, m2), i2(r2.left.expression), i2(r2.left.argumentExpression), t2.emit(n.LOAD, m2), t2.emit(n.ARRAY_SET), t2.emit(n.POP);
334
+ t2.emit(i$2.STORE, m2), n(r2.left.expression), n(r2.left.argumentExpression), t2.emit(i$2.LOAD, m2), t2.emit(i$2.ARRAY_SET), t2.emit(i$2.POP);
238
335
  } else if (s__namespace.isPropertyAccessExpression(r2.left)) {
239
336
  const m2 = `__temp_${t2.getBytecode().length}`;
240
- t2.emit(n.STORE, m2), i2(r2.left.expression), t2.emit(n.PUSH, r2.left.name.text), t2.emit(n.LOAD, m2), t2.emit(n.PROPERTY_SET), t2.emit(n.POP);
337
+ t2.emit(i$2.STORE, m2), n(r2.left.expression), t2.emit(i$2.PUSH, r2.left.name.text), t2.emit(i$2.LOAD, m2), t2.emit(i$2.PROPERTY_SET), t2.emit(i$2.POP);
241
338
  }
242
339
  return;
243
340
  }
244
341
  }
245
342
  s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.expression.getText() === "console" && r2.expression.name.getText() === "log" ? (r2.arguments.forEach((a2) => {
246
- i2(a2);
247
- }), t2.emit(n.PRINT)) : s__namespace.isCallExpression(r2) && s__namespace.isIdentifier(r2.expression) && r2.expression.text === "CC" ? (r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.CC), t2.emit(n.POP)) : s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.name.getText() === "push" ? (i2(r2.expression.expression), r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.ARRAY_PUSH)) : (s__namespace.isPostfixUnaryExpression(r2) || s__namespace.isPrefixUnaryExpression(r2), i2(r2), t2.emit(n.POP));
248
- }, U = (e2, t2, { compileExpression: i2 }) => {
249
- e2.expression ? i2(e2.expression) : t2.emit(n.PUSH, null), t2.emit(n.RETURN);
250
- }, p$2 = (e2, t2, i2) => {
343
+ n(a2);
344
+ }), t2.emit(i$2.PRINT)) : s__namespace.isCallExpression(r2) && s__namespace.isIdentifier(r2.expression) && r2.expression.text === "CC" ? (r2.arguments.length > 0 && n(r2.arguments[0]), t2.emit(i$2.CC), t2.emit(i$2.POP)) : s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.name.getText() === "push" ? (n(r2.expression.expression), r2.arguments.length > 0 && n(r2.arguments[0]), t2.emit(i$2.ARRAY_PUSH)) : (s__namespace.isPostfixUnaryExpression(r2) || s__namespace.isPrefixUnaryExpression(r2), n(r2), t2.emit(i$2.POP));
345
+ }, D = (e2, t2, { compileExpression: n }) => {
346
+ e2.expression ? n(e2.expression) : t2.emit(i$2.PUSH, null), t2.emit(i$2.RETURN);
347
+ }, F$1 = (e2, t2, n) => {
251
348
  const r2 = t2.findLoopContext();
252
349
  if (r2) {
253
- r2.type === "foreach" && t2.emit(n.ITER_END);
254
- const a2 = t2.emit(n.BREAK, -1);
350
+ r2.type === "foreach" && t2.emit(i$2.ITER_END);
351
+ const a2 = t2.emit(i$2.BREAK, -1);
255
352
  r2.breakTargets = r2.breakTargets || [], r2.breakTargets.push(a2);
256
353
  } else
257
- i2.reportError(e2, "break statement not in loop");
258
- }, y$1 = (e2, t2, i2) => {
354
+ n.reportError(e2, "break statement not in loop");
355
+ }, b$1 = (e2, t2, n) => {
259
356
  const r2 = t2.findLoopContext();
260
357
  if (r2 && r2.startAddress !== void 0) {
261
- const a2 = t2.emit(n.CONTINUE, r2.startAddress);
358
+ const a2 = t2.emit(i$2.CONTINUE, r2.startAddress);
262
359
  r2.continueTargets = r2.continueTargets || [], r2.continueTargets.push(a2);
263
360
  } else
264
- i2.reportError(e2, "continue statement not in loop");
265
- }, L = {
266
- [s__namespace.SyntaxKind.IfStatement]: A,
267
- [s__namespace.SyntaxKind.WhileStatement]: o$1,
268
- [s__namespace.SyntaxKind.ForOfStatement]: N,
269
- [s__namespace.SyntaxKind.Block]: P$1,
270
- [s__namespace.SyntaxKind.VariableStatement]: g,
271
- [s__namespace.SyntaxKind.ExpressionStatement]: h$1,
272
- [s__namespace.SyntaxKind.ReturnStatement]: U,
273
- [s__namespace.SyntaxKind.BreakStatement]: p$2,
274
- [s__namespace.SyntaxKind.ContinueStatement]: y$1
275
- }, k = (e2, t2, i2) => {
276
- t2.emit(n.PUSH, e2.text);
277
- }, G = (e2, t2, i2) => {
278
- t2.emit(n.PUSH, Number(e2.text));
279
- }, D$1 = (e2, t2, i2) => {
280
- t2.emit(n.PUSH, true);
281
- }, F$1 = (e2, t2, i2) => {
282
- t2.emit(n.PUSH, false);
283
- }, K = (e2, t2, i2) => {
284
- t2.emit(n.PUSH, null);
285
- }, H = (e2, t2, i2) => {
286
- e2.text === "undefined" ? t2.emit(n.PUSH_UNDEFINED) : t2.emit(n.LOAD, e2.text);
287
- }, b$2 = (e2, t2, { compileExpression: i2 }) => {
288
- t2.emit(n.ARRAY_NEW), e2.elements.forEach((r2) => {
289
- i2(r2), t2.emit(n.ARRAY_PUSH);
361
+ n.reportError(e2, "continue statement not in loop");
362
+ }, K = {
363
+ [s__namespace.SyntaxKind.IfStatement]: P,
364
+ [s__namespace.SyntaxKind.WhileStatement]: N,
365
+ [s__namespace.SyntaxKind.ForOfStatement]: h$1,
366
+ [s__namespace.SyntaxKind.ForInStatement]: p$2,
367
+ [s__namespace.SyntaxKind.ForStatement]: U,
368
+ [s__namespace.SyntaxKind.SwitchStatement]: y$1,
369
+ [s__namespace.SyntaxKind.Block]: L,
370
+ [s__namespace.SyntaxKind.VariableStatement]: k,
371
+ [s__namespace.SyntaxKind.ExpressionStatement]: G,
372
+ [s__namespace.SyntaxKind.ReturnStatement]: D,
373
+ [s__namespace.SyntaxKind.BreakStatement]: F$1,
374
+ [s__namespace.SyntaxKind.ContinueStatement]: b$1
375
+ }, H = (e2, t2, n) => {
376
+ t2.emit(i$2.PUSH, e2.text);
377
+ }, J = (e2, t2, n) => {
378
+ t2.emit(i$2.PUSH, Number(e2.text));
379
+ }, M$2 = (e2, t2, n) => {
380
+ t2.emit(i$2.PUSH, true);
381
+ }, Y = (e2, t2, n) => {
382
+ t2.emit(i$2.PUSH, false);
383
+ }, C$2 = (e2, t2, n) => {
384
+ t2.emit(i$2.PUSH, null);
385
+ }, B$1 = (e2, t2, n) => {
386
+ const r2 = e2.text, a2 = r2.lastIndexOf("/"), m2 = r2.substring(1, a2), T = r2.substring(a2 + 1);
387
+ t2.emit(i$2.LOAD_REGEX, { pattern: m2, flags: T });
388
+ }, w$1 = (e2, t2, n) => {
389
+ e2.text === "undefined" ? t2.emit(i$2.PUSH_UNDEFINED) : t2.emit(i$2.LOAD, e2.text);
390
+ }, q = (e2, t2, { compileExpression: n }) => {
391
+ t2.emit(i$2.ARRAY_NEW), e2.elements.forEach((r2) => {
392
+ n(r2), t2.emit(i$2.ARRAY_PUSH);
290
393
  });
291
- }, M$2 = (e2, t2, { compileExpression: i2 }) => {
292
- i2(e2.expression);
293
- }, Y = (e2, t2, { compileExpression: i2 }) => {
294
- e2.name.text === "length" ? (i2(e2.expression), t2.emit(n.LENGTH)) : (i2(e2.expression), t2.emit(n.PUSH, e2.name.text), t2.emit(n.PROPERTY_GET));
295
- }, J = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
296
- i2(e2.expression), e2.argumentExpression ? i2(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(n.ARRAY_GET);
297
- }, w$1 = (e2, t2, { compileExpression: i2 }) => {
394
+ }, O = (e2, t2, { compileExpression: n }) => {
395
+ n(e2.expression);
396
+ }, X = (e2, t2, { compileExpression: n }) => {
397
+ e2.name.text === "length" ? (n(e2.expression), t2.emit(i$2.LENGTH)) : (n(e2.expression), t2.emit(i$2.PUSH, e2.name.text), t2.emit(i$2.PROPERTY_GET));
398
+ }, V$1 = (e2, t2, { compileExpression: n, reportError: r2 }) => {
399
+ n(e2.expression), e2.argumentExpression ? n(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(i$2.ARRAY_GET);
400
+ }, W$1 = (e2, t2, { compileExpression: n }) => {
298
401
  switch (e2.operator) {
299
402
  case s__namespace.SyntaxKind.ExclamationToken:
300
- i2(e2.operand), t2.emit(n.NOT);
403
+ n(e2.operand), t2.emit(i$2.NOT);
301
404
  break;
302
405
  case s__namespace.SyntaxKind.MinusToken:
303
- i2(e2.operand), t2.emit(n.UNARY_MINUS);
406
+ n(e2.operand), t2.emit(i$2.UNARY_MINUS);
304
407
  break;
305
408
  case s__namespace.SyntaxKind.PlusToken:
306
- i2(e2.operand), t2.emit(n.UNARY_PLUS);
409
+ n(e2.operand), t2.emit(i$2.UNARY_PLUS);
307
410
  break;
308
411
  case s__namespace.SyntaxKind.PlusPlusToken:
309
- s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.INC, false));
412
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.INC, false));
310
413
  break;
311
414
  case s__namespace.SyntaxKind.MinusMinusToken:
312
- s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, false));
415
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, false));
313
416
  break;
314
417
  }
315
- }, B$1 = (e2, t2, { compileExpression: i2 }) => {
418
+ }, d$3 = (e2, t2, { compileExpression: n }) => {
316
419
  switch (e2.operator) {
317
420
  case s__namespace.SyntaxKind.PlusPlusToken:
318
- s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.INC, true));
421
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.INC, true));
319
422
  break;
320
423
  case s__namespace.SyntaxKind.MinusMinusToken:
321
- s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, true));
424
+ s__namespace.isIdentifier(e2.operand) && (t2.emit(i$2.PUSH, e2.operand.text), t2.emit(i$2.DEC, true));
322
425
  break;
323
426
  }
324
- }, q = (e2, t2, { compileExpression: i2 }) => {
427
+ }, j$1 = (e2, t2, { compileExpression: n }) => {
325
428
  const r2 = e2.operatorToken.kind;
326
- switch (i2(e2.left), i2(e2.right), r2) {
429
+ switch (n(e2.left), n(e2.right), r2) {
327
430
  case s__namespace.SyntaxKind.PlusToken:
328
- t2.emit(n.ADD);
431
+ t2.emit(i$2.ADD);
329
432
  break;
330
433
  case s__namespace.SyntaxKind.MinusToken:
331
- t2.emit(n.SUB);
434
+ t2.emit(i$2.SUB);
332
435
  break;
333
436
  case s__namespace.SyntaxKind.AsteriskToken:
334
- t2.emit(n.MUL);
437
+ t2.emit(i$2.MUL);
335
438
  break;
336
439
  case s__namespace.SyntaxKind.SlashToken:
337
- t2.emit(n.DIV);
440
+ t2.emit(i$2.DIV);
338
441
  break;
339
442
  case s__namespace.SyntaxKind.PercentToken:
340
- t2.emit(n.MOD);
443
+ t2.emit(i$2.MOD);
341
444
  break;
342
445
  case s__namespace.SyntaxKind.EqualsEqualsToken:
343
- t2.emit(n.EQ);
446
+ t2.emit(i$2.EQ);
344
447
  break;
345
448
  case s__namespace.SyntaxKind.ExclamationEqualsToken:
346
- t2.emit(n.NEQ);
449
+ t2.emit(i$2.NEQ);
347
450
  break;
348
451
  case s__namespace.SyntaxKind.LessThanToken:
349
- t2.emit(n.LT);
452
+ t2.emit(i$2.LT);
350
453
  break;
351
454
  case s__namespace.SyntaxKind.GreaterThanToken:
352
- t2.emit(n.GT);
455
+ t2.emit(i$2.GT);
353
456
  break;
354
457
  case s__namespace.SyntaxKind.LessThanEqualsToken:
355
- t2.emit(n.LTE);
458
+ t2.emit(i$2.LTE);
356
459
  break;
357
460
  case s__namespace.SyntaxKind.GreaterThanEqualsToken:
358
- t2.emit(n.GTE);
461
+ t2.emit(i$2.GTE);
359
462
  break;
360
463
  case s__namespace.SyntaxKind.EqualsEqualsEqualsToken:
361
- t2.emit(n.EQ_STRICT);
464
+ t2.emit(i$2.EQ_STRICT);
362
465
  break;
363
466
  case s__namespace.SyntaxKind.ExclamationEqualsEqualsToken:
364
- t2.emit(n.NEQ_STRICT);
467
+ t2.emit(i$2.NEQ_STRICT);
365
468
  break;
366
469
  case s__namespace.SyntaxKind.AmpersandAmpersandToken:
367
- t2.emit(n.AND);
470
+ t2.emit(i$2.AND);
368
471
  break;
369
472
  case s__namespace.SyntaxKind.BarBarToken:
370
- t2.emit(n.OR);
473
+ t2.emit(i$2.OR);
371
474
  break;
372
475
  }
373
- }, W$1 = (e2, t2, { compileExpression: i2 }) => {
374
- i2(e2.condition);
375
- const r2 = t2.emit(n.JUMP_IF_FALSE, -1);
376
- i2(e2.whenTrue);
377
- const a2 = t2.emit(n.JUMP, -1), m2 = t2.currentAddress();
378
- t2.patchJump(r2, m2), i2(e2.whenFalse);
379
- const T2 = t2.currentAddress();
380
- t2.patchJump(a2, T2);
381
- }, C$1 = (e2, t2, { compileExpression: i2 }) => {
382
- i2(e2.expression), t2.emit(n.TYPEOF);
383
- }, V = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
476
+ }, v$1 = (e2, t2, { compileExpression: n }) => {
477
+ n(e2.condition);
478
+ const r2 = t2.emit(i$2.JUMP_IF_FALSE, -1);
479
+ n(e2.whenTrue);
480
+ const a2 = t2.emit(i$2.JUMP, -1), m2 = t2.currentAddress();
481
+ t2.patchJump(r2, m2), n(e2.whenFalse);
482
+ const T = t2.currentAddress();
483
+ t2.patchJump(a2, T);
484
+ }, z = (e2, t2, { compileExpression: n }) => {
485
+ n(e2.expression), t2.emit(i$2.TYPEOF);
486
+ }, Q$1 = (e2, t2, { compileExpression: n, reportError: r2 }) => {
384
487
  if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "fs") {
385
488
  const a2 = e2.expression.name.text;
386
489
  if (a2 === "listFiles")
387
- e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, "."), e2.arguments.length > 1 && i2(e2.arguments[1]), t2.emit(n.FS_LIST_FILES);
490
+ e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, "."), e2.arguments.length > 1 && n(e2.arguments[1]), t2.emit(i$2.FS_LIST_FILES);
388
491
  else if (a2 === "readFile")
389
- e2.arguments.length > 0 ? (i2(e2.arguments[0]), t2.emit(n.FS_READ_FILE)) : r2(e2, "fs.readFile() requires a path argument");
492
+ e2.arguments.length > 0 ? (n(e2.arguments[0]), t2.emit(i$2.FS_READ_FILE)) : r2(e2, "fs.readFile() requires a path argument");
390
493
  else if (a2 === "writeFile") {
391
494
  if (e2.arguments.length < 2) {
392
495
  r2(e2, "fs.writeFile() requires path and content arguments");
393
496
  return;
394
497
  }
395
- i2(e2.arguments[0]), i2(e2.arguments[1]), t2.emit(n.FS_WRITE_FILE);
498
+ n(e2.arguments[0]), n(e2.arguments[1]), t2.emit(i$2.FS_WRITE_FILE);
396
499
  } else
397
500
  r2(e2, `Unsupported fs method: ${a2}`);
398
501
  } else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "JSON" && e2.expression.name.text === "parse")
399
- e2.arguments.length > 0 && i2(e2.arguments[0]), t2.emit(n.JSON_PARSE);
502
+ e2.arguments.length > 0 && n(e2.arguments[0]), t2.emit(i$2.JSON_PARSE);
400
503
  else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "JSON" && e2.expression.name.text === "stringify")
401
- e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.JSON_STRINGIFY);
402
- else if (s__namespace.isIdentifier(e2.expression) && e2.expression.text === "CC")
403
- e2.arguments.length > 0 && i2(e2.arguments[0]), t2.emit(n.CC);
504
+ e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.JSON_STRINGIFY);
505
+ else if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "Object" && e2.expression.name.text === "keys") {
506
+ if (e2.arguments.length !== 1) {
507
+ r2(e2, "Object.keys() requires exactly one argument");
508
+ return;
509
+ }
510
+ n(e2.arguments[0]), t2.emit(i$2.OBJECT_KEYS);
511
+ } else if (s__namespace.isIdentifier(e2.expression) && e2.expression.text === "CC")
512
+ e2.arguments.length > 0 && n(e2.arguments[0]), t2.emit(i$2.CC);
404
513
  else if (s__namespace.isPropertyAccessExpression(e2.expression)) {
405
514
  const a2 = e2.expression.name.text;
406
515
  if (a2 === "substring")
407
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 && i2(e2.arguments[1]), t2.emit(n.STRING_SUBSTRING);
516
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 && n(e2.arguments[1]), t2.emit(i$2.STRING_SUBSTRING);
408
517
  else if (a2 === "indexOf")
409
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_INDEXOF);
518
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_INDEXOF);
410
519
  else if (a2 === "split")
411
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_SPLIT);
520
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_SPLIT);
412
521
  else if (a2 === "slice")
413
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.STRING_SLICE);
522
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.STRING_SLICE);
414
523
  else if (a2 === "join")
415
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ","), t2.emit(n.ARRAY_JOIN);
524
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ","), t2.emit(i$2.ARRAY_JOIN);
416
525
  else if (a2 === "charAt")
417
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_CHARAT);
526
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), t2.emit(i$2.STRING_CHARAT);
418
527
  else if (a2 === "toUpperCase")
419
- i2(e2.expression.expression), t2.emit(n.STRING_TOUPPERCASE);
528
+ n(e2.expression.expression), t2.emit(i$2.STRING_TOUPPERCASE);
420
529
  else if (a2 === "toLowerCase")
421
- i2(e2.expression.expression), t2.emit(n.STRING_TOLOWERCASE);
530
+ n(e2.expression.expression), t2.emit(i$2.STRING_TOLOWERCASE);
422
531
  else if (a2 === "toString")
423
- i2(e2.expression.expression), t2.emit(n.TO_STRING);
532
+ n(e2.expression.expression), t2.emit(i$2.TO_STRING);
424
533
  else if (a2 === "includes")
425
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_INCLUDES);
534
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_INCLUDES);
426
535
  else if (a2 === "endsWith")
427
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_ENDS_WITH);
536
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_ENDS_WITH);
428
537
  else if (a2 === "startsWith")
429
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_STARTS_WITH);
538
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_STARTS_WITH);
430
539
  else if (a2 === "trim")
431
- i2(e2.expression.expression), t2.emit(n.STRING_TRIM);
540
+ n(e2.expression.expression), t2.emit(i$2.STRING_TRIM);
432
541
  else if (a2 === "trimStart")
433
- i2(e2.expression.expression), t2.emit(n.STRING_TRIM_START);
542
+ n(e2.expression.expression), t2.emit(i$2.STRING_TRIM_START);
434
543
  else if (a2 === "trimEnd")
435
- i2(e2.expression.expression), t2.emit(n.STRING_TRIM_END);
436
- else if (a2 === "replace")
437
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE);
544
+ n(e2.expression.expression), t2.emit(i$2.STRING_TRIM_END);
545
+ else if (a2 === "test")
546
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.REGEX_TEST);
547
+ else if (a2 === "match") {
548
+ if (n(e2.expression.expression), e2.arguments.length > 0)
549
+ n(e2.arguments[0]);
550
+ else {
551
+ r2(e2, "match() requires a regex argument");
552
+ return;
553
+ }
554
+ t2.emit(i$2.STRING_MATCH);
555
+ } else if (a2 === "replace")
556
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, ""), e2.arguments.length > 0 && s__namespace.isRegularExpressionLiteral(e2.arguments[0]), t2.emit(i$2.STRING_REPLACE_REGEX);
438
557
  else if (a2 === "replaceAll")
439
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE_ALL);
558
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_REPLACE_ALL);
440
559
  else if (a2 === "lastIndexOf")
441
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_LAST_INDEX_OF);
560
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, ""), t2.emit(i$2.STRING_LAST_INDEX_OF);
442
561
  else if (a2 === "repeat")
443
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_REPEAT);
562
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), t2.emit(i$2.STRING_REPEAT);
444
563
  else if (a2 === "padStart")
445
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_START);
564
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, " "), t2.emit(i$2.STRING_PAD_START);
446
565
  else if (a2 === "padEnd")
447
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_END);
566
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH, 0), e2.arguments.length > 1 ? n(e2.arguments[1]) : t2.emit(i$2.PUSH, " "), t2.emit(i$2.STRING_PAD_END);
448
567
  else if (a2 === "push")
449
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.ARRAY_PUSH);
568
+ n(e2.expression.expression), e2.arguments.length > 0 ? n(e2.arguments[0]) : t2.emit(i$2.PUSH_UNDEFINED), t2.emit(i$2.ARRAY_PUSH);
450
569
  else
451
570
  throw new Error(`Method call '${a2}' is not supported`);
452
571
  } else
453
572
  throw new Error("Unsupported call expression");
454
- }, O = (e2, t2, { compileExpression: i2 }) => {
455
- t2.emit(n.OBJECT_CREATE);
573
+ }, $$1 = (e2, t2, { compileExpression: n }) => {
574
+ t2.emit(i$2.OBJECT_CREATE);
456
575
  for (const r2 of e2.properties)
457
576
  if (s__namespace.isPropertyAssignment(r2)) {
458
577
  let a2;
@@ -462,92 +581,93 @@ const A = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
462
581
  a2 = r2.name.text;
463
582
  else
464
583
  throw new Error("Computed property names are not supported");
465
- t2.emit(n.PUSH, a2), i2(r2.initializer), t2.emit(n.PROPERTY_SET);
584
+ t2.emit(i$2.PUSH, a2), n(r2.initializer), t2.emit(i$2.PROPERTY_SET);
466
585
  } else if (s__namespace.isShorthandPropertyAssignment(r2)) {
467
586
  const a2 = r2.name.text;
468
- t2.emit(n.PUSH, a2), t2.emit(n.LOAD, a2), t2.emit(n.PROPERTY_SET);
587
+ t2.emit(i$2.PUSH, a2), t2.emit(i$2.LOAD, a2), t2.emit(i$2.PROPERTY_SET);
469
588
  } else
470
589
  throw new Error("Unsupported property type in object literal");
471
- }, Q$1 = {
472
- [s__namespace.SyntaxKind.StringLiteral]: k,
473
- [s__namespace.SyntaxKind.NumericLiteral]: G,
474
- [s__namespace.SyntaxKind.TrueKeyword]: D$1,
475
- [s__namespace.SyntaxKind.FalseKeyword]: F$1,
476
- [s__namespace.SyntaxKind.NullKeyword]: K,
477
- [s__namespace.SyntaxKind.Identifier]: H,
478
- [s__namespace.SyntaxKind.ArrayLiteralExpression]: b$2,
479
- [s__namespace.SyntaxKind.BinaryExpression]: q,
480
- [s__namespace.SyntaxKind.PrefixUnaryExpression]: w$1,
481
- [s__namespace.SyntaxKind.PostfixUnaryExpression]: B$1,
482
- [s__namespace.SyntaxKind.CallExpression]: V,
483
- [s__namespace.SyntaxKind.PropertyAccessExpression]: Y,
484
- [s__namespace.SyntaxKind.ElementAccessExpression]: J,
485
- [s__namespace.SyntaxKind.ConditionalExpression]: W$1,
486
- [s__namespace.SyntaxKind.TypeOfExpression]: C$1,
487
- [s__namespace.SyntaxKind.ParenthesizedExpression]: M$2,
488
- [s__namespace.SyntaxKind.ObjectLiteralExpression]: O
590
+ }, Z$1 = {
591
+ [s__namespace.SyntaxKind.StringLiteral]: H,
592
+ [s__namespace.SyntaxKind.NumericLiteral]: J,
593
+ [s__namespace.SyntaxKind.TrueKeyword]: M$2,
594
+ [s__namespace.SyntaxKind.FalseKeyword]: Y,
595
+ [s__namespace.SyntaxKind.NullKeyword]: C$2,
596
+ [s__namespace.SyntaxKind.RegularExpressionLiteral]: B$1,
597
+ [s__namespace.SyntaxKind.Identifier]: w$1,
598
+ [s__namespace.SyntaxKind.ArrayLiteralExpression]: q,
599
+ [s__namespace.SyntaxKind.BinaryExpression]: j$1,
600
+ [s__namespace.SyntaxKind.PrefixUnaryExpression]: W$1,
601
+ [s__namespace.SyntaxKind.PostfixUnaryExpression]: d$3,
602
+ [s__namespace.SyntaxKind.CallExpression]: Q$1,
603
+ [s__namespace.SyntaxKind.PropertyAccessExpression]: X,
604
+ [s__namespace.SyntaxKind.ElementAccessExpression]: V$1,
605
+ [s__namespace.SyntaxKind.ConditionalExpression]: v$1,
606
+ [s__namespace.SyntaxKind.TypeOfExpression]: z,
607
+ [s__namespace.SyntaxKind.ParenthesizedExpression]: O,
608
+ [s__namespace.SyntaxKind.ObjectLiteralExpression]: $$1
489
609
  };
490
- function X(e2) {
491
- const t2 = [], i2 = f$3(e2);
492
- if (i2.errors.length > 0)
610
+ function te$1(e2) {
611
+ const t2 = [], n = A$1(e2);
612
+ if (n.errors.length > 0)
493
613
  return {
494
614
  success: false,
495
615
  bytecode: [],
496
- errors: i2.errors.map((S) => ({
616
+ errors: n.errors.map((S) => ({
497
617
  message: S,
498
618
  line: 0,
499
619
  character: 0
500
620
  }))
501
621
  };
502
- const r2 = new I(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
503
- compileStatement: T2,
504
- compileExpression: l2,
505
- reportError: (S, c2) => {
506
- const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
622
+ const r2 = new g(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
623
+ compileStatement: T,
624
+ compileExpression: l,
625
+ reportError: (S, u2) => {
626
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
507
627
  throw t2.push({
508
- message: c2,
509
- line: R + 1,
628
+ message: u2,
629
+ line: c2 + 1,
510
630
  // TypeScript uses 0-based lines
511
- character: u2 + 1
631
+ character: R + 1
512
632
  // TypeScript uses 0-based columns
513
- }), new Error(c2);
633
+ }), new Error(u2);
514
634
  }
515
635
  };
516
- function T2(S) {
517
- const c2 = L[S.kind];
518
- if (c2)
519
- c2(S, r2, m2);
636
+ function T(S) {
637
+ const u2 = K[S.kind];
638
+ if (u2)
639
+ u2(S, r2, m2);
520
640
  else {
521
- const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
641
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
522
642
  t2.push({
523
643
  message: `Unsupported statement: ${s__namespace.SyntaxKind[S.kind]}`,
524
- line: R + 1,
525
- character: u2 + 1
644
+ line: c2 + 1,
645
+ character: R + 1
526
646
  });
527
647
  }
528
648
  }
529
- function l2(S) {
530
- const c2 = Q$1[S.kind];
531
- if (c2)
532
- c2(S, r2, m2);
649
+ function l(S) {
650
+ const u2 = Z$1[S.kind];
651
+ if (u2)
652
+ u2(S, r2, m2);
533
653
  else {
534
- const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
654
+ const { line: c2, character: R } = a2.getLineAndCharacterOfPosition(S.getStart());
535
655
  t2.push({
536
656
  message: `Unsupported expression: ${s__namespace.SyntaxKind[S.kind]}`,
537
- line: R + 1,
538
- character: u2 + 1
657
+ line: c2 + 1,
658
+ character: R + 1
539
659
  });
540
660
  }
541
661
  }
542
662
  return a2.forEachChild((S) => {
543
- var c2;
544
- s__namespace.isFunctionDeclaration(S) && ((c2 = S.name) == null ? void 0 : c2.text) === "main" && S.body && S.body.statements.forEach((R) => {
663
+ var u2;
664
+ s__namespace.isFunctionDeclaration(S) && ((u2 = S.name) == null ? void 0 : u2.text) === "main" && S.body && S.body.statements.forEach((c2) => {
545
665
  try {
546
- T2(R);
666
+ T(c2);
547
667
  } catch {
548
668
  }
549
669
  });
550
- }), r2.emit(n.HALT), {
670
+ }), r2.emit(i$2.HALT), {
551
671
  success: t2.length === 0,
552
672
  bytecode: r2.getBytecode(),
553
673
  errors: t2
@@ -577,17 +697,17 @@ function y(r2) {
577
697
  function u$1(r2) {
578
698
  return r2 !== null && typeof r2 == "object" && "type" in r2 && r2.type === "array-ref";
579
699
  }
580
- function b$1(r2) {
700
+ function b(r2) {
581
701
  return r2 !== null && typeof r2 == "object" && "type" in r2 && r2.type === "object-ref";
582
702
  }
583
703
  function p$1(r2) {
584
704
  return t(r2) ? r2 : i$1(r2) || e(r2) ? r2.toString() : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) ? `[array:${r2.elements.length}]` : y(r2) ? "[object Object]" : String(r2);
585
705
  }
586
- function j$1(r2) {
706
+ function j(r2) {
587
707
  return e(r2) ? r2 : f$2(r2) || c(r2) ? false : i$1(r2) ? r2 !== 0 : t(r2) ? r2 !== "" : o(r2) || y(r2) ? true : !!r2;
588
708
  }
589
- function d$1(r2) {
590
- return t(r2) ? "string" : i$1(r2) ? "number" : e(r2) ? "boolean" : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) || u$1(r2) ? "array" : y(r2) || b$1(r2) ? "object" : "unknown";
709
+ function d$2(r2) {
710
+ return t(r2) ? "string" : i$1(r2) ? "number" : e(r2) ? "boolean" : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) || u$1(r2) ? "array" : y(r2) || b(r2) ? "object" : "unknown";
591
711
  }
592
712
  function m(r2) {
593
713
  if (i$1(r2)) return r2;
@@ -595,23 +715,23 @@ function m(r2) {
595
715
  if (f$2(r2)) return 0;
596
716
  if (c(r2)) return NaN;
597
717
  if (t(r2)) {
598
- const n2 = r2.trim();
599
- return n2 === "" ? 0 : Number(n2);
718
+ const n = r2.trim();
719
+ return n === "" ? 0 : Number(n);
600
720
  }
601
721
  return o(r2) ? NaN : Number(r2);
602
722
  }
603
- function s(r2 = [], n2) {
604
- return n2 ? { type: "array", elements: r2, properties: n2 } : { type: "array", elements: r2 };
723
+ function s(r2 = [], n) {
724
+ return n ? { type: "array", elements: r2, properties: n } : { type: "array", elements: r2 };
605
725
  }
606
- function C() {
726
+ function C$1() {
607
727
  return { type: "undefined" };
608
728
  }
609
729
  function M$1(r2 = {}) {
610
730
  return { type: "object", properties: r2 };
611
731
  }
612
- var d = Object.defineProperty;
613
- var h = (s2, t2, n2) => t2 in s2 ? d(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
614
- var a = (s2, t2, n2) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n2);
732
+ var d$1 = Object.defineProperty;
733
+ var h = (s2, t2, n) => t2 in s2 ? d$1(s2, t2, { enumerable: true, configurable: true, writable: true, value: n }) : s2[t2] = n;
734
+ var a = (s2, t2, n) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n);
615
735
  class p {
616
736
  constructor(t2) {
617
737
  a(this, "connected", false);
@@ -624,7 +744,7 @@ class p {
624
744
  return r__namespace.join(this.dataDir, "metadata.json");
625
745
  }
626
746
  async connect() {
627
- await x$2.promises.mkdir(this.dataDir, { recursive: true }), await x$2.promises.mkdir(this.programsDir, { recursive: true }), await x$2.promises.mkdir(this.executionsDir, { recursive: true }), await x$2.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
747
+ await b$2.promises.mkdir(this.dataDir, { recursive: true }), await b$2.promises.mkdir(this.programsDir, { recursive: true }), await b$2.promises.mkdir(this.executionsDir, { recursive: true }), await b$2.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
628
748
  }
629
749
  async disconnect() {
630
750
  this.connected = false;
@@ -634,14 +754,14 @@ class p {
634
754
  }
635
755
  async saveProgram(t2) {
636
756
  if (!this.connected) throw new Error("Not connected");
637
- const n2 = r__namespace.join(this.programsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
638
- await x$2.promises.writeFile(n2, e2, "utf-8");
757
+ const n = r__namespace.join(this.programsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
758
+ await b$2.promises.writeFile(n, e2, "utf-8");
639
759
  }
640
760
  async getProgram(t2) {
641
761
  if (!this.connected) throw new Error("Not connected");
642
- const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
762
+ const n = r__namespace.join(this.programsDir, `${t2}.json`);
643
763
  try {
644
- const e2 = await x$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
764
+ const e2 = await b$2.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
645
765
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
646
766
  } catch (e2) {
647
767
  if (e2.code === "ENOENT")
@@ -651,14 +771,14 @@ class p {
651
771
  }
652
772
  async saveExecution(t2) {
653
773
  if (!this.connected) throw new Error("Not connected");
654
- const n2 = r__namespace.join(this.executionsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
655
- await x$2.promises.writeFile(n2, e2, "utf-8");
774
+ const n = r__namespace.join(this.executionsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
775
+ await b$2.promises.writeFile(n, e2, "utf-8");
656
776
  }
657
777
  async getExecution(t2) {
658
778
  if (!this.connected) throw new Error("Not connected");
659
- const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
779
+ const n = r__namespace.join(this.executionsDir, `${t2}.json`);
660
780
  try {
661
- const e2 = await x$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
781
+ const e2 = await b$2.promises.readFile(n, "utf-8"), o2 = JSON.parse(e2);
662
782
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
663
783
  } catch (e2) {
664
784
  if (e2.code === "ENOENT")
@@ -666,18 +786,18 @@ class p {
666
786
  throw e2;
667
787
  }
668
788
  }
669
- async appendOutput(t2, n2) {
789
+ async appendOutput(t2, n) {
670
790
  if (!this.connected) throw new Error("Not connected");
671
- const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n2.join(`
791
+ const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n.join(`
672
792
  `) + `
673
793
  `;
674
- await x$2.promises.appendFile(e2, o2, "utf-8");
794
+ await b$2.promises.appendFile(e2, o2, "utf-8");
675
795
  }
676
796
  async getOutput(t2) {
677
797
  if (!this.connected) throw new Error("Not connected");
678
- const n2 = r__namespace.join(this.outputsDir, `${t2}.output`);
798
+ const n = r__namespace.join(this.outputsDir, `${t2}.output`);
679
799
  try {
680
- return (await x$2.promises.readFile(n2, "utf-8")).split(`
800
+ return (await b$2.promises.readFile(n, "utf-8")).split(`
681
801
  `).filter((o2) => o2.length > 0);
682
802
  } catch (e2) {
683
803
  if (e2.code === "ENOENT")
@@ -687,18 +807,18 @@ class p {
687
807
  }
688
808
  async listExecutions() {
689
809
  if (!this.connected) throw new Error("Not connected");
690
- const t2 = await x$2.promises.readdir(this.executionsDir), n2 = [];
810
+ const t2 = await b$2.promises.readdir(this.executionsDir), n = [];
691
811
  for (const e2 of t2)
692
812
  if (e2.endsWith(".json")) {
693
813
  const o2 = e2.slice(0, -5), i2 = await this.getExecution(o2);
694
- i2 && n2.push(i2);
814
+ i2 && n.push(i2);
695
815
  }
696
- return n2;
816
+ return n;
697
817
  }
698
818
  async getCurrentExecutionId() {
699
819
  if (!this.connected) throw new Error("Not connected");
700
820
  try {
701
- const t2 = await x$2.promises.readFile(this.metadataFile, "utf-8");
821
+ const t2 = await b$2.promises.readFile(this.metadataFile, "utf-8");
702
822
  return JSON.parse(t2).currentExecutionId || null;
703
823
  } catch (t2) {
704
824
  if (t2.code === "ENOENT")
@@ -708,20 +828,20 @@ class p {
708
828
  }
709
829
  async setCurrentExecutionId(t2) {
710
830
  if (!this.connected) throw new Error("Not connected");
711
- const n2 = { currentExecutionId: t2 };
712
- await x$2.promises.writeFile(this.metadataFile, JSON.stringify(n2, null, 2), "utf-8");
831
+ const n = { currentExecutionId: t2 };
832
+ await b$2.promises.writeFile(this.metadataFile, JSON.stringify(n, null, 2), "utf-8");
713
833
  }
714
834
  async deleteExecution(t2) {
715
835
  if (!this.connected) throw new Error("Not connected");
716
- const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
836
+ const n = r__namespace.join(this.executionsDir, `${t2}.json`);
717
837
  try {
718
- await x$2.promises.unlink(n2);
838
+ await b$2.promises.unlink(n);
719
839
  } catch (i2) {
720
840
  if (i2.code !== "ENOENT") throw i2;
721
841
  }
722
842
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`);
723
843
  try {
724
- await x$2.promises.unlink(e2);
844
+ await b$2.promises.unlink(e2);
725
845
  } catch (i2) {
726
846
  if (i2.code !== "ENOENT") throw i2;
727
847
  }
@@ -729,19 +849,19 @@ class p {
729
849
  }
730
850
  async listPrograms() {
731
851
  if (!this.connected) throw new Error("Not connected");
732
- const t2 = await x$2.promises.readdir(this.programsDir), n2 = [];
852
+ const t2 = await b$2.promises.readdir(this.programsDir), n = [];
733
853
  for (const e2 of t2)
734
854
  if (e2.endsWith(".json")) {
735
855
  const o2 = e2.slice(0, -5), i2 = await this.getProgram(o2);
736
- i2 && n2.push(i2);
856
+ i2 && n.push(i2);
737
857
  }
738
- return n2;
858
+ return n;
739
859
  }
740
860
  async deleteProgram(t2) {
741
861
  if (!this.connected) throw new Error("Not connected");
742
- const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
862
+ const n = r__namespace.join(this.programsDir, `${t2}.json`);
743
863
  try {
744
- await x$2.promises.unlink(n2);
864
+ await b$2.promises.unlink(n);
745
865
  } catch (e2) {
746
866
  if (e2.code !== "ENOENT") throw e2;
747
867
  }
@@ -770,7 +890,7 @@ let f$1 = class f {
770
890
  }
771
891
  async getCollections() {
772
892
  if (!this.db) throw new Error("Not connected to database");
773
- return (await this.db.listCollections().toArray()).map((n2) => n2.name);
893
+ return (await this.db.listCollections().toArray()).map((n) => n.name);
774
894
  }
775
895
  getCollection(t2) {
776
896
  if (!this.db) throw new Error("Not connected to database");
@@ -796,12 +916,12 @@ let f$1 = class f {
796
916
  async getExecution(t2) {
797
917
  return await this.getCollection("executions").findOne({ id: t2 });
798
918
  }
799
- async appendOutput(t2, n2) {
919
+ async appendOutput(t2, n) {
800
920
  const e2 = this.getCollection("outputs");
801
921
  await e2.findOne({ executionId: t2 }) ? await e2.updateOne(
802
922
  { executionId: t2 },
803
- { $push: { lines: { $each: n2 } } }
804
- ) : await e2.insertOne({ executionId: t2, lines: n2 });
923
+ { $push: { lines: { $each: n } } }
924
+ ) : await e2.insertOne({ executionId: t2, lines: n });
805
925
  }
806
926
  async getOutput(t2) {
807
927
  const e2 = await this.getCollection("outputs").findOne({ executionId: t2 });
@@ -811,8 +931,8 @@ let f$1 = class f {
811
931
  return await this.getCollection("executions").find({}).toArray();
812
932
  }
813
933
  async getCurrentExecutionId() {
814
- const n2 = await this.getCollection("metadata").findOne({ _id: "current" });
815
- return (n2 == null ? void 0 : n2.currentExecutionId) || null;
934
+ const n = await this.getCollection("metadata").findOne({ _id: "current" });
935
+ return (n == null ? void 0 : n.currentExecutionId) || null;
816
936
  }
817
937
  async setCurrentExecutionId(t2) {
818
938
  await this.getCollection("metadata").replaceOne(
@@ -823,7 +943,7 @@ let f$1 = class f {
823
943
  }
824
944
  async deleteExecution(t2) {
825
945
  var o2;
826
- let n2 = true;
946
+ let n = true;
827
947
  const e2 = this.client.startSession();
828
948
  try {
829
949
  await e2.withTransaction(async () => {
@@ -835,13 +955,13 @@ let f$1 = class f {
835
955
  });
836
956
  } catch (i2) {
837
957
  if ((o2 = i2 == null ? void 0 : i2.message) != null && o2.includes("Transaction numbers are only allowed"))
838
- n2 = false;
958
+ n = false;
839
959
  else
840
960
  throw i2;
841
961
  } finally {
842
962
  await e2.endSession();
843
963
  }
844
- n2 || (await this.getCollection("executions").deleteOne({ id: t2 }), await this.getCollection("outputs").deleteMany({ executionId: t2 }), await this.getCurrentExecutionId() === t2 && await this.setCurrentExecutionId(null));
964
+ n || (await this.getCollection("executions").deleteOne({ id: t2 }), await this.getCollection("outputs").deleteMany({ executionId: t2 }), await this.getCurrentExecutionId() === t2 && await this.setCurrentExecutionId(null));
845
965
  }
846
966
  async listPrograms() {
847
967
  return await this.getCollection("programs").find({}).toArray();
@@ -852,8 +972,8 @@ let f$1 = class f {
852
972
  };
853
973
  class E {
854
974
  static create(t2) {
855
- const n2 = (t2 == null ? void 0 : t2.type) || process.env.CVM_STORAGE_TYPE || "file";
856
- switch (n2) {
975
+ const n = (t2 == null ? void 0 : t2.type) || process.env.CVM_STORAGE_TYPE || "file";
976
+ switch (n) {
857
977
  case "file": {
858
978
  const e2 = (t2 == null ? void 0 : t2.dataDir) || process.env.CVM_DATA_DIR || ".cvm";
859
979
  return new p(e2);
@@ -863,32 +983,32 @@ class E {
863
983
  return new f$1(e2);
864
984
  }
865
985
  default:
866
- throw new Error(`Unsupported storage type: ${n2}`);
986
+ throw new Error(`Unsupported storage type: ${n}`);
867
987
  }
868
988
  }
869
989
  }
870
- var W = Object.defineProperty;
871
- var B = (e2, t2, r2) => t2 in e2 ? W(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2;
872
- var b = (e2, t2, r2) => B(e2, typeof t2 != "symbol" ? t2 + "" : t2, r2);
990
+ var B = Object.defineProperty;
991
+ var W = (e2, t2, r2) => t2 in e2 ? B(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2;
992
+ var _ = (e2, t2, r2) => W(e2, typeof t2 != "symbol" ? t2 + "" : t2, r2);
873
993
  function Q(e2) {
874
994
  return !!(e2 && typeof e2 == "object" && "type" in e2 && "message" in e2);
875
995
  }
876
- function l(e2, t2) {
996
+ function d(e2, t2) {
877
997
  return e2.stack.length < 1 ? {
878
998
  type: "RuntimeError",
879
999
  message: "Stack underflow",
880
1000
  pc: e2.pc,
881
- opcode: t2 || n.POP
1001
+ opcode: t2 || i$2.POP
882
1002
  } : e2.stack.pop();
883
1003
  }
884
1004
  const f2 = Q, Z = {
885
- [n.ADD]: {
1005
+ [i$2.ADD]: {
886
1006
  stackIn: 2,
887
1007
  stackOut: 1,
888
1008
  execute: (e2, t$1) => {
889
- const r2 = l(e2, t$1.op);
1009
+ const r2 = d(e2, t$1.op);
890
1010
  if (f2(r2)) return r2;
891
- const o2 = l(e2, t$1.op);
1011
+ const o2 = d(e2, t$1.op);
892
1012
  if (f2(o2)) return o2;
893
1013
  if (t(o2) || t(r2))
894
1014
  e2.stack.push(p$1(o2) + p$1(r2));
@@ -898,37 +1018,37 @@ const f2 = Q, Z = {
898
1018
  }
899
1019
  }
900
1020
  },
901
- [n.SUB]: {
1021
+ [i$2.SUB]: {
902
1022
  stackIn: 2,
903
1023
  stackOut: 1,
904
1024
  execute: (e2, t2) => {
905
- const r2 = l(e2, t2.op);
1025
+ const r2 = d(e2, t2.op);
906
1026
  if (f2(r2)) return r2;
907
- const o2 = l(e2, t2.op);
1027
+ const o2 = d(e2, t2.op);
908
1028
  if (f2(o2)) return o2;
909
1029
  const s2 = m(o2), c2 = m(r2);
910
1030
  e2.stack.push(s2 - c2);
911
1031
  }
912
1032
  },
913
- [n.MUL]: {
1033
+ [i$2.MUL]: {
914
1034
  stackIn: 2,
915
1035
  stackOut: 1,
916
1036
  execute: (e2, t2) => {
917
- const r2 = l(e2, t2.op);
1037
+ const r2 = d(e2, t2.op);
918
1038
  if (f2(r2)) return r2;
919
- const o2 = l(e2, t2.op);
1039
+ const o2 = d(e2, t2.op);
920
1040
  if (f2(o2)) return o2;
921
1041
  const s2 = m(o2), c2 = m(r2);
922
1042
  e2.stack.push(s2 * c2);
923
1043
  }
924
1044
  },
925
- [n.DIV]: {
1045
+ [i$2.DIV]: {
926
1046
  stackIn: 2,
927
1047
  stackOut: 1,
928
1048
  execute: (e2, t2) => {
929
- const r2 = l(e2, t2.op);
1049
+ const r2 = d(e2, t2.op);
930
1050
  if (f2(r2)) return r2;
931
- const o2 = l(e2, t2.op);
1051
+ const o2 = d(e2, t2.op);
932
1052
  if (f2(o2)) return o2;
933
1053
  const s2 = m(o2), c2 = m(r2);
934
1054
  if (c2 === 0)
@@ -941,61 +1061,61 @@ const f2 = Q, Z = {
941
1061
  e2.stack.push(s2 / c2);
942
1062
  }
943
1063
  },
944
- [n.MOD]: {
1064
+ [i$2.MOD]: {
945
1065
  stackIn: 2,
946
1066
  stackOut: 1,
947
1067
  execute: (e2, t2) => {
948
- const r2 = l(e2, t2.op);
1068
+ const r2 = d(e2, t2.op);
949
1069
  if (f2(r2)) return r2;
950
- const o2 = l(e2, t2.op);
1070
+ const o2 = d(e2, t2.op);
951
1071
  if (f2(o2)) return o2;
952
1072
  const s2 = m(o2), c2 = m(r2);
953
1073
  e2.stack.push(s2 % c2);
954
1074
  }
955
1075
  },
956
- [n.UNARY_MINUS]: {
1076
+ [i$2.UNARY_MINUS]: {
957
1077
  stackIn: 1,
958
1078
  stackOut: 1,
959
1079
  execute: (e2, t2) => {
960
- const r2 = l(e2, t2.op);
1080
+ const r2 = d(e2, t2.op);
961
1081
  if (f2(r2)) return r2;
962
1082
  const o2 = m(r2);
963
1083
  e2.stack.push(-o2);
964
1084
  }
965
1085
  },
966
- [n.UNARY_PLUS]: {
1086
+ [i$2.UNARY_PLUS]: {
967
1087
  stackIn: 1,
968
1088
  stackOut: 1,
969
1089
  execute: (e2, t2) => {
970
- const r2 = l(e2, t2.op);
1090
+ const r2 = d(e2, t2.op);
971
1091
  if (f2(r2)) return r2;
972
1092
  const o2 = m(r2);
973
1093
  e2.stack.push(o2);
974
1094
  }
975
1095
  }
976
1096
  }, ee = {
977
- [n.PUSH]: {
1097
+ [i$2.PUSH]: {
978
1098
  stackIn: 0,
979
1099
  stackOut: 1,
980
1100
  execute: (e2, t2) => {
981
1101
  e2.stack.push(t2.arg);
982
1102
  }
983
1103
  },
984
- [n.PUSH_UNDEFINED]: {
1104
+ [i$2.PUSH_UNDEFINED]: {
985
1105
  stackIn: 0,
986
1106
  stackOut: 1,
987
1107
  execute: (e2) => {
988
- e2.stack.push(C());
1108
+ e2.stack.push(C$1());
989
1109
  }
990
1110
  },
991
- [n.POP]: {
1111
+ [i$2.POP]: {
992
1112
  stackIn: 1,
993
1113
  stackOut: 0,
994
1114
  execute: (e2) => {
995
1115
  e2.stack.pop();
996
1116
  }
997
1117
  },
998
- [n.DUP]: {
1118
+ [i$2.DUP]: {
999
1119
  stackIn: 1,
1000
1120
  stackOut: 2,
1001
1121
  execute: (e2, t2) => {
@@ -1003,7 +1123,7 @@ const f2 = Q, Z = {
1003
1123
  e2.stack.push(r2), e2.stack.push(r2);
1004
1124
  }
1005
1125
  },
1006
- [n.SWAP]: {
1126
+ [i$2.SWAP]: {
1007
1127
  stackIn: 2,
1008
1128
  stackOut: 2,
1009
1129
  execute: (e2, t2) => {
@@ -1011,7 +1131,7 @@ const f2 = Q, Z = {
1011
1131
  e2.stack.push(r2), e2.stack.push(o2);
1012
1132
  }
1013
1133
  },
1014
- [n.DUP2]: {
1134
+ [i$2.DUP2]: {
1015
1135
  stackIn: 2,
1016
1136
  stackOut: 4,
1017
1137
  execute: (e2, t2) => {
@@ -1020,7 +1140,7 @@ const f2 = Q, Z = {
1020
1140
  }
1021
1141
  }
1022
1142
  }, re = {
1023
- [n.PRINT]: {
1143
+ [i$2.PRINT]: {
1024
1144
  stackIn: 1,
1025
1145
  stackOut: 0,
1026
1146
  execute: (e2) => {
@@ -1028,7 +1148,7 @@ const f2 = Q, Z = {
1028
1148
  t2 !== void 0 && e2.output.push(p$1(t2));
1029
1149
  }
1030
1150
  },
1031
- [n.CC]: {
1151
+ [i$2.CC]: {
1032
1152
  stackIn: 1,
1033
1153
  stackOut: 0,
1034
1154
  controlsPC: true,
@@ -1039,7 +1159,7 @@ const f2 = Q, Z = {
1039
1159
  }
1040
1160
  }
1041
1161
  }, te = {
1042
- [n.HALT]: {
1162
+ [i$2.HALT]: {
1043
1163
  stackIn: 0,
1044
1164
  stackOut: 0,
1045
1165
  controlsPC: true,
@@ -1047,7 +1167,7 @@ const f2 = Q, Z = {
1047
1167
  e2.status = "complete";
1048
1168
  }
1049
1169
  },
1050
- [n.JUMP]: {
1170
+ [i$2.JUMP]: {
1051
1171
  stackIn: 0,
1052
1172
  stackOut: 0,
1053
1173
  controlsPC: true,
@@ -1070,7 +1190,7 @@ const f2 = Q, Z = {
1070
1190
  e2.pc = r2;
1071
1191
  }
1072
1192
  },
1073
- [n.JUMP_IF_FALSE]: {
1193
+ [i$2.JUMP_IF_FALSE]: {
1074
1194
  stackIn: 1,
1075
1195
  stackOut: 0,
1076
1196
  controlsPC: true,
@@ -1091,10 +1211,10 @@ const f2 = Q, Z = {
1091
1211
  pc: e2.pc,
1092
1212
  opcode: t2.op
1093
1213
  };
1094
- j$1(r2) ? e2.pc++ : e2.pc = o2;
1214
+ j(r2) ? e2.pc++ : e2.pc = o2;
1095
1215
  }
1096
1216
  },
1097
- [n.JUMP_IF]: {
1217
+ [i$2.JUMP_IF]: {
1098
1218
  stackIn: 1,
1099
1219
  stackOut: 0,
1100
1220
  controlsPC: true,
@@ -1115,10 +1235,10 @@ const f2 = Q, Z = {
1115
1235
  pc: e2.pc,
1116
1236
  opcode: t2.op
1117
1237
  };
1118
- j$1(r2) ? e2.pc = o2 : e2.pc++;
1238
+ j(r2) ? e2.pc = o2 : e2.pc++;
1119
1239
  }
1120
1240
  },
1121
- [n.JUMP_IF_TRUE]: {
1241
+ [i$2.JUMP_IF_TRUE]: {
1122
1242
  stackIn: 1,
1123
1243
  stackOut: 0,
1124
1244
  controlsPC: true,
@@ -1139,10 +1259,10 @@ const f2 = Q, Z = {
1139
1259
  pc: e2.pc,
1140
1260
  opcode: t2.op
1141
1261
  };
1142
- j$1(r2) ? e2.pc = o2 : e2.pc++;
1262
+ j(r2) ? e2.pc = o2 : e2.pc++;
1143
1263
  }
1144
1264
  },
1145
- [n.CALL]: {
1265
+ [i$2.CALL]: {
1146
1266
  stackIn: 1,
1147
1267
  stackOut: 0,
1148
1268
  controlsPC: false,
@@ -1150,19 +1270,19 @@ const f2 = Q, Z = {
1150
1270
  type: "RuntimeError",
1151
1271
  message: "Functions not implemented",
1152
1272
  pc: e2.pc,
1153
- opcode: n.CALL
1273
+ opcode: i$2.CALL
1154
1274
  })
1155
1275
  }
1156
1276
  }, oe = {
1157
- [n.LOAD]: {
1277
+ [i$2.LOAD]: {
1158
1278
  stackIn: 0,
1159
1279
  stackOut: 1,
1160
1280
  execute: (e2, t2) => {
1161
1281
  const r2 = t2.arg;
1162
- e2.variables.has(r2) ? e2.stack.push(e2.variables.get(r2)) : e2.stack.push(C());
1282
+ e2.variables.has(r2) ? e2.stack.push(e2.variables.get(r2)) : e2.stack.push(C$1());
1163
1283
  }
1164
1284
  },
1165
- [n.STORE]: {
1285
+ [i$2.STORE]: {
1166
1286
  stackIn: 1,
1167
1287
  stackOut: 0,
1168
1288
  execute: (e2, t2) => {
@@ -1171,7 +1291,7 @@ const f2 = Q, Z = {
1171
1291
  }
1172
1292
  }
1173
1293
  }, se = {
1174
- [n.ITER_START]: {
1294
+ [i$2.ITER_START]: {
1175
1295
  stackIn: 1,
1176
1296
  stackOut: 0,
1177
1297
  execute: (e2, t2) => {
@@ -1217,7 +1337,7 @@ const f2 = Q, Z = {
1217
1337
  });
1218
1338
  }
1219
1339
  },
1220
- [n.ITER_NEXT]: {
1340
+ [i$2.ITER_NEXT]: {
1221
1341
  stackIn: 0,
1222
1342
  stackOut: 2,
1223
1343
  // Pushes element and hasMore flag
@@ -1230,10 +1350,10 @@ const f2 = Q, Z = {
1230
1350
  opcode: t2.op
1231
1351
  };
1232
1352
  const r2 = e2.iterators[e2.iterators.length - 1];
1233
- r2.index < r2.length ? (r2.index < r2.array.elements.length ? e2.stack.push(r2.array.elements[r2.index]) : e2.stack.push(C()), e2.stack.push(true), r2.index++) : (e2.stack.push(null), e2.stack.push(false));
1353
+ r2.index < r2.length ? (r2.array && r2.index < r2.array.elements.length ? e2.stack.push(r2.array.elements[r2.index]) : e2.stack.push(C$1()), e2.stack.push(true), r2.index++) : (e2.stack.push(null), e2.stack.push(false));
1234
1354
  }
1235
1355
  },
1236
- [n.ITER_END]: {
1356
+ [i$2.ITER_END]: {
1237
1357
  stackIn: 0,
1238
1358
  stackOut: 0,
1239
1359
  execute: (e2, t2) => {
@@ -1248,121 +1368,121 @@ const f2 = Q, Z = {
1248
1368
  }
1249
1369
  }
1250
1370
  };
1251
- function T(e2, t2, r2) {
1252
- const o2 = l(e2, t2.op);
1371
+ function v(e2, t2, r2) {
1372
+ const o2 = d(e2, t2.op);
1253
1373
  if (f2(o2)) return o2;
1254
- const s2 = l(e2, t2.op);
1374
+ const s2 = d(e2, t2.op);
1255
1375
  if (f2(s2)) return s2;
1256
1376
  const c2 = r2(s2, o2);
1257
1377
  e2.stack.push(c2);
1258
1378
  }
1259
1379
  const ce = {
1260
- [n.EQ]: {
1380
+ [i$2.EQ]: {
1261
1381
  stackIn: 2,
1262
1382
  stackOut: 1,
1263
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1383
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1264
1384
  if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1265
1385
  return true;
1266
1386
  if (c(r2) && c(o2))
1267
1387
  return true;
1268
- if (u$1(r2) || b$1(r2))
1269
- return u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id === o2.id : false;
1388
+ if (u$1(r2) || b(r2))
1389
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : false;
1270
1390
  {
1271
1391
  const s2 = m(r2), c2 = m(o2);
1272
1392
  return !isNaN(s2) && !isNaN(c2) ? s2 === c2 : p$1(r2) === p$1(o2);
1273
1393
  }
1274
1394
  })
1275
1395
  },
1276
- [n.NEQ]: {
1396
+ [i$2.NEQ]: {
1277
1397
  stackIn: 2,
1278
1398
  stackOut: 1,
1279
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1399
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1280
1400
  if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1281
1401
  return false;
1282
1402
  if (c(r2) && c(o2))
1283
1403
  return false;
1284
- if (u$1(r2) || b$1(r2))
1285
- return u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id !== o2.id : true;
1404
+ if (u$1(r2) || b(r2))
1405
+ return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : true;
1286
1406
  {
1287
1407
  const s2 = m(r2), c2 = m(o2);
1288
1408
  return !isNaN(s2) && !isNaN(c2) ? s2 !== c2 : p$1(r2) !== p$1(o2);
1289
1409
  }
1290
1410
  })
1291
1411
  },
1292
- [n.LT]: {
1412
+ [i$2.LT]: {
1293
1413
  stackIn: 2,
1294
1414
  stackOut: 1,
1295
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1415
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1296
1416
  const s2 = m(r2), c2 = m(o2);
1297
1417
  return s2 < c2;
1298
1418
  })
1299
1419
  },
1300
- [n.GT]: {
1420
+ [i$2.GT]: {
1301
1421
  stackIn: 2,
1302
1422
  stackOut: 1,
1303
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1423
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1304
1424
  const s2 = m(r2), c2 = m(o2);
1305
1425
  return s2 > c2;
1306
1426
  })
1307
1427
  },
1308
- [n.LTE]: {
1428
+ [i$2.LTE]: {
1309
1429
  stackIn: 2,
1310
1430
  stackOut: 1,
1311
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1431
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1312
1432
  const s2 = m(r2), c2 = m(o2);
1313
1433
  return s2 <= c2;
1314
1434
  })
1315
1435
  },
1316
- [n.GTE]: {
1436
+ [i$2.GTE]: {
1317
1437
  stackIn: 2,
1318
1438
  stackOut: 1,
1319
- execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1439
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => {
1320
1440
  const s2 = m(r2), c2 = m(o2);
1321
1441
  return s2 >= c2;
1322
1442
  })
1323
1443
  },
1324
- [n.EQ_STRICT]: {
1444
+ [i$2.EQ_STRICT]: {
1325
1445
  stackIn: 2,
1326
1446
  stackOut: 1,
1327
- execute: (e2, t2) => T(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id === o2.id : r2 === o2)
1447
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : r2 === o2)
1328
1448
  },
1329
- [n.NEQ_STRICT]: {
1449
+ [i$2.NEQ_STRICT]: {
1330
1450
  stackIn: 2,
1331
1451
  stackOut: 1,
1332
- execute: (e2, t2) => T(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id !== o2.id : r2 !== o2)
1452
+ execute: (e2, t2) => v(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : r2 !== o2)
1333
1453
  }
1334
1454
  }, ne = {
1335
- [n.AND]: {
1455
+ [i$2.AND]: {
1336
1456
  stackIn: 2,
1337
1457
  stackOut: 1,
1338
1458
  execute: (e2, t2) => {
1339
- const r2 = l(e2, t2.op);
1459
+ const r2 = d(e2, t2.op);
1340
1460
  if (f2(r2)) return r2;
1341
- const o2 = l(e2, t2.op);
1461
+ const o2 = d(e2, t2.op);
1342
1462
  if (f2(o2)) return o2;
1343
- const s2 = j$1(o2) ? r2 : o2;
1463
+ const s2 = j(o2) ? r2 : o2;
1344
1464
  e2.stack.push(s2);
1345
1465
  }
1346
1466
  },
1347
- [n.OR]: {
1467
+ [i$2.OR]: {
1348
1468
  stackIn: 2,
1349
1469
  stackOut: 1,
1350
1470
  execute: (e2, t2) => {
1351
- const r2 = l(e2, t2.op);
1471
+ const r2 = d(e2, t2.op);
1352
1472
  if (f2(r2)) return r2;
1353
- const o2 = l(e2, t2.op);
1473
+ const o2 = d(e2, t2.op);
1354
1474
  if (f2(o2)) return o2;
1355
- const s2 = j$1(o2) ? o2 : r2;
1475
+ const s2 = j(o2) ? o2 : r2;
1356
1476
  e2.stack.push(s2);
1357
1477
  }
1358
1478
  },
1359
- [n.NOT]: {
1479
+ [i$2.NOT]: {
1360
1480
  stackIn: 1,
1361
1481
  stackOut: 1,
1362
1482
  execute: (e2, t2) => {
1363
- const r2 = l(e2, t2.op);
1483
+ const r2 = d(e2, t2.op);
1364
1484
  if (f2(r2)) return r2;
1365
- const o2 = !j$1(r2);
1485
+ const o2 = !j(r2);
1366
1486
  e2.stack.push(o2);
1367
1487
  }
1368
1488
  }
@@ -1371,7 +1491,7 @@ const ce = {
1371
1491
  * ARRAY_NEW: Creates a new empty array on the heap
1372
1492
  * Stack: [] -> [array-ref]
1373
1493
  */
1374
- [n.ARRAY_NEW]: {
1494
+ [i$2.ARRAY_NEW]: {
1375
1495
  stackIn: 0,
1376
1496
  stackOut: 1,
1377
1497
  execute: (e2, t2) => {
@@ -1383,7 +1503,7 @@ const ce = {
1383
1503
  * ARRAY_PUSH: Pushes a value to the end of an array
1384
1504
  * Stack: [array-ref, value] -> [array-ref]
1385
1505
  */
1386
- [n.ARRAY_PUSH]: {
1506
+ [i$2.ARRAY_PUSH]: {
1387
1507
  stackIn: 2,
1388
1508
  stackOut: 1,
1389
1509
  execute: (e2, t2) => {
@@ -1411,7 +1531,7 @@ const ce = {
1411
1531
  s2.elements.push(r2), e2.stack.push(o$12);
1412
1532
  }
1413
1533
  },
1414
- [n.ARRAY_GET]: {
1534
+ [i$2.ARRAY_GET]: {
1415
1535
  stackIn: 2,
1416
1536
  stackOut: 1,
1417
1537
  execute: (e2, t$1) => {
@@ -1428,7 +1548,7 @@ const ce = {
1428
1548
  opcode: t$1.op
1429
1549
  };
1430
1550
  s2 = u2.data;
1431
- } else if (b$1(o$12)) {
1551
+ } else if (b(o$12)) {
1432
1552
  const u2 = e2.heap.get(o$12.id);
1433
1553
  if (!u2 || u2.type !== "object")
1434
1554
  return {
@@ -1437,7 +1557,7 @@ const ce = {
1437
1557
  pc: e2.pc,
1438
1558
  opcode: t$1.op
1439
1559
  };
1440
- const i2 = u2.data, y2 = p$1(r2), E2 = i2.properties[y2] ?? C();
1560
+ const i2 = u2.data, y2 = p$1(r2), E2 = i2.properties[y2] ?? C$1();
1441
1561
  e2.stack.push(E2);
1442
1562
  return;
1443
1563
  } else if (o(o$12))
@@ -1450,7 +1570,7 @@ const ce = {
1450
1570
  const i2 = parseInt(r2, 10);
1451
1571
  !isNaN(i2) && i2.toString() === r2 && (u2 = i2);
1452
1572
  }
1453
- u2 !== void 0 && u2 >= 0 && u2 < o$12.length ? e2.stack.push(o$12[u2]) : e2.stack.push(C());
1573
+ u2 !== void 0 && u2 >= 0 && u2 < o$12.length ? e2.stack.push(o$12[u2]) : e2.stack.push(C$1());
1454
1574
  return;
1455
1575
  } else
1456
1576
  return {
@@ -1467,7 +1587,7 @@ const ce = {
1467
1587
  if (!isNaN(u2) && u2.toString() === r2 && u2 >= 0)
1468
1588
  c2 = u2;
1469
1589
  else {
1470
- const i2 = ((a2 = s2.properties) == null ? void 0 : a2[r2]) ?? C();
1590
+ const i2 = ((a2 = s2.properties) == null ? void 0 : a2[r2]) ?? C$1();
1471
1591
  e2.stack.push(i2);
1472
1592
  return;
1473
1593
  }
@@ -1478,11 +1598,11 @@ const ce = {
1478
1598
  pc: e2.pc,
1479
1599
  opcode: t$1.op
1480
1600
  };
1481
- const p2 = s2.elements[c2] ?? C();
1601
+ const p2 = s2.elements[c2] ?? C$1();
1482
1602
  e2.stack.push(p2);
1483
1603
  }
1484
1604
  },
1485
- [n.ARRAY_SET]: {
1605
+ [i$2.ARRAY_SET]: {
1486
1606
  stackIn: 3,
1487
1607
  stackOut: 1,
1488
1608
  execute: (e2, t$1) => {
@@ -1498,7 +1618,7 @@ const ce = {
1498
1618
  opcode: t$1.op
1499
1619
  };
1500
1620
  c2 = u2.data;
1501
- } else if (b$1(s2)) {
1621
+ } else if (b(s2)) {
1502
1622
  const u2 = e2.heap.get(s2.id);
1503
1623
  if (!u2 || u2.type !== "object")
1504
1624
  return {
@@ -1548,7 +1668,7 @@ const ce = {
1548
1668
  c2.elements[a2] = r2, e2.stack.push(s2);
1549
1669
  }
1550
1670
  },
1551
- [n.ARRAY_LEN]: {
1671
+ [i$2.ARRAY_LEN]: {
1552
1672
  stackIn: 1,
1553
1673
  stackOut: 1,
1554
1674
  execute: (e2, t2) => {
@@ -1576,7 +1696,7 @@ const ce = {
1576
1696
  e2.stack.push(o$12.elements.length);
1577
1697
  }
1578
1698
  },
1579
- [n.ARRAY_MAP_PROP]: {
1699
+ [i$2.ARRAY_MAP_PROP]: {
1580
1700
  stackIn: 2,
1581
1701
  stackOut: 1,
1582
1702
  execute: (e2, t2) => {
@@ -1598,7 +1718,7 @@ const ce = {
1598
1718
  };
1599
1719
  const c2 = s$12.data, p2 = s();
1600
1720
  for (const u2 of c2.elements)
1601
- if (b$1(u2)) {
1721
+ if (b(u2)) {
1602
1722
  const i2 = e2.heap.get(u2.id);
1603
1723
  if (i2 && i2.type === "object") {
1604
1724
  const y2 = i2.data, E2 = p$1(r2);
@@ -1611,7 +1731,7 @@ const ce = {
1611
1731
  e2.stack.push(a2);
1612
1732
  }
1613
1733
  },
1614
- [n.ARRAY_FILTER_PROP]: {
1734
+ [i$2.ARRAY_FILTER_PROP]: {
1615
1735
  stackIn: 2,
1616
1736
  stackOut: 1,
1617
1737
  execute: (e2, t2) => {
@@ -1633,7 +1753,7 @@ const ce = {
1633
1753
  };
1634
1754
  const c2 = s$12.data, p2 = s();
1635
1755
  for (const u2 of c2.elements)
1636
- if (b$1(u2)) {
1756
+ if (b(u2)) {
1637
1757
  const i2 = e2.heap.get(u2.id);
1638
1758
  if (i2 && i2.type === "object") {
1639
1759
  const y2 = i2.data, E2 = p$1(r2);
@@ -1644,7 +1764,7 @@ const ce = {
1644
1764
  e2.stack.push(a2);
1645
1765
  }
1646
1766
  },
1647
- [n.ARRAY_SLICE]: {
1767
+ [i$2.ARRAY_SLICE]: {
1648
1768
  stackIn: 3,
1649
1769
  // array, start, end
1650
1770
  stackOut: 1,
@@ -1662,11 +1782,11 @@ const ce = {
1662
1782
  pc: e2.pc,
1663
1783
  opcode: t2.op
1664
1784
  };
1665
- const a2 = e2.heap.get(s$12.id).data, u2 = i$1(o2) ? o2 : 0, i2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, E2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, Y2 = a2.elements.slice(y2, E2), J2 = s(Y2), z = e2.heap.allocate("array", J2);
1666
- e2.stack.push(z);
1785
+ const a2 = e2.heap.get(s$12.id).data, u2 = i$1(o2) ? o2 : 0, i2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, E2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, J2 = a2.elements.slice(y2, E2), Y2 = s(J2), z2 = e2.heap.allocate("array", Y2);
1786
+ e2.stack.push(z2);
1667
1787
  }
1668
1788
  },
1669
- [n.ARRAY_JOIN]: {
1789
+ [i$2.ARRAY_JOIN]: {
1670
1790
  stackIn: 2,
1671
1791
  // array, separator
1672
1792
  stackOut: 1,
@@ -1689,7 +1809,7 @@ const ce = {
1689
1809
  e2.stack.push(i2);
1690
1810
  }
1691
1811
  },
1692
- [n.ARRAY_INDEX_OF]: {
1812
+ [i$2.ARRAY_INDEX_OF]: {
1693
1813
  stackIn: 2,
1694
1814
  // array, searchElement
1695
1815
  stackOut: 1,
@@ -1739,22 +1859,22 @@ function M(e2, t2) {
1739
1859
  }
1740
1860
  }
1741
1861
  const ae = {
1742
- [n.CONCAT]: {
1862
+ [i$2.CONCAT]: {
1743
1863
  stackIn: 2,
1744
1864
  stackOut: 1,
1745
1865
  execute: (e2, t2) => {
1746
- const r2 = l(e2, t2.op);
1866
+ const r2 = d(e2, t2.op);
1747
1867
  if (f2(r2)) return r2;
1748
- const o2 = l(e2, t2.op);
1868
+ const o2 = d(e2, t2.op);
1749
1869
  if (f2(o2)) return o2;
1750
1870
  e2.stack.push(p$1(o2) + p$1(r2));
1751
1871
  }
1752
1872
  },
1753
- [n.STRING_LEN]: {
1873
+ [i$2.STRING_LEN]: {
1754
1874
  stackIn: 1,
1755
1875
  stackOut: 1,
1756
1876
  execute: (e2, t$1) => {
1757
- const r2 = l(e2, t$1.op);
1877
+ const r2 = d(e2, t$1.op);
1758
1878
  if (f2(r2)) return r2;
1759
1879
  if (!t(r2))
1760
1880
  return {
@@ -1766,11 +1886,11 @@ const ae = {
1766
1886
  e2.stack.push(r2.length);
1767
1887
  }
1768
1888
  },
1769
- [n.LENGTH]: {
1889
+ [i$2.LENGTH]: {
1770
1890
  stackIn: 1,
1771
1891
  stackOut: 1,
1772
1892
  execute: (e2, t$1) => {
1773
- const r2 = l(e2, t$1.op);
1893
+ const r2 = d(e2, t$1.op);
1774
1894
  if (f2(r2)) return r2;
1775
1895
  if (t(r2))
1776
1896
  e2.stack.push(r2.length);
@@ -1796,11 +1916,11 @@ const ae = {
1796
1916
  };
1797
1917
  }
1798
1918
  },
1799
- [n.JSON_PARSE]: {
1919
+ [i$2.JSON_PARSE]: {
1800
1920
  stackIn: 1,
1801
1921
  stackOut: 1,
1802
1922
  execute: (e2, t$1) => {
1803
- const r2 = l(e2, t$1.op);
1923
+ const r2 = d(e2, t$1.op);
1804
1924
  if (f2(r2)) return r2;
1805
1925
  if (!t(r2))
1806
1926
  return {
@@ -1817,17 +1937,17 @@ const ae = {
1817
1937
  }
1818
1938
  }
1819
1939
  },
1820
- [n.TYPEOF]: {
1940
+ [i$2.TYPEOF]: {
1821
1941
  stackIn: 1,
1822
1942
  stackOut: 1,
1823
1943
  execute: (e2, t2) => {
1824
- const r2 = l(e2, t2.op);
1944
+ const r2 = d(e2, t2.op);
1825
1945
  if (f2(r2)) return r2;
1826
- e2.stack.push(d$1(r2));
1946
+ e2.stack.push(d$2(r2));
1827
1947
  }
1828
1948
  }
1829
1949
  }, ue = {
1830
- [n.INC]: {
1950
+ [i$2.INC]: {
1831
1951
  stackIn: 1,
1832
1952
  stackOut: 1,
1833
1953
  execute: (e2, t2) => {
@@ -1845,7 +1965,7 @@ const ae = {
1845
1965
  e2.stack.push(c2 ? m(o2) : s2);
1846
1966
  }
1847
1967
  },
1848
- [n.DEC]: {
1968
+ [i$2.DEC]: {
1849
1969
  stackIn: 1,
1850
1970
  stackOut: 1,
1851
1971
  execute: (e2, t2) => {
@@ -1864,7 +1984,7 @@ const ae = {
1864
1984
  }
1865
1985
  }
1866
1986
  }, ie = {
1867
- [n.RETURN]: {
1987
+ [i$2.RETURN]: {
1868
1988
  stackIn: 0,
1869
1989
  stackOut: 0,
1870
1990
  controlsPC: true,
@@ -1873,7 +1993,7 @@ const ae = {
1873
1993
  e2.returnValue = r2, e2.status = "complete";
1874
1994
  }
1875
1995
  },
1876
- [n.BREAK]: {
1996
+ [i$2.BREAK]: {
1877
1997
  stackIn: 0,
1878
1998
  stackOut: 0,
1879
1999
  controlsPC: true,
@@ -1896,7 +2016,7 @@ const ae = {
1896
2016
  e2.pc = r2;
1897
2017
  }
1898
2018
  },
1899
- [n.CONTINUE]: {
2019
+ [i$2.CONTINUE]: {
1900
2020
  stackIn: 0,
1901
2021
  stackOut: 0,
1902
2022
  controlsPC: true,
@@ -1919,7 +2039,7 @@ const ae = {
1919
2039
  e2.pc = r2;
1920
2040
  }
1921
2041
  },
1922
- [n.FS_LIST_FILES]: {
2042
+ [i$2.FS_LIST_FILES]: {
1923
2043
  stackIn: 1,
1924
2044
  // Minimum 1 argument (path), optionally 2 (path + options)
1925
2045
  stackOut: 1,
@@ -1955,7 +2075,7 @@ const ae = {
1955
2075
  e2.stack.push(c2);
1956
2076
  }
1957
2077
  },
1958
- [n.FS_READ_FILE]: {
2078
+ [i$2.FS_READ_FILE]: {
1959
2079
  stackIn: 1,
1960
2080
  // path
1961
2081
  stackOut: 1,
@@ -1980,7 +2100,7 @@ const ae = {
1980
2100
  e2.stack.push(o2);
1981
2101
  }
1982
2102
  },
1983
- [n.FS_WRITE_FILE]: {
2103
+ [i$2.FS_WRITE_FILE]: {
1984
2104
  stackIn: 2,
1985
2105
  // path, content
1986
2106
  stackOut: 1,
@@ -2013,7 +2133,7 @@ const ae = {
2013
2133
  }
2014
2134
  },
2015
2135
  // String method handlers
2016
- [n.STRING_SUBSTRING]: {
2136
+ [i$2.STRING_SUBSTRING]: {
2017
2137
  stackIn: 2,
2018
2138
  // Minimum 2 (string, start), optionally 3 (string, start, end)
2019
2139
  stackOut: 1,
@@ -2048,7 +2168,7 @@ const ae = {
2048
2168
  e2.stack.push(i2);
2049
2169
  }
2050
2170
  },
2051
- [n.STRING_INDEXOF]: {
2171
+ [i$2.STRING_INDEXOF]: {
2052
2172
  stackIn: 2,
2053
2173
  stackOut: 1,
2054
2174
  execute: (e2, t$1) => {
@@ -2063,7 +2183,7 @@ const ae = {
2063
2183
  e2.stack.push(o2.indexOf(r2));
2064
2184
  }
2065
2185
  },
2066
- [n.STRING_SPLIT]: {
2186
+ [i$2.STRING_SPLIT]: {
2067
2187
  stackIn: 2,
2068
2188
  stackOut: 1,
2069
2189
  execute: (e2, t$1) => {
@@ -2081,7 +2201,7 @@ const ae = {
2081
2201
  e2.stack.push(p2);
2082
2202
  }
2083
2203
  },
2084
- [n.STRING_SLICE]: {
2204
+ [i$2.STRING_SLICE]: {
2085
2205
  stackIn: 2,
2086
2206
  // Minimum 2 (string, start), optionally 3 (string, start, end)
2087
2207
  stackOut: 1,
@@ -2114,7 +2234,7 @@ const ae = {
2114
2234
  e2.stack.push(u2);
2115
2235
  }
2116
2236
  },
2117
- [n.STRING_CHARAT]: {
2237
+ [i$2.STRING_CHARAT]: {
2118
2238
  stackIn: 2,
2119
2239
  stackOut: 1,
2120
2240
  execute: (e2, t$1) => {
@@ -2137,7 +2257,7 @@ const ae = {
2137
2257
  e2.stack.push(s2);
2138
2258
  }
2139
2259
  },
2140
- [n.STRING_TOUPPERCASE]: {
2260
+ [i$2.STRING_TOUPPERCASE]: {
2141
2261
  stackIn: 1,
2142
2262
  stackOut: 1,
2143
2263
  execute: (e2, t$1) => {
@@ -2152,7 +2272,7 @@ const ae = {
2152
2272
  e2.stack.push(r2.toUpperCase());
2153
2273
  }
2154
2274
  },
2155
- [n.STRING_TOLOWERCASE]: {
2275
+ [i$2.STRING_TOLOWERCASE]: {
2156
2276
  stackIn: 1,
2157
2277
  stackOut: 1,
2158
2278
  execute: (e2, t$1) => {
@@ -2167,7 +2287,7 @@ const ae = {
2167
2287
  e2.stack.push(r2.toLowerCase());
2168
2288
  }
2169
2289
  },
2170
- [n.TO_STRING]: {
2290
+ [i$2.TO_STRING]: {
2171
2291
  stackIn: 1,
2172
2292
  stackOut: 1,
2173
2293
  execute: (e2, t2) => {
@@ -2183,7 +2303,7 @@ const ae = {
2183
2303
  e2.stack.push(o2);
2184
2304
  }
2185
2305
  },
2186
- [n.STRING_INCLUDES]: {
2306
+ [i$2.STRING_INCLUDES]: {
2187
2307
  stackIn: 2,
2188
2308
  // string, searchString
2189
2309
  stackOut: 1,
@@ -2201,7 +2321,7 @@ const ae = {
2201
2321
  e2.stack.push(o2.includes(s2));
2202
2322
  }
2203
2323
  },
2204
- [n.STRING_ENDS_WITH]: {
2324
+ [i$2.STRING_ENDS_WITH]: {
2205
2325
  stackIn: 2,
2206
2326
  stackOut: 1,
2207
2327
  execute: (e2, t$1) => {
@@ -2217,7 +2337,7 @@ const ae = {
2217
2337
  e2.stack.push(o2.endsWith(s2));
2218
2338
  }
2219
2339
  },
2220
- [n.STRING_STARTS_WITH]: {
2340
+ [i$2.STRING_STARTS_WITH]: {
2221
2341
  stackIn: 2,
2222
2342
  stackOut: 1,
2223
2343
  execute: (e2, t$1) => {
@@ -2233,7 +2353,7 @@ const ae = {
2233
2353
  e2.stack.push(o2.startsWith(s2));
2234
2354
  }
2235
2355
  },
2236
- [n.STRING_TRIM]: {
2356
+ [i$2.STRING_TRIM]: {
2237
2357
  stackIn: 1,
2238
2358
  stackOut: 1,
2239
2359
  execute: (e2, t$1) => {
@@ -2248,7 +2368,7 @@ const ae = {
2248
2368
  e2.stack.push(r2.trim());
2249
2369
  }
2250
2370
  },
2251
- [n.STRING_TRIM_START]: {
2371
+ [i$2.STRING_TRIM_START]: {
2252
2372
  stackIn: 1,
2253
2373
  stackOut: 1,
2254
2374
  execute: (e2, t$1) => {
@@ -2263,7 +2383,7 @@ const ae = {
2263
2383
  e2.stack.push(r2.trimStart());
2264
2384
  }
2265
2385
  },
2266
- [n.STRING_TRIM_END]: {
2386
+ [i$2.STRING_TRIM_END]: {
2267
2387
  stackIn: 1,
2268
2388
  stackOut: 1,
2269
2389
  execute: (e2, t$1) => {
@@ -2278,7 +2398,7 @@ const ae = {
2278
2398
  e2.stack.push(r2.trimEnd());
2279
2399
  }
2280
2400
  },
2281
- [n.STRING_REPLACE]: {
2401
+ [i$2.STRING_REPLACE]: {
2282
2402
  stackIn: 3,
2283
2403
  // string, search, replacement
2284
2404
  stackOut: 1,
@@ -2295,7 +2415,7 @@ const ae = {
2295
2415
  e2.stack.push(u2);
2296
2416
  }
2297
2417
  },
2298
- [n.STRING_REPLACE_ALL]: {
2418
+ [i$2.STRING_REPLACE_ALL]: {
2299
2419
  stackIn: 3,
2300
2420
  stackOut: 1,
2301
2421
  execute: (e2, t$1) => {
@@ -2311,7 +2431,7 @@ const ae = {
2311
2431
  e2.stack.push(a2);
2312
2432
  }
2313
2433
  },
2314
- [n.STRING_LAST_INDEX_OF]: {
2434
+ [i$2.STRING_LAST_INDEX_OF]: {
2315
2435
  stackIn: 2,
2316
2436
  stackOut: 1,
2317
2437
  execute: (e2, t$1) => {
@@ -2327,7 +2447,7 @@ const ae = {
2327
2447
  e2.stack.push(o2.lastIndexOf(s2));
2328
2448
  }
2329
2449
  },
2330
- [n.STRING_REPEAT]: {
2450
+ [i$2.STRING_REPEAT]: {
2331
2451
  stackIn: 2,
2332
2452
  stackOut: 1,
2333
2453
  execute: (e2, t$1) => {
@@ -2349,7 +2469,7 @@ const ae = {
2349
2469
  e2.stack.push(o2.repeat(Math.floor(r2)));
2350
2470
  }
2351
2471
  },
2352
- [n.STRING_PAD_START]: {
2472
+ [i$2.STRING_PAD_START]: {
2353
2473
  stackIn: 3,
2354
2474
  // string, targetLength, padString
2355
2475
  stackOut: 1,
@@ -2373,7 +2493,7 @@ const ae = {
2373
2493
  e2.stack.push(s2.padStart(o2, c2 || " "));
2374
2494
  }
2375
2495
  },
2376
- [n.STRING_PAD_END]: {
2496
+ [i$2.STRING_PAD_END]: {
2377
2497
  stackIn: 3,
2378
2498
  stackOut: 1,
2379
2499
  execute: (e2, t$1) => {
@@ -2397,34 +2517,34 @@ const ae = {
2397
2517
  }
2398
2518
  }
2399
2519
  };
2400
- function P(e2, t2) {
2520
+ function A(e2, t2) {
2401
2521
  if (u$1(e2)) {
2402
2522
  const r2 = t2.get(e2.id);
2403
- return r2 && r2.type === "array" ? r2.data.elements.map((s2) => P(s2, t2)) : null;
2523
+ return r2 && r2.type === "array" ? r2.data.elements.map((s2) => A(s2, t2)) : null;
2404
2524
  }
2405
- if (b$1(e2)) {
2525
+ if (b(e2)) {
2406
2526
  const r2 = t2.get(e2.id);
2407
2527
  if (r2 && r2.type === "object") {
2408
2528
  const o2 = r2.data, s2 = {};
2409
2529
  for (const [c2, p2] of Object.entries(o2.properties))
2410
- s2[c2] = P(p2, t2);
2530
+ s2[c2] = A(p2, t2);
2411
2531
  return s2;
2412
2532
  }
2413
2533
  return null;
2414
2534
  }
2415
2535
  if (o(e2))
2416
- return e2.elements.map((r2) => P(r2, t2));
2536
+ return e2.elements.map((r2) => A(r2, t2));
2417
2537
  if (y(e2)) {
2418
2538
  const r2 = {};
2419
2539
  for (const [o2, s2] of Object.entries(e2.properties))
2420
- r2[o2] = P(s2, t2);
2540
+ r2[o2] = A(s2, t2);
2421
2541
  return r2;
2422
2542
  }
2423
2543
  if (!c(e2))
2424
2544
  return e2;
2425
2545
  }
2426
- const de = {
2427
- [n.OBJECT_CREATE]: {
2546
+ const le = {
2547
+ [i$2.OBJECT_CREATE]: {
2428
2548
  stackIn: 0,
2429
2549
  stackOut: 1,
2430
2550
  execute: (e2) => {
@@ -2432,18 +2552,18 @@ const de = {
2432
2552
  e2.stack.push(r2);
2433
2553
  }
2434
2554
  },
2435
- [n.PROPERTY_SET]: {
2555
+ [i$2.PROPERTY_SET]: {
2436
2556
  stackIn: 3,
2437
2557
  stackOut: 1,
2438
2558
  execute: (e2, t2) => {
2439
- const r2 = l(e2, t2.op);
2559
+ const r2 = d(e2, t2.op);
2440
2560
  if (f2(r2)) return r2;
2441
- const o2 = l(e2, t2.op);
2561
+ const o2 = d(e2, t2.op);
2442
2562
  if (f2(o2)) return o2;
2443
- const s2 = l(e2, t2.op);
2563
+ const s2 = d(e2, t2.op);
2444
2564
  if (f2(s2)) return s2;
2445
2565
  let c2;
2446
- if (b$1(s2)) {
2566
+ if (b(s2)) {
2447
2567
  const a2 = e2.heap.get(s2.id);
2448
2568
  if (!a2 || a2.type !== "object")
2449
2569
  return {
@@ -2458,7 +2578,7 @@ const de = {
2458
2578
  else
2459
2579
  return {
2460
2580
  type: "RuntimeError",
2461
- message: `Cannot set property '${o2}' on ${d$1(s2)}`,
2581
+ message: `Cannot set property '${o2}' on ${d$2(s2)}`,
2462
2582
  pc: e2.pc,
2463
2583
  opcode: t2.op
2464
2584
  };
@@ -2466,23 +2586,23 @@ const de = {
2466
2586
  c2.properties[p2] = r2, e2.stack.push(s2);
2467
2587
  }
2468
2588
  },
2469
- [n.PROPERTY_GET]: {
2589
+ [i$2.PROPERTY_GET]: {
2470
2590
  stackIn: 2,
2471
2591
  stackOut: 1,
2472
2592
  execute: (e2, t2) => {
2473
- const r2 = l(e2, t2.op);
2593
+ const r2 = d(e2, t2.op);
2474
2594
  if (f2(r2)) return r2;
2475
- const o2 = l(e2, t2.op);
2595
+ const o2 = d(e2, t2.op);
2476
2596
  if (f2(o2)) return o2;
2477
2597
  if (f$2(o2) || c(o2))
2478
2598
  return {
2479
2599
  type: "RuntimeError",
2480
- message: `Cannot read property '${r2}' of ${d$1(o2)}`,
2600
+ message: `Cannot read property '${r2}' of ${d$2(o2)}`,
2481
2601
  pc: e2.pc,
2482
2602
  opcode: t2.op
2483
2603
  };
2484
2604
  let s2 = null;
2485
- if (b$1(o2)) {
2605
+ if (b(o2)) {
2486
2606
  const p2 = e2.heap.get(o2.id);
2487
2607
  if (!p2 || p2.type !== "object")
2488
2608
  return {
@@ -2495,25 +2615,99 @@ const de = {
2495
2615
  } else if (y(o2))
2496
2616
  s2 = o2;
2497
2617
  else {
2498
- e2.stack.push(C());
2618
+ e2.stack.push(C$1());
2499
2619
  return;
2500
2620
  }
2501
2621
  const c$1 = s2.properties[p$1(r2)];
2502
- e2.stack.push(c$1 ?? C());
2622
+ e2.stack.push(c$1 ?? C$1());
2503
2623
  }
2504
2624
  },
2505
- [n.JSON_STRINGIFY]: {
2625
+ [i$2.JSON_STRINGIFY]: {
2506
2626
  stackIn: 1,
2507
2627
  stackOut: 1,
2508
2628
  execute: (e2, t2) => {
2509
- const r2 = l(e2, t2.op);
2629
+ const r2 = d(e2, t2.op);
2510
2630
  if (f2(r2)) return r2;
2511
- const o2 = P(r2, e2.heap);
2631
+ const o2 = A(r2, e2.heap);
2512
2632
  e2.stack.push(JSON.stringify(o2));
2513
2633
  }
2634
+ },
2635
+ [i$2.OBJECT_KEYS]: {
2636
+ stackIn: 1,
2637
+ stackOut: 1,
2638
+ execute: (e2, t2) => {
2639
+ const r2 = d(e2, t2.op);
2640
+ if (f2(r2)) return r2;
2641
+ if (b(r2)) {
2642
+ const o2 = e2.heap.get(r2.id);
2643
+ if (o2 && o2.type === "object") {
2644
+ const s2 = o2.data, c2 = Object.keys(s2.properties), p2 = e2.heap.allocate("array", { type: "array", elements: c2 });
2645
+ e2.stack.push(p2);
2646
+ } else
2647
+ e2.stack.push(null);
2648
+ } else if (y(r2)) {
2649
+ const o2 = Object.keys(r2.properties), s2 = e2.heap.allocate("array", { type: "array", elements: o2 });
2650
+ e2.stack.push(s2);
2651
+ } else
2652
+ e2.stack.push(null);
2653
+ }
2654
+ }
2655
+ }, de = {
2656
+ [i$2.OBJECT_ITER_START]: {
2657
+ stackIn: 1,
2658
+ stackOut: 0,
2659
+ execute: (e2, t2) => {
2660
+ const r2 = d(e2, t2.op);
2661
+ if (f2(r2)) return r2;
2662
+ if (b(r2)) {
2663
+ const o2 = e2.heap.get(r2.id);
2664
+ if (o2 && o2.type === "object") {
2665
+ const s2 = o2.data, c2 = Object.keys(s2.properties);
2666
+ e2.iterators.push({
2667
+ array: null,
2668
+ keys: c2,
2669
+ index: 0,
2670
+ length: c2.length
2671
+ });
2672
+ } else
2673
+ e2.iterators.push({
2674
+ array: null,
2675
+ keys: [],
2676
+ index: 0,
2677
+ length: 0
2678
+ });
2679
+ } else if (y(r2)) {
2680
+ const o2 = Object.keys(r2.properties);
2681
+ e2.iterators.push({
2682
+ array: null,
2683
+ keys: o2,
2684
+ index: 0,
2685
+ length: o2.length
2686
+ });
2687
+ } else
2688
+ e2.iterators.push({
2689
+ array: null,
2690
+ keys: [],
2691
+ index: 0,
2692
+ length: 0
2693
+ });
2694
+ }
2695
+ },
2696
+ [i$2.OBJECT_ITER_NEXT]: {
2697
+ stackIn: 0,
2698
+ stackOut: 2,
2699
+ // Push key and hasNext
2700
+ execute: (e2, t2) => {
2701
+ const r2 = e2.iterators[e2.iterators.length - 1];
2702
+ if (r2 && r2.index < r2.length && r2.keys) {
2703
+ const o2 = r2.keys[r2.index];
2704
+ e2.stack.push(o2), e2.stack.push(true), r2.index++;
2705
+ } else
2706
+ e2.stack.push(null), e2.stack.push(false);
2707
+ }
2514
2708
  }
2515
- }, le = {
2516
- [n.GET]: {
2709
+ }, fe = {
2710
+ [i$2.GET]: {
2517
2711
  stackIn: 2,
2518
2712
  stackOut: 1,
2519
2713
  execute: (e2, t$1) => {
@@ -2537,7 +2731,7 @@ const de = {
2537
2731
  if (!isNaN(i2) && i2.toString() === r2 && i2 >= 0)
2538
2732
  a2 = i2;
2539
2733
  else {
2540
- const y2 = ((s2 = p2.properties) == null ? void 0 : s2[r2]) ?? C();
2734
+ const y2 = ((s2 = p2.properties) == null ? void 0 : s2[r2]) ?? C$1();
2541
2735
  e2.stack.push(y2);
2542
2736
  return;
2543
2737
  }
@@ -2548,10 +2742,10 @@ const de = {
2548
2742
  pc: e2.pc,
2549
2743
  opcode: t$1.op
2550
2744
  };
2551
- const u2 = p2.elements[a2] ?? C();
2745
+ const u2 = p2.elements[a2] ?? C$1();
2552
2746
  e2.stack.push(u2);
2553
2747
  return;
2554
- } else if (b$1(o2)) {
2748
+ } else if (b(o2)) {
2555
2749
  const c2 = e2.heap.get(o2.id);
2556
2750
  if (!c2 || c2.type !== "object")
2557
2751
  return {
@@ -2560,7 +2754,7 @@ const de = {
2560
2754
  pc: e2.pc,
2561
2755
  opcode: t$1.op
2562
2756
  };
2563
- const p2 = c2.data, a2 = p$1(r2), u2 = p2.properties[a2] ?? C();
2757
+ const p2 = c2.data, a2 = p$1(r2), u2 = p2.properties[a2] ?? C$1();
2564
2758
  e2.stack.push(u2);
2565
2759
  return;
2566
2760
  } else if (t(o2)) {
@@ -2571,7 +2765,7 @@ const de = {
2571
2765
  const p2 = parseInt(r2, 10);
2572
2766
  !isNaN(p2) && p2.toString() === r2 && (c2 = p2);
2573
2767
  }
2574
- c2 !== void 0 && c2 >= 0 && c2 < o2.length ? e2.stack.push(o2[c2]) : e2.stack.push(C());
2768
+ c2 !== void 0 && c2 >= 0 && c2 < o2.length ? e2.stack.push(o2[c2]) : e2.stack.push(C$1());
2575
2769
  return;
2576
2770
  } else
2577
2771
  return {
@@ -2582,7 +2776,7 @@ const de = {
2582
2776
  };
2583
2777
  }
2584
2778
  },
2585
- [n.SET]: {
2779
+ [i$2.SET]: {
2586
2780
  stackIn: 3,
2587
2781
  stackOut: 1,
2588
2782
  execute: (e2, t$1) => {
@@ -2625,7 +2819,7 @@ const de = {
2625
2819
  };
2626
2820
  p2.elements[u2] = r2, e2.stack.push(s2);
2627
2821
  return;
2628
- } else if (b$1(s2)) {
2822
+ } else if (b(s2)) {
2629
2823
  const c2 = e2.heap.get(s2.id);
2630
2824
  if (!c2 || c2.type !== "object")
2631
2825
  return {
@@ -2646,6 +2840,224 @@ const de = {
2646
2840
  };
2647
2841
  }
2648
2842
  }
2843
+ }, ge = {
2844
+ stackIn: 0,
2845
+ // Consumes no stack items
2846
+ stackOut: 1,
2847
+ // Produces one stack item (heap reference)
2848
+ execute: (e2, t2) => {
2849
+ const r2 = t2.arg;
2850
+ if (!r2 || typeof r2.pattern != "string" || typeof r2.flags != "string")
2851
+ return {
2852
+ type: "TypeError",
2853
+ message: "LOAD_REGEX instruction requires pattern and flags properties",
2854
+ pc: e2.pc,
2855
+ opcode: t2.op
2856
+ };
2857
+ try {
2858
+ const o2 = new RegExp(r2.pattern, r2.flags), s2 = {
2859
+ type: "object",
2860
+ properties: {
2861
+ source: o2.source,
2862
+ flags: o2.flags,
2863
+ global: o2.global,
2864
+ ignoreCase: o2.ignoreCase,
2865
+ multiline: o2.multiline
2866
+ }
2867
+ }, c2 = e2.heap.allocate("object", s2);
2868
+ e2.stack.push(c2);
2869
+ return;
2870
+ } catch (o2) {
2871
+ return {
2872
+ type: "SyntaxError",
2873
+ message: `Invalid regular expression: ${o2.message}`,
2874
+ pc: e2.pc,
2875
+ opcode: t2.op
2876
+ };
2877
+ }
2878
+ }
2879
+ }, me = {
2880
+ stackIn: 2,
2881
+ // Consumes regex reference and string
2882
+ stackOut: 1,
2883
+ // Produces boolean result
2884
+ execute: (e2, t2) => {
2885
+ const r2 = d(e2, t2.op);
2886
+ if (f2(r2)) return r2;
2887
+ const o2 = d(e2, t2.op);
2888
+ if (f2(o2)) return o2;
2889
+ if (typeof r2 != "string")
2890
+ return {
2891
+ type: "TypeError",
2892
+ message: `Expected string argument for regex test, got ${typeof r2}`,
2893
+ pc: e2.pc,
2894
+ opcode: t2.op
2895
+ };
2896
+ if (!b(o2))
2897
+ return {
2898
+ type: "TypeError",
2899
+ message: "Expected regex object for regex test",
2900
+ pc: e2.pc,
2901
+ opcode: t2.op
2902
+ };
2903
+ const s2 = e2.heap.get(o2.id);
2904
+ if (!s2 || s2.type !== "object")
2905
+ return {
2906
+ type: "TypeError",
2907
+ message: "Invalid regex object reference",
2908
+ pc: e2.pc,
2909
+ opcode: t2.op
2910
+ };
2911
+ try {
2912
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2913
+ if (typeof p2 != "string" || typeof a2 != "string")
2914
+ return {
2915
+ type: "TypeError",
2916
+ message: "Invalid regex object structure",
2917
+ pc: e2.pc,
2918
+ opcode: t2.op
2919
+ };
2920
+ const i2 = new RegExp(p2, a2).test(r2);
2921
+ e2.stack.push(i2);
2922
+ return;
2923
+ } catch (c2) {
2924
+ return {
2925
+ type: "RuntimeError",
2926
+ message: `Regex test failed: ${c2.message}`,
2927
+ pc: e2.pc,
2928
+ opcode: t2.op
2929
+ };
2930
+ }
2931
+ }
2932
+ }, ke = {
2933
+ stackIn: 2,
2934
+ // Consumes string and regex reference
2935
+ stackOut: 1,
2936
+ // Produces array reference or null
2937
+ execute: (e2, t2) => {
2938
+ const r2 = d(e2, t2.op);
2939
+ if (f2(r2)) return r2;
2940
+ const o2 = d(e2, t2.op);
2941
+ if (f2(o2)) return o2;
2942
+ if (typeof o2 != "string")
2943
+ return {
2944
+ type: "TypeError",
2945
+ message: `Expected string input for match, got ${typeof o2}`,
2946
+ pc: e2.pc,
2947
+ opcode: t2.op
2948
+ };
2949
+ if (!b(r2))
2950
+ return {
2951
+ type: "TypeError",
2952
+ message: "Expected regex object for match",
2953
+ pc: e2.pc,
2954
+ opcode: t2.op
2955
+ };
2956
+ const s2 = e2.heap.get(r2.id);
2957
+ if (!s2 || s2.type !== "object")
2958
+ return {
2959
+ type: "TypeError",
2960
+ message: "Invalid regex object reference",
2961
+ pc: e2.pc,
2962
+ opcode: t2.op
2963
+ };
2964
+ try {
2965
+ const c2 = s2.data, p2 = c2.properties.source, a2 = c2.properties.flags;
2966
+ if (typeof p2 != "string" || typeof a2 != "string")
2967
+ return {
2968
+ type: "TypeError",
2969
+ message: "Invalid regex object structure",
2970
+ pc: e2.pc,
2971
+ opcode: t2.op
2972
+ };
2973
+ const u2 = new RegExp(p2, a2), i2 = o2.match(u2);
2974
+ if (i2 === null)
2975
+ e2.stack.push(null);
2976
+ else {
2977
+ const y2 = {
2978
+ type: "array",
2979
+ elements: [...i2]
2980
+ // Copy all match results
2981
+ }, E2 = e2.heap.allocate("array", y2);
2982
+ e2.stack.push(E2);
2983
+ }
2984
+ return;
2985
+ } catch (c2) {
2986
+ return {
2987
+ type: "RuntimeError",
2988
+ message: `String match failed: ${c2.message}`,
2989
+ pc: e2.pc,
2990
+ opcode: t2.op
2991
+ };
2992
+ }
2993
+ }
2994
+ }, ye = {
2995
+ stackIn: 3,
2996
+ // Consumes string, regex reference, and replacement string
2997
+ stackOut: 1,
2998
+ // Produces new string
2999
+ execute: (e2, t2) => {
3000
+ const r2 = d(e2, t2.op);
3001
+ if (f2(r2)) return r2;
3002
+ const o2 = d(e2, t2.op);
3003
+ if (f2(o2)) return o2;
3004
+ const s2 = d(e2, t2.op);
3005
+ if (f2(s2)) return s2;
3006
+ if (typeof s2 != "string")
3007
+ return {
3008
+ type: "TypeError",
3009
+ message: `Expected string input for replace, got ${typeof s2}`,
3010
+ pc: e2.pc,
3011
+ opcode: t2.op
3012
+ };
3013
+ if (!b(o2))
3014
+ return {
3015
+ type: "TypeError",
3016
+ message: "Expected regex object for replace",
3017
+ pc: e2.pc,
3018
+ opcode: t2.op
3019
+ };
3020
+ if (typeof r2 != "string")
3021
+ return {
3022
+ type: "TypeError",
3023
+ message: `Expected string replacement, got ${typeof r2}`,
3024
+ pc: e2.pc,
3025
+ opcode: t2.op
3026
+ };
3027
+ const c2 = e2.heap.get(o2.id);
3028
+ if (!c2 || c2.type !== "object")
3029
+ return {
3030
+ type: "TypeError",
3031
+ message: "Invalid regex object reference",
3032
+ pc: e2.pc,
3033
+ opcode: t2.op
3034
+ };
3035
+ try {
3036
+ const p2 = c2.data, a2 = p2.properties.source, u2 = p2.properties.flags;
3037
+ if (typeof a2 != "string" || typeof u2 != "string")
3038
+ return {
3039
+ type: "TypeError",
3040
+ message: "Invalid regex object structure",
3041
+ pc: e2.pc,
3042
+ opcode: t2.op
3043
+ };
3044
+ const i2 = new RegExp(a2, u2), y2 = s2.replace(i2, r2);
3045
+ e2.stack.push(y2);
3046
+ return;
3047
+ } catch (p2) {
3048
+ return {
3049
+ type: "RuntimeError",
3050
+ message: `String replace failed: ${p2.message}`,
3051
+ pc: e2.pc,
3052
+ opcode: t2.op
3053
+ };
3054
+ }
3055
+ }
3056
+ }, he = {
3057
+ [i$2.LOAD_REGEX]: ge,
3058
+ [i$2.REGEX_TEST]: me,
3059
+ [i$2.STRING_MATCH]: ke,
3060
+ [i$2.STRING_REPLACE_REGEX]: ye
2649
3061
  }, F = {
2650
3062
  ...Z,
2651
3063
  ...ee,
@@ -2659,10 +3071,12 @@ const de = {
2659
3071
  ...ae,
2660
3072
  ...ue,
2661
3073
  ...ie,
3074
+ ...le,
2662
3075
  ...de,
2663
- ...le
3076
+ ...fe,
3077
+ ...he
2664
3078
  };
2665
- function j() {
3079
+ function w() {
2666
3080
  const e2 = /* @__PURE__ */ new Map();
2667
3081
  let t2 = 1;
2668
3082
  return {
@@ -2679,7 +3093,7 @@ function j() {
2679
3093
  }
2680
3094
  };
2681
3095
  }
2682
- class w {
3096
+ class C {
2683
3097
  createInitialState() {
2684
3098
  return {
2685
3099
  pc: 0,
@@ -2688,7 +3102,7 @@ class w {
2688
3102
  status: "running",
2689
3103
  output: [],
2690
3104
  iterators: [],
2691
- heap: j()
3105
+ heap: w()
2692
3106
  };
2693
3107
  }
2694
3108
  executeInstruction(t2, r2) {
@@ -2706,7 +3120,7 @@ class w {
2706
3120
  if (o2.stack.length < t2.stackIn)
2707
3121
  return {
2708
3122
  type: "StackUnderflow",
2709
- message: `${n[r2.op]}: Stack underflow`,
3123
+ message: `${i$2[r2.op]}: Stack underflow`,
2710
3124
  pc: o2.pc,
2711
3125
  opcode: r2.op
2712
3126
  };
@@ -2720,7 +3134,7 @@ class w {
2720
3134
  output: (r2 == null ? void 0 : r2.output) ?? [],
2721
3135
  iterators: (r2 == null ? void 0 : r2.iterators) ?? [],
2722
3136
  fileSystem: o2,
2723
- heap: (r2 == null ? void 0 : r2.heap) ?? j(),
3137
+ heap: (r2 == null ? void 0 : r2.heap) ?? w(),
2724
3138
  ...r2
2725
3139
  };
2726
3140
  for (; s2.status === "running" && s2.pc < t2.length; ) {
@@ -2731,16 +3145,16 @@ class w {
2731
3145
  s2.status = "error", s2.error = a2.message;
2732
3146
  break;
2733
3147
  }
2734
- if ((c2.op === n.JUMP || c2.op === n.JUMP_IF_FALSE || c2.op === n.JUMP_IF || c2.op === n.JUMP_IF_TRUE || c2.op === n.BREAK || c2.op === n.CONTINUE) && c2.arg !== void 0 && c2.arg >= t2.length) {
3148
+ if ((c2.op === i$2.JUMP || c2.op === i$2.JUMP_IF_FALSE || c2.op === i$2.JUMP_IF || c2.op === i$2.JUMP_IF_TRUE || c2.op === i$2.BREAK || c2.op === i$2.CONTINUE) && c2.arg !== void 0 && c2.arg >= t2.length) {
2735
3149
  s2.status = "error";
2736
- const i2 = c2.op === n.JUMP || c2.op === n.JUMP_IF_FALSE || c2.op === n.JUMP_IF || c2.op === n.JUMP_IF_TRUE ? "jump" : c2.op === n.BREAK ? "break" : "continue";
3150
+ const i2 = c2.op === i$2.JUMP || c2.op === i$2.JUMP_IF_FALSE || c2.op === i$2.JUMP_IF || c2.op === i$2.JUMP_IF_TRUE ? "jump" : c2.op === i$2.BREAK ? "break" : "continue";
2737
3151
  s2.error = `Invalid ${i2} target: ${c2.arg}`;
2738
3152
  break;
2739
3153
  }
2740
3154
  const u2 = p2.execute(s2, c2);
2741
3155
  if (u2) {
2742
3156
  const i2 = s2.pc + 1;
2743
- if (i2 < t2.length && t2[i2].op === n.CC) {
3157
+ if (i2 < t2.length && t2[i2].op === i$2.CC) {
2744
3158
  s2.ccPrompt = `ERROR: ${u2.message}. How should I proceed?`, s2.status = "waiting_cc", s2.pc = i2;
2745
3159
  break;
2746
3160
  }
@@ -2750,7 +3164,7 @@ class w {
2750
3164
  p2.controlsPC || s2.pc++;
2751
3165
  continue;
2752
3166
  }
2753
- s2.status = "error", s2.error = `Unknown opcode: ${n[c2.op]}`;
3167
+ s2.status = "error", s2.error = `Unknown opcode: ${i$2[c2.op]}`;
2754
3168
  break;
2755
3169
  }
2756
3170
  return s2;
@@ -2768,9 +3182,9 @@ class w {
2768
3182
  return this.execute(o2, c2, s2 || t2.fileSystem);
2769
3183
  }
2770
3184
  }
2771
- class D {
3185
+ class V {
2772
3186
  constructor() {
2773
- b(this, "sandboxPaths", []);
3187
+ _(this, "sandboxPaths", []);
2774
3188
  const t2 = process.env.CVM_SANDBOX_PATHS, r2 = process.env.CVM_SANDBOX_ROOT;
2775
3189
  t2 ? this.sandboxPaths = t2.split(",").map((o2) => r__namespace.resolve(o2.trim())) : r2 && (this.sandboxPaths = [r__namespace.resolve(r2)]);
2776
3190
  }
@@ -2802,7 +3216,7 @@ class D {
2802
3216
  }
2803
3217
  listFilesRecursive(t2, r2, o2, s2, c2 = 0) {
2804
3218
  try {
2805
- const p2 = x__namespace.readdirSync(r2, { withFileTypes: true });
3219
+ const p2 = b__namespace.readdirSync(r2, { withFileTypes: true });
2806
3220
  for (const a2 of p2) {
2807
3221
  const u2 = r__namespace.join(r2, a2.name), i2 = r__namespace.relative(t2, u2);
2808
3222
  a2.isSymbolicLink() || s2.filter && !this.matchesPattern(i2, s2.filter) || (o2.push(u2), a2.isDirectory() && s2.recursive && this.listFilesRecursive(t2, u2, o2, s2, c2 + 1));
@@ -2814,8 +3228,8 @@ class D {
2814
3228
  if (!this.isPathAllowed(t2))
2815
3229
  return null;
2816
3230
  try {
2817
- const r2 = r__namespace.resolve(t2), o2 = x__namespace.lstatSync(r2);
2818
- return o2.isSymbolicLink() || !o2.isFile() ? null : x__namespace.readFileSync(r2, "utf-8");
3231
+ const r2 = r__namespace.resolve(t2), o2 = b__namespace.lstatSync(r2);
3232
+ return o2.isSymbolicLink() || !o2.isFile() ? null : b__namespace.readFileSync(r2, "utf-8");
2819
3233
  } catch {
2820
3234
  return null;
2821
3235
  }
@@ -2828,25 +3242,25 @@ class D {
2828
3242
  if (!this.isPathAllowed(s2))
2829
3243
  return false;
2830
3244
  try {
2831
- if (x__namespace.lstatSync(o2).isSymbolicLink())
3245
+ if (b__namespace.lstatSync(o2).isSymbolicLink())
2832
3246
  return false;
2833
3247
  } catch (c2) {
2834
3248
  if (c2.code !== "ENOENT")
2835
3249
  return false;
2836
3250
  }
2837
- return x__namespace.mkdirSync(s2, { recursive: true }), x__namespace.writeFileSync(o2, r2, "utf-8"), true;
3251
+ return b__namespace.mkdirSync(s2, { recursive: true }), b__namespace.writeFileSync(o2, r2, "utf-8"), true;
2838
3252
  } catch {
2839
3253
  return false;
2840
3254
  }
2841
3255
  }
2842
3256
  }
2843
- new D();
2844
- class he {
3257
+ new V();
3258
+ class Se {
2845
3259
  constructor(t2, r2) {
2846
- b(this, "vms", /* @__PURE__ */ new Map());
2847
- b(this, "storage");
2848
- b(this, "fileSystem");
2849
- t2 ? this.storage = t2 : this.storage = E.create(), this.fileSystem = r2 || new D();
3260
+ _(this, "vms", /* @__PURE__ */ new Map());
3261
+ _(this, "storage");
3262
+ _(this, "fileSystem");
3263
+ t2 ? this.storage = t2 : this.storage = E.create(), this.fileSystem = r2 || new V();
2850
3264
  }
2851
3265
  /**
2852
3266
  * Initialize the VMManager (connect to database)
@@ -2864,7 +3278,7 @@ class he {
2864
3278
  * Load and compile a program from source code
2865
3279
  */
2866
3280
  async loadProgram(t2, r2) {
2867
- const o2 = X(r2);
3281
+ const o2 = te$1(r2);
2868
3282
  if (!o2.success)
2869
3283
  throw new Error(`Compilation failed: ${o2.errors.join(", ")}`);
2870
3284
  const s2 = {
@@ -2893,7 +3307,7 @@ class he {
2893
3307
  created: /* @__PURE__ */ new Date()
2894
3308
  };
2895
3309
  await this.storage.saveExecution(s2);
2896
- const c2 = new w();
3310
+ const c2 = new C();
2897
3311
  this.vms.set(r2, c2);
2898
3312
  }
2899
3313
  /**
@@ -2909,7 +3323,7 @@ class he {
2909
3323
  if (!o2)
2910
3324
  throw new Error(`Program not found: ${r2.programId}`);
2911
3325
  let s2 = this.vms.get(t2);
2912
- s2 || (s2 = new w(), this.vms.set(t2, s2));
3326
+ s2 || (s2 = new C(), this.vms.set(t2, s2));
2913
3327
  const c2 = r2.state === "READY" ? {
2914
3328
  pc: 0,
2915
3329
  stack: [],
@@ -2963,7 +3377,7 @@ class he {
2963
3377
  if (!s2)
2964
3378
  throw new Error(`Program not found: ${o2.programId}`);
2965
3379
  let c2 = this.vms.get(t2);
2966
- c2 || (c2 = new w(), this.vms.set(t2, c2));
3380
+ c2 || (c2 = new C(), this.vms.set(t2, c2));
2967
3381
  const p2 = {
2968
3382
  ...this.deserializeVMState(o2),
2969
3383
  status: "waiting_cc",
@@ -3052,7 +3466,7 @@ class he {
3052
3466
  * Serialize heap to storage format
3053
3467
  */
3054
3468
  serializeHeap(t2) {
3055
- const r2 = (s2, c2) => u$1(c2) || b$1(c2) ? { $ref: c2.id } : c2, o2 = {};
3469
+ const r2 = (s2, c2) => u$1(c2) || b(c2) ? { $ref: c2.id } : c2, o2 = {};
3056
3470
  return t2.objects.forEach((s2, c2) => {
3057
3471
  o2[c2] = {
3058
3472
  type: s2.type,
@@ -3068,7 +3482,7 @@ class he {
3068
3482
  * Deserialize heap from storage format
3069
3483
  */
3070
3484
  deserializeHeap(t2) {
3071
- const r2 = j();
3485
+ const r2 = w();
3072
3486
  r2.nextId = t2.nextId;
3073
3487
  for (const o2 in t2.objects) {
3074
3488
  const s2 = parseInt(o2, 10), c2 = t2.objects[s2];
@@ -3108,7 +3522,7 @@ class he {
3108
3522
  pc: t2.pc || 0,
3109
3523
  stack: t2.stack || [],
3110
3524
  variables: new Map(Object.entries(t2.variables || {})),
3111
- heap: t2.heap ? this.deserializeHeap(t2.heap) : j(),
3525
+ heap: t2.heap ? this.deserializeHeap(t2.heap) : w(),
3112
3526
  iterators: t2.iterators || [],
3113
3527
  status: t2.status || "running",
3114
3528
  error: t2.error || null,
@@ -3142,7 +3556,7 @@ class $ {
3142
3556
  i(this, "transport", null);
3143
3557
  i(this, "vmManager");
3144
3558
  i(this, "version");
3145
- this.version = e2, this.vmManager = new he(), this.server = new mcp_js.McpServer({
3559
+ this.version = e2, this.vmManager = new Se(), this.server = new mcp_js.McpServer({
3146
3560
  name: "cvm-server",
3147
3561
  version: this.version
3148
3562
  }), this.setupTools();
@@ -3180,19 +3594,19 @@ class $ {
3180
3594
  },
3181
3595
  async ({ programId: e2, filePath: r$1 }) => {
3182
3596
  try {
3183
- const t2 = r.resolve(r$1), n2 = await promises.readFile(t2, "utf-8");
3184
- return await this.vmManager.loadProgram(e2, n2), {
3597
+ const t2 = r.resolve(r$1), n = await promises.readFile(t2, "utf-8");
3598
+ return await this.vmManager.loadProgram(e2, n), {
3185
3599
  content: [{ type: "text", text: `Program loaded successfully from ${r$1}: ${e2}` }]
3186
3600
  };
3187
3601
  } catch (t2) {
3188
3602
  if (t2 instanceof Error) {
3189
- const n2 = t2;
3190
- if (n2.code === "ENOENT")
3603
+ const n = t2;
3604
+ if (n.code === "ENOENT")
3191
3605
  return {
3192
3606
  content: [{ type: "text", text: `Error: File not found: ${r$1}` }],
3193
3607
  isError: true
3194
3608
  };
3195
- if (n2.code === "EACCES")
3609
+ if (n.code === "EACCES")
3196
3610
  return {
3197
3611
  content: [{ type: "text", text: `Error: Permission denied: ${r$1}` }],
3198
3612
  isError: true
@@ -3216,9 +3630,9 @@ class $ {
3216
3630
  return await this.vmManager.startExecution(e2, r2), t2 && await this.vmManager.setCurrentExecutionId(r2), {
3217
3631
  content: [{ type: "text", text: `Execution started: ${r2}${t2 ? " (set as current)" : ""}` }]
3218
3632
  };
3219
- } catch (n2) {
3633
+ } catch (n) {
3220
3634
  return {
3221
- content: [{ type: "text", text: `Error: ${n2 instanceof Error ? n2.message : "Unknown error"}` }],
3635
+ content: [{ type: "text", text: `Error: ${n instanceof Error ? n.message : "Unknown error"}` }],
3222
3636
  isError: true
3223
3637
  };
3224
3638
  }
@@ -3232,12 +3646,12 @@ class $ {
3232
3646
  try {
3233
3647
  let r2 = e2;
3234
3648
  if (!r2) {
3235
- const n2 = await this.vmManager.getCurrentExecutionId();
3236
- if (!n2)
3649
+ const n = await this.vmManager.getCurrentExecutionId();
3650
+ if (!n)
3237
3651
  return {
3238
3652
  content: [{ type: "text", text: "No current execution set. Use list_executions to see available executions." }]
3239
3653
  };
3240
- r2 = n2;
3654
+ r2 = n;
3241
3655
  }
3242
3656
  const t2 = await this.vmManager.getNext(r2);
3243
3657
  return t2.type === "completed" ? {
@@ -3268,13 +3682,13 @@ class $ {
3268
3682
  try {
3269
3683
  let t2 = e2;
3270
3684
  if (!t2) {
3271
- const n2 = await this.vmManager.getCurrentExecutionId();
3272
- if (!n2)
3685
+ const n = await this.vmManager.getCurrentExecutionId();
3686
+ if (!n)
3273
3687
  return {
3274
3688
  content: [{ type: "text", text: "Error: No current execution set" }],
3275
3689
  isError: true
3276
3690
  };
3277
- t2 = n2;
3691
+ t2 = n;
3278
3692
  }
3279
3693
  return await this.vmManager.reportCCResult(t2, r2), {
3280
3694
  content: [{ type: "text", text: "Execution resumed" }]
@@ -3295,13 +3709,13 @@ class $ {
3295
3709
  try {
3296
3710
  let r2 = e2;
3297
3711
  if (!r2) {
3298
- const n2 = await this.vmManager.getCurrentExecutionId();
3299
- if (!n2)
3712
+ const n = await this.vmManager.getCurrentExecutionId();
3713
+ if (!n)
3300
3714
  return {
3301
3715
  content: [{ type: "text", text: "Error: No current execution set" }],
3302
3716
  isError: true
3303
3717
  };
3304
- r2 = n2;
3718
+ r2 = n;
3305
3719
  }
3306
3720
  const t2 = await this.vmManager.getExecutionStatus(r2);
3307
3721
  return {
@@ -3319,14 +3733,14 @@ class $ {
3319
3733
  {},
3320
3734
  async () => {
3321
3735
  try {
3322
- const e2 = await this.vmManager.listExecutions(), r2 = await this.vmManager.getCurrentExecutionId(), t2 = e2.map((n2) => ({
3323
- executionId: n2.id,
3324
- programId: n2.programId,
3325
- state: n2.state,
3326
- created: n2.created,
3327
- isCurrent: n2.id === r2,
3736
+ const e2 = await this.vmManager.listExecutions(), r2 = await this.vmManager.getCurrentExecutionId(), t2 = e2.map((n) => ({
3737
+ executionId: n.id,
3738
+ programId: n.programId,
3739
+ state: n.state,
3740
+ created: n.created,
3741
+ isCurrent: n.id === r2,
3328
3742
  summary: {
3329
- currentPrompt: n2.state === "AWAITING_COGNITIVE_RESULT" ? n2.ccPrompt : void 0,
3743
+ currentPrompt: n.state === "AWAITING_COGNITIVE_RESULT" ? n.ccPrompt : void 0,
3330
3744
  tasksCompleted: 0
3331
3745
  // TODO: Track this in future
3332
3746
  }
@@ -3358,12 +3772,12 @@ class $ {
3358
3772
  };
3359
3773
  r2 = a2;
3360
3774
  }
3361
- const t2 = await this.vmManager.getExecutionWithAttempts(r2), n2 = await this.vmManager.getCurrentExecutionId(), c2 = {
3775
+ const t2 = await this.vmManager.getExecutionWithAttempts(r2), n = await this.vmManager.getCurrentExecutionId(), c2 = {
3362
3776
  executionId: t2.id,
3363
3777
  programId: t2.programId,
3364
3778
  state: t2.state,
3365
3779
  created: t2.created,
3366
- isCurrent: t2.id === n2,
3780
+ isCurrent: t2.id === n,
3367
3781
  currentTask: t2.state === "AWAITING_COGNITIVE_RESULT" ? {
3368
3782
  prompt: t2.ccPrompt,
3369
3783
  attempts: t2.attempts || 1,
@@ -3620,7 +4034,7 @@ async function main() {
3620
4034
  ];
3621
4035
  for (const packageJsonPath of possiblePaths) {
3622
4036
  try {
3623
- const packageJson = JSON.parse(x$2.readFileSync(packageJsonPath, "utf-8"));
4037
+ const packageJson = JSON.parse(b$2.readFileSync(packageJsonPath, "utf-8"));
3624
4038
  if (packageJson.name === "cvm-server" && packageJson.version) {
3625
4039
  version = packageJson.version;
3626
4040
  break;