@alcyone-labs/arg-parser 2.13.5 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,22 @@
1
1
  import * as fs from "node:fs";
2
+ import { existsSync, lstatSync, readdirSync } from "node:fs";
2
3
  import * as path from "node:path";
4
+ import { dirname, join } from "node:path";
3
5
  import { fileURLToPath } from "node:url";
4
6
  import { anyOf, char, createRegExp, oneOrMore } from "magic-regexp";
5
7
  import { Logger, createCliLogger, createMcpLogger, createMcpLogger as createMcpLogger$1, logger } from "@alcyone-labs/simple-mcp-logger";
6
8
  import { createPathsMatcher, getTsconfig } from "get-tsconfig";
7
9
  import * as os from "node:os";
8
10
  import { z } from "zod";
11
+ import P, { stdin, stdout } from "node:process";
12
+ import * as k$1 from "node:readline";
13
+ import ot from "node:readline";
14
+ import { ReadStream } from "node:tty";
15
+ var __create = Object.create;
9
16
  var __defProp$1 = Object.defineProperty;
10
17
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
11
18
  var __getOwnPropNames$1 = Object.getOwnPropertyNames;
19
+ var __getProtoOf = Object.getPrototypeOf;
12
20
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
13
21
  var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
14
22
  var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
@@ -25,16 +33,20 @@ var __copyProps$1 = (to, from, except, desc) => {
25
33
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) {
26
34
  key = keys[i];
27
35
  if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, {
28
- get: ((k) => from[k]).bind(null, key),
36
+ get: ((k$2) => from[k$2]).bind(null, key),
29
37
  enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable
30
38
  });
31
39
  }
32
40
  return to;
33
41
  };
42
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
43
+ value: mod,
44
+ enumerable: true
45
+ }) : target, mod));
34
46
  var __toCommonJS$1 = (mod) => __hasOwnProp$1.call(mod, "module.exports") ? mod["module.exports"] : __copyProps$1(__defProp$1({}, "__esModule", { value: true }), mod);
35
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
47
+ var __require = /* @__PURE__ */ ((x$3) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x$3, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x$3)(function(x$3) {
36
48
  if (typeof require !== "undefined") return require.apply(this, arguments);
37
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
49
+ throw Error("Calling `require` for \"" + x$3 + "\" in an environment that doesn't expose the `require` function.");
38
50
  });
39
51
  var RESET$1 = "\x1B[0m";
40
52
  var BOLD$1 = "\x1B[1m";
@@ -766,18 +778,18 @@ ${codeblock}`, options);
766
778
  });
767
779
  else if (c === "#") ptr = skipComment$1(str, ptr);
768
780
  else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
769
- let k;
770
- let t = res;
781
+ let k$2;
782
+ let t$1 = res;
771
783
  let hasOwn = false;
772
784
  let [key, keyEndPtr] = parseKey$1(str, ptr - 1);
773
785
  for (let i = 0; i < key.length; i++) {
774
- if (i) t = hasOwn ? t[k] : t[k] = {};
775
- k = key[i];
776
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError$1("trying to redefine an already defined value", {
786
+ if (i) t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
787
+ k$2 = key[i];
788
+ if ((hasOwn = Object.hasOwn(t$1, k$2)) && (typeof t$1[k$2] !== "object" || seen.has(t$1[k$2]))) throw new TomlError$1("trying to redefine an already defined value", {
777
789
  toml: str,
778
790
  ptr
779
791
  });
780
- if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
792
+ if (!hasOwn && k$2 === "__proto__") Object.defineProperty(t$1, k$2, {
781
793
  enumerable: true,
782
794
  configurable: true,
783
795
  writable: true
@@ -789,7 +801,7 @@ ${codeblock}`, options);
789
801
  });
790
802
  let [value, valueEndPtr] = extractValue$1(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
791
803
  seen.add(value);
792
- t[k] = value;
804
+ t$1[k$2] = value;
793
805
  ptr = valueEndPtr;
794
806
  }
795
807
  if (!c) throw new TomlError$1("unfinished table encountered", {
@@ -819,38 +831,38 @@ ${codeblock}`, options);
819
831
  return [res, ptr];
820
832
  }
821
833
  function peekTable$1(key, table, meta, type) {
822
- let t = table;
834
+ let t$1 = table;
823
835
  let m = meta;
824
- let k;
836
+ let k$2;
825
837
  let hasOwn = false;
826
838
  let state;
827
839
  for (let i = 0; i < key.length; i++) {
828
840
  if (i) {
829
- t = hasOwn ? t[k] : t[k] = {};
830
- m = (state = m[k]).c;
841
+ t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
842
+ m = (state = m[k$2]).c;
831
843
  if (type === 0 && (state.t === 1 || state.t === 2)) return null;
832
844
  if (state.t === 2) {
833
- let l = t.length - 1;
834
- t = t[l];
845
+ let l = t$1.length - 1;
846
+ t$1 = t$1[l];
835
847
  m = m[l].c;
836
848
  }
837
849
  }
838
- k = key[i];
839
- if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
850
+ k$2 = key[i];
851
+ if ((hasOwn = Object.hasOwn(t$1, k$2)) && m[k$2]?.t === 0 && m[k$2]?.d) return null;
840
852
  if (!hasOwn) {
841
- if (k === "__proto__") {
842
- Object.defineProperty(t, k, {
853
+ if (k$2 === "__proto__") {
854
+ Object.defineProperty(t$1, k$2, {
843
855
  enumerable: true,
844
856
  configurable: true,
845
857
  writable: true
846
858
  });
847
- Object.defineProperty(m, k, {
859
+ Object.defineProperty(m, k$2, {
848
860
  enumerable: true,
849
861
  configurable: true,
850
862
  writable: true
851
863
  });
852
864
  }
853
- m[k] = {
865
+ m[k$2] = {
854
866
  t: i < key.length - 1 && type === 2 ? 3 : type,
855
867
  d: false,
856
868
  i: 0,
@@ -858,14 +870,14 @@ ${codeblock}`, options);
858
870
  };
859
871
  }
860
872
  }
861
- state = m[k];
873
+ state = m[k$2];
862
874
  if (state.t !== type && !(type === 1 && state.t === 3)) return null;
863
875
  if (type === 2) {
864
876
  if (!state.d) {
865
877
  state.d = true;
866
- t[k] = [];
878
+ t$1[k$2] = [];
867
879
  }
868
- t[k].push(t = {});
880
+ t$1[k$2].push(t$1 = {});
869
881
  state.c[state.i++] = state = {
870
882
  t: 1,
871
883
  d: false,
@@ -875,11 +887,11 @@ ${codeblock}`, options);
875
887
  }
876
888
  if (state.d) return null;
877
889
  state.d = true;
878
- if (type === 1) t = hasOwn ? t[k] : t[k] = {};
890
+ if (type === 1) t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
879
891
  else if (type === 0 && hasOwn) return null;
880
892
  return [
881
- k,
882
- t,
893
+ k$2,
894
+ t$1,
883
895
  state.c
884
896
  ];
885
897
  }
@@ -891,30 +903,30 @@ ${codeblock}`, options);
891
903
  for (let ptr = skipVoid$1(toml, 0); ptr < toml.length;) {
892
904
  if (toml[ptr] === "[") {
893
905
  let isTableArray = toml[++ptr] === "[";
894
- let k = parseKey$1(toml, ptr += +isTableArray, "]");
906
+ let k$2 = parseKey$1(toml, ptr += +isTableArray, "]");
895
907
  if (isTableArray) {
896
- if (toml[k[1] - 1] !== "]") throw new TomlError$1("expected end of table declaration", {
908
+ if (toml[k$2[1] - 1] !== "]") throw new TomlError$1("expected end of table declaration", {
897
909
  toml,
898
- ptr: k[1] - 1
910
+ ptr: k$2[1] - 1
899
911
  });
900
- k[1]++;
912
+ k$2[1]++;
901
913
  }
902
- let p = peekTable$1(k[0], res, meta, isTableArray ? 2 : 1);
914
+ let p = peekTable$1(k$2[0], res, meta, isTableArray ? 2 : 1);
903
915
  if (!p) throw new TomlError$1("trying to redefine an already defined table or value", {
904
916
  toml,
905
917
  ptr
906
918
  });
907
919
  m = p[2];
908
920
  tbl = p[1];
909
- ptr = k[1];
921
+ ptr = k$2[1];
910
922
  } else {
911
- let k = parseKey$1(toml, ptr);
912
- let p = peekTable$1(k[0], tbl, m, 0);
923
+ let k$2 = parseKey$1(toml, ptr);
924
+ let p = peekTable$1(k$2[0], tbl, m, 0);
913
925
  if (!p) throw new TomlError$1("trying to redefine an already defined table or value", {
914
926
  toml,
915
927
  ptr
916
928
  });
917
- let v = extractValue$1(toml, k[1], void 0, maxDepth, integersAsBigInt);
929
+ let v = extractValue$1(toml, k$2[1], void 0, maxDepth, integersAsBigInt);
918
930
  p[1][p[0]] = v[0];
919
931
  ptr = v[1];
920
932
  }
@@ -966,11 +978,11 @@ ${codeblock}`, options);
966
978
  if (keys.length === 0) return "{}";
967
979
  let res = "{ ";
968
980
  for (let i = 0; i < keys.length; i++) {
969
- let k = keys[i];
981
+ let k$2 = keys[i];
970
982
  if (i) res += ", ";
971
- res += BARE_KEY$1.test(k) ? k : formatString$1(k);
983
+ res += BARE_KEY$1.test(k$2) ? k$2 : formatString$1(k$2);
972
984
  res += " = ";
973
- res += stringifyValue$1(obj[k], extendedTypeOf$1(obj[k]), depth - 1, numberAsFloat);
985
+ res += stringifyValue$1(obj[k$2], extendedTypeOf$1(obj[k$2]), depth - 1, numberAsFloat);
974
986
  }
975
987
  return res + " }";
976
988
  }
@@ -1000,19 +1012,19 @@ ${codeblock}`, options);
1000
1012
  let tables = "";
1001
1013
  let keys = Object.keys(obj);
1002
1014
  for (let i = 0; i < keys.length; i++) {
1003
- let k = keys[i];
1004
- if (obj[k] !== null && obj[k] !== void 0) {
1005
- let type = extendedTypeOf$1(obj[k]);
1015
+ let k$2 = keys[i];
1016
+ if (obj[k$2] !== null && obj[k$2] !== void 0) {
1017
+ let type = extendedTypeOf$1(obj[k$2]);
1006
1018
  if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
1007
- let key = BARE_KEY$1.test(k) ? k : formatString$1(k);
1008
- if (type === "array" && isArrayOfTables$1(obj[k])) tables += (tables && "\n") + stringifyArrayTable$1(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
1019
+ let key = BARE_KEY$1.test(k$2) ? k$2 : formatString$1(k$2);
1020
+ if (type === "array" && isArrayOfTables$1(obj[k$2])) tables += (tables && "\n") + stringifyArrayTable$1(obj[k$2], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
1009
1021
  else if (type === "object") {
1010
1022
  let tblKey = prefix ? `${prefix}.${key}` : key;
1011
- tables += (tables && "\n") + stringifyTable$1(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
1023
+ tables += (tables && "\n") + stringifyTable$1(tblKey, obj[k$2], tblKey, depth - 1, numberAsFloat);
1012
1024
  } else {
1013
1025
  preamble += key;
1014
1026
  preamble += " = ";
1015
- preamble += stringifyValue$1(obj[k], type, depth, numberAsFloat);
1027
+ preamble += stringifyValue$1(obj[k$2], type, depth, numberAsFloat);
1016
1028
  preamble += "\n";
1017
1029
  }
1018
1030
  }
@@ -1455,18 +1467,18 @@ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
1455
1467
  });
1456
1468
  else if (c === "#") ptr = skipComment(str, ptr);
1457
1469
  else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
1458
- let k;
1459
- let t = res;
1470
+ let k$2;
1471
+ let t$1 = res;
1460
1472
  let hasOwn = false;
1461
1473
  let [key, keyEndPtr] = parseKey(str, ptr - 1);
1462
1474
  for (let i = 0; i < key.length; i++) {
1463
- if (i) t = hasOwn ? t[k] : t[k] = {};
1464
- k = key[i];
1465
- if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
1475
+ if (i) t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
1476
+ k$2 = key[i];
1477
+ if ((hasOwn = Object.hasOwn(t$1, k$2)) && (typeof t$1[k$2] !== "object" || seen.has(t$1[k$2]))) throw new TomlError("trying to redefine an already defined value", {
1466
1478
  toml: str,
1467
1479
  ptr
1468
1480
  });
1469
- if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
1481
+ if (!hasOwn && k$2 === "__proto__") Object.defineProperty(t$1, k$2, {
1470
1482
  enumerable: true,
1471
1483
  configurable: true,
1472
1484
  writable: true
@@ -1478,7 +1490,7 @@ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
1478
1490
  });
1479
1491
  let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
1480
1492
  seen.add(value);
1481
- t[k] = value;
1493
+ t$1[k$2] = value;
1482
1494
  ptr = valueEndPtr;
1483
1495
  }
1484
1496
  if (!c) throw new TomlError("unfinished table encountered", {
@@ -1516,38 +1528,38 @@ var init_struct = __esmMin((() => {
1516
1528
  KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
1517
1529
  }));
1518
1530
  function peekTable(key, table, meta, type) {
1519
- let t = table;
1531
+ let t$1 = table;
1520
1532
  let m = meta;
1521
- let k;
1533
+ let k$2;
1522
1534
  let hasOwn = false;
1523
1535
  let state;
1524
1536
  for (let i = 0; i < key.length; i++) {
1525
1537
  if (i) {
1526
- t = hasOwn ? t[k] : t[k] = {};
1527
- m = (state = m[k]).c;
1538
+ t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
1539
+ m = (state = m[k$2]).c;
1528
1540
  if (type === 0 && (state.t === 1 || state.t === 2)) return null;
1529
1541
  if (state.t === 2) {
1530
- let l = t.length - 1;
1531
- t = t[l];
1542
+ let l = t$1.length - 1;
1543
+ t$1 = t$1[l];
1532
1544
  m = m[l].c;
1533
1545
  }
1534
1546
  }
1535
- k = key[i];
1536
- if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
1547
+ k$2 = key[i];
1548
+ if ((hasOwn = Object.hasOwn(t$1, k$2)) && m[k$2]?.t === 0 && m[k$2]?.d) return null;
1537
1549
  if (!hasOwn) {
1538
- if (k === "__proto__") {
1539
- Object.defineProperty(t, k, {
1550
+ if (k$2 === "__proto__") {
1551
+ Object.defineProperty(t$1, k$2, {
1540
1552
  enumerable: true,
1541
1553
  configurable: true,
1542
1554
  writable: true
1543
1555
  });
1544
- Object.defineProperty(m, k, {
1556
+ Object.defineProperty(m, k$2, {
1545
1557
  enumerable: true,
1546
1558
  configurable: true,
1547
1559
  writable: true
1548
1560
  });
1549
1561
  }
1550
- m[k] = {
1562
+ m[k$2] = {
1551
1563
  t: i < key.length - 1 && type === 2 ? 3 : type,
1552
1564
  d: false,
1553
1565
  i: 0,
@@ -1555,14 +1567,14 @@ function peekTable(key, table, meta, type) {
1555
1567
  };
1556
1568
  }
1557
1569
  }
1558
- state = m[k];
1570
+ state = m[k$2];
1559
1571
  if (state.t !== type && !(type === 1 && state.t === 3)) return null;
1560
1572
  if (type === 2) {
1561
1573
  if (!state.d) {
1562
1574
  state.d = true;
1563
- t[k] = [];
1575
+ t$1[k$2] = [];
1564
1576
  }
1565
- t[k].push(t = {});
1577
+ t$1[k$2].push(t$1 = {});
1566
1578
  state.c[state.i++] = state = {
1567
1579
  t: 1,
1568
1580
  d: false,
@@ -1572,11 +1584,11 @@ function peekTable(key, table, meta, type) {
1572
1584
  }
1573
1585
  if (state.d) return null;
1574
1586
  state.d = true;
1575
- if (type === 1) t = hasOwn ? t[k] : t[k] = {};
1587
+ if (type === 1) t$1 = hasOwn ? t$1[k$2] : t$1[k$2] = {};
1576
1588
  else if (type === 0 && hasOwn) return null;
1577
1589
  return [
1578
- k,
1579
- t,
1590
+ k$2,
1591
+ t$1,
1580
1592
  state.c
1581
1593
  ];
1582
1594
  }
@@ -1588,30 +1600,30 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1588
1600
  for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
1589
1601
  if (toml[ptr] === "[") {
1590
1602
  let isTableArray = toml[++ptr] === "[";
1591
- let k = parseKey(toml, ptr += +isTableArray, "]");
1603
+ let k$2 = parseKey(toml, ptr += +isTableArray, "]");
1592
1604
  if (isTableArray) {
1593
- if (toml[k[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
1605
+ if (toml[k$2[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
1594
1606
  toml,
1595
- ptr: k[1] - 1
1607
+ ptr: k$2[1] - 1
1596
1608
  });
1597
- k[1]++;
1609
+ k$2[1]++;
1598
1610
  }
1599
- let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
1611
+ let p = peekTable(k$2[0], res, meta, isTableArray ? 2 : 1);
1600
1612
  if (!p) throw new TomlError("trying to redefine an already defined table or value", {
1601
1613
  toml,
1602
1614
  ptr
1603
1615
  });
1604
1616
  m = p[2];
1605
1617
  tbl = p[1];
1606
- ptr = k[1];
1618
+ ptr = k$2[1];
1607
1619
  } else {
1608
- let k = parseKey(toml, ptr);
1609
- let p = peekTable(k[0], tbl, m, 0);
1620
+ let k$2 = parseKey(toml, ptr);
1621
+ let p = peekTable(k$2[0], tbl, m, 0);
1610
1622
  if (!p) throw new TomlError("trying to redefine an already defined table or value", {
1611
1623
  toml,
1612
1624
  ptr
1613
1625
  });
1614
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
1626
+ let v = extractValue(toml, k$2[1], void 0, maxDepth, integersAsBigInt);
1615
1627
  p[1][p[0]] = v[0];
1616
1628
  ptr = v[1];
1617
1629
  }
@@ -1668,11 +1680,11 @@ function stringifyInlineTable(obj, depth, numberAsFloat) {
1668
1680
  if (keys.length === 0) return "{}";
1669
1681
  let res = "{ ";
1670
1682
  for (let i = 0; i < keys.length; i++) {
1671
- let k = keys[i];
1683
+ let k$2 = keys[i];
1672
1684
  if (i) res += ", ";
1673
- res += BARE_KEY.test(k) ? k : formatString(k);
1685
+ res += BARE_KEY.test(k$2) ? k$2 : formatString(k$2);
1674
1686
  res += " = ";
1675
- res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
1687
+ res += stringifyValue(obj[k$2], extendedTypeOf(obj[k$2]), depth - 1, numberAsFloat);
1676
1688
  }
1677
1689
  return res + " }";
1678
1690
  }
@@ -1701,19 +1713,19 @@ function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
1701
1713
  let tables = "";
1702
1714
  let keys = Object.keys(obj);
1703
1715
  for (let i = 0; i < keys.length; i++) {
1704
- let k = keys[i];
1705
- if (obj[k] !== null && obj[k] !== void 0) {
1706
- let type = extendedTypeOf(obj[k]);
1716
+ let k$2 = keys[i];
1717
+ if (obj[k$2] !== null && obj[k$2] !== void 0) {
1718
+ let type = extendedTypeOf(obj[k$2]);
1707
1719
  if (type === "symbol" || type === "function") throw new TypeError(`cannot serialize values of type '${type}'`);
1708
- let key = BARE_KEY.test(k) ? k : formatString(k);
1709
- if (type === "array" && isArrayOfTables(obj[k])) tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
1720
+ let key = BARE_KEY.test(k$2) ? k$2 : formatString(k$2);
1721
+ if (type === "array" && isArrayOfTables(obj[k$2])) tables += (tables && "\n") + stringifyArrayTable(obj[k$2], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
1710
1722
  else if (type === "object") {
1711
1723
  let tblKey = prefix ? `${prefix}.${key}` : key;
1712
- tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
1724
+ tables += (tables && "\n") + stringifyTable(tblKey, obj[k$2], tblKey, depth - 1, numberAsFloat);
1713
1725
  } else {
1714
1726
  preamble += key;
1715
1727
  preamble += " = ";
1716
- preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
1728
+ preamble += stringifyValue(obj[k$2], type, depth, numberAsFloat);
1717
1729
  preamble += "\n";
1718
1730
  }
1719
1731
  }
@@ -1731,7 +1743,7 @@ var BARE_KEY;
1731
1743
  var init_stringify = __esmMin((() => {
1732
1744
  BARE_KEY = /^[a-z0-9-_]+$/i;
1733
1745
  }));
1734
- var dist_exports = /* @__PURE__ */ __export$1({
1746
+ var dist_exports$1 = /* @__PURE__ */ __export$1({
1735
1747
  TomlDate: () => TomlDate,
1736
1748
  TomlError: () => TomlError,
1737
1749
  default: () => dist_default,
@@ -1769,7 +1781,7 @@ async function createTomlPluginAsync() {
1769
1781
  if (typeof __require !== "undefined") try {
1770
1782
  return new TomlConfigPlugin(require_dist());
1771
1783
  } catch (error) {}
1772
- return new TomlConfigPlugin(await Promise.resolve().then(() => (init_dist(), dist_exports)));
1784
+ return new TomlConfigPlugin(await Promise.resolve().then(() => (init_dist(), dist_exports$1)));
1773
1785
  } catch (error) {
1774
1786
  console.warn("TOML plugin not available:", error instanceof Error ? error.message : String(error));
1775
1787
  return null;
@@ -2672,7 +2684,9 @@ const zodFlagSchema = z.object({
2672
2684
  dxtOptions: zodDxtOptionsSchema.optional().describe("DXT-specific configuration options for enhanced DXT manifest generation"),
2673
2685
  dynamicRegister: z.custom((val) => typeof val === "function").optional().describe("Optional callback that can register additional flags dynamically when this flag is present."),
2674
2686
  setWorkingDirectory: z.boolean().optional().describe("If true, this flag's value becomes the effective working directory for file operations."),
2675
- positional: z.number().int().positive("Positional index must be a positive integer (1, 2, 3...)").optional().describe("If set, this flag captures the Nth trailing positional argument (1-indexed). Multiple flags can have different positional values to capture multiple trailing args in order.")
2687
+ positional: z.number().int().positive("Positional index must be a positive integer (1, 2, 3...)").optional().describe("If set, this flag captures the Nth trailing positional argument (1-indexed). Multiple flags can have different positional values to capture multiple trailing args in order."),
2688
+ prompt: z.custom((val) => typeof val === "function").optional().describe("Prompt configuration factory for interactive mode"),
2689
+ promptSequence: z.number().int().positive("Prompt sequence must be a positive integer").optional().describe("Explicit sequence order for prompts (1 = first, 2 = second, etc.)")
2676
2690
  }).transform((obj) => {
2677
2691
  const newObj = { ...obj };
2678
2692
  if ("default" in newObj && newObj["default"] !== void 0 && !("defaultValue" in newObj)) newObj["defaultValue"] = newObj["default"];
@@ -3792,6 +3806,9 @@ var McpPromptsManager = class {
3792
3806
  }
3793
3807
  }
3794
3808
  };
3809
+ var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3810
+ module.exports = {};
3811
+ }));
3795
3812
  var logger$4 = createMcpLogger$1("MCP Resources");
3796
3813
  var ResourceTemplateParser = class {
3797
3814
  constructor(template) {
@@ -3928,9 +3945,14 @@ const debug = {
3928
3945
  };
3929
3946
  var FlagManager = class FlagManager {
3930
3947
  #_flags = /* @__PURE__ */ new Map();
3948
+ #_optionToFlagName = /* @__PURE__ */ new Map();
3931
3949
  #throwForDuplicateFlags;
3950
+ #detectOptionCollisions;
3951
+ #throwForOptionCollisions;
3932
3952
  constructor(options = {}, initialFlags = []) {
3933
3953
  this.#throwForDuplicateFlags = options.throwForDuplicateFlags ?? false;
3954
+ this.#detectOptionCollisions = options.detectOptionCollisions ?? true;
3955
+ this.#throwForOptionCollisions = options.throwForOptionCollisions ?? false;
3934
3956
  this.addFlags(initialFlags);
3935
3957
  }
3936
3958
  static _safeFlag(flag) {
@@ -3964,9 +3986,26 @@ var FlagManager = class FlagManager {
3964
3986
  enum: parsedFromZod["enum"],
3965
3987
  mandatory: parsedFromZod["mandatory"],
3966
3988
  env: parsedFromZod["env"],
3967
- dxtOptions: parsedFromZod["dxtOptions"]
3989
+ dxtOptions: parsedFromZod["dxtOptions"],
3990
+ prompt: parsedFromZod["prompt"],
3991
+ promptSequence: parsedFromZod["promptSequence"]
3968
3992
  };
3969
3993
  }
3994
+ #findOptionCollisions(newFlag) {
3995
+ const collisions = [];
3996
+ for (const option of newFlag["options"]) {
3997
+ const existingFlagName = this.#_optionToFlagName.get(option);
3998
+ if (existingFlagName && existingFlagName !== newFlag["name"]) collisions.push({
3999
+ option,
4000
+ existingFlagName,
4001
+ newFlagName: newFlag["name"]
4002
+ });
4003
+ }
4004
+ return collisions;
4005
+ }
4006
+ #registerFlagOptions(flag) {
4007
+ for (const option of flag["options"]) this.#_optionToFlagName.set(option, flag["name"]);
4008
+ }
3970
4009
  addFlag(flag) {
3971
4010
  const safeFlag = FlagManager._safeFlag(flag);
3972
4011
  if (this.#_flags.has(safeFlag["name"])) if (this.#throwForDuplicateFlags) throw new Error(`FlagManager: Flag '${safeFlag["name"]}' already exists.`);
@@ -3974,12 +4013,23 @@ var FlagManager = class FlagManager {
3974
4013
  console.warn(`Warning: FlagManager: Flag '${safeFlag["name"]}' already exists. Duplicate not added.`);
3975
4014
  return this;
3976
4015
  }
4016
+ if (this.#detectOptionCollisions) {
4017
+ const collisions = this.#findOptionCollisions(safeFlag);
4018
+ if (collisions.length > 0) {
4019
+ const collisionMessages = collisions.map((c) => `'${c.option}' (conflicts with '${c.existingFlagName}')`);
4020
+ const message = `Flag '${safeFlag["name"]}' has option collision(s): ${collisionMessages.join(", ")}. Each option string can only be used by one flag.`;
4021
+ if (this.#throwForOptionCollisions) throw new Error(`FlagManager: ${message}`);
4022
+ else console.warn(`Warning: FlagManager: ${message}`);
4023
+ }
4024
+ }
3977
4025
  this.#_flags.set(safeFlag["name"], safeFlag);
4026
+ this.#registerFlagOptions(safeFlag);
3978
4027
  return this;
3979
4028
  }
3980
4029
  _setProcessedFlagForInheritance(processedFlag) {
3981
4030
  if (this.#_flags.has(processedFlag["name"])) return this;
3982
4031
  this.#_flags.set(processedFlag["name"], processedFlag);
4032
+ this.#registerFlagOptions(processedFlag);
3983
4033
  return this;
3984
4034
  }
3985
4035
  addFlags(flags) {
@@ -3990,7 +4040,12 @@ var FlagManager = class FlagManager {
3990
4040
  return this.#_flags.has(name);
3991
4041
  }
3992
4042
  removeFlag(name) {
3993
- return this.#_flags.delete(name);
4043
+ const flag = this.#_flags.get(name);
4044
+ if (flag) {
4045
+ for (const option of flag["options"]) this.#_optionToFlagName.delete(option);
4046
+ return this.#_flags.delete(name);
4047
+ }
4048
+ return false;
3994
4049
  }
3995
4050
  getFlag(name) {
3996
4051
  return this.#_flags.get(name);
@@ -4001,7 +4056,1381 @@ var FlagManager = class FlagManager {
4001
4056
  get flagNames() {
4002
4057
  return Array.from(this.#_flags.values()).map((flag) => flag["name"]);
4003
4058
  }
4059
+ get optionMappings() {
4060
+ return new Map(this.#_optionToFlagName);
4061
+ }
4062
+ getCollisionsForFlag(flag) {
4063
+ const safeFlag = FlagManager._safeFlag(flag);
4064
+ return this.#findOptionCollisions(safeFlag);
4065
+ }
4066
+ };
4067
+ var require_picocolors_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4068
+ var x$2 = String;
4069
+ var create = function() {
4070
+ return {
4071
+ isColorSupported: false,
4072
+ reset: x$2,
4073
+ bold: x$2,
4074
+ dim: x$2,
4075
+ italic: x$2,
4076
+ underline: x$2,
4077
+ inverse: x$2,
4078
+ hidden: x$2,
4079
+ strikethrough: x$2,
4080
+ black: x$2,
4081
+ red: x$2,
4082
+ green: x$2,
4083
+ yellow: x$2,
4084
+ blue: x$2,
4085
+ magenta: x$2,
4086
+ cyan: x$2,
4087
+ white: x$2,
4088
+ gray: x$2,
4089
+ bgBlack: x$2,
4090
+ bgRed: x$2,
4091
+ bgGreen: x$2,
4092
+ bgYellow: x$2,
4093
+ bgBlue: x$2,
4094
+ bgMagenta: x$2,
4095
+ bgCyan: x$2,
4096
+ bgWhite: x$2,
4097
+ blackBright: x$2,
4098
+ redBright: x$2,
4099
+ greenBright: x$2,
4100
+ yellowBright: x$2,
4101
+ blueBright: x$2,
4102
+ magentaBright: x$2,
4103
+ cyanBright: x$2,
4104
+ whiteBright: x$2,
4105
+ bgBlackBright: x$2,
4106
+ bgRedBright: x$2,
4107
+ bgGreenBright: x$2,
4108
+ bgYellowBright: x$2,
4109
+ bgBlueBright: x$2,
4110
+ bgMagentaBright: x$2,
4111
+ bgCyanBright: x$2,
4112
+ bgWhiteBright: x$2
4113
+ };
4114
+ };
4115
+ module.exports = create();
4116
+ module.exports.createColors = create;
4117
+ }));
4118
+ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4119
+ var ESC = "\x1B";
4120
+ var CSI = `${ESC}[`;
4121
+ var beep = "\x07";
4122
+ var cursor = {
4123
+ to(x$3, y$1) {
4124
+ if (!y$1) return `${CSI}${x$3 + 1}G`;
4125
+ return `${CSI}${y$1 + 1};${x$3 + 1}H`;
4126
+ },
4127
+ move(x$3, y$1) {
4128
+ let ret = "";
4129
+ if (x$3 < 0) ret += `${CSI}${-x$3}D`;
4130
+ else if (x$3 > 0) ret += `${CSI}${x$3}C`;
4131
+ if (y$1 < 0) ret += `${CSI}${-y$1}A`;
4132
+ else if (y$1 > 0) ret += `${CSI}${y$1}B`;
4133
+ return ret;
4134
+ },
4135
+ up: (count = 1) => `${CSI}${count}A`,
4136
+ down: (count = 1) => `${CSI}${count}B`,
4137
+ forward: (count = 1) => `${CSI}${count}C`,
4138
+ backward: (count = 1) => `${CSI}${count}D`,
4139
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
4140
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
4141
+ left: `${CSI}G`,
4142
+ hide: `${CSI}?25l`,
4143
+ show: `${CSI}?25h`,
4144
+ save: `${ESC}7`,
4145
+ restore: `${ESC}8`
4146
+ };
4147
+ module.exports = {
4148
+ cursor,
4149
+ scroll: {
4150
+ up: (count = 1) => `${CSI}S`.repeat(count),
4151
+ down: (count = 1) => `${CSI}T`.repeat(count)
4152
+ },
4153
+ erase: {
4154
+ screen: `${CSI}2J`,
4155
+ up: (count = 1) => `${CSI}1J`.repeat(count),
4156
+ down: (count = 1) => `${CSI}J`.repeat(count),
4157
+ line: `${CSI}2K`,
4158
+ lineEnd: `${CSI}K`,
4159
+ lineStart: `${CSI}1K`,
4160
+ lines(count) {
4161
+ let clear = "";
4162
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
4163
+ if (count) clear += cursor.left;
4164
+ return clear;
4165
+ }
4166
+ },
4167
+ beep
4168
+ };
4169
+ }));
4170
+ var import_picocolors_browser$1 = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1);
4171
+ var import_src$1 = require_src();
4172
+ var at = (t$1) => t$1 === 161 || t$1 === 164 || t$1 === 167 || t$1 === 168 || t$1 === 170 || t$1 === 173 || t$1 === 174 || t$1 >= 176 && t$1 <= 180 || t$1 >= 182 && t$1 <= 186 || t$1 >= 188 && t$1 <= 191 || t$1 === 198 || t$1 === 208 || t$1 === 215 || t$1 === 216 || t$1 >= 222 && t$1 <= 225 || t$1 === 230 || t$1 >= 232 && t$1 <= 234 || t$1 === 236 || t$1 === 237 || t$1 === 240 || t$1 === 242 || t$1 === 243 || t$1 >= 247 && t$1 <= 250 || t$1 === 252 || t$1 === 254 || t$1 === 257 || t$1 === 273 || t$1 === 275 || t$1 === 283 || t$1 === 294 || t$1 === 295 || t$1 === 299 || t$1 >= 305 && t$1 <= 307 || t$1 === 312 || t$1 >= 319 && t$1 <= 322 || t$1 === 324 || t$1 >= 328 && t$1 <= 331 || t$1 === 333 || t$1 === 338 || t$1 === 339 || t$1 === 358 || t$1 === 359 || t$1 === 363 || t$1 === 462 || t$1 === 464 || t$1 === 466 || t$1 === 468 || t$1 === 470 || t$1 === 472 || t$1 === 474 || t$1 === 476 || t$1 === 593 || t$1 === 609 || t$1 === 708 || t$1 === 711 || t$1 >= 713 && t$1 <= 715 || t$1 === 717 || t$1 === 720 || t$1 >= 728 && t$1 <= 731 || t$1 === 733 || t$1 === 735 || t$1 >= 768 && t$1 <= 879 || t$1 >= 913 && t$1 <= 929 || t$1 >= 931 && t$1 <= 937 || t$1 >= 945 && t$1 <= 961 || t$1 >= 963 && t$1 <= 969 || t$1 === 1025 || t$1 >= 1040 && t$1 <= 1103 || t$1 === 1105 || t$1 === 8208 || t$1 >= 8211 && t$1 <= 8214 || t$1 === 8216 || t$1 === 8217 || t$1 === 8220 || t$1 === 8221 || t$1 >= 8224 && t$1 <= 8226 || t$1 >= 8228 && t$1 <= 8231 || t$1 === 8240 || t$1 === 8242 || t$1 === 8243 || t$1 === 8245 || t$1 === 8251 || t$1 === 8254 || t$1 === 8308 || t$1 === 8319 || t$1 >= 8321 && t$1 <= 8324 || t$1 === 8364 || t$1 === 8451 || t$1 === 8453 || t$1 === 8457 || t$1 === 8467 || t$1 === 8470 || t$1 === 8481 || t$1 === 8482 || t$1 === 8486 || t$1 === 8491 || t$1 === 8531 || t$1 === 8532 || t$1 >= 8539 && t$1 <= 8542 || t$1 >= 8544 && t$1 <= 8555 || t$1 >= 8560 && t$1 <= 8569 || t$1 === 8585 || t$1 >= 8592 && t$1 <= 8601 || t$1 === 8632 || t$1 === 8633 || t$1 === 8658 || t$1 === 8660 || t$1 === 8679 || t$1 === 8704 || t$1 === 8706 || t$1 === 8707 || t$1 === 8711 || t$1 === 8712 || t$1 === 8715 || t$1 === 8719 || t$1 === 8721 || t$1 === 8725 || t$1 === 8730 || t$1 >= 8733 && t$1 <= 8736 || t$1 === 8739 || t$1 === 8741 || t$1 >= 8743 && t$1 <= 8748 || t$1 === 8750 || t$1 >= 8756 && t$1 <= 8759 || t$1 === 8764 || t$1 === 8765 || t$1 === 8776 || t$1 === 8780 || t$1 === 8786 || t$1 === 8800 || t$1 === 8801 || t$1 >= 8804 && t$1 <= 8807 || t$1 === 8810 || t$1 === 8811 || t$1 === 8814 || t$1 === 8815 || t$1 === 8834 || t$1 === 8835 || t$1 === 8838 || t$1 === 8839 || t$1 === 8853 || t$1 === 8857 || t$1 === 8869 || t$1 === 8895 || t$1 === 8978 || t$1 >= 9312 && t$1 <= 9449 || t$1 >= 9451 && t$1 <= 9547 || t$1 >= 9552 && t$1 <= 9587 || t$1 >= 9600 && t$1 <= 9615 || t$1 >= 9618 && t$1 <= 9621 || t$1 === 9632 || t$1 === 9633 || t$1 >= 9635 && t$1 <= 9641 || t$1 === 9650 || t$1 === 9651 || t$1 === 9654 || t$1 === 9655 || t$1 === 9660 || t$1 === 9661 || t$1 === 9664 || t$1 === 9665 || t$1 >= 9670 && t$1 <= 9672 || t$1 === 9675 || t$1 >= 9678 && t$1 <= 9681 || t$1 >= 9698 && t$1 <= 9701 || t$1 === 9711 || t$1 === 9733 || t$1 === 9734 || t$1 === 9737 || t$1 === 9742 || t$1 === 9743 || t$1 === 9756 || t$1 === 9758 || t$1 === 9792 || t$1 === 9794 || t$1 === 9824 || t$1 === 9825 || t$1 >= 9827 && t$1 <= 9829 || t$1 >= 9831 && t$1 <= 9834 || t$1 === 9836 || t$1 === 9837 || t$1 === 9839 || t$1 === 9886 || t$1 === 9887 || t$1 === 9919 || t$1 >= 9926 && t$1 <= 9933 || t$1 >= 9935 && t$1 <= 9939 || t$1 >= 9941 && t$1 <= 9953 || t$1 === 9955 || t$1 === 9960 || t$1 === 9961 || t$1 >= 9963 && t$1 <= 9969 || t$1 === 9972 || t$1 >= 9974 && t$1 <= 9977 || t$1 === 9979 || t$1 === 9980 || t$1 === 9982 || t$1 === 9983 || t$1 === 10045 || t$1 >= 10102 && t$1 <= 10111 || t$1 >= 11094 && t$1 <= 11097 || t$1 >= 12872 && t$1 <= 12879 || t$1 >= 57344 && t$1 <= 63743 || t$1 >= 65024 && t$1 <= 65039 || t$1 === 65533 || t$1 >= 127232 && t$1 <= 127242 || t$1 >= 127248 && t$1 <= 127277 || t$1 >= 127280 && t$1 <= 127337 || t$1 >= 127344 && t$1 <= 127373 || t$1 === 127375 || t$1 === 127376 || t$1 >= 127387 && t$1 <= 127404 || t$1 >= 917760 && t$1 <= 917999 || t$1 >= 983040 && t$1 <= 1048573 || t$1 >= 1048576 && t$1 <= 1114109, lt = (t$1) => t$1 === 12288 || t$1 >= 65281 && t$1 <= 65376 || t$1 >= 65504 && t$1 <= 65510, ht$1 = (t$1) => t$1 >= 4352 && t$1 <= 4447 || t$1 === 8986 || t$1 === 8987 || t$1 === 9001 || t$1 === 9002 || t$1 >= 9193 && t$1 <= 9196 || t$1 === 9200 || t$1 === 9203 || t$1 === 9725 || t$1 === 9726 || t$1 === 9748 || t$1 === 9749 || t$1 >= 9800 && t$1 <= 9811 || t$1 === 9855 || t$1 === 9875 || t$1 === 9889 || t$1 === 9898 || t$1 === 9899 || t$1 === 9917 || t$1 === 9918 || t$1 === 9924 || t$1 === 9925 || t$1 === 9934 || t$1 === 9940 || t$1 === 9962 || t$1 === 9970 || t$1 === 9971 || t$1 === 9973 || t$1 === 9978 || t$1 === 9981 || t$1 === 9989 || t$1 === 9994 || t$1 === 9995 || t$1 === 10024 || t$1 === 10060 || t$1 === 10062 || t$1 >= 10067 && t$1 <= 10069 || t$1 === 10071 || t$1 >= 10133 && t$1 <= 10135 || t$1 === 10160 || t$1 === 10175 || t$1 === 11035 || t$1 === 11036 || t$1 === 11088 || t$1 === 11093 || t$1 >= 11904 && t$1 <= 11929 || t$1 >= 11931 && t$1 <= 12019 || t$1 >= 12032 && t$1 <= 12245 || t$1 >= 12272 && t$1 <= 12287 || t$1 >= 12289 && t$1 <= 12350 || t$1 >= 12353 && t$1 <= 12438 || t$1 >= 12441 && t$1 <= 12543 || t$1 >= 12549 && t$1 <= 12591 || t$1 >= 12593 && t$1 <= 12686 || t$1 >= 12688 && t$1 <= 12771 || t$1 >= 12783 && t$1 <= 12830 || t$1 >= 12832 && t$1 <= 12871 || t$1 >= 12880 && t$1 <= 19903 || t$1 >= 19968 && t$1 <= 42124 || t$1 >= 42128 && t$1 <= 42182 || t$1 >= 43360 && t$1 <= 43388 || t$1 >= 44032 && t$1 <= 55203 || t$1 >= 63744 && t$1 <= 64255 || t$1 >= 65040 && t$1 <= 65049 || t$1 >= 65072 && t$1 <= 65106 || t$1 >= 65108 && t$1 <= 65126 || t$1 >= 65128 && t$1 <= 65131 || t$1 >= 94176 && t$1 <= 94180 || t$1 === 94192 || t$1 === 94193 || t$1 >= 94208 && t$1 <= 100343 || t$1 >= 100352 && t$1 <= 101589 || t$1 >= 101632 && t$1 <= 101640 || t$1 >= 110576 && t$1 <= 110579 || t$1 >= 110581 && t$1 <= 110587 || t$1 === 110589 || t$1 === 110590 || t$1 >= 110592 && t$1 <= 110882 || t$1 === 110898 || t$1 >= 110928 && t$1 <= 110930 || t$1 === 110933 || t$1 >= 110948 && t$1 <= 110951 || t$1 >= 110960 && t$1 <= 111355 || t$1 === 126980 || t$1 === 127183 || t$1 === 127374 || t$1 >= 127377 && t$1 <= 127386 || t$1 >= 127488 && t$1 <= 127490 || t$1 >= 127504 && t$1 <= 127547 || t$1 >= 127552 && t$1 <= 127560 || t$1 === 127568 || t$1 === 127569 || t$1 >= 127584 && t$1 <= 127589 || t$1 >= 127744 && t$1 <= 127776 || t$1 >= 127789 && t$1 <= 127797 || t$1 >= 127799 && t$1 <= 127868 || t$1 >= 127870 && t$1 <= 127891 || t$1 >= 127904 && t$1 <= 127946 || t$1 >= 127951 && t$1 <= 127955 || t$1 >= 127968 && t$1 <= 127984 || t$1 === 127988 || t$1 >= 127992 && t$1 <= 128062 || t$1 === 128064 || t$1 >= 128066 && t$1 <= 128252 || t$1 >= 128255 && t$1 <= 128317 || t$1 >= 128331 && t$1 <= 128334 || t$1 >= 128336 && t$1 <= 128359 || t$1 === 128378 || t$1 === 128405 || t$1 === 128406 || t$1 === 128420 || t$1 >= 128507 && t$1 <= 128591 || t$1 >= 128640 && t$1 <= 128709 || t$1 === 128716 || t$1 >= 128720 && t$1 <= 128722 || t$1 >= 128725 && t$1 <= 128727 || t$1 >= 128732 && t$1 <= 128735 || t$1 === 128747 || t$1 === 128748 || t$1 >= 128756 && t$1 <= 128764 || t$1 >= 128992 && t$1 <= 129003 || t$1 === 129008 || t$1 >= 129292 && t$1 <= 129338 || t$1 >= 129340 && t$1 <= 129349 || t$1 >= 129351 && t$1 <= 129535 || t$1 >= 129648 && t$1 <= 129660 || t$1 >= 129664 && t$1 <= 129672 || t$1 >= 129680 && t$1 <= 129725 || t$1 >= 129727 && t$1 <= 129733 || t$1 >= 129742 && t$1 <= 129755 || t$1 >= 129760 && t$1 <= 129768 || t$1 >= 129776 && t$1 <= 129784 || t$1 >= 131072 && t$1 <= 196605 || t$1 >= 196608 && t$1 <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, M$1 = /\t{1,1000}/y, P$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, L = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, pt$1 = {
4173
+ limit: Infinity,
4174
+ ellipsis: ""
4175
+ }, X = (t$1, e = {}, s = {}) => {
4176
+ const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, pt$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
4177
+ let h$1 = 0, o = 0, f = t$1.length, v = 0, F = !1, d = f, b = Math.max(0, i - n), C = 0, B = 0, c = 0, p = 0;
4178
+ t: for (;;) {
4179
+ if (B > C || o >= f && o > h$1) {
4180
+ const ut = t$1.slice(C, B) || t$1.slice(h$1, o);
4181
+ v = 0;
4182
+ for (const Y$1 of ut.replaceAll(ct, "")) {
4183
+ const $ = Y$1.codePointAt(0) || 0;
4184
+ if (lt($) ? p = m : ht$1($) ? p = V : E !== A && at($) ? p = E : p = A, c + p > b && (d = Math.min(d, Math.max(C, h$1) + v)), c + p > i) {
4185
+ F = !0;
4186
+ break t;
4187
+ }
4188
+ v += Y$1.length, c += p;
4189
+ }
4190
+ C = B = 0;
4191
+ }
4192
+ if (o >= f) break;
4193
+ if (L.lastIndex = o, L.test(t$1)) {
4194
+ if (v = L.lastIndex - o, p = v * A, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + p > i) {
4195
+ F = !0;
4196
+ break;
4197
+ }
4198
+ c += p, C = h$1, B = o, o = h$1 = L.lastIndex;
4199
+ continue;
4200
+ }
4201
+ if (O.lastIndex = o, O.test(t$1)) {
4202
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
4203
+ F = !0;
4204
+ break;
4205
+ }
4206
+ c += u, C = h$1, B = o, o = h$1 = O.lastIndex;
4207
+ continue;
4208
+ }
4209
+ if (y.lastIndex = o, y.test(t$1)) {
4210
+ if (v = y.lastIndex - o, p = v * a, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + p > i) {
4211
+ F = !0;
4212
+ break;
4213
+ }
4214
+ c += p, C = h$1, B = o, o = h$1 = y.lastIndex;
4215
+ continue;
4216
+ }
4217
+ if (M$1.lastIndex = o, M$1.test(t$1)) {
4218
+ if (v = M$1.lastIndex - o, p = v * l, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + p > i) {
4219
+ F = !0;
4220
+ break;
4221
+ }
4222
+ c += p, C = h$1, B = o, o = h$1 = M$1.lastIndex;
4223
+ continue;
4224
+ }
4225
+ if (P$1.lastIndex = o, P$1.test(t$1)) {
4226
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
4227
+ F = !0;
4228
+ break;
4229
+ }
4230
+ c += g, C = h$1, B = o, o = h$1 = P$1.lastIndex;
4231
+ continue;
4232
+ }
4233
+ o += 1;
4234
+ }
4235
+ return {
4236
+ width: F ? b : c,
4237
+ index: F ? d : f,
4238
+ truncated: F,
4239
+ ellipsed: F && i >= n
4240
+ };
4241
+ }, ft$1 = {
4242
+ limit: Infinity,
4243
+ ellipsis: "",
4244
+ ellipsisWidth: 0
4245
+ }, S = (t$1, e = {}) => X(t$1, ft$1, e).width, W = "\x1B", Z = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y"), mt$1 = (t$1) => {
4246
+ if (t$1 >= 30 && t$1 <= 37 || t$1 >= 90 && t$1 <= 97) return 39;
4247
+ if (t$1 >= 40 && t$1 <= 47 || t$1 >= 100 && t$1 <= 107) return 49;
4248
+ if (t$1 === 1 || t$1 === 2) return 22;
4249
+ if (t$1 === 3) return 23;
4250
+ if (t$1 === 4) return 24;
4251
+ if (t$1 === 7) return 27;
4252
+ if (t$1 === 8) return 28;
4253
+ if (t$1 === 9) return 29;
4254
+ if (t$1 === 0) return 0;
4255
+ }, st = (t$1) => `${W}${Q$1}${t$1}${tt}`, it = (t$1) => `${W}${U}${t$1}${j}`, gt$1 = (t$1) => t$1.map((e) => S(e)), G$1 = (t$1, e, s) => {
4256
+ const i = e[Symbol.iterator]();
4257
+ let r = !1, n = !1, u = t$1.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
4258
+ for (; !l.done;) {
4259
+ const m = l.value, A = S(m);
4260
+ a + A <= s ? t$1[t$1.length - 1] += m : (t$1.push(m), a = 0), (m === W || m === Z) && (r = !0, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t$1.push(""), a = 0)), l = E, E = i.next(), g += m.length;
4261
+ }
4262
+ u = t$1.at(-1), !a && u !== void 0 && u.length > 0 && t$1.length > 1 && (t$1[t$1.length - 2] += t$1.pop());
4263
+ }, vt$1 = (t$1) => {
4264
+ const e = t$1.split(" ");
4265
+ let s = e.length;
4266
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
4267
+ return s === e.length ? t$1 : e.slice(0, s).join(" ") + e.slice(s).join("");
4268
+ }, Et$1 = (t$1, e, s = {}) => {
4269
+ if (s.trim !== !1 && t$1.trim() === "") return "";
4270
+ let i = "", r, n;
4271
+ const u = t$1.split(" "), a = gt$1(u);
4272
+ let l = [""];
4273
+ for (const [h$1, o] of u.entries()) {
4274
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
4275
+ let f = S(l.at(-1) ?? "");
4276
+ if (h$1 !== 0 && (f >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), f = 0), (f > 0 || s.trim === !1) && (l[l.length - 1] += " ", f++)), s.hard && a[h$1] > e) {
4277
+ const v = e - f, F = 1 + Math.floor((a[h$1] - v - 1) / e);
4278
+ Math.floor((a[h$1] - 1) / e) < F && l.push(""), G$1(l, o, e);
4279
+ continue;
4280
+ }
4281
+ if (f + a[h$1] > e && f > 0 && a[h$1] > 0) {
4282
+ if (s.wordWrap === !1 && f < e) {
4283
+ G$1(l, o, e);
4284
+ continue;
4285
+ }
4286
+ l.push("");
4287
+ }
4288
+ if (f + a[h$1] > e && s.wordWrap === !1) {
4289
+ G$1(l, o, e);
4290
+ continue;
4291
+ }
4292
+ l[l.length - 1] += o;
4293
+ }
4294
+ s.trim !== !1 && (l = l.map((h$1) => vt$1(h$1)));
4295
+ const E = l.join(`
4296
+ `), g = E[Symbol.iterator]();
4297
+ let m = g.next(), A = g.next(), V = 0;
4298
+ for (; !m.done;) {
4299
+ const h$1 = m.value, o = A.value;
4300
+ if (i += h$1, h$1 === W || h$1 === Z) {
4301
+ et.lastIndex = V + 1;
4302
+ const F = et.exec(E)?.groups;
4303
+ if (F?.code !== void 0) {
4304
+ const d = Number.parseFloat(F.code);
4305
+ r = d === Ft$1 ? void 0 : d;
4306
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
4307
+ }
4308
+ const f = r ? mt$1(r) : void 0;
4309
+ o === `
4310
+ ` ? (n && (i += it("")), r && f && (i += st(f))) : h$1 === `
4311
+ ` && (r && f && (i += st(r)), n && (i += it(n))), V += h$1.length, m = A, A = g.next();
4312
+ }
4313
+ return i;
4314
+ };
4315
+ function K$1(t$1, e, s) {
4316
+ return String(t$1).normalize().replaceAll(`\r
4317
+ `, `
4318
+ `).split(`
4319
+ `).map((i) => Et$1(i, e, s)).join(`
4320
+ `);
4321
+ }
4322
+ var _ = {
4323
+ actions: new Set([
4324
+ "up",
4325
+ "down",
4326
+ "left",
4327
+ "right",
4328
+ "space",
4329
+ "enter",
4330
+ "cancel"
4331
+ ]),
4332
+ aliases: new Map([
4333
+ ["k", "up"],
4334
+ ["j", "down"],
4335
+ ["h", "left"],
4336
+ ["l", "right"],
4337
+ ["", "cancel"],
4338
+ ["escape", "cancel"]
4339
+ ]),
4340
+ messages: {
4341
+ cancel: "Canceled",
4342
+ error: "Something went wrong"
4343
+ },
4344
+ withGuide: !0
4345
+ };
4346
+ function H$1(t$1, e) {
4347
+ if (typeof t$1 == "string") return _.aliases.get(t$1) === e;
4348
+ for (const s of t$1) if (s !== void 0 && H$1(s, e)) return !0;
4349
+ return !1;
4350
+ }
4351
+ function _t$1(t$1, e) {
4352
+ if (t$1 === e) return;
4353
+ const s = t$1.split(`
4354
+ `), i = e.split(`
4355
+ `), r = Math.max(s.length, i.length), n = [];
4356
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
4357
+ return {
4358
+ lines: n,
4359
+ numLinesBefore: s.length,
4360
+ numLinesAfter: i.length,
4361
+ numLines: r
4362
+ };
4363
+ }
4364
+ globalThis.process.platform.startsWith("win");
4365
+ var z$2 = Symbol("clack:cancel");
4366
+ function Ct(t$1) {
4367
+ return t$1 === z$2;
4368
+ }
4369
+ function T(t$1, e) {
4370
+ const s = t$1;
4371
+ s.isTTY && s.setRawMode(e);
4372
+ }
4373
+ var rt = (t$1) => "columns" in t$1 && typeof t$1.columns == "number" ? t$1.columns : 80, nt = (t$1) => "rows" in t$1 && typeof t$1.rows == "number" ? t$1.rows : 20;
4374
+ function Bt(t$1, e, s, i = s) {
4375
+ return K$1(e, rt(t$1 ?? stdout) - s.length, {
4376
+ hard: !0,
4377
+ trim: !1
4378
+ }).split(`
4379
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
4380
+ `);
4381
+ }
4382
+ var x$1 = class {
4383
+ input;
4384
+ output;
4385
+ _abortSignal;
4386
+ rl;
4387
+ opts;
4388
+ _render;
4389
+ _track = !1;
4390
+ _prevFrame = "";
4391
+ _subscribers = /* @__PURE__ */ new Map();
4392
+ _cursor = 0;
4393
+ state = "initial";
4394
+ error = "";
4395
+ value;
4396
+ userInput = "";
4397
+ constructor(e, s = !0) {
4398
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
4399
+ this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
4400
+ }
4401
+ unsubscribe() {
4402
+ this._subscribers.clear();
4403
+ }
4404
+ setSubscriber(e, s) {
4405
+ const i = this._subscribers.get(e) ?? [];
4406
+ i.push(s), this._subscribers.set(e, i);
4407
+ }
4408
+ on(e, s) {
4409
+ this.setSubscriber(e, { cb: s });
4410
+ }
4411
+ once(e, s) {
4412
+ this.setSubscriber(e, {
4413
+ cb: s,
4414
+ once: !0
4415
+ });
4416
+ }
4417
+ emit(e, ...s) {
4418
+ const i = this._subscribers.get(e) ?? [], r = [];
4419
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
4420
+ for (const n of r) n();
4421
+ }
4422
+ prompt() {
4423
+ return new Promise((e) => {
4424
+ if (this._abortSignal) {
4425
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$2);
4426
+ this._abortSignal.addEventListener("abort", () => {
4427
+ this.state = "cancel", this.close();
4428
+ }, { once: !0 });
4429
+ }
4430
+ this.rl = ot.createInterface({
4431
+ input: this.input,
4432
+ tabSize: 2,
4433
+ prompt: "",
4434
+ escapeCodeTimeout: 50,
4435
+ terminal: !0
4436
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), T(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
4437
+ this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(this.value);
4438
+ }), this.once("cancel", () => {
4439
+ this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(z$2);
4440
+ });
4441
+ });
4442
+ }
4443
+ _isActionKey(e, s) {
4444
+ return e === " ";
4445
+ }
4446
+ _setValue(e) {
4447
+ this.value = e, this.emit("value", this.value);
4448
+ }
4449
+ _setUserInput(e, s) {
4450
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
4451
+ }
4452
+ _clearUserInput() {
4453
+ this.rl?.write(null, {
4454
+ ctrl: !0,
4455
+ name: "u"
4456
+ }), this._setUserInput("");
4457
+ }
4458
+ onKeypress(e, s) {
4459
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
4460
+ ctrl: !0,
4461
+ name: "h"
4462
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
4463
+ if (this.opts.validate) {
4464
+ const i = this.opts.validate(this.value);
4465
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
4466
+ }
4467
+ this.state !== "error" && (this.state = "submit");
4468
+ }
4469
+ H$1([
4470
+ e,
4471
+ s?.name,
4472
+ s?.sequence
4473
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
4474
+ }
4475
+ close() {
4476
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
4477
+ `), T(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
4478
+ }
4479
+ restoreCursor() {
4480
+ const e = K$1(this._prevFrame, process.stdout.columns, {
4481
+ hard: !0,
4482
+ trim: !1
4483
+ }).split(`
4484
+ `).length - 1;
4485
+ this.output.write(import_src$1.cursor.move(-999, e * -1));
4486
+ }
4487
+ render() {
4488
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
4489
+ hard: !0,
4490
+ trim: !1
4491
+ });
4492
+ if (e !== this._prevFrame) {
4493
+ if (this.state === "initial") this.output.write(import_src$1.cursor.hide);
4494
+ else {
4495
+ const s = _t$1(this._prevFrame, e), i = nt(this.output);
4496
+ if (this.restoreCursor(), s) {
4497
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
4498
+ let u = s.lines.find((a) => a >= r);
4499
+ if (u === void 0) {
4500
+ this._prevFrame = e;
4501
+ return;
4502
+ }
4503
+ if (s.lines.length === 1) {
4504
+ this.output.write(import_src$1.cursor.move(0, u - n)), this.output.write(import_src$1.erase.lines(1));
4505
+ const a = e.split(`
4506
+ `);
4507
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src$1.cursor.move(0, a.length - u - 1));
4508
+ return;
4509
+ } else if (s.lines.length > 1) {
4510
+ if (r < n) u = r;
4511
+ else {
4512
+ const l = u - n;
4513
+ l > 0 && this.output.write(import_src$1.cursor.move(0, l));
4514
+ }
4515
+ this.output.write(import_src$1.erase.down());
4516
+ const a = e.split(`
4517
+ `).slice(u);
4518
+ this.output.write(a.join(`
4519
+ `)), this._prevFrame = e;
4520
+ return;
4521
+ }
4522
+ }
4523
+ this.output.write(import_src$1.erase.down());
4524
+ }
4525
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
4526
+ }
4527
+ }
4528
+ };
4529
+ var kt = class extends x$1 {
4530
+ get cursor() {
4531
+ return this.value ? 0 : 1;
4532
+ }
4533
+ get _value() {
4534
+ return this.cursor === 0;
4535
+ }
4536
+ constructor(e) {
4537
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
4538
+ this.value = this._value;
4539
+ }), this.on("confirm", (s) => {
4540
+ this.output.write(import_src$1.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
4541
+ }), this.on("cursor", () => {
4542
+ this.value = !this.value;
4543
+ });
4544
+ }
4545
+ };
4546
+ function D(t$1, e, s) {
4547
+ const i = t$1 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
4548
+ return s[n].disabled ? D(n, e < 0 ? -1 : 1, s) : n;
4549
+ }
4550
+ var Mt = class extends x$1 {
4551
+ options;
4552
+ cursor = 0;
4553
+ get _value() {
4554
+ return this.options[this.cursor].value;
4555
+ }
4556
+ get _enabledOptions() {
4557
+ return this.options.filter((e) => e.disabled !== !0);
4558
+ }
4559
+ toggleAll() {
4560
+ const e = this._enabledOptions;
4561
+ this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
4562
+ }
4563
+ toggleInvert() {
4564
+ const e = this.value;
4565
+ if (!e) return;
4566
+ this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
4567
+ }
4568
+ toggleValue() {
4569
+ this.value === void 0 && (this.value = []);
4570
+ this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
4571
+ }
4572
+ constructor(e) {
4573
+ super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
4574
+ const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
4575
+ this.cursor = this.options[s].disabled ? D(s, 1, this.options) : s, this.on("key", (i) => {
4576
+ i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
4577
+ }), this.on("cursor", (i) => {
4578
+ switch (i) {
4579
+ case "left":
4580
+ case "up":
4581
+ this.cursor = D(this.cursor, -1, this.options);
4582
+ break;
4583
+ case "down":
4584
+ case "right":
4585
+ this.cursor = D(this.cursor, 1, this.options);
4586
+ break;
4587
+ case "space":
4588
+ this.toggleValue();
4589
+ break;
4590
+ }
4591
+ });
4592
+ }
4593
+ };
4594
+ var Lt = class extends x$1 {
4595
+ _mask = "•";
4596
+ get cursor() {
4597
+ return this._cursor;
4598
+ }
4599
+ get masked() {
4600
+ return this.userInput.replaceAll(/./g, this._mask);
4601
+ }
4602
+ get userInputWithCursor() {
4603
+ if (this.state === "submit" || this.state === "cancel") return this.masked;
4604
+ const e = this.userInput;
4605
+ if (this.cursor >= e.length) return `${this.masked}${import_picocolors_browser$1.default.inverse(import_picocolors_browser$1.default.hidden("_"))}`;
4606
+ const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
4607
+ return `${i}${import_picocolors_browser$1.default.inverse(r[0])}${r.slice(1)}`;
4608
+ }
4609
+ clear() {
4610
+ this._clearUserInput();
4611
+ }
4612
+ constructor({ mask: e, ...s }) {
4613
+ super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
4614
+ this._setValue(i);
4615
+ });
4616
+ }
4617
+ };
4618
+ var Wt = class extends x$1 {
4619
+ options;
4620
+ cursor = 0;
4621
+ get _selectedValue() {
4622
+ return this.options[this.cursor];
4623
+ }
4624
+ changeValue() {
4625
+ this.value = this._selectedValue.value;
4626
+ }
4627
+ constructor(e) {
4628
+ super(e, !1), this.options = e.options;
4629
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
4630
+ this.cursor = this.options[i].disabled ? D(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
4631
+ switch (r) {
4632
+ case "left":
4633
+ case "up":
4634
+ this.cursor = D(this.cursor, -1, this.options);
4635
+ break;
4636
+ case "down":
4637
+ case "right":
4638
+ this.cursor = D(this.cursor, 1, this.options);
4639
+ break;
4640
+ }
4641
+ this.changeValue();
4642
+ });
4643
+ }
4644
+ };
4645
+ var $t = class extends x$1 {
4646
+ get userInputWithCursor() {
4647
+ if (this.state === "submit") return this.userInput;
4648
+ const e = this.userInput;
4649
+ if (this.cursor >= e.length) return `${this.userInput}\u2588`;
4650
+ const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
4651
+ return `${s}${import_picocolors_browser$1.default.inverse(i)}${r.join("")}`;
4652
+ }
4653
+ get cursor() {
4654
+ return this._cursor;
4655
+ }
4656
+ constructor(e) {
4657
+ super({
4658
+ ...e,
4659
+ initialUserInput: e.initialUserInput ?? e.initialValue
4660
+ }), this.on("userInput", (s) => {
4661
+ this._setValue(s);
4662
+ }), this.on("finalize", () => {
4663
+ this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
4664
+ });
4665
+ }
4666
+ };
4667
+ var import_picocolors_browser = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1);
4668
+ require_src();
4669
+ var import___vite_browser_external = require___vite_browser_external();
4670
+ function ht() {
4671
+ return P.platform !== "win32" ? P.env.TERM !== "linux" : !!P.env.CI || !!P.env.WT_SESSION || !!P.env.TERMINUS_SUBLIME || P.env.ConEmuTask === "{cmd::Cmder}" || P.env.TERM_PROGRAM === "Terminus-Sublime" || P.env.TERM_PROGRAM === "vscode" || P.env.TERM === "xterm-256color" || P.env.TERM === "alacritty" || P.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
4672
+ }
4673
+ var ee = ht(), w = (e, r) => ee ? e : r, Me = w("◆", "*"), ce = w("■", "x"), de = w("▲", "x"), k = w("◇", "o");
4674
+ w("┌", "T");
4675
+ var h = w("│", "|"), x = w("└", "—");
4676
+ w("┐", "T");
4677
+ w("┘", "—");
4678
+ var Y = w("●", ">"), K = w("○", " "), te = w("◻", "[•]"), G = w("◼", "[+]"), z$1 = w("◻", "[ ]"), Pe = w("▪", "•");
4679
+ w("─", "-");
4680
+ w("╮", "+");
4681
+ w("├", "+");
4682
+ w("╯", "+");
4683
+ w("╰", "+");
4684
+ w("╭", "+");
4685
+ var ge = w("●", "•"), fe = w("◆", "*"), Fe = w("▲", "!"), ye = w("■", "x"), N = (e) => {
4686
+ switch (e) {
4687
+ case "initial":
4688
+ case "active": return import_picocolors_browser.default.cyan(Me);
4689
+ case "cancel": return import_picocolors_browser.default.red(ce);
4690
+ case "error": return import_picocolors_browser.default.yellow(de);
4691
+ case "submit": return import_picocolors_browser.default.green(k);
4692
+ }
4693
+ }, Ee = (e) => {
4694
+ switch (e) {
4695
+ case "initial":
4696
+ case "active": return import_picocolors_browser.default.cyan(h);
4697
+ case "cancel": return import_picocolors_browser.default.red(h);
4698
+ case "error": return import_picocolors_browser.default.yellow(h);
4699
+ case "submit": return import_picocolors_browser.default.green(h);
4700
+ }
4701
+ }, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, pt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, gt = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, ve = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ft = /\p{M}+/gu, Ft = {
4702
+ limit: Infinity,
4703
+ ellipsis: ""
4704
+ }, Le = (e, r = {}, s = {}) => {
4705
+ const i = r.limit ?? Infinity, n = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (n ? Le(n, Ft, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, a = s.tabWidth ?? 8, d = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, E = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, y$1 = s.wideWidth ?? 2;
4706
+ let $ = 0, c = 0, m = e.length, f = 0, F = !1, v = m, S$1 = Math.max(0, i - o), B = 0, b = 0, A = 0, C = 0;
4707
+ e: for (;;) {
4708
+ if (b > B || c >= m && c > $) {
4709
+ const _$1 = e.slice(B, b) || e.slice($, c);
4710
+ f = 0;
4711
+ for (const D$1 of _$1.replaceAll(ft, "")) {
4712
+ const T$1 = D$1.codePointAt(0) || 0;
4713
+ if (pt(T$1) ? C = E : gt(T$1) ? C = y$1 : d !== p && mt(T$1) ? C = d : C = p, A + C > S$1 && (v = Math.min(v, Math.max(B, $) + f)), A + C > i) {
4714
+ F = !0;
4715
+ break e;
4716
+ }
4717
+ f += D$1.length, A += C;
4718
+ }
4719
+ B = b = 0;
4720
+ }
4721
+ if (c >= m) break;
4722
+ if (ne.lastIndex = c, ne.test(e)) {
4723
+ if (f = ne.lastIndex - c, C = f * p, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / p))), A + C > i) {
4724
+ F = !0;
4725
+ break;
4726
+ }
4727
+ A += C, B = $, b = c, c = $ = ne.lastIndex;
4728
+ continue;
4729
+ }
4730
+ if (ve.lastIndex = c, ve.test(e)) {
4731
+ if (A + u > S$1 && (v = Math.min(v, c)), A + u > i) {
4732
+ F = !0;
4733
+ break;
4734
+ }
4735
+ A += u, B = $, b = c, c = $ = ve.lastIndex;
4736
+ continue;
4737
+ }
4738
+ if (re.lastIndex = c, re.test(e)) {
4739
+ if (f = re.lastIndex - c, C = f * l, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / l))), A + C > i) {
4740
+ F = !0;
4741
+ break;
4742
+ }
4743
+ A += C, B = $, b = c, c = $ = re.lastIndex;
4744
+ continue;
4745
+ }
4746
+ if (ie.lastIndex = c, ie.test(e)) {
4747
+ if (f = ie.lastIndex - c, C = f * a, A + C > S$1 && (v = Math.min(v, c + Math.floor((S$1 - A) / a))), A + C > i) {
4748
+ F = !0;
4749
+ break;
4750
+ }
4751
+ A += C, B = $, b = c, c = $ = ie.lastIndex;
4752
+ continue;
4753
+ }
4754
+ if (Ae.lastIndex = c, Ae.test(e)) {
4755
+ if (A + g > S$1 && (v = Math.min(v, c)), A + g > i) {
4756
+ F = !0;
4757
+ break;
4758
+ }
4759
+ A += g, B = $, b = c, c = $ = Ae.lastIndex;
4760
+ continue;
4761
+ }
4762
+ c += 1;
4763
+ }
4764
+ return {
4765
+ width: F ? S$1 : A,
4766
+ index: F ? v : m,
4767
+ truncated: F,
4768
+ ellipsed: F && i >= o
4769
+ };
4770
+ }, yt$1 = {
4771
+ limit: Infinity,
4772
+ ellipsis: "",
4773
+ ellipsisWidth: 0
4774
+ }, M = (e, r = {}) => Le(e, yt$1, r).width, ae = "\x1B", je = "›", Et = 39, Ce = "\x07", Ve = "[", vt = "]", ke = "m", we = `${vt}8;;`, Ge = new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${we}(?<uri>.*)${Ce})`, "y"), At = (e) => {
4775
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
4776
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
4777
+ if (e === 1 || e === 2) return 22;
4778
+ if (e === 3) return 23;
4779
+ if (e === 4) return 24;
4780
+ if (e === 7) return 27;
4781
+ if (e === 8) return 28;
4782
+ if (e === 9) return 29;
4783
+ if (e === 0) return 0;
4784
+ }, He = (e) => `${ae}${Ve}${e}${ke}`, Ue = (e) => `${ae}${we}${e}${Ce}`, Ct$1 = (e) => e.map((r) => M(r)), Se = (e, r, s) => {
4785
+ const i = r[Symbol.iterator]();
4786
+ let n = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : M(u), a = i.next(), d = i.next(), g = 0;
4787
+ for (; !a.done;) {
4788
+ const E = a.value, p = M(E);
4789
+ l + p <= s ? e[e.length - 1] += E : (e.push(E), l = 0), (E === ae || E === je) && (n = !0, o = r.startsWith(we, g + 1)), n ? o ? E === Ce && (n = !1, o = !1) : E === ke && (n = !1) : (l += p, l === s && !d.done && (e.push(""), l = 0)), a = d, d = i.next(), g += E.length;
4790
+ }
4791
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
4792
+ }, wt = (e) => {
4793
+ const r = e.split(" ");
4794
+ let s = r.length;
4795
+ for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
4796
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
4797
+ }, St = (e, r, s = {}) => {
4798
+ if (s.trim !== !1 && e.trim() === "") return "";
4799
+ let i = "", n, o;
4800
+ const u = e.split(" "), l = Ct$1(u);
4801
+ let a = [""];
4802
+ for (const [$, c] of u.entries()) {
4803
+ s.trim !== !1 && (a[a.length - 1] = (a.at(-1) ?? "").trimStart());
4804
+ let m = M(a.at(-1) ?? "");
4805
+ if ($ !== 0 && (m >= r && (s.wordWrap === !1 || s.trim === !1) && (a.push(""), m = 0), (m > 0 || s.trim === !1) && (a[a.length - 1] += " ", m++)), s.hard && l[$] > r) {
4806
+ const f = r - m, F = 1 + Math.floor((l[$] - f - 1) / r);
4807
+ Math.floor((l[$] - 1) / r) < F && a.push(""), Se(a, c, r);
4808
+ continue;
4809
+ }
4810
+ if (m + l[$] > r && m > 0 && l[$] > 0) {
4811
+ if (s.wordWrap === !1 && m < r) {
4812
+ Se(a, c, r);
4813
+ continue;
4814
+ }
4815
+ a.push("");
4816
+ }
4817
+ if (m + l[$] > r && s.wordWrap === !1) {
4818
+ Se(a, c, r);
4819
+ continue;
4820
+ }
4821
+ a[a.length - 1] += c;
4822
+ }
4823
+ s.trim !== !1 && (a = a.map(($) => wt($)));
4824
+ const d = a.join(`
4825
+ `), g = d[Symbol.iterator]();
4826
+ let E = g.next(), p = g.next(), y$1 = 0;
4827
+ for (; !E.done;) {
4828
+ const $ = E.value, c = p.value;
4829
+ if (i += $, $ === ae || $ === je) {
4830
+ Ge.lastIndex = y$1 + 1;
4831
+ const F = Ge.exec(d)?.groups;
4832
+ if (F?.code !== void 0) {
4833
+ const v = Number.parseFloat(F.code);
4834
+ n = v === Et ? void 0 : v;
4835
+ } else F?.uri !== void 0 && (o = F.uri.length === 0 ? void 0 : F.uri);
4836
+ }
4837
+ const m = n ? At(n) : void 0;
4838
+ c === `
4839
+ ` ? (o && (i += Ue("")), n && m && (i += He(m))) : $ === `
4840
+ ` && (n && m && (i += He(n)), o && (i += Ue(o))), y$1 += $.length, E = p, p = g.next();
4841
+ }
4842
+ return i;
4843
+ };
4844
+ function q(e, r, s) {
4845
+ return String(e).normalize().replaceAll(`\r
4846
+ `, `
4847
+ `).split(`
4848
+ `).map((i) => St(i, r, s)).join(`
4849
+ `);
4850
+ }
4851
+ var It$1 = (e, r, s, i, n) => {
4852
+ let o = r, u = 0;
4853
+ for (let l = s; l < i; l++) {
4854
+ const a = e[l];
4855
+ if (o = o - a.length, u++, o <= n) break;
4856
+ }
4857
+ return {
4858
+ lineCount: o,
4859
+ removals: u
4860
+ };
4861
+ }, J = (e) => {
4862
+ const { cursor: r, options: s, style: i } = e, n = e.output ?? process.stdout, o = rt(n), u = e.columnPadding ?? 0, l = e.rowPadding ?? 4, a = o - u, d = nt(n), g = import_picocolors_browser.default.dim("..."), E = e.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(d - l, 0), y$1 = Math.max(Math.min(E, p), 5);
4863
+ let $ = 0;
4864
+ r >= y$1 - 3 && ($ = Math.max(Math.min(r - y$1 + 3, s.length - y$1), 0));
4865
+ let c = y$1 < s.length && $ > 0, m = y$1 < s.length && $ + y$1 < s.length;
4866
+ const f = Math.min($ + y$1, s.length), F = [];
4867
+ let v = 0;
4868
+ c && v++, m && v++;
4869
+ const S$1 = $ + (c ? 1 : 0), B = f - (m ? 1 : 0);
4870
+ for (let A = S$1; A < B; A++) {
4871
+ const C = q(i(s[A], A === r), a, {
4872
+ hard: !0,
4873
+ trim: !1
4874
+ }).split(`
4875
+ `);
4876
+ F.push(C), v += C.length;
4877
+ }
4878
+ if (v > p) {
4879
+ let A = 0, C = 0, _$1 = v;
4880
+ const D$1 = r - S$1, T$1 = (W$1, I$1) => It$1(F, _$1, W$1, I$1, p);
4881
+ c ? ({lineCount: _$1, removals: A} = T$1(0, D$1), _$1 > p && ({lineCount: _$1, removals: C} = T$1(D$1 + 1, F.length))) : ({lineCount: _$1, removals: C} = T$1(D$1 + 1, F.length), _$1 > p && ({lineCount: _$1, removals: A} = T$1(0, D$1))), A > 0 && (c = !0, F.splice(0, A)), C > 0 && (m = !0, F.splice(F.length - C, C));
4882
+ }
4883
+ const b = [];
4884
+ c && b.push(g);
4885
+ for (const A of F) for (const C of A) b.push(C);
4886
+ return m && b.push(g), b;
4887
+ }, Mt$1 = (e) => {
4888
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
4889
+ return new kt({
4890
+ active: r,
4891
+ inactive: s,
4892
+ signal: e.signal,
4893
+ input: e.input,
4894
+ output: e.output,
4895
+ initialValue: e.initialValue ?? !0,
4896
+ render() {
4897
+ const i = `${import_picocolors_browser.default.gray(h)}
4898
+ ${N(this.state)} ${e.message}
4899
+ `, n = this.value ? r : s;
4900
+ switch (this.state) {
4901
+ case "submit": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.dim(n)}`;
4902
+ case "cancel": return `${i}${import_picocolors_browser.default.gray(h)} ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(n))}
4903
+ ${import_picocolors_browser.default.gray(h)}`;
4904
+ default: return `${i}${import_picocolors_browser.default.cyan(h)} ${this.value ? `${import_picocolors_browser.default.green(Y)} ${r}` : `${import_picocolors_browser.default.dim(K)} ${import_picocolors_browser.default.dim(r)}`} ${import_picocolors_browser.default.dim("/")} ${this.value ? `${import_picocolors_browser.default.dim(K)} ${import_picocolors_browser.default.dim(s)}` : `${import_picocolors_browser.default.green(Y)} ${s}`}
4905
+ ${import_picocolors_browser.default.cyan(x)}
4906
+ `;
4907
+ }
4908
+ }
4909
+ }).prompt();
4910
+ }, R = {
4911
+ message: (e = [], { symbol: r = import_picocolors_browser.default.gray(h), secondarySymbol: s = import_picocolors_browser.default.gray(h), output: i = process.stdout, spacing: n = 1, withGuide: o } = {}) => {
4912
+ const u = [], l = (o ?? _.withGuide) !== !1, a = l ? s : "", d = l ? `${r} ` : "", g = l ? `${s} ` : "";
4913
+ for (let p = 0; p < n; p++) u.push(a);
4914
+ const E = Array.isArray(e) ? e : e.split(`
4915
+ `);
4916
+ if (E.length > 0) {
4917
+ const [p, ...y$1] = E;
4918
+ p.length > 0 ? u.push(`${d}${p}`) : u.push(l ? r : "");
4919
+ for (const $ of y$1) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
4920
+ }
4921
+ i.write(`${u.join(`
4922
+ `)}
4923
+ `);
4924
+ },
4925
+ info: (e, r) => {
4926
+ R.message(e, {
4927
+ ...r,
4928
+ symbol: import_picocolors_browser.default.blue(ge)
4929
+ });
4930
+ },
4931
+ success: (e, r) => {
4932
+ R.message(e, {
4933
+ ...r,
4934
+ symbol: import_picocolors_browser.default.green(fe)
4935
+ });
4936
+ },
4937
+ step: (e, r) => {
4938
+ R.message(e, {
4939
+ ...r,
4940
+ symbol: import_picocolors_browser.default.green(k)
4941
+ });
4942
+ },
4943
+ warn: (e, r) => {
4944
+ R.message(e, {
4945
+ ...r,
4946
+ symbol: import_picocolors_browser.default.yellow(Fe)
4947
+ });
4948
+ },
4949
+ warning: (e, r) => {
4950
+ R.warn(e, r);
4951
+ },
4952
+ error: (e, r) => {
4953
+ R.message(e, {
4954
+ ...r,
4955
+ symbol: import_picocolors_browser.default.red(ye)
4956
+ });
4957
+ }
4958
+ }, Pt = (e = "", r) => {
4959
+ (r?.output ?? process.stdout).write(`${import_picocolors_browser.default.gray(x)} ${import_picocolors_browser.default.red(e)}
4960
+
4961
+ `);
4962
+ }, Q = (e, r) => e.split(`
4963
+ `).map((s) => r(s)).join(`
4964
+ `), Lt$1 = (e) => {
4965
+ const r = (i, n) => {
4966
+ const o = i.label ?? String(i.value);
4967
+ return n === "disabled" ? `${import_picocolors_browser.default.gray(z$1)} ${Q(o, (u) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.gray(u)))}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : n === "active" ? `${import_picocolors_browser.default.cyan(te)} ${o}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "selected" ? `${import_picocolors_browser.default.green(G)} ${Q(o, import_picocolors_browser.default.dim)}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "cancelled" ? `${Q(o, (u) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(u)))}` : n === "active-selected" ? `${import_picocolors_browser.default.green(G)} ${o}${i.hint ? ` ${import_picocolors_browser.default.dim(`(${i.hint})`)}` : ""}` : n === "submitted" ? `${Q(o, import_picocolors_browser.default.dim)}` : `${import_picocolors_browser.default.dim(z$1)} ${Q(o, import_picocolors_browser.default.dim)}`;
4968
+ }, s = e.required ?? !0;
4969
+ return new Mt({
4970
+ options: e.options,
4971
+ signal: e.signal,
4972
+ input: e.input,
4973
+ output: e.output,
4974
+ initialValues: e.initialValues,
4975
+ required: s,
4976
+ cursorAt: e.cursorAt,
4977
+ validate(i) {
4978
+ if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
4979
+ ${import_picocolors_browser.default.reset(import_picocolors_browser.default.dim(`Press ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" space ")))} to select, ${import_picocolors_browser.default.gray(import_picocolors_browser.default.bgWhite(import_picocolors_browser.default.inverse(" enter ")))} to submit`))}`;
4980
+ },
4981
+ render() {
4982
+ const i = Bt(e.output, e.message, `${Ee(this.state)} `, `${N(this.state)} `), n = `${import_picocolors_browser.default.gray(h)}
4983
+ ${i}
4984
+ `, o = this.value ?? [], u = (l, a) => {
4985
+ if (l.disabled) return r(l, "disabled");
4986
+ const d = o.includes(l.value);
4987
+ return a && d ? r(l, "active-selected") : d ? r(l, "selected") : r(l, a ? "active" : "inactive");
4988
+ };
4989
+ switch (this.state) {
4990
+ case "submit": {
4991
+ const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "submitted")).join(import_picocolors_browser.default.dim(", ")) || import_picocolors_browser.default.dim("none");
4992
+ return `${n}${Bt(e.output, l, `${import_picocolors_browser.default.gray(h)} `)}`;
4993
+ }
4994
+ case "cancel": {
4995
+ const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "cancelled")).join(import_picocolors_browser.default.dim(", "));
4996
+ if (l.trim() === "") return `${n}${import_picocolors_browser.default.gray(h)}`;
4997
+ return `${n}${Bt(e.output, l, `${import_picocolors_browser.default.gray(h)} `)}
4998
+ ${import_picocolors_browser.default.gray(h)}`;
4999
+ }
5000
+ case "error": {
5001
+ const l = `${import_picocolors_browser.default.yellow(h)} `, a = this.error.split(`
5002
+ `).map((E, p) => p === 0 ? `${import_picocolors_browser.default.yellow(x)} ${import_picocolors_browser.default.yellow(E)}` : ` ${E}`).join(`
5003
+ `), d = n.split(`
5004
+ `).length, g = a.split(`
5005
+ `).length + 1;
5006
+ return `${n}${l}${J({
5007
+ output: e.output,
5008
+ options: this.options,
5009
+ cursor: this.cursor,
5010
+ maxItems: e.maxItems,
5011
+ columnPadding: l.length,
5012
+ rowPadding: d + g,
5013
+ style: u
5014
+ }).join(`
5015
+ ${l}`)}
5016
+ ${a}
5017
+ `;
5018
+ }
5019
+ default: {
5020
+ const l = `${import_picocolors_browser.default.cyan(h)} `, a = n.split(`
5021
+ `).length;
5022
+ return `${n}${l}${J({
5023
+ output: e.output,
5024
+ options: this.options,
5025
+ cursor: this.cursor,
5026
+ maxItems: e.maxItems,
5027
+ columnPadding: l.length,
5028
+ rowPadding: a + 2,
5029
+ style: u
5030
+ }).join(`
5031
+ ${l}`)}
5032
+ ${import_picocolors_browser.default.cyan(x)}
5033
+ `;
5034
+ }
5035
+ }
5036
+ }
5037
+ }).prompt();
5038
+ }, Gt = (e) => new Lt({
5039
+ validate: e.validate,
5040
+ mask: e.mask ?? Pe,
5041
+ signal: e.signal,
5042
+ input: e.input,
5043
+ output: e.output,
5044
+ render() {
5045
+ const r = `${import_picocolors_browser.default.gray(h)}
5046
+ ${N(this.state)} ${e.message}
5047
+ `, s = this.userInputWithCursor, i = this.masked;
5048
+ switch (this.state) {
5049
+ case "error": {
5050
+ const n = i ? ` ${i}` : "";
5051
+ return e.clearOnError && this.clear(), `${r.trim()}
5052
+ ${import_picocolors_browser.default.yellow(h)}${n}
5053
+ ${import_picocolors_browser.default.yellow(x)} ${import_picocolors_browser.default.yellow(this.error)}
5054
+ `;
5055
+ }
5056
+ case "submit": {
5057
+ const n = i ? ` ${import_picocolors_browser.default.dim(i)}` : "";
5058
+ return `${r}${import_picocolors_browser.default.gray(h)}${n}`;
5059
+ }
5060
+ case "cancel": {
5061
+ const n = i ? ` ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(i))}` : "";
5062
+ return `${r}${import_picocolors_browser.default.gray(h)}${n}${i ? `
5063
+ ${import_picocolors_browser.default.gray(h)}` : ""}`;
5064
+ }
5065
+ default: return `${r}${import_picocolors_browser.default.cyan(h)} ${s}
5066
+ ${import_picocolors_browser.default.cyan(x)}
5067
+ `;
5068
+ }
5069
+ }
5070
+ }).prompt();
5071
+ import_picocolors_browser.default.magenta;
5072
+ w("─", "-"), w("━", "="), w("█", "#");
5073
+ var oe = (e, r) => e.includes(`
5074
+ `) ? e.split(`
5075
+ `).map((s) => r(s)).join(`
5076
+ `) : r(e), qt = (e) => {
5077
+ const r = (s, i) => {
5078
+ const n = s.label ?? String(s.value);
5079
+ switch (i) {
5080
+ case "disabled": return `${import_picocolors_browser.default.gray(K)} ${oe(n, import_picocolors_browser.default.gray)}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
5081
+ case "selected": return `${oe(n, import_picocolors_browser.default.dim)}`;
5082
+ case "active": return `${import_picocolors_browser.default.green(Y)} ${n}${s.hint ? ` ${import_picocolors_browser.default.dim(`(${s.hint})`)}` : ""}`;
5083
+ case "cancelled": return `${oe(n, (o) => import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(o)))}`;
5084
+ default: return `${import_picocolors_browser.default.dim(K)} ${oe(n, import_picocolors_browser.default.dim)}`;
5085
+ }
5086
+ };
5087
+ return new Wt({
5088
+ options: e.options,
5089
+ signal: e.signal,
5090
+ input: e.input,
5091
+ output: e.output,
5092
+ initialValue: e.initialValue,
5093
+ render() {
5094
+ const s = `${N(this.state)} `, i = `${Ee(this.state)} `, n = Bt(e.output, e.message, i, s), o = `${import_picocolors_browser.default.gray(h)}
5095
+ ${n}
5096
+ `;
5097
+ switch (this.state) {
5098
+ case "submit": {
5099
+ const u = `${import_picocolors_browser.default.gray(h)} `;
5100
+ return `${o}${Bt(e.output, r(this.options[this.cursor], "selected"), u)}`;
5101
+ }
5102
+ case "cancel": {
5103
+ const u = `${import_picocolors_browser.default.gray(h)} `;
5104
+ return `${o}${Bt(e.output, r(this.options[this.cursor], "cancelled"), u)}
5105
+ ${import_picocolors_browser.default.gray(h)}`;
5106
+ }
5107
+ default: {
5108
+ const u = `${import_picocolors_browser.default.cyan(h)} `, l = o.split(`
5109
+ `).length;
5110
+ return `${o}${u}${J({
5111
+ output: e.output,
5112
+ cursor: this.cursor,
5113
+ options: this.options,
5114
+ maxItems: e.maxItems,
5115
+ columnPadding: u.length,
5116
+ rowPadding: l + 2,
5117
+ style: (a, d) => r(a, a.disabled ? "disabled" : d ? "active" : "inactive")
5118
+ }).join(`
5119
+ ${u}`)}
5120
+ ${import_picocolors_browser.default.cyan(x)}
5121
+ `;
5122
+ }
5123
+ }
5124
+ }
5125
+ }).prompt();
5126
+ }, ze = `${import_picocolors_browser.default.gray(h)} `, H = {
5127
+ message: async (e, { symbol: r = import_picocolors_browser.default.gray(h) } = {}) => {
5128
+ process.stdout.write(`${import_picocolors_browser.default.gray(h)}
5129
+ ${r} `);
5130
+ let s = 3;
5131
+ for await (let i of e) {
5132
+ i = i.replace(/\n/g, `
5133
+ ${ze}`), i.includes(`
5134
+ `) && (s = 3 + (0, import___vite_browser_external.stripVTControlCharacters)(i.slice(i.lastIndexOf(`
5135
+ `))).length);
5136
+ const n = (0, import___vite_browser_external.stripVTControlCharacters)(i).length;
5137
+ s + n < process.stdout.columns ? (s += n, process.stdout.write(i)) : (process.stdout.write(`
5138
+ ${ze}${i.trimStart()}`), s = 3 + (0, import___vite_browser_external.stripVTControlCharacters)(i.trimStart()).length);
5139
+ }
5140
+ process.stdout.write(`
5141
+ `);
5142
+ },
5143
+ info: (e) => H.message(e, { symbol: import_picocolors_browser.default.blue(ge) }),
5144
+ success: (e) => H.message(e, { symbol: import_picocolors_browser.default.green(fe) }),
5145
+ step: (e) => H.message(e, { symbol: import_picocolors_browser.default.green(k) }),
5146
+ warn: (e) => H.message(e, { symbol: import_picocolors_browser.default.yellow(Fe) }),
5147
+ warning: (e) => H.warn(e),
5148
+ error: (e) => H.message(e, { symbol: import_picocolors_browser.default.red(ye) })
5149
+ }, Qt = (e) => new $t({
5150
+ validate: e.validate,
5151
+ placeholder: e.placeholder,
5152
+ defaultValue: e.defaultValue,
5153
+ initialValue: e.initialValue,
5154
+ output: e.output,
5155
+ signal: e.signal,
5156
+ input: e.input,
5157
+ render() {
5158
+ const r = (e?.withGuide ?? _.withGuide) !== !1, s = `${`${r ? `${import_picocolors_browser.default.gray(h)}
5159
+ ` : ""}${N(this.state)} `}${e.message}
5160
+ `, i = e.placeholder ? import_picocolors_browser.default.inverse(e.placeholder[0]) + import_picocolors_browser.default.dim(e.placeholder.slice(1)) : import_picocolors_browser.default.inverse(import_picocolors_browser.default.hidden("_")), n = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
5161
+ switch (this.state) {
5162
+ case "error": {
5163
+ const u = this.error ? ` ${import_picocolors_browser.default.yellow(this.error)}` : "", l = r ? `${import_picocolors_browser.default.yellow(h)} ` : "", a = r ? import_picocolors_browser.default.yellow(x) : "";
5164
+ return `${s.trim()}
5165
+ ${l}${n}
5166
+ ${a}${u}
5167
+ `;
5168
+ }
5169
+ case "submit": {
5170
+ const u = o ? ` ${import_picocolors_browser.default.dim(o)}` : "";
5171
+ return `${s}${r ? import_picocolors_browser.default.gray(h) : ""}${u}`;
5172
+ }
5173
+ case "cancel": {
5174
+ const u = o ? ` ${import_picocolors_browser.default.strikethrough(import_picocolors_browser.default.dim(o))}` : "", l = r ? import_picocolors_browser.default.gray(h) : "";
5175
+ return `${s}${l}${u}${o.trim() ? `
5176
+ ${l}` : ""}`;
5177
+ }
5178
+ default: return `${s}${r ? `${import_picocolors_browser.default.cyan(h)} ` : ""}${n}
5179
+ ${r ? import_picocolors_browser.default.cyan(x) : ""}
5180
+ `;
5181
+ }
5182
+ }
5183
+ }).prompt();
5184
+ var PromptManager = class PromptManager {
5185
+ #context;
5186
+ #onCancel;
5187
+ constructor(options) {
5188
+ this.#context = options.context;
5189
+ this.#onCancel = options.onCancel;
5190
+ }
5191
+ static isInteractiveEnvironment() {
5192
+ if (typeof process !== "undefined" && process.stdin) return process.stdin.isTTY === true;
5193
+ return false;
5194
+ }
5195
+ static shouldTriggerInteractive(promptWhen, flags, args) {
5196
+ switch (promptWhen) {
5197
+ case "always": return true;
5198
+ case "interactive-flag": return args["interactive"] === true;
5199
+ case "missing": return flags.some(({ name }) => {
5200
+ const value = args[name];
5201
+ return value === void 0 || value === null || value === "";
5202
+ });
5203
+ default: return false;
5204
+ }
5205
+ }
5206
+ static sortFlagsBySequence(flags) {
5207
+ return [...flags].sort((a, b) => {
5208
+ const seqA = a.flag.promptSequence ?? a.index;
5209
+ const seqB = b.flag.promptSequence ?? b.index;
5210
+ if (seqA !== seqB) return seqA - seqB;
5211
+ return a.index - b.index;
5212
+ });
5213
+ }
5214
+ async executePrompts(flags) {
5215
+ const flagsWithIndex = flags.map((f, index) => ({
5216
+ ...f,
5217
+ index
5218
+ }));
5219
+ const sortedFlags = PromptManager.sortFlagsBySequence(flagsWithIndex);
5220
+ const answers = {};
5221
+ for (const { flag, name } of sortedFlags) try {
5222
+ if (!flag.prompt) continue;
5223
+ const config = await flag.prompt(this.#context);
5224
+ answers[name] = await this.#executePromptWithValidation(name, config);
5225
+ this.#context.promptAnswers = {
5226
+ ...this.#context.promptAnswers,
5227
+ ...answers
5228
+ };
5229
+ } catch (error) {
5230
+ if (this.#isCancelled(error)) {
5231
+ await this.#handleCancel();
5232
+ return {
5233
+ success: false,
5234
+ answers,
5235
+ cancelled: true
5236
+ };
5237
+ }
5238
+ throw error;
5239
+ }
5240
+ return {
5241
+ success: true,
5242
+ answers,
5243
+ cancelled: false
5244
+ };
5245
+ }
5246
+ async #executePromptWithValidation(name, config) {
5247
+ while (true) {
5248
+ const value = await this.#executePrompt(config);
5249
+ if (Ct(value)) throw new Error("USER_CANCELLED");
5250
+ if (config.validate) {
5251
+ const validationResult = await config.validate(value, this.#context);
5252
+ if (validationResult === true) return value;
5253
+ else if (typeof validationResult === "string") {
5254
+ R.error(validationResult);
5255
+ continue;
5256
+ } else {
5257
+ R.error(`Invalid value for ${name}`);
5258
+ continue;
5259
+ }
5260
+ }
5261
+ return value;
5262
+ }
5263
+ }
5264
+ async #executePrompt(config) {
5265
+ switch (config.type) {
5266
+ case "text": return Qt({
5267
+ message: config.message,
5268
+ placeholder: config.placeholder,
5269
+ initialValue: config.initial
5270
+ });
5271
+ case "password": return Gt({ message: config.message });
5272
+ case "confirm": return Mt$1({
5273
+ message: config.message,
5274
+ initialValue: config.initial ?? false
5275
+ });
5276
+ case "select": return qt({
5277
+ message: config.message,
5278
+ options: this.#normalizeOptions(config.options ?? []),
5279
+ initialValue: config.initial,
5280
+ maxItems: config.maxItems
5281
+ });
5282
+ case "multiselect": return Lt$1({
5283
+ message: config.message,
5284
+ options: this.#normalizeOptions(config.options ?? []),
5285
+ initialValues: config.initial,
5286
+ maxItems: config.maxItems
5287
+ });
5288
+ default: throw new Error(`Unknown prompt type: ${config.type}`);
5289
+ }
5290
+ }
5291
+ #normalizeOptions(options) {
5292
+ return options.map((opt) => {
5293
+ if (typeof opt === "string") return {
5294
+ value: opt,
5295
+ label: opt
5296
+ };
5297
+ return opt;
5298
+ });
5299
+ }
5300
+ async #handleCancel() {
5301
+ Pt("Operation cancelled by user");
5302
+ if (this.#onCancel) await this.#onCancel(this.#context);
5303
+ }
5304
+ #isCancelled(error) {
5305
+ if (error instanceof Error) return error.message === "USER_CANCELLED";
5306
+ return false;
5307
+ }
4004
5308
  };
5309
+ function detectAndStripSystemFlags(processArgs) {
5310
+ const systemArgs = {};
5311
+ const filteredArgs = [];
5312
+ for (let i = 0; i < processArgs.length; i++) {
5313
+ const arg = processArgs[i];
5314
+ const nextArg = processArgs[i + 1];
5315
+ const hasNextArg = nextArg !== void 0 && !nextArg.startsWith("-");
5316
+ switch (arg) {
5317
+ case "--s-debug":
5318
+ systemArgs.debug = true;
5319
+ break;
5320
+ case "--s-debug-print":
5321
+ systemArgs.debugPrint = true;
5322
+ break;
5323
+ case "--s-enable-fuzzy":
5324
+ systemArgs.enableFuzzy = true;
5325
+ break;
5326
+ case "--s-with-env":
5327
+ systemArgs.withEnv = hasNextArg ? nextArg : true;
5328
+ if (hasNextArg) i++;
5329
+ break;
5330
+ case "--s-save-to-env":
5331
+ systemArgs.saveToEnv = true;
5332
+ break;
5333
+ case "--s-build-dxt":
5334
+ systemArgs.buildDxt = hasNextArg ? nextArg : true;
5335
+ if (hasNextArg) i++;
5336
+ break;
5337
+ case "--s-mcp-serve":
5338
+ systemArgs.mcpServe = true;
5339
+ break;
5340
+ case "--s-mcp-transport":
5341
+ if (hasNextArg) {
5342
+ systemArgs.mcpTransport = nextArg;
5343
+ i++;
5344
+ }
5345
+ break;
5346
+ case "--s-mcp-port":
5347
+ if (hasNextArg) {
5348
+ systemArgs.mcpPort = parseInt(nextArg, 10);
5349
+ i++;
5350
+ }
5351
+ break;
5352
+ case "--s-mcp-host":
5353
+ if (hasNextArg) {
5354
+ systemArgs.mcpHost = nextArg;
5355
+ i++;
5356
+ }
5357
+ break;
5358
+ case "--s-mcp-path":
5359
+ if (hasNextArg) {
5360
+ systemArgs.mcpPath = nextArg;
5361
+ i++;
5362
+ }
5363
+ break;
5364
+ case "--s-mcp-transports":
5365
+ if (hasNextArg) {
5366
+ systemArgs.mcpTransports = nextArg;
5367
+ i++;
5368
+ }
5369
+ break;
5370
+ case "--s-mcp-log-path":
5371
+ if (hasNextArg) {
5372
+ systemArgs.mcpLogPath = nextArg;
5373
+ i++;
5374
+ }
5375
+ break;
5376
+ case "--s-mcp-cors":
5377
+ if (hasNextArg) {
5378
+ try {
5379
+ systemArgs.mcpCors = JSON.parse(nextArg);
5380
+ } catch {
5381
+ systemArgs.mcpCors = nextArg;
5382
+ }
5383
+ i++;
5384
+ }
5385
+ break;
5386
+ case "--s-mcp-auth":
5387
+ if (hasNextArg) {
5388
+ try {
5389
+ systemArgs.mcpAuth = JSON.parse(nextArg);
5390
+ } catch {
5391
+ systemArgs.mcpAuth = nextArg;
5392
+ }
5393
+ i++;
5394
+ }
5395
+ break;
5396
+ case "--transport":
5397
+ if (hasNextArg) {
5398
+ systemArgs.mcpTransport = nextArg;
5399
+ i++;
5400
+ }
5401
+ break;
5402
+ case "--port":
5403
+ if (hasNextArg) {
5404
+ systemArgs.mcpPort = parseInt(nextArg, 10);
5405
+ i++;
5406
+ }
5407
+ break;
5408
+ case "--host":
5409
+ if (hasNextArg) {
5410
+ systemArgs.mcpHost = nextArg;
5411
+ i++;
5412
+ }
5413
+ break;
5414
+ case "--path":
5415
+ if (hasNextArg) {
5416
+ systemArgs.mcpPath = nextArg;
5417
+ i++;
5418
+ }
5419
+ break;
5420
+ case "--transports":
5421
+ if (hasNextArg) {
5422
+ systemArgs.mcpTransports = nextArg;
5423
+ i++;
5424
+ }
5425
+ break;
5426
+ default: filteredArgs.push(arg);
5427
+ }
5428
+ }
5429
+ return {
5430
+ systemArgs,
5431
+ filteredArgs
5432
+ };
5433
+ }
4005
5434
  var ArgParserError = class extends Error {
4006
5435
  constructor(message, cmdChain = []) {
4007
5436
  super(message);
@@ -4042,6 +5471,8 @@ var ArgParserBase = class ArgParserBase {
4042
5471
  #effectiveWorkingDirectory = null;
4043
5472
  #rootPath = null;
4044
5473
  #workingDirectoryResolved = false;
5474
+ #promptWhen = "interactive-flag";
5475
+ #onCancel;
4045
5476
  constructor(options = {}, initialFlags) {
4046
5477
  this.#appName = options.appName || "app";
4047
5478
  if (options.blankSpaceWidth && !isNaN(Number(options.blankSpaceWidth)) && Number(options.blankSpaceWidth) > 20) this.#parameters.blankSpaceWidth = Number(options.blankSpaceWidth);
@@ -4078,6 +5509,8 @@ var ArgParserBase = class ArgParserBase {
4078
5509
  this.#dxtGenerator = new DxtGenerator(this);
4079
5510
  this.#configurationManager = new ConfigurationManager(this);
4080
5511
  if (options.subCommands) for (const sub of options.subCommands) this.addSubCommand(sub);
5512
+ this.#promptWhen = options.promptWhen ?? "interactive-flag";
5513
+ this.#onCancel = options.onCancel;
4081
5514
  }
4082
5515
  get flags() {
4083
5516
  return this.#flagManager.flags;
@@ -4121,6 +5554,14 @@ var ArgParserBase = class ArgParserBase {
4121
5554
  getSubCommands() {
4122
5555
  return this.#subCommands;
4123
5556
  }
5557
+ setPromptWhen(promptWhen) {
5558
+ this.#promptWhen = promptWhen;
5559
+ return this;
5560
+ }
5561
+ setOnCancel(onCancel) {
5562
+ this.#onCancel = onCancel;
5563
+ return this;
5564
+ }
4124
5565
  async _addToOutput(flag, arg, output, _parseOptions) {
4125
5566
  let value = arg;
4126
5567
  if (flag["type"] === Boolean) if (typeof arg === "boolean") value = arg;
@@ -4198,7 +5639,20 @@ var ArgParserBase = class ArgParserBase {
4198
5639
  this.#flagManager.addFlag(flag);
4199
5640
  return this;
4200
5641
  }
5642
+ getPromptableFlags() {
5643
+ const promptableFlags = [];
5644
+ for (const flag of this.#flagManager.flags) if ("prompt" in flag && typeof flag["prompt"] === "function") promptableFlags.push({
5645
+ flag,
5646
+ name: flag["name"]
5647
+ });
5648
+ return promptableFlags;
5649
+ }
5650
+ getPromptWhen() {
5651
+ return this.#promptWhen;
5652
+ }
4201
5653
  addSubCommand(subCommandConfig) {
5654
+ if ("promptWhen" in subCommandConfig && subCommandConfig.promptWhen) subCommandConfig.parser.setPromptWhen?.(subCommandConfig.promptWhen);
5655
+ if ("onCancel" in subCommandConfig && subCommandConfig.onCancel) subCommandConfig.parser.setOnCancel?.(subCommandConfig.onCancel);
4202
5656
  if (this.#subCommands.has(subCommandConfig.name)) throw new Error(`Sub-command '${subCommandConfig.name}' already exists`);
4203
5657
  const subParser = subCommandConfig.parser;
4204
5658
  if (!(subParser instanceof ArgParserBase)) throw new Error(`Parser for subcommand '${subCommandConfig.name}' is not an instance of ArgParserBase. Please provide 'new ArgParserBase(...)' for the 'parser' property of an ISubCommand.`);
@@ -4218,7 +5672,7 @@ var ArgParserBase = class ArgParserBase {
4218
5672
  return this;
4219
5673
  }
4220
5674
  #propagateFlagsRecursive(parser) {
4221
- for (const [_, subConfig] of parser.getSubCommands()) {
5675
+ for (const [_$1, subConfig] of parser.getSubCommands()) {
4222
5676
  const childParser = subConfig.parser;
4223
5677
  if (!(childParser instanceof ArgParserBase)) continue;
4224
5678
  if (childParser.#inheritParentFlags === FlagInheritance.AllParents) {
@@ -4307,9 +5761,9 @@ var ArgParserBase = class ArgParserBase {
4307
5761
  foundCwd = resolvedPath;
4308
5762
  process.chdir(resolvedPath);
4309
5763
  const allChdirIndices = [];
4310
- for (let j = 0; j < processArgs.length; j++) for (const p of parserChain) for (const f of p.#flagManager.flags) if (f["setWorkingDirectory"] && f["options"].includes(processArgs[j])) allChdirIndices.push({
4311
- index: j,
4312
- flag: processArgs[j]
5764
+ for (let j$1 = 0; j$1 < processArgs.length; j$1++) for (const p of parserChain) for (const f of p.#flagManager.flags) if (f["setWorkingDirectory"] && f["options"].includes(processArgs[j$1])) allChdirIndices.push({
5765
+ index: j$1,
5766
+ flag: processArgs[j$1]
4313
5767
  });
4314
5768
  if (allChdirIndices.length > 1) this.#logger.warn(SimpleChalk_default.yellow(`Warning: Multiple working directory flags detected. Using '${option}' (last one in command chain).`));
4315
5769
  break;
@@ -4614,18 +6068,30 @@ var ArgParserBase = class ArgParserBase {
4614
6068
  else throw new Error("parse() called without arguments in non-Node.js environment. Please provide arguments explicitly: parse(['--flag', 'value'])");
4615
6069
  this.#resetDynamicFlagsRecursive();
4616
6070
  const originalProcessArgs = [...processArgs];
4617
- if (typeof process !== "undefined" && (process.env["ARGPARSER_FUZZY_MODE"] === "true" || process.argv && process.argv.includes("--s-enable-fuzzy") && !processArgs.includes("--s-enable-fuzzy")) && !options?.skipHelpHandling) return {
6071
+ const { systemArgs: detectedSystemArgs } = detectAndStripSystemFlags(processArgs);
6072
+ if (typeof process !== "undefined" && (process.env["ARGPARSER_FUZZY_MODE"] === "true" || detectedSystemArgs.enableFuzzy === true) && !options?.skipHelpHandling) return {
4618
6073
  _fuzzyModePreventedExecution: true,
4619
- _originalInputArgs: originalProcessArgs
6074
+ _originalInputArgs: originalProcessArgs,
6075
+ systemArgs: detectedSystemArgs
4620
6076
  };
4621
6077
  const globalCheckResult = await this.#_handleGlobalChecks(processArgs, options);
4622
- if (globalCheckResult !== false) return globalCheckResult === true ? {} : globalCheckResult;
6078
+ const { filteredArgs: processArgsWithoutSystemFlags } = detectAndStripSystemFlags(processArgs);
6079
+ processArgs.length = 0;
6080
+ processArgs.push(...processArgsWithoutSystemFlags);
6081
+ if (globalCheckResult !== false) {
6082
+ if (globalCheckResult !== true && typeof globalCheckResult === "object") globalCheckResult.systemArgs = detectedSystemArgs;
6083
+ return globalCheckResult === true ? {} : globalCheckResult;
6084
+ }
4623
6085
  try {
4624
6086
  const { finalParser: identifiedFinalParser, commandChain: identifiedCommandChain, parserChain: identifiedParserChain } = this.#_identifyCommandChainAndParsers(processArgs, this, [], [this]);
4625
6087
  const saveToEnvResult = identifiedFinalParser.#_handleSaveToEnvFlag(processArgs, identifiedParserChain);
4626
- if (saveToEnvResult !== false) return saveToEnvResult === true ? {} : saveToEnvResult;
4627
- const { finalArgs, handlerToExecute } = await this._parseRecursive(processArgs, this, {}, [], options, void 0);
6088
+ if (saveToEnvResult !== false) {
6089
+ if (saveToEnvResult !== true && typeof saveToEnvResult === "object") saveToEnvResult.systemArgs = detectedSystemArgs;
6090
+ return saveToEnvResult === true ? {} : saveToEnvResult;
6091
+ }
6092
+ const { finalArgs, handlerToExecute, systemArgs } = await this._parseRecursive(processArgs, this, {}, [], options, void 0, detectedSystemArgs);
4628
6093
  if (identifiedCommandChain.length > 0) finalArgs.$commandChain = identifiedCommandChain;
6094
+ if (systemArgs && Object.keys(systemArgs).length > 0) finalArgs.systemArgs = systemArgs;
4629
6095
  if (this.#fuzzyMode) finalArgs._originalInputArgs = originalProcessArgs;
4630
6096
  if (!this.#fuzzyMode) this.#_validateMandatoryFlags(finalArgs, identifiedParserChain, identifiedCommandChain);
4631
6097
  this.#_applyDefaultValues(finalArgs, identifiedFinalParser);
@@ -4652,7 +6118,7 @@ var ArgParserBase = class ArgParserBase {
4652
6118
  parseAsync(processArgs, options) {
4653
6119
  return this.parse(processArgs, options);
4654
6120
  }
4655
- async _parseRecursive(argsToParse, currentParser, accumulatedParentArgs, commandChainSoFar, options, parentParser) {
6121
+ async _parseRecursive(argsToParse, currentParser, accumulatedParentArgs, commandChainSoFar, options, parentParser, systemArgs) {
4656
6122
  let subCommandIndex = -1;
4657
6123
  let subCommandName = null;
4658
6124
  for (let i = 0; i < argsToParse.length; i++) {
@@ -4692,8 +6158,29 @@ var ArgParserBase = class ArgParserBase {
4692
6158
  },
4693
6159
  rootPath: this.#rootPath || void 0,
4694
6160
  logger: this.#logger,
4695
- isMcp: options?.isMcp || false
6161
+ isMcp: options?.isMcp || false,
6162
+ systemArgs,
6163
+ promptAnswers: {},
6164
+ isInteractive: false
4696
6165
  };
6166
+ const promptableFlags = currentParser.getPromptableFlags();
6167
+ if (PromptManager.shouldTriggerInteractive(currentParser.#promptWhen, promptableFlags, currentLevelArgs) && PromptManager.isInteractiveEnvironment()) {
6168
+ const promptResult = await new PromptManager({
6169
+ context: handlerContext,
6170
+ onCancel: currentParser.#onCancel
6171
+ }).executePrompts(promptableFlags);
6172
+ if (promptResult.success) {
6173
+ Object.assign(currentLevelArgs, promptResult.answers);
6174
+ Object.assign(finalParseResultArgs, promptResult.answers);
6175
+ handlerContext.promptAnswers = promptResult.answers;
6176
+ handlerContext.isInteractive = true;
6177
+ handlerContext.args = currentLevelArgs;
6178
+ } else if (promptResult.cancelled) return {
6179
+ finalArgs: finalParseResultArgs,
6180
+ handlerToExecute: void 0,
6181
+ systemArgs
6182
+ };
6183
+ }
4697
6184
  if (currentParser.#handler) handlerToExecute = {
4698
6185
  handler: currentParser.#handler,
4699
6186
  context: handlerContext
@@ -4704,7 +6191,8 @@ var ArgParserBase = class ArgParserBase {
4704
6191
  };
4705
6192
  return {
4706
6193
  finalArgs: finalParseResultArgs,
4707
- handlerToExecute
6194
+ handlerToExecute,
6195
+ systemArgs
4708
6196
  };
4709
6197
  }
4710
6198
  if (firstUnconsumedIndex < argsForCurrentLevel.length) {
@@ -4720,7 +6208,7 @@ var ArgParserBase = class ArgParserBase {
4720
6208
  ...accumulatedParentArgs,
4721
6209
  ...currentLevelArgs
4722
6210
  };
4723
- return await this._parseRecursive(nextArgs, nextParser, combinedArgsForNextLevel, nextCommandChain, options, currentParser);
6211
+ return await this._parseRecursive(nextArgs, nextParser, combinedArgsForNextLevel, nextCommandChain, options, currentParser, systemArgs);
4724
6212
  }
4725
6213
  async #parseFlags(args, options) {
4726
6214
  let flags = this.#flagManager.flags;
@@ -6391,7 +7879,7 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6391
7879
  const cliTools = generateMcpToolsFromArgParser(this, options);
6392
7880
  const unifiedToolNames = Array.from(this._tools.keys());
6393
7881
  const legacyMcpToolNames = Array.from(this._mcpTools.keys());
6394
- const cliToolNames = cliTools.map((t) => t.name);
7882
+ const cliToolNames = cliTools.map((t$1) => t$1.name);
6395
7883
  const allToolNames = [
6396
7884
  ...unifiedToolNames,
6397
7885
  ...legacyMcpToolNames,
@@ -6437,10 +7925,10 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6437
7925
  async testMcpToolRouting(toolName, args = {}) {
6438
7926
  try {
6439
7927
  const tools = this.toMcpTools();
6440
- const tool = tools.find((t) => t.name === toolName);
7928
+ const tool = tools.find((t$1) => t$1.name === toolName);
6441
7929
  if (!tool) return {
6442
7930
  success: false,
6443
- error: `Tool '${toolName}' not found. Available tools: ${tools.map((t) => t.name).join(", ")}`
7931
+ error: `Tool '${toolName}' not found. Available tools: ${tools.map((t$1) => t$1.name).join(", ")}`
6444
7932
  };
6445
7933
  const startTime = Date.now();
6446
7934
  return {
@@ -6580,9 +8068,9 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6580
8068
  ...legacyMcpTools,
6581
8069
  ...cliTools
6582
8070
  ].reduce((acc, tool) => {
6583
- if (!acc.find((t) => t.name === tool.name)) acc.push(tool);
8071
+ if (!acc.find((t$1) => t$1.name === tool.name)) acc.push(tool);
6584
8072
  else {
6585
- const toolSource = unifiedTools.find((t) => t.name === tool.name) ? "unified" : legacyMcpTools.find((t) => t.name === tool.name) ? "legacy MCP" : "CLI-generated";
8073
+ const toolSource = unifiedTools.find((t$1) => t$1.name === tool.name) ? "unified" : legacyMcpTools.find((t$1) => t$1.name === tool.name) ? "legacy MCP" : "CLI-generated";
6586
8074
  console.warn(`[MCP Tool Registration] ${toolSource} tool '${tool.name}' overrides other tool definitions`);
6587
8075
  }
6588
8076
  return acc;
@@ -6648,15 +8136,15 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6648
8136
  const tools = this.toMcpTools(toolOptions);
6649
8137
  logger$7.mcpError(`Generated ${tools.length} MCP tools`);
6650
8138
  const uniqueTools = tools.reduce((acc, tool) => {
6651
- if (!acc.find((t) => t.name === tool.name)) acc.push(tool);
8139
+ if (!acc.find((t$1) => t$1.name === tool.name)) acc.push(tool);
6652
8140
  return acc;
6653
8141
  }, []);
6654
8142
  logger$7.mcpError(`After deduplication: ${uniqueTools.length} unique tools`);
6655
8143
  uniqueTools.forEach((tool) => {
6656
8144
  logger$7.mcpError(`Registering tool: ${tool.name}`);
6657
8145
  let zodSchema;
6658
- const toolFromUnified = Array.from(this._tools.values()).find((t) => t.name === tool.name);
6659
- const toolFromLegacy = Array.from(this._mcpTools.values()).find((t) => t.name === tool.name);
8146
+ const toolFromUnified = Array.from(this._tools.values()).find((t$1) => t$1.name === tool.name);
8147
+ const toolFromLegacy = Array.from(this._mcpTools.values()).find((t$1) => t$1.name === tool.name);
6660
8148
  if (toolFromUnified && toolFromUnified.flags) zodSchema = convertFlagsToZodSchema(toolFromUnified.flags);
6661
8149
  else if (toolFromLegacy && toolFromLegacy.inputSchema) zodSchema = toolFromLegacy.inputSchema;
6662
8150
  else zodSchema = z.object({});
@@ -6979,13 +8467,13 @@ Migration guide: https://github.com/alcyone-labs/arg-parser/blob/main/docs/MCP-M
6979
8467
  const base64urlDecode = (s) => Buffer.from(s.replace(/-/g, "+").replace(/_/g, "/"), "base64");
6980
8468
  const verifyJwt = async (token) => {
6981
8469
  if (!authOpts?.jwt) return false;
6982
- const [h, p, sig] = token.split(".");
6983
- if (!h || !p || !sig) return false;
6984
- const header = JSON.parse(base64urlDecode(h).toString("utf8"));
8470
+ const [h$1, p, sig] = token.split(".");
8471
+ if (!h$1 || !p || !sig) return false;
8472
+ const header = JSON.parse(base64urlDecode(h$1).toString("utf8"));
6985
8473
  const payload = JSON.parse(base64urlDecode(p).toString("utf8"));
6986
8474
  const alg = header.alg;
6987
8475
  if (authOpts.jwt.algorithms && !authOpts.jwt.algorithms.includes(alg)) return false;
6988
- const data = Buffer.from(`${h}.${p}`);
8476
+ const data = Buffer.from(`${h$1}.${p}`);
6989
8477
  const signature = base64urlDecode(sig);
6990
8478
  if (alg === "HS256") {
6991
8479
  const secret = authOpts.jwt.secret;
@@ -7363,9 +8851,9 @@ var ArgParserFuzzyTester = class {
7363
8851
  const flagArgs = this.generateFlagArgs(flag, "valid");
7364
8852
  if (flagArgs.length > 0) combinations.push([...mandatoryArgs, ...flagArgs]);
7365
8853
  }
7366
- if (optionalFlags.length > 1) for (let i = 0; i < optionalFlags.length - 1; i++) for (let j = i + 1; j < optionalFlags.length; j++) {
8854
+ if (optionalFlags.length > 1) for (let i = 0; i < optionalFlags.length - 1; i++) for (let j$1 = i + 1; j$1 < optionalFlags.length; j$1++) {
7367
8855
  const flag1Args = this.generateFlagArgs(optionalFlags[i], "valid");
7368
- const flag2Args = this.generateFlagArgs(optionalFlags[j], "valid");
8856
+ const flag2Args = this.generateFlagArgs(optionalFlags[j$1], "valid");
7369
8857
  if (flag1Args.length > 0 && flag2Args.length > 0) combinations.push([
7370
8858
  ...mandatoryArgs,
7371
8859
  ...flag1Args,
@@ -7490,6 +8978,6 @@ var ArgParserFuzzyTester = class {
7490
8978
  };
7491
8979
  }
7492
8980
  };
7493
- export { ArgParser, ArgParserBase, ArgParserError, ArgParserFuzzyTester, ArgParserMcp, ConfigPlugin, ConfigPluginRegistry, DxtPathResolver, EnvConfigPlugin, FlagInheritance, JsonConfigPlugin, Logger, OutputSchemaPatterns, SimpleChalk_default as SimpleChalk, TomlConfigPlugin, YamlConfigPlugin, absolutePath, autoHelpHandler, convertFlagToJsonSchemaProperty, convertFlagsToJsonSchema, convertFlagsToZodSchema, createCliLogger, createMcpArgParser, createMcpErrorResponse, createMcpLogger, createMcpSuccessResponse, createOutputSchema, createTomlPlugin, createTomlPluginAsync, createYamlPlugin, createYamlPluginAsync, cwdRelative, debug, detectEntryPoint, enableConfigPlugins, enableOptionalConfigPlugins, enableOptionalConfigPluginsAsync, entryRelative, extractSimplifiedResponse, generateMcpToolsFromArgParser, getEntryPointFromImportMeta, getJsonSchemaTypeFromFlag, globalConfigPluginRegistry, isValidMcpToolName, legacyCwdPath, logger, resolveLogPath, sanitizeMcpToolName, zodDxtOptionsSchema, zodFlagSchema };
8981
+ export { ArgParser, ArgParserBase, ArgParserError, ArgParserFuzzyTester, ArgParserMcp, ConfigPlugin, ConfigPluginRegistry, DxtPathResolver, EnvConfigPlugin, FlagInheritance, FlagManager, JsonConfigPlugin, Logger, OutputSchemaPatterns, PromptManager, SimpleChalk_default as SimpleChalk, TomlConfigPlugin, YamlConfigPlugin, absolutePath, autoHelpHandler, convertFlagToJsonSchemaProperty, convertFlagsToJsonSchema, convertFlagsToZodSchema, createCliLogger, createMcpArgParser, createMcpErrorResponse, createMcpLogger, createMcpSuccessResponse, createOutputSchema, createTomlPlugin, createTomlPluginAsync, createYamlPlugin, createYamlPluginAsync, cwdRelative, debug, detectEntryPoint, enableConfigPlugins, enableOptionalConfigPlugins, enableOptionalConfigPluginsAsync, entryRelative, extractSimplifiedResponse, generateMcpToolsFromArgParser, getEntryPointFromImportMeta, getJsonSchemaTypeFromFlag, globalConfigPluginRegistry, isValidMcpToolName, legacyCwdPath, logger, resolveLogPath, sanitizeMcpToolName, zodDxtOptionsSchema, zodFlagSchema };
7494
8982
 
7495
8983
  //# sourceMappingURL=index.mjs.map