@devscholar/vbs-engine-js 0.0.1 → 0.0.3

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.
@@ -1,5 +1,5 @@
1
- var u = /* @__PURE__ */ ((r) => (r.EOF = "EOF", r.Newline = "Newline", r.WhiteSpace = "WhiteSpace", r.Identifier = "Identifier", r.Unknown = "Unknown", r.StringLiteral = "StringLiteral", r.NumberLiteral = "NumberLiteral", r.DateLiteral = "DateLiteral", r.BooleanLiteral = "BooleanLiteral", r.NothingLiteral = "NothingLiteral", r.NullLiteral = "NullLiteral", r.EmptyLiteral = "EmptyLiteral", r.Plus = "Plus", r.Minus = "Minus", r.Asterisk = "Asterisk", r.Slash = "Slash", r.Backslash = "Backslash", r.Caret = "Caret", r.Mod = "Mod", r.Ampersand = "Ampersand", r.Eq = "Eq", r.Lt = "Lt", r.Gt = "Gt", r.Le = "Le", r.Ge = "Ge", r.Ne = "Ne", r.Is = "Is", r.And = "And", r.Or = "Or", r.Not = "Not", r.Xor = "Xor", r.Eqv = "Eqv", r.Imp = "Imp", r.LParen = "LParen", r.RParen = "RParen", r.LBrace = "LBrace", r.RBrace = "RBrace", r.LBracket = "LBracket", r.RBracket = "RBracket", r.Comma = "Comma", r.Colon = "Colon", r.Dot = "Dot", r.Bang = "Bang", r.Dim = "Dim", r.ReDim = "ReDim", r.Preserve = "Preserve", r.Public = "Public", r.Private = "Private", r.Sub = "Sub", r.Function = "Function", r.End = "End", r.Exit = "Exit", r.Call = "Call", r.Set = "Set", r.Let = "Let", r.Get = "Get", r.If = "If", r.Then = "Then", r.Else = "Else", r.ElseIf = "ElseIf", r.For = "For", r.To = "To", r.Step = "Step", r.Next = "Next", r.Each = "Each", r.In = "In", r.Do = "Do", r.Loop = "Loop", r.While = "While", r.Until = "Until", r.Select = "Select", r.Case = "Case", r.On = "On", r.Error = "Error", r.Resume = "Resume", r.Goto = "Goto", r.With = "With", r.Class = "Class", r.Property = "Property", r.New = "New", r.Const = "Const", r.Option = "Option", r.Explicit = "Explicit", r.ByRef = "ByRef", r.ByVal = "ByVal", r.Optional = "Optional", r.ParamArray = "ParamArray", r.Rem = "Rem", r.As = "As", r.Integer = "Integer", r.Long = "Long", r.Single = "Single", r.Double = "Double", r.Currency = "Currency", r.String = "String", r.Boolean = "Boolean", r.Date = "Date", r.Object = "Object", r.Variant = "Variant", r.Byte = "Byte", r))(u || {});
2
- const ue = {
1
+ var u = /* @__PURE__ */ ((r) => (r.EOF = "EOF", r.Newline = "Newline", r.WhiteSpace = "WhiteSpace", r.Identifier = "Identifier", r.Unknown = "Unknown", r.StringLiteral = "StringLiteral", r.NumberLiteral = "NumberLiteral", r.DateLiteral = "DateLiteral", r.BooleanLiteral = "BooleanLiteral", r.NothingLiteral = "NothingLiteral", r.NullLiteral = "NullLiteral", r.EmptyLiteral = "EmptyLiteral", r.Plus = "Plus", r.Minus = "Minus", r.Asterisk = "Asterisk", r.Slash = "Slash", r.Backslash = "Backslash", r.Caret = "Caret", r.Mod = "Mod", r.Ampersand = "Ampersand", r.Eq = "Eq", r.Lt = "Lt", r.Gt = "Gt", r.Le = "Le", r.Ge = "Ge", r.Ne = "Ne", r.Is = "Is", r.And = "And", r.Or = "Or", r.Not = "Not", r.Xor = "Xor", r.Eqv = "Eqv", r.Imp = "Imp", r.LParen = "LParen", r.RParen = "RParen", r.LBrace = "LBrace", r.RBrace = "RBrace", r.LBracket = "LBracket", r.RBracket = "RBracket", r.Comma = "Comma", r.Colon = "Colon", r.Dot = "Dot", r.Bang = "Bang", r.Dim = "Dim", r.ReDim = "ReDim", r.Preserve = "Preserve", r.Public = "Public", r.Private = "Private", r.Sub = "Sub", r.Function = "Function", r.End = "End", r.Exit = "Exit", r.Call = "Call", r.Set = "Set", r.Let = "Let", r.Get = "Get", r.If = "If", r.Then = "Then", r.Else = "Else", r.ElseIf = "ElseIf", r.For = "For", r.To = "To", r.Step = "Step", r.Next = "Next", r.Each = "Each", r.In = "In", r.Do = "Do", r.Loop = "Loop", r.While = "While", r.Until = "Until", r.Select = "Select", r.Case = "Case", r.On = "On", r.Error = "Error", r.Resume = "Resume", r.Goto = "Goto", r.With = "With", r.Class = "Class", r.Property = "Property", r.New = "New", r.Const = "Const", r.Option = "Option", r.Explicit = "Explicit", r.ByRef = "ByRef", r.ByVal = "ByVal", r.Optional = "Optional", r.ParamArray = "ParamArray", r.Rem = "Rem", r.Erase = "Erase", r.As = "As", r.Integer = "Integer", r.Long = "Long", r.Single = "Single", r.Double = "Double", r.Currency = "Currency", r.String = "String", r.Boolean = "Boolean", r.Date = "Date", r.Object = "Object", r.Variant = "Variant", r.Byte = "Byte", r))(u || {});
2
+ const he = {
3
3
  dim: u.Dim,
4
4
  redim: u.ReDim,
5
5
  preserve: u.Preserve,
@@ -45,6 +45,7 @@ const ue = {
45
45
  optional: u.Optional,
46
46
  paramarray: u.ParamArray,
47
47
  rem: u.Rem,
48
+ erase: u.Erase,
48
49
  as: u.As,
49
50
  and: u.And,
50
51
  or: u.Or,
@@ -189,7 +190,7 @@ class W {
189
190
  let t = "";
190
191
  for (; /[a-zA-Z0-9_]/.test(this.current); )
191
192
  t += this.advance();
192
- const s = t.toLowerCase(), n = ue[s];
193
+ const s = t.toLowerCase(), n = he[s];
193
194
  return n ? n === u.BooleanLiteral ? this.createToken(u.BooleanLiteral, s, e, t) : n === u.NothingLiteral ? this.createToken(u.NothingLiteral, "nothing", e, t) : n === u.NullLiteral ? this.createToken(u.NullLiteral, "null", e, t) : n === u.EmptyLiteral ? this.createToken(u.EmptyLiteral, "empty", e, t) : this.createToken(n, s, e, t) : this.createToken(u.Identifier, t, e, t);
194
195
  }
195
196
  readRemComment() {
@@ -303,14 +304,14 @@ class W {
303
304
  return e;
304
305
  }
305
306
  }
306
- class K extends Error {
307
+ class J extends Error {
307
308
  token;
308
309
  expected;
309
310
  constructor(e, t, s) {
310
311
  super(e), this.name = "ParseError", this.token = t, s !== void 0 && (this.expected = s);
311
312
  }
312
313
  }
313
- class pe {
314
+ class fe {
314
315
  tokens;
315
316
  pos = 0;
316
317
  constructor(e) {
@@ -360,7 +361,7 @@ class pe {
360
361
  expect(e, t) {
361
362
  if (this.check(e))
362
363
  return this.advance();
363
- throw new K(
364
+ throw new J(
364
365
  t ?? `Expected ${e}, got ${this.current.type}`,
365
366
  this.current,
366
367
  e
@@ -369,7 +370,7 @@ class pe {
369
370
  expectAny(e, t) {
370
371
  if (this.checkAny(...e))
371
372
  return this.advance();
372
- throw new K(
373
+ throw new J(
373
374
  t ?? `Expected one of ${e.join(", ")}, got ${this.current.type}`,
374
375
  this.current,
375
376
  e
@@ -387,13 +388,13 @@ class pe {
387
388
  ;
388
389
  }
389
390
  }
390
- function he(r) {
391
+ function ye(r) {
391
392
  return {
392
393
  line: r.loc.start.line,
393
394
  column: r.loc.start.column
394
395
  };
395
396
  }
396
- function fe(r) {
397
+ function me(r) {
397
398
  return {
398
399
  line: r.loc.end.line,
399
400
  column: r.loc.end.column
@@ -401,11 +402,11 @@ function fe(r) {
401
402
  }
402
403
  function f(r, e) {
403
404
  return {
404
- start: he(r),
405
- end: fe(e)
405
+ start: ye(r),
406
+ end: me(e)
406
407
  };
407
408
  }
408
- class ye {
409
+ class ge {
409
410
  state;
410
411
  constructor(e) {
411
412
  this.state = e;
@@ -1041,7 +1042,7 @@ class ye {
1041
1042
  throw new Error(`Expected property name, got ${e.type}`);
1042
1043
  }
1043
1044
  }
1044
- class me {
1045
+ class ve {
1045
1046
  constructor(e, t) {
1046
1047
  this.state = e, this.exprParser = t;
1047
1048
  }
@@ -1081,6 +1082,14 @@ class me {
1081
1082
  loc: f(e, this.state.previous)
1082
1083
  };
1083
1084
  }
1085
+ parseEraseStatement() {
1086
+ const e = this.state.advance();
1087
+ return {
1088
+ type: "VbEraseStatement",
1089
+ arrayName: this.exprParser.parseIdentifier(),
1090
+ loc: f(e, this.state.previous)
1091
+ };
1092
+ }
1084
1093
  parseConstStatement() {
1085
1094
  const e = this.state.advance();
1086
1095
  return {
@@ -1184,7 +1193,7 @@ class me {
1184
1193
  };
1185
1194
  }
1186
1195
  }
1187
- function ge(r) {
1196
+ function be(r) {
1188
1197
  return [
1189
1198
  "VbSubStatement",
1190
1199
  "VbFunctionStatement",
@@ -1195,7 +1204,7 @@ function ge(r) {
1195
1204
  "VbConstStatement"
1196
1205
  ].includes(r.type);
1197
1206
  }
1198
- class ve {
1207
+ class de {
1199
1208
  constructor(e, t, s) {
1200
1209
  this.state = e, this.exprParser = t, this.parseStatement = s;
1201
1210
  }
@@ -1336,12 +1345,12 @@ class ve {
1336
1345
  const e = [];
1337
1346
  for (; !this.state.isEOF && (this.state.skipStatementSeparators(), !(this.state.check("End") || this.state.isEOF)); ) {
1338
1347
  const t = this.parseStatement();
1339
- ge(t) && e.push(t);
1348
+ be(t) && e.push(t);
1340
1349
  }
1341
1350
  return e;
1342
1351
  }
1343
1352
  }
1344
- class be {
1353
+ class Se {
1345
1354
  constructor(e, t, s) {
1346
1355
  this.state = e, this.exprParser = t, this.parseStatement = s;
1347
1356
  }
@@ -1618,7 +1627,7 @@ class be {
1618
1627
  return e;
1619
1628
  }
1620
1629
  }
1621
- class de {
1630
+ class we {
1622
1631
  constructor(e, t, s) {
1623
1632
  this.state = e, this.exprParser = t, this.parseStatement = s;
1624
1633
  }
@@ -1762,7 +1771,7 @@ class de {
1762
1771
  return e;
1763
1772
  }
1764
1773
  }
1765
- class Se {
1774
+ class xe {
1766
1775
  state;
1767
1776
  exprParser;
1768
1777
  declarationParser;
@@ -1770,7 +1779,7 @@ class Se {
1770
1779
  controlFlowParser;
1771
1780
  statementsParser;
1772
1781
  constructor(e) {
1773
- this.state = e, this.exprParser = new ye(e), this.declarationParser = new me(e, this.exprParser), this.procedureParser = new ve(e, this.exprParser, () => this.parseStatement()), this.controlFlowParser = new be(e, this.exprParser, () => this.parseStatement()), this.statementsParser = new de(e, this.exprParser, () => this.parseStatement());
1782
+ this.state = e, this.exprParser = new ge(e), this.declarationParser = new ve(e, this.exprParser), this.procedureParser = new de(e, this.exprParser, () => this.parseStatement()), this.controlFlowParser = new Se(e, this.exprParser, () => this.parseStatement()), this.statementsParser = new we(e, this.exprParser, () => this.parseStatement());
1774
1783
  }
1775
1784
  parseStatement() {
1776
1785
  switch (this.state.skipNewlines(), this.state.current.type) {
@@ -1778,6 +1787,8 @@ class Se {
1778
1787
  return this.declarationParser.parseDimStatement();
1779
1788
  case "ReDim":
1780
1789
  return this.declarationParser.parseReDimStatement();
1790
+ case "Erase":
1791
+ return this.declarationParser.parseEraseStatement();
1781
1792
  case "Const":
1782
1793
  return this.declarationParser.parseConstStatement();
1783
1794
  case "Public":
@@ -1870,7 +1881,7 @@ class G {
1870
1881
  state;
1871
1882
  stmtParser;
1872
1883
  constructor(e) {
1873
- this.state = new pe(e), this.stmtParser = new Se(this.state);
1884
+ this.state = new fe(e), this.stmtParser = new xe(this.state);
1874
1885
  }
1875
1886
  parse() {
1876
1887
  const e = [];
@@ -1890,13 +1901,105 @@ class G {
1890
1901
  };
1891
1902
  }
1892
1903
  }
1893
- function A(r, e) {
1904
+ function R(r, e) {
1894
1905
  const s = new W(r).tokenize();
1895
1906
  return new G(s).parse();
1896
1907
  }
1897
- const m = { type: "Empty", value: void 0 }, I = { type: "Null", value: null }, we = { type: "Object", value: null };
1908
+ class Ee {
1909
+ cache = /* @__PURE__ */ new Map();
1910
+ maxSize;
1911
+ defaultTTL;
1912
+ // Time to live in milliseconds
1913
+ constructor(e = 100, t = 300 * 1e3) {
1914
+ this.maxSize = e, this.defaultTTL = t;
1915
+ }
1916
+ /**
1917
+ * Generate a simple hash for the source code.
1918
+ * Uses a fast djb2-like hash algorithm.
1919
+ */
1920
+ hashSource(e) {
1921
+ let t = 5381;
1922
+ for (let s = 0; s < e.length; s++)
1923
+ t = (t << 5) + t + e.charCodeAt(s);
1924
+ return t.toString(36);
1925
+ }
1926
+ /**
1927
+ * Get cached AST for a source code string.
1928
+ * Returns undefined if not found or expired.
1929
+ */
1930
+ get(e) {
1931
+ const t = this.hashSource(e), s = this.cache.get(t);
1932
+ if (!s)
1933
+ return;
1934
+ const n = Date.now();
1935
+ if (n - s.lastAccessed > this.defaultTTL) {
1936
+ this.cache.delete(t);
1937
+ return;
1938
+ }
1939
+ return s.lastAccessed = n, s.accessCount++, s.ast;
1940
+ }
1941
+ /**
1942
+ * Store parsed AST in cache.
1943
+ */
1944
+ set(e, t) {
1945
+ this.cache.size >= this.maxSize && this.evictLRU();
1946
+ const s = this.hashSource(e), n = Date.now();
1947
+ this.cache.set(s, {
1948
+ ast: t,
1949
+ lastAccessed: n,
1950
+ accessCount: 1
1951
+ });
1952
+ }
1953
+ /**
1954
+ * Check if source code is in cache.
1955
+ */
1956
+ has(e) {
1957
+ const t = this.hashSource(e), s = this.cache.get(t);
1958
+ return s ? Date.now() - s.lastAccessed > this.defaultTTL ? (this.cache.delete(t), !1) : !0 : !1;
1959
+ }
1960
+ /**
1961
+ * Evict least recently used entries.
1962
+ */
1963
+ evictLRU() {
1964
+ let e = null, t = 1 / 0;
1965
+ for (const [s, n] of this.cache)
1966
+ n.lastAccessed < t && (t = n.lastAccessed, e = s);
1967
+ e && this.cache.delete(e);
1968
+ }
1969
+ /**
1970
+ * Clear all cached entries.
1971
+ */
1972
+ clear() {
1973
+ this.cache.clear();
1974
+ }
1975
+ /**
1976
+ * Get cache statistics.
1977
+ */
1978
+ getStats() {
1979
+ let e = 0;
1980
+ for (const t of this.cache.values())
1981
+ e += t.accessCount;
1982
+ return {
1983
+ size: this.cache.size,
1984
+ maxSize: this.maxSize,
1985
+ totalAccessCount: e,
1986
+ averageAccessCount: this.cache.size > 0 ? e / this.cache.size : 0
1987
+ };
1988
+ }
1989
+ /**
1990
+ * Clean up expired entries.
1991
+ */
1992
+ cleanup() {
1993
+ const e = Date.now();
1994
+ let t = 0;
1995
+ for (const [s, n] of this.cache)
1996
+ e - n.lastAccessed > this.defaultTTL && (this.cache.delete(s), t++);
1997
+ return t;
1998
+ }
1999
+ }
2000
+ const O = new Ee(), m = { type: "Empty", value: void 0 }, L = { type: "Null", value: null }, Ce = { type: "Object", value: null };
1898
2001
  function k(r) {
1899
- return r === void 0 ? m : r === null ? I : r === /* @__PURE__ */ Symbol.for("Nothing") ? we : typeof r == "boolean" ? { type: "Boolean", value: r } : typeof r == "number" ? Number.isInteger(r) ? r >= -32768 && r <= 32767 ? { type: "Integer", value: r } : { type: "Long", value: r } : { type: "Double", value: r } : typeof r == "string" ? { type: "String", value: r } : r instanceof Date ? { type: "Date", value: r } : Array.isArray(r) ? { type: "Array", value: r } : typeof r == "object" ? { type: "Object", value: r } : { type: "Variant", value: r };
2002
+ return r === void 0 ? m : r === null ? L : r === /* @__PURE__ */ Symbol.for("Nothing") ? Ce : typeof r == "boolean" ? { type: "Boolean", value: r } : typeof r == "number" ? Number.isInteger(r) ? r >= -32768 && r <= 32767 ? { type: "Integer", value: r } : { type: "Long", value: r } : { type: "Double", value: r } : typeof r == "string" ? { type: "String", value: r } : r instanceof Date ? { type: "Date", value: r } : Array.isArray(r) ? { type: "Array", value: r } : typeof r == "object" ? { type: "Object", value: r } : { type: "Variant", value: r };
1900
2003
  }
1901
2004
  function d(r) {
1902
2005
  if (r.type === "Boolean") return r.value;
@@ -1910,7 +2013,7 @@ function d(r) {
1910
2013
  }
1911
2014
  return r.type === "Integer" || r.type === "Long" || r.type === "Double" || r.type === "Single" || r.type === "Byte" ? r.value !== 0 : !0;
1912
2015
  }
1913
- function c(r) {
2016
+ function l(r) {
1914
2017
  if (r.type === "Empty") return 0;
1915
2018
  if (r.type === "Null") throw new Error("Type mismatch: Null cannot be converted to Number");
1916
2019
  if (r.type === "Boolean") return r.value ? -1 : 0;
@@ -1930,7 +2033,7 @@ function c(r) {
1930
2033
  function y(r) {
1931
2034
  return r.type === "Empty" ? "" : r.type === "Null" ? "Null" : r.type === "Boolean" ? r.value ? "True" : "False" : r.type === "String" ? r.value : r.type === "Integer" || r.type === "Long" || r.type === "Byte" ? String(Math.floor(r.value)) : r.type === "Double" || r.type === "Single" || r.type === "Currency" ? String(r.value) : r.type === "Date" ? r.value.toLocaleString() : r.type === "Object" ? r.value === null ? "Nothing" : "[object]" : r.type === "Array" ? "[array]" : String(r.value);
1932
2035
  }
1933
- function xe(r) {
2036
+ function ke(r) {
1934
2037
  if (r.type === "Integer" || r.type === "Long" || r.type === "Double" || r.type === "Single" || r.type === "Currency" || r.type === "Byte")
1935
2038
  return !0;
1936
2039
  if (r.type === "String") {
@@ -1939,25 +2042,25 @@ function xe(r) {
1939
2042
  }
1940
2043
  return r.type === "Boolean" || r.type === "Empty";
1941
2044
  }
1942
- function Ee(r) {
2045
+ function Ie(r) {
1943
2046
  return r.type === "Empty";
1944
2047
  }
1945
- function Ce(r) {
2048
+ function Le(r) {
1946
2049
  return r.type === "Null";
1947
2050
  }
1948
- class ke {
2051
+ class Ne {
1949
2052
  constructor(e, t, s = !1, n = !1, a = !1) {
1950
2053
  this.name = e, this.value = t, this.isByRef = s, this.isArray = n, this.isConst = a;
1951
2054
  }
1952
2055
  }
1953
- class J {
2056
+ class X {
1954
2057
  variables = /* @__PURE__ */ new Map();
1955
2058
  parent;
1956
2059
  constructor(e = null) {
1957
2060
  this.parent = e;
1958
2061
  }
1959
2062
  declare(e, t, s = {}) {
1960
- const n = new ke(
2063
+ const n = new Ne(
1961
2064
  e,
1962
2065
  t,
1963
2066
  s.isByRef ?? !1,
@@ -1997,7 +2100,7 @@ class J {
1997
2100
  return this.parent && this.parent.getAllVariables().forEach((s, n) => e.set(n, s)), this.variables.forEach((t, s) => e.set(s, t)), e;
1998
2101
  }
1999
2102
  }
2000
- class Le {
2103
+ class Pe {
2001
2104
  functions = /* @__PURE__ */ new Map();
2002
2105
  register(e, t, s = {}) {
2003
2106
  const n = e.toLowerCase();
@@ -2040,8 +2143,8 @@ class Le {
2040
2143
  let a;
2041
2144
  s.isUserDefined ? a = s.func(n) : a = s.func(...n);
2042
2145
  for (let i = 0; i < t.length && i < s.params.length; i++) {
2043
- const o = s.params[i], l = t[i];
2044
- o && l && o.byRef && l.setValue && n[i] !== l.value && l.setValue(n[i]);
2146
+ const o = s.params[i], c = t[i];
2147
+ o && c && o.byRef && c.setValue && n[i] !== c.value && c.setValue(n[i]);
2045
2148
  }
2046
2149
  return s.isSub ? m : a ?? m;
2047
2150
  }
@@ -2055,12 +2158,12 @@ class Le {
2055
2158
  return e;
2056
2159
  }
2057
2160
  }
2058
- class te {
2161
+ class se {
2059
2162
  constructor(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n) {
2060
2163
  this.name = e, this.properties = t, this.methods = s, this.initializer = n;
2061
2164
  }
2062
2165
  }
2063
- class re {
2166
+ class ne {
2064
2167
  constructor(e, t = null) {
2065
2168
  this.classInfo = e, this.prototype = t, e.initializer && e.initializer(this), e.properties.forEach((s, n) => {
2066
2169
  this.propertyAccessors.set(n.toLowerCase(), s), !s.get && !s.let && !s.set && this.properties.set(n.toLowerCase(), m);
@@ -2113,13 +2216,13 @@ class re {
2113
2216
  this.properties.set(t.toLowerCase(), s);
2114
2217
  }
2115
2218
  }
2116
- class Ie {
2219
+ class De {
2117
2220
  classes = /* @__PURE__ */ new Map();
2118
2221
  register(e) {
2119
2222
  this.classes.set(e.name.toLowerCase(), e);
2120
2223
  }
2121
2224
  registerClass(e, t) {
2122
- const s = new te(e);
2225
+ const s = new se(e);
2123
2226
  s.initializer = (n) => {
2124
2227
  const a = t();
2125
2228
  if (a.type === "Object" && a.value) {
@@ -2138,13 +2241,13 @@ class Ie {
2138
2241
  const s = this.classes.get(e.toLowerCase());
2139
2242
  if (!s)
2140
2243
  throw new Error(`Undefined class: ${e}`);
2141
- const n = new re(s), a = s.methods.get("class_initialize");
2244
+ const n = new ne(s), a = s.methods.get("class_initialize");
2142
2245
  a && a.func.call(n);
2143
2246
  const i = s.properties.get("class_initialize");
2144
2247
  return i && i.get && i.get.call(n), n;
2145
2248
  }
2146
2249
  }
2147
- class se {
2250
+ class ae {
2148
2251
  data;
2149
2252
  dimensions;
2150
2253
  lowerBounds;
@@ -2195,13 +2298,21 @@ class se {
2195
2298
  toArray() {
2196
2299
  return [...this.data];
2197
2300
  }
2301
+ /**
2302
+ * Erase the array - reset all elements to Empty
2303
+ * For fixed-size arrays: clears all elements but keeps dimensions
2304
+ * For dynamic arrays: would normally deallocate, but we just clear
2305
+ */
2306
+ erase() {
2307
+ this.data.fill(m);
2308
+ }
2198
2309
  }
2199
- function R(r) {
2310
+ function F(r) {
2200
2311
  const e = r.map((t) => t + 1);
2201
- return new se(e);
2312
+ return new ae(e);
2202
2313
  }
2203
- function T(r) {
2204
- const e = new se([r.length]);
2314
+ function _(r) {
2315
+ const e = new ae([r.length]);
2205
2316
  return r.forEach((t, s) => e.set([s], t)), e;
2206
2317
  }
2207
2318
  class N extends Error {
@@ -2226,10 +2337,10 @@ const w = {
2226
2337
  function x(r, e, t) {
2227
2338
  return new N(r, e, t);
2228
2339
  }
2229
- function X(r, e) {
2340
+ function Z(r, e) {
2230
2341
  return r === void 0 ? { type: "Empty", value: void 0 } : r === null ? { type: "Null", value: null } : typeof r == "boolean" ? { type: "Boolean", value: r } : typeof r == "number" ? Number.isInteger(r) && r >= -2147483648 && r <= 2147483647 ? { type: "Long", value: r } : { type: "Double", value: r } : typeof r == "string" ? { type: "String", value: r } : r instanceof Date ? { type: "Date", value: r } : Array.isArray(r) ? { type: "Array", value: r } : typeof r == "function" ? { type: "Object", value: { type: "jsfunction", func: r, thisArg: e ?? null } } : typeof r == "object" ? { type: "Object", value: r } : { type: "String", value: String(r) };
2231
2342
  }
2232
- class Ne {
2343
+ class Oe {
2233
2344
  globalScope;
2234
2345
  currentScope;
2235
2346
  functionRegistry;
@@ -2253,10 +2364,10 @@ class Ne {
2253
2364
  callStack = [];
2254
2365
  exitFlag = "none";
2255
2366
  constructor() {
2256
- this.globalScope = new J(), this.currentScope = this.globalScope, this.functionRegistry = new Le(), this.classRegistry = new Ie();
2367
+ this.globalScope = new X(), this.currentScope = this.globalScope, this.functionRegistry = new Pe(), this.classRegistry = new De();
2257
2368
  }
2258
2369
  pushScope() {
2259
- const e = new J(this.currentScope);
2370
+ const e = new X(this.currentScope);
2260
2371
  return this.currentScope = e, e;
2261
2372
  }
2262
2373
  popScope() {
@@ -2308,13 +2419,13 @@ class Ne {
2308
2419
  for (const a of Object.keys(globalThis))
2309
2420
  if (a.toLowerCase() === s) {
2310
2421
  const i = globalThis[a];
2311
- return X(i, globalThis);
2422
+ return Z(i, globalThis);
2312
2423
  }
2313
2424
  const n = ["eval", "parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "unescape"];
2314
2425
  for (const a of n)
2315
2426
  if (a.toLowerCase() === s && a in globalThis) {
2316
2427
  const i = globalThis[a];
2317
- return X(i, globalThis);
2428
+ return Z(i, globalThis);
2318
2429
  }
2319
2430
  if (this.optionExplicit)
2320
2431
  throw new N(500, `Variable is undefined: '${e}'`, "Vbscript");
@@ -2337,13 +2448,100 @@ class Ne {
2337
2448
  return this.currentScope.has(e) ? !0 : e.toLowerCase() in globalThis;
2338
2449
  }
2339
2450
  }
2340
- function Pe(r) {
2451
+ const Q = /* @__PURE__ */ new Map();
2452
+ function Ae(r) {
2453
+ for (const e of r)
2454
+ Q.has(e) || Q.set(e, { type: "String", value: e });
2455
+ }
2456
+ const Be = [
2457
+ "true",
2458
+ "false",
2459
+ "empty",
2460
+ "null",
2461
+ "nothing",
2462
+ "dim",
2463
+ "redim",
2464
+ "const",
2465
+ "public",
2466
+ "private",
2467
+ "sub",
2468
+ "function",
2469
+ "class",
2470
+ "end",
2471
+ "exit",
2472
+ "if",
2473
+ "then",
2474
+ "else",
2475
+ "elseif",
2476
+ "for",
2477
+ "next",
2478
+ "to",
2479
+ "step",
2480
+ "each",
2481
+ "in",
2482
+ "do",
2483
+ "loop",
2484
+ "while",
2485
+ "until",
2486
+ "wend",
2487
+ "select",
2488
+ "case",
2489
+ "default",
2490
+ "and",
2491
+ "or",
2492
+ "not",
2493
+ "xor",
2494
+ "eqv",
2495
+ "imp",
2496
+ "new",
2497
+ "set",
2498
+ "call",
2499
+ "byval",
2500
+ "byref",
2501
+ "option",
2502
+ "explicit",
2503
+ "on",
2504
+ "error",
2505
+ "resume",
2506
+ "with",
2507
+ "property",
2508
+ "get",
2509
+ "let",
2510
+ "msgbox",
2511
+ "inputbox",
2512
+ "i",
2513
+ "j",
2514
+ "k",
2515
+ "n",
2516
+ "x",
2517
+ "y",
2518
+ "z",
2519
+ "count",
2520
+ "index",
2521
+ "item",
2522
+ "key",
2523
+ "value",
2524
+ "name",
2525
+ "text",
2526
+ "data",
2527
+ "result",
2528
+ "obj",
2529
+ "arr",
2530
+ "str",
2531
+ "num",
2532
+ "val",
2533
+ "document",
2534
+ "window",
2535
+ "console"
2536
+ ];
2537
+ Ae(Be);
2538
+ function Ve(r) {
2341
2539
  return r.type === "method" && "object" in r && "method" in r;
2342
2540
  }
2343
- function De(r) {
2541
+ function Me(r) {
2344
2542
  return r.type === "jsfunction" && "func" in r;
2345
2543
  }
2346
- class ne {
2544
+ class ie {
2347
2545
  constructor(e) {
2348
2546
  this.context = e;
2349
2547
  }
@@ -2426,7 +2624,7 @@ class ne {
2426
2624
  throw x(w.ObjectRequired, "Object required", "Vbscript");
2427
2625
  }
2428
2626
  getArrayElement(e, t) {
2429
- const s = e.value, n = c(this.evaluate(t));
2627
+ const s = e.value, n = l(this.evaluate(t));
2430
2628
  return s.get([Math.floor(n)]);
2431
2629
  }
2432
2630
  getObjectProperty(e, t) {
@@ -2452,8 +2650,8 @@ class ne {
2452
2650
  return {
2453
2651
  value: S ? S.value : this.context.getVariable(v),
2454
2652
  variableName: v,
2455
- setValue: (L) => {
2456
- this.context.currentScope.has(v) ? this.context.currentScope.set(v, L) : this.context.setVariable(v, L);
2653
+ setValue: (I) => {
2654
+ this.context.currentScope.has(v) ? this.context.currentScope.set(v, I) : this.context.setVariable(v, I);
2457
2655
  }
2458
2656
  };
2459
2657
  }
@@ -2467,14 +2665,14 @@ class ne {
2467
2665
  const a = this.context.currentScope.get(n);
2468
2666
  if (a) {
2469
2667
  if (a.value.type === "Array") {
2470
- const o = t.map((p) => Math.floor(c(this.evaluate(p))));
2668
+ const o = t.map((p) => Math.floor(l(this.evaluate(p))));
2471
2669
  return a.value.value.get(o);
2472
2670
  }
2473
2671
  if (a.value.type === "Object" && a.value.value !== null) {
2474
2672
  const o = a.value.value;
2475
2673
  if (o.hasMethod?.("default") && o.getMethod) {
2476
- const l = o.getMethod("default"), p = t.map((h) => this.evaluate(h));
2477
- return l.func(...p);
2674
+ const c = o.getMethod("default"), p = t.map((h) => this.evaluate(h));
2675
+ return c.func(...p);
2478
2676
  }
2479
2677
  }
2480
2678
  }
@@ -2498,11 +2696,11 @@ class ne {
2498
2696
  const s = e.value;
2499
2697
  if (s === null)
2500
2698
  throw x(w.ObjectRequired, "Object required", "Vbscript");
2501
- if (Pe(s)) {
2699
+ if (Ve(s)) {
2502
2700
  const n = t.map((a) => this.evaluate(a));
2503
2701
  return s.object.getMethod(s.method).func.call(s.object, ...n);
2504
2702
  }
2505
- if (De(s)) {
2703
+ if (Me(s)) {
2506
2704
  const n = t.map((i) => {
2507
2705
  const o = this.evaluate(i);
2508
2706
  return this.vbToJs(o);
@@ -2581,79 +2779,79 @@ class ne {
2581
2779
  }
2582
2780
  add(e, t) {
2583
2781
  if (e.type === "Null" || t.type === "Null")
2584
- return I;
2782
+ return L;
2585
2783
  if (e.type === "String" || t.type === "String")
2586
2784
  return { type: "String", value: y(e) + y(t) };
2587
- const s = c(e), n = c(t);
2785
+ const s = l(e), n = l(t);
2588
2786
  return k(s + n);
2589
2787
  }
2590
2788
  subtract(e, t) {
2591
2789
  if (e.type === "Null" || t.type === "Null")
2592
- return I;
2593
- const s = c(e), n = c(t);
2790
+ return L;
2791
+ const s = l(e), n = l(t);
2594
2792
  return k(s - n);
2595
2793
  }
2596
2794
  multiply(e, t) {
2597
2795
  if (e.type === "Null" || t.type === "Null")
2598
- return I;
2599
- const s = c(e), n = c(t);
2796
+ return L;
2797
+ const s = l(e), n = l(t);
2600
2798
  return k(s * n);
2601
2799
  }
2602
2800
  divide(e, t) {
2603
2801
  if (e.type === "Null" || t.type === "Null")
2604
- return I;
2605
- const s = c(e), n = c(t);
2802
+ return L;
2803
+ const s = l(e), n = l(t);
2606
2804
  if (n === 0)
2607
2805
  throw x(w.DivisionByZero, "Division by zero", "Vbscript");
2608
2806
  return { type: "Double", value: s / n };
2609
2807
  }
2610
2808
  integerDivide(e, t) {
2611
2809
  if (e.type === "Null" || t.type === "Null")
2612
- return I;
2613
- const s = c(e), n = c(t);
2810
+ return L;
2811
+ const s = l(e), n = l(t);
2614
2812
  if (n === 0)
2615
2813
  throw x(w.DivisionByZero, "Division by zero", "Vbscript");
2616
2814
  return { type: "Long", value: Math.floor(s / n) };
2617
2815
  }
2618
2816
  modulo(e, t) {
2619
2817
  if (e.type === "Null" || t.type === "Null")
2620
- return I;
2621
- const s = c(e), n = c(t);
2818
+ return L;
2819
+ const s = l(e), n = l(t);
2622
2820
  if (n === 0)
2623
2821
  throw x(w.DivisionByZero, "Division by zero", "Vbscript");
2624
2822
  return k(s % n);
2625
2823
  }
2626
2824
  power(e, t) {
2627
2825
  if (e.type === "Null" || t.type === "Null")
2628
- return I;
2629
- const s = c(e), n = c(t);
2826
+ return L;
2827
+ const s = l(e), n = l(t);
2630
2828
  return { type: "Double", value: Math.pow(s, n) };
2631
2829
  }
2632
2830
  equals(e, t) {
2633
- return e.type === "Empty" && t.type === "Empty" ? { type: "Boolean", value: !0 } : e.type === "Null" || t.type === "Null" ? { type: "Boolean", value: !1 } : e.type === "Object" && t.type === "Object" ? { type: "Boolean", value: e.value === t.value } : e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e).toLowerCase() === y(t).toLowerCase() } : { type: "Boolean", value: c(e) === c(t) };
2831
+ return e.type === "Empty" && t.type === "Empty" ? { type: "Boolean", value: !0 } : e.type === "Null" || t.type === "Null" ? { type: "Boolean", value: !1 } : e.type === "Object" && t.type === "Object" ? { type: "Boolean", value: e.value === t.value } : e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e).toLowerCase() === y(t).toLowerCase() } : { type: "Boolean", value: l(e) === l(t) };
2634
2832
  }
2635
2833
  notEquals(e, t) {
2636
2834
  return { type: "Boolean", value: !this.equals(e, t).value };
2637
2835
  }
2638
2836
  lessThan(e, t) {
2639
- return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) < y(t) } : { type: "Boolean", value: c(e) < c(t) };
2837
+ return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) < y(t) } : { type: "Boolean", value: l(e) < l(t) };
2640
2838
  }
2641
2839
  lessThanOrEqual(e, t) {
2642
- return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) <= y(t) } : { type: "Boolean", value: c(e) <= c(t) };
2840
+ return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) <= y(t) } : { type: "Boolean", value: l(e) <= l(t) };
2643
2841
  }
2644
2842
  greaterThan(e, t) {
2645
- return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) > y(t) } : { type: "Boolean", value: c(e) > c(t) };
2843
+ return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) > y(t) } : { type: "Boolean", value: l(e) > l(t) };
2646
2844
  }
2647
2845
  greaterThanOrEqual(e, t) {
2648
- return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) >= y(t) } : { type: "Boolean", value: c(e) >= c(t) };
2846
+ return e.type === "String" || t.type === "String" ? { type: "Boolean", value: y(e) >= y(t) } : { type: "Boolean", value: l(e) >= l(t) };
2649
2847
  }
2650
2848
  evaluateUnary(e) {
2651
2849
  const t = this.evaluate(e.argument);
2652
2850
  switch (e.operator) {
2653
2851
  case "-":
2654
- return k(-c(t));
2852
+ return k(-l(t));
2655
2853
  case "+":
2656
- return k(c(t));
2854
+ return k(l(t));
2657
2855
  case "!":
2658
2856
  case "Not":
2659
2857
  return { type: "Boolean", value: !d(t) };
@@ -2703,7 +2901,7 @@ class ne {
2703
2901
  throw new Error(`Invalid assignment target: ${e.left.type}`);
2704
2902
  }
2705
2903
  callTerminateIfNeeded(e, t) {
2706
- if (e.type === "Object" && e.value instanceof re && (t.type !== "Object" || t.value !== e.value)) {
2904
+ if (e.type === "Object" && e.value instanceof ne && (t.type !== "Object" || t.value !== e.value)) {
2707
2905
  const s = e.value, n = s.classInfo.properties.get("class_terminate");
2708
2906
  n && n.get && n.get.call(s);
2709
2907
  }
@@ -2718,7 +2916,7 @@ class ne {
2718
2916
  } else
2719
2917
  a = e.property.name;
2720
2918
  if (n.type === "Array") {
2721
- const i = n.value, o = c(this.evaluate(e.property));
2919
+ const i = n.value, o = l(this.evaluate(e.property));
2722
2920
  i.set([Math.floor(o)], t);
2723
2921
  } else if (n.type === "Object") {
2724
2922
  const i = n.value;
@@ -2743,14 +2941,14 @@ class E extends Error {
2743
2941
  super(e), this.type = e, this.value = t;
2744
2942
  }
2745
2943
  }
2746
- class _ extends E {
2944
+ class U extends E {
2747
2945
  constructor(e) {
2748
2946
  super("goto"), this.labelName = e;
2749
2947
  }
2750
2948
  }
2751
- class Oe {
2949
+ class Re {
2752
2950
  constructor(e) {
2753
- this.context = e, this.exprEvaluator = new ne(e);
2951
+ this.context = e, this.exprEvaluator = new ie(e);
2754
2952
  }
2755
2953
  exprEvaluator;
2756
2954
  execute(e) {
@@ -2766,6 +2964,8 @@ class Oe {
2766
2964
  return this.executeDimStatement(e);
2767
2965
  case "VbReDimStatement":
2768
2966
  return this.executeReDimStatement(e);
2967
+ case "VbEraseStatement":
2968
+ return this.executeEraseStatement(e);
2769
2969
  case "VbConstStatement":
2770
2970
  return this.executeConstStatement(e);
2771
2971
  case "VbForToStatement":
@@ -2841,9 +3041,9 @@ class Oe {
2841
3041
  if (t.isArray && t.arrayBounds) {
2842
3042
  const n = t.arrayBounds.map((i) => {
2843
3043
  const o = this.exprEvaluator.evaluate(i);
2844
- return c(o);
3044
+ return l(o);
2845
3045
  });
2846
- s = { type: "Array", value: R(n) };
3046
+ s = { type: "Array", value: F(n) };
2847
3047
  } else t.init && (s = this.exprEvaluator.evaluate(t.init));
2848
3048
  this.context.declareVariable(t.id.name, s);
2849
3049
  }
@@ -2854,17 +3054,25 @@ class Oe {
2854
3054
  if (!t.isArray || !t.arrayBounds) continue;
2855
3055
  const s = t.arrayBounds.map((a) => {
2856
3056
  const i = this.exprEvaluator.evaluate(a);
2857
- return c(i);
3057
+ return l(i);
2858
3058
  }), n = this.context.currentScope.get(t.id.name);
2859
3059
  if (n && n.value.type === "Array")
2860
3060
  n.value.value.redim(s, e.preserve);
2861
3061
  else {
2862
- const a = R(s);
3062
+ const a = F(s);
2863
3063
  this.context.setVariable(t.id.name, { type: "Array", value: a });
2864
3064
  }
2865
3065
  }
2866
3066
  return m;
2867
3067
  }
3068
+ executeEraseStatement(e) {
3069
+ const t = e.arrayName.name, s = this.context.currentScope.get(t);
3070
+ if (!s)
3071
+ throw new Error(`Variable '${t}' not defined`);
3072
+ if (s.value.type !== "Array")
3073
+ throw new Error(`Type mismatch: '${t}' is not an array`);
3074
+ return s.value.value.erase(), m;
3075
+ }
2868
3076
  executeConstStatement(e) {
2869
3077
  for (const t of e.declarations) {
2870
3078
  const s = this.exprEvaluator.evaluate(t.init);
@@ -2873,10 +3081,10 @@ class Oe {
2873
3081
  return m;
2874
3082
  }
2875
3083
  executeForToStatement(e) {
2876
- const t = this.exprEvaluator.evaluate(e.init), s = this.exprEvaluator.evaluate(e.to), n = e.step ? this.exprEvaluator.evaluate(e.step) : k(1), a = c(t), i = c(s), o = c(n);
3084
+ const t = this.exprEvaluator.evaluate(e.init), s = this.exprEvaluator.evaluate(e.to), n = e.step ? this.exprEvaluator.evaluate(e.step) : k(1), a = l(t), i = l(s), o = l(n);
2877
3085
  this.context.declareVariable(e.left.name, k(a));
2878
- const l = o > 0 ? () => c(this.context.getVariable(e.left.name)) <= i : () => c(this.context.getVariable(e.left.name)) >= i;
2879
- for (; l(); ) {
3086
+ const c = o > 0 ? () => l(this.context.getVariable(e.left.name)) <= i : () => l(this.context.getVariable(e.left.name)) >= i;
3087
+ for (; c(); ) {
2880
3088
  this.context.checkTimeout && this.context.checkTimeout();
2881
3089
  try {
2882
3090
  this.execute(e.body);
@@ -2891,7 +3099,7 @@ class Oe {
2891
3099
  }
2892
3100
  throw h;
2893
3101
  }
2894
- const p = c(this.context.getVariable(e.left.name));
3102
+ const p = l(this.context.getVariable(e.left.name));
2895
3103
  this.context.setVariable(e.left.name, k(p + o));
2896
3104
  }
2897
3105
  return m;
@@ -2904,7 +3112,7 @@ class Oe {
2904
3112
  if (t.type === "Array")
2905
3113
  s = t.value.toArray();
2906
3114
  else {
2907
- const n = t.value, a = n.getProperty("Count"), i = c(a);
3115
+ const n = t.value, a = n.getProperty("Count"), i = l(a);
2908
3116
  s = [];
2909
3117
  for (let o = 0; o < i; o++)
2910
3118
  s.push(n.getProperty(String(o)));
@@ -2980,16 +3188,16 @@ class Oe {
2980
3188
  if (d(this.equals(t, a))) return !0;
2981
3189
  break;
2982
3190
  case "<":
2983
- if (c(t) < c(a)) return !0;
3191
+ if (l(t) < l(a)) return !0;
2984
3192
  break;
2985
3193
  case ">":
2986
- if (c(t) > c(a)) return !0;
3194
+ if (l(t) > l(a)) return !0;
2987
3195
  break;
2988
3196
  case "<=":
2989
- if (c(t) <= c(a)) return !0;
3197
+ if (l(t) <= l(a)) return !0;
2990
3198
  break;
2991
3199
  case ">=":
2992
- if (c(t) >= c(a)) return !0;
3200
+ if (l(t) >= l(a)) return !0;
2993
3201
  break;
2994
3202
  case "!=":
2995
3203
  if (!d(this.equals(t, a))) return !0;
@@ -3008,10 +3216,10 @@ class Oe {
3008
3216
  if (e.type === "Null" || t.type === "Null")
3009
3217
  return { type: "Boolean", value: !1 };
3010
3218
  if (e.type === "String" || t.type === "String") {
3011
- const s = e.type === "String" ? e.value : String(c(e)), n = t.type === "String" ? t.value : String(c(t));
3219
+ const s = e.type === "String" ? e.value : String(l(e)), n = t.type === "String" ? t.value : String(l(t));
3012
3220
  return { type: "Boolean", value: s.toLowerCase() === n.toLowerCase() };
3013
3221
  }
3014
- return { type: "Boolean", value: c(e) === c(t) };
3222
+ return { type: "Boolean", value: l(e) === l(t) };
3015
3223
  }
3016
3224
  executeWithStatement(e) {
3017
3225
  const t = this.exprEvaluator.evaluate(e.object);
@@ -3058,11 +3266,11 @@ class Oe {
3058
3266
  let o = m;
3059
3267
  try {
3060
3268
  s.bindParameters(e.params, i), s.executeBlockStatement(e.body), s.updateByRefArgs(e.params, i), o = s.context.getVariable(t);
3061
- } catch (l) {
3062
- if (l instanceof E && l.type === "return")
3269
+ } catch (c) {
3270
+ if (c instanceof E && c.type === "return")
3063
3271
  s.updateByRefArgs(e.params, i), o = s.context.getVariable(t);
3064
3272
  else
3065
- throw l;
3273
+ throw c;
3066
3274
  } finally {
3067
3275
  s.context.popCall(), s.context.popScope();
3068
3276
  }
@@ -3083,8 +3291,8 @@ class Oe {
3083
3291
  const a = [];
3084
3292
  for (; s < t.length; )
3085
3293
  a.push(t[s++]);
3086
- const i = R([a.length]);
3087
- a.forEach((o, l) => i.set([l], o)), this.context.declareVariable(n.name.name, { type: "Array", value: i });
3294
+ const i = F([a.length]);
3295
+ a.forEach((o, c) => i.set([c], o)), this.context.declareVariable(n.name.name, { type: "Array", value: i });
3088
3296
  } else {
3089
3297
  let a;
3090
3298
  s < t.length ? a = t[s++] : n.defaultValue ? a = this.exprEvaluator.evaluate(n.defaultValue) : (n.isOptional, a = m), this.context.declareVariable(n.name.name, a);
@@ -3099,16 +3307,16 @@ class Oe {
3099
3307
  }
3100
3308
  }
3101
3309
  executeClassStatement(e) {
3102
- const t = e.name.name, s = new te(t), n = this;
3310
+ const t = e.name.name, s = new se(t), n = this;
3103
3311
  let a, i;
3104
3312
  for (const o of e.body)
3105
3313
  if (o.type === "VbDimStatement")
3106
- for (const l of o.declarations)
3107
- s.properties.set(l.id.name.toLowerCase(), {
3108
- name: l.id.name
3314
+ for (const c of o.declarations)
3315
+ s.properties.set(c.id.name.toLowerCase(), {
3316
+ name: c.id.name
3109
3317
  });
3110
3318
  else if (o.type === "VbSubStatement") {
3111
- const l = o, p = o.name.name.toLowerCase();
3319
+ const c = o, p = o.name.name.toLowerCase();
3112
3320
  if (p === "class_initialize") {
3113
3321
  a = {
3114
3322
  name: "Class_Initialize",
@@ -3116,7 +3324,7 @@ class Oe {
3116
3324
  const h = n.context.currentInstance;
3117
3325
  n.context.currentInstance = this, n.context.pushScope();
3118
3326
  try {
3119
- n.executeBlockStatement(l.body);
3327
+ n.executeBlockStatement(c.body);
3120
3328
  } finally {
3121
3329
  n.context.popScope(), n.context.currentInstance = h;
3122
3330
  }
@@ -3132,7 +3340,7 @@ class Oe {
3132
3340
  const h = n.context.currentInstance;
3133
3341
  n.context.currentInstance = this, n.context.pushScope();
3134
3342
  try {
3135
- n.executeBlockStatement(l.body);
3343
+ n.executeBlockStatement(c.body);
3136
3344
  } finally {
3137
3345
  n.context.popScope(), n.context.currentInstance = h;
3138
3346
  }
@@ -3147,7 +3355,7 @@ class Oe {
3147
3355
  const g = n.context.currentInstance;
3148
3356
  n.context.currentInstance = this, n.context.pushScope();
3149
3357
  try {
3150
- n.bindParameters(l.params, h), n.executeBlockStatement(l.body);
3358
+ n.bindParameters(c.params, h), n.executeBlockStatement(c.body);
3151
3359
  } finally {
3152
3360
  n.context.popScope(), n.context.currentInstance = g;
3153
3361
  }
@@ -3156,18 +3364,18 @@ class Oe {
3156
3364
  isSub: !0
3157
3365
  });
3158
3366
  } else if (o.type === "VbFunctionStatement") {
3159
- const l = o;
3367
+ const c = o;
3160
3368
  s.methods.set(o.name.name.toLowerCase(), {
3161
3369
  name: o.name.name,
3162
3370
  func: function(...p) {
3163
3371
  const h = n.context.currentInstance;
3164
- n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(l.name.name, m), n.bindParameters(l.params, p);
3372
+ n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(c.name.name, m), n.bindParameters(c.params, p);
3165
3373
  let g = m;
3166
3374
  try {
3167
- n.executeBlockStatement(l.body), g = n.context.getVariable(l.name.name);
3375
+ n.executeBlockStatement(c.body), g = n.context.getVariable(c.name.name);
3168
3376
  } catch (v) {
3169
3377
  if (v instanceof E && v.type === "return")
3170
- g = n.context.getVariable(l.name.name);
3378
+ g = n.context.getVariable(c.name.name);
3171
3379
  else
3172
3380
  throw v;
3173
3381
  } finally {
@@ -3178,38 +3386,38 @@ class Oe {
3178
3386
  isSub: !1
3179
3387
  });
3180
3388
  } else if (o.type === "VbPropertyGetStatement") {
3181
- const l = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3389
+ const c = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3182
3390
  h.get = function() {
3183
3391
  const g = n.context.currentInstance, v = n.context.inPropertyGet, S = n.context.propertyGetName;
3184
- n.context.currentInstance = this, n.context.inPropertyGet = !0, n.context.propertyGetName = l.name.name.toLowerCase(), n.context.pushScope(), n.context.declareVariable(l.name.name, m);
3392
+ n.context.currentInstance = this, n.context.inPropertyGet = !0, n.context.propertyGetName = c.name.name.toLowerCase(), n.context.pushScope(), n.context.declareVariable(c.name.name, m);
3185
3393
  try {
3186
- return n.executeBlockStatement(l.body), n.context.currentScope.get(l.name.name)?.value ?? m;
3394
+ return n.executeBlockStatement(c.body), n.context.currentScope.get(c.name.name)?.value ?? m;
3187
3395
  } finally {
3188
3396
  n.context.popScope(), n.context.currentInstance = g, n.context.inPropertyGet = v, n.context.propertyGetName = S;
3189
3397
  }
3190
3398
  }, s.properties.set(p, h);
3191
3399
  } else if (o.type === "VbPropertyLetStatement") {
3192
- const l = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3400
+ const c = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3193
3401
  h.let = function(g) {
3194
3402
  const v = n.context.currentInstance;
3195
- n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(l.name.name, m);
3196
- const S = l.params[0];
3403
+ n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(c.name.name, m);
3404
+ const S = c.params[0];
3197
3405
  S && n.context.declareVariable(S.name.name, g);
3198
3406
  try {
3199
- n.executeBlockStatement(l.body);
3407
+ n.executeBlockStatement(c.body);
3200
3408
  } finally {
3201
3409
  n.context.popScope(), n.context.currentInstance = v;
3202
3410
  }
3203
3411
  }, s.properties.set(p, h);
3204
3412
  } else if (o.type === "VbPropertySetStatement") {
3205
- const l = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3413
+ const c = o, p = o.name.name.toLowerCase(), h = s.properties.get(p) || { name: o.name.name };
3206
3414
  h.set = function(g) {
3207
3415
  const v = n.context.currentInstance;
3208
- n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(l.name.name, m);
3209
- const S = l.params[0];
3416
+ n.context.currentInstance = this, n.context.pushScope(), n.context.declareVariable(c.name.name, m);
3417
+ const S = c.params[0];
3210
3418
  S && n.context.declareVariable(S.name.name, g);
3211
3419
  try {
3212
- n.executeBlockStatement(l.body);
3420
+ n.executeBlockStatement(c.body);
3213
3421
  } finally {
3214
3422
  n.context.popScope(), n.context.currentInstance = v;
3215
3423
  }
@@ -3224,7 +3432,7 @@ class Oe {
3224
3432
  return e.action === "resume_next" ? this.context.onErrorResumeNext = !0 : e.action === "goto_0" && (this.context.onErrorResumeNext = !1, this.context.clearError()), m;
3225
3433
  }
3226
3434
  executeGotoStatement(e) {
3227
- throw new _(e.label.name.toLowerCase());
3435
+ throw new U(e.label.name.toLowerCase());
3228
3436
  }
3229
3437
  }
3230
3438
  const M = /* @__PURE__ */ new Map([
@@ -3375,12 +3583,12 @@ const M = /* @__PURE__ */ new Map([
3375
3583
  ["xh", 1076],
3376
3584
  ["yi", 1085],
3377
3585
  ["zu", 1077]
3378
- ]), ae = /* @__PURE__ */ new Map();
3586
+ ]), oe = /* @__PURE__ */ new Map();
3379
3587
  M.forEach((r, e) => {
3380
- ae.set(r, e);
3588
+ oe.set(r, e);
3381
3589
  });
3382
3590
  let B = null;
3383
- function Be(r) {
3591
+ function Fe(r) {
3384
3592
  return r.toLowerCase().replace(/_/g, "-");
3385
3593
  }
3386
3594
  function q(r) {
@@ -3388,32 +3596,32 @@ function q(r) {
3388
3596
  if (e.toLowerCase() === r)
3389
3597
  return e;
3390
3598
  }
3391
- function H() {
3599
+ function K() {
3392
3600
  if (B)
3393
3601
  return B;
3394
- const r = Intl.DateTimeFormat().resolvedOptions().locale || "en-US", e = Be(r), t = q(e);
3602
+ const r = Intl.DateTimeFormat().resolvedOptions().locale || "en-US", e = Fe(r), t = q(e);
3395
3603
  if (t)
3396
3604
  return t;
3397
3605
  const s = e.split("-")[0] ?? "en", n = q(s);
3398
3606
  return n || "en";
3399
3607
  }
3400
- function U() {
3401
- const r = H();
3608
+ function z() {
3609
+ const r = K();
3402
3610
  return { type: "Long", value: M.get(r) ?? 1033 };
3403
3611
  }
3404
- function Ve(r) {
3612
+ function je(r) {
3405
3613
  const e = typeof r.value == "number" ? r.value : parseInt(String(r.value), 10);
3406
3614
  if (isNaN(e)) {
3407
3615
  const s = String(r.value).toLowerCase(), n = q(s);
3408
- return n ? (B = n, { type: "Long", value: M.get(n) ?? 1033 }) : U();
3616
+ return n ? (B = n, { type: "Long", value: M.get(n) ?? 1033 }) : z();
3409
3617
  }
3410
- const t = ae.get(e);
3411
- return t ? (B = t, { type: "Long", value: e }) : U();
3618
+ const t = oe.get(e);
3619
+ return t ? (B = t, { type: "Long", value: e }) : z();
3412
3620
  }
3413
3621
  function P() {
3414
- return H();
3622
+ return K();
3415
3623
  }
3416
- const Z = /* @__PURE__ */ new Map([
3624
+ const ee = /* @__PURE__ */ new Map([
3417
3625
  ["en-us", "USD"],
3418
3626
  ["en-gb", "GBP"],
3419
3627
  ["en-au", "AUD"],
@@ -3461,17 +3669,17 @@ const Z = /* @__PURE__ */ new Map([
3461
3669
  ["en-ph", "PHP"],
3462
3670
  ["en-in", "INR"]
3463
3671
  ]);
3464
- function Me() {
3465
- const r = H(), e = Z.get(r);
3672
+ function Te() {
3673
+ const r = K(), e = ee.get(r);
3466
3674
  if (e) return e;
3467
- const t = r.split("-")[0] ?? "en", s = Z.get(t);
3675
+ const t = r.split("-")[0] ?? "en", s = ee.get(t);
3468
3676
  return s || "USD";
3469
3677
  }
3470
- const Ae = {
3471
- GetLocale: U,
3472
- SetLocale: Ve
3678
+ const We = {
3679
+ GetLocale: z,
3680
+ SetLocale: je
3473
3681
  };
3474
- function Re(r, e) {
3682
+ function Ge(r, e) {
3475
3683
  const t = [];
3476
3684
  let s = 0;
3477
3685
  for (; s < e.length; ) {
@@ -3526,7 +3734,7 @@ function Re(r, e) {
3526
3734
  }
3527
3735
  return t.join("");
3528
3736
  }
3529
- function Fe(r, e) {
3737
+ function _e(r, e) {
3530
3738
  let t = e, s = "", n = "";
3531
3739
  const a = e.indexOf(";");
3532
3740
  if (a !== -1) {
@@ -3534,9 +3742,9 @@ function Fe(r, e) {
3534
3742
  const i = e.substring(a + 1), o = i.indexOf(";");
3535
3743
  o !== -1 ? (s = i.substring(0, o), n = i.substring(o + 1)) : s = i;
3536
3744
  }
3537
- return r === 0 && n ? O(0, n) : r < 0 && s ? O(Math.abs(r), s) : r < 0 ? "-" + O(Math.abs(r), t) : O(r, t);
3745
+ return r === 0 && n ? A(0, n) : r < 0 && s ? A(Math.abs(r), s) : r < 0 ? "-" + A(Math.abs(r), t) : A(r, t);
3538
3746
  }
3539
- function O(r, e) {
3747
+ function A(r, e) {
3540
3748
  let t = e.includes("%");
3541
3749
  t && (r *= 100);
3542
3750
  const s = e.toLowerCase();
@@ -3548,46 +3756,46 @@ function O(r, e) {
3548
3756
  }
3549
3757
  let i = Math.floor(Math.abs(r)), o = a > 0 ? Math.round((Math.abs(r) - i) * Math.pow(10, a)) : 0;
3550
3758
  o >= Math.pow(10, a) && (i++, o = 0);
3551
- let l = i.toString();
3552
- s.indexOf(",") !== -1 && (l = l.replace(/\B(?=(\d{3})+(?!\d))/g, ","));
3553
- let h = l;
3759
+ let c = i.toString();
3760
+ s.indexOf(",") !== -1 && (c = c.replace(/\B(?=(\d{3})+(?!\d))/g, ","));
3761
+ let h = c;
3554
3762
  if (a > 0) {
3555
3763
  const g = o.toString().padStart(a, "0");
3556
3764
  h += "." + g;
3557
3765
  }
3558
3766
  return t && (h += "%"), h;
3559
3767
  }
3560
- function je(r, e) {
3768
+ function Ue(r, e) {
3561
3769
  return e === ">" || e.toLowerCase() === ">" ? r.toUpperCase() : e === "<" || e.toLowerCase() === "<" ? r.toLowerCase() : r;
3562
3770
  }
3563
- const We = {
3771
+ const qe = {
3564
3772
  Len: (r) => ({ type: "Long", value: y(r).length }),
3565
3773
  Left: (r, e) => {
3566
- const t = y(r), s = Math.max(0, Math.floor(c(e)));
3774
+ const t = y(r), s = Math.max(0, Math.floor(l(e)));
3567
3775
  return { type: "String", value: t.substring(0, s) };
3568
3776
  },
3569
3777
  Right: (r, e) => {
3570
- const t = y(r), s = Math.max(0, Math.floor(c(e)));
3778
+ const t = y(r), s = Math.max(0, Math.floor(l(e)));
3571
3779
  return { type: "String", value: t.substring(t.length - s) };
3572
3780
  },
3573
3781
  Mid: (r, e, t) => {
3574
- const s = y(r), n = Math.max(1, Math.floor(c(e))) - 1;
3782
+ const s = y(r), n = Math.max(1, Math.floor(l(e))) - 1;
3575
3783
  if (t) {
3576
- const a = Math.floor(c(t));
3784
+ const a = Math.floor(l(t));
3577
3785
  return { type: "String", value: s.substring(n, n + a) };
3578
3786
  }
3579
3787
  return { type: "String", value: s.substring(n) };
3580
3788
  },
3581
3789
  InStr: (r, e, t, s) => {
3582
3790
  let n = 1, a, i, o = 0;
3583
- e === void 0 ? (a = "", i = y(r)) : t === void 0 ? (a = y(r), i = y(e)) : (n = Math.max(1, Math.floor(c(r))), a = y(e), i = y(t), s && (o = Math.floor(c(s))));
3584
- let l;
3585
- return o === 0 ? l = a.indexOf(i, n - 1) : l = a.toLowerCase().indexOf(i.toLowerCase(), n - 1), { type: "Long", value: l + 1 };
3791
+ e === void 0 ? (a = "", i = y(r)) : t === void 0 ? (a = y(r), i = y(e)) : (n = Math.max(1, Math.floor(l(r))), a = y(e), i = y(t), s && (o = Math.floor(l(s))));
3792
+ let c;
3793
+ return o === 0 ? c = a.indexOf(i, n - 1) : c = a.toLowerCase().indexOf(i.toLowerCase(), n - 1), { type: "Long", value: c + 1 };
3586
3794
  },
3587
3795
  InStrRev: (r, e, t, s) => {
3588
- const n = y(r), a = y(e), i = t ? Math.floor(c(t)) : n.length, o = s ? Math.floor(c(s)) : 0;
3589
- let l;
3590
- return o === 0 ? l = n.lastIndexOf(a, i - 1) : l = n.toLowerCase().lastIndexOf(a.toLowerCase(), i - 1), { type: "Long", value: l + 1 };
3796
+ const n = y(r), a = y(e), i = t ? Math.floor(l(t)) : n.length, o = s ? Math.floor(l(s)) : 0;
3797
+ let c;
3798
+ return o === 0 ? c = n.lastIndexOf(a, i - 1) : c = n.toLowerCase().lastIndexOf(a.toLowerCase(), i - 1), { type: "Long", value: c + 1 };
3591
3799
  },
3592
3800
  LCase: (r) => ({ type: "String", value: y(r).toLowerCase() }),
3593
3801
  UCase: (r) => ({ type: "String", value: y(r).toUpperCase() }),
@@ -3595,25 +3803,25 @@ const We = {
3595
3803
  RTrim: (r) => ({ type: "String", value: y(r).replace(/\s+$/, "") }),
3596
3804
  Trim: (r) => ({ type: "String", value: y(r).trim() }),
3597
3805
  Replace: (r, e, t, s, n, a) => {
3598
- const i = y(r), o = y(e), l = y(t), p = s ? Math.max(1, Math.floor(c(s))) - 1 : 0, h = n ? Math.floor(c(n)) : -1, g = a ? Math.floor(c(a)) : 0;
3599
- let v = "", S = 0, L = p;
3600
- const ce = g === 0 ? i : i.toLowerCase(), le = g === 0 ? o : o.toLowerCase();
3601
- for (; L < i.length; ) {
3806
+ const i = y(r), o = y(e), c = y(t), p = s ? Math.max(1, Math.floor(l(s))) - 1 : 0, h = n ? Math.floor(l(n)) : -1, g = a ? Math.floor(l(a)) : 0;
3807
+ let v = "", S = 0, I = p;
3808
+ const ue = g === 0 ? i : i.toLowerCase(), pe = g === 0 ? o : o.toLowerCase();
3809
+ for (; I < i.length; ) {
3602
3810
  if (h !== -1 && S >= h) {
3603
- v += i.substring(L);
3811
+ v += i.substring(I);
3604
3812
  break;
3605
3813
  }
3606
- ce.substring(L, L + o.length) === le ? (v += l, L += o.length, S++) : (v += i[L], L++);
3814
+ ue.substring(I, I + o.length) === pe ? (v += c, I += o.length, S++) : (v += i[I], I++);
3607
3815
  }
3608
3816
  return { type: "String", value: v };
3609
3817
  },
3610
3818
  StrReverse: (r) => ({ type: "String", value: y(r).split("").reverse().join("") }),
3611
3819
  Space: (r) => {
3612
- const e = Math.max(0, Math.floor(c(r)));
3820
+ const e = Math.max(0, Math.floor(l(r)));
3613
3821
  return { type: "String", value: " ".repeat(e) };
3614
3822
  },
3615
3823
  String: (r, e) => {
3616
- const t = Math.max(0, Math.floor(c(r))), s = y(e);
3824
+ const t = Math.max(0, Math.floor(l(r))), s = y(e);
3617
3825
  return { type: "String", value: (s.length > 0 ? s[0] : " ").repeat(t) };
3618
3826
  },
3619
3827
  Asc: (r) => {
@@ -3625,15 +3833,15 @@ const We = {
3625
3833
  return { type: "Integer", value: e.length > 0 ? e.charCodeAt(0) : 0 };
3626
3834
  },
3627
3835
  Chr: (r) => {
3628
- const e = Math.floor(c(r));
3836
+ const e = Math.floor(l(r));
3629
3837
  return { type: "String", value: String.fromCharCode(e) };
3630
3838
  },
3631
3839
  ChrW: (r) => {
3632
- const e = Math.floor(c(r));
3840
+ const e = Math.floor(l(r));
3633
3841
  return { type: "String", value: String.fromCharCode(e) };
3634
3842
  },
3635
3843
  StrComp: (r, e, t) => {
3636
- const s = y(r), n = y(e), a = t ? Math.floor(c(t)) : 0;
3844
+ const s = y(r), n = y(e), a = t ? Math.floor(l(t)) : 0;
3637
3845
  let i;
3638
3846
  if (a === 1)
3639
3847
  i = s.toLowerCase().localeCompare(n.toLowerCase());
@@ -3645,9 +3853,9 @@ const We = {
3645
3853
  return { type: "Integer", value: i };
3646
3854
  },
3647
3855
  Split: (r, e, t, s) => {
3648
- const n = y(r), a = e ? y(e) : " ", i = t ? Math.floor(c(t)) : -1, o = n.split(a);
3649
- let l;
3650
- return i > 0 && o.length > i ? (l = o.slice(0, i - 1), l.push(o.slice(i - 1).join(a))) : l = o, { type: "Array", value: T(l.map((h) => ({ type: "String", value: h }))) };
3856
+ const n = y(r), a = e ? y(e) : " ", i = t ? Math.floor(l(t)) : -1, o = n.split(a);
3857
+ let c;
3858
+ return i > 0 && o.length > i ? (c = o.slice(0, i - 1), c.push(o.slice(i - 1).join(a))) : c = o, { type: "Array", value: _(c.map((h) => ({ type: "String", value: h }))) };
3651
3859
  },
3652
3860
  Join: (r, e) => {
3653
3861
  const t = e ? y(e) : " ";
@@ -3661,74 +3869,74 @@ const We = {
3661
3869
  if (r.type === "Empty" || r.type === "Null")
3662
3870
  return { type: "String", value: "" };
3663
3871
  const t = e ? y(e) : "";
3664
- return t ? r.type === "Date" && r.value instanceof Date ? { type: "String", value: Re(r.value, t) } : r.type === "Boolean" ? { type: "String", value: r.value ? "True" : "False" } : ["Integer", "Long", "Single", "Double", "Currency", "Byte"].includes(r.type) ? { type: "String", value: Fe(c(r), t) } : r.type === "String" ? { type: "String", value: je(y(r), t) } : { type: "String", value: y(r) } : { type: "String", value: y(r) };
3872
+ return t ? r.type === "Date" && r.value instanceof Date ? { type: "String", value: Ge(r.value, t) } : r.type === "Boolean" ? { type: "String", value: r.value ? "True" : "False" } : ["Integer", "Long", "Single", "Double", "Currency", "Byte"].includes(r.type) ? { type: "String", value: _e(l(r), t) } : r.type === "String" ? { type: "String", value: Ue(y(r), t) } : { type: "String", value: y(r) } : { type: "String", value: y(r) };
3665
3873
  },
3666
3874
  LSet: (r, e) => {
3667
- const t = y(r), s = Math.max(0, Math.floor(c(e)));
3875
+ const t = y(r), s = Math.max(0, Math.floor(l(e)));
3668
3876
  return t.length >= s ? { type: "String", value: t.substring(0, s) } : { type: "String", value: t.padEnd(s, " ") };
3669
3877
  },
3670
3878
  RSet: (r, e) => {
3671
- const t = y(r), s = Math.max(0, Math.floor(c(e)));
3879
+ const t = y(r), s = Math.max(0, Math.floor(l(e)));
3672
3880
  return t.length >= s ? { type: "String", value: t.substring(0, s) } : { type: "String", value: t.padStart(s, " ") };
3673
3881
  }
3674
- }, Ge = {
3882
+ }, ze = {
3675
3883
  Abs: (r) => {
3676
- const e = c(r);
3884
+ const e = l(r);
3677
3885
  return k(Math.abs(e));
3678
3886
  },
3679
3887
  Sgn: (r) => {
3680
- const e = c(r);
3888
+ const e = l(r);
3681
3889
  return { type: "Integer", value: e > 0 ? 1 : e < 0 ? -1 : 0 };
3682
3890
  },
3683
3891
  Sqr: (r) => {
3684
- const e = c(r);
3892
+ const e = l(r);
3685
3893
  if (e < 0)
3686
3894
  throw new Error("Invalid procedure call or argument: Sqr");
3687
3895
  return { type: "Double", value: Math.sqrt(e) };
3688
3896
  },
3689
3897
  Int: (r) => {
3690
- const e = c(r);
3898
+ const e = l(r);
3691
3899
  return { type: "Long", value: Math.floor(e) };
3692
3900
  },
3693
3901
  Fix: (r) => {
3694
- const e = c(r);
3902
+ const e = l(r);
3695
3903
  return { type: "Long", value: e >= 0 ? Math.floor(e) : Math.ceil(e) };
3696
3904
  },
3697
3905
  Round: (r, e) => {
3698
- const t = c(r), s = e ? Math.floor(c(e)) : 0, n = Math.pow(10, s);
3906
+ const t = l(r), s = e ? Math.floor(l(e)) : 0, n = Math.pow(10, s);
3699
3907
  return { type: "Double", value: Math.round(t * n) / n };
3700
3908
  },
3701
3909
  Atn: (r) => {
3702
- const e = c(r);
3910
+ const e = l(r);
3703
3911
  return { type: "Double", value: Math.atan(e) };
3704
3912
  },
3705
3913
  Cos: (r) => {
3706
- const e = c(r);
3914
+ const e = l(r);
3707
3915
  return { type: "Double", value: Math.cos(e) };
3708
3916
  },
3709
3917
  Sin: (r) => {
3710
- const e = c(r);
3918
+ const e = l(r);
3711
3919
  return { type: "Double", value: Math.sin(e) };
3712
3920
  },
3713
3921
  Tan: (r) => {
3714
- const e = c(r);
3922
+ const e = l(r);
3715
3923
  return { type: "Double", value: Math.tan(e) };
3716
3924
  },
3717
3925
  Exp: (r) => {
3718
- const e = c(r);
3926
+ const e = l(r);
3719
3927
  return { type: "Double", value: Math.exp(e) };
3720
3928
  },
3721
3929
  Log: (r) => {
3722
- const e = c(r);
3930
+ const e = l(r);
3723
3931
  if (e <= 0)
3724
3932
  throw new Error("Invalid procedure call or argument: Log");
3725
3933
  return { type: "Double", value: Math.log(e) };
3726
3934
  },
3727
3935
  Rnd: (r) => ({ type: "Single", value: Math.random() }),
3728
3936
  Randomize: (r) => m,
3729
- Oct: (r) => ({ type: "String", value: Math.floor(c(r)).toString(8) }),
3730
- Hex: (r) => ({ type: "String", value: Math.floor(c(r)).toString(16).toUpperCase() })
3731
- }, Te = {
3937
+ Oct: (r) => ({ type: "String", value: Math.floor(l(r)).toString(8) }),
3938
+ Hex: (r) => ({ type: "String", value: Math.floor(l(r)).toString(16).toUpperCase() })
3939
+ }, Ye = {
3732
3940
  vbCr: { type: "String", value: "\r" },
3733
3941
  vbCrLf: { type: "String", value: `\r
3734
3942
  ` },
@@ -3803,7 +4011,7 @@ function C(r) {
3803
4011
  const e = new Date(1899, 11, 30);
3804
4012
  return new Date(e.getTime() + r * 864e5);
3805
4013
  }
3806
- const _e = {
4014
+ const $e = {
3807
4015
  Now: () => ({ type: "Date", value: /* @__PURE__ */ new Date() }),
3808
4016
  Date: () => {
3809
4017
  const r = /* @__PURE__ */ new Date();
@@ -3813,19 +4021,19 @@ const _e = {
3813
4021
  const r = /* @__PURE__ */ new Date();
3814
4022
  return { type: "Date", value: new Date(0, 0, 0, r.getHours(), r.getMinutes(), r.getSeconds()) };
3815
4023
  },
3816
- Year: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getFullYear() }),
3817
- Month: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getMonth() + 1 }),
3818
- Day: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getDate() }),
4024
+ Year: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getFullYear() }),
4025
+ Month: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getMonth() + 1 }),
4026
+ Day: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getDate() }),
3819
4027
  Weekday: (r, e) => {
3820
- const t = r.type === "Date" ? r.value : C(c(r)), s = e ? Math.floor(c(e)) : 1;
4028
+ const t = r.type === "Date" ? r.value : C(l(r)), s = e ? Math.floor(l(e)) : 1;
3821
4029
  let n = t.getDay() + 1;
3822
4030
  return n = n - s + 1, n < 1 && (n += 7), { type: "Integer", value: n };
3823
4031
  },
3824
- Hour: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getHours() }),
3825
- Minute: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getMinutes() }),
3826
- Second: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(c(r))).getSeconds() }),
4032
+ Hour: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getHours() }),
4033
+ Minute: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getMinutes() }),
4034
+ Second: (r) => ({ type: "Integer", value: (r.type === "Date" ? r.value : C(l(r))).getSeconds() }),
3827
4035
  DateAdd: (r, e, t) => {
3828
- const s = y(r).toLowerCase(), n = c(e), a = t.type === "Date" ? new Date(t.value) : C(c(t));
4036
+ const s = y(r).toLowerCase(), n = l(e), a = t.type === "Date" ? new Date(t.value) : C(l(t));
3829
4037
  switch (s) {
3830
4038
  case "yyyy":
3831
4039
  a.setFullYear(a.getFullYear() + n);
@@ -3857,7 +4065,7 @@ const _e = {
3857
4065
  return { type: "Date", value: a };
3858
4066
  },
3859
4067
  DateDiff: (r, e, t, s, n) => {
3860
- const a = y(r).toLowerCase(), i = e.type === "Date" ? e.value : C(c(e)), o = t.type === "Date" ? t.value : C(c(t)), l = o.getTime() - i.getTime();
4068
+ const a = y(r).toLowerCase(), i = e.type === "Date" ? e.value : C(l(e)), o = t.type === "Date" ? t.value : C(l(t)), c = o.getTime() - i.getTime();
3861
4069
  let p;
3862
4070
  switch (a) {
3863
4071
  case "yyyy":
@@ -3871,22 +4079,22 @@ const _e = {
3871
4079
  break;
3872
4080
  case "y":
3873
4081
  case "d":
3874
- p = Math.floor(l / 864e5);
4082
+ p = Math.floor(c / 864e5);
3875
4083
  break;
3876
4084
  case "w":
3877
- p = Math.floor(l / 864e5);
4085
+ p = Math.floor(c / 864e5);
3878
4086
  break;
3879
4087
  case "ww":
3880
- p = Math.floor(l / (864e5 * 7));
4088
+ p = Math.floor(c / (864e5 * 7));
3881
4089
  break;
3882
4090
  case "h":
3883
- p = Math.floor(l / 36e5);
4091
+ p = Math.floor(c / 36e5);
3884
4092
  break;
3885
4093
  case "n":
3886
- p = Math.floor(l / 6e4);
4094
+ p = Math.floor(c / 6e4);
3887
4095
  break;
3888
4096
  case "s":
3889
- p = Math.floor(l / 1e3);
4097
+ p = Math.floor(c / 1e3);
3890
4098
  break;
3891
4099
  default:
3892
4100
  p = 0;
@@ -3894,7 +4102,7 @@ const _e = {
3894
4102
  return { type: "Long", value: p };
3895
4103
  },
3896
4104
  DatePart: (r, e, t, s) => {
3897
- const n = y(r).toLowerCase(), a = e.type === "Date" ? e.value : C(c(e));
4105
+ const n = y(r).toLowerCase(), a = e.type === "Date" ? e.value : C(l(e));
3898
4106
  let i;
3899
4107
  switch (n) {
3900
4108
  case "yyyy":
@@ -3917,8 +4125,8 @@ const _e = {
3917
4125
  i = a.getDay() + 1;
3918
4126
  break;
3919
4127
  case "ww":
3920
- const l = new Date(a.getFullYear(), 0, 1);
3921
- i = Math.floor((a.getTime() - l.getTime()) / (864e5 * 7)) + 1;
4128
+ const c = new Date(a.getFullYear(), 0, 1);
4129
+ i = Math.floor((a.getTime() - c.getTime()) / (864e5 * 7)) + 1;
3922
4130
  break;
3923
4131
  case "h":
3924
4132
  i = a.getHours();
@@ -3935,11 +4143,11 @@ const _e = {
3935
4143
  return { type: "Integer", value: i };
3936
4144
  },
3937
4145
  DateSerial: (r, e, t) => {
3938
- const s = Math.floor(c(r)), n = Math.floor(c(e)), a = Math.floor(c(t));
4146
+ const s = Math.floor(l(r)), n = Math.floor(l(e)), a = Math.floor(l(t));
3939
4147
  return { type: "Date", value: new Date(s, n - 1, a) };
3940
4148
  },
3941
4149
  TimeSerial: (r, e, t) => {
3942
- const s = Math.floor(c(r)), n = Math.floor(c(e)), a = Math.floor(c(t));
4150
+ const s = Math.floor(l(r)), n = Math.floor(l(e)), a = Math.floor(l(t));
3943
4151
  return { type: "Date", value: new Date(0, 0, 0, s, n, a) };
3944
4152
  },
3945
4153
  DateValue: (r) => {
@@ -3955,7 +4163,7 @@ const _e = {
3955
4163
  return { type: "Date", value: new Date(0, 0, 0, e.getHours(), e.getMinutes(), e.getSeconds()) };
3956
4164
  },
3957
4165
  MonthName: (r, e) => {
3958
- const t = Math.floor(c(r)), s = [
4166
+ const t = Math.floor(l(r)), s = [
3959
4167
  "January",
3960
4168
  "February",
3961
4169
  "March",
@@ -3968,26 +4176,26 @@ const _e = {
3968
4176
  "October",
3969
4177
  "November",
3970
4178
  "December"
3971
- ], n = e ? c(e) !== 0 : !1, a = s[t - 1] || "";
4179
+ ], n = e ? l(e) !== 0 : !1, a = s[t - 1] || "";
3972
4180
  return { type: "String", value: n ? a.substring(0, 3) : a };
3973
4181
  },
3974
4182
  WeekdayName: (r, e, t) => {
3975
- const s = Math.floor(c(r)), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = e ? c(e) !== 0 : !1, i = n[s - 1] || "";
4183
+ const s = Math.floor(l(r)), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = e ? l(e) !== 0 : !1, i = n[s - 1] || "";
3976
4184
  return { type: "String", value: a ? i.substring(0, 3) : i };
3977
4185
  },
3978
4186
  Timer: () => {
3979
4187
  const r = /* @__PURE__ */ new Date();
3980
4188
  return { type: "Single", value: r.getHours() * 3600 + r.getMinutes() * 60 + r.getSeconds() + r.getMilliseconds() / 1e3 };
3981
4189
  }
3982
- }, qe = {
4190
+ }, He = {
3983
4191
  CBool: (r) => ({ type: "Boolean", value: d(r) }),
3984
4192
  CByte: (r) => {
3985
- const e = Math.floor(c(r));
4193
+ const e = Math.floor(l(r));
3986
4194
  if (e < 0 || e > 255)
3987
4195
  throw new Error("Overflow: CByte");
3988
4196
  return { type: "Byte", value: e };
3989
4197
  },
3990
- CCur: (r) => ({ type: "Currency", value: c(r) }),
4198
+ CCur: (r) => ({ type: "Currency", value: l(r) }),
3991
4199
  CDate: (r) => {
3992
4200
  if (r.type === "Date")
3993
4201
  return r;
@@ -3996,61 +4204,61 @@ const _e = {
3996
4204
  throw new Error("Type mismatch: CDate");
3997
4205
  return { type: "Date", value: t };
3998
4206
  },
3999
- CDbl: (r) => ({ type: "Double", value: c(r) }),
4207
+ CDbl: (r) => ({ type: "Double", value: l(r) }),
4000
4208
  CInt: (r) => {
4001
- const e = Math.round(c(r));
4209
+ const e = Math.round(l(r));
4002
4210
  if (e < -32768 || e > 32767)
4003
4211
  throw new Error("Overflow: CInt");
4004
4212
  return { type: "Integer", value: e };
4005
4213
  },
4006
- CLng: (r) => ({ type: "Long", value: Math.round(c(r)) }),
4007
- CSng: (r) => ({ type: "Single", value: c(r) }),
4214
+ CLng: (r) => ({ type: "Long", value: Math.round(l(r)) }),
4215
+ CSng: (r) => ({ type: "Single", value: l(r) }),
4008
4216
  CStr: (r) => ({ type: "String", value: y(r) }),
4009
4217
  CVar: (r) => r,
4010
- CVErr: (r) => ({ type: "Error", value: c(r) }),
4218
+ CVErr: (r) => ({ type: "Error", value: l(r) }),
4011
4219
  Val: (r) => {
4012
4220
  const t = y(r).trim().match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
4013
4221
  return t ? { type: "Double", value: parseFloat(t[0]) } : { type: "Double", value: 0 };
4014
4222
  },
4015
4223
  Str: (r) => {
4016
- const e = c(r), t = String(e);
4224
+ const e = l(r), t = String(e);
4017
4225
  return e >= 0 ? { type: "String", value: " " + t } : { type: "String", value: t };
4018
4226
  },
4019
4227
  FormatNumber: (r, e, t, s, n) => {
4020
- const a = c(r), i = e ? Math.floor(c(e)) : -1, o = t ? c(t) : -2, l = n ? c(n) : -2, p = {
4228
+ const a = l(r), i = e ? Math.floor(l(e)) : -1, o = t ? l(t) : -2, c = n ? l(n) : -2, p = {
4021
4229
  minimumFractionDigits: i >= 0 ? i : void 0,
4022
4230
  maximumFractionDigits: i >= 0 ? i : void 0,
4023
- useGrouping: l === 0 ? !1 : l === -1 ? !0 : void 0
4231
+ useGrouping: c === 0 ? !1 : c === -1 ? !0 : void 0
4024
4232
  };
4025
4233
  o === -1 ? p.minimumIntegerDigits = 1 : o === 0 && (p.minimumIntegerDigits = 2);
4026
4234
  const h = P();
4027
4235
  return { type: "String", value: a.toLocaleString(h, p) };
4028
4236
  },
4029
4237
  FormatCurrency: (r, e, t, s, n) => {
4030
- const a = c(r), i = e ? Math.floor(c(e)) : -1, o = t ? c(t) : -2, l = n ? c(n) : -2, p = {
4238
+ const a = l(r), i = e ? Math.floor(l(e)) : -1, o = t ? l(t) : -2, c = n ? l(n) : -2, p = {
4031
4239
  style: "currency",
4032
- currency: Me(),
4240
+ currency: Te(),
4033
4241
  minimumFractionDigits: i >= 0 ? i : 2,
4034
4242
  maximumFractionDigits: i >= 0 ? i : 2,
4035
- useGrouping: l === 0 ? !1 : l === -1 ? !0 : void 0
4243
+ useGrouping: c === 0 ? !1 : c === -1 ? !0 : void 0
4036
4244
  };
4037
4245
  o === -1 ? p.minimumIntegerDigits = 1 : o === 0 && (p.minimumIntegerDigits = 2);
4038
4246
  const h = P();
4039
4247
  return { type: "String", value: a.toLocaleString(h, p) };
4040
4248
  },
4041
4249
  FormatPercent: (r, e, t, s, n) => {
4042
- const a = c(r), i = e ? Math.floor(c(e)) : -1, o = t ? c(t) : -2, l = n ? c(n) : -2, p = {
4250
+ const a = l(r), i = e ? Math.floor(l(e)) : -1, o = t ? l(t) : -2, c = n ? l(n) : -2, p = {
4043
4251
  style: "percent",
4044
4252
  minimumFractionDigits: i >= 0 ? i : void 0,
4045
4253
  maximumFractionDigits: i >= 0 ? i : void 0,
4046
- useGrouping: l === 0 ? !1 : l === -1 ? !0 : void 0
4254
+ useGrouping: c === 0 ? !1 : c === -1 ? !0 : void 0
4047
4255
  };
4048
4256
  o === -1 ? p.minimumIntegerDigits = 1 : o === 0 && (p.minimumIntegerDigits = 2);
4049
4257
  const h = P();
4050
4258
  return { type: "String", value: a.toLocaleString(h, p) };
4051
4259
  },
4052
4260
  FormatDateTime: (r, e) => {
4053
- const t = r.type === "Date" ? r.value : new Date(y(r)), s = e ? Math.floor(c(e)) : 0, n = P();
4261
+ const t = r.type === "Date" ? r.value : new Date(y(r)), s = e ? Math.floor(l(e)) : 0, n = P();
4054
4262
  let a;
4055
4263
  switch (s) {
4056
4264
  case 0:
@@ -4073,9 +4281,9 @@ const _e = {
4073
4281
  }
4074
4282
  return { type: "String", value: a };
4075
4283
  },
4076
- Hex: (r) => ({ type: "String", value: Math.floor(c(r)).toString(16).toUpperCase() }),
4077
- Oct: (r) => ({ type: "String", value: Math.floor(c(r)).toString(8) })
4078
- }, Ue = {
4284
+ Hex: (r) => ({ type: "String", value: Math.floor(l(r)).toString(16).toUpperCase() }),
4285
+ Oct: (r) => ({ type: "String", value: Math.floor(l(r)).toString(8) })
4286
+ }, Ke = {
4079
4287
  IsArray: (r) => ({ type: "Boolean", value: r.type === "Array" }),
4080
4288
  IsDate: (r) => {
4081
4289
  if (r.type === "Date")
@@ -4086,9 +4294,9 @@ const _e = {
4086
4294
  }
4087
4295
  return { type: "Boolean", value: !1 };
4088
4296
  },
4089
- IsEmpty: (r) => ({ type: "Boolean", value: Ee(r) }),
4090
- IsNull: (r) => ({ type: "Boolean", value: Ce(r) }),
4091
- IsNumeric: (r) => ({ type: "Boolean", value: xe(r) }),
4297
+ IsEmpty: (r) => ({ type: "Boolean", value: Ie(r) }),
4298
+ IsNull: (r) => ({ type: "Boolean", value: Le(r) }),
4299
+ IsNumeric: (r) => ({ type: "Boolean", value: ke(r) }),
4092
4300
  IsObject: (r) => ({ type: "Boolean", value: r.type === "Object" }),
4093
4301
  VarType: (r) => ({ type: "Integer", value: {
4094
4302
  Empty: 0,
@@ -4124,39 +4332,40 @@ const _e = {
4124
4332
  Byte: "Byte",
4125
4333
  Array: "Variant()"
4126
4334
  }[r.type] ?? "Variant" })
4127
- }, ze = {
4128
- Array: (...r) => ({ type: "Array", value: T(r) }),
4335
+ }, Je = {
4336
+ Array: (...r) => ({ type: "Array", value: _(r) }),
4129
4337
  LBound: (r, e) => {
4130
4338
  if (r.type !== "Array")
4131
4339
  throw new Error("Type mismatch: LBound");
4132
- const t = r.value, s = e ? Math.floor(c(e)) : 1;
4340
+ const t = r.value, s = e ? Math.floor(l(e)) : 1;
4133
4341
  return { type: "Long", value: t.getBounds(s).lower };
4134
4342
  },
4135
4343
  UBound: (r, e) => {
4136
4344
  if (r.type !== "Array")
4137
4345
  throw new Error("Type mismatch: UBound");
4138
- const t = r.value, s = e ? Math.floor(c(e)) : 1;
4346
+ const t = r.value, s = e ? Math.floor(l(e)) : 1;
4139
4347
  return { type: "Long", value: t.getBounds(s).upper };
4140
4348
  },
4141
4349
  IsArray: (r) => ({ type: "Boolean", value: r.type === "Array" }),
4142
4350
  Filter: (r, e, t, s) => {
4143
4351
  if (r.type !== "Array")
4144
4352
  throw new Error("Type mismatch: Filter");
4145
- const n = r.value.toArray(), a = e.value.toLowerCase(), i = t ? c(t) !== 0 : !0, o = n.filter((p) => {
4353
+ const n = r.value.toArray(), a = e.value.toLowerCase(), i = t ? l(t) !== 0 : !0, o = n.filter((p) => {
4146
4354
  const g = p.value.toLowerCase().includes(a);
4147
4355
  return i ? g : !g;
4148
4356
  });
4149
- return { type: "Array", value: T(o) };
4357
+ return { type: "Array", value: _(o) };
4150
4358
  }
4151
4359
  }, b = {
4152
4360
  vbOK: 1,
4153
4361
  vbCancel: 2,
4154
4362
  vbAbort: 3,
4155
4363
  vbRetry: 4,
4364
+ vbIgnore: 5,
4156
4365
  vbYes: 6,
4157
4366
  vbNo: 7
4158
4367
  };
4159
- function ie(r) {
4368
+ function ce(r) {
4160
4369
  const e = r ?? 0, t = e & 7, s = e & 240, n = e & 768;
4161
4370
  let a;
4162
4371
  switch (t) {
@@ -4198,7 +4407,7 @@ function ie(r) {
4198
4407
  }
4199
4408
  return { buttonType: a, iconType: i, defaultButton: n };
4200
4409
  }
4201
- function $e(r) {
4410
+ function Xe(r) {
4202
4411
  switch (r) {
4203
4412
  case "Critical":
4204
4413
  return "[X] ";
@@ -4212,12 +4421,12 @@ function $e(r) {
4212
4421
  return "";
4213
4422
  }
4214
4423
  }
4215
- function oe(r, e, t) {
4216
- let s = $e(e) + t;
4424
+ function le(r, e, t) {
4425
+ let s = Xe(e) + t;
4217
4426
  return r && (s = `[${r}]
4218
4427
  ` + s), s;
4219
4428
  }
4220
- function Ye(r, e) {
4429
+ function Ze(r, e) {
4221
4430
  const t = [];
4222
4431
  switch (r) {
4223
4432
  case "OK":
@@ -4241,57 +4450,94 @@ function Ye(r, e) {
4241
4450
  }
4242
4451
  return t;
4243
4452
  }
4244
- function He() {
4453
+ function Qe() {
4245
4454
  return function(r, e, t) {
4246
- const s = String(r.value ?? r), n = e ? Number(e.value ?? e) : 0, a = t ? String(t.value ?? t) : "VBScript", { buttonType: i, iconType: o } = ie(n), l = oe(a, o, s);
4455
+ const s = String(r.value ?? r), n = e ? Number(e.value ?? e) : 0, a = t ? String(t.value ?? t) : "VBScript", { buttonType: i, iconType: o } = ce(n), c = le(a, o, s);
4247
4456
  if (i === "OK")
4248
- return alert(l), { type: "Integer", value: b.vbOK };
4249
- if (i === "OKCancel" || i === "YesNo" || i === "YesNoCancel") {
4250
- const p = confirm(l);
4251
- return i === "OKCancel" ? { type: "Integer", value: p ? b.vbOK : b.vbCancel } : { type: "Integer", value: p ? b.vbYes : b.vbNo };
4457
+ return alert(c), { type: "Integer", value: b.vbOK };
4458
+ if (i === "OKCancel")
4459
+ return { type: "Integer", value: confirm(c) ? b.vbOK : b.vbCancel };
4460
+ if (i === "YesNo")
4461
+ return { type: "Integer", value: confirm(c + `
4462
+ [OK]=Yes / [Cancel]=No`) ? b.vbYes : b.vbNo };
4463
+ if (i === "YesNoCancel") {
4464
+ const p = window.prompt(c + `
4465
+
4466
+ Enter: Y (Yes) / N (No) / C (Cancel) or invalid value for cancel`, "");
4467
+ if (p === null)
4468
+ return { type: "Integer", value: b.vbCancel };
4469
+ const h = p.trim().toUpperCase();
4470
+ return h === "Y" || h === "YES" ? { type: "Integer", value: b.vbYes } : h === "N" || h === "NO" ? { type: "Integer", value: b.vbNo } : h === "C" || h === "CANCEL" || h === "" ? { type: "Integer", value: b.vbCancel } : { type: "Integer", value: b.vbCancel };
4252
4471
  }
4253
- return i === "RetryCancel" ? { type: "Integer", value: confirm(l + `
4254
- [Retry] / [Cancel]`) ? b.vbRetry : b.vbCancel } : (alert(l), { type: "Integer", value: b.vbOK });
4472
+ if (i === "RetryCancel")
4473
+ return { type: "Integer", value: confirm(c + `
4474
+ [OK]=Retry / [Cancel]=Cancel`) ? b.vbRetry : b.vbCancel };
4475
+ if (i === "AbortRetryIgnore") {
4476
+ const p = window.prompt(c + `
4477
+
4478
+ Enter: A (Abort) / R (Retry) / I (Ignore)`, "");
4479
+ if (p === null)
4480
+ return { type: "Integer", value: b.vbCancel };
4481
+ const h = p.trim().toUpperCase();
4482
+ return h === "A" || h === "ABORT" ? { type: "Integer", value: b.vbAbort } : h === "R" || h === "RETRY" ? { type: "Integer", value: b.vbRetry } : h === "I" || h === "IGNORE" || h === "" ? { type: "Integer", value: b.vbIgnore } : { type: "Integer", value: b.vbIgnore };
4483
+ }
4484
+ return alert(c), { type: "Integer", value: b.vbOK };
4255
4485
  };
4256
4486
  }
4257
- function Ke(r) {
4487
+ function et(r) {
4258
4488
  r.functionRegistry.register("MsgBox", (e, t, s) => {
4259
- const n = String(e.value ?? e), a = t ? Number(t.value ?? t) : 0, i = s ? String(s.value ?? s) : null, { buttonType: o, iconType: l, defaultButton: p } = ie(a), h = oe(i, l, n);
4489
+ const n = String(e.value ?? e), a = t ? Number(t.value ?? t) : 0, i = s ? String(s.value ?? s) : null, { buttonType: o, iconType: c, defaultButton: p } = ce(a), h = le(i, c, n);
4260
4490
  if (o === "OK")
4261
4491
  return typeof alert < "u" ? alert(h) : console.log(h), { type: "Integer", value: b.vbOK };
4262
4492
  if (typeof window < "u" && typeof window.confirm == "function") {
4263
- if (o === "OKCancel" || o === "YesNo" || o === "YesNoCancel") {
4264
- const g = confirm(h);
4265
- return o === "OKCancel" ? { type: "Integer", value: g ? b.vbOK : b.vbCancel } : { type: "Integer", value: g ? b.vbYes : b.vbNo };
4493
+ if (o === "OKCancel")
4494
+ return { type: "Integer", value: confirm(h) ? b.vbOK : b.vbCancel };
4495
+ if (o === "YesNo")
4496
+ return { type: "Integer", value: confirm(h + `
4497
+ [OK]=Yes / [Cancel]=No`) ? b.vbYes : b.vbNo };
4498
+ if (o === "YesNoCancel" && typeof window.prompt == "function") {
4499
+ const g = window.prompt(h + `
4500
+
4501
+ Enter: Y (Yes) / N (No) / C (Cancel) or invalid value for cancel`, "");
4502
+ if (g === null)
4503
+ return { type: "Integer", value: b.vbCancel };
4504
+ const v = g.trim().toUpperCase();
4505
+ return v === "Y" || v === "YES" ? { type: "Integer", value: b.vbYes } : v === "N" || v === "NO" ? { type: "Integer", value: b.vbNo } : { type: "Integer", value: b.vbCancel };
4266
4506
  }
4267
4507
  if (o === "RetryCancel")
4268
4508
  return { type: "Integer", value: confirm(h + `
4269
- [R]etry / [C]ancel`) ? b.vbRetry : b.vbCancel };
4270
- if (o === "AbortRetryIgnore")
4271
- return { type: "Integer", value: confirm(h + `
4272
- [A]bort / [R]etry / [I]gnore`) ? b.vbAbort : b.vbRetry };
4509
+ [OK]=Retry / [Cancel]=Cancel`) ? b.vbRetry : b.vbCancel };
4510
+ if (o === "AbortRetryIgnore" && typeof window.prompt == "function") {
4511
+ const g = window.prompt(h + `
4512
+
4513
+ Enter: A (Abort) / R (Retry) / I (Ignore)`, "");
4514
+ if (g === null)
4515
+ return { type: "Integer", value: b.vbCancel };
4516
+ const v = g.trim().toUpperCase();
4517
+ return v === "A" || v === "ABORT" ? { type: "Integer", value: b.vbAbort } : v === "R" || v === "RETRY" ? { type: "Integer", value: b.vbRetry } : v === "I" || v === "IGNORE" || v === "" ? { type: "Integer", value: b.vbIgnore } : { type: "Integer", value: b.vbIgnore };
4518
+ }
4273
4519
  }
4274
4520
  return console.log(h + `
4275
- ` + Ye(o, p).join(" ")), { type: "Integer", value: b.vbCancel };
4521
+ ` + Ze(o, p).join(" ")), { type: "Integer", value: b.vbCancel };
4276
4522
  }, { isSub: !1 });
4277
4523
  }
4278
- function Je() {
4524
+ function tt() {
4279
4525
  return function(r, e, t, s, n, a, i) {
4280
- const o = String(r.value ?? r), l = e ? String(e.value ?? e) : "Input", p = t ? String(t.value ?? t) : "";
4281
- return { type: "String", value: window.prompt(`[${l}]
4526
+ const o = String(r.value ?? r), c = e ? String(e.value ?? e) : "Input", p = t ? String(t.value ?? t) : "";
4527
+ return { type: "String", value: window.prompt(`[${c}]
4282
4528
  ${o}`, p) ?? "" };
4283
4529
  };
4284
4530
  }
4285
- function Xe(r) {
4531
+ function rt(r) {
4286
4532
  r.functionRegistry.register("InputBox", (e, t, s, n, a, i, o) => {
4287
- const l = String(e.value ?? e), p = t ? String(t.value ?? t) : "Input", h = s ? String(s.value ?? s) : "";
4533
+ const c = String(e.value ?? e), p = t ? String(t.value ?? t) : "Input", h = s ? String(s.value ?? s) : "";
4288
4534
  return typeof window < "u" && typeof window.prompt == "function" ? { type: "String", value: window.prompt(`[${p}]
4289
- ${l}`, h) ?? "" } : (console.log(`[${p}]
4290
- ${l}
4535
+ ${c}`, h) ?? "" } : (console.log(`[${p}]
4536
+ ${c}
4291
4537
  Default: ${h}`), { type: "String", value: "" });
4292
4538
  });
4293
4539
  }
4294
- function Ze(r) {
4540
+ function st(r) {
4295
4541
  return {
4296
4542
  type: "Object",
4297
4543
  value: {
@@ -4308,8 +4554,8 @@ function Ze(r) {
4308
4554
  }
4309
4555
  };
4310
4556
  }
4311
- function F(r) {
4312
- const e = r.map(Ze);
4557
+ function j(r) {
4558
+ const e = r.map(st);
4313
4559
  return {
4314
4560
  type: "Object",
4315
4561
  value: {
@@ -4339,7 +4585,7 @@ function F(r) {
4339
4585
  }
4340
4586
  };
4341
4587
  }
4342
- function Q(r) {
4588
+ function te(r) {
4343
4589
  return {
4344
4590
  type: "Object",
4345
4591
  value: {
@@ -4379,20 +4625,20 @@ function Q(r) {
4379
4625
  func: (s) => {
4380
4626
  const n = String(s.value ?? "");
4381
4627
  if (!r.pattern)
4382
- return F([]);
4628
+ return j([]);
4383
4629
  try {
4384
4630
  const a = (r.ignoreCase ? "i" : "") + (r.multiline ? "m" : "") + (r.global ? "g" : ""), i = new RegExp(r.pattern, a), o = [];
4385
- let l;
4386
- for (; (l = i.exec(n)) !== null && (o.push({
4387
- firstIndex: l.index,
4388
- length: l[0].length,
4389
- value: l[0],
4390
- subMatches: l.slice(1).map((p) => p ?? "")
4631
+ let c;
4632
+ for (; (c = i.exec(n)) !== null && (o.push({
4633
+ firstIndex: c.index,
4634
+ length: c[0].length,
4635
+ value: c[0],
4636
+ subMatches: c.slice(1).map((p) => p ?? "")
4391
4637
  }), !!r.global); )
4392
4638
  ;
4393
- return F(o);
4639
+ return j(o);
4394
4640
  } catch {
4395
- return F([]);
4641
+ return j([]);
4396
4642
  }
4397
4643
  }
4398
4644
  };
@@ -4403,8 +4649,8 @@ function Q(r) {
4403
4649
  if (!r.pattern)
4404
4650
  return { type: "String", value: a };
4405
4651
  try {
4406
- const o = (r.ignoreCase ? "i" : "") + (r.multiline ? "m" : "") + (r.global ? "g" : ""), l = new RegExp(r.pattern, o);
4407
- return { type: "String", value: a.replace(l, i) };
4652
+ const o = (r.ignoreCase ? "i" : "") + (r.multiline ? "m" : "") + (r.global ? "g" : ""), c = new RegExp(r.pattern, o);
4653
+ return { type: "String", value: a.replace(c, i) };
4408
4654
  } catch {
4409
4655
  return { type: "String", value: a };
4410
4656
  }
@@ -4415,35 +4661,35 @@ function Q(r) {
4415
4661
  }
4416
4662
  };
4417
4663
  }
4418
- function Qe(r) {
4419
- r.classRegistry.registerClass("RegExp", () => Q({
4664
+ function nt(r) {
4665
+ r.classRegistry.registerClass("RegExp", () => te({
4420
4666
  pattern: "",
4421
4667
  global: !1,
4422
4668
  ignoreCase: !1,
4423
4669
  multiline: !1
4424
- })), r.functionRegistry.register("RegExp", () => Q({
4670
+ })), r.functionRegistry.register("RegExp", () => te({
4425
4671
  pattern: "",
4426
4672
  global: !1,
4427
4673
  ignoreCase: !1,
4428
4674
  multiline: !1
4429
4675
  }));
4430
4676
  }
4431
- function et(r) {
4432
- Object.entries(We).forEach(([t, s]) => {
4677
+ function at(r) {
4678
+ Object.entries(qe).forEach(([t, s]) => {
4433
4679
  r.functionRegistry.register(t, s);
4434
- }), Object.entries(Ge).forEach(([t, s]) => {
4680
+ }), Object.entries(ze).forEach(([t, s]) => {
4435
4681
  r.functionRegistry.register(t, s);
4436
- }), Object.entries(_e).forEach(([t, s]) => {
4682
+ }), Object.entries($e).forEach(([t, s]) => {
4437
4683
  r.functionRegistry.register(t, s);
4438
- }), Object.entries(qe).forEach(([t, s]) => {
4684
+ }), Object.entries(He).forEach(([t, s]) => {
4439
4685
  r.functionRegistry.register(t, s);
4440
- }), Object.entries(Ue).forEach(([t, s]) => {
4686
+ }), Object.entries(Ke).forEach(([t, s]) => {
4441
4687
  r.functionRegistry.register(t, s);
4442
- }), Object.entries(ze).forEach(([t, s]) => {
4688
+ }), Object.entries(Je).forEach(([t, s]) => {
4443
4689
  r.functionRegistry.register(t, s);
4444
- }), Object.entries(Te).forEach(([t, s]) => {
4690
+ }), Object.entries(Ye).forEach(([t, s]) => {
4445
4691
  r.globalScope.declare(t, s);
4446
- }), Ke(r), Xe(r), Qe(r), Object.entries(Ae).forEach(([t, s]) => {
4692
+ }), et(r), rt(r), nt(r), Object.entries(We).forEach(([t, s]) => {
4447
4693
  r.functionRegistry.register(t, s);
4448
4694
  }), r.functionRegistry.register("ScriptEngine", () => ({ type: "String", value: "VBScript" })), r.functionRegistry.register("ScriptEngineMajorVersion", () => ({ type: "Integer", value: 10 })), r.functionRegistry.register("ScriptEngineMinorVersion", () => ({ type: "Integer", value: 8 })), r.functionRegistry.register("ScriptEngineBuildVersion", () => ({ type: "Long", value: 16384 })), r.functionRegistry.register("Eval", (t) => {
4449
4695
  const s = String(t.value ?? t);
@@ -4584,13 +4830,13 @@ function et(r) {
4584
4830
  };
4585
4831
  r.globalScope.declare("Err", { type: "Object", value: e });
4586
4832
  }
4587
- class tt {
4833
+ class it {
4588
4834
  context;
4589
4835
  executor;
4590
4836
  maxExecutionTime = -1;
4591
4837
  startTime = 0;
4592
4838
  constructor() {
4593
- this.context = new Ne(), this.executor = new Oe(this.context), et(this.context);
4839
+ this.context = new Oe(), this.executor = new Re(this.context), at(this.context);
4594
4840
  }
4595
4841
  setMaxExecutionTime(e) {
4596
4842
  this.maxExecutionTime = e;
@@ -4621,11 +4867,11 @@ class tt {
4621
4867
  if (o++ > i)
4622
4868
  throw new Error("Possible infinite loop detected (too many goto jumps)");
4623
4869
  this.checkTimeout();
4624
- const l = s[a];
4870
+ const c = s[a];
4625
4871
  try {
4626
- t = this.executor.execute(l), a++;
4872
+ t = this.executor.execute(c), a++;
4627
4873
  } catch (p) {
4628
- if (p instanceof _) {
4874
+ if (p instanceof U) {
4629
4875
  const h = n.get(p.labelName);
4630
4876
  if (h) {
4631
4877
  a = h.index + 1;
@@ -4649,8 +4895,8 @@ class tt {
4649
4895
  }
4650
4896
  evaluate(e) {
4651
4897
  try {
4652
- const t = A(e);
4653
- return new ne(this.context).evaluateProgram(t);
4898
+ const t = R(e);
4899
+ return new ie(this.context).evaluateProgram(t);
4654
4900
  } catch (t) {
4655
4901
  return console.error("Eval error:", t), { type: "Empty", value: void 0 };
4656
4902
  }
@@ -4670,29 +4916,29 @@ class tt {
4670
4916
  const o = e[n];
4671
4917
  try {
4672
4918
  s = this.executor.execute(o), n++;
4673
- } catch (l) {
4674
- if (l instanceof _) {
4675
- const p = t.get(l.labelName);
4919
+ } catch (c) {
4920
+ if (c instanceof U) {
4921
+ const p = t.get(c.labelName);
4676
4922
  if (p) {
4677
4923
  n = p.index + 1;
4678
4924
  continue;
4679
4925
  }
4680
- throw new Error(`Label not found: ${l.labelName}`);
4926
+ throw new Error(`Label not found: ${c.labelName}`);
4681
4927
  }
4682
- throw l instanceof E, l;
4928
+ throw c instanceof E, c;
4683
4929
  }
4684
4930
  }
4685
4931
  return s;
4686
4932
  }
4687
4933
  executeInCurrentScope(e) {
4688
- const t = A(e);
4934
+ const t = R(e);
4689
4935
  return this.executeStatements(t.body);
4690
4936
  }
4691
4937
  executeInGlobalScope(e) {
4692
4938
  const t = this.context.currentScope;
4693
4939
  this.context.currentScope = this.context.globalScope;
4694
4940
  try {
4695
- const s = A(e);
4941
+ const s = R(e);
4696
4942
  return this.executeStatements(s.body);
4697
4943
  } finally {
4698
4944
  this.context.currentScope = t;
@@ -4720,39 +4966,39 @@ function D(r) {
4720
4966
  return r.value;
4721
4967
  }
4722
4968
  }
4723
- function j(r, e) {
4969
+ function T(r, e) {
4724
4970
  return r === void 0 ? { type: "Empty", value: void 0 } : r === null ? { type: "Null", value: null } : typeof r == "boolean" ? { type: "Boolean", value: r } : typeof r == "number" ? Number.isInteger(r) && r >= -2147483648 && r <= 2147483647 ? { type: "Long", value: r } : { type: "Double", value: r } : typeof r == "string" ? { type: "String", value: r } : r instanceof Date ? { type: "Date", value: r } : Array.isArray(r) ? { type: "Array", value: r } : typeof r == "function" ? { type: "Object", value: { type: "jsfunction", func: r, thisArg: e ?? null } } : typeof r == "object" ? { type: "Object", value: r } : { type: "String", value: String(r) };
4725
4971
  }
4726
- function ee(r) {
4972
+ function re(r) {
4727
4973
  if (typeof window > "u")
4728
4974
  return { originalSetTimeout: null, originalSetInterval: null };
4729
4975
  const e = window.setTimeout, t = window.setInterval;
4730
4976
  return window.setTimeout = function(s, n, a, ...i) {
4731
4977
  if (typeof s == "string") {
4732
- const o = typeof a == "string" ? a.toLowerCase() : null, l = typeof n == "number" ? n : 0;
4978
+ const o = typeof a == "string" ? a.toLowerCase() : null, c = typeof n == "number" ? n : 0;
4733
4979
  return o === "vbscript" || o === "vbs" ? e.call(window, () => {
4734
4980
  r._getContext()?.functionRegistry?.has(s) ? r.run(s) : r.executeStatement(s);
4735
- }, l) : e.call(window, () => {
4981
+ }, c) : e.call(window, () => {
4736
4982
  r._getContext()?.functionRegistry?.has(s) ? r.run(s) : r.executeStatement(s);
4737
- }, l);
4983
+ }, c);
4738
4984
  }
4739
4985
  return e.call(window, s, n, ...[a, ...i].filter((o) => o !== void 0));
4740
4986
  }, window.setInterval = function(s, n, a, ...i) {
4741
4987
  if (typeof s == "string") {
4742
- const o = typeof a == "string" ? a.toLowerCase() : null, l = typeof n == "number" ? n : 0;
4988
+ const o = typeof a == "string" ? a.toLowerCase() : null, c = typeof n == "number" ? n : 0;
4743
4989
  return o === "vbscript" || o === "vbs" ? t.call(window, () => {
4744
4990
  r._getContext()?.functionRegistry?.has(s) ? r.run(s) : r.executeStatement(s);
4745
- }, l) : t.call(window, () => {
4991
+ }, c) : t.call(window, () => {
4746
4992
  r._getContext()?.functionRegistry?.has(s) ? r.run(s) : r.executeStatement(s);
4747
- }, l);
4993
+ }, c);
4748
4994
  }
4749
4995
  return t.call(window, s, n, ...[a, ...i].filter((o) => o !== void 0));
4750
4996
  }, { originalSetTimeout: e, originalSetInterval: t };
4751
4997
  }
4752
- function rt(r) {
4998
+ function ot(r) {
4753
4999
  typeof window > "u" || (r.originalSetTimeout && (window.setTimeout = r.originalSetTimeout), r.originalSetInterval && (window.setInterval = r.originalSetInterval));
4754
5000
  }
4755
- function st(r) {
5001
+ function ct(r) {
4756
5002
  if (typeof window > "u")
4757
5003
  return { originalEval: null };
4758
5004
  const e = window.eval;
@@ -4767,10 +5013,10 @@ function st(r) {
4767
5013
  return e.call(window, String(t));
4768
5014
  }, { originalEval: e };
4769
5015
  }
4770
- function nt(r) {
5016
+ function lt(r) {
4771
5017
  typeof window > "u" || (r.originalEval && (window.eval = r.originalEval), delete window.vbsEval);
4772
5018
  }
4773
- function at(r) {
5019
+ function ut(r) {
4774
5020
  if (typeof window > "u")
4775
5021
  return { navigateHandler: null, clickHandler: null };
4776
5022
  let e = null, t = null;
@@ -4801,10 +5047,10 @@ function at(r) {
4801
5047
  }
4802
5048
  }, document.addEventListener("click", t, !0)), { navigateHandler: e, clickHandler: t };
4803
5049
  }
4804
- function it(r) {
5050
+ function pt(r) {
4805
5051
  typeof window > "u" || (r.navigateHandler && "navigation" in window && window.navigation && window.navigation.removeEventListener("navigate", r.navigateHandler), r.clickHandler && document.removeEventListener("click", r.clickHandler, !0));
4806
5052
  }
4807
- function ot(r, e) {
5053
+ function ht(r, e) {
4808
5054
  const t = String(r.value ?? r), s = window.ActiveXObject;
4809
5055
  if (s)
4810
5056
  try {
@@ -4818,7 +5064,7 @@ function ot(r, e) {
4818
5064
  }
4819
5065
  throw new Error(`ActiveXObject is not supported in this browser environment. Cannot create: '${t}'`);
4820
5066
  }
4821
- function ct(r, e) {
5067
+ function ft(r, e) {
4822
5068
  const t = window.ActiveXObject;
4823
5069
  if (t) {
4824
5070
  const n = r ? String(r.value ?? r) : "", a = e ? String(e.value ?? e) : "";
@@ -4836,13 +5082,21 @@ function ct(r, e) {
4836
5082
  const s = e ? String(e.value ?? e) : "";
4837
5083
  throw new Error(`ActiveXObject is not supported in this browser environment. Cannot get: '${s}'`);
4838
5084
  }
4839
- function z(r) {
5085
+ function Y(r) {
4840
5086
  const e = r.getAttribute("language"), t = r.getAttribute("type");
4841
- return e?.toLowerCase() === "vbscript" || t?.toLowerCase() === "text/vbscript" || t?.toLowerCase() === "application/x-vbscript";
5087
+ return e?.toLowerCase() === "vbscript" || t?.toLowerCase() === "text/vbscript" || t?.toLowerCase() === "text/vbs" || t?.toLowerCase() === "application/x-vbscript";
4842
5088
  }
4843
- function lt(r, e, t) {
4844
- if (!z(e)) return;
4845
- const s = e.textContent ?? "", n = e.getAttribute("for"), a = e.getAttribute("event");
5089
+ function yt(r) {
5090
+ let e = r.textContent ?? "";
5091
+ if (e = e.trim(), e.startsWith("<!--")) {
5092
+ const t = e.indexOf("//-->");
5093
+ t !== -1 ? e = e.substring(4, t).trim() : e.endsWith("-->") && (e = e.substring(4, e.length - 3).trim());
5094
+ }
5095
+ return e;
5096
+ }
5097
+ function mt(r, e, t) {
5098
+ if (!Y(e)) return;
5099
+ const s = yt(e), n = e.getAttribute("for"), a = e.getAttribute("event");
4846
5100
  if (n && a)
4847
5101
  $(r, n, a, s);
4848
5102
  else
@@ -4859,8 +5113,8 @@ function $(r, e, t, s) {
4859
5113
  const o = () => {
4860
5114
  try {
4861
5115
  r.addCode(s);
4862
- } catch (l) {
4863
- console.error("VBScript event handler error:", l);
5116
+ } catch (c) {
5117
+ console.error("VBScript event handler error:", c);
4864
5118
  }
4865
5119
  };
4866
5120
  return i.addEventListener(n, o), !0;
@@ -4871,13 +5125,13 @@ function $(r, e, t, s) {
4871
5125
  a();
4872
5126
  }) : setTimeout(a, 0));
4873
5127
  }
4874
- function ut(r, e) {
5128
+ function gt(r, e) {
4875
5129
  if (typeof document > "u") return;
4876
5130
  document.querySelectorAll("script").forEach((s) => {
4877
- lt(r, s, e);
5131
+ mt(r, s, e);
4878
5132
  });
4879
5133
  }
4880
- function Y(r, e) {
5134
+ function H(r, e) {
4881
5135
  const t = e.attributes;
4882
5136
  for (let s = 0; s < t.length; s++) {
4883
5137
  const n = t[s];
@@ -4890,21 +5144,21 @@ function Y(r, e) {
4890
5144
  e[a] = () => {
4891
5145
  try {
4892
5146
  r.executeStatement(o);
4893
- } catch (l) {
4894
- console.error("VBScript event handler error:", l);
5147
+ } catch (c) {
5148
+ console.error("VBScript event handler error:", c);
4895
5149
  }
4896
5150
  };
4897
5151
  }
4898
5152
  }
4899
5153
  }
4900
5154
  }
4901
- function pt(r) {
5155
+ function vt(r) {
4902
5156
  if (typeof document > "u") return;
4903
5157
  document.querySelectorAll("*").forEach((t) => {
4904
- Y(r, t);
5158
+ H(r, t);
4905
5159
  });
4906
5160
  }
4907
- function ht(r) {
5161
+ function bt(r) {
4908
5162
  if (r in globalThis) {
4909
5163
  const t = globalThis[r];
4910
5164
  if (t && typeof t.addEventListener == "function")
@@ -4938,8 +5192,8 @@ function V(r, e) {
4938
5192
  for (const [n] of s) {
4939
5193
  const a = n.toLowerCase().indexOf("_on");
4940
5194
  if (a > 0) {
4941
- const i = n.substring(0, a), o = n.substring(a + 3), l = ht(i);
4942
- if (l) {
5195
+ const i = n.substring(0, a), o = n.substring(a + 3), c = bt(i);
5196
+ if (c) {
4943
5197
  const p = o.toLowerCase();
4944
5198
  if (e.has(n)) {
4945
5199
  const g = e.get(n);
@@ -4952,12 +5206,12 @@ function V(r, e) {
4952
5206
  console.error(`VBScript ${n} error:`, g);
4953
5207
  }
4954
5208
  };
4955
- l.addEventListener(p, h), e.set(n, { target: l, handler: h });
5209
+ c.addEventListener(p, h), e.set(n, { target: c, handler: h });
4956
5210
  }
4957
5211
  }
4958
5212
  }
4959
5213
  }
4960
- function ft(r) {
5214
+ function dt(r) {
4961
5215
  r.forEach(({ target: e, handler: t }, s) => {
4962
5216
  const n = s.toLowerCase().indexOf("_on");
4963
5217
  if (n > 0) {
@@ -4966,25 +5220,25 @@ function ft(r) {
4966
5220
  }
4967
5221
  }), r.clear();
4968
5222
  }
4969
- function yt(r, e, t) {
5223
+ function St(r, e, t) {
4970
5224
  const s = new MutationObserver((n) => {
4971
5225
  n.forEach((a) => {
4972
5226
  a.addedNodes.forEach((i) => {
4973
5227
  if (i.nodeType === Node.ELEMENT_NODE) {
4974
5228
  const o = i;
4975
- if (e.parseScriptElement && o.tagName.toLowerCase() === "script" && z(o)) {
4976
- const l = o.textContent ?? "", p = o.getAttribute("for"), h = o.getAttribute("event");
5229
+ if (e.parseScriptElement && o.tagName.toLowerCase() === "script" && Y(o)) {
5230
+ const c = o.textContent ?? "", p = o.getAttribute("for"), h = o.getAttribute("event");
4977
5231
  if (p && h)
4978
- $(r, p, h, l);
5232
+ $(r, p, h, c);
4979
5233
  else
4980
5234
  try {
4981
- r.addCode(l), e.injectGlobalThis && e.parseEventSubNames && V(r, t);
5235
+ r.addCode(c), e.injectGlobalThis && e.parseEventSubNames && V(r, t);
4982
5236
  } catch (g) {
4983
5237
  console.error("Vbscript error:", g);
4984
5238
  }
4985
5239
  }
4986
- e.parseInlineEventAttributes && Y(r, o), e.parseScriptElement && o.querySelectorAll("script").forEach((p) => {
4987
- if (z(p)) {
5240
+ e.parseInlineEventAttributes && H(r, o), e.parseScriptElement && o.querySelectorAll("script").forEach((p) => {
5241
+ if (Y(p)) {
4988
5242
  const h = p.textContent ?? "", g = p.getAttribute("for"), v = p.getAttribute("event");
4989
5243
  if (g && v)
4990
5244
  $(r, g, v, h);
@@ -4996,7 +5250,7 @@ function yt(r, e, t) {
4996
5250
  }
4997
5251
  }
4998
5252
  }), e.parseInlineEventAttributes && o.querySelectorAll("*").forEach((p) => {
4999
- Y(r, p);
5253
+ H(r, p);
5000
5254
  });
5001
5255
  }
5002
5256
  });
@@ -5007,20 +5261,20 @@ function yt(r, e, t) {
5007
5261
  subtree: !0
5008
5262
  }), { observer: s };
5009
5263
  }
5010
- function mt(r) {
5264
+ function wt(r) {
5011
5265
  r.observer.disconnect();
5012
5266
  }
5013
- function gt(r, e) {
5267
+ function xt(r, e) {
5014
5268
  const t = { originalSetTimeout: null, originalSetInterval: null }, s = { originalEval: null };
5015
5269
  let n = { navigateHandler: null, clickHandler: null }, a = null;
5016
5270
  const i = /* @__PURE__ */ new Map();
5017
- return r._registerFunction("MsgBox", He()), r._registerFunction("InputBox", Je()), r._registerFunction("CreateObject", ot), r._registerFunction("GetObject", ct), e.overrideJSEvalFunctions && (t.originalSetTimeout = ee(r).originalSetTimeout, t.originalSetInterval = ee(r).originalSetInterval, s.originalEval = st(r).originalEval), e.parseVbsProtocol && (n = at(r)), e.parseScriptElement && ut(r), e.parseInlineEventAttributes && pt(r), e.injectGlobalThis && e.parseEventSubNames && V(r, i), (e.parseScriptElement || e.parseInlineEventAttributes) && (a = yt(r, e, i)), document.readyState === "loading" && document.addEventListener("DOMContentLoaded", () => {
5271
+ return r._registerFunction("MsgBox", Qe()), r._registerFunction("InputBox", tt()), r._registerFunction("CreateObject", ht), r._registerFunction("GetObject", ft), e.overrideJsEvalFunctions && (t.originalSetTimeout = re(r).originalSetTimeout, t.originalSetInterval = re(r).originalSetInterval, s.originalEval = ct(r).originalEval), e.parseVbsProtocol && (n = ut(r)), e.parseScriptElement && gt(r), e.parseInlineEventAttributes && vt(r), e.injectGlobalThis && e.parseEventSubNames && V(r, i), (e.parseScriptElement || e.parseInlineEventAttributes) && (a = St(r, e, i)), document.readyState === "loading" && document.addEventListener("DOMContentLoaded", () => {
5018
5272
  e.injectGlobalThis && e.parseEventSubNames && V(r, i);
5019
5273
  }), () => {
5020
- a && mt(a), ft(i), (n.navigateHandler || n.clickHandler) && it(n), e.overrideJSEvalFunctions && (rt(t), nt(s));
5274
+ a && wt(a), dt(i), (n.navigateHandler || n.clickHandler) && pt(n), e.overrideJsEvalFunctions && (ot(t), lt(s));
5021
5275
  };
5022
5276
  }
5023
- class vt {
5277
+ class Et {
5024
5278
  interpreter;
5025
5279
  options;
5026
5280
  browserCleanup = null;
@@ -5033,12 +5287,12 @@ class vt {
5033
5287
  parseScriptElement: e.parseScriptElement ?? !0,
5034
5288
  parseInlineEventAttributes: e.parseInlineEventAttributes ?? !0,
5035
5289
  parseEventSubNames: e.parseEventSubNames ?? !0,
5036
- overrideJSEvalFunctions: e.overrideJSEvalFunctions ?? !0,
5290
+ overrideJsEvalFunctions: e.overrideJsEvalFunctions ?? !0,
5037
5291
  parseVbsProtocol: e.parseVbsProtocol ?? !0
5038
- }, this.interpreter = new tt(), this.interpreter.getContext().evaluate = (t) => this.interpreter.evaluate(t), this.interpreter.getContext().execute = (t) => this.interpreter.executeInCurrentScope(t), this.interpreter.getContext().executeGlobal = (t) => this.interpreter.executeInGlobalScope(t), this.options.maxExecutionTime > 0 && this.setMaxExecutionTime(this.options.maxExecutionTime), this.options.mode === "browser" && typeof window < "u" && this.initializeBrowserMode();
5292
+ }, this.interpreter = new it(), this.interpreter.getContext().evaluate = (t) => this.interpreter.evaluate(t), this.interpreter.getContext().execute = (t) => this.interpreter.executeInCurrentScope(t), this.interpreter.getContext().executeGlobal = (t) => this.interpreter.executeInGlobalScope(t), this.options.maxExecutionTime > 0 && this.setMaxExecutionTime(this.options.maxExecutionTime), this.options.mode === "browser" && typeof window < "u" && this.initializeBrowserMode();
5039
5293
  }
5040
5294
  initializeBrowserMode() {
5041
- this.browserCleanup = gt(this, this.options);
5295
+ this.browserCleanup = xt(this, this.options);
5042
5296
  }
5043
5297
  setMaxExecutionTime(e) {
5044
5298
  this.interpreter.setMaxExecutionTime(e), this.interpreter.getContext().checkTimeout = () => this.interpreter.checkTimeout();
@@ -5080,8 +5334,12 @@ class vt {
5080
5334
  addCode(e) {
5081
5335
  this.clearError();
5082
5336
  try {
5083
- const s = new W(e).tokenize(), a = new G(s).parse();
5084
- this.interpreter.run(a), this.syncFunctionsToGlobalThis();
5337
+ let t = O.get(e);
5338
+ if (!t) {
5339
+ const n = new W(e).tokenize();
5340
+ t = new G(n).parse(), O.set(e, t);
5341
+ }
5342
+ this.interpreter.run(t), this.syncFunctionsToGlobalThis();
5085
5343
  } catch (t) {
5086
5344
  this.handleError(t);
5087
5345
  }
@@ -5100,8 +5358,12 @@ class vt {
5100
5358
  executeStatement(e) {
5101
5359
  this.clearError();
5102
5360
  try {
5103
- const s = new W(e).tokenize(), a = new G(s).parse();
5104
- this.interpreter.run(a);
5361
+ let t = O.get(e);
5362
+ if (!t) {
5363
+ const n = new W(e).tokenize();
5364
+ t = new G(n).parse(), O.set(e, t);
5365
+ }
5366
+ this.interpreter.run(t);
5105
5367
  } catch (t) {
5106
5368
  this.handleError(t);
5107
5369
  }
@@ -5122,7 +5384,7 @@ class vt {
5122
5384
  run(e, ...t) {
5123
5385
  this.clearError();
5124
5386
  try {
5125
- const n = this.interpreter.getContext().functionRegistry, a = t.map((o) => j(o)), i = n.call(e, a);
5387
+ const n = this.interpreter.getContext().functionRegistry, a = t.map((o) => T(o)), i = n.call(e, a);
5126
5388
  return D(i);
5127
5389
  } catch (s) {
5128
5390
  this.handleError(s);
@@ -5156,14 +5418,14 @@ class vt {
5156
5418
  addObject(e, t, s = !0) {
5157
5419
  this.clearError();
5158
5420
  try {
5159
- const n = j(t);
5421
+ const n = T(t);
5160
5422
  if (this.interpreter.setVariable(e, n), s && typeof t == "object" && t !== null) {
5161
5423
  const a = t;
5162
5424
  for (const i of Object.keys(a)) {
5163
- const o = `${e}.${i}`, l = a[i];
5164
- typeof l == "function" && this.interpreter.registerFunction(o, (...p) => {
5165
- const h = p.map(D), g = l(...h);
5166
- return j(g);
5425
+ const o = `${e}.${i}`, c = a[i];
5426
+ typeof c == "function" && this.interpreter.registerFunction(o, (...p) => {
5427
+ const h = p.map(D), g = c(...h);
5428
+ return T(g);
5167
5429
  });
5168
5430
  }
5169
5431
  }
@@ -5247,13 +5509,13 @@ class vt {
5247
5509
  }
5248
5510
  }
5249
5511
  }
5250
- function bt(r) {
5251
- return new vt().eval(r);
5512
+ function Ct(r) {
5513
+ return new Et().eval(r);
5252
5514
  }
5253
5515
  export {
5254
- vt as VbsEngine,
5255
- bt as evalVbscript,
5256
- j as jsToVb,
5516
+ Et as VbsEngine,
5517
+ Ct as evalVbscript,
5518
+ T as jsToVb,
5257
5519
  D as vbToJs
5258
5520
  };
5259
5521
  //# sourceMappingURL=vbs-engine.js.map