@buiducnhat/agent-skills 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1877 -1340
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import fs, { existsSync, mkdtempSync } from "node:fs";
4
- import path from "node:path";
3
+ import fs, { existsSync, lstatSync, mkdtempSync, readdirSync } from "node:fs";
4
+ import path, { dirname, join } from "node:path";
5
+ import N, { stdin, stdout } from "node:process";
6
+ import * as k from "node:readline";
7
+ import ot from "node:readline";
8
+ import { ReadStream } from "node:tty";
5
9
  import { stripVTControlCharacters } from "node:util";
6
- import y, { stdin, stdout } from "node:process";
7
- import * as g from "node:readline";
8
- import O from "node:readline";
9
- import { Writable } from "node:stream";
10
- import { execSync } from "node:child_process";
11
- import os, { tmpdir } from "node:os";
10
+ import { execSync, spawn } from "node:child_process";
11
+ import { tmpdir } from "node:os";
12
12
 
13
13
  //#region \0rolldown/runtime.js
14
14
  var __create = Object.create;
@@ -37,63 +37,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  enumerable: true
38
38
  }) : target, mod));
39
39
 
40
- //#endregion
41
- //#region node_modules/sisteransi/src/index.js
42
- var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
43
- const ESC = "\x1B";
44
- const CSI = `${ESC}[`;
45
- const beep = "\x07";
46
- const cursor = {
47
- to(x, y) {
48
- if (!y) return `${CSI}${x + 1}G`;
49
- return `${CSI}${y + 1};${x + 1}H`;
50
- },
51
- move(x, y) {
52
- let ret = "";
53
- if (x < 0) ret += `${CSI}${-x}D`;
54
- else if (x > 0) ret += `${CSI}${x}C`;
55
- if (y < 0) ret += `${CSI}${-y}A`;
56
- else if (y > 0) ret += `${CSI}${y}B`;
57
- return ret;
58
- },
59
- up: (count = 1) => `${CSI}${count}A`,
60
- down: (count = 1) => `${CSI}${count}B`,
61
- forward: (count = 1) => `${CSI}${count}C`,
62
- backward: (count = 1) => `${CSI}${count}D`,
63
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
64
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
65
- left: `${CSI}G`,
66
- hide: `${CSI}?25l`,
67
- show: `${CSI}?25h`,
68
- save: `${ESC}7`,
69
- restore: `${ESC}8`
70
- };
71
- const scroll = {
72
- up: (count = 1) => `${CSI}S`.repeat(count),
73
- down: (count = 1) => `${CSI}T`.repeat(count)
74
- };
75
- const erase = {
76
- screen: `${CSI}2J`,
77
- up: (count = 1) => `${CSI}1J`.repeat(count),
78
- down: (count = 1) => `${CSI}J`.repeat(count),
79
- line: `${CSI}2K`,
80
- lineEnd: `${CSI}K`,
81
- lineStart: `${CSI}1K`,
82
- lines(count) {
83
- let clear = "";
84
- for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
85
- if (count) clear += cursor.left;
86
- return clear;
87
- }
88
- };
89
- module.exports = {
90
- cursor,
91
- scroll,
92
- erase,
93
- beep
94
- };
95
- }));
96
-
97
40
  //#endregion
98
41
  //#region node_modules/picocolors/picocolors.js
99
42
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -163,274 +106,223 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
163
106
  module.exports.createColors = createColors;
164
107
  }));
165
108
 
109
+ //#endregion
110
+ //#region node_modules/sisteransi/src/index.js
111
+ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112
+ const ESC = "\x1B";
113
+ const CSI = `${ESC}[`;
114
+ const beep = "\x07";
115
+ const cursor = {
116
+ to(x, y) {
117
+ if (!y) return `${CSI}${x + 1}G`;
118
+ return `${CSI}${y + 1};${x + 1}H`;
119
+ },
120
+ move(x, y) {
121
+ let ret = "";
122
+ if (x < 0) ret += `${CSI}${-x}D`;
123
+ else if (x > 0) ret += `${CSI}${x}C`;
124
+ if (y < 0) ret += `${CSI}${-y}A`;
125
+ else if (y > 0) ret += `${CSI}${y}B`;
126
+ return ret;
127
+ },
128
+ up: (count = 1) => `${CSI}${count}A`,
129
+ down: (count = 1) => `${CSI}${count}B`,
130
+ forward: (count = 1) => `${CSI}${count}C`,
131
+ backward: (count = 1) => `${CSI}${count}D`,
132
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
133
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
134
+ left: `${CSI}G`,
135
+ hide: `${CSI}?25l`,
136
+ show: `${CSI}?25h`,
137
+ save: `${ESC}7`,
138
+ restore: `${ESC}8`
139
+ };
140
+ const scroll = {
141
+ up: (count = 1) => `${CSI}S`.repeat(count),
142
+ down: (count = 1) => `${CSI}T`.repeat(count)
143
+ };
144
+ const erase = {
145
+ screen: `${CSI}2J`,
146
+ up: (count = 1) => `${CSI}1J`.repeat(count),
147
+ down: (count = 1) => `${CSI}J`.repeat(count),
148
+ line: `${CSI}2K`,
149
+ lineEnd: `${CSI}K`,
150
+ lineStart: `${CSI}1K`,
151
+ lines(count) {
152
+ let clear = "";
153
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
154
+ if (count) clear += cursor.left;
155
+ return clear;
156
+ }
157
+ };
158
+ module.exports = {
159
+ cursor,
160
+ scroll,
161
+ erase,
162
+ beep
163
+ };
164
+ }));
165
+
166
166
  //#endregion
167
167
  //#region node_modules/@clack/core/dist/index.mjs
168
- var import_src = require_src();
169
168
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
170
- function DD({ onlyFirst: e = !1 } = {}) {
171
- const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
172
- return new RegExp(t, e ? void 0 : "g");
173
- }
174
- const uD = DD();
175
- function P$1(e) {
176
- if (typeof e != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);
177
- return e.replace(uD, "");
178
- }
179
- function L$1(e) {
180
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
169
+ var import_src = require_src();
170
+ function B(t, e, s) {
171
+ if (!s.some((u) => !u.disabled)) return t;
172
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
173
+ return s[n].disabled ? B(n, e < 0 ? -1 : 1, s) : n;
181
174
  }
182
- var W$1 = { exports: {} };
183
- (function(e) {
184
- var u = {};
185
- e.exports = u, u.eastAsianWidth = function(F) {
186
- var s = F.charCodeAt(0), i = F.length == 2 ? F.charCodeAt(1) : 0, D = s;
187
- return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
188
- }, u.characterLength = function(F) {
189
- var s = this.eastAsianWidth(F);
190
- return s == "F" || s == "W" || s == "A" ? 2 : 1;
191
- };
192
- function t(F) {
193
- return F.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
194
- }
195
- u.length = function(F) {
196
- for (var s = t(F), i = 0, D = 0; D < s.length; D++) i = i + this.characterLength(s[D]);
197
- return i;
198
- }, u.slice = function(F, s, i) {
199
- textLen = u.length(F), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
200
- for (var D = "", r = 0, n = t(F), E = 0; E < n.length; E++) {
201
- var a = n[E], o = u.length(a);
202
- if (r >= s - (o == 2 ? 1 : 0)) if (r + o <= i) D += a;
203
- else break;
204
- r += o;
175
+ const at$1 = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt$1 = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 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, L = /\t{1,1000}/y, P = /[\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, M$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, ft$1 = {
176
+ limit: Infinity,
177
+ ellipsis: ""
178
+ }, X$1 = (t, e = {}, s = {}) => {
179
+ const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$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;
180
+ let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
181
+ t: for (;;) {
182
+ if (w > C || o >= p && o > h) {
183
+ const ut = t.slice(C, w) || t.slice(h, o);
184
+ v = 0;
185
+ for (const Y of ut.replaceAll(ct$1, "")) {
186
+ const $ = Y.codePointAt(0) || 0;
187
+ if (lt$1($) ? f = m : ht$1($) ? f = V : E !== A && at$1($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
188
+ F = !0;
189
+ break t;
190
+ }
191
+ v += Y.length, c += f;
192
+ }
193
+ C = w = 0;
205
194
  }
206
- return D;
207
- };
208
- })(W$1);
209
- var tD = W$1.exports;
210
- const eD = L$1(tD);
211
- var FD = function() {
212
- return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
213
- };
214
- const sD = L$1(FD);
215
- function p(e, u = {}) {
216
- if (typeof e != "string" || e.length === 0 || (u = {
217
- ambiguousIsNarrow: !0,
218
- ...u
219
- }, e = P$1(e), e.length === 0)) return 0;
220
- e = e.replace(sD(), " ");
221
- const t = u.ambiguousIsNarrow ? 1 : 2;
222
- let F = 0;
223
- for (const s of e) {
224
- const i = s.codePointAt(0);
225
- if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
226
- switch (eD.eastAsianWidth(s)) {
227
- case "F":
228
- case "W":
229
- F += 2;
195
+ if (o >= p) break;
196
+ if (M$1.lastIndex = o, M$1.test(t)) {
197
+ if (v = M$1.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
198
+ F = !0;
199
+ break;
200
+ }
201
+ c += f, C = h, w = o, o = h = M$1.lastIndex;
202
+ continue;
203
+ }
204
+ if (O.lastIndex = o, O.test(t)) {
205
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
206
+ F = !0;
230
207
  break;
231
- case "A":
232
- F += t;
208
+ }
209
+ c += u, C = h, w = o, o = h = O.lastIndex;
210
+ continue;
211
+ }
212
+ if (y.lastIndex = o, y.test(t)) {
213
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
214
+ F = !0;
233
215
  break;
234
- default: F += 1;
216
+ }
217
+ c += f, C = h, w = o, o = h = y.lastIndex;
218
+ continue;
235
219
  }
236
- }
237
- return F;
238
- }
239
- const w = 10, N = (e = 0) => (u) => `\x1B[${u + e}m`, I = (e = 0) => (u) => `\x1B[${38 + e};5;${u}m`, R = (e = 0) => (u, t, F) => `\x1B[${38 + e};2;${u};${t};${F}m`, C$1 = {
240
- modifier: {
241
- reset: [0, 0],
242
- bold: [1, 22],
243
- dim: [2, 22],
244
- italic: [3, 23],
245
- underline: [4, 24],
246
- overline: [53, 55],
247
- inverse: [7, 27],
248
- hidden: [8, 28],
249
- strikethrough: [9, 29]
250
- },
251
- color: {
252
- black: [30, 39],
253
- red: [31, 39],
254
- green: [32, 39],
255
- yellow: [33, 39],
256
- blue: [34, 39],
257
- magenta: [35, 39],
258
- cyan: [36, 39],
259
- white: [37, 39],
260
- blackBright: [90, 39],
261
- gray: [90, 39],
262
- grey: [90, 39],
263
- redBright: [91, 39],
264
- greenBright: [92, 39],
265
- yellowBright: [93, 39],
266
- blueBright: [94, 39],
267
- magentaBright: [95, 39],
268
- cyanBright: [96, 39],
269
- whiteBright: [97, 39]
270
- },
271
- bgColor: {
272
- bgBlack: [40, 49],
273
- bgRed: [41, 49],
274
- bgGreen: [42, 49],
275
- bgYellow: [43, 49],
276
- bgBlue: [44, 49],
277
- bgMagenta: [45, 49],
278
- bgCyan: [46, 49],
279
- bgWhite: [47, 49],
280
- bgBlackBright: [100, 49],
281
- bgGray: [100, 49],
282
- bgGrey: [100, 49],
283
- bgRedBright: [101, 49],
284
- bgGreenBright: [102, 49],
285
- bgYellowBright: [103, 49],
286
- bgBlueBright: [104, 49],
287
- bgMagentaBright: [105, 49],
288
- bgCyanBright: [106, 49],
289
- bgWhiteBright: [107, 49]
290
- }
291
- };
292
- Object.keys(C$1.modifier);
293
- const iD = Object.keys(C$1.color), rD = Object.keys(C$1.bgColor);
294
- [...iD, ...rD];
295
- function CD() {
296
- const e = /* @__PURE__ */ new Map();
297
- for (const [u, t] of Object.entries(C$1)) {
298
- for (const [F, s] of Object.entries(t)) C$1[F] = {
299
- open: `\x1B[${s[0]}m`,
300
- close: `\x1B[${s[1]}m`
301
- }, t[F] = C$1[F], e.set(s[0], s[1]);
302
- Object.defineProperty(C$1, u, {
303
- value: t,
304
- enumerable: !1
305
- });
306
- }
307
- return Object.defineProperty(C$1, "codes", {
308
- value: e,
309
- enumerable: !1
310
- }), C$1.color.close = "\x1B[39m", C$1.bgColor.close = "\x1B[49m", C$1.color.ansi = N(), C$1.color.ansi256 = I(), C$1.color.ansi16m = R(), C$1.bgColor.ansi = N(w), C$1.bgColor.ansi256 = I(w), C$1.bgColor.ansi16m = R(w), Object.defineProperties(C$1, {
311
- rgbToAnsi256: {
312
- value: (u, t, F) => u === t && t === F ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F / 255 * 5),
313
- enumerable: !1
314
- },
315
- hexToRgb: {
316
- value: (u) => {
317
- const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
318
- if (!t) return [
319
- 0,
320
- 0,
321
- 0
322
- ];
323
- let [F] = t;
324
- F.length === 3 && (F = [...F].map((i) => i + i).join(""));
325
- const s = Number.parseInt(F, 16);
326
- return [
327
- s >> 16 & 255,
328
- s >> 8 & 255,
329
- s & 255
330
- ];
331
- },
332
- enumerable: !1
333
- },
334
- hexToAnsi256: {
335
- value: (u) => C$1.rgbToAnsi256(...C$1.hexToRgb(u)),
336
- enumerable: !1
337
- },
338
- ansi256ToAnsi: {
339
- value: (u) => {
340
- if (u < 8) return 30 + u;
341
- if (u < 16) return 90 + (u - 8);
342
- let t, F, s;
343
- if (u >= 232) t = ((u - 232) * 10 + 8) / 255, F = t, s = t;
344
- else {
345
- u -= 16;
346
- const r = u % 36;
347
- t = Math.floor(u / 36) / 5, F = Math.floor(r / 6) / 5, s = r % 6 / 5;
348
- }
349
- const i = Math.max(t, F, s) * 2;
350
- if (i === 0) return 30;
351
- let D = 30 + (Math.round(s) << 2 | Math.round(F) << 1 | Math.round(t));
352
- return i === 2 && (D += 60), D;
353
- },
354
- enumerable: !1
355
- },
356
- rgbToAnsi: {
357
- value: (u, t, F) => C$1.ansi256ToAnsi(C$1.rgbToAnsi256(u, t, F)),
358
- enumerable: !1
359
- },
360
- hexToAnsi: {
361
- value: (u) => C$1.ansi256ToAnsi(C$1.hexToAnsi256(u)),
362
- enumerable: !1
220
+ if (L.lastIndex = o, L.test(t)) {
221
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
222
+ F = !0;
223
+ break;
224
+ }
225
+ c += f, C = h, w = o, o = h = L.lastIndex;
226
+ continue;
363
227
  }
364
- }), C$1;
365
- }
366
- const ED = CD(), d$1 = new Set(["\x1B", "›"]), oD = 39, y$1 = "\x07", V$1 = "[", nD = "]", G$1 = "m", _$1 = `${nD}8;;`, z = (e) => `${d$1.values().next().value}${V$1}${e}${G$1}`, K$1 = (e) => `${d$1.values().next().value}${_$1}${e}${y$1}`, aD = (e) => e.split(" ").map((u) => p(u)), k$1 = (e, u, t) => {
367
- const F = [...u];
368
- let s = !1, i = !1, D = p(P$1(e[e.length - 1]));
369
- for (const [r, n] of F.entries()) {
370
- const E = p(n);
371
- if (D + E <= t ? e[e.length - 1] += n : (e.push(n), D = 0), d$1.has(n) && (s = !0, i = F.slice(r + 1).join("").startsWith(_$1)), s) {
372
- i ? n === y$1 && (s = !1, i = !1) : n === G$1 && (s = !1);
228
+ if (P.lastIndex = o, P.test(t)) {
229
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
230
+ F = !0;
231
+ break;
232
+ }
233
+ c += g, C = h, w = o, o = h = P.lastIndex;
373
234
  continue;
374
235
  }
375
- D += E, D === t && r < F.length - 1 && (e.push(""), D = 0);
376
- }
377
- !D && e[e.length - 1].length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
378
- }, hD = (e) => {
379
- const u = e.split(" ");
380
- let t = u.length;
381
- for (; t > 0 && !(p(u[t - 1]) > 0);) t--;
382
- return t === u.length ? e : u.slice(0, t).join(" ") + u.slice(t).join("");
383
- }, lD = (e, u, t = {}) => {
384
- if (t.trim !== !1 && e.trim() === "") return "";
385
- let F = "", s, i;
386
- const D = aD(e);
387
- let r = [""];
388
- for (const [E, a] of e.split(" ").entries()) {
389
- t.trim !== !1 && (r[r.length - 1] = r[r.length - 1].trimStart());
390
- let o = p(r[r.length - 1]);
391
- if (E !== 0 && (o >= u && (t.wordWrap === !1 || t.trim === !1) && (r.push(""), o = 0), (o > 0 || t.trim === !1) && (r[r.length - 1] += " ", o++)), t.hard && D[E] > u) {
392
- const c = u - o, f = 1 + Math.floor((D[E] - c - 1) / u);
393
- Math.floor((D[E] - 1) / u) < f && r.push(""), k$1(r, a, u);
236
+ o += 1;
237
+ }
238
+ return {
239
+ width: F ? b : c,
240
+ index: F ? d : p,
241
+ truncated: F,
242
+ ellipsed: F && i >= n
243
+ };
244
+ }, pt$1 = {
245
+ limit: Infinity,
246
+ ellipsis: "",
247
+ ellipsisWidth: 0
248
+ }, S = (t, e = {}) => X$1(t, pt$1, e).width, W$1 = "\x1B", Z$1 = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt$1 = "]", tt = "m", U$1 = `${dt$1}8;;`, et$1 = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
249
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
250
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
251
+ if (t === 1 || t === 2) return 22;
252
+ if (t === 3) return 23;
253
+ if (t === 4) return 24;
254
+ if (t === 7) return 27;
255
+ if (t === 8) return 28;
256
+ if (t === 9) return 29;
257
+ if (t === 0) return 0;
258
+ }, st$1 = (t) => `${W$1}${Q$1}${t}${tt}`, it$1 = (t) => `${W$1}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
259
+ const i = e[Symbol.iterator]();
260
+ let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
261
+ for (; !l.done;) {
262
+ const m = l.value, A = S(m);
263
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W$1 || m === Z$1) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
264
+ }
265
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
266
+ }, vt$1 = (t) => {
267
+ const e = t.split(" ");
268
+ let s = e.length;
269
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
270
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
271
+ }, Et$1 = (t, e, s = {}) => {
272
+ if (s.trim !== !1 && t.trim() === "") return "";
273
+ let i = "", r, n;
274
+ const u = t.split(" "), a = gt$1(u);
275
+ let l = [""];
276
+ for (const [h, o] of u.entries()) {
277
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
278
+ let p = S(l.at(-1) ?? "");
279
+ if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
280
+ const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
281
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
394
282
  continue;
395
283
  }
396
- if (o + D[E] > u && o > 0 && D[E] > 0) {
397
- if (t.wordWrap === !1 && o < u) {
398
- k$1(r, a, u);
284
+ if (p + a[h] > e && p > 0 && a[h] > 0) {
285
+ if (s.wordWrap === !1 && p < e) {
286
+ G(l, o, e);
399
287
  continue;
400
288
  }
401
- r.push("");
289
+ l.push("");
402
290
  }
403
- if (o + D[E] > u && t.wordWrap === !1) {
404
- k$1(r, a, u);
291
+ if (p + a[h] > e && s.wordWrap === !1) {
292
+ G(l, o, e);
405
293
  continue;
406
294
  }
407
- r[r.length - 1] += a;
408
- }
409
- t.trim !== !1 && (r = r.map((E) => hD(E)));
410
- const n = [...r.join(`
411
- `)];
412
- for (const [E, a] of n.entries()) {
413
- if (F += a, d$1.has(a)) {
414
- const { groups: c } = new RegExp(`(?:\\${V$1}(?<code>\\d+)m|\\${_$1}(?<uri>.*)${y$1})`).exec(n.slice(E).join("")) || { groups: {} };
415
- if (c.code !== void 0) {
416
- const f = Number.parseFloat(c.code);
417
- s = f === oD ? void 0 : f;
418
- } else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
295
+ l[l.length - 1] += o;
296
+ }
297
+ s.trim !== !1 && (l = l.map((h) => vt$1(h)));
298
+ const E = l.join(`
299
+ `), g = E[Symbol.iterator]();
300
+ let m = g.next(), A = g.next(), V = 0;
301
+ for (; !m.done;) {
302
+ const h = m.value, o = A.value;
303
+ if (i += h, h === W$1 || h === Z$1) {
304
+ et$1.lastIndex = V + 1;
305
+ const F = et$1.exec(E)?.groups;
306
+ if (F?.code !== void 0) {
307
+ const d = Number.parseFloat(F.code);
308
+ r = d === Ft$1 ? void 0 : d;
309
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
419
310
  }
420
- const o = ED.codes.get(Number(s));
421
- n[E + 1] === `
422
- ` ? (i && (F += K$1("")), s && o && (F += z(o))) : a === `
423
- ` && (s && o && (F += z(s)), i && (F += K$1(i)));
311
+ const p = r ? mt$1(r) : void 0;
312
+ o === `
313
+ ` ? (n && (i += it$1("")), r && p && (i += st$1(p))) : h === `
314
+ ` && (r && p && (i += st$1(r)), n && (i += it$1(n))), V += h.length, m = A, A = g.next();
424
315
  }
425
- return F;
316
+ return i;
426
317
  };
427
- function Y$1(e, u, t) {
428
- return String(e).normalize().replace(/\r\n/g, `
318
+ function K$1(t, e, s) {
319
+ return String(t).normalize().replaceAll(`\r
320
+ `, `
429
321
  `).split(`
430
- `).map((F) => lD(F, u, t)).join(`
322
+ `).map((i) => Et$1(i, e, s)).join(`
431
323
  `);
432
324
  }
433
- const B = {
325
+ const _ = {
434
326
  actions: new Set([
435
327
  "up",
436
328
  "down",
@@ -447,221 +339,351 @@ const B = {
447
339
  ["l", "right"],
448
340
  ["", "cancel"],
449
341
  ["escape", "cancel"]
450
- ])
342
+ ]),
343
+ messages: {
344
+ cancel: "Canceled",
345
+ error: "Something went wrong"
346
+ },
347
+ withGuide: !0
451
348
  };
452
- function $(e, u) {
453
- if (typeof e == "string") return B.aliases.get(e) === u;
454
- for (const t of e) if (t !== void 0 && $(t, u)) return !0;
349
+ function H$1(t, e) {
350
+ if (typeof t == "string") return _.aliases.get(t) === e;
351
+ for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
455
352
  return !1;
456
353
  }
457
- function BD(e, u) {
458
- if (e === u) return;
459
- const t = e.split(`
460
- `), F = u.split(`
461
- `), s = [];
462
- for (let i = 0; i < Math.max(t.length, F.length); i++) t[i] !== F[i] && s.push(i);
463
- return s;
354
+ function _t(t, e) {
355
+ if (t === e) return;
356
+ const s = t.split(`
357
+ `), i = e.split(`
358
+ `), r = Math.max(s.length, i.length), n = [];
359
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
360
+ return {
361
+ lines: n,
362
+ numLinesBefore: s.length,
363
+ numLinesAfter: i.length,
364
+ numLines: r
365
+ };
464
366
  }
465
- const AD = globalThis.process.platform.startsWith("win"), S = Symbol("clack:cancel");
466
- function pD(e) {
467
- return e === S;
367
+ const bt$1 = globalThis.process.platform.startsWith("win"), z = Symbol("clack:cancel");
368
+ function Ct$1(t) {
369
+ return t === z;
468
370
  }
469
- function m(e, u) {
470
- const t = e;
471
- t.isTTY && t.setRawMode(u);
371
+ function T(t, e) {
372
+ const s = t;
373
+ s.isTTY && s.setRawMode(e);
472
374
  }
473
- function fD({ input: e = stdin, output: u = stdout, overwrite: t = !0, hideCursor: F = !0 } = {}) {
474
- const s = g.createInterface({
475
- input: e,
476
- output: u,
375
+ function Bt({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
376
+ const r = k.createInterface({
377
+ input: t,
378
+ output: e,
477
379
  prompt: "",
478
380
  tabSize: 1
479
381
  });
480
- g.emitKeypressEvents(e, s), e.isTTY && e.setRawMode(!0);
481
- const i = (D, { name: r, sequence: n }) => {
482
- if ($([
483
- String(D),
484
- r,
485
- n
382
+ k.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
383
+ const n = (u, { name: a, sequence: l }) => {
384
+ if (H$1([
385
+ String(u),
386
+ a,
387
+ l
486
388
  ], "cancel")) {
487
- F && u.write(import_src.cursor.show), process.exit(0);
389
+ i && e.write(import_src.cursor.show), process.exit(0);
488
390
  return;
489
391
  }
490
- if (!t) return;
491
- const a = r === "return" ? 0 : -1, o = r === "return" ? -1 : 0;
492
- g.moveCursor(u, a, o, () => {
493
- g.clearLine(u, 1, () => {
494
- e.once("keypress", i);
392
+ if (!s) return;
393
+ const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
394
+ k.moveCursor(e, g, m, () => {
395
+ k.clearLine(e, 1, () => {
396
+ t.once("keypress", n);
495
397
  });
496
398
  });
497
399
  };
498
- return F && u.write(import_src.cursor.hide), e.once("keypress", i), () => {
499
- e.off("keypress", i), F && u.write(import_src.cursor.show), e.isTTY && !AD && e.setRawMode(!1), s.terminal = !1, s.close();
400
+ return i && e.write(import_src.cursor.hide), t.once("keypress", n), () => {
401
+ t.off("keypress", n), i && e.write(import_src.cursor.show), t instanceof ReadStream && t.isTTY && !bt$1 && t.setRawMode(!1), r.terminal = !1, r.close();
500
402
  };
501
403
  }
502
- var gD = Object.defineProperty, vD = (e, u, t) => u in e ? gD(e, u, {
503
- enumerable: !0,
504
- configurable: !0,
505
- writable: !0,
506
- value: t
507
- }) : e[u] = t, h = (e, u, t) => (vD(e, typeof u != "symbol" ? u + "" : u, t), t);
404
+ const rt$1 = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt$1 = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
405
+ function xt(t, e, s, i = s) {
406
+ return K$1(e, rt$1(t ?? stdout) - s.length, {
407
+ hard: !0,
408
+ trim: !1
409
+ }).split(`
410
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
411
+ `);
412
+ }
508
413
  var x$1 = class {
509
- constructor(u, t = !0) {
510
- h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", !1), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
511
- const { input: F = stdin, output: s = stdout, render: i, signal: D, ...r } = u;
512
- this.opts = r, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = D, this.input = F, this.output = s;
414
+ input;
415
+ output;
416
+ _abortSignal;
417
+ rl;
418
+ opts;
419
+ _render;
420
+ _track = !1;
421
+ _prevFrame = "";
422
+ _subscribers = /* @__PURE__ */ new Map();
423
+ _cursor = 0;
424
+ state = "initial";
425
+ error = "";
426
+ value;
427
+ userInput = "";
428
+ constructor(e, s = !0) {
429
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
430
+ 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;
513
431
  }
514
432
  unsubscribe() {
515
433
  this._subscribers.clear();
516
434
  }
517
- setSubscriber(u, t) {
518
- const F = this._subscribers.get(u) ?? [];
519
- F.push(t), this._subscribers.set(u, F);
435
+ setSubscriber(e, s) {
436
+ const i = this._subscribers.get(e) ?? [];
437
+ i.push(s), this._subscribers.set(e, i);
520
438
  }
521
- on(u, t) {
522
- this.setSubscriber(u, { cb: t });
439
+ on(e, s) {
440
+ this.setSubscriber(e, { cb: s });
523
441
  }
524
- once(u, t) {
525
- this.setSubscriber(u, {
526
- cb: t,
442
+ once(e, s) {
443
+ this.setSubscriber(e, {
444
+ cb: s,
527
445
  once: !0
528
446
  });
529
447
  }
530
- emit(u, ...t) {
531
- const F = this._subscribers.get(u) ?? [], s = [];
532
- for (const i of F) i.cb(...t), i.once && s.push(() => F.splice(F.indexOf(i), 1));
533
- for (const i of s) i();
448
+ emit(e, ...s) {
449
+ const i = this._subscribers.get(e) ?? [], r = [];
450
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
451
+ for (const n of r) n();
534
452
  }
535
453
  prompt() {
536
- return new Promise((u, t) => {
454
+ return new Promise((e) => {
537
455
  if (this._abortSignal) {
538
- if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u(S);
456
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z);
539
457
  this._abortSignal.addEventListener("abort", () => {
540
458
  this.state = "cancel", this.close();
541
459
  }, { once: !0 });
542
460
  }
543
- const F = new Writable();
544
- F._write = (s, i, D) => {
545
- this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
546
- }, this.input.pipe(F), this.rl = O.createInterface({
461
+ this.rl = ot.createInterface({
547
462
  input: this.input,
548
- output: F,
549
463
  tabSize: 2,
550
464
  prompt: "",
551
465
  escapeCodeTimeout: 50,
552
466
  terminal: !0
553
- }), O.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), m(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
554
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u(this.value);
467
+ }), 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", () => {
468
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(this.value);
555
469
  }), this.once("cancel", () => {
556
- this.output.write(import_src.cursor.show), this.output.off("resize", this.render), m(this.input, !1), u(S);
470
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(z);
557
471
  });
558
472
  });
559
473
  }
560
- onKeypress(u, t) {
561
- if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), t?.name === "return") {
562
- if (!this.value && this.opts.placeholder && (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder)), this.opts.validate) {
563
- const F = this.opts.validate(this.value);
564
- F && (this.error = F instanceof Error ? F.message : F, this.state = "error", this.rl?.write(this.value));
474
+ _isActionKey(e, s) {
475
+ return e === " ";
476
+ }
477
+ _setValue(e) {
478
+ this.value = e, this.emit("value", this.value);
479
+ }
480
+ _setUserInput(e, s) {
481
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
482
+ }
483
+ _clearUserInput() {
484
+ this.rl?.write(null, {
485
+ ctrl: !0,
486
+ name: "u"
487
+ }), this._setUserInput("");
488
+ }
489
+ onKeypress(e, s) {
490
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
491
+ ctrl: !0,
492
+ name: "h"
493
+ }), 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") {
494
+ if (this.opts.validate) {
495
+ const i = this.opts.validate(this.value);
496
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
565
497
  }
566
498
  this.state !== "error" && (this.state = "submit");
567
499
  }
568
- $([
569
- u,
570
- t?.name,
571
- t?.sequence
500
+ H$1([
501
+ e,
502
+ s?.name,
503
+ s?.sequence
572
504
  ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
573
505
  }
574
506
  close() {
575
507
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
576
- `), m(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
508
+ `), T(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
577
509
  }
578
510
  restoreCursor() {
579
- const u = Y$1(this._prevFrame, process.stdout.columns, { hard: !0 }).split(`
511
+ const e = K$1(this._prevFrame, process.stdout.columns, {
512
+ hard: !0,
513
+ trim: !1
514
+ }).split(`
580
515
  `).length - 1;
581
- this.output.write(import_src.cursor.move(-999, u * -1));
516
+ this.output.write(import_src.cursor.move(-999, e * -1));
582
517
  }
583
518
  render() {
584
- const u = Y$1(this._render(this) ?? "", process.stdout.columns, { hard: !0 });
585
- if (u !== this._prevFrame) {
519
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
520
+ hard: !0,
521
+ trim: !1
522
+ });
523
+ if (e !== this._prevFrame) {
586
524
  if (this.state === "initial") this.output.write(import_src.cursor.hide);
587
525
  else {
588
- const t = BD(this._prevFrame, u);
589
- if (this.restoreCursor(), t && t?.length === 1) {
590
- const F = t[0];
591
- this.output.write(import_src.cursor.move(0, F)), this.output.write(import_src.erase.lines(1));
592
- const s = u.split(`
526
+ const s = _t(this._prevFrame, e), i = nt$1(this.output);
527
+ if (this.restoreCursor(), s) {
528
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
529
+ let u = s.lines.find((a) => a >= r);
530
+ if (u === void 0) {
531
+ this._prevFrame = e;
532
+ return;
533
+ }
534
+ if (s.lines.length === 1) {
535
+ this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
536
+ const a = e.split(`
593
537
  `);
594
- this.output.write(s[F]), this._prevFrame = u, this.output.write(import_src.cursor.move(0, s.length - F - 1));
595
- return;
596
- }
597
- if (t && t?.length > 1) {
598
- const F = t[0];
599
- this.output.write(import_src.cursor.move(0, F)), this.output.write(import_src.erase.down());
600
- const s = u.split(`
601
- `).slice(F);
602
- this.output.write(s.join(`
603
- `)), this._prevFrame = u;
604
- return;
538
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
539
+ return;
540
+ } else if (s.lines.length > 1) {
541
+ if (r < n) u = r;
542
+ else {
543
+ const l = u - n;
544
+ l > 0 && this.output.write(import_src.cursor.move(0, l));
545
+ }
546
+ this.output.write(import_src.erase.down());
547
+ const a = e.split(`
548
+ `).slice(u);
549
+ this.output.write(a.join(`
550
+ `)), this._prevFrame = e;
551
+ return;
552
+ }
605
553
  }
606
554
  this.output.write(import_src.erase.down());
607
555
  }
608
- this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
556
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
557
+ }
558
+ }
559
+ };
560
+ function wt$1(t, e) {
561
+ if (t === void 0 || e.length === 0) return 0;
562
+ const s = e.findIndex((i) => i.value === t);
563
+ return s !== -1 ? s : 0;
564
+ }
565
+ function Dt$1(t, e) {
566
+ return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
567
+ }
568
+ function St$1(t, e) {
569
+ if (e) return t ? e : e[0];
570
+ }
571
+ var Vt$1 = class extends x$1 {
572
+ filteredOptions;
573
+ multiple;
574
+ isNavigating = !1;
575
+ selectedValues = [];
576
+ focusedValue;
577
+ #t = 0;
578
+ #s = "";
579
+ #i;
580
+ #e;
581
+ get cursor() {
582
+ return this.#t;
583
+ }
584
+ get userInputWithCursor() {
585
+ if (!this.userInput) return import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
586
+ if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
587
+ const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
588
+ return `${e}${import_picocolors.default.inverse(s)}${i.join("")}`;
589
+ }
590
+ get options() {
591
+ return typeof this.#e == "function" ? this.#e() : this.#e;
592
+ }
593
+ constructor(e) {
594
+ super(e), this.#e = e.options;
595
+ const s = this.options;
596
+ this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt$1;
597
+ let i;
598
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
599
+ const n = s.findIndex((u) => u.value === r);
600
+ n !== -1 && (this.toggleSelected(r), this.#t = n);
601
+ }
602
+ this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
603
+ }
604
+ _isActionKey(e, s) {
605
+ return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
606
+ }
607
+ #r(e, s) {
608
+ const i = s.name === "up", r = s.name === "down", n = s.name === "return";
609
+ i || r ? (this.#t = B(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
610
+ }
611
+ deselectAll() {
612
+ this.selectedValues = [];
613
+ }
614
+ toggleSelected(e) {
615
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
616
+ }
617
+ #n(e) {
618
+ if (e !== this.#s) {
619
+ this.#s = e;
620
+ const s = this.options;
621
+ e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
622
+ this.#t = B(wt$1(this.focusedValue, this.filteredOptions), 0, this.filteredOptions);
623
+ const r = this.filteredOptions[this.#t];
624
+ r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
609
625
  }
610
626
  }
611
627
  };
612
- var dD = class extends x$1 {
628
+ var kt$1 = class extends x$1 {
613
629
  get cursor() {
614
630
  return this.value ? 0 : 1;
615
631
  }
616
632
  get _value() {
617
633
  return this.cursor === 0;
618
634
  }
619
- constructor(u) {
620
- super(u, !1), this.value = !!u.initialValue, this.on("value", () => {
635
+ constructor(e) {
636
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
621
637
  this.value = this._value;
622
- }), this.on("confirm", (t) => {
623
- this.output.write(import_src.cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
638
+ }), this.on("confirm", (s) => {
639
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
624
640
  }), this.on("cursor", () => {
625
641
  this.value = !this.value;
626
642
  });
627
643
  }
628
644
  };
629
- var mD = Object.defineProperty, bD = (e, u, t) => u in e ? mD(e, u, {
630
- enumerable: !0,
631
- configurable: !0,
632
- writable: !0,
633
- value: t
634
- }) : e[u] = t, Z = (e, u, t) => (bD(e, typeof u != "symbol" ? u + "" : u, t), t), q$1 = (e, u, t) => {
635
- if (!u.has(e)) throw TypeError("Cannot " + t);
636
- }, T$1 = (e, u, t) => (q$1(e, u, "read from private field"), t ? t.call(e) : u.get(e)), wD = (e, u, t) => {
637
- if (u.has(e)) throw TypeError("Cannot add the same private member more than once");
638
- u instanceof WeakSet ? u.add(e) : u.set(e, t);
639
- }, yD = (e, u, t, F) => (q$1(e, u, "write to private field"), F ? F.call(e, t) : u.set(e, t), t), A$1;
640
- let _D = class extends x$1 {
641
- constructor(u) {
642
- super(u, !1), Z(this, "options"), Z(this, "cursor", 0), wD(this, A$1, void 0);
643
- const { options: t } = u;
644
- yD(this, A$1, u.selectableGroups !== !1), this.options = Object.entries(t).flatMap(([F, s]) => [{
645
- value: F,
645
+ var yt$1 = class extends x$1 {
646
+ options;
647
+ cursor = 0;
648
+ #t;
649
+ getGroupItems(e) {
650
+ return this.options.filter((s) => s.group === e);
651
+ }
652
+ isGroupSelected(e) {
653
+ const s = this.getGroupItems(e), i = this.value;
654
+ return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
655
+ }
656
+ toggleValue() {
657
+ const e = this.options[this.cursor];
658
+ if (this.value === void 0 && (this.value = []), e.group === !0) {
659
+ const s = e.value, i = this.getGroupItems(s);
660
+ this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
661
+ } else this.value = this.value.includes(e.value) ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
662
+ }
663
+ constructor(e) {
664
+ super(e, !1);
665
+ const { options: s } = e;
666
+ this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
667
+ value: i,
646
668
  group: !0,
647
- label: F
648
- }, ...s.map((i) => ({
649
- ...i,
650
- group: F
651
- }))]), this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F }) => F === u.cursorAt), T$1(this, A$1) ? 0 : 1), this.on("cursor", (F) => {
652
- switch (F) {
669
+ label: i
670
+ }, ...r.map((n) => ({
671
+ ...n,
672
+ group: i
673
+ }))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
674
+ switch (i) {
653
675
  case "left":
654
676
  case "up": {
655
677
  this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
656
- const s = this.options[this.cursor]?.group === !0;
657
- !T$1(this, A$1) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
678
+ const r = this.options[this.cursor]?.group === !0;
679
+ !this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
658
680
  break;
659
681
  }
660
682
  case "down":
661
683
  case "right": {
662
684
  this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
663
- const s = this.options[this.cursor]?.group === !0;
664
- !T$1(this, A$1) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
685
+ const r = this.options[this.cursor]?.group === !0;
686
+ !this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
665
687
  break;
666
688
  }
667
689
  case "space":
@@ -670,40 +692,43 @@ let _D = class extends x$1 {
670
692
  }
671
693
  });
672
694
  }
673
- getGroupItems(u) {
674
- return this.options.filter((t) => t.group === u);
695
+ };
696
+ var Lt$1 = class extends x$1 {
697
+ options;
698
+ cursor = 0;
699
+ get _value() {
700
+ return this.options[this.cursor].value;
701
+ }
702
+ get _enabledOptions() {
703
+ return this.options.filter((e) => e.disabled !== !0);
675
704
  }
676
- isGroupSelected(u) {
677
- return this.getGroupItems(u).every((t) => this.value.includes(t.value));
705
+ toggleAll() {
706
+ const e = this._enabledOptions;
707
+ this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
678
708
  }
679
- toggleValue() {
680
- const u = this.options[this.cursor];
681
- if (u.group === !0) {
682
- const t = u.value, F = this.getGroupItems(t);
683
- this.isGroupSelected(t) ? this.value = this.value.filter((s) => F.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F.map((s) => s.value)], this.value = Array.from(new Set(this.value));
684
- } else this.value = this.value.includes(u.value) ? this.value.filter((F) => F !== u.value) : [...this.value, u.value];
709
+ toggleInvert() {
710
+ const e = this.value;
711
+ if (!e) return;
712
+ this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
685
713
  }
686
- };
687
- A$1 = /* @__PURE__ */ new WeakMap();
688
- var kD = Object.defineProperty, $D = (e, u, t) => u in e ? kD(e, u, {
689
- enumerable: !0,
690
- configurable: !0,
691
- writable: !0,
692
- value: t
693
- }) : e[u] = t, H = (e, u, t) => ($D(e, typeof u != "symbol" ? u + "" : u, t), t);
694
- let SD = class extends x$1 {
695
- constructor(u) {
696
- super(u, !1), H(this, "options"), H(this, "cursor", 0), this.options = u.options, this.value = [...u.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u.cursorAt), 0), this.on("key", (t) => {
697
- t === "a" && this.toggleAll();
698
- }), this.on("cursor", (t) => {
699
- switch (t) {
714
+ toggleValue() {
715
+ this.value === void 0 && (this.value = []);
716
+ this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
717
+ }
718
+ constructor(e) {
719
+ super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
720
+ const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
721
+ this.cursor = this.options[s].disabled ? B(s, 1, this.options) : s, this.on("key", (i) => {
722
+ i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
723
+ }), this.on("cursor", (i) => {
724
+ switch (i) {
700
725
  case "left":
701
726
  case "up":
702
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
727
+ this.cursor = B(this.cursor, -1, this.options);
703
728
  break;
704
729
  case "down":
705
730
  case "right":
706
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
731
+ this.cursor = B(this.cursor, 1, this.options);
707
732
  break;
708
733
  case "space":
709
734
  this.toggleValue();
@@ -711,737 +736,1426 @@ let SD = class extends x$1 {
711
736
  }
712
737
  });
713
738
  }
714
- get _value() {
715
- return this.options[this.cursor].value;
716
- }
717
- toggleAll() {
718
- this.value = this.value.length === this.options.length ? [] : this.options.map((t) => t.value);
719
- }
720
- toggleValue() {
721
- this.value = this.value.includes(this._value) ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
722
- }
723
739
  };
724
- var TD = Object.defineProperty, jD = (e, u, t) => u in e ? TD(e, u, {
725
- enumerable: !0,
726
- configurable: !0,
727
- writable: !0,
728
- value: t
729
- }) : e[u] = t, U$1 = (e, u, t) => (jD(e, typeof u != "symbol" ? u + "" : u, t), t);
730
- var MD = class extends x$1 {
731
- constructor({ mask: u, ...t }) {
732
- super(t), U$1(this, "valueWithCursor", ""), U$1(this, "_mask", "•"), this._mask = u ?? "•", this.on("finalize", () => {
733
- this.valueWithCursor = this.masked;
734
- }), this.on("value", () => {
735
- if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
736
- else {
737
- const F = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
738
- this.valueWithCursor = `${F}${import_picocolors.default.inverse(s[0])}${s.slice(1)}`;
739
- }
740
- });
741
- }
740
+ let Mt$1 = class extends x$1 {
741
+ _mask = "•";
742
742
  get cursor() {
743
743
  return this._cursor;
744
744
  }
745
745
  get masked() {
746
- return this.value.replaceAll(/./g, this._mask);
746
+ return this.userInput.replaceAll(/./g, this._mask);
747
+ }
748
+ get userInputWithCursor() {
749
+ if (this.state === "submit" || this.state === "cancel") return this.masked;
750
+ const e = this.userInput;
751
+ if (this.cursor >= e.length) return `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
752
+ const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
753
+ return `${i}${import_picocolors.default.inverse(r[0])}${r.slice(1)}`;
754
+ }
755
+ clear() {
756
+ this._clearUserInput();
757
+ }
758
+ constructor({ mask: e, ...s }) {
759
+ super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
760
+ this._setValue(i);
761
+ });
747
762
  }
748
763
  };
749
- var OD = Object.defineProperty, PD = (e, u, t) => u in e ? OD(e, u, {
750
- enumerable: !0,
751
- configurable: !0,
752
- writable: !0,
753
- value: t
754
- }) : e[u] = t, J$1 = (e, u, t) => (PD(e, typeof u != "symbol" ? u + "" : u, t), t);
755
- var LD = class extends x$1 {
756
- constructor(u) {
757
- super(u, !1), J$1(this, "options"), J$1(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: t }) => t === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
758
- switch (t) {
764
+ var Wt$1 = class extends x$1 {
765
+ options;
766
+ cursor = 0;
767
+ get _selectedValue() {
768
+ return this.options[this.cursor];
769
+ }
770
+ changeValue() {
771
+ this.value = this._selectedValue.value;
772
+ }
773
+ constructor(e) {
774
+ super(e, !1), this.options = e.options;
775
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
776
+ this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
777
+ switch (r) {
759
778
  case "left":
760
779
  case "up":
761
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
780
+ this.cursor = B(this.cursor, -1, this.options);
762
781
  break;
763
782
  case "down":
764
783
  case "right":
765
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
784
+ this.cursor = B(this.cursor, 1, this.options);
766
785
  break;
767
786
  }
768
787
  this.changeValue();
769
788
  });
770
789
  }
771
- get _value() {
772
- return this.options[this.cursor];
773
- }
774
- changeValue() {
775
- this.value = this._value.value;
776
- }
777
790
  };
778
- var WD = Object.defineProperty, ND = (e, u, t) => u in e ? WD(e, u, {
779
- enumerable: !0,
780
- configurable: !0,
781
- writable: !0,
782
- value: t
783
- }) : e[u] = t, Q = (e, u, t) => (ND(e, typeof u != "symbol" ? u + "" : u, t), t);
784
- var ID = class extends x$1 {
785
- constructor(u) {
786
- super(u, !1), Q(this, "options"), Q(this, "cursor", 0), this.options = u.options;
787
- const t = this.options.map(({ value: [F] }) => F?.toLowerCase());
788
- this.cursor = Math.max(t.indexOf(u.initialValue), 0), this.on("key", (F) => {
789
- if (!t.includes(F)) return;
790
- const s = this.options.find(({ value: [i] }) => i?.toLowerCase() === F);
791
- s && (this.value = s.value, this.state = "submit", this.emit("submit"));
791
+ var Tt$1 = class extends x$1 {
792
+ options;
793
+ cursor = 0;
794
+ constructor(e) {
795
+ super(e, !1), this.options = e.options;
796
+ const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
797
+ this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
798
+ if (!r) return;
799
+ const u = s && n.shift ? r.toUpperCase() : r;
800
+ if (!i.includes(u)) return;
801
+ const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
802
+ a && (this.value = a.value, this.state = "submit", this.emit("submit"));
792
803
  });
793
804
  }
794
805
  };
795
- var RD = class extends x$1 {
796
- get valueWithCursor() {
797
- if (this.state === "submit") return this.value;
798
- if (this.cursor >= this.value.length) return `${this.value}\u2588`;
799
- const u = this.value.slice(0, this.cursor), [t, ...F] = this.value.slice(this.cursor);
800
- return `${u}${import_picocolors.default.inverse(t)}${F.join("")}`;
806
+ var $t$1 = class extends x$1 {
807
+ get userInputWithCursor() {
808
+ if (this.state === "submit") return this.userInput;
809
+ const e = this.userInput;
810
+ if (this.cursor >= e.length) return `${this.userInput}\u2588`;
811
+ const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
812
+ return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
801
813
  }
802
814
  get cursor() {
803
815
  return this._cursor;
804
816
  }
805
- constructor(u) {
806
- super(u), this.on("finalize", () => {
807
- this.value || (this.value = u.defaultValue);
817
+ constructor(e) {
818
+ super({
819
+ ...e,
820
+ initialUserInput: e.initialUserInput ?? e.initialValue
821
+ }), this.on("userInput", (s) => {
822
+ this._setValue(s);
823
+ }), this.on("finalize", () => {
824
+ this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
808
825
  });
809
826
  }
810
827
  };
811
828
 
812
829
  //#endregion
813
830
  //#region node_modules/@clack/prompts/dist/index.mjs
814
- function ce() {
815
- return y.platform !== "win32" ? y.env.TERM !== "linux" : !!y.env.CI || !!y.env.WT_SESSION || !!y.env.TERMINUS_SUBLIME || y.env.ConEmuTask === "{cmd::Cmder}" || y.env.TERM_PROGRAM === "Terminus-Sublime" || y.env.TERM_PROGRAM === "vscode" || y.env.TERM === "xterm-256color" || y.env.TERM === "alacritty" || y.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
831
+ function me() {
832
+ return N.platform !== "win32" ? N.env.TERM !== "linux" : !!N.env.CI || !!N.env.WT_SESSION || !!N.env.TERMINUS_SUBLIME || N.env.ConEmuTask === "{cmd::Cmder}" || N.env.TERM_PROGRAM === "Terminus-Sublime" || N.env.TERM_PROGRAM === "vscode" || N.env.TERM === "xterm-256color" || N.env.TERM === "alacritty" || N.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
816
833
  }
817
- const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), $e = u("▪", "•"), _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
834
+ const et = me(), ct = () => process.env.CI === "true", Mt = (t) => t.isTTY === !0, C = (t, r) => et ? t : r, Rt = C("◆", "*"), dt = C("■", "x"), $t = C("▲", "x"), V = C("◇", "o"), ht = C("┌", "T"), d = C("│", "|"), x = C("└", "—"), Ot = C("┐", "T"), Pt = C("┘", "—"), Q = C("●", ">"), H = C("○", " "), st = C("◻", "[•]"), U = C("◼", "[+]"), q = C("◻", "[ ]"), Nt = C("▪", "•"), rt = C("─", "-"), mt = C("╮", "+"), Wt = C("├", "+"), pt = C("╯", "+"), gt = C("╰", "+"), Lt = C("╭", "+"), ft = C("●", "•"), Ft = C("◆", "*"), yt = C("▲", "!"), Et = C("■", "x"), W = (t) => {
818
835
  switch (t) {
819
836
  case "initial":
820
- case "active": return import_picocolors.default.cyan(le);
821
- case "cancel": return import_picocolors.default.red(L);
822
- case "error": return import_picocolors.default.yellow(W);
823
- case "submit": return import_picocolors.default.green(C);
824
- }
825
- }, G = (t) => {
826
- const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
827
- let l = 0;
828
- n >= l + a - 3 ? l = Math.max(Math.min(n - a + 3, r.length - a), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
829
- const $ = a < r.length && l > 0, g = a < r.length && l + a < r.length;
830
- return r.slice(l, l + a).map((p, v, f) => {
831
- const j = v === 0 && $, E = v === f.length - 1 && g;
832
- return j || E ? import_picocolors.default.dim("...") : i(p, v + l === n);
833
- });
834
- }, he = (t) => new RD({
835
- validate: t.validate,
836
- placeholder: t.placeholder,
837
- defaultValue: t.defaultValue,
838
- initialValue: t.initialValue,
839
- render() {
840
- const n = `${import_picocolors.default.gray(o)}
841
- ${b(this.state)} ${t.message}
842
- `, r = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), i = this.value ? this.valueWithCursor : r;
843
- switch (this.state) {
844
- case "error": return `${n.trim()}
845
- ${import_picocolors.default.yellow(o)} ${i}
846
- ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
847
- `;
848
- case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(this.value || t.placeholder)}`;
849
- case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(this.value ?? ""))}${this.value?.trim() ? `
850
- ${import_picocolors.default.gray(o)}` : ""}`;
851
- default: return `${n}${import_picocolors.default.cyan(o)} ${i}
852
- ${import_picocolors.default.cyan(d)}
853
- `;
854
- }
855
- }
856
- }).prompt(), ge = (t) => new MD({
857
- validate: t.validate,
858
- mask: t.mask ?? $e,
859
- render() {
860
- const n = `${import_picocolors.default.gray(o)}
861
- ${b(this.state)} ${t.message}
862
- `, r = this.valueWithCursor, i = this.masked;
863
- switch (this.state) {
864
- case "error": return `${n.trim()}
865
- ${import_picocolors.default.yellow(o)} ${i}
866
- ${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(this.error)}
867
- `;
868
- case "submit": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(i)}`;
869
- case "cancel": return `${n}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i ?? ""))}${i ? `
870
- ${import_picocolors.default.gray(o)}` : ""}`;
871
- default: return `${n}${import_picocolors.default.cyan(o)} ${r}
872
- ${import_picocolors.default.cyan(d)}
873
- `;
874
- }
837
+ case "active": return import_picocolors.default.cyan(Rt);
838
+ case "cancel": return import_picocolors.default.red(dt);
839
+ case "error": return import_picocolors.default.yellow($t);
840
+ case "submit": return import_picocolors.default.green(V);
875
841
  }
876
- }).prompt(), ye = (t) => {
877
- const n = t.active ?? "Yes", r = t.inactive ?? "No";
878
- return new dD({
879
- active: n,
880
- inactive: r,
881
- initialValue: t.initialValue ?? !0,
882
- render() {
883
- const i = `${import_picocolors.default.gray(o)}
884
- ${b(this.state)} ${t.message}
885
- `, s = this.value ? n : r;
886
- switch (this.state) {
887
- case "submit": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(s)}`;
888
- case "cancel": return `${i}${import_picocolors.default.gray(o)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}
889
- ${import_picocolors.default.gray(o)}`;
890
- default: return `${i}${import_picocolors.default.cyan(o)} ${this.value ? `${import_picocolors.default.green(k)} ${n}` : `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(r)}` : `${import_picocolors.default.green(k)} ${r}`}
891
- ${import_picocolors.default.cyan(d)}
892
- `;
842
+ }, vt = (t) => {
843
+ switch (t) {
844
+ case "initial":
845
+ case "active": return import_picocolors.default.cyan(d);
846
+ case "cancel": return import_picocolors.default.red(d);
847
+ case "error": return import_picocolors.default.yellow(d);
848
+ case "submit": return import_picocolors.default.green(d);
849
+ }
850
+ }, pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, At = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, it = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, nt = /\t{1,1000}/y, wt = /[\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, at = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Fe = /\p{M}+/gu, ye = {
851
+ limit: Infinity,
852
+ ellipsis: ""
853
+ }, jt = (t, r = {}, s = {}) => {
854
+ const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
855
+ let $ = 0, m = 0, h = t.length, y = 0, f = !1, v = h, S = Math.max(0, i - o), I = 0, B = 0, A = 0, w = 0;
856
+ t: for (;;) {
857
+ if (B > I || m >= h && m > $) {
858
+ const _ = t.slice(I, B) || t.slice($, m);
859
+ y = 0;
860
+ for (const D of _.replaceAll(Fe, "")) {
861
+ const T = D.codePointAt(0) || 0;
862
+ if (ge(T) ? w = F : fe(T) ? w = E : c !== p && pe(T) ? w = c : w = p, A + w > S && (v = Math.min(v, Math.max(I, $) + y)), A + w > i) {
863
+ f = !0;
864
+ break t;
865
+ }
866
+ y += D.length, A += w;
893
867
  }
868
+ I = B = 0;
894
869
  }
895
- }).prompt();
896
- }, ve = (t) => {
897
- const n = (r, i) => {
898
- const s = r.label ?? String(r.value);
899
- switch (i) {
900
- case "selected": return `${import_picocolors.default.dim(s)}`;
901
- case "active": return `${import_picocolors.default.green(k)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}`;
902
- case "cancelled": return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}`;
903
- default: return `${import_picocolors.default.dim(P)} ${import_picocolors.default.dim(s)}`;
904
- }
905
- };
906
- return new LD({
907
- options: t.options,
908
- initialValue: t.initialValue,
909
- render() {
910
- const r = `${import_picocolors.default.gray(o)}
911
- ${b(this.state)} ${t.message}
912
- `;
913
- switch (this.state) {
914
- case "submit": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
915
- case "cancel": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
916
- ${import_picocolors.default.gray(o)}`;
917
- default: return `${r}${import_picocolors.default.cyan(o)} ${G({
918
- cursor: this.cursor,
919
- options: this.options,
920
- maxItems: t.maxItems,
921
- style: (i, s) => n(i, s ? "active" : "inactive")
922
- }).join(`
923
- ${import_picocolors.default.cyan(o)} `)}
924
- ${import_picocolors.default.cyan(d)}
925
- `;
870
+ if (m >= h) break;
871
+ if (at.lastIndex = m, at.test(t)) {
872
+ if (y = at.lastIndex - m, w = y * p, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / p))), A + w > i) {
873
+ f = !0;
874
+ break;
926
875
  }
876
+ A += w, I = $, B = m, m = $ = at.lastIndex;
877
+ continue;
927
878
  }
928
- }).prompt();
929
- }, we = (t) => {
930
- const n = (r, i = "inactive") => {
931
- const s = r.label ?? String(r.value);
932
- return i === "selected" ? `${import_picocolors.default.dim(s)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${r.value} `))} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${r.value} `)))} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}`;
879
+ if (At.lastIndex = m, At.test(t)) {
880
+ if (A + u > S && (v = Math.min(v, m)), A + u > i) {
881
+ f = !0;
882
+ break;
883
+ }
884
+ A += u, I = $, B = m, m = $ = At.lastIndex;
885
+ continue;
886
+ }
887
+ if (it.lastIndex = m, it.test(t)) {
888
+ if (y = it.lastIndex - m, w = y * l, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / l))), A + w > i) {
889
+ f = !0;
890
+ break;
891
+ }
892
+ A += w, I = $, B = m, m = $ = it.lastIndex;
893
+ continue;
894
+ }
895
+ if (nt.lastIndex = m, nt.test(t)) {
896
+ if (y = nt.lastIndex - m, w = y * n, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / n))), A + w > i) {
897
+ f = !0;
898
+ break;
899
+ }
900
+ A += w, I = $, B = m, m = $ = nt.lastIndex;
901
+ continue;
902
+ }
903
+ if (wt.lastIndex = m, wt.test(t)) {
904
+ if (A + g > S && (v = Math.min(v, m)), A + g > i) {
905
+ f = !0;
906
+ break;
907
+ }
908
+ A += g, I = $, B = m, m = $ = wt.lastIndex;
909
+ continue;
910
+ }
911
+ m += 1;
912
+ }
913
+ return {
914
+ width: f ? S : A,
915
+ index: f ? v : h,
916
+ truncated: f,
917
+ ellipsed: f && i >= o
918
+ };
919
+ }, Ee = {
920
+ limit: Infinity,
921
+ ellipsis: "",
922
+ ellipsisWidth: 0
923
+ }, M = (t, r = {}) => jt(t, Ee, r).width, ot$1 = "\x1B", Gt = "›", ve = 39, Ct = "\x07", kt = "[", Ae = "]", Vt = "m", St = `${Ae}8;;`, Ht = new RegExp(`(?:\\${kt}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct})`, "y"), we = (t) => {
924
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
925
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
926
+ if (t === 1 || t === 2) return 22;
927
+ if (t === 3) return 23;
928
+ if (t === 4) return 24;
929
+ if (t === 7) return 27;
930
+ if (t === 8) return 28;
931
+ if (t === 9) return 29;
932
+ if (t === 0) return 0;
933
+ }, Ut = (t) => `${ot$1}${kt}${t}${Vt}`, Kt = (t) => `${ot$1}${St}${t}${Ct}`, Ce = (t) => t.map((r) => M(r)), It = (t, r, s) => {
934
+ const i = r[Symbol.iterator]();
935
+ let a = !1, o = !1, u = t.at(-1), l = u === void 0 ? 0 : M(u), n = i.next(), c = i.next(), g = 0;
936
+ for (; !n.done;) {
937
+ const F = n.value, p = M(F);
938
+ l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot$1 || F === Gt) && (a = !0, o = r.startsWith(St, g + 1)), a ? o ? F === Ct && (a = !1, o = !1) : F === Vt && (a = !1) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
939
+ }
940
+ u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
941
+ }, Se = (t) => {
942
+ const r = t.split(" ");
943
+ let s = r.length;
944
+ for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
945
+ return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
946
+ }, Ie = (t, r, s = {}) => {
947
+ if (s.trim !== !1 && t.trim() === "") return "";
948
+ let i = "", a, o;
949
+ const u = t.split(" "), l = Ce(u);
950
+ let n = [""];
951
+ for (const [$, m] of u.entries()) {
952
+ s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
953
+ let h = M(n.at(-1) ?? "");
954
+ if ($ !== 0 && (h >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), h = 0), (h > 0 || s.trim === !1) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
955
+ const y = r - h, f = 1 + Math.floor((l[$] - y - 1) / r);
956
+ Math.floor((l[$] - 1) / r) < f && n.push(""), It(n, m, r);
957
+ continue;
958
+ }
959
+ if (h + l[$] > r && h > 0 && l[$] > 0) {
960
+ if (s.wordWrap === !1 && h < r) {
961
+ It(n, m, r);
962
+ continue;
963
+ }
964
+ n.push("");
965
+ }
966
+ if (h + l[$] > r && s.wordWrap === !1) {
967
+ It(n, m, r);
968
+ continue;
969
+ }
970
+ n[n.length - 1] += m;
971
+ }
972
+ s.trim !== !1 && (n = n.map(($) => Se($)));
973
+ const c = n.join(`
974
+ `), g = c[Symbol.iterator]();
975
+ let F = g.next(), p = g.next(), E = 0;
976
+ for (; !F.done;) {
977
+ const $ = F.value, m = p.value;
978
+ if (i += $, $ === ot$1 || $ === Gt) {
979
+ Ht.lastIndex = E + 1;
980
+ const f = Ht.exec(c)?.groups;
981
+ if (f?.code !== void 0) {
982
+ const v = Number.parseFloat(f.code);
983
+ a = v === ve ? void 0 : v;
984
+ } else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
985
+ }
986
+ const h = a ? we(a) : void 0;
987
+ m === `
988
+ ` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
989
+ ` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
990
+ }
991
+ return i;
992
+ };
993
+ function J(t, r, s) {
994
+ return String(t).normalize().replaceAll(`\r
995
+ `, `
996
+ `).split(`
997
+ `).map((i) => Ie(i, r, s)).join(`
998
+ `);
999
+ }
1000
+ const be = (t, r, s, i, a) => {
1001
+ let o = r, u = 0;
1002
+ for (let l = s; l < i; l++) {
1003
+ const n = t[l];
1004
+ if (o = o - n.length, u++, o <= a) break;
1005
+ }
1006
+ return {
1007
+ lineCount: o,
1008
+ removals: u
933
1009
  };
934
- return new ID({
1010
+ }, X = (t) => {
1011
+ const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt$1(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt$1(a), g = import_picocolors.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
1012
+ let $ = 0;
1013
+ r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
1014
+ let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
1015
+ const y = Math.min($ + E, s.length), f = [];
1016
+ let v = 0;
1017
+ m && v++, h && v++;
1018
+ const S = $ + (m ? 1 : 0), I = y - (h ? 1 : 0);
1019
+ for (let A = S; A < I; A++) {
1020
+ const w = J(i(s[A], A === r), n, {
1021
+ hard: !0,
1022
+ trim: !1
1023
+ }).split(`
1024
+ `);
1025
+ f.push(w), v += w.length;
1026
+ }
1027
+ if (v > p) {
1028
+ let A = 0, w = 0, _ = v;
1029
+ const D = r - S, T = (Y, L) => be(f, _, Y, L, p);
1030
+ m ? ({lineCount: _, removals: A} = T(0, D), _ > p && ({lineCount: _, removals: w} = T(D + 1, f.length))) : ({lineCount: _, removals: w} = T(D + 1, f.length), _ > p && ({lineCount: _, removals: A} = T(0, D))), A > 0 && (m = !0, f.splice(0, A)), w > 0 && (h = !0, f.splice(f.length - w, w));
1031
+ }
1032
+ const B = [];
1033
+ m && B.push(g);
1034
+ for (const A of f) for (const w of A) B.push(w);
1035
+ return h && B.push(g), B;
1036
+ };
1037
+ function qt(t) {
1038
+ return t.label ?? String(t.value ?? "");
1039
+ }
1040
+ function Jt(t, r) {
1041
+ if (!t) return !0;
1042
+ const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), a = String(r.value).toLowerCase(), o = t.toLowerCase();
1043
+ return s.includes(o) || i.includes(o) || a.includes(o);
1044
+ }
1045
+ function Be(t, r) {
1046
+ const s = [];
1047
+ for (const i of r) t.includes(i.value) && s.push(i);
1048
+ return s;
1049
+ }
1050
+ const Xt = (t) => new Vt$1({
1051
+ options: t.options,
1052
+ initialValue: t.initialValue ? [t.initialValue] : void 0,
1053
+ initialUserInput: t.initialUserInput,
1054
+ filter: t.filter ?? ((r, s) => Jt(r, s)),
1055
+ signal: t.signal,
1056
+ input: t.input,
1057
+ output: t.output,
1058
+ validate: t.validate,
1059
+ render() {
1060
+ const r = t.withGuide ?? _.withGuide, s = r ? [`${import_picocolors.default.gray(d)}`, `${W(this.state)} ${t.message}`] : [`${W(this.state)} ${t.message}`], i = this.userInput, a = this.options, o = t.placeholder, u = i === "" && o !== void 0, l = (n, c) => {
1061
+ const g = qt(n), F = n.hint && n.value === this.focusedValue ? import_picocolors.default.dim(` (${n.hint})`) : "";
1062
+ switch (c) {
1063
+ case "active": return `${import_picocolors.default.green(Q)} ${g}${F}`;
1064
+ case "inactive": return `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(g)}`;
1065
+ case "disabled": return `${import_picocolors.default.gray(H)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(g))}`;
1066
+ }
1067
+ };
1068
+ switch (this.state) {
1069
+ case "submit": {
1070
+ const n = Be(this.selectedValues, a), c = n.length > 0 ? ` ${import_picocolors.default.dim(n.map(qt).join(", "))}` : "", g = r ? import_picocolors.default.gray(d) : "";
1071
+ return `${s.join(`
1072
+ `)}
1073
+ ${g}${c}`;
1074
+ }
1075
+ case "cancel": {
1076
+ const n = i ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i))}` : "", c = r ? import_picocolors.default.gray(d) : "";
1077
+ return `${s.join(`
1078
+ `)}
1079
+ ${c}${n}`;
1080
+ }
1081
+ default: {
1082
+ const n = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, c = r ? `${n(d)} ` : "", g = r ? n(x) : "";
1083
+ let F = "";
1084
+ if (this.isNavigating || u) {
1085
+ const f = u ? o : i;
1086
+ F = f !== "" ? ` ${import_picocolors.default.dim(f)}` : "";
1087
+ } else F = ` ${this.userInputWithCursor}`;
1088
+ const p = this.filteredOptions.length !== a.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", E = this.filteredOptions.length === 0 && i ? [`${c}${import_picocolors.default.yellow("No matches found")}`] : [], $ = this.state === "error" ? [`${c}${import_picocolors.default.yellow(this.error)}`] : [];
1089
+ r && s.push(`${c.trimEnd()}`), s.push(`${c}${import_picocolors.default.dim("Search:")}${F}${p}`, ...E, ...$);
1090
+ const h = [`${c}${[
1091
+ `${import_picocolors.default.dim("↑/↓")} to select`,
1092
+ `${import_picocolors.default.dim("Enter:")} confirm`,
1093
+ `${import_picocolors.default.dim("Type:")} to search`
1094
+ ].join(" • ")}`, g], y = this.filteredOptions.length === 0 ? [] : X({
1095
+ cursor: this.cursor,
1096
+ options: this.filteredOptions,
1097
+ columnPadding: r ? 3 : 0,
1098
+ rowPadding: s.length + h.length,
1099
+ style: (f, v) => l(f, f.disabled ? "disabled" : v ? "active" : "inactive"),
1100
+ maxItems: t.maxItems,
1101
+ output: t.output
1102
+ });
1103
+ return [
1104
+ ...s,
1105
+ ...y.map((f) => `${c}${f}`),
1106
+ ...h
1107
+ ].join(`
1108
+ `);
1109
+ }
1110
+ }
1111
+ }
1112
+ }).prompt(), xe = (t) => {
1113
+ const r = (i, a, o, u) => {
1114
+ const l = o.includes(i.value), n = i.label ?? String(i.value ?? ""), c = i.hint && u !== void 0 && i.value === u ? import_picocolors.default.dim(` (${i.hint})`) : "", g = l ? import_picocolors.default.green(U) : import_picocolors.default.dim(q);
1115
+ return i.disabled ? `${import_picocolors.default.gray(q)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(n))}` : a ? `${g} ${n}${c}` : `${g} ${import_picocolors.default.dim(n)}`;
1116
+ }, s = new Vt$1({
935
1117
  options: t.options,
936
- initialValue: t.initialValue,
1118
+ multiple: !0,
1119
+ filter: t.filter ?? ((i, a) => Jt(i, a)),
1120
+ validate: () => {
1121
+ if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
1122
+ },
1123
+ initialValue: t.initialValues,
1124
+ signal: t.signal,
1125
+ input: t.input,
1126
+ output: t.output,
937
1127
  render() {
938
- const r = `${import_picocolors.default.gray(o)}
939
- ${b(this.state)} ${t.message}
940
- `;
1128
+ const i = `${import_picocolors.default.gray(d)}
1129
+ ${W(this.state)} ${t.message}
1130
+ `, a = this.userInput, o = t.placeholder, u = a === "" && o !== void 0, l = this.isNavigating || u ? import_picocolors.default.dim(u ? o : a) : this.userInputWithCursor, n = this.options, c = this.filteredOptions.length !== n.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
1131
+ switch (this.state) {
1132
+ case "submit": return `${i}${import_picocolors.default.gray(d)} ${import_picocolors.default.dim(`${this.selectedValues.length} items selected`)}`;
1133
+ case "cancel": return `${i}${import_picocolors.default.gray(d)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
1134
+ default: {
1135
+ const g = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, F = [
1136
+ `${import_picocolors.default.dim("↑/↓")} to navigate`,
1137
+ `${import_picocolors.default.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
1138
+ `${import_picocolors.default.dim("Enter:")} confirm`,
1139
+ `${import_picocolors.default.dim("Type:")} to search`
1140
+ ], p = this.filteredOptions.length === 0 && a ? [`${g(d)} ${import_picocolors.default.yellow("No matches found")}`] : [], E = this.state === "error" ? [`${g(d)} ${import_picocolors.default.yellow(this.error)}`] : [], $ = [
1141
+ ...`${i}${g(d)}`.split(`
1142
+ `),
1143
+ `${g(d)} ${import_picocolors.default.dim("Search:")} ${l}${c}`,
1144
+ ...p,
1145
+ ...E
1146
+ ], m = [`${g(d)} ${F.join(" • ")}`, `${g(x)}`], h = X({
1147
+ cursor: this.cursor,
1148
+ options: this.filteredOptions,
1149
+ style: (y, f) => r(y, f, this.selectedValues, this.focusedValue),
1150
+ maxItems: t.maxItems,
1151
+ output: t.output,
1152
+ rowPadding: $.length + m.length
1153
+ });
1154
+ return [
1155
+ ...$,
1156
+ ...h.map((y) => `${g(d)} ${y}`),
1157
+ ...m
1158
+ ].join(`
1159
+ `);
1160
+ }
1161
+ }
1162
+ }
1163
+ });
1164
+ return s.prompt();
1165
+ }, _e = [
1166
+ Lt,
1167
+ mt,
1168
+ gt,
1169
+ pt
1170
+ ], De = [
1171
+ ht,
1172
+ Ot,
1173
+ x,
1174
+ Pt
1175
+ ];
1176
+ function Yt(t, r, s, i) {
1177
+ let a = s, o = s;
1178
+ return i === "center" ? a = Math.floor((r - t) / 2) : i === "right" && (a = r - t - s), o = r - a - t, [a, o];
1179
+ }
1180
+ const Te = (t) => t, Me = (t = "", r = "", s) => {
1181
+ const i = s?.output ?? process.stdout, a = rt$1(i), o = 2, u = s?.titlePadding ?? 1, l = s?.contentPadding ?? 2, n = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), c = s?.withGuide ?? _.withGuide ? `${d} ` : "", g = s?.formatBorder ?? Te, F = (s?.rounded ? _e : De).map(g), p = g(rt), E = g(d), $ = M(c), m = M(r), h = a - $;
1182
+ let y = Math.floor(a * n) - $;
1183
+ if (s?.width === "auto") {
1184
+ const _ = t.split(`
1185
+ `);
1186
+ let D = m + u * 2;
1187
+ for (const Y of _) {
1188
+ const L = M(Y) + l * 2;
1189
+ L > D && (D = L);
1190
+ }
1191
+ const T = D + o;
1192
+ T < y && (y = T);
1193
+ }
1194
+ y % 2 !== 0 && (y < h ? y++ : y--);
1195
+ const f = y - o, v = f - u * 2, S = m > v ? `${r.slice(0, v - 3)}...` : r, [I, B] = Yt(M(S), f, u, s?.titleAlign), A = J(t, f - l * 2, {
1196
+ hard: !0,
1197
+ trim: !1
1198
+ });
1199
+ i.write(`${c}${F[0]}${p.repeat(I)}${S}${p.repeat(B)}${F[1]}
1200
+ `);
1201
+ const w = A.split(`
1202
+ `);
1203
+ for (const _ of w) {
1204
+ const [D, T] = Yt(M(_), f, l, s?.contentAlign);
1205
+ i.write(`${c}${E}${" ".repeat(D)}${_}${" ".repeat(T)}${E}
1206
+ `);
1207
+ }
1208
+ i.write(`${c}${F[2]}${p.repeat(f)}${F[3]}
1209
+ `);
1210
+ }, Re = (t) => {
1211
+ const r = t.active ?? "Yes", s = t.inactive ?? "No";
1212
+ return new kt$1({
1213
+ active: r,
1214
+ inactive: s,
1215
+ signal: t.signal,
1216
+ input: t.input,
1217
+ output: t.output,
1218
+ initialValue: t.initialValue ?? !0,
1219
+ render() {
1220
+ const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors.default.gray(d)}
1221
+ ` : ""}${W(this.state)} ${t.message}
1222
+ `, o = this.value ? r : s;
941
1223
  switch (this.state) {
942
- case "submit": return `${r}${import_picocolors.default.gray(o)} ${n(this.options.find((i) => i.value === this.value) ?? t.options[0], "selected")}`;
943
- case "cancel": return `${r}${import_picocolors.default.gray(o)} ${n(this.options[0], "cancelled")}
944
- ${import_picocolors.default.gray(o)}`;
945
- default: return `${r}${import_picocolors.default.cyan(o)} ${this.options.map((i, s) => n(i, s === this.cursor ? "active" : "inactive")).join(`
946
- ${import_picocolors.default.cyan(o)} `)}
947
- ${import_picocolors.default.cyan(d)}
1224
+ case "submit": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.dim(o)}`;
1225
+ case "cancel": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}${i ? `
1226
+ ${import_picocolors.default.gray(d)}` : ""}`;
1227
+ default: {
1228
+ const u = i ? `${import_picocolors.default.cyan(d)} ` : "", l = i ? import_picocolors.default.cyan(x) : "";
1229
+ return `${a}${u}${this.value ? `${import_picocolors.default.green(Q)} ${r}` : `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(r)}`}${t.vertical ? i ? `
1230
+ ${import_picocolors.default.cyan(d)} ` : `
1231
+ ` : ` ${import_picocolors.default.dim("/")} `}${this.value ? `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(s)}` : `${import_picocolors.default.green(Q)} ${s}`}
1232
+ ${l}
948
1233
  `;
1234
+ }
949
1235
  }
950
1236
  }
951
1237
  }).prompt();
952
- }, fe = (t) => {
953
- const n = (r, i) => {
954
- const s = r.label ?? String(r.value);
955
- return i === "active" ? `${import_picocolors.default.cyan(A)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(T)} ${import_picocolors.default.dim(s)} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : i === "active-selected" ? `${import_picocolors.default.green(T)} ${s} ${r.hint ? import_picocolors.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(s)}` : `${import_picocolors.default.dim(F)} ${import_picocolors.default.dim(s)}`;
956
- };
957
- return new SD({
1238
+ }, Oe = async (t, r) => {
1239
+ const s = {}, i = Object.keys(t);
1240
+ for (const a of i) {
1241
+ const o = t[a], u = await o({ results: s })?.catch((l) => {
1242
+ throw l;
1243
+ });
1244
+ if (typeof r?.onCancel == "function" && Ct$1(u)) {
1245
+ s[a] = "canceled", r.onCancel({ results: s });
1246
+ continue;
1247
+ }
1248
+ s[a] = u;
1249
+ }
1250
+ return s;
1251
+ }, Pe = (t) => {
1252
+ const { selectableGroups: r = !0, groupSpacing: s = 0 } = t, i = (o, u, l = []) => {
1253
+ const n = o.label ?? String(o.value), c = typeof o.group == "string", g = c && (l[l.indexOf(o) + 1] ?? { group: !0 }), F = c && g && g.group === !0, p = c ? r ? `${F ? x : d} ` : " " : "";
1254
+ let E = "";
1255
+ if (s > 0 && !c) {
1256
+ const m = `
1257
+ ${import_picocolors.default.cyan(d)}`;
1258
+ E = `${m.repeat(s - 1)}${m} `;
1259
+ }
1260
+ if (u === "active") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(st)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1261
+ if (u === "group-active") return `${E}${p}${import_picocolors.default.cyan(st)} ${import_picocolors.default.dim(n)}`;
1262
+ if (u === "group-active-selected") return `${E}${p}${import_picocolors.default.green(U)} ${import_picocolors.default.dim(n)}`;
1263
+ if (u === "selected") {
1264
+ const m = c || r ? import_picocolors.default.green(U) : "";
1265
+ return `${E}${import_picocolors.default.dim(p)}${m} ${import_picocolors.default.dim(n)}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1266
+ }
1267
+ if (u === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}`;
1268
+ if (u === "active-selected") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.green(U)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1269
+ if (u === "submitted") return `${import_picocolors.default.dim(n)}`;
1270
+ const $ = c || r ? import_picocolors.default.dim(q) : "";
1271
+ return `${E}${import_picocolors.default.dim(p)}${$} ${import_picocolors.default.dim(n)}`;
1272
+ }, a = t.required ?? !0;
1273
+ return new yt$1({
958
1274
  options: t.options,
1275
+ signal: t.signal,
1276
+ input: t.input,
1277
+ output: t.output,
959
1278
  initialValues: t.initialValues,
960
- required: t.required ?? !0,
1279
+ required: a,
961
1280
  cursorAt: t.cursorAt,
962
- validate(r) {
963
- if (this.required && r.length === 0) return `Please select at least one option.
1281
+ selectableGroups: r,
1282
+ validate(o) {
1283
+ if (a && (o === void 0 || o.length === 0)) return `Please select at least one option.
964
1284
  ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
965
1285
  },
966
1286
  render() {
967
- const r = `${import_picocolors.default.gray(o)}
968
- ${b(this.state)} ${t.message}
969
- `, i = (s, c) => {
970
- const a = this.value.includes(s.value);
971
- return c && a ? n(s, "active-selected") : a ? n(s, "selected") : n(s, c ? "active" : "inactive");
972
- };
1287
+ const o = `${import_picocolors.default.gray(d)}
1288
+ ${W(this.state)} ${t.message}
1289
+ `, u = this.value ?? [];
973
1290
  switch (this.state) {
974
- case "submit": return `${r}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
1291
+ case "submit": {
1292
+ const l = this.options.filter(({ value: c }) => u.includes(c)).map((c) => i(c, "submitted")), n = l.length === 0 ? "" : ` ${l.join(import_picocolors.default.dim(", "))}`;
1293
+ return `${o}${import_picocolors.default.gray(d)}${n}`;
1294
+ }
975
1295
  case "cancel": {
976
- const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors.default.dim(", "));
977
- return `${r}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
978
- ${import_picocolors.default.gray(o)}` : ""}`;
1296
+ const l = this.options.filter(({ value: n }) => u.includes(n)).map((n) => i(n, "cancelled")).join(import_picocolors.default.dim(", "));
1297
+ return `${o}${import_picocolors.default.gray(d)} ${l.trim() ? `${l}
1298
+ ${import_picocolors.default.gray(d)}` : ""}`;
979
1299
  }
980
1300
  case "error": {
981
- const s = this.error.split(`
982
- `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
1301
+ const l = this.error.split(`
1302
+ `).map((n, c) => c === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(n)}` : ` ${n}`).join(`
983
1303
  `);
984
- return `${r + import_picocolors.default.yellow(o)} ${G({
985
- options: this.options,
986
- cursor: this.cursor,
987
- maxItems: t.maxItems,
988
- style: i
1304
+ return `${o}${import_picocolors.default.yellow(d)} ${this.options.map((n, c, g) => {
1305
+ const F = u.includes(n.value) || n.group === !0 && this.isGroupSelected(`${n.value}`), p = c === this.cursor;
1306
+ return !p && typeof n.group == "string" && this.options[this.cursor].value === n.group ? i(n, F ? "group-active-selected" : "group-active", g) : p && F ? i(n, "active-selected", g) : F ? i(n, "selected", g) : i(n, p ? "active" : "inactive", g);
989
1307
  }).join(`
990
- ${import_picocolors.default.yellow(o)} `)}
991
- ${s}
1308
+ ${import_picocolors.default.yellow(d)} `)}
1309
+ ${l}
992
1310
  `;
993
1311
  }
994
- default: return `${r}${import_picocolors.default.cyan(o)} ${G({
995
- options: this.options,
996
- cursor: this.cursor,
997
- maxItems: t.maxItems,
998
- style: i
999
- }).join(`
1000
- ${import_picocolors.default.cyan(o)} `)}
1001
- ${import_picocolors.default.cyan(d)}
1312
+ default: {
1313
+ const l = this.options.map((c, g, F) => {
1314
+ const p = u.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), E = g === this.cursor, $ = !E && typeof c.group == "string" && this.options[this.cursor].value === c.group;
1315
+ let m = "";
1316
+ return $ ? m = i(c, p ? "group-active-selected" : "group-active", F) : E && p ? m = i(c, "active-selected", F) : p ? m = i(c, "selected", F) : m = i(c, E ? "active" : "inactive", F), `${g !== 0 && !m.startsWith(`
1317
+ `) ? " " : ""}${m}`;
1318
+ }).join(`
1319
+ ${import_picocolors.default.cyan(d)}`), n = l.startsWith(`
1320
+ `) ? "" : " ";
1321
+ return `${o}${import_picocolors.default.cyan(d)}${n}${l}
1322
+ ${import_picocolors.default.cyan(x)}
1002
1323
  `;
1324
+ }
1003
1325
  }
1004
1326
  }
1005
1327
  }).prompt();
1006
- }, be = (t) => {
1007
- const { selectableGroups: n = !0 } = t, r = (i, s, c = []) => {
1008
- const a = i.label ?? String(i.value), l = typeof i.group == "string", $ = l && (c[c.indexOf(i) + 1] ?? { group: !0 }), g = l && $.group === !0, p = l ? n ? `${g ? d : o} ` : " " : "";
1009
- if (s === "active") return `${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(A)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1010
- if (s === "group-active") return `${p}${import_picocolors.default.cyan(A)} ${import_picocolors.default.dim(a)}`;
1011
- if (s === "group-active-selected") return `${p}${import_picocolors.default.green(T)} ${import_picocolors.default.dim(a)}`;
1012
- if (s === "selected") {
1013
- const f = l || n ? import_picocolors.default.green(T) : "";
1014
- return `${import_picocolors.default.dim(p)}${f} ${import_picocolors.default.dim(a)} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1328
+ }, R = {
1329
+ message: (t = [], { symbol: r = import_picocolors.default.gray(d), secondarySymbol: s = import_picocolors.default.gray(d), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
1330
+ const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", g = l ? `${s} ` : "";
1331
+ for (let p = 0; p < a; p++) u.push(n);
1332
+ const F = Array.isArray(t) ? t : t.split(`
1333
+ `);
1334
+ if (F.length > 0) {
1335
+ const [p, ...E] = F;
1336
+ p.length > 0 ? u.push(`${c}${p}`) : u.push(l ? r : "");
1337
+ for (const $ of E) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
1015
1338
  }
1016
- if (s === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
1017
- if (s === "active-selected") return `${import_picocolors.default.dim(p)}${import_picocolors.default.green(T)} ${a} ${i.hint ? import_picocolors.default.dim(`(${i.hint})`) : ""}`;
1018
- if (s === "submitted") return `${import_picocolors.default.dim(a)}`;
1019
- const v = l || n ? import_picocolors.default.dim(F) : "";
1020
- return `${import_picocolors.default.dim(p)}${v} ${import_picocolors.default.dim(a)}`;
1021
- };
1022
- return new _D({
1339
+ i.write(`${u.join(`
1340
+ `)}
1341
+ `);
1342
+ },
1343
+ info: (t, r) => {
1344
+ R.message(t, {
1345
+ ...r,
1346
+ symbol: import_picocolors.default.blue(ft)
1347
+ });
1348
+ },
1349
+ success: (t, r) => {
1350
+ R.message(t, {
1351
+ ...r,
1352
+ symbol: import_picocolors.default.green(Ft)
1353
+ });
1354
+ },
1355
+ step: (t, r) => {
1356
+ R.message(t, {
1357
+ ...r,
1358
+ symbol: import_picocolors.default.green(V)
1359
+ });
1360
+ },
1361
+ warn: (t, r) => {
1362
+ R.message(t, {
1363
+ ...r,
1364
+ symbol: import_picocolors.default.yellow(yt)
1365
+ });
1366
+ },
1367
+ warning: (t, r) => {
1368
+ R.warn(t, r);
1369
+ },
1370
+ error: (t, r) => {
1371
+ R.message(t, {
1372
+ ...r,
1373
+ symbol: import_picocolors.default.red(Et)
1374
+ });
1375
+ }
1376
+ }, Ne = (t = "", r) => {
1377
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x)} ${import_picocolors.default.red(t)}
1378
+
1379
+ `);
1380
+ }, We = (t = "", r) => {
1381
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray(ht)} ${t}
1382
+ `);
1383
+ }, Le = (t = "", r) => {
1384
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray(d)}
1385
+ ${import_picocolors.default.gray(x)} ${t}
1386
+
1387
+ `);
1388
+ }, Z = (t, r) => t.split(`
1389
+ `).map((s) => r(s)).join(`
1390
+ `), je = (t) => {
1391
+ const r = (i, a) => {
1392
+ const o = i.label ?? String(i.value);
1393
+ return a === "disabled" ? `${import_picocolors.default.gray(q)} ${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.gray(u)))}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${import_picocolors.default.cyan(st)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "selected" ? `${import_picocolors.default.green(U)} ${Z(o, import_picocolors.default.dim)}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "cancelled" ? `${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.dim(u)))}` : a === "active-selected" ? `${import_picocolors.default.green(U)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "submitted" ? `${Z(o, import_picocolors.default.dim)}` : `${import_picocolors.default.dim(q)} ${Z(o, import_picocolors.default.dim)}`;
1394
+ }, s = t.required ?? !0;
1395
+ return new Lt$1({
1023
1396
  options: t.options,
1397
+ signal: t.signal,
1398
+ input: t.input,
1399
+ output: t.output,
1024
1400
  initialValues: t.initialValues,
1025
- required: t.required ?? !0,
1401
+ required: s,
1026
1402
  cursorAt: t.cursorAt,
1027
- selectableGroups: n,
1028
1403
  validate(i) {
1029
- if (this.required && i.length === 0) return `Please select at least one option.
1404
+ if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
1030
1405
  ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
1031
1406
  },
1032
1407
  render() {
1033
- const i = `${import_picocolors.default.gray(o)}
1034
- ${b(this.state)} ${t.message}
1035
- `;
1408
+ const i = xt(t.output, t.message, `${vt(this.state)} `, `${W(this.state)} `), a = `${import_picocolors.default.gray(d)}
1409
+ ${i}
1410
+ `, o = this.value ?? [], u = (l, n) => {
1411
+ if (l.disabled) return r(l, "disabled");
1412
+ const c = o.includes(l.value);
1413
+ return n && c ? r(l, "active-selected") : c ? r(l, "selected") : r(l, n ? "active" : "inactive");
1414
+ };
1036
1415
  switch (this.state) {
1037
- case "submit": return `${i}${import_picocolors.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r(s, "submitted")).join(import_picocolors.default.dim(", "))}`;
1416
+ case "submit": {
1417
+ const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
1418
+ return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d)} `)}`;
1419
+ }
1038
1420
  case "cancel": {
1039
- const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
1040
- return `${i}${import_picocolors.default.gray(o)} ${s.trim() ? `${s}
1041
- ${import_picocolors.default.gray(o)}` : ""}`;
1421
+ const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
1422
+ if (l.trim() === "") return `${a}${import_picocolors.default.gray(d)}`;
1423
+ return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d)} `)}
1424
+ ${import_picocolors.default.gray(d)}`;
1042
1425
  }
1043
1426
  case "error": {
1044
- const s = this.error.split(`
1045
- `).map((c, a) => a === 0 ? `${import_picocolors.default.yellow(d)} ${import_picocolors.default.yellow(c)}` : ` ${c}`).join(`
1046
- `);
1047
- return `${i}${import_picocolors.default.yellow(o)} ${this.options.map((c, a, l) => {
1048
- const $ = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g = a === this.cursor;
1049
- return !g && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r(c, $ ? "group-active-selected" : "group-active", l) : g && $ ? r(c, "active-selected", l) : $ ? r(c, "selected", l) : r(c, g ? "active" : "inactive", l);
1427
+ const l = `${import_picocolors.default.yellow(d)} `, n = this.error.split(`
1428
+ `).map((F, p) => p === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(F)}` : ` ${F}`).join(`
1429
+ `), c = a.split(`
1430
+ `).length, g = n.split(`
1431
+ `).length + 1;
1432
+ return `${a}${l}${X({
1433
+ output: t.output,
1434
+ options: this.options,
1435
+ cursor: this.cursor,
1436
+ maxItems: t.maxItems,
1437
+ columnPadding: l.length,
1438
+ rowPadding: c + g,
1439
+ style: u
1050
1440
  }).join(`
1051
- ${import_picocolors.default.yellow(o)} `)}
1052
- ${s}
1441
+ ${l}`)}
1442
+ ${n}
1053
1443
  `;
1054
1444
  }
1055
- default: return `${i}${import_picocolors.default.cyan(o)} ${this.options.map((s, c, a) => {
1056
- const l = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $ = c === this.cursor;
1057
- return !$ && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r(s, l ? "group-active-selected" : "group-active", a) : $ && l ? r(s, "active-selected", a) : l ? r(s, "selected", a) : r(s, $ ? "active" : "inactive", a);
1058
- }).join(`
1059
- ${import_picocolors.default.cyan(o)} `)}
1060
- ${import_picocolors.default.cyan(d)}
1445
+ default: {
1446
+ const l = `${import_picocolors.default.cyan(d)} `, n = a.split(`
1447
+ `).length;
1448
+ return `${a}${l}${X({
1449
+ output: t.output,
1450
+ options: this.options,
1451
+ cursor: this.cursor,
1452
+ maxItems: t.maxItems,
1453
+ columnPadding: l.length,
1454
+ rowPadding: n + 2,
1455
+ style: u
1456
+ }).join(`
1457
+ ${l}`)}
1458
+ ${import_picocolors.default.cyan(x)}
1061
1459
  `;
1460
+ }
1062
1461
  }
1063
1462
  }
1064
1463
  }).prompt();
1065
- }, Me = (t = "", n = "") => {
1066
- const r = `
1067
- ${t}
1068
- `.split(`
1069
- `), i = stripVTControlCharacters(n).length, s = Math.max(r.reduce((a, l) => {
1070
- const $ = stripVTControlCharacters(l);
1071
- return $.length > a ? $.length : a;
1072
- }, 0), i) + 2, c = r.map((a) => `${import_picocolors.default.gray(o)} ${import_picocolors.default.dim(a)}${" ".repeat(s - stripVTControlCharacters(a).length)}${import_picocolors.default.gray(o)}`).join(`
1073
- `);
1074
- process.stdout.write(`${import_picocolors.default.gray(o)}
1075
- ${import_picocolors.default.green(C)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
1464
+ }, Ge = (t) => import_picocolors.default.dim(t), ke = (t, r, s) => {
1465
+ const i = {
1466
+ hard: !0,
1467
+ trim: !1
1468
+ }, a = J(t, r, i).split(`
1469
+ `), o = a.reduce((n, c) => Math.max(M(c), n), 0);
1470
+ return J(t, r - (a.map(s).reduce((n, c) => Math.max(M(c), n), 0) - o), i);
1471
+ }, Ve = (t = "", r = "", s) => {
1472
+ const i = s?.output ?? N.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? Ge, u = [
1473
+ "",
1474
+ ...ke(t, rt$1(i) - 6, o).split(`
1475
+ `).map(o),
1476
+ ""
1477
+ ], l = M(r), n = Math.max(u.reduce((p, E) => {
1478
+ const $ = M(E);
1479
+ return $ > p ? $ : p;
1480
+ }, 0), l) + 2, c = u.map((p) => `${import_picocolors.default.gray(d)} ${p}${" ".repeat(n - M(p))}${import_picocolors.default.gray(d)}`).join(`
1481
+ `), g = a ? `${import_picocolors.default.gray(d)}
1482
+ ` : "", F = a ? Wt : gt;
1483
+ i.write(`${g}${import_picocolors.default.green(V)} ${import_picocolors.default.reset(r)} ${import_picocolors.default.gray(rt.repeat(Math.max(n - l - 1, 1)) + mt)}
1076
1484
  ${c}
1077
- ${import_picocolors.default.gray(de + _.repeat(s + 2) + pe)}
1078
- `);
1079
- }, xe = (t = "") => {
1080
- process.stdout.write(`${import_picocolors.default.gray(d)} ${import_picocolors.default.red(t)}
1081
-
1485
+ ${import_picocolors.default.gray(F + rt.repeat(n + 2) + pt)}
1082
1486
  `);
1083
- }, Ie = (t = "") => {
1084
- process.stdout.write(`${import_picocolors.default.gray(ue)} ${t}
1487
+ }, He = (t) => new Mt$1({
1488
+ validate: t.validate,
1489
+ mask: t.mask ?? Nt,
1490
+ signal: t.signal,
1491
+ input: t.input,
1492
+ output: t.output,
1493
+ render() {
1494
+ const r = t.withGuide ?? _.withGuide, s = `${r ? `${import_picocolors.default.gray(d)}
1495
+ ` : ""}${W(this.state)} ${t.message}
1496
+ `, i = this.userInputWithCursor, a = this.masked;
1497
+ switch (this.state) {
1498
+ case "error": {
1499
+ const o = r ? `${import_picocolors.default.yellow(d)} ` : "", u = r ? `${import_picocolors.default.yellow(x)} ` : "", l = a ?? "";
1500
+ return t.clearOnError && this.clear(), `${s.trim()}
1501
+ ${o}${l}
1502
+ ${u}${import_picocolors.default.yellow(this.error)}
1503
+ `;
1504
+ }
1505
+ case "submit": return `${s}${r ? `${import_picocolors.default.gray(d)} ` : ""}${a ? import_picocolors.default.dim(a) : ""}`;
1506
+ case "cancel": return `${s}${r ? `${import_picocolors.default.gray(d)} ` : ""}${a ? import_picocolors.default.strikethrough(import_picocolors.default.dim(a)) : ""}${a && r ? `
1507
+ ${import_picocolors.default.gray(d)}` : ""}`;
1508
+ default: return `${s}${r ? `${import_picocolors.default.cyan(d)} ` : ""}${i}
1509
+ ${r ? import_picocolors.default.cyan(x) : ""}
1510
+ `;
1511
+ }
1512
+ }
1513
+ }).prompt(), Ue = (t) => {
1514
+ const r = t.validate;
1515
+ return Xt({
1516
+ ...t,
1517
+ initialUserInput: t.initialValue ?? t.root ?? process.cwd(),
1518
+ maxItems: 5,
1519
+ validate(s) {
1520
+ if (!Array.isArray(s)) {
1521
+ if (!s) return "Please select a path";
1522
+ if (r) return r(s);
1523
+ }
1524
+ },
1525
+ options() {
1526
+ const s = this.userInput;
1527
+ if (s === "") return [];
1528
+ try {
1529
+ let i;
1530
+ return existsSync(s) ? lstatSync(s).isDirectory() ? i = s : i = dirname(s) : i = dirname(s), readdirSync(i).map((a) => {
1531
+ const o = join(i, a);
1532
+ return {
1533
+ name: a,
1534
+ path: o,
1535
+ isDirectory: lstatSync(o).isDirectory()
1536
+ };
1537
+ }).filter(({ path: a, isDirectory: o }) => a.startsWith(s) && (t.directory || !o)).map((a) => ({ value: a.path }));
1538
+ } catch {
1539
+ return [];
1540
+ }
1541
+ }
1542
+ });
1543
+ }, Ke = import_picocolors.default.magenta, bt = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = et ? [
1544
+ "◒",
1545
+ "◐",
1546
+ "◓",
1547
+ "◑"
1548
+ ] : [
1549
+ "•",
1550
+ "o",
1551
+ "O",
1552
+ "0"
1553
+ ], delay: u = et ? 80 : 120, signal: l, ...n } = {}) => {
1554
+ const c = ct();
1555
+ let g, F, p = !1, E = !1, $ = "", m, h = performance.now();
1556
+ const y = rt$1(s), f = n?.styleFrame ?? Ke, v = (b) => {
1557
+ const O = b > 1 ? a ?? _.messages.error : i ?? _.messages.cancel;
1558
+ E = b === 1, p && (L(O, b), E && typeof r == "function" && r());
1559
+ }, S = () => v(2), I = () => v(1), B = () => {
1560
+ process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", I), process.on("SIGTERM", I), process.on("exit", v), l && l.addEventListener("abort", I);
1561
+ }, A = () => {
1562
+ process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", I), process.removeListener("SIGTERM", I), process.removeListener("exit", v), l && l.removeEventListener("abort", I);
1563
+ }, w = () => {
1564
+ if (m === void 0) return;
1565
+ c && s.write(`
1085
1566
  `);
1086
- }, Se = (t = "") => {
1087
- process.stdout.write(`${import_picocolors.default.gray(o)}
1088
- ${import_picocolors.default.gray(d)} ${t}
1089
-
1567
+ const b = J(m, y, {
1568
+ hard: !0,
1569
+ trim: !1
1570
+ }).split(`
1090
1571
  `);
1091
- }, M = {
1092
- message: (t = "", { symbol: n = import_picocolors.default.gray(o) } = {}) => {
1093
- const r = [`${import_picocolors.default.gray(o)}`];
1094
- if (t) {
1095
- const [i, ...s] = t.split(`
1572
+ b.length > 1 && s.write(import_src.cursor.up(b.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
1573
+ }, _$1 = (b) => b.replace(/\.+$/, ""), D = (b) => {
1574
+ const O = (performance.now() - b) / 1e3, j = Math.floor(O / 60), G = Math.floor(O % 60);
1575
+ return j > 0 ? `[${j}m ${G}s]` : `[${G}s]`;
1576
+ }, T = n.withGuide ?? _.withGuide, Y = (b = "") => {
1577
+ p = !0, g = Bt({ output: s }), $ = _$1(b), h = performance.now(), T && s.write(`${import_picocolors.default.gray(d)}
1096
1578
  `);
1097
- r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors.default.gray(o)} ${c}`));
1579
+ let O = 0, j = 0;
1580
+ B(), F = setInterval(() => {
1581
+ if (c && $ === m) return;
1582
+ w(), m = $;
1583
+ const G = f(o[O]);
1584
+ let tt;
1585
+ if (c) tt = `${G} ${$}...`;
1586
+ else if (t === "timer") tt = `${G} ${$} ${D(h)}`;
1587
+ else {
1588
+ const te = ".".repeat(Math.floor(j)).slice(0, 3);
1589
+ tt = `${G} ${$}${te}`;
1590
+ }
1591
+ const Zt = J(tt, y, {
1592
+ hard: !0,
1593
+ trim: !1
1594
+ });
1595
+ s.write(Zt), O = O + 1 < o.length ? O + 1 : 0, j = j < 4 ? j + .125 : 0;
1596
+ }, u);
1597
+ }, L = (b = "", O = 0, j = !1) => {
1598
+ if (!p) return;
1599
+ p = !1, clearInterval(F), w();
1600
+ const G = O === 0 ? import_picocolors.default.green(V) : O === 1 ? import_picocolors.default.red(dt) : import_picocolors.default.red($t);
1601
+ $ = b ?? $, j || (t === "timer" ? s.write(`${G} ${$} ${D(h)}
1602
+ `) : s.write(`${G} ${$}
1603
+ `)), A(), g();
1604
+ };
1605
+ return {
1606
+ start: Y,
1607
+ stop: (b = "") => L(b, 0),
1608
+ message: (b = "") => {
1609
+ $ = _$1(b ?? $);
1610
+ },
1611
+ cancel: (b = "") => L(b, 1),
1612
+ error: (b = "") => L(b, 2),
1613
+ clear: () => L("", 0, !0),
1614
+ get isCancelled() {
1615
+ return E;
1098
1616
  }
1099
- process.stdout.write(`${r.join(`
1617
+ };
1618
+ }, zt = {
1619
+ light: C("─", "-"),
1620
+ heavy: C("━", "="),
1621
+ block: C("█", "#")
1622
+ };
1623
+ const lt = (t, r) => t.includes(`
1624
+ `) ? t.split(`
1625
+ `).map((s) => r(s)).join(`
1626
+ `) : r(t), Je = (t) => {
1627
+ const r = (s, i) => {
1628
+ const a = s.label ?? String(s.value);
1629
+ switch (i) {
1630
+ case "disabled": return `${import_picocolors.default.gray(H)} ${lt(a, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
1631
+ case "selected": return `${lt(a, import_picocolors.default.dim)}`;
1632
+ case "active": return `${import_picocolors.default.green(Q)} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
1633
+ case "cancelled": return `${lt(a, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
1634
+ default: return `${import_picocolors.default.dim(H)} ${lt(a, import_picocolors.default.dim)}`;
1635
+ }
1636
+ };
1637
+ return new Wt$1({
1638
+ options: t.options,
1639
+ signal: t.signal,
1640
+ input: t.input,
1641
+ output: t.output,
1642
+ initialValue: t.initialValue,
1643
+ render() {
1644
+ const s = t.withGuide ?? _.withGuide, i = `${W(this.state)} `, a = `${vt(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors.default.gray(d)}
1645
+ ` : ""}${o}
1646
+ `;
1647
+ switch (this.state) {
1648
+ case "submit": {
1649
+ const l = s ? `${import_picocolors.default.gray(d)} ` : "";
1650
+ return `${u}${xt(t.output, r(this.options[this.cursor], "selected"), l)}`;
1651
+ }
1652
+ case "cancel": {
1653
+ const l = s ? `${import_picocolors.default.gray(d)} ` : "";
1654
+ return `${u}${xt(t.output, r(this.options[this.cursor], "cancelled"), l)}${s ? `
1655
+ ${import_picocolors.default.gray(d)}` : ""}`;
1656
+ }
1657
+ default: {
1658
+ const l = s ? `${import_picocolors.default.cyan(d)} ` : "", n = s ? import_picocolors.default.cyan(x) : "", c = u.split(`
1659
+ `).length, g = s ? 2 : 1;
1660
+ return `${u}${l}${X({
1661
+ output: t.output,
1662
+ cursor: this.cursor,
1663
+ options: this.options,
1664
+ maxItems: t.maxItems,
1665
+ columnPadding: l.length,
1666
+ rowPadding: c + g,
1667
+ style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive")
1668
+ }).join(`
1669
+ ${l}`)}
1670
+ ${n}
1671
+ `;
1672
+ }
1673
+ }
1674
+ }
1675
+ }).prompt();
1676
+ }, Xe = (t) => {
1677
+ const r = (s, i = "inactive") => {
1678
+ const a = s.label ?? String(s.value);
1679
+ return i === "selected" ? `${import_picocolors.default.dim(a)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${s.value} `))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${s.value} `)))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
1680
+ };
1681
+ return new Tt$1({
1682
+ options: t.options,
1683
+ signal: t.signal,
1684
+ input: t.input,
1685
+ output: t.output,
1686
+ initialValue: t.initialValue,
1687
+ caseSensitive: t.caseSensitive,
1688
+ render() {
1689
+ const s = t.withGuide ?? _.withGuide, i = `${s ? `${import_picocolors.default.gray(d)}
1690
+ ` : ""}${W(this.state)} ${t.message}
1691
+ `;
1692
+ switch (this.state) {
1693
+ case "submit": {
1694
+ const a = s ? `${import_picocolors.default.gray(d)} ` : "", o = this.options.find((l) => l.value === this.value) ?? t.options[0];
1695
+ return `${i}${xt(t.output, r(o, "selected"), a)}`;
1696
+ }
1697
+ case "cancel": {
1698
+ const a = s ? `${import_picocolors.default.gray(d)} ` : "";
1699
+ return `${i}${xt(t.output, r(this.options[0], "cancelled"), a)}${s ? `
1700
+ ${import_picocolors.default.gray(d)}` : ""}`;
1701
+ }
1702
+ default: {
1703
+ const a = s ? `${import_picocolors.default.cyan(d)} ` : "", o = s ? import_picocolors.default.cyan(x) : "";
1704
+ return `${i}${this.options.map((l, n) => xt(t.output, r(l, n === this.cursor ? "active" : "inactive"), a)).join(`
1100
1705
  `)}
1101
- `);
1102
- },
1103
- info: (t) => {
1104
- M.message(t, { symbol: import_picocolors.default.blue(q) });
1105
- },
1106
- success: (t) => {
1107
- M.message(t, { symbol: import_picocolors.default.green(D) });
1108
- },
1109
- step: (t) => {
1110
- M.message(t, { symbol: import_picocolors.default.green(C) });
1111
- },
1112
- warn: (t) => {
1113
- M.message(t, { symbol: import_picocolors.default.yellow(U) });
1114
- },
1115
- warning: (t) => {
1116
- M.warn(t);
1117
- },
1118
- error: (t) => {
1119
- M.message(t, { symbol: import_picocolors.default.red(K) });
1120
- }
1121
- }, J = `${import_picocolors.default.gray(o)} `, x = {
1122
- message: async (t, { symbol: n = import_picocolors.default.gray(o) } = {}) => {
1123
- process.stdout.write(`${import_picocolors.default.gray(o)}
1124
- ${n} `);
1125
- let r = 3;
1706
+ ${o}
1707
+ `;
1708
+ }
1709
+ }
1710
+ }
1711
+ }).prompt();
1712
+ }, Qt = `${import_picocolors.default.gray(d)} `, K = {
1713
+ message: async (t, { symbol: r = import_picocolors.default.gray(d) } = {}) => {
1714
+ process.stdout.write(`${import_picocolors.default.gray(d)}
1715
+ ${r} `);
1716
+ let s = 3;
1126
1717
  for await (let i of t) {
1127
1718
  i = i.replace(/\n/g, `
1128
- ${J}`), i.includes(`
1129
- `) && (r = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1719
+ ${Qt}`), i.includes(`
1720
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1130
1721
  `))).length);
1131
- const s = stripVTControlCharacters(i).length;
1132
- r + s < process.stdout.columns ? (r += s, process.stdout.write(i)) : (process.stdout.write(`
1133
- ${J}${i.trimStart()}`), r = 3 + stripVTControlCharacters(i.trimStart()).length);
1722
+ const a = stripVTControlCharacters(i).length;
1723
+ s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
1724
+ ${Qt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
1134
1725
  }
1135
1726
  process.stdout.write(`
1136
1727
  `);
1137
1728
  },
1138
- info: (t) => x.message(t, { symbol: import_picocolors.default.blue(q) }),
1139
- success: (t) => x.message(t, { symbol: import_picocolors.default.green(D) }),
1140
- step: (t) => x.message(t, { symbol: import_picocolors.default.green(C) }),
1141
- warn: (t) => x.message(t, { symbol: import_picocolors.default.yellow(U) }),
1142
- warning: (t) => x.warn(t),
1143
- error: (t) => x.message(t, { symbol: import_picocolors.default.red(K) })
1144
- }, Y = ({ indicator: t = "dots" } = {}) => {
1145
- const n = V ? [
1146
- "◒",
1147
- "◐",
1148
- "◓",
1149
- "◑"
1150
- ] : [
1151
- "•",
1152
- "o",
1153
- "O",
1154
- "0"
1155
- ], r = V ? 80 : 120, i = process.env.CI === "true";
1156
- let s, c, a = !1, l = "", $, g = performance.now();
1157
- const p = (m) => {
1158
- a && N(m > 1 ? "Something went wrong" : "Canceled", m);
1159
- }, v = () => p(2), f = () => p(1), j = () => {
1160
- process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p);
1161
- }, E = () => {
1162
- process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p);
1163
- }, B = () => {
1164
- if ($ === void 0) return;
1165
- i && process.stdout.write(`
1729
+ info: (t) => K.message(t, { symbol: import_picocolors.default.blue(ft) }),
1730
+ success: (t) => K.message(t, { symbol: import_picocolors.default.green(Ft) }),
1731
+ step: (t) => K.message(t, { symbol: import_picocolors.default.green(V) }),
1732
+ warn: (t) => K.message(t, { symbol: import_picocolors.default.yellow(yt) }),
1733
+ warning: (t) => K.warn(t),
1734
+ error: (t) => K.message(t, { symbol: import_picocolors.default.red(Et) })
1735
+ }, Ye = async (t, r) => {
1736
+ for (const s of t) {
1737
+ if (s.enabled === !1) continue;
1738
+ const i = bt(r);
1739
+ i.start(s.title);
1740
+ const a = await s.task(i.message);
1741
+ i.stop(a || s.title);
1742
+ }
1743
+ }, ze = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Qe = (t) => {
1744
+ const r = t.output ?? process.stdout, s = rt$1(r), i = import_picocolors.default.gray(d), a = t.spacing ?? 1, o = 3, u = t.retainLog === !0, l = !ct() && Mt(r);
1745
+ r.write(`${i}
1746
+ `), r.write(`${import_picocolors.default.green(V)} ${t.title}
1166
1747
  `);
1167
- const m = $.split(`
1748
+ for (let h = 0; h < a; h++) r.write(`${i}
1168
1749
  `);
1169
- process.stdout.write(import_src.cursor.move(-999, m.length - 1)), process.stdout.write(import_src.erase.down(m.length));
1170
- }, R = (m) => m.replace(/\.+$/, ""), O = (m) => {
1171
- const h = (performance.now() - m) / 1e3, w = Math.floor(h / 60), I = Math.floor(h % 60);
1172
- return w > 0 ? `[${w}m ${I}s]` : `[${I}s]`;
1173
- }, H = (m = "") => {
1174
- a = !0, s = fD(), l = R(m), g = performance.now(), process.stdout.write(`${import_picocolors.default.gray(o)}
1175
- `);
1176
- let h = 0, w = 0;
1177
- j(), c = setInterval(() => {
1178
- if (i && l === $) return;
1179
- B(), $ = l;
1180
- const I = import_picocolors.default.magenta(n[h]);
1181
- if (i) process.stdout.write(`${I} ${l}...`);
1182
- else if (t === "timer") process.stdout.write(`${I} ${l} ${O(g)}`);
1183
- else {
1184
- const z = ".".repeat(Math.floor(w)).slice(0, 3);
1185
- process.stdout.write(`${I} ${l}${z}`);
1750
+ const n = [{
1751
+ value: "",
1752
+ full: ""
1753
+ }];
1754
+ let c = !1;
1755
+ const g = (h) => {
1756
+ if (n.length === 0) return;
1757
+ let y = 0;
1758
+ h && (y += a + 2);
1759
+ for (const f of n) {
1760
+ const { value: v, result: S } = f;
1761
+ let I = S?.message ?? v;
1762
+ if (I.length === 0) continue;
1763
+ S === void 0 && f.header !== void 0 && f.header !== "" && (I += `
1764
+ ${f.header}`);
1765
+ const B = I.split(`
1766
+ `).reduce((A, w) => w === "" ? A + 1 : A + Math.ceil((w.length + o) / s), 0);
1767
+ y += B;
1768
+ }
1769
+ y > 0 && (y += 1, r.write(import_src.erase.lines(y)));
1770
+ }, F = (h, y, f) => {
1771
+ const v = f ? `${h.full}
1772
+ ${h.value}` : h.value;
1773
+ h.header !== void 0 && h.header !== "" && R.message(h.header.split(`
1774
+ `).map(import_picocolors.default.bold), {
1775
+ output: r,
1776
+ secondarySymbol: i,
1777
+ symbol: i,
1778
+ spacing: 0
1779
+ }), R.message(v.split(`
1780
+ `).map(import_picocolors.default.dim), {
1781
+ output: r,
1782
+ secondarySymbol: i,
1783
+ symbol: i,
1784
+ spacing: y ?? a
1785
+ });
1786
+ }, p = () => {
1787
+ for (const h of n) {
1788
+ const { header: y, value: f, full: v } = h;
1789
+ (y === void 0 || y.length === 0) && f.length === 0 || F(h, void 0, u === !0 && v.length > 0);
1790
+ }
1791
+ }, E = (h, y, f) => {
1792
+ if (g(!1), (f?.raw !== !0 || !c) && h.value !== "" && (h.value += `
1793
+ `), h.value += ze(y), c = f?.raw === !0, t.limit !== void 0) {
1794
+ const v = h.value.split(`
1795
+ `), S = v.length - t.limit;
1796
+ if (S > 0) {
1797
+ const I = v.splice(0, S);
1798
+ u && (h.full += (h.full === "" ? "" : `
1799
+ `) + I.join(`
1800
+ `));
1186
1801
  }
1187
- h = h + 1 < n.length ? h + 1 : 0, w = w < n.length ? w + .125 : 0;
1188
- }, r);
1189
- }, N = (m = "", h = 0) => {
1190
- a = !1, clearInterval(c), B();
1191
- const w = h === 0 ? import_picocolors.default.green(C) : h === 1 ? import_picocolors.default.red(L) : import_picocolors.default.red(W);
1192
- l = R(m ?? l), t === "timer" ? process.stdout.write(`${w} ${l} ${O(g)}
1193
- `) : process.stdout.write(`${w} ${l}
1194
- `), E(), s();
1802
+ h.value = v.join(`
1803
+ `);
1804
+ }
1805
+ l && $();
1806
+ }, $ = () => {
1807
+ for (const h of n) h.result ? h.result.status === "error" ? R.error(h.result.message, {
1808
+ output: r,
1809
+ secondarySymbol: i,
1810
+ spacing: 0
1811
+ }) : R.success(h.result.message, {
1812
+ output: r,
1813
+ secondarySymbol: i,
1814
+ spacing: 0
1815
+ }) : h.value !== "" && F(h, 0);
1816
+ }, m = (h, y) => {
1817
+ g(!1), h.result = y, l && $();
1195
1818
  };
1196
1819
  return {
1197
- start: H,
1198
- stop: N,
1199
- message: (m = "") => {
1200
- l = R(m ?? l);
1820
+ message(h, y) {
1821
+ E(n[0], h, y);
1822
+ },
1823
+ group(h) {
1824
+ const y = {
1825
+ header: h,
1826
+ value: "",
1827
+ full: ""
1828
+ };
1829
+ return n.push(y), {
1830
+ message(f, v) {
1831
+ E(y, f, v);
1832
+ },
1833
+ error(f) {
1834
+ m(y, {
1835
+ status: "error",
1836
+ message: f
1837
+ });
1838
+ },
1839
+ success(f) {
1840
+ m(y, {
1841
+ status: "success",
1842
+ message: f
1843
+ });
1844
+ }
1845
+ };
1846
+ },
1847
+ error(h, y) {
1848
+ g(!0), R.error(h, {
1849
+ output: r,
1850
+ secondarySymbol: i,
1851
+ spacing: 1
1852
+ }), y?.showLog !== !1 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1853
+ },
1854
+ success(h, y) {
1855
+ g(!0), R.success(h, {
1856
+ output: r,
1857
+ secondarySymbol: i,
1858
+ spacing: 1
1859
+ }), y?.showLog === !0 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
1201
1860
  }
1202
1861
  };
1203
- }, Ce = async (t, n) => {
1204
- const r = {}, i = Object.keys(t);
1205
- for (const s of i) {
1206
- const c = t[s], a = await c({ results: r })?.catch((l) => {
1207
- throw l;
1208
- });
1209
- if (typeof n?.onCancel == "function" && pD(a)) {
1210
- r[s] = "canceled", n.onCancel({ results: r });
1211
- continue;
1862
+ }, Ze = (t) => new $t$1({
1863
+ validate: t.validate,
1864
+ placeholder: t.placeholder,
1865
+ defaultValue: t.defaultValue,
1866
+ initialValue: t.initialValue,
1867
+ output: t.output,
1868
+ signal: t.signal,
1869
+ input: t.input,
1870
+ render() {
1871
+ const r = t?.withGuide ?? _.withGuide, s = `${`${r ? `${import_picocolors.default.gray(d)}
1872
+ ` : ""}${W(this.state)} `}${t.message}
1873
+ `, i = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
1874
+ switch (this.state) {
1875
+ case "error": {
1876
+ const u = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "", l = r ? `${import_picocolors.default.yellow(d)} ` : "", n = r ? import_picocolors.default.yellow(x) : "";
1877
+ return `${s.trim()}
1878
+ ${l}${a}
1879
+ ${n}${u}
1880
+ `;
1881
+ }
1882
+ case "submit": {
1883
+ const u = o ? ` ${import_picocolors.default.dim(o)}` : "";
1884
+ return `${s}${r ? import_picocolors.default.gray(d) : ""}${u}`;
1885
+ }
1886
+ case "cancel": {
1887
+ const u = o ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}` : "", l = r ? import_picocolors.default.gray(d) : "";
1888
+ return `${s}${l}${u}${o.trim() ? `
1889
+ ${l}` : ""}`;
1890
+ }
1891
+ default: return `${s}${r ? `${import_picocolors.default.cyan(d)} ` : ""}${a}
1892
+ ${r ? import_picocolors.default.cyan(x) : ""}
1893
+ `;
1212
1894
  }
1213
- r[s] = a;
1214
1895
  }
1215
- return r;
1216
- }, Te = async (t) => {
1217
- for (const n of t) {
1218
- if (n.enabled === !1) continue;
1219
- const r = Y();
1220
- r.start(n.title);
1221
- const i = await n.task(r.message);
1222
- r.stop(i || n.title);
1223
- }
1224
- };
1225
-
1226
- //#endregion
1227
- //#region src/apply.ts
1228
- async function runRulerApply(projectDir, agents) {
1229
- const s = Y();
1230
- s.start("Running ruler to generate agent configurations...");
1231
- const agentFlag = agents.join(",");
1232
- try {
1233
- execSync(`npx --yes @intellectronica/ruler apply --agents ${agentFlag}`, {
1234
- cwd: projectDir,
1235
- stdio: "pipe",
1236
- timeout: 12e4
1237
- });
1238
- s.stop("Generated agent configurations");
1239
- } catch {
1240
- s.stop("ruler apply encountered issues");
1241
- M.warn(`ruler apply had warnings or errors. You can run it manually:
1242
- npx @intellectronica/ruler apply --agents ${agentFlag}`);
1243
- }
1244
- }
1245
-
1246
- //#endregion
1247
- //#region src/configure.ts
1248
- function configureRulerToml(projectDir, agents) {
1249
- const tomlPath = path.join(projectDir, ".ruler", "ruler.toml");
1250
- if (!fs.existsSync(tomlPath)) {
1251
- M.warn("ruler.toml not found, skipping configuration");
1252
- return;
1253
- }
1254
- let content = fs.readFileSync(tomlPath, "utf-8");
1255
- const newLine = `default_agents = [${agents.map((a) => `"${a}"`).join(", ")}]`;
1256
- if (/^#?\s*default_agents\s*=/m.test(content)) content = content.replace(/^#?\s*default_agents\s*=.*$/m, newLine);
1257
- else {
1258
- const insertPoint = content.indexOf("\n\n");
1259
- if (insertPoint !== -1) content = content.slice(0, insertPoint) + "\n" + newLine + content.slice(insertPoint);
1260
- else content += `\n${newLine}\n`;
1261
- }
1262
- fs.writeFileSync(tomlPath, content, "utf-8");
1263
- M.info(`Configured ruler.toml with agents: ${agents.join(", ")}`);
1264
- }
1896
+ }).prompt();
1265
1897
 
1266
1898
  //#endregion
1267
1899
  //#region src/constants.ts
1268
1900
  const REPO_URL = "https://github.com/buiducnhat/agent-skills.git";
1269
1901
  const REPO_BRANCH = "main";
1270
- const RULER_AGENTS = [
1902
+ const SUPPORTED_AGENTS = [
1903
+ {
1904
+ id: "adal",
1905
+ name: "AdaL"
1906
+ },
1907
+ {
1908
+ id: "amp",
1909
+ name: "Amp"
1910
+ },
1271
1911
  {
1272
- value: "claude",
1273
- label: "Claude Code",
1274
- hint: "Anthropic"
1912
+ id: "antigravity",
1913
+ name: "Antigravity"
1275
1914
  },
1276
1915
  {
1277
- value: "copilot",
1278
- label: "GitHub Copilot",
1279
- hint: "GitHub"
1916
+ id: "augment",
1917
+ name: "Augment"
1280
1918
  },
1281
1919
  {
1282
- value: "cursor",
1283
- label: "Cursor",
1284
- hint: "Cursor"
1920
+ id: "claude-code",
1921
+ name: "Claude Code"
1285
1922
  },
1286
1923
  {
1287
- value: "windsurf",
1288
- label: "Windsurf",
1289
- hint: "Codeium"
1924
+ id: "cline",
1925
+ name: "Cline"
1290
1926
  },
1291
1927
  {
1292
- value: "codex",
1293
- label: "OpenAI Codex CLI",
1294
- hint: "OpenAI"
1928
+ id: "codebuddy",
1929
+ name: "CodeBuddy"
1295
1930
  },
1296
1931
  {
1297
- value: "gemini-cli",
1298
- label: "Gemini CLI",
1299
- hint: "Google"
1932
+ id: "codex",
1933
+ name: "Codex"
1300
1934
  },
1301
1935
  {
1302
- value: "amp",
1303
- label: "Amp",
1304
- hint: "Sourcegraph"
1936
+ id: "command-code",
1937
+ name: "Command Code"
1305
1938
  },
1306
1939
  {
1307
- value: "cline",
1308
- label: "Cline",
1309
- hint: "VS Code"
1940
+ id: "continue",
1941
+ name: "Continue"
1310
1942
  },
1311
1943
  {
1312
- value: "roo",
1313
- label: "Roo Code",
1314
- hint: "VS Code"
1944
+ id: "cortex",
1945
+ name: "Cortex Code"
1315
1946
  },
1316
1947
  {
1317
- value: "aider",
1318
- label: "Aider",
1319
- hint: "Terminal"
1948
+ id: "crush",
1949
+ name: "Crush"
1320
1950
  },
1321
1951
  {
1322
- value: "antigravity",
1323
- label: "Antigravity",
1324
- hint: ""
1952
+ id: "cursor",
1953
+ name: "Cursor"
1325
1954
  },
1326
1955
  {
1327
- value: "pi",
1328
- label: "Pi Coding Agent",
1329
- hint: ""
1956
+ id: "droid",
1957
+ name: "Droid"
1330
1958
  },
1331
1959
  {
1332
- value: "jules",
1333
- label: "Jules",
1334
- hint: "Google"
1960
+ id: "gemini-cli",
1961
+ name: "Gemini CLI"
1335
1962
  },
1336
1963
  {
1337
- value: "kiro",
1338
- label: "Kiro",
1339
- hint: "AWS"
1964
+ id: "github-copilot",
1965
+ name: "GitHub Copilot"
1340
1966
  },
1341
1967
  {
1342
- value: "kilocode",
1343
- label: "Kilo Code",
1344
- hint: "VS Code"
1968
+ id: "goose",
1969
+ name: "Goose"
1345
1970
  },
1346
1971
  {
1347
- value: "crush",
1348
- label: "Crush",
1349
- hint: ""
1972
+ id: "iflow-cli",
1973
+ name: "iFlow CLI"
1350
1974
  },
1351
1975
  {
1352
- value: "amazonqcli",
1353
- label: "Amazon Q CLI",
1354
- hint: "AWS"
1976
+ id: "junie",
1977
+ name: "Junie"
1355
1978
  },
1356
1979
  {
1357
- value: "firebase",
1358
- label: "Firebase Studio",
1359
- hint: "Google"
1980
+ id: "kilo",
1981
+ name: "Kilo Code"
1360
1982
  },
1361
1983
  {
1362
- value: "openhands",
1363
- label: "Open Hands",
1364
- hint: ""
1984
+ id: "kimi-cli",
1985
+ name: "Kimi Code CLI"
1365
1986
  },
1366
1987
  {
1367
- value: "junie",
1368
- label: "Junie",
1369
- hint: "JetBrains"
1988
+ id: "kiro-cli",
1989
+ name: "Kiro CLI"
1370
1990
  },
1371
1991
  {
1372
- value: "jetbrains-ai",
1373
- label: "JetBrains AI Assistant",
1374
- hint: "JetBrains"
1992
+ id: "kode",
1993
+ name: "Kode"
1375
1994
  },
1376
1995
  {
1377
- value: "augmentcode",
1378
- label: "AugmentCode",
1379
- hint: ""
1996
+ id: "mcpjam",
1997
+ name: "MCPJam"
1380
1998
  },
1381
1999
  {
1382
- value: "opencode",
1383
- label: "OpenCode",
1384
- hint: ""
2000
+ id: "mistral-vibe",
2001
+ name: "Mistral Vibe"
1385
2002
  },
1386
2003
  {
1387
- value: "goose",
1388
- label: "Goose",
1389
- hint: "Block"
2004
+ id: "mux",
2005
+ name: "Mux"
1390
2006
  },
1391
2007
  {
1392
- value: "qwen",
1393
- label: "Qwen Code",
1394
- hint: "Alibaba"
2008
+ id: "neovate",
2009
+ name: "Neovate"
1395
2010
  },
1396
2011
  {
1397
- value: "zed",
1398
- label: "Zed",
1399
- hint: ""
2012
+ id: "openclaw",
2013
+ name: "OpenClaw"
1400
2014
  },
1401
2015
  {
1402
- value: "trae",
1403
- label: "Trae AI",
1404
- hint: "ByteDance"
2016
+ id: "opencode",
2017
+ name: "OpenCode"
1405
2018
  },
1406
2019
  {
1407
- value: "warp",
1408
- label: "Warp",
1409
- hint: ""
2020
+ id: "openhands",
2021
+ name: "OpenHands"
1410
2022
  },
1411
2023
  {
1412
- value: "firebender",
1413
- label: "Firebender",
1414
- hint: ""
2024
+ id: "pi",
2025
+ name: "Pi"
1415
2026
  },
1416
2027
  {
1417
- value: "factory",
1418
- label: "Factory Droid",
1419
- hint: ""
2028
+ id: "pochi",
2029
+ name: "Pochi"
1420
2030
  },
1421
2031
  {
1422
- value: "mistral",
1423
- label: "Mistral Vibe",
1424
- hint: "Mistral"
2032
+ id: "qoder",
2033
+ name: "Qoder"
2034
+ },
2035
+ {
2036
+ id: "qwen-code",
2037
+ name: "Qwen Code"
2038
+ },
2039
+ {
2040
+ id: "replit",
2041
+ name: "Replit"
2042
+ },
2043
+ {
2044
+ id: "roo",
2045
+ name: "Roo Code"
2046
+ },
2047
+ {
2048
+ id: "trae",
2049
+ name: "Trae"
2050
+ },
2051
+ {
2052
+ id: "trae-cn",
2053
+ name: "Trae CN"
2054
+ },
2055
+ {
2056
+ id: "windsurf",
2057
+ name: "Windsurf"
2058
+ },
2059
+ {
2060
+ id: "zencoder",
2061
+ name: "Zencoder"
1425
2062
  }
1426
2063
  ];
1427
- const POPULAR_AGENTS = [
1428
- "claude",
1429
- "copilot",
1430
- "cursor",
1431
- "windsurf",
1432
- "codex",
1433
- "gemini-cli"
1434
- ];
2064
+ const AGENT_SKILLS_DIRS = {
2065
+ ".adal": "adal",
2066
+ ".agent": "antigravity",
2067
+ ".agents": "amp",
2068
+ ".augment": "augment",
2069
+ ".claude": "claude-code",
2070
+ ".codebuddy": "codebuddy",
2071
+ ".commandcode": "command-code",
2072
+ ".continue": "continue",
2073
+ ".cortex": "cortex",
2074
+ ".crush": "crush",
2075
+ ".cursor": "cursor",
2076
+ ".factory": "droid",
2077
+ ".gemini": "gemini-cli",
2078
+ ".goose": "goose",
2079
+ ".iflow": "iflow-cli",
2080
+ ".junie": "junie",
2081
+ ".kilocode": "kilo",
2082
+ ".kiro": "kiro-cli",
2083
+ ".kode": "kode",
2084
+ ".mcpjam": "mcpjam",
2085
+ ".mux": "mux",
2086
+ ".neovate": "neovate",
2087
+ ".openhands": "openhands",
2088
+ ".pi": "pi",
2089
+ ".pochi": "pochi",
2090
+ ".qoder": "qoder",
2091
+ ".qwen": "qwen-code",
2092
+ ".roo": "roo",
2093
+ ".trae": "trae",
2094
+ ".vibe": "mistral-vibe",
2095
+ ".windsurf": "windsurf",
2096
+ ".zencoder": "zencoder",
2097
+ skills: "openclaw"
2098
+ };
2099
+ const AGENT_RULES_MAP = {
2100
+ "github-copilot": "AGENTS.md",
2101
+ codex: "AGENTS.md",
2102
+ pi: "AGENTS.md",
2103
+ cursor: "AGENTS.md",
2104
+ amp: "AGENTS.md",
2105
+ "gemini-cli": "AGENTS.md",
2106
+ kilo: "AGENTS.md",
2107
+ opencode: "AGENTS.md",
2108
+ "qwen-code": "AGENTS.md",
2109
+ roo: "AGENTS.md",
2110
+ droid: "AGENTS.md",
2111
+ "mistral-vibe": "AGENTS.md",
2112
+ aider: "AGENTS.md",
2113
+ windsurf: "AGENTS.md",
2114
+ replit: "AGENTS.md",
2115
+ adal: "AGENTS.md",
2116
+ codebuddy: "AGENTS.md",
2117
+ "command-code": "AGENTS.md",
2118
+ continue: "AGENTS.md",
2119
+ cortex: "AGENTS.md",
2120
+ "iflow-cli": "AGENTS.md",
2121
+ "kimi-cli": "AGENTS.md",
2122
+ kode: "AGENTS.md",
2123
+ mcpjam: "AGENTS.md",
2124
+ mux: "AGENTS.md",
2125
+ neovate: "AGENTS.md",
2126
+ openclaw: "AGENTS.md",
2127
+ pochi: "AGENTS.md",
2128
+ qoder: "AGENTS.md",
2129
+ "trae-cn": "AGENTS.md",
2130
+ zencoder: "AGENTS.md",
2131
+ "claude-code": "CLAUDE.md",
2132
+ cline: ".clinerules",
2133
+ crush: "CRUSH.md",
2134
+ antigravity: ".agent/rules/ruler.md",
2135
+ "amazon-q": ".amazonq/rules/ruler_q_rules.md",
2136
+ "firebase-studio": ".idx/airules.md",
2137
+ openhands: ".openhands/microagents/repo.md",
2138
+ junie: ".junie/guidelines.md",
2139
+ augment: ".augment/rules/ruler_augment_instructions.md",
2140
+ trae: ".trae/rules/project_rules.md",
2141
+ "kiro-cli": ".kiro/steering/ruler_kiro_instructions.md",
2142
+ "jetbrains-ai": ".aiassistant/rules/AGENTS.md",
2143
+ goose: ".goosehints"
2144
+ };
2145
+ const RULES_MARKER_START = "<!-- BEGIN agent-skills rules -->";
2146
+ const RULES_MARKER_END = "<!-- END agent-skills rules -->";
1435
2147
 
1436
2148
  //#endregion
1437
2149
  //#region src/fetch.ts
1438
2150
  async function fetchTemplates() {
1439
- const s = Y();
2151
+ const s = bt();
1440
2152
  s.start("Downloading agent skills from GitHub...");
1441
2153
  const tempDir = mkdtempSync(path.join(tmpdir(), "agent-skills-"));
1442
2154
  try {
1443
2155
  execSync(`git clone --depth 1 --branch ${REPO_BRANCH} "${REPO_URL}" "${tempDir}"`, { stdio: "pipe" });
1444
- if (!existsSync(path.join(tempDir, "templates"))) throw new Error("templates/ directory not found in the repository");
2156
+ const templatesDir = path.join(tempDir, "templates");
2157
+ if (!existsSync(templatesDir)) throw new Error("templates/ directory not found in the repository");
2158
+ if (!existsSync(path.join(templatesDir, "AGENTS.md"))) throw new Error("templates/AGENTS.md not found in the repository");
1445
2159
  s.stop("Downloaded agent skills");
1446
2160
  return tempDir;
1447
2161
  } catch (err) {
@@ -1457,99 +2171,82 @@ function cleanupTemp(tempDir) {
1457
2171
  }
1458
2172
 
1459
2173
  //#endregion
1460
- //#region src/prompts.ts
1461
- function handleCancel(value) {
1462
- if (pD(value)) {
1463
- xe("Operation cancelled.");
1464
- process.exit(0);
1465
- }
1466
- }
1467
- async function promptExistingAction() {
1468
- const action = await ve({
1469
- message: "Existing .ruler/ directory found. What would you like to do?",
1470
- options: [{
1471
- value: "update",
1472
- label: "Update existing configuration"
1473
- }, {
1474
- value: "fresh",
1475
- label: "Fresh install (backs up and overwrites current)"
1476
- }]
1477
- });
1478
- handleCancel(action);
1479
- return action;
2174
+ //#region src/rules.ts
2175
+ function escapeRegex(str) {
2176
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1480
2177
  }
1481
- async function promptAgentSelection() {
1482
- const selected = await fe({
1483
- message: "Which AI agents do you use? (space to toggle, enter to confirm)",
1484
- options: [...RULER_AGENTS].sort((a, b) => {
1485
- const aPopular = POPULAR_AGENTS.includes(a.value);
1486
- const bPopular = POPULAR_AGENTS.includes(b.value);
1487
- if (aPopular && !bPopular) return -1;
1488
- if (!aPopular && bPopular) return 1;
1489
- return a.label.localeCompare(b.label);
1490
- }).map((a) => ({
1491
- value: a.value,
1492
- label: a.label,
1493
- hint: a.hint || void 0
1494
- })),
1495
- initialValues: ["claude"],
1496
- required: true
1497
- });
1498
- handleCancel(selected);
1499
- return selected;
2178
+ function injectRules(projectDir, agents, agentsContent) {
2179
+ const rulesFilePaths = /* @__PURE__ */ new Map();
2180
+ for (const agent of agents) {
2181
+ const rulesFile = AGENT_RULES_MAP[agent];
2182
+ if (rulesFile && !rulesFilePaths.has(rulesFile)) rulesFilePaths.set(rulesFile, agent);
2183
+ }
2184
+ const results = [];
2185
+ for (const rulesFilePath of rulesFilePaths.keys()) {
2186
+ const fullPath = path.join(projectDir, rulesFilePath);
2187
+ if (rulesFilePath.endsWith(".json")) {
2188
+ results.push({
2189
+ rulesFile: rulesFilePath,
2190
+ action: "skipped"
2191
+ });
2192
+ continue;
2193
+ }
2194
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
2195
+ const markedBlock = `\n${RULES_MARKER_START}\n${agentsContent}\n${RULES_MARKER_END}\n`;
2196
+ if (fs.existsSync(fullPath)) {
2197
+ const existing = fs.readFileSync(fullPath, "utf-8");
2198
+ const markerRegex = new RegExp(`${escapeRegex(RULES_MARKER_START)}[\\s\\S]*?${escapeRegex(RULES_MARKER_END)}`);
2199
+ if (markerRegex.test(existing)) {
2200
+ const updated = existing.replace(markerRegex, `${RULES_MARKER_START}\n${agentsContent}\n${RULES_MARKER_END}`);
2201
+ fs.writeFileSync(fullPath, updated, "utf-8");
2202
+ } else fs.writeFileSync(fullPath, existing + markedBlock, "utf-8");
2203
+ results.push({
2204
+ rulesFile: rulesFilePath,
2205
+ action: "updated"
2206
+ });
2207
+ } else {
2208
+ fs.writeFileSync(fullPath, markedBlock, "utf-8");
2209
+ results.push({
2210
+ rulesFile: rulesFilePath,
2211
+ action: "created"
2212
+ });
2213
+ }
2214
+ }
2215
+ return results;
1500
2216
  }
1501
2217
 
1502
2218
  //#endregion
1503
- //#region src/manifest.ts
1504
- const MANIFEST_FILENAME = ".library-manifest.json";
1505
- function getManifestPath(projectDir) {
1506
- return path.join(projectDir, ".ruler", "skills", MANIFEST_FILENAME);
1507
- }
1508
- function readManifest(projectDir) {
1509
- const manifestPath = getManifestPath(projectDir);
1510
- if (!fs.existsSync(manifestPath)) return null;
1511
- try {
1512
- const raw = fs.readFileSync(manifestPath, "utf8");
1513
- const data = JSON.parse(raw);
1514
- if (typeof data.version !== "number" || !Array.isArray(data.skills) || !data.skills.every((s) => typeof s === "string")) return null;
1515
- return {
1516
- version: data.version,
1517
- skills: data.skills
1518
- };
1519
- } catch {
1520
- return null;
1521
- }
1522
- }
1523
- function writeManifest(projectDir, skills) {
1524
- const manifestPath = getManifestPath(projectDir);
1525
- const manifestDir = path.dirname(manifestPath);
1526
- fs.mkdirSync(manifestDir, { recursive: true });
1527
- const manifest = {
1528
- version: 1,
1529
- skills: [...new Set(skills)].sort()
1530
- };
1531
- fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
1532
- }
1533
- function getTemplateSkillNames(tempDir) {
1534
- const skillsDir = path.join(tempDir, "templates", ".ruler", "skills");
1535
- if (!fs.existsSync(skillsDir)) return [];
1536
- return fs.readdirSync(skillsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
1537
- }
1538
- function getInstalledSkillNames(projectDir) {
1539
- const skillsDir = path.join(projectDir, ".ruler", "skills");
1540
- if (!fs.existsSync(skillsDir)) return [];
1541
- return fs.readdirSync(skillsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== MANIFEST_FILENAME).map((entry) => entry.name);
1542
- }
1543
- function computeDeprecatedSkills(oldManifest, newTemplateSkills) {
1544
- if (!oldManifest) return [];
1545
- const templateSet = new Set(newTemplateSkills);
1546
- return oldManifest.skills.filter((skill) => !templateSet.has(skill));
1547
- }
1548
- function computeCustomSkills(installedSkills, manifestSkills, templateSkills) {
1549
- const templateSet = new Set(templateSkills);
1550
- if (manifestSkills.length === 0) return installedSkills.filter((skill) => !templateSet.has(skill));
1551
- const manifestSet = new Set(manifestSkills);
1552
- return installedSkills.filter((skill) => !manifestSet.has(skill) && !templateSet.has(skill));
2219
+ //#region src/skills.ts
2220
+ async function runSkillsAdd(projectDir, agents) {
2221
+ const args = agents.length === 0 ? [
2222
+ "skills",
2223
+ "add",
2224
+ "buiducnhat/agent-skills",
2225
+ "--skill",
2226
+ "*",
2227
+ "--all",
2228
+ "-y"
2229
+ ] : [
2230
+ "skills",
2231
+ "add",
2232
+ "buiducnhat/agent-skills",
2233
+ "--skill",
2234
+ "*",
2235
+ ...agents.flatMap((a) => ["-a", a]),
2236
+ "-y"
2237
+ ];
2238
+ return new Promise((resolve) => {
2239
+ const child = spawn("npx", args, {
2240
+ cwd: projectDir,
2241
+ stdio: "inherit"
2242
+ });
2243
+ child.on("close", (code) => {
2244
+ resolve({ success: code === 0 });
2245
+ });
2246
+ child.on("error", () => {
2247
+ resolve({ success: false });
2248
+ });
2249
+ });
1553
2250
  }
1554
2251
 
1555
2252
  //#endregion
@@ -1561,9 +2258,6 @@ function parseArgs(argv) {
1561
2258
  version: false
1562
2259
  };
1563
2260
  for (let i = 0; i < argv.length; i++) switch (argv[i]) {
1564
- case "--agents":
1565
- args.agents = argv[++i];
1566
- break;
1567
2261
  case "--non-interactive":
1568
2262
  args.nonInteractive = true;
1569
2263
  break;
@@ -1576,243 +2270,68 @@ function parseArgs(argv) {
1576
2270
  args.version = true;
1577
2271
  break;
1578
2272
  }
1579
- if (args.agents) args.nonInteractive = true;
1580
2273
  return args;
1581
2274
  }
1582
- function copyDirectory(src, dest) {
1583
- fs.mkdirSync(dest, { recursive: true });
1584
- const entries = fs.readdirSync(src, { withFileTypes: true });
1585
- for (const entry of entries) {
1586
- const srcPath = path.join(src, entry.name);
1587
- const destPath = path.join(dest, entry.name);
1588
- if (entry.isDirectory()) copyDirectory(srcPath, destPath);
1589
- else fs.copyFileSync(srcPath, destPath);
2275
+ function detectAgentsFromFilesystem(projectDir) {
2276
+ const detected = [];
2277
+ for (const [dirPrefix, agentId] of Object.entries(AGENT_SKILLS_DIRS)) {
2278
+ const skillsDir = path.join(projectDir, dirPrefix, "skills");
2279
+ if (fs.existsSync(skillsDir)) detected.push(agentId);
1590
2280
  }
2281
+ return detected;
1591
2282
  }
1592
- function getAgentOutputSkillsDir(projectDir, agent) {
1593
- return path.join(projectDir, `.${agent}`, "skills");
1594
- }
1595
- function preserveCustomSkills(tempDir, projectDir, agents) {
1596
- const templateSkills = new Set(getTemplateSkillNames(tempDir));
1597
- const manifestSkills = new Set(readManifest(projectDir)?.skills ?? []);
1598
- const backupDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-skills-custom-skills-"));
1599
- const entries = [];
1600
- for (const agent of agents) {
1601
- const skillsDir = getAgentOutputSkillsDir(projectDir, agent);
1602
- if (!fs.existsSync(skillsDir)) continue;
1603
- const customSkills = fs.readdirSync(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).filter((skill) => !templateSkills.has(skill) && !manifestSkills.has(skill));
1604
- for (const skill of customSkills) {
1605
- const srcSkillDir = path.join(skillsDir, skill);
1606
- const destSkillDir = path.join(backupDir, agent, skill);
1607
- try {
1608
- copyDirectory(srcSkillDir, destSkillDir);
1609
- entries.push({
1610
- agent,
1611
- skill
1612
- });
1613
- } catch (err) {
1614
- const message = err instanceof Error ? err.message : String(err);
1615
- M.warn(`Failed to back up custom skill "${skill}" for agent "${agent}": ${message}`);
1616
- }
1617
- }
1618
- }
1619
- if (entries.length === 0) {
1620
- fs.rmSync(backupDir, {
1621
- recursive: true,
1622
- force: true
1623
- });
1624
- return null;
1625
- }
1626
- M.info(`Backed up ${entries.length} custom skill(s) from agent output directories`);
1627
- return {
1628
- backupDir,
1629
- entries
1630
- };
1631
- }
1632
- function restoreCustomSkills(preserved, projectDir) {
1633
- if (!preserved) return;
1634
- let restored = 0;
1635
- for (const entry of preserved.entries) {
1636
- const destSkillsDir = getAgentOutputSkillsDir(projectDir, entry.agent);
1637
- const srcSkillDir = path.join(preserved.backupDir, entry.agent, entry.skill);
1638
- const destSkillDir = path.join(destSkillsDir, entry.skill);
1639
- try {
1640
- if (!fs.existsSync(srcSkillDir)) continue;
1641
- fs.mkdirSync(destSkillsDir, { recursive: true });
1642
- fs.rmSync(destSkillDir, {
1643
- recursive: true,
1644
- force: true
1645
- });
1646
- copyDirectory(srcSkillDir, destSkillDir);
1647
- restored++;
1648
- } catch (err) {
1649
- const message = err instanceof Error ? err.message : String(err);
1650
- M.warn(`Failed to restore custom skill "${entry.skill}" for agent "${entry.agent}": ${message}`);
1651
- }
1652
- }
1653
- fs.rmSync(preserved.backupDir, {
1654
- recursive: true,
1655
- force: true
1656
- });
1657
- M.info(`Restored ${restored}/${preserved.entries.length} custom skill(s) to agent output directories`);
1658
- }
1659
- function copyDirectoryExcluding(src, dest, excludeNames) {
2283
+ function copyDirectory(src, dest) {
1660
2284
  fs.mkdirSync(dest, { recursive: true });
1661
2285
  const entries = fs.readdirSync(src, { withFileTypes: true });
1662
2286
  for (const entry of entries) {
1663
- if (excludeNames.has(entry.name)) continue;
1664
2287
  const srcPath = path.join(src, entry.name);
1665
2288
  const destPath = path.join(dest, entry.name);
1666
2289
  if (entry.isDirectory()) copyDirectory(srcPath, destPath);
1667
2290
  else fs.copyFileSync(srcPath, destPath);
1668
2291
  }
1669
2292
  }
1670
- async function copyTemplates(tempDir, projectDir, action) {
1671
- const s = Y();
1672
- s.start("Copying templates to your project...");
1673
- const templatesDir = path.join(tempDir, "templates");
1674
- const srcRuler = path.join(templatesDir, ".ruler");
1675
- const srcClaude = path.join(templatesDir, ".claude");
1676
- const destRuler = path.join(projectDir, ".ruler");
2293
+ function copyClaudeTemplate(tempDir, projectDir) {
2294
+ const srcClaude = path.join(tempDir, "templates", ".claude");
1677
2295
  const destClaude = path.join(projectDir, ".claude");
1678
- const templateSkills = getTemplateSkillNames(tempDir);
1679
- const existingManifest = readManifest(projectDir);
1680
- const manifestSkills = existingManifest?.skills ?? [];
1681
- const installedSkills = getInstalledSkillNames(projectDir);
1682
- const deprecatedSkills = computeDeprecatedSkills(existingManifest, templateSkills);
1683
- const customSkills = computeCustomSkills(installedSkills, manifestSkills, templateSkills);
1684
- if (deprecatedSkills.length > 0) {
1685
- for (const skill of deprecatedSkills) {
1686
- const skillPath = path.join(destRuler, "skills", skill);
1687
- if (fs.existsSync(skillPath)) fs.rmSync(skillPath, {
1688
- recursive: true,
1689
- force: true
1690
- });
1691
- }
1692
- M.info(`Removing ${deprecatedSkills.length} deprecated library skill(s): ${deprecatedSkills.join(", ")}`);
1693
- }
1694
- if (action === "fresh") {
1695
- let rulerBackup;
1696
- let claudeBackup;
1697
- if (fs.existsSync(destRuler)) {
1698
- rulerBackup = `${destRuler}.backup-${Date.now()}`;
1699
- fs.renameSync(destRuler, rulerBackup);
1700
- M.info(`Backed up existing .ruler/ to ${path.basename(rulerBackup)}`);
1701
- }
1702
- if (fs.existsSync(destClaude)) {
1703
- claudeBackup = `${destClaude}.backup-${Date.now()}`;
1704
- fs.renameSync(destClaude, claudeBackup);
1705
- M.info(`Backed up existing .claude/ to ${path.basename(claudeBackup)}`);
1706
- }
1707
- if (fs.existsSync(srcRuler)) copyDirectory(srcRuler, destRuler);
1708
- if (rulerBackup && customSkills.length > 0) {
1709
- for (const skill of customSkills) {
1710
- const srcSkill = path.join(rulerBackup, "skills", skill);
1711
- const destSkill = path.join(destRuler, "skills", skill);
1712
- if (fs.existsSync(srcSkill)) copyDirectory(srcSkill, destSkill);
1713
- }
1714
- M.info(`Preserving ${customSkills.length} custom skill(s): ${customSkills.join(", ")}`);
1715
- }
1716
- if (fs.existsSync(srcClaude)) copyDirectory(srcClaude, destClaude);
1717
- } else {
1718
- if (!fs.existsSync(destRuler)) {
1719
- if (fs.existsSync(srcRuler)) copyDirectory(srcRuler, destRuler);
1720
- if (fs.existsSync(srcClaude)) copyDirectory(srcClaude, destClaude);
1721
- if (templateSkills.length > 0) writeManifest(projectDir, templateSkills);
1722
- makeScriptsExecutable(path.join(destRuler, "scripts"));
1723
- s.stop("Copied templates to project");
1724
- return;
1725
- }
1726
- if (fs.existsSync(srcRuler)) {
1727
- copyDirectoryExcluding(srcRuler, destRuler, new Set(["skills"]));
1728
- const srcSkillsDir = path.join(srcRuler, "skills");
1729
- const destSkillsDir = path.join(destRuler, "skills");
1730
- if (fs.existsSync(srcSkillsDir)) {
1731
- fs.mkdirSync(destSkillsDir, { recursive: true });
1732
- for (const skill of templateSkills) {
1733
- const srcSkill = path.join(srcSkillsDir, skill);
1734
- const destSkill = path.join(destSkillsDir, skill);
1735
- if (fs.existsSync(srcSkill)) copyDirectory(srcSkill, destSkill);
1736
- }
1737
- }
1738
- }
1739
- if (customSkills.length > 0) M.info(`Preserving ${customSkills.length} custom skill(s): ${customSkills.join(", ")}`);
1740
- if (fs.existsSync(srcClaude)) copyDirectory(srcClaude, destClaude);
2296
+ if (!fs.existsSync(srcClaude)) return;
2297
+ fs.mkdirSync(destClaude, { recursive: true });
2298
+ for (const entry of fs.readdirSync(srcClaude, { withFileTypes: true })) {
2299
+ if (entry.name === "skills") continue;
2300
+ const src = path.join(srcClaude, entry.name);
2301
+ const dest = path.join(destClaude, entry.name);
2302
+ if (entry.isDirectory()) copyDirectory(src, dest);
2303
+ else fs.copyFileSync(src, dest);
1741
2304
  }
1742
- if (templateSkills.length > 0) writeManifest(projectDir, templateSkills);
1743
- makeScriptsExecutable(path.join(destRuler, "scripts"));
1744
- s.stop("Copied templates to project");
1745
- }
1746
- function ensureRulerScripts(tempDir, projectDir) {
1747
- const srcScripts = path.join(tempDir, "templates", ".ruler", "scripts");
1748
- const destScripts = path.join(projectDir, ".ruler", "scripts");
1749
- if (!fs.existsSync(srcScripts)) return;
1750
- copyDirectory(srcScripts, destScripts);
1751
- makeScriptsExecutable(destScripts);
1752
- }
1753
- function makeScriptsExecutable(scriptsDir) {
1754
- if (!fs.existsSync(scriptsDir)) return;
1755
- for (const script of fs.readdirSync(scriptsDir).filter((fileName) => fileName.endsWith(".sh"))) fs.chmodSync(path.join(scriptsDir, script), 493);
1756
2305
  }
1757
2306
  function printHelp() {
1758
2307
  console.log(`
1759
- @buiducnhat/agent-skills - Install AI agent skills for coding assistants
2308
+ @buiducnhat/agent-skills - Install AI agent workflow skills for coding assistants
1760
2309
 
1761
2310
  Usage: npx @buiducnhat/agent-skills [options]
1762
2311
 
1763
2312
  Options:
1764
- --agents <list> Comma-separated agent IDs (e.g., claude,cursor,copilot)
1765
- --non-interactive Skip all prompts, use defaults
2313
+ --non-interactive Skip interactive prompts (installs all skills to all agents)
1766
2314
  -h, --help Show this help message
1767
2315
  -v, --version Show version
1768
2316
 
1769
2317
  Examples:
1770
2318
  npx @buiducnhat/agent-skills
1771
- npx @buiducnhat/agent-skills --agents claude,cursor
1772
- npx @buiducnhat/agent-skills --agents claude --non-interactive
1773
-
1774
- Supported agents:
1775
- claude, copilot, cursor, windsurf, codex, gemini-cli, amp, cline, roo,
1776
- aider, antigravity, pi, jules, kiro, kilocode, crush, amazonqcli,
1777
- firebase, openhands, junie, jetbrains-ai, augmentcode, opencode,
1778
- goose, qwen, zed, trae, warp, firebender, factory, mistral
2319
+ npx @buiducnhat/agent-skills --non-interactive
1779
2320
  `);
1780
2321
  }
1781
- function printSummary(agents, projectDir) {
1782
- M.success("Installation complete!");
1783
- M.message("");
1784
- M.message("What was set up:");
1785
- M.message(` .claude/ - Claude vibe coding settings`);
1786
- M.message(` .ruler/AGENTS.md - Agent instructions`);
1787
- M.message(` .ruler/ruler.toml - Ruler config (agents: ${agents.join(", ")})`);
1788
- const counts = countSkillsByType(projectDir);
1789
- if (counts.custom > 0) M.message(` .ruler/skills/ - ${counts.library} library + ${counts.custom} custom skill(s)`);
1790
- else M.message(` .ruler/skills/ - ${counts.library} workflow skills`);
1791
- M.message("");
1792
- M.message("Agent configurations generated for:");
1793
- for (const agent of agents) M.message(` - ${agent}`);
1794
- M.message("");
1795
- M.message("Next steps:");
1796
- M.message(" 1. Review .ruler/AGENTS.md for agent instructions");
1797
- M.message(" 2. Customize .ruler/ruler.toml if needed");
1798
- M.message(" 3. Commit the generated files to your repository");
1799
- }
1800
- function countSkillsByType(projectDir) {
1801
- const skillsDir = path.join(projectDir, ".ruler", "skills");
1802
- if (!fs.existsSync(skillsDir)) return {
1803
- library: 0,
1804
- custom: 0,
1805
- total: 0
1806
- };
1807
- const manifest = readManifest(projectDir);
1808
- const manifestSkills = new Set(manifest?.skills ?? []);
1809
- const allSkills = fs.readdirSync(skillsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
1810
- const library = allSkills.filter((s) => manifestSkills.has(s)).length;
1811
- return {
1812
- library,
1813
- custom: allSkills.length - library,
1814
- total: allSkills.length
1815
- };
2322
+ function printSummary(agents, results) {
2323
+ R.success("Installation complete!");
2324
+ R.message("");
2325
+ R.message("What was set up:");
2326
+ R.message(" .claude/ - Claude Code settings");
2327
+ for (const result of results) if (result.action !== "skipped") R.message(` ${result.rulesFile} - ${result.action}`);
2328
+ R.message("");
2329
+ R.message("Agent configurations updated for:");
2330
+ for (const agent of agents) R.message(` - ${agent}`);
2331
+ R.message("");
2332
+ R.message("Next steps:");
2333
+ R.message(" 1. Review the updated agent rules files");
2334
+ R.message(" 2. Commit the generated files to your repository");
1816
2335
  }
1817
2336
 
1818
2337
  //#endregion
@@ -1835,41 +2354,59 @@ async function main() {
1835
2354
  console.log(getCliVersion());
1836
2355
  process.exit(0);
1837
2356
  }
1838
- Ie(import_picocolors.default.bold(import_picocolors.default.cyan(" Agent Skills Installer ")));
2357
+ We(import_picocolors.default.bold(import_picocolors.default.cyan(" Agent Skills Installer ")));
1839
2358
  const cwd = process.cwd();
1840
- const rulerDir = path.join(cwd, ".ruler");
1841
- const existingInstall = fs.existsSync(rulerDir);
1842
- let action = "fresh";
1843
- if (existingInstall) if (args.nonInteractive) {
1844
- action = "update";
1845
- M.info("Existing .ruler/ found, updating...");
1846
- } else action = await promptExistingAction();
1847
2359
  let selectedAgents;
1848
- if (args.agents) {
1849
- selectedAgents = args.agents.split(",").map((a) => a.trim());
1850
- M.info(`Using agents: ${selectedAgents.join(", ")}`);
1851
- } else if (args.nonInteractive) {
1852
- selectedAgents = ["claude"];
1853
- M.info("Using default agent: claude");
1854
- } else selectedAgents = await promptAgentSelection();
1855
- if (selectedAgents.length === 0) {
1856
- xe("No agents selected.");
1857
- process.exit(1);
2360
+ if (args.nonInteractive) {
2361
+ R.step("Installing skills to all agents (non-interactive)...");
2362
+ if (!(await runSkillsAdd(cwd, [])).success) {
2363
+ Ne(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' --all -y"));
2364
+ process.exit(1);
2365
+ }
2366
+ selectedAgents = detectAgentsFromFilesystem(cwd);
2367
+ if (selectedAgents.length === 0) {
2368
+ R.warn("No agents detected from filesystem. Skills may have been installed but rules injection was skipped.");
2369
+ Le(import_picocolors.default.yellow("Done. No agent rules files were updated."));
2370
+ process.exit(0);
2371
+ }
2372
+ } else {
2373
+ const preSelected = detectAgentsFromFilesystem(cwd);
2374
+ const selection = await je({
2375
+ message: "Select agents to install skills for:",
2376
+ options: SUPPORTED_AGENTS.map((a) => ({
2377
+ value: a.id,
2378
+ label: a.name
2379
+ })),
2380
+ initialValues: preSelected,
2381
+ required: false
2382
+ });
2383
+ if (Ct$1(selection)) {
2384
+ Ne("Installation cancelled.");
2385
+ process.exit(0);
2386
+ }
2387
+ selectedAgents = selection;
2388
+ if (selectedAgents.length === 0) {
2389
+ Le(import_picocolors.default.yellow("No agents selected. Nothing to install."));
2390
+ process.exit(0);
2391
+ }
2392
+ R.step("Installing skills via skills CLI...");
2393
+ if (!(await runSkillsAdd(cwd, selectedAgents)).success) {
2394
+ Ne(import_picocolors.default.red("Skills CLI failed. See errors above.\nYou can try running manually: npx skills add buiducnhat/agent-skills --skill '*' -a <agent> -y"));
2395
+ process.exit(1);
2396
+ }
1858
2397
  }
2398
+ R.info(`Configuring agents: ${selectedAgents.join(", ")}`);
1859
2399
  let tempDir;
1860
2400
  try {
1861
2401
  tempDir = await fetchTemplates();
1862
- await copyTemplates(tempDir, cwd, action);
1863
- configureRulerToml(cwd, selectedAgents);
1864
- const preserved = preserveCustomSkills(tempDir, cwd, selectedAgents);
1865
- await runRulerApply(cwd, selectedAgents);
1866
- restoreCustomSkills(preserved, cwd);
1867
- ensureRulerScripts(tempDir, cwd);
1868
- printSummary(selectedAgents, cwd);
1869
- Se(import_picocolors.default.green("Done! Your AI agent skills are ready."));
2402
+ const agentsContent = fs.readFileSync(path.join(tempDir, "templates", "AGENTS.md"), "utf-8");
2403
+ const results = injectRules(cwd, selectedAgents, agentsContent);
2404
+ copyClaudeTemplate(tempDir, cwd);
2405
+ printSummary(selectedAgents, results);
2406
+ Le(import_picocolors.default.green("Done! Your AI agent skills are ready."));
1870
2407
  } catch (err) {
1871
2408
  const message = err instanceof Error ? err.message : String(err);
1872
- xe(import_picocolors.default.red(`Error: ${message}`));
2409
+ Ne(import_picocolors.default.red(`Error: ${message}`));
1873
2410
  process.exit(1);
1874
2411
  } finally {
1875
2412
  if (tempDir) cleanupTemp(tempDir);