adograb 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/dist/index.js +3976 -0
  4. package/package.json +53 -0
package/dist/index.js ADDED
@@ -0,0 +1,3976 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+
34
+ // node_modules/yoctocolors-cjs/index.js
35
+ var require_yoctocolors_cjs = __commonJS({
36
+ "node_modules/yoctocolors-cjs/index.js"(exports, module) {
37
+ "use strict";
38
+ var tty = __require("tty");
39
+ var hasColors = tty?.WriteStream?.prototype?.hasColors?.() ?? false;
40
+ var format = (open, close) => {
41
+ if (!hasColors) {
42
+ return (input2) => input2;
43
+ }
44
+ const openCode = `\x1B[${open}m`;
45
+ const closeCode = `\x1B[${close}m`;
46
+ return (input2) => {
47
+ const string = input2 + "";
48
+ let index = string.indexOf(closeCode);
49
+ if (index === -1) {
50
+ return openCode + string + closeCode;
51
+ }
52
+ let result = openCode;
53
+ let lastIndex = 0;
54
+ const reopenOnNestedClose = close === 22;
55
+ const replaceCode = (reopenOnNestedClose ? closeCode : "") + openCode;
56
+ while (index !== -1) {
57
+ result += string.slice(lastIndex, index) + replaceCode;
58
+ lastIndex = index + closeCode.length;
59
+ index = string.indexOf(closeCode, lastIndex);
60
+ }
61
+ result += string.slice(lastIndex) + closeCode;
62
+ return result;
63
+ };
64
+ };
65
+ var colors4 = {};
66
+ colors4.reset = format(0, 0);
67
+ colors4.bold = format(1, 22);
68
+ colors4.dim = format(2, 22);
69
+ colors4.italic = format(3, 23);
70
+ colors4.underline = format(4, 24);
71
+ colors4.overline = format(53, 55);
72
+ colors4.inverse = format(7, 27);
73
+ colors4.hidden = format(8, 28);
74
+ colors4.strikethrough = format(9, 29);
75
+ colors4.black = format(30, 39);
76
+ colors4.red = format(31, 39);
77
+ colors4.green = format(32, 39);
78
+ colors4.yellow = format(33, 39);
79
+ colors4.blue = format(34, 39);
80
+ colors4.magenta = format(35, 39);
81
+ colors4.cyan = format(36, 39);
82
+ colors4.white = format(37, 39);
83
+ colors4.gray = format(90, 39);
84
+ colors4.bgBlack = format(40, 49);
85
+ colors4.bgRed = format(41, 49);
86
+ colors4.bgGreen = format(42, 49);
87
+ colors4.bgYellow = format(43, 49);
88
+ colors4.bgBlue = format(44, 49);
89
+ colors4.bgMagenta = format(45, 49);
90
+ colors4.bgCyan = format(46, 49);
91
+ colors4.bgWhite = format(47, 49);
92
+ colors4.bgGray = format(100, 49);
93
+ colors4.redBright = format(91, 39);
94
+ colors4.greenBright = format(92, 39);
95
+ colors4.yellowBright = format(93, 39);
96
+ colors4.blueBright = format(94, 39);
97
+ colors4.magentaBright = format(95, 39);
98
+ colors4.cyanBright = format(96, 39);
99
+ colors4.whiteBright = format(97, 39);
100
+ colors4.bgRedBright = format(101, 49);
101
+ colors4.bgGreenBright = format(102, 49);
102
+ colors4.bgYellowBright = format(103, 49);
103
+ colors4.bgBlueBright = format(104, 49);
104
+ colors4.bgMagentaBright = format(105, 49);
105
+ colors4.bgCyanBright = format(106, 49);
106
+ colors4.bgWhiteBright = format(107, 49);
107
+ module.exports = colors4;
108
+ }
109
+ });
110
+
111
+ // node_modules/cli-width/index.js
112
+ var require_cli_width = __commonJS({
113
+ "node_modules/cli-width/index.js"(exports, module) {
114
+ "use strict";
115
+ module.exports = cliWidth2;
116
+ function normalizeOpts(options) {
117
+ const defaultOpts = {
118
+ defaultWidth: 0,
119
+ output: process.stdout,
120
+ tty: __require("tty")
121
+ };
122
+ if (!options) {
123
+ return defaultOpts;
124
+ }
125
+ Object.keys(defaultOpts).forEach(function(key) {
126
+ if (!options[key]) {
127
+ options[key] = defaultOpts[key];
128
+ }
129
+ });
130
+ return options;
131
+ }
132
+ function cliWidth2(options) {
133
+ const opts = normalizeOpts(options);
134
+ if (opts.output.getWindowSize) {
135
+ return opts.output.getWindowSize()[0] || opts.defaultWidth;
136
+ }
137
+ if (opts.tty.getWindowSize) {
138
+ return opts.tty.getWindowSize()[1] || opts.defaultWidth;
139
+ }
140
+ if (opts.output.columns) {
141
+ return opts.output.columns;
142
+ }
143
+ if (process.env.CLI_WIDTH) {
144
+ const width = parseInt(process.env.CLI_WIDTH, 10);
145
+ if (!isNaN(width) && width !== 0) {
146
+ return width;
147
+ }
148
+ }
149
+ return opts.defaultWidth;
150
+ }
151
+ }
152
+ });
153
+
154
+ // node_modules/ansi-regex/index.js
155
+ var require_ansi_regex = __commonJS({
156
+ "node_modules/ansi-regex/index.js"(exports, module) {
157
+ "use strict";
158
+ module.exports = ({ onlyFirst = false } = {}) => {
159
+ const pattern = [
160
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
161
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
162
+ ].join("|");
163
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
164
+ };
165
+ }
166
+ });
167
+
168
+ // node_modules/strip-ansi/index.js
169
+ var require_strip_ansi = __commonJS({
170
+ "node_modules/strip-ansi/index.js"(exports, module) {
171
+ "use strict";
172
+ var ansiRegex = require_ansi_regex();
173
+ module.exports = (string) => typeof string === "string" ? string.replace(ansiRegex(), "") : string;
174
+ }
175
+ });
176
+
177
+ // node_modules/is-fullwidth-code-point/index.js
178
+ var require_is_fullwidth_code_point = __commonJS({
179
+ "node_modules/is-fullwidth-code-point/index.js"(exports, module) {
180
+ "use strict";
181
+ var isFullwidthCodePoint = (codePoint) => {
182
+ if (Number.isNaN(codePoint)) {
183
+ return false;
184
+ }
185
+ if (codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo
186
+ codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET
187
+ codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET
188
+ // CJK Radicals Supplement .. Enclosed CJK Letters and Months
189
+ 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
190
+ 12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals
191
+ 19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A
192
+ 43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables
193
+ 44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs
194
+ 63744 <= codePoint && codePoint <= 64255 || // Vertical Forms
195
+ 65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants
196
+ 65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms
197
+ 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement
198
+ 110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement
199
+ 127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
200
+ 131072 <= codePoint && codePoint <= 262141)) {
201
+ return true;
202
+ }
203
+ return false;
204
+ };
205
+ module.exports = isFullwidthCodePoint;
206
+ module.exports.default = isFullwidthCodePoint;
207
+ }
208
+ });
209
+
210
+ // node_modules/emoji-regex/index.js
211
+ var require_emoji_regex = __commonJS({
212
+ "node_modules/emoji-regex/index.js"(exports, module) {
213
+ "use strict";
214
+ module.exports = function() {
215
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\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\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])|\uD83C[\uDF3E\uDF73\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])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\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])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\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\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\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\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\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\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*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\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\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\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[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
216
+ };
217
+ }
218
+ });
219
+
220
+ // node_modules/string-width/index.js
221
+ var require_string_width = __commonJS({
222
+ "node_modules/string-width/index.js"(exports, module) {
223
+ "use strict";
224
+ var stripAnsi = require_strip_ansi();
225
+ var isFullwidthCodePoint = require_is_fullwidth_code_point();
226
+ var emojiRegex = require_emoji_regex();
227
+ var stringWidth = (string) => {
228
+ if (typeof string !== "string" || string.length === 0) {
229
+ return 0;
230
+ }
231
+ string = stripAnsi(string);
232
+ if (string.length === 0) {
233
+ return 0;
234
+ }
235
+ string = string.replace(emojiRegex(), " ");
236
+ let width = 0;
237
+ for (let i = 0; i < string.length; i++) {
238
+ const code = string.codePointAt(i);
239
+ if (code <= 31 || code >= 127 && code <= 159) {
240
+ continue;
241
+ }
242
+ if (code >= 768 && code <= 879) {
243
+ continue;
244
+ }
245
+ if (code > 65535) {
246
+ i++;
247
+ }
248
+ width += isFullwidthCodePoint(code) ? 2 : 1;
249
+ }
250
+ return width;
251
+ };
252
+ module.exports = stringWidth;
253
+ module.exports.default = stringWidth;
254
+ }
255
+ });
256
+
257
+ // node_modules/color-name/index.js
258
+ var require_color_name = __commonJS({
259
+ "node_modules/color-name/index.js"(exports, module) {
260
+ "use strict";
261
+ module.exports = {
262
+ "aliceblue": [240, 248, 255],
263
+ "antiquewhite": [250, 235, 215],
264
+ "aqua": [0, 255, 255],
265
+ "aquamarine": [127, 255, 212],
266
+ "azure": [240, 255, 255],
267
+ "beige": [245, 245, 220],
268
+ "bisque": [255, 228, 196],
269
+ "black": [0, 0, 0],
270
+ "blanchedalmond": [255, 235, 205],
271
+ "blue": [0, 0, 255],
272
+ "blueviolet": [138, 43, 226],
273
+ "brown": [165, 42, 42],
274
+ "burlywood": [222, 184, 135],
275
+ "cadetblue": [95, 158, 160],
276
+ "chartreuse": [127, 255, 0],
277
+ "chocolate": [210, 105, 30],
278
+ "coral": [255, 127, 80],
279
+ "cornflowerblue": [100, 149, 237],
280
+ "cornsilk": [255, 248, 220],
281
+ "crimson": [220, 20, 60],
282
+ "cyan": [0, 255, 255],
283
+ "darkblue": [0, 0, 139],
284
+ "darkcyan": [0, 139, 139],
285
+ "darkgoldenrod": [184, 134, 11],
286
+ "darkgray": [169, 169, 169],
287
+ "darkgreen": [0, 100, 0],
288
+ "darkgrey": [169, 169, 169],
289
+ "darkkhaki": [189, 183, 107],
290
+ "darkmagenta": [139, 0, 139],
291
+ "darkolivegreen": [85, 107, 47],
292
+ "darkorange": [255, 140, 0],
293
+ "darkorchid": [153, 50, 204],
294
+ "darkred": [139, 0, 0],
295
+ "darksalmon": [233, 150, 122],
296
+ "darkseagreen": [143, 188, 143],
297
+ "darkslateblue": [72, 61, 139],
298
+ "darkslategray": [47, 79, 79],
299
+ "darkslategrey": [47, 79, 79],
300
+ "darkturquoise": [0, 206, 209],
301
+ "darkviolet": [148, 0, 211],
302
+ "deeppink": [255, 20, 147],
303
+ "deepskyblue": [0, 191, 255],
304
+ "dimgray": [105, 105, 105],
305
+ "dimgrey": [105, 105, 105],
306
+ "dodgerblue": [30, 144, 255],
307
+ "firebrick": [178, 34, 34],
308
+ "floralwhite": [255, 250, 240],
309
+ "forestgreen": [34, 139, 34],
310
+ "fuchsia": [255, 0, 255],
311
+ "gainsboro": [220, 220, 220],
312
+ "ghostwhite": [248, 248, 255],
313
+ "gold": [255, 215, 0],
314
+ "goldenrod": [218, 165, 32],
315
+ "gray": [128, 128, 128],
316
+ "green": [0, 128, 0],
317
+ "greenyellow": [173, 255, 47],
318
+ "grey": [128, 128, 128],
319
+ "honeydew": [240, 255, 240],
320
+ "hotpink": [255, 105, 180],
321
+ "indianred": [205, 92, 92],
322
+ "indigo": [75, 0, 130],
323
+ "ivory": [255, 255, 240],
324
+ "khaki": [240, 230, 140],
325
+ "lavender": [230, 230, 250],
326
+ "lavenderblush": [255, 240, 245],
327
+ "lawngreen": [124, 252, 0],
328
+ "lemonchiffon": [255, 250, 205],
329
+ "lightblue": [173, 216, 230],
330
+ "lightcoral": [240, 128, 128],
331
+ "lightcyan": [224, 255, 255],
332
+ "lightgoldenrodyellow": [250, 250, 210],
333
+ "lightgray": [211, 211, 211],
334
+ "lightgreen": [144, 238, 144],
335
+ "lightgrey": [211, 211, 211],
336
+ "lightpink": [255, 182, 193],
337
+ "lightsalmon": [255, 160, 122],
338
+ "lightseagreen": [32, 178, 170],
339
+ "lightskyblue": [135, 206, 250],
340
+ "lightslategray": [119, 136, 153],
341
+ "lightslategrey": [119, 136, 153],
342
+ "lightsteelblue": [176, 196, 222],
343
+ "lightyellow": [255, 255, 224],
344
+ "lime": [0, 255, 0],
345
+ "limegreen": [50, 205, 50],
346
+ "linen": [250, 240, 230],
347
+ "magenta": [255, 0, 255],
348
+ "maroon": [128, 0, 0],
349
+ "mediumaquamarine": [102, 205, 170],
350
+ "mediumblue": [0, 0, 205],
351
+ "mediumorchid": [186, 85, 211],
352
+ "mediumpurple": [147, 112, 219],
353
+ "mediumseagreen": [60, 179, 113],
354
+ "mediumslateblue": [123, 104, 238],
355
+ "mediumspringgreen": [0, 250, 154],
356
+ "mediumturquoise": [72, 209, 204],
357
+ "mediumvioletred": [199, 21, 133],
358
+ "midnightblue": [25, 25, 112],
359
+ "mintcream": [245, 255, 250],
360
+ "mistyrose": [255, 228, 225],
361
+ "moccasin": [255, 228, 181],
362
+ "navajowhite": [255, 222, 173],
363
+ "navy": [0, 0, 128],
364
+ "oldlace": [253, 245, 230],
365
+ "olive": [128, 128, 0],
366
+ "olivedrab": [107, 142, 35],
367
+ "orange": [255, 165, 0],
368
+ "orangered": [255, 69, 0],
369
+ "orchid": [218, 112, 214],
370
+ "palegoldenrod": [238, 232, 170],
371
+ "palegreen": [152, 251, 152],
372
+ "paleturquoise": [175, 238, 238],
373
+ "palevioletred": [219, 112, 147],
374
+ "papayawhip": [255, 239, 213],
375
+ "peachpuff": [255, 218, 185],
376
+ "peru": [205, 133, 63],
377
+ "pink": [255, 192, 203],
378
+ "plum": [221, 160, 221],
379
+ "powderblue": [176, 224, 230],
380
+ "purple": [128, 0, 128],
381
+ "rebeccapurple": [102, 51, 153],
382
+ "red": [255, 0, 0],
383
+ "rosybrown": [188, 143, 143],
384
+ "royalblue": [65, 105, 225],
385
+ "saddlebrown": [139, 69, 19],
386
+ "salmon": [250, 128, 114],
387
+ "sandybrown": [244, 164, 96],
388
+ "seagreen": [46, 139, 87],
389
+ "seashell": [255, 245, 238],
390
+ "sienna": [160, 82, 45],
391
+ "silver": [192, 192, 192],
392
+ "skyblue": [135, 206, 235],
393
+ "slateblue": [106, 90, 205],
394
+ "slategray": [112, 128, 144],
395
+ "slategrey": [112, 128, 144],
396
+ "snow": [255, 250, 250],
397
+ "springgreen": [0, 255, 127],
398
+ "steelblue": [70, 130, 180],
399
+ "tan": [210, 180, 140],
400
+ "teal": [0, 128, 128],
401
+ "thistle": [216, 191, 216],
402
+ "tomato": [255, 99, 71],
403
+ "turquoise": [64, 224, 208],
404
+ "violet": [238, 130, 238],
405
+ "wheat": [245, 222, 179],
406
+ "white": [255, 255, 255],
407
+ "whitesmoke": [245, 245, 245],
408
+ "yellow": [255, 255, 0],
409
+ "yellowgreen": [154, 205, 50]
410
+ };
411
+ }
412
+ });
413
+
414
+ // node_modules/color-convert/conversions.js
415
+ var require_conversions = __commonJS({
416
+ "node_modules/color-convert/conversions.js"(exports, module) {
417
+ "use strict";
418
+ var cssKeywords = require_color_name();
419
+ var reverseKeywords = {};
420
+ for (const key of Object.keys(cssKeywords)) {
421
+ reverseKeywords[cssKeywords[key]] = key;
422
+ }
423
+ var convert = {
424
+ rgb: { channels: 3, labels: "rgb" },
425
+ hsl: { channels: 3, labels: "hsl" },
426
+ hsv: { channels: 3, labels: "hsv" },
427
+ hwb: { channels: 3, labels: "hwb" },
428
+ cmyk: { channels: 4, labels: "cmyk" },
429
+ xyz: { channels: 3, labels: "xyz" },
430
+ lab: { channels: 3, labels: "lab" },
431
+ lch: { channels: 3, labels: "lch" },
432
+ hex: { channels: 1, labels: ["hex"] },
433
+ keyword: { channels: 1, labels: ["keyword"] },
434
+ ansi16: { channels: 1, labels: ["ansi16"] },
435
+ ansi256: { channels: 1, labels: ["ansi256"] },
436
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
437
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
438
+ gray: { channels: 1, labels: ["gray"] }
439
+ };
440
+ module.exports = convert;
441
+ for (const model of Object.keys(convert)) {
442
+ if (!("channels" in convert[model])) {
443
+ throw new Error("missing channels property: " + model);
444
+ }
445
+ if (!("labels" in convert[model])) {
446
+ throw new Error("missing channel labels property: " + model);
447
+ }
448
+ if (convert[model].labels.length !== convert[model].channels) {
449
+ throw new Error("channel and label counts mismatch: " + model);
450
+ }
451
+ const { channels, labels } = convert[model];
452
+ delete convert[model].channels;
453
+ delete convert[model].labels;
454
+ Object.defineProperty(convert[model], "channels", { value: channels });
455
+ Object.defineProperty(convert[model], "labels", { value: labels });
456
+ }
457
+ convert.rgb.hsl = function(rgb) {
458
+ const r = rgb[0] / 255;
459
+ const g = rgb[1] / 255;
460
+ const b = rgb[2] / 255;
461
+ const min = Math.min(r, g, b);
462
+ const max = Math.max(r, g, b);
463
+ const delta = max - min;
464
+ let h;
465
+ let s;
466
+ if (max === min) {
467
+ h = 0;
468
+ } else if (r === max) {
469
+ h = (g - b) / delta;
470
+ } else if (g === max) {
471
+ h = 2 + (b - r) / delta;
472
+ } else if (b === max) {
473
+ h = 4 + (r - g) / delta;
474
+ }
475
+ h = Math.min(h * 60, 360);
476
+ if (h < 0) {
477
+ h += 360;
478
+ }
479
+ const l = (min + max) / 2;
480
+ if (max === min) {
481
+ s = 0;
482
+ } else if (l <= 0.5) {
483
+ s = delta / (max + min);
484
+ } else {
485
+ s = delta / (2 - max - min);
486
+ }
487
+ return [h, s * 100, l * 100];
488
+ };
489
+ convert.rgb.hsv = function(rgb) {
490
+ let rdif;
491
+ let gdif;
492
+ let bdif;
493
+ let h;
494
+ let s;
495
+ const r = rgb[0] / 255;
496
+ const g = rgb[1] / 255;
497
+ const b = rgb[2] / 255;
498
+ const v = Math.max(r, g, b);
499
+ const diff = v - Math.min(r, g, b);
500
+ const diffc = function(c) {
501
+ return (v - c) / 6 / diff + 1 / 2;
502
+ };
503
+ if (diff === 0) {
504
+ h = 0;
505
+ s = 0;
506
+ } else {
507
+ s = diff / v;
508
+ rdif = diffc(r);
509
+ gdif = diffc(g);
510
+ bdif = diffc(b);
511
+ if (r === v) {
512
+ h = bdif - gdif;
513
+ } else if (g === v) {
514
+ h = 1 / 3 + rdif - bdif;
515
+ } else if (b === v) {
516
+ h = 2 / 3 + gdif - rdif;
517
+ }
518
+ if (h < 0) {
519
+ h += 1;
520
+ } else if (h > 1) {
521
+ h -= 1;
522
+ }
523
+ }
524
+ return [
525
+ h * 360,
526
+ s * 100,
527
+ v * 100
528
+ ];
529
+ };
530
+ convert.rgb.hwb = function(rgb) {
531
+ const r = rgb[0];
532
+ const g = rgb[1];
533
+ let b = rgb[2];
534
+ const h = convert.rgb.hsl(rgb)[0];
535
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
536
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
537
+ return [h, w * 100, b * 100];
538
+ };
539
+ convert.rgb.cmyk = function(rgb) {
540
+ const r = rgb[0] / 255;
541
+ const g = rgb[1] / 255;
542
+ const b = rgb[2] / 255;
543
+ const k = Math.min(1 - r, 1 - g, 1 - b);
544
+ const c = (1 - r - k) / (1 - k) || 0;
545
+ const m = (1 - g - k) / (1 - k) || 0;
546
+ const y = (1 - b - k) / (1 - k) || 0;
547
+ return [c * 100, m * 100, y * 100, k * 100];
548
+ };
549
+ function comparativeDistance(x, y) {
550
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
551
+ }
552
+ convert.rgb.keyword = function(rgb) {
553
+ const reversed = reverseKeywords[rgb];
554
+ if (reversed) {
555
+ return reversed;
556
+ }
557
+ let currentClosestDistance = Infinity;
558
+ let currentClosestKeyword;
559
+ for (const keyword of Object.keys(cssKeywords)) {
560
+ const value = cssKeywords[keyword];
561
+ const distance = comparativeDistance(rgb, value);
562
+ if (distance < currentClosestDistance) {
563
+ currentClosestDistance = distance;
564
+ currentClosestKeyword = keyword;
565
+ }
566
+ }
567
+ return currentClosestKeyword;
568
+ };
569
+ convert.keyword.rgb = function(keyword) {
570
+ return cssKeywords[keyword];
571
+ };
572
+ convert.rgb.xyz = function(rgb) {
573
+ let r = rgb[0] / 255;
574
+ let g = rgb[1] / 255;
575
+ let b = rgb[2] / 255;
576
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
577
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
578
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
579
+ const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
580
+ const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
581
+ const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
582
+ return [x * 100, y * 100, z * 100];
583
+ };
584
+ convert.rgb.lab = function(rgb) {
585
+ const xyz = convert.rgb.xyz(rgb);
586
+ let x = xyz[0];
587
+ let y = xyz[1];
588
+ let z = xyz[2];
589
+ x /= 95.047;
590
+ y /= 100;
591
+ z /= 108.883;
592
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
593
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
594
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
595
+ const l = 116 * y - 16;
596
+ const a = 500 * (x - y);
597
+ const b = 200 * (y - z);
598
+ return [l, a, b];
599
+ };
600
+ convert.hsl.rgb = function(hsl) {
601
+ const h = hsl[0] / 360;
602
+ const s = hsl[1] / 100;
603
+ const l = hsl[2] / 100;
604
+ let t2;
605
+ let t3;
606
+ let val;
607
+ if (s === 0) {
608
+ val = l * 255;
609
+ return [val, val, val];
610
+ }
611
+ if (l < 0.5) {
612
+ t2 = l * (1 + s);
613
+ } else {
614
+ t2 = l + s - l * s;
615
+ }
616
+ const t1 = 2 * l - t2;
617
+ const rgb = [0, 0, 0];
618
+ for (let i = 0; i < 3; i++) {
619
+ t3 = h + 1 / 3 * -(i - 1);
620
+ if (t3 < 0) {
621
+ t3++;
622
+ }
623
+ if (t3 > 1) {
624
+ t3--;
625
+ }
626
+ if (6 * t3 < 1) {
627
+ val = t1 + (t2 - t1) * 6 * t3;
628
+ } else if (2 * t3 < 1) {
629
+ val = t2;
630
+ } else if (3 * t3 < 2) {
631
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
632
+ } else {
633
+ val = t1;
634
+ }
635
+ rgb[i] = val * 255;
636
+ }
637
+ return rgb;
638
+ };
639
+ convert.hsl.hsv = function(hsl) {
640
+ const h = hsl[0];
641
+ let s = hsl[1] / 100;
642
+ let l = hsl[2] / 100;
643
+ let smin = s;
644
+ const lmin = Math.max(l, 0.01);
645
+ l *= 2;
646
+ s *= l <= 1 ? l : 2 - l;
647
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
648
+ const v = (l + s) / 2;
649
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
650
+ return [h, sv * 100, v * 100];
651
+ };
652
+ convert.hsv.rgb = function(hsv) {
653
+ const h = hsv[0] / 60;
654
+ const s = hsv[1] / 100;
655
+ let v = hsv[2] / 100;
656
+ const hi = Math.floor(h) % 6;
657
+ const f = h - Math.floor(h);
658
+ const p = 255 * v * (1 - s);
659
+ const q = 255 * v * (1 - s * f);
660
+ const t = 255 * v * (1 - s * (1 - f));
661
+ v *= 255;
662
+ switch (hi) {
663
+ case 0:
664
+ return [v, t, p];
665
+ case 1:
666
+ return [q, v, p];
667
+ case 2:
668
+ return [p, v, t];
669
+ case 3:
670
+ return [p, q, v];
671
+ case 4:
672
+ return [t, p, v];
673
+ case 5:
674
+ return [v, p, q];
675
+ }
676
+ };
677
+ convert.hsv.hsl = function(hsv) {
678
+ const h = hsv[0];
679
+ const s = hsv[1] / 100;
680
+ const v = hsv[2] / 100;
681
+ const vmin = Math.max(v, 0.01);
682
+ let sl;
683
+ let l;
684
+ l = (2 - s) * v;
685
+ const lmin = (2 - s) * vmin;
686
+ sl = s * vmin;
687
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
688
+ sl = sl || 0;
689
+ l /= 2;
690
+ return [h, sl * 100, l * 100];
691
+ };
692
+ convert.hwb.rgb = function(hwb) {
693
+ const h = hwb[0] / 360;
694
+ let wh = hwb[1] / 100;
695
+ let bl = hwb[2] / 100;
696
+ const ratio = wh + bl;
697
+ let f;
698
+ if (ratio > 1) {
699
+ wh /= ratio;
700
+ bl /= ratio;
701
+ }
702
+ const i = Math.floor(6 * h);
703
+ const v = 1 - bl;
704
+ f = 6 * h - i;
705
+ if ((i & 1) !== 0) {
706
+ f = 1 - f;
707
+ }
708
+ const n = wh + f * (v - wh);
709
+ let r;
710
+ let g;
711
+ let b;
712
+ switch (i) {
713
+ default:
714
+ case 6:
715
+ case 0:
716
+ r = v;
717
+ g = n;
718
+ b = wh;
719
+ break;
720
+ case 1:
721
+ r = n;
722
+ g = v;
723
+ b = wh;
724
+ break;
725
+ case 2:
726
+ r = wh;
727
+ g = v;
728
+ b = n;
729
+ break;
730
+ case 3:
731
+ r = wh;
732
+ g = n;
733
+ b = v;
734
+ break;
735
+ case 4:
736
+ r = n;
737
+ g = wh;
738
+ b = v;
739
+ break;
740
+ case 5:
741
+ r = v;
742
+ g = wh;
743
+ b = n;
744
+ break;
745
+ }
746
+ return [r * 255, g * 255, b * 255];
747
+ };
748
+ convert.cmyk.rgb = function(cmyk) {
749
+ const c = cmyk[0] / 100;
750
+ const m = cmyk[1] / 100;
751
+ const y = cmyk[2] / 100;
752
+ const k = cmyk[3] / 100;
753
+ const r = 1 - Math.min(1, c * (1 - k) + k);
754
+ const g = 1 - Math.min(1, m * (1 - k) + k);
755
+ const b = 1 - Math.min(1, y * (1 - k) + k);
756
+ return [r * 255, g * 255, b * 255];
757
+ };
758
+ convert.xyz.rgb = function(xyz) {
759
+ const x = xyz[0] / 100;
760
+ const y = xyz[1] / 100;
761
+ const z = xyz[2] / 100;
762
+ let r;
763
+ let g;
764
+ let b;
765
+ r = x * 3.2406 + y * -1.5372 + z * -0.4986;
766
+ g = x * -0.9689 + y * 1.8758 + z * 0.0415;
767
+ b = x * 0.0557 + y * -0.204 + z * 1.057;
768
+ r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
769
+ g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
770
+ b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
771
+ r = Math.min(Math.max(0, r), 1);
772
+ g = Math.min(Math.max(0, g), 1);
773
+ b = Math.min(Math.max(0, b), 1);
774
+ return [r * 255, g * 255, b * 255];
775
+ };
776
+ convert.xyz.lab = function(xyz) {
777
+ let x = xyz[0];
778
+ let y = xyz[1];
779
+ let z = xyz[2];
780
+ x /= 95.047;
781
+ y /= 100;
782
+ z /= 108.883;
783
+ x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
784
+ y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
785
+ z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
786
+ const l = 116 * y - 16;
787
+ const a = 500 * (x - y);
788
+ const b = 200 * (y - z);
789
+ return [l, a, b];
790
+ };
791
+ convert.lab.xyz = function(lab) {
792
+ const l = lab[0];
793
+ const a = lab[1];
794
+ const b = lab[2];
795
+ let x;
796
+ let y;
797
+ let z;
798
+ y = (l + 16) / 116;
799
+ x = a / 500 + y;
800
+ z = y - b / 200;
801
+ const y2 = y ** 3;
802
+ const x2 = x ** 3;
803
+ const z2 = z ** 3;
804
+ y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
805
+ x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
806
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
807
+ x *= 95.047;
808
+ y *= 100;
809
+ z *= 108.883;
810
+ return [x, y, z];
811
+ };
812
+ convert.lab.lch = function(lab) {
813
+ const l = lab[0];
814
+ const a = lab[1];
815
+ const b = lab[2];
816
+ let h;
817
+ const hr = Math.atan2(b, a);
818
+ h = hr * 360 / 2 / Math.PI;
819
+ if (h < 0) {
820
+ h += 360;
821
+ }
822
+ const c = Math.sqrt(a * a + b * b);
823
+ return [l, c, h];
824
+ };
825
+ convert.lch.lab = function(lch) {
826
+ const l = lch[0];
827
+ const c = lch[1];
828
+ const h = lch[2];
829
+ const hr = h / 360 * 2 * Math.PI;
830
+ const a = c * Math.cos(hr);
831
+ const b = c * Math.sin(hr);
832
+ return [l, a, b];
833
+ };
834
+ convert.rgb.ansi16 = function(args, saturation = null) {
835
+ const [r, g, b] = args;
836
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
837
+ value = Math.round(value / 50);
838
+ if (value === 0) {
839
+ return 30;
840
+ }
841
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
842
+ if (value === 2) {
843
+ ansi += 60;
844
+ }
845
+ return ansi;
846
+ };
847
+ convert.hsv.ansi16 = function(args) {
848
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
849
+ };
850
+ convert.rgb.ansi256 = function(args) {
851
+ const r = args[0];
852
+ const g = args[1];
853
+ const b = args[2];
854
+ if (r === g && g === b) {
855
+ if (r < 8) {
856
+ return 16;
857
+ }
858
+ if (r > 248) {
859
+ return 231;
860
+ }
861
+ return Math.round((r - 8) / 247 * 24) + 232;
862
+ }
863
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
864
+ return ansi;
865
+ };
866
+ convert.ansi16.rgb = function(args) {
867
+ let color = args % 10;
868
+ if (color === 0 || color === 7) {
869
+ if (args > 50) {
870
+ color += 3.5;
871
+ }
872
+ color = color / 10.5 * 255;
873
+ return [color, color, color];
874
+ }
875
+ const mult = (~~(args > 50) + 1) * 0.5;
876
+ const r = (color & 1) * mult * 255;
877
+ const g = (color >> 1 & 1) * mult * 255;
878
+ const b = (color >> 2 & 1) * mult * 255;
879
+ return [r, g, b];
880
+ };
881
+ convert.ansi256.rgb = function(args) {
882
+ if (args >= 232) {
883
+ const c = (args - 232) * 10 + 8;
884
+ return [c, c, c];
885
+ }
886
+ args -= 16;
887
+ let rem;
888
+ const r = Math.floor(args / 36) / 5 * 255;
889
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
890
+ const b = rem % 6 / 5 * 255;
891
+ return [r, g, b];
892
+ };
893
+ convert.rgb.hex = function(args) {
894
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
895
+ const string = integer.toString(16).toUpperCase();
896
+ return "000000".substring(string.length) + string;
897
+ };
898
+ convert.hex.rgb = function(args) {
899
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
900
+ if (!match) {
901
+ return [0, 0, 0];
902
+ }
903
+ let colorString = match[0];
904
+ if (match[0].length === 3) {
905
+ colorString = colorString.split("").map((char) => {
906
+ return char + char;
907
+ }).join("");
908
+ }
909
+ const integer = parseInt(colorString, 16);
910
+ const r = integer >> 16 & 255;
911
+ const g = integer >> 8 & 255;
912
+ const b = integer & 255;
913
+ return [r, g, b];
914
+ };
915
+ convert.rgb.hcg = function(rgb) {
916
+ const r = rgb[0] / 255;
917
+ const g = rgb[1] / 255;
918
+ const b = rgb[2] / 255;
919
+ const max = Math.max(Math.max(r, g), b);
920
+ const min = Math.min(Math.min(r, g), b);
921
+ const chroma = max - min;
922
+ let grayscale;
923
+ let hue;
924
+ if (chroma < 1) {
925
+ grayscale = min / (1 - chroma);
926
+ } else {
927
+ grayscale = 0;
928
+ }
929
+ if (chroma <= 0) {
930
+ hue = 0;
931
+ } else if (max === r) {
932
+ hue = (g - b) / chroma % 6;
933
+ } else if (max === g) {
934
+ hue = 2 + (b - r) / chroma;
935
+ } else {
936
+ hue = 4 + (r - g) / chroma;
937
+ }
938
+ hue /= 6;
939
+ hue %= 1;
940
+ return [hue * 360, chroma * 100, grayscale * 100];
941
+ };
942
+ convert.hsl.hcg = function(hsl) {
943
+ const s = hsl[1] / 100;
944
+ const l = hsl[2] / 100;
945
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
946
+ let f = 0;
947
+ if (c < 1) {
948
+ f = (l - 0.5 * c) / (1 - c);
949
+ }
950
+ return [hsl[0], c * 100, f * 100];
951
+ };
952
+ convert.hsv.hcg = function(hsv) {
953
+ const s = hsv[1] / 100;
954
+ const v = hsv[2] / 100;
955
+ const c = s * v;
956
+ let f = 0;
957
+ if (c < 1) {
958
+ f = (v - c) / (1 - c);
959
+ }
960
+ return [hsv[0], c * 100, f * 100];
961
+ };
962
+ convert.hcg.rgb = function(hcg) {
963
+ const h = hcg[0] / 360;
964
+ const c = hcg[1] / 100;
965
+ const g = hcg[2] / 100;
966
+ if (c === 0) {
967
+ return [g * 255, g * 255, g * 255];
968
+ }
969
+ const pure = [0, 0, 0];
970
+ const hi = h % 1 * 6;
971
+ const v = hi % 1;
972
+ const w = 1 - v;
973
+ let mg = 0;
974
+ switch (Math.floor(hi)) {
975
+ case 0:
976
+ pure[0] = 1;
977
+ pure[1] = v;
978
+ pure[2] = 0;
979
+ break;
980
+ case 1:
981
+ pure[0] = w;
982
+ pure[1] = 1;
983
+ pure[2] = 0;
984
+ break;
985
+ case 2:
986
+ pure[0] = 0;
987
+ pure[1] = 1;
988
+ pure[2] = v;
989
+ break;
990
+ case 3:
991
+ pure[0] = 0;
992
+ pure[1] = w;
993
+ pure[2] = 1;
994
+ break;
995
+ case 4:
996
+ pure[0] = v;
997
+ pure[1] = 0;
998
+ pure[2] = 1;
999
+ break;
1000
+ default:
1001
+ pure[0] = 1;
1002
+ pure[1] = 0;
1003
+ pure[2] = w;
1004
+ }
1005
+ mg = (1 - c) * g;
1006
+ return [
1007
+ (c * pure[0] + mg) * 255,
1008
+ (c * pure[1] + mg) * 255,
1009
+ (c * pure[2] + mg) * 255
1010
+ ];
1011
+ };
1012
+ convert.hcg.hsv = function(hcg) {
1013
+ const c = hcg[1] / 100;
1014
+ const g = hcg[2] / 100;
1015
+ const v = c + g * (1 - c);
1016
+ let f = 0;
1017
+ if (v > 0) {
1018
+ f = c / v;
1019
+ }
1020
+ return [hcg[0], f * 100, v * 100];
1021
+ };
1022
+ convert.hcg.hsl = function(hcg) {
1023
+ const c = hcg[1] / 100;
1024
+ const g = hcg[2] / 100;
1025
+ const l = g * (1 - c) + 0.5 * c;
1026
+ let s = 0;
1027
+ if (l > 0 && l < 0.5) {
1028
+ s = c / (2 * l);
1029
+ } else if (l >= 0.5 && l < 1) {
1030
+ s = c / (2 * (1 - l));
1031
+ }
1032
+ return [hcg[0], s * 100, l * 100];
1033
+ };
1034
+ convert.hcg.hwb = function(hcg) {
1035
+ const c = hcg[1] / 100;
1036
+ const g = hcg[2] / 100;
1037
+ const v = c + g * (1 - c);
1038
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
1039
+ };
1040
+ convert.hwb.hcg = function(hwb) {
1041
+ const w = hwb[1] / 100;
1042
+ const b = hwb[2] / 100;
1043
+ const v = 1 - b;
1044
+ const c = v - w;
1045
+ let g = 0;
1046
+ if (c < 1) {
1047
+ g = (v - c) / (1 - c);
1048
+ }
1049
+ return [hwb[0], c * 100, g * 100];
1050
+ };
1051
+ convert.apple.rgb = function(apple) {
1052
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1053
+ };
1054
+ convert.rgb.apple = function(rgb) {
1055
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1056
+ };
1057
+ convert.gray.rgb = function(args) {
1058
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1059
+ };
1060
+ convert.gray.hsl = function(args) {
1061
+ return [0, 0, args[0]];
1062
+ };
1063
+ convert.gray.hsv = convert.gray.hsl;
1064
+ convert.gray.hwb = function(gray) {
1065
+ return [0, 100, gray[0]];
1066
+ };
1067
+ convert.gray.cmyk = function(gray) {
1068
+ return [0, 0, 0, gray[0]];
1069
+ };
1070
+ convert.gray.lab = function(gray) {
1071
+ return [gray[0], 0, 0];
1072
+ };
1073
+ convert.gray.hex = function(gray) {
1074
+ const val = Math.round(gray[0] / 100 * 255) & 255;
1075
+ const integer = (val << 16) + (val << 8) + val;
1076
+ const string = integer.toString(16).toUpperCase();
1077
+ return "000000".substring(string.length) + string;
1078
+ };
1079
+ convert.rgb.gray = function(rgb) {
1080
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1081
+ return [val / 255 * 100];
1082
+ };
1083
+ }
1084
+ });
1085
+
1086
+ // node_modules/color-convert/route.js
1087
+ var require_route = __commonJS({
1088
+ "node_modules/color-convert/route.js"(exports, module) {
1089
+ "use strict";
1090
+ var conversions = require_conversions();
1091
+ function buildGraph() {
1092
+ const graph = {};
1093
+ const models = Object.keys(conversions);
1094
+ for (let len = models.length, i = 0; i < len; i++) {
1095
+ graph[models[i]] = {
1096
+ // http://jsperf.com/1-vs-infinity
1097
+ // micro-opt, but this is simple.
1098
+ distance: -1,
1099
+ parent: null
1100
+ };
1101
+ }
1102
+ return graph;
1103
+ }
1104
+ function deriveBFS(fromModel) {
1105
+ const graph = buildGraph();
1106
+ const queue = [fromModel];
1107
+ graph[fromModel].distance = 0;
1108
+ while (queue.length) {
1109
+ const current = queue.pop();
1110
+ const adjacents = Object.keys(conversions[current]);
1111
+ for (let len = adjacents.length, i = 0; i < len; i++) {
1112
+ const adjacent = adjacents[i];
1113
+ const node = graph[adjacent];
1114
+ if (node.distance === -1) {
1115
+ node.distance = graph[current].distance + 1;
1116
+ node.parent = current;
1117
+ queue.unshift(adjacent);
1118
+ }
1119
+ }
1120
+ }
1121
+ return graph;
1122
+ }
1123
+ function link(from, to) {
1124
+ return function(args) {
1125
+ return to(from(args));
1126
+ };
1127
+ }
1128
+ function wrapConversion(toModel, graph) {
1129
+ const path4 = [graph[toModel].parent, toModel];
1130
+ let fn = conversions[graph[toModel].parent][toModel];
1131
+ let cur = graph[toModel].parent;
1132
+ while (graph[cur].parent) {
1133
+ path4.unshift(graph[cur].parent);
1134
+ fn = link(conversions[graph[cur].parent][cur], fn);
1135
+ cur = graph[cur].parent;
1136
+ }
1137
+ fn.conversion = path4;
1138
+ return fn;
1139
+ }
1140
+ module.exports = function(fromModel) {
1141
+ const graph = deriveBFS(fromModel);
1142
+ const conversion = {};
1143
+ const models = Object.keys(graph);
1144
+ for (let len = models.length, i = 0; i < len; i++) {
1145
+ const toModel = models[i];
1146
+ const node = graph[toModel];
1147
+ if (node.parent === null) {
1148
+ continue;
1149
+ }
1150
+ conversion[toModel] = wrapConversion(toModel, graph);
1151
+ }
1152
+ return conversion;
1153
+ };
1154
+ }
1155
+ });
1156
+
1157
+ // node_modules/color-convert/index.js
1158
+ var require_color_convert = __commonJS({
1159
+ "node_modules/color-convert/index.js"(exports, module) {
1160
+ "use strict";
1161
+ var conversions = require_conversions();
1162
+ var route = require_route();
1163
+ var convert = {};
1164
+ var models = Object.keys(conversions);
1165
+ function wrapRaw(fn) {
1166
+ const wrappedFn = function(...args) {
1167
+ const arg0 = args[0];
1168
+ if (arg0 === void 0 || arg0 === null) {
1169
+ return arg0;
1170
+ }
1171
+ if (arg0.length > 1) {
1172
+ args = arg0;
1173
+ }
1174
+ return fn(args);
1175
+ };
1176
+ if ("conversion" in fn) {
1177
+ wrappedFn.conversion = fn.conversion;
1178
+ }
1179
+ return wrappedFn;
1180
+ }
1181
+ function wrapRounded(fn) {
1182
+ const wrappedFn = function(...args) {
1183
+ const arg0 = args[0];
1184
+ if (arg0 === void 0 || arg0 === null) {
1185
+ return arg0;
1186
+ }
1187
+ if (arg0.length > 1) {
1188
+ args = arg0;
1189
+ }
1190
+ const result = fn(args);
1191
+ if (typeof result === "object") {
1192
+ for (let len = result.length, i = 0; i < len; i++) {
1193
+ result[i] = Math.round(result[i]);
1194
+ }
1195
+ }
1196
+ return result;
1197
+ };
1198
+ if ("conversion" in fn) {
1199
+ wrappedFn.conversion = fn.conversion;
1200
+ }
1201
+ return wrappedFn;
1202
+ }
1203
+ models.forEach((fromModel) => {
1204
+ convert[fromModel] = {};
1205
+ Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
1206
+ Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
1207
+ const routes = route(fromModel);
1208
+ const routeModels = Object.keys(routes);
1209
+ routeModels.forEach((toModel) => {
1210
+ const fn = routes[toModel];
1211
+ convert[fromModel][toModel] = wrapRounded(fn);
1212
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1213
+ });
1214
+ });
1215
+ module.exports = convert;
1216
+ }
1217
+ });
1218
+
1219
+ // node_modules/ansi-styles/index.js
1220
+ var require_ansi_styles = __commonJS({
1221
+ "node_modules/ansi-styles/index.js"(exports, module) {
1222
+ "use strict";
1223
+ var wrapAnsi16 = (fn, offset) => (...args) => {
1224
+ const code = fn(...args);
1225
+ return `\x1B[${code + offset}m`;
1226
+ };
1227
+ var wrapAnsi256 = (fn, offset) => (...args) => {
1228
+ const code = fn(...args);
1229
+ return `\x1B[${38 + offset};5;${code}m`;
1230
+ };
1231
+ var wrapAnsi16m = (fn, offset) => (...args) => {
1232
+ const rgb = fn(...args);
1233
+ return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1234
+ };
1235
+ var ansi2ansi = (n) => n;
1236
+ var rgb2rgb = (r, g, b) => [r, g, b];
1237
+ var setLazyProperty = (object, property, get) => {
1238
+ Object.defineProperty(object, property, {
1239
+ get: () => {
1240
+ const value = get();
1241
+ Object.defineProperty(object, property, {
1242
+ value,
1243
+ enumerable: true,
1244
+ configurable: true
1245
+ });
1246
+ return value;
1247
+ },
1248
+ enumerable: true,
1249
+ configurable: true
1250
+ });
1251
+ };
1252
+ var colorConvert;
1253
+ var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
1254
+ if (colorConvert === void 0) {
1255
+ colorConvert = require_color_convert();
1256
+ }
1257
+ const offset = isBackground ? 10 : 0;
1258
+ const styles = {};
1259
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
1260
+ const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
1261
+ if (sourceSpace === targetSpace) {
1262
+ styles[name] = wrap(identity, offset);
1263
+ } else if (typeof suite === "object") {
1264
+ styles[name] = wrap(suite[targetSpace], offset);
1265
+ }
1266
+ }
1267
+ return styles;
1268
+ };
1269
+ function assembleStyles() {
1270
+ const codes = /* @__PURE__ */ new Map();
1271
+ const styles = {
1272
+ modifier: {
1273
+ reset: [0, 0],
1274
+ // 21 isn't widely supported and 22 does the same thing
1275
+ bold: [1, 22],
1276
+ dim: [2, 22],
1277
+ italic: [3, 23],
1278
+ underline: [4, 24],
1279
+ inverse: [7, 27],
1280
+ hidden: [8, 28],
1281
+ strikethrough: [9, 29]
1282
+ },
1283
+ color: {
1284
+ black: [30, 39],
1285
+ red: [31, 39],
1286
+ green: [32, 39],
1287
+ yellow: [33, 39],
1288
+ blue: [34, 39],
1289
+ magenta: [35, 39],
1290
+ cyan: [36, 39],
1291
+ white: [37, 39],
1292
+ // Bright color
1293
+ blackBright: [90, 39],
1294
+ redBright: [91, 39],
1295
+ greenBright: [92, 39],
1296
+ yellowBright: [93, 39],
1297
+ blueBright: [94, 39],
1298
+ magentaBright: [95, 39],
1299
+ cyanBright: [96, 39],
1300
+ whiteBright: [97, 39]
1301
+ },
1302
+ bgColor: {
1303
+ bgBlack: [40, 49],
1304
+ bgRed: [41, 49],
1305
+ bgGreen: [42, 49],
1306
+ bgYellow: [43, 49],
1307
+ bgBlue: [44, 49],
1308
+ bgMagenta: [45, 49],
1309
+ bgCyan: [46, 49],
1310
+ bgWhite: [47, 49],
1311
+ // Bright color
1312
+ bgBlackBright: [100, 49],
1313
+ bgRedBright: [101, 49],
1314
+ bgGreenBright: [102, 49],
1315
+ bgYellowBright: [103, 49],
1316
+ bgBlueBright: [104, 49],
1317
+ bgMagentaBright: [105, 49],
1318
+ bgCyanBright: [106, 49],
1319
+ bgWhiteBright: [107, 49]
1320
+ }
1321
+ };
1322
+ styles.color.gray = styles.color.blackBright;
1323
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
1324
+ styles.color.grey = styles.color.blackBright;
1325
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
1326
+ for (const [groupName, group] of Object.entries(styles)) {
1327
+ for (const [styleName, style] of Object.entries(group)) {
1328
+ styles[styleName] = {
1329
+ open: `\x1B[${style[0]}m`,
1330
+ close: `\x1B[${style[1]}m`
1331
+ };
1332
+ group[styleName] = styles[styleName];
1333
+ codes.set(style[0], style[1]);
1334
+ }
1335
+ Object.defineProperty(styles, groupName, {
1336
+ value: group,
1337
+ enumerable: false
1338
+ });
1339
+ }
1340
+ Object.defineProperty(styles, "codes", {
1341
+ value: codes,
1342
+ enumerable: false
1343
+ });
1344
+ styles.color.close = "\x1B[39m";
1345
+ styles.bgColor.close = "\x1B[49m";
1346
+ setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
1347
+ setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
1348
+ setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
1349
+ setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
1350
+ setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
1351
+ setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
1352
+ return styles;
1353
+ }
1354
+ Object.defineProperty(module, "exports", {
1355
+ enumerable: true,
1356
+ get: assembleStyles
1357
+ });
1358
+ }
1359
+ });
1360
+
1361
+ // node_modules/wrap-ansi/index.js
1362
+ var require_wrap_ansi = __commonJS({
1363
+ "node_modules/wrap-ansi/index.js"(exports, module) {
1364
+ "use strict";
1365
+ var stringWidth = require_string_width();
1366
+ var stripAnsi = require_strip_ansi();
1367
+ var ansiStyles = require_ansi_styles();
1368
+ var ESCAPES = /* @__PURE__ */ new Set([
1369
+ "\x1B",
1370
+ "\x9B"
1371
+ ]);
1372
+ var END_CODE = 39;
1373
+ var wrapAnsi2 = (code) => `${ESCAPES.values().next().value}[${code}m`;
1374
+ var wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
1375
+ var wrapWord = (rows, word, columns) => {
1376
+ const characters = [...word];
1377
+ let isInsideEscape = false;
1378
+ let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
1379
+ for (const [index, character] of characters.entries()) {
1380
+ const characterLength = stringWidth(character);
1381
+ if (visible + characterLength <= columns) {
1382
+ rows[rows.length - 1] += character;
1383
+ } else {
1384
+ rows.push(character);
1385
+ visible = 0;
1386
+ }
1387
+ if (ESCAPES.has(character)) {
1388
+ isInsideEscape = true;
1389
+ } else if (isInsideEscape && character === "m") {
1390
+ isInsideEscape = false;
1391
+ continue;
1392
+ }
1393
+ if (isInsideEscape) {
1394
+ continue;
1395
+ }
1396
+ visible += characterLength;
1397
+ if (visible === columns && index < characters.length - 1) {
1398
+ rows.push("");
1399
+ visible = 0;
1400
+ }
1401
+ }
1402
+ if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
1403
+ rows[rows.length - 2] += rows.pop();
1404
+ }
1405
+ };
1406
+ var stringVisibleTrimSpacesRight = (str) => {
1407
+ const words = str.split(" ");
1408
+ let last = words.length;
1409
+ while (last > 0) {
1410
+ if (stringWidth(words[last - 1]) > 0) {
1411
+ break;
1412
+ }
1413
+ last--;
1414
+ }
1415
+ if (last === words.length) {
1416
+ return str;
1417
+ }
1418
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
1419
+ };
1420
+ var exec = (string, columns, options = {}) => {
1421
+ if (options.trim !== false && string.trim() === "") {
1422
+ return "";
1423
+ }
1424
+ let pre = "";
1425
+ let ret = "";
1426
+ let escapeCode;
1427
+ const lengths = wordLengths(string);
1428
+ let rows = [""];
1429
+ for (const [index, word] of string.split(" ").entries()) {
1430
+ if (options.trim !== false) {
1431
+ rows[rows.length - 1] = rows[rows.length - 1].trimLeft();
1432
+ }
1433
+ let rowLength = stringWidth(rows[rows.length - 1]);
1434
+ if (index !== 0) {
1435
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
1436
+ rows.push("");
1437
+ rowLength = 0;
1438
+ }
1439
+ if (rowLength > 0 || options.trim === false) {
1440
+ rows[rows.length - 1] += " ";
1441
+ rowLength++;
1442
+ }
1443
+ }
1444
+ if (options.hard && lengths[index] > columns) {
1445
+ const remainingColumns = columns - rowLength;
1446
+ const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
1447
+ const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
1448
+ if (breaksStartingNextLine < breaksStartingThisLine) {
1449
+ rows.push("");
1450
+ }
1451
+ wrapWord(rows, word, columns);
1452
+ continue;
1453
+ }
1454
+ if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
1455
+ if (options.wordWrap === false && rowLength < columns) {
1456
+ wrapWord(rows, word, columns);
1457
+ continue;
1458
+ }
1459
+ rows.push("");
1460
+ }
1461
+ if (rowLength + lengths[index] > columns && options.wordWrap === false) {
1462
+ wrapWord(rows, word, columns);
1463
+ continue;
1464
+ }
1465
+ rows[rows.length - 1] += word;
1466
+ }
1467
+ if (options.trim !== false) {
1468
+ rows = rows.map(stringVisibleTrimSpacesRight);
1469
+ }
1470
+ pre = rows.join("\n");
1471
+ for (const [index, character] of [...pre].entries()) {
1472
+ ret += character;
1473
+ if (ESCAPES.has(character)) {
1474
+ const code2 = parseFloat(/\d[^m]*/.exec(pre.slice(index, index + 4)));
1475
+ escapeCode = code2 === END_CODE ? null : code2;
1476
+ }
1477
+ const code = ansiStyles.codes.get(Number(escapeCode));
1478
+ if (escapeCode && code) {
1479
+ if (pre[index + 1] === "\n") {
1480
+ ret += wrapAnsi2(code);
1481
+ } else if (character === "\n") {
1482
+ ret += wrapAnsi2(escapeCode);
1483
+ }
1484
+ }
1485
+ }
1486
+ return ret;
1487
+ };
1488
+ module.exports = (string, columns, options) => {
1489
+ return String(string).normalize().replace(/\r\n/g, "\n").split("\n").map((line) => exec(line, columns, options)).join("\n");
1490
+ };
1491
+ }
1492
+ });
1493
+
1494
+ // node_modules/mute-stream/lib/index.js
1495
+ var require_lib = __commonJS({
1496
+ "node_modules/mute-stream/lib/index.js"(exports, module) {
1497
+ "use strict";
1498
+ var Stream = __require("stream");
1499
+ var MuteStream2 = class extends Stream {
1500
+ #isTTY = null;
1501
+ constructor(opts = {}) {
1502
+ super(opts);
1503
+ this.writable = this.readable = true;
1504
+ this.muted = false;
1505
+ this.on("pipe", this._onpipe);
1506
+ this.replace = opts.replace;
1507
+ this._prompt = opts.prompt || null;
1508
+ this._hadControl = false;
1509
+ }
1510
+ #destSrc(key, def) {
1511
+ if (this._dest) {
1512
+ return this._dest[key];
1513
+ }
1514
+ if (this._src) {
1515
+ return this._src[key];
1516
+ }
1517
+ return def;
1518
+ }
1519
+ #proxy(method, ...args) {
1520
+ if (typeof this._dest?.[method] === "function") {
1521
+ this._dest[method](...args);
1522
+ }
1523
+ if (typeof this._src?.[method] === "function") {
1524
+ this._src[method](...args);
1525
+ }
1526
+ }
1527
+ get isTTY() {
1528
+ if (this.#isTTY !== null) {
1529
+ return this.#isTTY;
1530
+ }
1531
+ return this.#destSrc("isTTY", false);
1532
+ }
1533
+ // basically just get replace the getter/setter with a regular value
1534
+ set isTTY(val) {
1535
+ this.#isTTY = val;
1536
+ }
1537
+ get rows() {
1538
+ return this.#destSrc("rows");
1539
+ }
1540
+ get columns() {
1541
+ return this.#destSrc("columns");
1542
+ }
1543
+ mute() {
1544
+ this.muted = true;
1545
+ }
1546
+ unmute() {
1547
+ this.muted = false;
1548
+ }
1549
+ _onpipe(src) {
1550
+ this._src = src;
1551
+ }
1552
+ pipe(dest, options) {
1553
+ this._dest = dest;
1554
+ return super.pipe(dest, options);
1555
+ }
1556
+ pause() {
1557
+ if (this._src) {
1558
+ return this._src.pause();
1559
+ }
1560
+ }
1561
+ resume() {
1562
+ if (this._src) {
1563
+ return this._src.resume();
1564
+ }
1565
+ }
1566
+ write(c) {
1567
+ if (this.muted) {
1568
+ if (!this.replace) {
1569
+ return true;
1570
+ }
1571
+ if (c.match(/^\u001b/)) {
1572
+ if (c.indexOf(this._prompt) === 0) {
1573
+ c = c.slice(this._prompt.length);
1574
+ c = c.replace(/./g, this.replace);
1575
+ c = this._prompt + c;
1576
+ }
1577
+ this._hadControl = true;
1578
+ return this.emit("data", c);
1579
+ } else {
1580
+ if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
1581
+ this._hadControl = false;
1582
+ this.emit("data", this._prompt);
1583
+ c = c.slice(this._prompt.length);
1584
+ }
1585
+ c = c.toString().replace(/./g, this.replace);
1586
+ }
1587
+ }
1588
+ this.emit("data", c);
1589
+ }
1590
+ end(c) {
1591
+ if (this.muted) {
1592
+ if (c && this.replace) {
1593
+ c = c.toString().replace(/./g, this.replace);
1594
+ } else {
1595
+ c = null;
1596
+ }
1597
+ }
1598
+ if (c) {
1599
+ this.emit("data", c);
1600
+ }
1601
+ this.emit("end");
1602
+ }
1603
+ destroy(...args) {
1604
+ return this.#proxy("destroy", ...args);
1605
+ }
1606
+ destroySoon(...args) {
1607
+ return this.#proxy("destroySoon", ...args);
1608
+ }
1609
+ close(...args) {
1610
+ return this.#proxy("close", ...args);
1611
+ }
1612
+ };
1613
+ module.exports = MuteStream2;
1614
+ }
1615
+ });
1616
+
1617
+ // src/index.ts
1618
+ import { Command } from "commander";
1619
+
1620
+ // src/shared/constants/app.constants.ts
1621
+ var APP_NAME = "adograb";
1622
+ var APP_VERSION = "0.1.0";
1623
+ var KEYTAR_SERVICE = "adograb";
1624
+ var KEYTAR_ACCOUNT_PAT = "pat";
1625
+ var ADO_API_VERSION = "7.1";
1626
+ var CONFIG_KEYS = {
1627
+ ORG_URL: "orgUrl",
1628
+ PROJECT_ID: "projectId",
1629
+ PROJECT_NAME: "projectName",
1630
+ AUTH_MODE: "authMode",
1631
+ CLONE_ROOT: "cloneRoot"
1632
+ };
1633
+
1634
+ // src/infrastructure/config/conf-store.ts
1635
+ import Conf from "conf";
1636
+ var ConfStore = class {
1637
+ conf;
1638
+ constructor() {
1639
+ this.conf = new Conf({
1640
+ projectName: APP_NAME
1641
+ });
1642
+ }
1643
+ get(key) {
1644
+ return this.conf.get(key);
1645
+ }
1646
+ set(key, value) {
1647
+ this.conf.set(key, value);
1648
+ }
1649
+ getAll() {
1650
+ return this.conf.store;
1651
+ }
1652
+ clear() {
1653
+ this.conf.clear();
1654
+ }
1655
+ has(key) {
1656
+ return this.conf.has(key);
1657
+ }
1658
+ };
1659
+
1660
+ // src/infrastructure/secrets/keytar-store.ts
1661
+ import { createRequire } from "module";
1662
+ var require2 = createRequire(import.meta.url);
1663
+ var keytar = require2("keytar");
1664
+ var KeytarStore = class {
1665
+ async setSecret(service, account, secret) {
1666
+ await keytar.setPassword(service, account, secret);
1667
+ }
1668
+ async getSecret(service, account) {
1669
+ return keytar.getPassword(service, account);
1670
+ }
1671
+ async deleteSecret(service, account) {
1672
+ return keytar.deletePassword(service, account);
1673
+ }
1674
+ };
1675
+
1676
+ // src/infrastructure/ado/ado-client.ts
1677
+ import axios from "axios";
1678
+
1679
+ // src/application/errors/app-errors.ts
1680
+ var AppError = class extends Error {
1681
+ constructor(code, message, cause) {
1682
+ super(message);
1683
+ this.code = code;
1684
+ this.cause = cause;
1685
+ this.name = "AppError";
1686
+ }
1687
+ };
1688
+ var MissingConfigError = class extends AppError {
1689
+ constructor(message = "Configuration not found. Run `adograb init` to set up the tool.") {
1690
+ super("MISSING_CONFIG" /* MISSING_CONFIG */, message);
1691
+ this.name = "MissingConfigError";
1692
+ }
1693
+ };
1694
+ var AuthenticationError = class extends AppError {
1695
+ constructor(message = "Authentication failed. Check your credentials or run `adograb auth switch`.") {
1696
+ super("AUTHENTICATION_FAILED" /* AUTHENTICATION_FAILED */, message);
1697
+ this.name = "AuthenticationError";
1698
+ }
1699
+ };
1700
+ var AuthorizationError = class extends AppError {
1701
+ constructor(message = "Access denied. You do not have permission to access this resource.") {
1702
+ super("AUTHORIZATION_FAILED" /* AUTHORIZATION_FAILED */, message);
1703
+ this.name = "AuthorizationError";
1704
+ }
1705
+ };
1706
+ var ProjectFetchError = class extends AppError {
1707
+ constructor(message, cause) {
1708
+ super("PROJECT_FETCH_FAILED" /* PROJECT_FETCH_FAILED */, message, cause);
1709
+ this.name = "ProjectFetchError";
1710
+ }
1711
+ };
1712
+ var RepositoryFetchError = class extends AppError {
1713
+ constructor(message, cause) {
1714
+ super("REPOSITORY_FETCH_FAILED" /* REPOSITORY_FETCH_FAILED */, message, cause);
1715
+ this.name = "RepositoryFetchError";
1716
+ }
1717
+ };
1718
+ var RepositoryNotFoundError = class extends AppError {
1719
+ constructor(repoName) {
1720
+ super(
1721
+ "REPOSITORY_NOT_FOUND" /* REPOSITORY_NOT_FOUND */,
1722
+ `Repository "${repoName}" was not found in the selected project.`
1723
+ );
1724
+ this.name = "RepositoryNotFoundError";
1725
+ }
1726
+ };
1727
+ var CloneError = class extends AppError {
1728
+ constructor(message, cause) {
1729
+ super("CLONE_FAILED" /* CLONE_FAILED */, message, cause);
1730
+ this.name = "CloneError";
1731
+ }
1732
+ };
1733
+ var SecureStoreError = class extends AppError {
1734
+ constructor(message, cause) {
1735
+ super("SECURE_STORE_FAILED" /* SECURE_STORE_FAILED */, message, cause);
1736
+ this.name = "SecureStoreError";
1737
+ }
1738
+ };
1739
+ var ConfigPersistenceError = class extends AppError {
1740
+ constructor(message, cause) {
1741
+ super("CONFIG_PERSISTENCE_FAILED" /* CONFIG_PERSISTENCE_FAILED */, message, cause);
1742
+ this.name = "ConfigPersistenceError";
1743
+ }
1744
+ };
1745
+ var NetworkError = class extends AppError {
1746
+ constructor(message = "Network request failed. Check your internet connection.", cause) {
1747
+ super("NETWORK_FAILED" /* NETWORK_FAILED */, message, cause);
1748
+ this.name = "NetworkError";
1749
+ }
1750
+ };
1751
+
1752
+ // src/shared/utils/url.utils.ts
1753
+ function normalizeOrgUrl(url) {
1754
+ return url.trim().replace(/\/+$/, "");
1755
+ }
1756
+ function isValidAdoOrgUrl(url) {
1757
+ try {
1758
+ const normalized = normalizeOrgUrl(url);
1759
+ const parsed = new URL(normalized);
1760
+ if (parsed.protocol !== "https:") return false;
1761
+ const devAzureMatch = /^https:\/\/dev\.azure\.com\/[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9](\/)?$/.test(
1762
+ normalized
1763
+ ) || /^https:\/\/dev\.azure\.com\/[a-zA-Z0-9](\/)?$/.test(normalized);
1764
+ const visualStudioMatch = /^https:\/\/[a-zA-Z0-9][a-zA-Z0-9-]*\.visualstudio\.com(\/)?$/.test(normalized);
1765
+ return devAzureMatch || visualStudioMatch;
1766
+ } catch {
1767
+ return false;
1768
+ }
1769
+ }
1770
+
1771
+ // src/infrastructure/ado/ado-client.ts
1772
+ var AdoClient = class {
1773
+ async getProjects(orgUrl, authHeader) {
1774
+ const url = `${normalizeOrgUrl(orgUrl)}/_apis/projects?api-version=${ADO_API_VERSION}&stateFilter=wellFormed`;
1775
+ try {
1776
+ const response = await axios.get(url, {
1777
+ headers: { Authorization: authHeader }
1778
+ });
1779
+ return response.data.value.map((p) => ({
1780
+ id: p.id,
1781
+ name: p.name,
1782
+ description: p.description,
1783
+ state: p.state,
1784
+ visibility: p.visibility
1785
+ }));
1786
+ } catch (error) {
1787
+ if (axios.isAxiosError(error)) {
1788
+ const status = error.response?.status;
1789
+ if (status === 401) throw new AuthenticationError();
1790
+ if (status === 403) throw new AuthorizationError();
1791
+ if (!error.response) throw new NetworkError(void 0, error);
1792
+ }
1793
+ throw new ProjectFetchError(
1794
+ `Failed to fetch projects: ${error instanceof Error ? error.message : String(error)}`,
1795
+ error
1796
+ );
1797
+ }
1798
+ }
1799
+ async getRepositories(orgUrl, projectId, authHeader) {
1800
+ const url = `${normalizeOrgUrl(orgUrl)}/${projectId}/_apis/git/repositories?api-version=${ADO_API_VERSION}`;
1801
+ try {
1802
+ const response = await axios.get(url, {
1803
+ headers: { Authorization: authHeader }
1804
+ });
1805
+ return response.data.value.map((r) => ({
1806
+ id: r.id,
1807
+ name: r.name,
1808
+ remoteUrl: r.remoteUrl,
1809
+ sshUrl: r.sshUrl,
1810
+ webUrl: r.webUrl,
1811
+ defaultBranch: r.defaultBranch
1812
+ }));
1813
+ } catch (error) {
1814
+ if (axios.isAxiosError(error)) {
1815
+ const status = error.response?.status;
1816
+ if (status === 401) throw new AuthenticationError();
1817
+ if (status === 403) throw new AuthorizationError();
1818
+ if (!error.response) throw new NetworkError(void 0, error);
1819
+ }
1820
+ throw new RepositoryFetchError(
1821
+ `Failed to fetch repositories: ${error instanceof Error ? error.message : String(error)}`,
1822
+ error
1823
+ );
1824
+ }
1825
+ }
1826
+ async getRepositoryByName(orgUrl, projectId, repoName, authHeader) {
1827
+ const repos = await this.getRepositories(orgUrl, projectId, authHeader);
1828
+ const repo = repos.find((r) => r.name.toLowerCase() === repoName.toLowerCase());
1829
+ if (!repo) throw new RepositoryNotFoundError(repoName);
1830
+ return repo;
1831
+ }
1832
+ };
1833
+
1834
+ // src/shared/utils/auth.utils.ts
1835
+ function buildBasicAuthHeader(pat) {
1836
+ const token = Buffer.from(`:${pat}`).toString("base64");
1837
+ return `Basic ${token}`;
1838
+ }
1839
+
1840
+ // src/infrastructure/auth/pat-auth-provider.ts
1841
+ var PatAuthHeaderProvider = class {
1842
+ constructor(pat) {
1843
+ this.pat = pat;
1844
+ }
1845
+ async getAuthHeader() {
1846
+ return buildBasicAuthHeader(this.pat);
1847
+ }
1848
+ };
1849
+
1850
+ // src/infrastructure/auth/default-auth-provider.ts
1851
+ import { execa } from "execa";
1852
+ var DefaultAuthHeaderProvider = class {
1853
+ constructor(orgUrl) {
1854
+ this.orgUrl = orgUrl;
1855
+ }
1856
+ async getAuthHeader() {
1857
+ try {
1858
+ const url = new URL(this.orgUrl);
1859
+ const host = url.hostname;
1860
+ const { stdout } = await execa("git", ["credential", "fill"], {
1861
+ input: `protocol=https
1862
+ host=${host}
1863
+
1864
+ `
1865
+ });
1866
+ const lines = stdout.split("\n");
1867
+ const usernameLine = lines.find((l) => l.startsWith("username="));
1868
+ const passwordLine = lines.find((l) => l.startsWith("password="));
1869
+ const username = usernameLine?.split("=").slice(1).join("=").trim() ?? "";
1870
+ const password2 = passwordLine?.split("=").slice(1).join("=").trim() ?? "";
1871
+ if (!password2) {
1872
+ throw new AuthenticationError(
1873
+ "No credentials found in Git Credential Manager for this host. Run 'adograb auth switch' to configure PAT authentication instead."
1874
+ );
1875
+ }
1876
+ const token = Buffer.from(`${username}:${password2}`).toString("base64");
1877
+ return `Basic ${token}`;
1878
+ } catch (error) {
1879
+ if (error instanceof AuthenticationError) throw error;
1880
+ throw new AuthenticationError(
1881
+ `Could not retrieve credentials from Git Credential Manager. Run 'adograb auth switch' to configure PAT authentication.
1882
+ Details: ${error instanceof Error ? error.message : String(error)}`
1883
+ );
1884
+ }
1885
+ }
1886
+ };
1887
+
1888
+ // src/application/use-cases/initialize-tool.use-case.ts
1889
+ var InitializeToolUseCase = class {
1890
+ constructor(configStore, secretStore) {
1891
+ this.configStore = configStore;
1892
+ this.secretStore = secretStore;
1893
+ }
1894
+ async execute(input2) {
1895
+ try {
1896
+ if (input2.authMode === "pat" && input2.pat) {
1897
+ try {
1898
+ await this.secretStore.setSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT, input2.pat);
1899
+ } catch (error) {
1900
+ throw new SecureStoreError("Failed to store PAT in secure store.", error);
1901
+ }
1902
+ }
1903
+ const existingAuthMode = this.configStore.get(CONFIG_KEYS.AUTH_MODE);
1904
+ if (existingAuthMode === "pat" && input2.authMode === "default") {
1905
+ try {
1906
+ await this.secretStore.deleteSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
1907
+ } catch {
1908
+ }
1909
+ }
1910
+ this.configStore.set(CONFIG_KEYS.ORG_URL, input2.orgUrl);
1911
+ this.configStore.set(CONFIG_KEYS.PROJECT_ID, input2.projectId);
1912
+ this.configStore.set(CONFIG_KEYS.PROJECT_NAME, input2.projectName);
1913
+ this.configStore.set(CONFIG_KEYS.AUTH_MODE, input2.authMode);
1914
+ this.configStore.set(CONFIG_KEYS.CLONE_ROOT, input2.cloneRoot);
1915
+ } catch (error) {
1916
+ if (error instanceof SecureStoreError) throw error;
1917
+ throw new ConfigPersistenceError("Failed to save configuration.", error);
1918
+ }
1919
+ }
1920
+ };
1921
+
1922
+ // src/application/use-cases/list-projects.use-case.ts
1923
+ var ListProjectsUseCase = class {
1924
+ constructor(adoClient, authProvider) {
1925
+ this.adoClient = adoClient;
1926
+ this.authProvider = authProvider;
1927
+ }
1928
+ async execute(input2) {
1929
+ const authHeader = await this.authProvider.getAuthHeader();
1930
+ return this.adoClient.getProjects(input2.orgUrl, authHeader);
1931
+ }
1932
+ };
1933
+
1934
+ // src/cli/prompts/setup.prompts.ts
1935
+ import { input, select, password } from "@inquirer/prompts";
1936
+
1937
+ // src/domain/rules/validation.rules.ts
1938
+ function validateOrgUrl(url) {
1939
+ if (!url?.trim()) return "Organization URL is required.";
1940
+ if (!isValidAdoOrgUrl(url.trim())) {
1941
+ return "Invalid Azure DevOps organization URL. Expected: https://dev.azure.com/{org} or https://{org}.visualstudio.com";
1942
+ }
1943
+ return null;
1944
+ }
1945
+ function validatePat(pat) {
1946
+ if (!pat?.trim()) return "Personal Access Token must not be empty.";
1947
+ if (pat.trim().length < 10) return "Personal Access Token appears too short.";
1948
+ return null;
1949
+ }
1950
+ function validateCloneRoot(path4) {
1951
+ if (!path4?.trim()) return "Clone destination folder is required.";
1952
+ return null;
1953
+ }
1954
+
1955
+ // src/cli/prompts/setup.prompts.ts
1956
+ import path from "path";
1957
+ async function promptOrgUrl() {
1958
+ return input({
1959
+ message: "Azure DevOps organization URL:",
1960
+ validate: (value) => {
1961
+ const error = validateOrgUrl(value);
1962
+ return error ?? true;
1963
+ }
1964
+ });
1965
+ }
1966
+ async function promptAuthMode() {
1967
+ return select({
1968
+ message: "Select authentication mode:",
1969
+ choices: [
1970
+ {
1971
+ name: "Default (Git Credential Manager)",
1972
+ value: "default",
1973
+ description: "Uses your existing machine credentials managed by Git Credential Manager."
1974
+ },
1975
+ {
1976
+ name: "PAT Token",
1977
+ value: "pat",
1978
+ description: "Uses a Personal Access Token you provide. The PAT is stored securely in the OS credential store."
1979
+ }
1980
+ ]
1981
+ });
1982
+ }
1983
+ async function promptPat() {
1984
+ return password({
1985
+ message: "Enter your Personal Access Token (PAT):",
1986
+ mask: "*",
1987
+ validate: (value) => {
1988
+ const error = validatePat(value);
1989
+ return error ?? true;
1990
+ }
1991
+ });
1992
+ }
1993
+ async function promptProjectSelection(projects) {
1994
+ return select({
1995
+ message: "Select a project:",
1996
+ choices: projects.map((p) => ({
1997
+ name: p.name,
1998
+ value: p,
1999
+ description: p.description
2000
+ }))
2001
+ });
2002
+ }
2003
+ async function promptCloneRoot() {
2004
+ const cwd = process.cwd();
2005
+ const answer = await input({
2006
+ message: `Clone destination folder: (press Enter for "${cwd}")`,
2007
+ validate: (value) => {
2008
+ const resolved = value?.trim() || cwd;
2009
+ const error = validateCloneRoot(resolved);
2010
+ return error ?? true;
2011
+ },
2012
+ transformer: (value) => {
2013
+ return value?.trim() ? path.normalize(value.trim()) : "";
2014
+ }
2015
+ });
2016
+ return answer.trim() || cwd;
2017
+ }
2018
+
2019
+ // src/cli/formatters/output.formatter.ts
2020
+ var Formatter = {
2021
+ success(message) {
2022
+ console.log(`
2023
+ \u2714 ${message}`);
2024
+ },
2025
+ error(message) {
2026
+ console.error(`
2027
+ \u2716 ${message}`);
2028
+ },
2029
+ info(message) {
2030
+ console.log(` ${message}`);
2031
+ },
2032
+ warn(message) {
2033
+ console.warn(`
2034
+ \u26A0 ${message}`);
2035
+ },
2036
+ section(title) {
2037
+ console.log(`
2038
+ ${title}`);
2039
+ console.log("\u2500".repeat(title.length));
2040
+ },
2041
+ config(data) {
2042
+ const entries = Object.entries(data);
2043
+ if (entries.length === 0) {
2044
+ console.log(" (no configuration saved)");
2045
+ return;
2046
+ }
2047
+ const maxKey = Math.max(...entries.map(([k]) => k.length));
2048
+ for (const [key, value] of entries) {
2049
+ console.log(` ${key.padEnd(maxKey)} ${value}`);
2050
+ }
2051
+ },
2052
+ repoList(repos) {
2053
+ repos.forEach((name, i) => {
2054
+ console.log(` ${String(i + 1).padStart(3)}. ${name}`);
2055
+ });
2056
+ }
2057
+ };
2058
+
2059
+ // src/cli/commands/init.command.ts
2060
+ function registerInitCommand(program2) {
2061
+ program2.command("init").description(
2062
+ "Run first-time setup: configure your Azure DevOps organization, project, and authentication."
2063
+ ).action(async () => {
2064
+ try {
2065
+ Formatter.section("adograb \u2014 First-time Setup");
2066
+ const configStore = new ConfStore();
2067
+ const secretStore = new KeytarStore();
2068
+ const adoClient = new AdoClient();
2069
+ const orgUrl = await promptOrgUrl();
2070
+ const authMode = await promptAuthMode();
2071
+ let pat;
2072
+ if (authMode === "pat") {
2073
+ pat = await promptPat();
2074
+ }
2075
+ Formatter.info("Connecting to Azure DevOps...");
2076
+ const authProvider = authMode === "pat" && pat ? new PatAuthHeaderProvider(pat) : new DefaultAuthHeaderProvider(orgUrl);
2077
+ const listProjectsUseCase = new ListProjectsUseCase(adoClient, authProvider);
2078
+ const projects = await listProjectsUseCase.execute({ orgUrl });
2079
+ if (projects.length === 0) {
2080
+ Formatter.error(
2081
+ "No projects found in this organization. Check your access permissions."
2082
+ );
2083
+ process.exit(1);
2084
+ }
2085
+ const selectedProject = await promptProjectSelection(projects);
2086
+ const cloneRoot = await promptCloneRoot();
2087
+ const initializeToolUseCase = new InitializeToolUseCase(configStore, secretStore);
2088
+ await initializeToolUseCase.execute({
2089
+ orgUrl,
2090
+ projectId: selectedProject.id,
2091
+ projectName: selectedProject.name,
2092
+ authMode,
2093
+ pat,
2094
+ cloneRoot
2095
+ });
2096
+ Formatter.success(
2097
+ `Setup complete! Project "${selectedProject.name}" saved.
2098
+ Repositories will be cloned to: ${cloneRoot}
2099
+
2100
+ Run 'adograb' to browse and clone repositories.`
2101
+ );
2102
+ } catch (error) {
2103
+ if (error instanceof AppError) {
2104
+ Formatter.error(error.message);
2105
+ } else if (error instanceof Error) {
2106
+ if (error.message.includes("User force closed")) {
2107
+ Formatter.warn("Setup cancelled.");
2108
+ } else {
2109
+ Formatter.error(error.message);
2110
+ }
2111
+ } else {
2112
+ Formatter.error("An unexpected error occurred during setup.");
2113
+ }
2114
+ process.exit(1);
2115
+ }
2116
+ });
2117
+ }
2118
+
2119
+ // src/infrastructure/git/git-service.ts
2120
+ import { execa as execa2 } from "execa";
2121
+ var GitService = class {
2122
+ async clone(options) {
2123
+ const { cloneUrl, targetPath, pat } = options;
2124
+ const url = pat ? this.embedPatInUrl(cloneUrl, pat) : cloneUrl;
2125
+ try {
2126
+ await execa2("git", ["clone", url, targetPath], {
2127
+ stdio: "pipe"
2128
+ });
2129
+ } catch (error) {
2130
+ const cause = error instanceof Error ? error : void 0;
2131
+ const stderr = error && typeof error === "object" && "stderr" in error && typeof error.stderr === "string" ? error.stderr : "";
2132
+ if (stderr.includes("Authentication failed") || stderr.includes("could not read Username")) {
2133
+ throw new CloneError(
2134
+ "Authentication failed during clone. Check your credentials or run `adograb auth switch`.",
2135
+ cause
2136
+ );
2137
+ }
2138
+ if (stderr.includes("Repository not found") || stderr.includes("not found")) {
2139
+ throw new CloneError(
2140
+ `Repository not found or you do not have access to it.`,
2141
+ cause
2142
+ );
2143
+ }
2144
+ const message = stderr || (cause?.message ?? "git clone failed. Check your network connection and permissions.");
2145
+ throw new CloneError(message, cause);
2146
+ }
2147
+ }
2148
+ embedPatInUrl(remoteUrl, pat) {
2149
+ const url = new URL(remoteUrl);
2150
+ url.username = "";
2151
+ url.password = pat;
2152
+ return url.toString();
2153
+ }
2154
+ };
2155
+
2156
+ // src/application/use-cases/validate-setup.use-case.ts
2157
+ var ValidateSetupUseCase = class {
2158
+ constructor(configStore) {
2159
+ this.configStore = configStore;
2160
+ }
2161
+ execute() {
2162
+ const orgUrl = this.configStore.get(CONFIG_KEYS.ORG_URL);
2163
+ const projectId = this.configStore.get(CONFIG_KEYS.PROJECT_ID);
2164
+ const projectName = this.configStore.get(CONFIG_KEYS.PROJECT_NAME);
2165
+ const authMode = this.configStore.get(CONFIG_KEYS.AUTH_MODE);
2166
+ const cloneRoot = this.configStore.get(CONFIG_KEYS.CLONE_ROOT);
2167
+ if (!orgUrl || !projectId || !projectName || !authMode || !cloneRoot) {
2168
+ throw new MissingConfigError();
2169
+ }
2170
+ return { orgUrl, projectId, projectName, authMode, cloneRoot };
2171
+ }
2172
+ };
2173
+
2174
+ // src/application/use-cases/list-repositories.use-case.ts
2175
+ var ListRepositoriesUseCase = class {
2176
+ constructor(adoClient, authProvider) {
2177
+ this.adoClient = adoClient;
2178
+ this.authProvider = authProvider;
2179
+ }
2180
+ async execute(input2) {
2181
+ const authHeader = await this.authProvider.getAuthHeader();
2182
+ return this.adoClient.getRepositories(input2.orgUrl, input2.projectId, authHeader);
2183
+ }
2184
+ };
2185
+
2186
+ // src/application/use-cases/clone-repository.use-case.ts
2187
+ import path2 from "path";
2188
+ import fs from "fs";
2189
+ var CloneRepositoryUseCase = class {
2190
+ constructor(adoClient, authProvider, gitService, secretStore) {
2191
+ this.adoClient = adoClient;
2192
+ this.authProvider = authProvider;
2193
+ this.gitService = gitService;
2194
+ this.secretStore = secretStore;
2195
+ }
2196
+ async execute(input2) {
2197
+ const authHeader = await this.authProvider.getAuthHeader();
2198
+ const repository = await this.adoClient.getRepositoryByName(
2199
+ input2.orgUrl,
2200
+ input2.projectId,
2201
+ input2.repoName,
2202
+ authHeader
2203
+ );
2204
+ if (!repository) {
2205
+ throw new RepositoryNotFoundError(input2.repoName);
2206
+ }
2207
+ const targetPath = path2.join(input2.cloneRoot, repository.name);
2208
+ if (fs.existsSync(targetPath)) {
2209
+ throw new CloneError(
2210
+ `Directory already exists: ${targetPath}
2211
+ Delete or rename it, then try again.`
2212
+ );
2213
+ }
2214
+ let pat;
2215
+ if (input2.authMode === "pat") {
2216
+ const stored = await this.secretStore.getSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
2217
+ if (stored) {
2218
+ pat = stored;
2219
+ }
2220
+ }
2221
+ await this.gitService.clone({
2222
+ cloneUrl: repository.remoteUrl,
2223
+ targetPath,
2224
+ pat
2225
+ });
2226
+ return { repository, clonedTo: targetPath };
2227
+ }
2228
+ };
2229
+
2230
+ // node_modules/@inquirer/core/dist/esm/lib/key.js
2231
+ var isUpKey = (key, keybindings = []) => (
2232
+ // The up key
2233
+ key.name === "up" || // Vim keybinding: hjkl keys map to left/down/up/right
2234
+ keybindings.includes("vim") && key.name === "k" || // Emacs keybinding: Ctrl+P means "previous" in Emacs navigation conventions
2235
+ keybindings.includes("emacs") && key.ctrl && key.name === "p"
2236
+ );
2237
+ var isDownKey = (key, keybindings = []) => (
2238
+ // The down key
2239
+ key.name === "down" || // Vim keybinding: hjkl keys map to left/down/up/right
2240
+ keybindings.includes("vim") && key.name === "j" || // Emacs keybinding: Ctrl+N means "next" in Emacs navigation conventions
2241
+ keybindings.includes("emacs") && key.ctrl && key.name === "n"
2242
+ );
2243
+ var isTabKey = (key) => key.name === "tab";
2244
+ var isEnterKey = (key) => key.name === "enter" || key.name === "return";
2245
+
2246
+ // node_modules/@inquirer/core/dist/esm/lib/errors.js
2247
+ var AbortPromptError = class extends Error {
2248
+ name = "AbortPromptError";
2249
+ message = "Prompt was aborted";
2250
+ constructor(options) {
2251
+ super();
2252
+ this.cause = options?.cause;
2253
+ }
2254
+ };
2255
+ var CancelPromptError = class extends Error {
2256
+ name = "CancelPromptError";
2257
+ message = "Prompt was canceled";
2258
+ };
2259
+ var ExitPromptError = class extends Error {
2260
+ name = "ExitPromptError";
2261
+ };
2262
+ var HookError = class extends Error {
2263
+ name = "HookError";
2264
+ };
2265
+ var ValidationError = class extends Error {
2266
+ name = "ValidationError";
2267
+ };
2268
+
2269
+ // node_modules/@inquirer/core/dist/esm/lib/use-state.js
2270
+ import { AsyncResource as AsyncResource2 } from "async_hooks";
2271
+
2272
+ // node_modules/@inquirer/core/dist/esm/lib/hook-engine.js
2273
+ import { AsyncLocalStorage, AsyncResource } from "async_hooks";
2274
+ var hookStorage = new AsyncLocalStorage();
2275
+ function createStore(rl) {
2276
+ const store = {
2277
+ rl,
2278
+ hooks: [],
2279
+ hooksCleanup: [],
2280
+ hooksEffect: [],
2281
+ index: 0,
2282
+ handleChange() {
2283
+ }
2284
+ };
2285
+ return store;
2286
+ }
2287
+ function withHooks(rl, cb) {
2288
+ const store = createStore(rl);
2289
+ return hookStorage.run(store, () => {
2290
+ function cycle(render) {
2291
+ store.handleChange = () => {
2292
+ store.index = 0;
2293
+ render();
2294
+ };
2295
+ store.handleChange();
2296
+ }
2297
+ return cb(cycle);
2298
+ });
2299
+ }
2300
+ function getStore() {
2301
+ const store = hookStorage.getStore();
2302
+ if (!store) {
2303
+ throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
2304
+ }
2305
+ return store;
2306
+ }
2307
+ function readline() {
2308
+ return getStore().rl;
2309
+ }
2310
+ function withUpdates(fn) {
2311
+ const wrapped = (...args) => {
2312
+ const store = getStore();
2313
+ let shouldUpdate = false;
2314
+ const oldHandleChange = store.handleChange;
2315
+ store.handleChange = () => {
2316
+ shouldUpdate = true;
2317
+ };
2318
+ const returnValue = fn(...args);
2319
+ if (shouldUpdate) {
2320
+ oldHandleChange();
2321
+ }
2322
+ store.handleChange = oldHandleChange;
2323
+ return returnValue;
2324
+ };
2325
+ return AsyncResource.bind(wrapped);
2326
+ }
2327
+ function withPointer(cb) {
2328
+ const store = getStore();
2329
+ const { index } = store;
2330
+ const pointer = {
2331
+ get() {
2332
+ return store.hooks[index];
2333
+ },
2334
+ set(value) {
2335
+ store.hooks[index] = value;
2336
+ },
2337
+ initialized: index in store.hooks
2338
+ };
2339
+ const returnValue = cb(pointer);
2340
+ store.index++;
2341
+ return returnValue;
2342
+ }
2343
+ function handleChange() {
2344
+ getStore().handleChange();
2345
+ }
2346
+ var effectScheduler = {
2347
+ queue(cb) {
2348
+ const store = getStore();
2349
+ const { index } = store;
2350
+ store.hooksEffect.push(() => {
2351
+ store.hooksCleanup[index]?.();
2352
+ const cleanFn = cb(readline());
2353
+ if (cleanFn != null && typeof cleanFn !== "function") {
2354
+ throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
2355
+ }
2356
+ store.hooksCleanup[index] = cleanFn;
2357
+ });
2358
+ },
2359
+ run() {
2360
+ const store = getStore();
2361
+ withUpdates(() => {
2362
+ store.hooksEffect.forEach((effect) => {
2363
+ effect();
2364
+ });
2365
+ store.hooksEffect.length = 0;
2366
+ })();
2367
+ },
2368
+ clearAll() {
2369
+ const store = getStore();
2370
+ store.hooksCleanup.forEach((cleanFn) => {
2371
+ cleanFn?.();
2372
+ });
2373
+ store.hooksEffect.length = 0;
2374
+ store.hooksCleanup.length = 0;
2375
+ }
2376
+ };
2377
+
2378
+ // node_modules/@inquirer/core/dist/esm/lib/use-state.js
2379
+ function useState(defaultValue) {
2380
+ return withPointer((pointer) => {
2381
+ const setState = AsyncResource2.bind(function setState2(newValue) {
2382
+ if (pointer.get() !== newValue) {
2383
+ pointer.set(newValue);
2384
+ handleChange();
2385
+ }
2386
+ });
2387
+ if (pointer.initialized) {
2388
+ return [pointer.get(), setState];
2389
+ }
2390
+ const value = typeof defaultValue === "function" ? defaultValue() : defaultValue;
2391
+ pointer.set(value);
2392
+ return [value, setState];
2393
+ });
2394
+ }
2395
+
2396
+ // node_modules/@inquirer/core/dist/esm/lib/use-effect.js
2397
+ function useEffect(cb, depArray) {
2398
+ withPointer((pointer) => {
2399
+ const oldDeps = pointer.get();
2400
+ const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
2401
+ if (hasChanged) {
2402
+ effectScheduler.queue(cb);
2403
+ }
2404
+ pointer.set(depArray);
2405
+ });
2406
+ }
2407
+
2408
+ // node_modules/@inquirer/core/dist/esm/lib/theme.js
2409
+ var import_yoctocolors_cjs = __toESM(require_yoctocolors_cjs(), 1);
2410
+
2411
+ // node_modules/@inquirer/figures/dist/esm/index.js
2412
+ import process2 from "process";
2413
+ function isUnicodeSupported() {
2414
+ if (process2.platform !== "win32") {
2415
+ return process2.env["TERM"] !== "linux";
2416
+ }
2417
+ return Boolean(process2.env["WT_SESSION"]) || // Windows Terminal
2418
+ Boolean(process2.env["TERMINUS_SUBLIME"]) || // Terminus (<0.2.27)
2419
+ process2.env["ConEmuTask"] === "{cmd::Cmder}" || // ConEmu and cmder
2420
+ process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
2421
+ }
2422
+ var common = {
2423
+ circleQuestionMark: "(?)",
2424
+ questionMarkPrefix: "(?)",
2425
+ square: "\u2588",
2426
+ squareDarkShade: "\u2593",
2427
+ squareMediumShade: "\u2592",
2428
+ squareLightShade: "\u2591",
2429
+ squareTop: "\u2580",
2430
+ squareBottom: "\u2584",
2431
+ squareLeft: "\u258C",
2432
+ squareRight: "\u2590",
2433
+ squareCenter: "\u25A0",
2434
+ bullet: "\u25CF",
2435
+ dot: "\u2024",
2436
+ ellipsis: "\u2026",
2437
+ pointerSmall: "\u203A",
2438
+ triangleUp: "\u25B2",
2439
+ triangleUpSmall: "\u25B4",
2440
+ triangleDown: "\u25BC",
2441
+ triangleDownSmall: "\u25BE",
2442
+ triangleLeftSmall: "\u25C2",
2443
+ triangleRightSmall: "\u25B8",
2444
+ home: "\u2302",
2445
+ heart: "\u2665",
2446
+ musicNote: "\u266A",
2447
+ musicNoteBeamed: "\u266B",
2448
+ arrowUp: "\u2191",
2449
+ arrowDown: "\u2193",
2450
+ arrowLeft: "\u2190",
2451
+ arrowRight: "\u2192",
2452
+ arrowLeftRight: "\u2194",
2453
+ arrowUpDown: "\u2195",
2454
+ almostEqual: "\u2248",
2455
+ notEqual: "\u2260",
2456
+ lessOrEqual: "\u2264",
2457
+ greaterOrEqual: "\u2265",
2458
+ identical: "\u2261",
2459
+ infinity: "\u221E",
2460
+ subscriptZero: "\u2080",
2461
+ subscriptOne: "\u2081",
2462
+ subscriptTwo: "\u2082",
2463
+ subscriptThree: "\u2083",
2464
+ subscriptFour: "\u2084",
2465
+ subscriptFive: "\u2085",
2466
+ subscriptSix: "\u2086",
2467
+ subscriptSeven: "\u2087",
2468
+ subscriptEight: "\u2088",
2469
+ subscriptNine: "\u2089",
2470
+ oneHalf: "\xBD",
2471
+ oneThird: "\u2153",
2472
+ oneQuarter: "\xBC",
2473
+ oneFifth: "\u2155",
2474
+ oneSixth: "\u2159",
2475
+ oneEighth: "\u215B",
2476
+ twoThirds: "\u2154",
2477
+ twoFifths: "\u2156",
2478
+ threeQuarters: "\xBE",
2479
+ threeFifths: "\u2157",
2480
+ threeEighths: "\u215C",
2481
+ fourFifths: "\u2158",
2482
+ fiveSixths: "\u215A",
2483
+ fiveEighths: "\u215D",
2484
+ sevenEighths: "\u215E",
2485
+ line: "\u2500",
2486
+ lineBold: "\u2501",
2487
+ lineDouble: "\u2550",
2488
+ lineDashed0: "\u2504",
2489
+ lineDashed1: "\u2505",
2490
+ lineDashed2: "\u2508",
2491
+ lineDashed3: "\u2509",
2492
+ lineDashed4: "\u254C",
2493
+ lineDashed5: "\u254D",
2494
+ lineDashed6: "\u2574",
2495
+ lineDashed7: "\u2576",
2496
+ lineDashed8: "\u2578",
2497
+ lineDashed9: "\u257A",
2498
+ lineDashed10: "\u257C",
2499
+ lineDashed11: "\u257E",
2500
+ lineDashed12: "\u2212",
2501
+ lineDashed13: "\u2013",
2502
+ lineDashed14: "\u2010",
2503
+ lineDashed15: "\u2043",
2504
+ lineVertical: "\u2502",
2505
+ lineVerticalBold: "\u2503",
2506
+ lineVerticalDouble: "\u2551",
2507
+ lineVerticalDashed0: "\u2506",
2508
+ lineVerticalDashed1: "\u2507",
2509
+ lineVerticalDashed2: "\u250A",
2510
+ lineVerticalDashed3: "\u250B",
2511
+ lineVerticalDashed4: "\u254E",
2512
+ lineVerticalDashed5: "\u254F",
2513
+ lineVerticalDashed6: "\u2575",
2514
+ lineVerticalDashed7: "\u2577",
2515
+ lineVerticalDashed8: "\u2579",
2516
+ lineVerticalDashed9: "\u257B",
2517
+ lineVerticalDashed10: "\u257D",
2518
+ lineVerticalDashed11: "\u257F",
2519
+ lineDownLeft: "\u2510",
2520
+ lineDownLeftArc: "\u256E",
2521
+ lineDownBoldLeftBold: "\u2513",
2522
+ lineDownBoldLeft: "\u2512",
2523
+ lineDownLeftBold: "\u2511",
2524
+ lineDownDoubleLeftDouble: "\u2557",
2525
+ lineDownDoubleLeft: "\u2556",
2526
+ lineDownLeftDouble: "\u2555",
2527
+ lineDownRight: "\u250C",
2528
+ lineDownRightArc: "\u256D",
2529
+ lineDownBoldRightBold: "\u250F",
2530
+ lineDownBoldRight: "\u250E",
2531
+ lineDownRightBold: "\u250D",
2532
+ lineDownDoubleRightDouble: "\u2554",
2533
+ lineDownDoubleRight: "\u2553",
2534
+ lineDownRightDouble: "\u2552",
2535
+ lineUpLeft: "\u2518",
2536
+ lineUpLeftArc: "\u256F",
2537
+ lineUpBoldLeftBold: "\u251B",
2538
+ lineUpBoldLeft: "\u251A",
2539
+ lineUpLeftBold: "\u2519",
2540
+ lineUpDoubleLeftDouble: "\u255D",
2541
+ lineUpDoubleLeft: "\u255C",
2542
+ lineUpLeftDouble: "\u255B",
2543
+ lineUpRight: "\u2514",
2544
+ lineUpRightArc: "\u2570",
2545
+ lineUpBoldRightBold: "\u2517",
2546
+ lineUpBoldRight: "\u2516",
2547
+ lineUpRightBold: "\u2515",
2548
+ lineUpDoubleRightDouble: "\u255A",
2549
+ lineUpDoubleRight: "\u2559",
2550
+ lineUpRightDouble: "\u2558",
2551
+ lineUpDownLeft: "\u2524",
2552
+ lineUpBoldDownBoldLeftBold: "\u252B",
2553
+ lineUpBoldDownBoldLeft: "\u2528",
2554
+ lineUpDownLeftBold: "\u2525",
2555
+ lineUpBoldDownLeftBold: "\u2529",
2556
+ lineUpDownBoldLeftBold: "\u252A",
2557
+ lineUpDownBoldLeft: "\u2527",
2558
+ lineUpBoldDownLeft: "\u2526",
2559
+ lineUpDoubleDownDoubleLeftDouble: "\u2563",
2560
+ lineUpDoubleDownDoubleLeft: "\u2562",
2561
+ lineUpDownLeftDouble: "\u2561",
2562
+ lineUpDownRight: "\u251C",
2563
+ lineUpBoldDownBoldRightBold: "\u2523",
2564
+ lineUpBoldDownBoldRight: "\u2520",
2565
+ lineUpDownRightBold: "\u251D",
2566
+ lineUpBoldDownRightBold: "\u2521",
2567
+ lineUpDownBoldRightBold: "\u2522",
2568
+ lineUpDownBoldRight: "\u251F",
2569
+ lineUpBoldDownRight: "\u251E",
2570
+ lineUpDoubleDownDoubleRightDouble: "\u2560",
2571
+ lineUpDoubleDownDoubleRight: "\u255F",
2572
+ lineUpDownRightDouble: "\u255E",
2573
+ lineDownLeftRight: "\u252C",
2574
+ lineDownBoldLeftBoldRightBold: "\u2533",
2575
+ lineDownLeftBoldRightBold: "\u252F",
2576
+ lineDownBoldLeftRight: "\u2530",
2577
+ lineDownBoldLeftBoldRight: "\u2531",
2578
+ lineDownBoldLeftRightBold: "\u2532",
2579
+ lineDownLeftRightBold: "\u252E",
2580
+ lineDownLeftBoldRight: "\u252D",
2581
+ lineDownDoubleLeftDoubleRightDouble: "\u2566",
2582
+ lineDownDoubleLeftRight: "\u2565",
2583
+ lineDownLeftDoubleRightDouble: "\u2564",
2584
+ lineUpLeftRight: "\u2534",
2585
+ lineUpBoldLeftBoldRightBold: "\u253B",
2586
+ lineUpLeftBoldRightBold: "\u2537",
2587
+ lineUpBoldLeftRight: "\u2538",
2588
+ lineUpBoldLeftBoldRight: "\u2539",
2589
+ lineUpBoldLeftRightBold: "\u253A",
2590
+ lineUpLeftRightBold: "\u2536",
2591
+ lineUpLeftBoldRight: "\u2535",
2592
+ lineUpDoubleLeftDoubleRightDouble: "\u2569",
2593
+ lineUpDoubleLeftRight: "\u2568",
2594
+ lineUpLeftDoubleRightDouble: "\u2567",
2595
+ lineUpDownLeftRight: "\u253C",
2596
+ lineUpBoldDownBoldLeftBoldRightBold: "\u254B",
2597
+ lineUpDownBoldLeftBoldRightBold: "\u2548",
2598
+ lineUpBoldDownLeftBoldRightBold: "\u2547",
2599
+ lineUpBoldDownBoldLeftRightBold: "\u254A",
2600
+ lineUpBoldDownBoldLeftBoldRight: "\u2549",
2601
+ lineUpBoldDownLeftRight: "\u2540",
2602
+ lineUpDownBoldLeftRight: "\u2541",
2603
+ lineUpDownLeftBoldRight: "\u253D",
2604
+ lineUpDownLeftRightBold: "\u253E",
2605
+ lineUpBoldDownBoldLeftRight: "\u2542",
2606
+ lineUpDownLeftBoldRightBold: "\u253F",
2607
+ lineUpBoldDownLeftBoldRight: "\u2543",
2608
+ lineUpBoldDownLeftRightBold: "\u2544",
2609
+ lineUpDownBoldLeftBoldRight: "\u2545",
2610
+ lineUpDownBoldLeftRightBold: "\u2546",
2611
+ lineUpDoubleDownDoubleLeftDoubleRightDouble: "\u256C",
2612
+ lineUpDoubleDownDoubleLeftRight: "\u256B",
2613
+ lineUpDownLeftDoubleRightDouble: "\u256A",
2614
+ lineCross: "\u2573",
2615
+ lineBackslash: "\u2572",
2616
+ lineSlash: "\u2571"
2617
+ };
2618
+ var specialMainSymbols = {
2619
+ tick: "\u2714",
2620
+ info: "\u2139",
2621
+ warning: "\u26A0",
2622
+ cross: "\u2718",
2623
+ squareSmall: "\u25FB",
2624
+ squareSmallFilled: "\u25FC",
2625
+ circle: "\u25EF",
2626
+ circleFilled: "\u25C9",
2627
+ circleDotted: "\u25CC",
2628
+ circleDouble: "\u25CE",
2629
+ circleCircle: "\u24DE",
2630
+ circleCross: "\u24E7",
2631
+ circlePipe: "\u24BE",
2632
+ radioOn: "\u25C9",
2633
+ radioOff: "\u25EF",
2634
+ checkboxOn: "\u2612",
2635
+ checkboxOff: "\u2610",
2636
+ checkboxCircleOn: "\u24E7",
2637
+ checkboxCircleOff: "\u24BE",
2638
+ pointer: "\u276F",
2639
+ triangleUpOutline: "\u25B3",
2640
+ triangleLeft: "\u25C0",
2641
+ triangleRight: "\u25B6",
2642
+ lozenge: "\u25C6",
2643
+ lozengeOutline: "\u25C7",
2644
+ hamburger: "\u2630",
2645
+ smiley: "\u32E1",
2646
+ mustache: "\u0DF4",
2647
+ star: "\u2605",
2648
+ play: "\u25B6",
2649
+ nodejs: "\u2B22",
2650
+ oneSeventh: "\u2150",
2651
+ oneNinth: "\u2151",
2652
+ oneTenth: "\u2152"
2653
+ };
2654
+ var specialFallbackSymbols = {
2655
+ tick: "\u221A",
2656
+ info: "i",
2657
+ warning: "\u203C",
2658
+ cross: "\xD7",
2659
+ squareSmall: "\u25A1",
2660
+ squareSmallFilled: "\u25A0",
2661
+ circle: "( )",
2662
+ circleFilled: "(*)",
2663
+ circleDotted: "( )",
2664
+ circleDouble: "( )",
2665
+ circleCircle: "(\u25CB)",
2666
+ circleCross: "(\xD7)",
2667
+ circlePipe: "(\u2502)",
2668
+ radioOn: "(*)",
2669
+ radioOff: "( )",
2670
+ checkboxOn: "[\xD7]",
2671
+ checkboxOff: "[ ]",
2672
+ checkboxCircleOn: "(\xD7)",
2673
+ checkboxCircleOff: "( )",
2674
+ pointer: ">",
2675
+ triangleUpOutline: "\u2206",
2676
+ triangleLeft: "\u25C4",
2677
+ triangleRight: "\u25BA",
2678
+ lozenge: "\u2666",
2679
+ lozengeOutline: "\u25CA",
2680
+ hamburger: "\u2261",
2681
+ smiley: "\u263A",
2682
+ mustache: "\u250C\u2500\u2510",
2683
+ star: "\u2736",
2684
+ play: "\u25BA",
2685
+ nodejs: "\u2666",
2686
+ oneSeventh: "1/7",
2687
+ oneNinth: "1/9",
2688
+ oneTenth: "1/10"
2689
+ };
2690
+ var mainSymbols = {
2691
+ ...common,
2692
+ ...specialMainSymbols
2693
+ };
2694
+ var fallbackSymbols = {
2695
+ ...common,
2696
+ ...specialFallbackSymbols
2697
+ };
2698
+ var shouldUseMain = isUnicodeSupported();
2699
+ var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
2700
+ var esm_default = figures;
2701
+ var replacements = Object.entries(specialMainSymbols);
2702
+
2703
+ // node_modules/@inquirer/core/dist/esm/lib/theme.js
2704
+ var defaultTheme = {
2705
+ prefix: {
2706
+ idle: import_yoctocolors_cjs.default.blue("?"),
2707
+ done: import_yoctocolors_cjs.default.green(esm_default.tick)
2708
+ },
2709
+ spinner: {
2710
+ interval: 80,
2711
+ frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"].map((frame) => import_yoctocolors_cjs.default.yellow(frame))
2712
+ },
2713
+ style: {
2714
+ answer: import_yoctocolors_cjs.default.cyan,
2715
+ message: import_yoctocolors_cjs.default.bold,
2716
+ error: (text) => import_yoctocolors_cjs.default.red(`> ${text}`),
2717
+ defaultAnswer: (text) => import_yoctocolors_cjs.default.dim(`(${text})`),
2718
+ help: import_yoctocolors_cjs.default.dim,
2719
+ highlight: import_yoctocolors_cjs.default.cyan,
2720
+ key: (text) => import_yoctocolors_cjs.default.cyan(import_yoctocolors_cjs.default.bold(`<${text}>`))
2721
+ }
2722
+ };
2723
+
2724
+ // node_modules/@inquirer/core/dist/esm/lib/make-theme.js
2725
+ function isPlainObject(value) {
2726
+ if (typeof value !== "object" || value === null)
2727
+ return false;
2728
+ let proto = value;
2729
+ while (Object.getPrototypeOf(proto) !== null) {
2730
+ proto = Object.getPrototypeOf(proto);
2731
+ }
2732
+ return Object.getPrototypeOf(value) === proto;
2733
+ }
2734
+ function deepMerge(...objects) {
2735
+ const output = {};
2736
+ for (const obj of objects) {
2737
+ for (const [key, value] of Object.entries(obj)) {
2738
+ const prevValue = output[key];
2739
+ output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
2740
+ }
2741
+ }
2742
+ return output;
2743
+ }
2744
+ function makeTheme(...themes) {
2745
+ const themesToMerge = [
2746
+ defaultTheme,
2747
+ ...themes.filter((theme) => theme != null)
2748
+ ];
2749
+ return deepMerge(...themesToMerge);
2750
+ }
2751
+
2752
+ // node_modules/@inquirer/core/dist/esm/lib/use-prefix.js
2753
+ function usePrefix({ status = "idle", theme }) {
2754
+ const [showLoader, setShowLoader] = useState(false);
2755
+ const [tick, setTick] = useState(0);
2756
+ const { prefix, spinner } = makeTheme(theme);
2757
+ useEffect(() => {
2758
+ if (status === "loading") {
2759
+ let tickInterval;
2760
+ let inc = -1;
2761
+ const delayTimeout = setTimeout(() => {
2762
+ setShowLoader(true);
2763
+ tickInterval = setInterval(() => {
2764
+ inc = inc + 1;
2765
+ setTick(inc % spinner.frames.length);
2766
+ }, spinner.interval);
2767
+ }, 300);
2768
+ return () => {
2769
+ clearTimeout(delayTimeout);
2770
+ clearInterval(tickInterval);
2771
+ };
2772
+ } else {
2773
+ setShowLoader(false);
2774
+ }
2775
+ }, [status]);
2776
+ if (showLoader) {
2777
+ return spinner.frames[tick];
2778
+ }
2779
+ const iconName = status === "loading" ? "idle" : status;
2780
+ return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
2781
+ }
2782
+
2783
+ // node_modules/@inquirer/core/dist/esm/lib/use-memo.js
2784
+ function useMemo(fn, dependencies) {
2785
+ return withPointer((pointer) => {
2786
+ const prev = pointer.get();
2787
+ if (!prev || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
2788
+ const value = fn();
2789
+ pointer.set({ value, dependencies });
2790
+ return value;
2791
+ }
2792
+ return prev.value;
2793
+ });
2794
+ }
2795
+
2796
+ // node_modules/@inquirer/core/dist/esm/lib/use-ref.js
2797
+ function useRef(val) {
2798
+ return useState({ current: val })[0];
2799
+ }
2800
+
2801
+ // node_modules/@inquirer/core/dist/esm/lib/use-keypress.js
2802
+ function useKeypress(userHandler) {
2803
+ const signal = useRef(userHandler);
2804
+ signal.current = userHandler;
2805
+ useEffect((rl) => {
2806
+ let ignore = false;
2807
+ const handler = withUpdates((_input, event) => {
2808
+ if (ignore)
2809
+ return;
2810
+ void signal.current(event, rl);
2811
+ });
2812
+ rl.input.on("keypress", handler);
2813
+ return () => {
2814
+ ignore = true;
2815
+ rl.input.removeListener("keypress", handler);
2816
+ };
2817
+ }, []);
2818
+ }
2819
+
2820
+ // node_modules/@inquirer/core/dist/esm/lib/utils.js
2821
+ var import_cli_width = __toESM(require_cli_width(), 1);
2822
+ var import_wrap_ansi = __toESM(require_wrap_ansi(), 1);
2823
+ function breakLines(content, width) {
2824
+ return content.split("\n").flatMap((line) => (0, import_wrap_ansi.default)(line, width, { trim: false, hard: true }).split("\n").map((str) => str.trimEnd())).join("\n");
2825
+ }
2826
+ function readlineWidth() {
2827
+ return (0, import_cli_width.default)({ defaultWidth: 80, output: readline().output });
2828
+ }
2829
+
2830
+ // node_modules/@inquirer/core/dist/esm/lib/pagination/use-pagination.js
2831
+ function usePointerPosition({ active, renderedItems, pageSize, loop }) {
2832
+ const state = useRef({
2833
+ lastPointer: active,
2834
+ lastActive: void 0
2835
+ });
2836
+ const { lastPointer, lastActive } = state.current;
2837
+ const middle = Math.floor(pageSize / 2);
2838
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
2839
+ const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
2840
+ let pointer = defaultPointerPosition;
2841
+ if (renderedLength > pageSize) {
2842
+ if (loop) {
2843
+ pointer = lastPointer;
2844
+ if (
2845
+ // First render, skip this logic.
2846
+ lastActive != null && // Only move the pointer down when the user moves down.
2847
+ lastActive < active && // Check user didn't move up across page boundary.
2848
+ active - lastActive < pageSize
2849
+ ) {
2850
+ pointer = Math.min(
2851
+ // Furthest allowed position for the pointer is the middle of the list
2852
+ middle,
2853
+ Math.abs(active - lastActive) === 1 ? Math.min(
2854
+ // Move the pointer at most the height of the last active item.
2855
+ lastPointer + (renderedItems[lastActive]?.length ?? 0),
2856
+ // If the user moved by one item, move the pointer to the natural position of the active item as
2857
+ // long as it doesn't move the cursor up.
2858
+ Math.max(defaultPointerPosition, lastPointer)
2859
+ ) : (
2860
+ // Otherwise, move the pointer down by the difference between the active and last active item.
2861
+ lastPointer + active - lastActive
2862
+ )
2863
+ );
2864
+ }
2865
+ } else {
2866
+ const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
2867
+ pointer = spaceUnderActive < pageSize - middle ? (
2868
+ // If the active item is near the end of the list, progressively move the cursor towards the end.
2869
+ pageSize - spaceUnderActive
2870
+ ) : (
2871
+ // Otherwise, progressively move the pointer to the middle of the list.
2872
+ Math.min(defaultPointerPosition, middle)
2873
+ );
2874
+ }
2875
+ }
2876
+ state.current.lastPointer = pointer;
2877
+ state.current.lastActive = active;
2878
+ return pointer;
2879
+ }
2880
+ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
2881
+ const width = readlineWidth();
2882
+ const bound = (num) => (num % items.length + items.length) % items.length;
2883
+ const renderedItems = items.map((item, index) => {
2884
+ if (item == null)
2885
+ return [];
2886
+ return breakLines(renderItem({ item, index, isActive: index === active }), width).split("\n");
2887
+ });
2888
+ const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
2889
+ const renderItemAtIndex = (index) => renderedItems[index] ?? [];
2890
+ const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
2891
+ const activeItem = renderItemAtIndex(active).slice(0, pageSize);
2892
+ const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
2893
+ const pageBuffer = Array.from({ length: pageSize });
2894
+ pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
2895
+ const itemVisited = /* @__PURE__ */ new Set([active]);
2896
+ let bufferPointer = activeItemPosition + activeItem.length;
2897
+ let itemPointer = bound(active + 1);
2898
+ while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
2899
+ const lines = renderItemAtIndex(itemPointer);
2900
+ const linesToAdd = lines.slice(0, pageSize - bufferPointer);
2901
+ pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
2902
+ itemVisited.add(itemPointer);
2903
+ bufferPointer += linesToAdd.length;
2904
+ itemPointer = bound(itemPointer + 1);
2905
+ }
2906
+ bufferPointer = activeItemPosition - 1;
2907
+ itemPointer = bound(active - 1);
2908
+ while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
2909
+ const lines = renderItemAtIndex(itemPointer);
2910
+ const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
2911
+ pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
2912
+ itemVisited.add(itemPointer);
2913
+ bufferPointer -= linesToAdd.length;
2914
+ itemPointer = bound(itemPointer - 1);
2915
+ }
2916
+ return pageBuffer.filter((line) => typeof line === "string").join("\n");
2917
+ }
2918
+
2919
+ // node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
2920
+ var import_mute_stream = __toESM(require_lib(), 1);
2921
+ import * as readline2 from "readline";
2922
+ import { AsyncResource as AsyncResource3 } from "async_hooks";
2923
+
2924
+ // node_modules/signal-exit/dist/mjs/signals.js
2925
+ var signals = [];
2926
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
2927
+ if (process.platform !== "win32") {
2928
+ signals.push(
2929
+ "SIGALRM",
2930
+ "SIGABRT",
2931
+ "SIGVTALRM",
2932
+ "SIGXCPU",
2933
+ "SIGXFSZ",
2934
+ "SIGUSR2",
2935
+ "SIGTRAP",
2936
+ "SIGSYS",
2937
+ "SIGQUIT",
2938
+ "SIGIOT"
2939
+ // should detect profiler and enable/disable accordingly.
2940
+ // see #21
2941
+ // 'SIGPROF'
2942
+ );
2943
+ }
2944
+ if (process.platform === "linux") {
2945
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
2946
+ }
2947
+
2948
+ // node_modules/signal-exit/dist/mjs/index.js
2949
+ var processOk = (process4) => !!process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
2950
+ var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
2951
+ var global = globalThis;
2952
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
2953
+ var Emitter = class {
2954
+ emitted = {
2955
+ afterExit: false,
2956
+ exit: false
2957
+ };
2958
+ listeners = {
2959
+ afterExit: [],
2960
+ exit: []
2961
+ };
2962
+ count = 0;
2963
+ id = Math.random();
2964
+ constructor() {
2965
+ if (global[kExitEmitter]) {
2966
+ return global[kExitEmitter];
2967
+ }
2968
+ ObjectDefineProperty(global, kExitEmitter, {
2969
+ value: this,
2970
+ writable: false,
2971
+ enumerable: false,
2972
+ configurable: false
2973
+ });
2974
+ }
2975
+ on(ev, fn) {
2976
+ this.listeners[ev].push(fn);
2977
+ }
2978
+ removeListener(ev, fn) {
2979
+ const list = this.listeners[ev];
2980
+ const i = list.indexOf(fn);
2981
+ if (i === -1) {
2982
+ return;
2983
+ }
2984
+ if (i === 0 && list.length === 1) {
2985
+ list.length = 0;
2986
+ } else {
2987
+ list.splice(i, 1);
2988
+ }
2989
+ }
2990
+ emit(ev, code, signal) {
2991
+ if (this.emitted[ev]) {
2992
+ return false;
2993
+ }
2994
+ this.emitted[ev] = true;
2995
+ let ret = false;
2996
+ for (const fn of this.listeners[ev]) {
2997
+ ret = fn(code, signal) === true || ret;
2998
+ }
2999
+ if (ev === "exit") {
3000
+ ret = this.emit("afterExit", code, signal) || ret;
3001
+ }
3002
+ return ret;
3003
+ }
3004
+ };
3005
+ var SignalExitBase = class {
3006
+ };
3007
+ var signalExitWrap = (handler) => {
3008
+ return {
3009
+ onExit(cb, opts) {
3010
+ return handler.onExit(cb, opts);
3011
+ },
3012
+ load() {
3013
+ return handler.load();
3014
+ },
3015
+ unload() {
3016
+ return handler.unload();
3017
+ }
3018
+ };
3019
+ };
3020
+ var SignalExitFallback = class extends SignalExitBase {
3021
+ onExit() {
3022
+ return () => {
3023
+ };
3024
+ }
3025
+ load() {
3026
+ }
3027
+ unload() {
3028
+ }
3029
+ };
3030
+ var SignalExit = class extends SignalExitBase {
3031
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
3032
+ // so use a supported signal instead
3033
+ /* c8 ignore start */
3034
+ #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
3035
+ /* c8 ignore stop */
3036
+ #emitter = new Emitter();
3037
+ #process;
3038
+ #originalProcessEmit;
3039
+ #originalProcessReallyExit;
3040
+ #sigListeners = {};
3041
+ #loaded = false;
3042
+ constructor(process4) {
3043
+ super();
3044
+ this.#process = process4;
3045
+ this.#sigListeners = {};
3046
+ for (const sig of signals) {
3047
+ this.#sigListeners[sig] = () => {
3048
+ const listeners = this.#process.listeners(sig);
3049
+ let { count } = this.#emitter;
3050
+ const p = process4;
3051
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
3052
+ count += p.__signal_exit_emitter__.count;
3053
+ }
3054
+ if (listeners.length === count) {
3055
+ this.unload();
3056
+ const ret = this.#emitter.emit("exit", null, sig);
3057
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
3058
+ if (!ret)
3059
+ process4.kill(process4.pid, s);
3060
+ }
3061
+ };
3062
+ }
3063
+ this.#originalProcessReallyExit = process4.reallyExit;
3064
+ this.#originalProcessEmit = process4.emit;
3065
+ }
3066
+ onExit(cb, opts) {
3067
+ if (!processOk(this.#process)) {
3068
+ return () => {
3069
+ };
3070
+ }
3071
+ if (this.#loaded === false) {
3072
+ this.load();
3073
+ }
3074
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
3075
+ this.#emitter.on(ev, cb);
3076
+ return () => {
3077
+ this.#emitter.removeListener(ev, cb);
3078
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
3079
+ this.unload();
3080
+ }
3081
+ };
3082
+ }
3083
+ load() {
3084
+ if (this.#loaded) {
3085
+ return;
3086
+ }
3087
+ this.#loaded = true;
3088
+ this.#emitter.count += 1;
3089
+ for (const sig of signals) {
3090
+ try {
3091
+ const fn = this.#sigListeners[sig];
3092
+ if (fn)
3093
+ this.#process.on(sig, fn);
3094
+ } catch (_) {
3095
+ }
3096
+ }
3097
+ this.#process.emit = (ev, ...a) => {
3098
+ return this.#processEmit(ev, ...a);
3099
+ };
3100
+ this.#process.reallyExit = (code) => {
3101
+ return this.#processReallyExit(code);
3102
+ };
3103
+ }
3104
+ unload() {
3105
+ if (!this.#loaded) {
3106
+ return;
3107
+ }
3108
+ this.#loaded = false;
3109
+ signals.forEach((sig) => {
3110
+ const listener = this.#sigListeners[sig];
3111
+ if (!listener) {
3112
+ throw new Error("Listener not defined for signal: " + sig);
3113
+ }
3114
+ try {
3115
+ this.#process.removeListener(sig, listener);
3116
+ } catch (_) {
3117
+ }
3118
+ });
3119
+ this.#process.emit = this.#originalProcessEmit;
3120
+ this.#process.reallyExit = this.#originalProcessReallyExit;
3121
+ this.#emitter.count -= 1;
3122
+ }
3123
+ #processReallyExit(code) {
3124
+ if (!processOk(this.#process)) {
3125
+ return 0;
3126
+ }
3127
+ this.#process.exitCode = code || 0;
3128
+ this.#emitter.emit("exit", this.#process.exitCode, null);
3129
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
3130
+ }
3131
+ #processEmit(ev, ...args) {
3132
+ const og = this.#originalProcessEmit;
3133
+ if (ev === "exit" && processOk(this.#process)) {
3134
+ if (typeof args[0] === "number") {
3135
+ this.#process.exitCode = args[0];
3136
+ }
3137
+ const ret = og.call(this.#process, ev, ...args);
3138
+ this.#emitter.emit("exit", this.#process.exitCode, null);
3139
+ return ret;
3140
+ } else {
3141
+ return og.call(this.#process, ev, ...args);
3142
+ }
3143
+ }
3144
+ };
3145
+ var process3 = globalThis.process;
3146
+ var {
3147
+ /**
3148
+ * Called when the process is exiting, whether via signal, explicit
3149
+ * exit, or running out of stuff to do.
3150
+ *
3151
+ * If the global process object is not suitable for instrumentation,
3152
+ * then this will be a no-op.
3153
+ *
3154
+ * Returns a function that may be used to unload signal-exit.
3155
+ */
3156
+ onExit,
3157
+ /**
3158
+ * Load the listeners. Likely you never need to call this, unless
3159
+ * doing a rather deep integration with signal-exit functionality.
3160
+ * Mostly exposed for the benefit of testing.
3161
+ *
3162
+ * @internal
3163
+ */
3164
+ load,
3165
+ /**
3166
+ * Unload the listeners. Likely you never need to call this, unless
3167
+ * doing a rather deep integration with signal-exit functionality.
3168
+ * Mostly exposed for the benefit of testing.
3169
+ *
3170
+ * @internal
3171
+ */
3172
+ unload
3173
+ } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback());
3174
+
3175
+ // node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
3176
+ import { stripVTControlCharacters } from "util";
3177
+
3178
+ // node_modules/@inquirer/ansi/dist/esm/index.js
3179
+ var ESC = "\x1B[";
3180
+ var cursorLeft = ESC + "G";
3181
+ var cursorHide = ESC + "?25l";
3182
+ var cursorShow = ESC + "?25h";
3183
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
3184
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
3185
+ var cursorTo = (x, y) => {
3186
+ if (typeof y === "number" && !Number.isNaN(y)) {
3187
+ return `${ESC}${y + 1};${x + 1}H`;
3188
+ }
3189
+ return `${ESC}${x + 1}G`;
3190
+ };
3191
+ var eraseLine = ESC + "2K";
3192
+ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
3193
+
3194
+ // node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
3195
+ var height = (content) => content.split("\n").length;
3196
+ var lastLine = (content) => content.split("\n").pop() ?? "";
3197
+ var ScreenManager = class {
3198
+ // These variables are keeping information to allow correct prompt re-rendering
3199
+ height = 0;
3200
+ extraLinesUnderPrompt = 0;
3201
+ cursorPos;
3202
+ rl;
3203
+ constructor(rl) {
3204
+ this.rl = rl;
3205
+ this.cursorPos = rl.getCursorPos();
3206
+ }
3207
+ write(content) {
3208
+ this.rl.output.unmute();
3209
+ this.rl.output.write(content);
3210
+ this.rl.output.mute();
3211
+ }
3212
+ render(content, bottomContent = "") {
3213
+ const promptLine = lastLine(content);
3214
+ const rawPromptLine = stripVTControlCharacters(promptLine);
3215
+ let prompt = rawPromptLine;
3216
+ if (this.rl.line.length > 0) {
3217
+ prompt = prompt.slice(0, -this.rl.line.length);
3218
+ }
3219
+ this.rl.setPrompt(prompt);
3220
+ this.cursorPos = this.rl.getCursorPos();
3221
+ const width = readlineWidth();
3222
+ content = breakLines(content, width);
3223
+ bottomContent = breakLines(bottomContent, width);
3224
+ if (rawPromptLine.length % width === 0) {
3225
+ content += "\n";
3226
+ }
3227
+ let output = content + (bottomContent ? "\n" + bottomContent : "");
3228
+ const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
3229
+ const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
3230
+ if (bottomContentHeight > 0)
3231
+ output += cursorUp(bottomContentHeight);
3232
+ output += cursorTo(this.cursorPos.cols);
3233
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
3234
+ this.extraLinesUnderPrompt = bottomContentHeight;
3235
+ this.height = height(output);
3236
+ }
3237
+ checkCursorPos() {
3238
+ const cursorPos = this.rl.getCursorPos();
3239
+ if (cursorPos.cols !== this.cursorPos.cols) {
3240
+ this.write(cursorTo(cursorPos.cols));
3241
+ this.cursorPos = cursorPos;
3242
+ }
3243
+ }
3244
+ done({ clearContent }) {
3245
+ this.rl.setPrompt("");
3246
+ let output = cursorDown(this.extraLinesUnderPrompt);
3247
+ output += clearContent ? eraseLines(this.height) : "\n";
3248
+ output += cursorShow;
3249
+ this.write(output);
3250
+ this.rl.close();
3251
+ }
3252
+ };
3253
+
3254
+ // node_modules/@inquirer/core/dist/esm/lib/promise-polyfill.js
3255
+ var PromisePolyfill = class extends Promise {
3256
+ // Available starting from Node 22
3257
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
3258
+ static withResolver() {
3259
+ let resolve;
3260
+ let reject;
3261
+ const promise = new Promise((res, rej) => {
3262
+ resolve = res;
3263
+ reject = rej;
3264
+ });
3265
+ return { promise, resolve, reject };
3266
+ }
3267
+ };
3268
+
3269
+ // node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
3270
+ function getCallSites() {
3271
+ const _prepareStackTrace = Error.prepareStackTrace;
3272
+ let result = [];
3273
+ try {
3274
+ Error.prepareStackTrace = (_, callSites) => {
3275
+ const callSitesWithoutCurrent = callSites.slice(1);
3276
+ result = callSitesWithoutCurrent;
3277
+ return callSitesWithoutCurrent;
3278
+ };
3279
+ new Error().stack;
3280
+ } catch {
3281
+ return result;
3282
+ }
3283
+ Error.prepareStackTrace = _prepareStackTrace;
3284
+ return result;
3285
+ }
3286
+ function createPrompt(view) {
3287
+ const callSites = getCallSites();
3288
+ const prompt = (config, context = {}) => {
3289
+ const { input: input2 = process.stdin, signal } = context;
3290
+ const cleanups = /* @__PURE__ */ new Set();
3291
+ const output = new import_mute_stream.default();
3292
+ output.pipe(context.output ?? process.stdout);
3293
+ const rl = readline2.createInterface({
3294
+ terminal: true,
3295
+ input: input2,
3296
+ output
3297
+ });
3298
+ const screen = new ScreenManager(rl);
3299
+ const { promise, resolve, reject } = PromisePolyfill.withResolver();
3300
+ const cancel = () => reject(new CancelPromptError());
3301
+ if (signal) {
3302
+ const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
3303
+ if (signal.aborted) {
3304
+ abort();
3305
+ return Object.assign(promise, { cancel });
3306
+ }
3307
+ signal.addEventListener("abort", abort);
3308
+ cleanups.add(() => signal.removeEventListener("abort", abort));
3309
+ }
3310
+ cleanups.add(onExit((code, signal2) => {
3311
+ reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
3312
+ }));
3313
+ const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
3314
+ rl.on("SIGINT", sigint);
3315
+ cleanups.add(() => rl.removeListener("SIGINT", sigint));
3316
+ const checkCursorPos = () => screen.checkCursorPos();
3317
+ rl.input.on("keypress", checkCursorPos);
3318
+ cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
3319
+ return withHooks(rl, (cycle) => {
3320
+ const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
3321
+ rl.on("close", hooksCleanup);
3322
+ cleanups.add(() => rl.removeListener("close", hooksCleanup));
3323
+ cycle(() => {
3324
+ try {
3325
+ const nextView = view(config, (value) => {
3326
+ setImmediate(() => resolve(value));
3327
+ });
3328
+ if (nextView === void 0) {
3329
+ const callerFilename = callSites[1]?.getFileName();
3330
+ throw new Error(`Prompt functions must return a string.
3331
+ at ${callerFilename}`);
3332
+ }
3333
+ const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
3334
+ screen.render(content, bottomContent);
3335
+ effectScheduler.run();
3336
+ } catch (error) {
3337
+ reject(error);
3338
+ }
3339
+ });
3340
+ return Object.assign(promise.then((answer) => {
3341
+ effectScheduler.clearAll();
3342
+ return answer;
3343
+ }, (error) => {
3344
+ effectScheduler.clearAll();
3345
+ throw error;
3346
+ }).finally(() => {
3347
+ cleanups.forEach((cleanup) => cleanup());
3348
+ screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
3349
+ output.end();
3350
+ }).then(() => promise), { cancel });
3351
+ });
3352
+ };
3353
+ return prompt;
3354
+ }
3355
+
3356
+ // node_modules/@inquirer/core/dist/esm/lib/Separator.js
3357
+ var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
3358
+ var Separator = class {
3359
+ separator = import_yoctocolors_cjs2.default.dim(Array.from({ length: 15 }).join(esm_default.line));
3360
+ type = "separator";
3361
+ constructor(separator) {
3362
+ if (separator) {
3363
+ this.separator = separator;
3364
+ }
3365
+ }
3366
+ static isSeparator(choice) {
3367
+ return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
3368
+ }
3369
+ };
3370
+
3371
+ // node_modules/@inquirer/search/dist/esm/index.js
3372
+ var import_yoctocolors_cjs3 = __toESM(require_yoctocolors_cjs(), 1);
3373
+ var searchTheme = {
3374
+ icon: { cursor: esm_default.pointer },
3375
+ style: {
3376
+ disabled: (text) => import_yoctocolors_cjs3.default.dim(`- ${text}`),
3377
+ searchTerm: (text) => import_yoctocolors_cjs3.default.cyan(text),
3378
+ description: (text) => import_yoctocolors_cjs3.default.cyan(text),
3379
+ keysHelpTip: (keys) => keys.map(([key, action]) => `${import_yoctocolors_cjs3.default.bold(key)} ${import_yoctocolors_cjs3.default.dim(action)}`).join(import_yoctocolors_cjs3.default.dim(" \u2022 "))
3380
+ },
3381
+ helpMode: "always"
3382
+ };
3383
+ function isSelectable(item) {
3384
+ return !Separator.isSeparator(item) && !item.disabled;
3385
+ }
3386
+ function normalizeChoices(choices) {
3387
+ return choices.map((choice) => {
3388
+ if (Separator.isSeparator(choice))
3389
+ return choice;
3390
+ if (typeof choice === "string") {
3391
+ return {
3392
+ value: choice,
3393
+ name: choice,
3394
+ short: choice,
3395
+ disabled: false
3396
+ };
3397
+ }
3398
+ const name = choice.name ?? String(choice.value);
3399
+ const normalizedChoice = {
3400
+ value: choice.value,
3401
+ name,
3402
+ short: choice.short ?? name,
3403
+ disabled: choice.disabled ?? false
3404
+ };
3405
+ if (choice.description) {
3406
+ normalizedChoice.description = choice.description;
3407
+ }
3408
+ return normalizedChoice;
3409
+ });
3410
+ }
3411
+ var esm_default2 = createPrompt((config, done) => {
3412
+ const { pageSize = 7, validate = () => true } = config;
3413
+ const theme = makeTheme(searchTheme, config.theme);
3414
+ const [status, setStatus] = useState("loading");
3415
+ const [searchTerm, setSearchTerm] = useState("");
3416
+ const [searchResults, setSearchResults] = useState([]);
3417
+ const [searchError, setSearchError] = useState();
3418
+ const prefix = usePrefix({ status, theme });
3419
+ const bounds = useMemo(() => {
3420
+ const first = searchResults.findIndex(isSelectable);
3421
+ const last = searchResults.findLastIndex(isSelectable);
3422
+ return { first, last };
3423
+ }, [searchResults]);
3424
+ const [active = bounds.first, setActive] = useState();
3425
+ useEffect(() => {
3426
+ const controller = new AbortController();
3427
+ setStatus("loading");
3428
+ setSearchError(void 0);
3429
+ const fetchResults = async () => {
3430
+ try {
3431
+ const results = await config.source(searchTerm || void 0, {
3432
+ signal: controller.signal
3433
+ });
3434
+ if (!controller.signal.aborted) {
3435
+ setActive(void 0);
3436
+ setSearchError(void 0);
3437
+ setSearchResults(normalizeChoices(results));
3438
+ setStatus("idle");
3439
+ }
3440
+ } catch (error2) {
3441
+ if (!controller.signal.aborted && error2 instanceof Error) {
3442
+ setSearchError(error2.message);
3443
+ }
3444
+ }
3445
+ };
3446
+ void fetchResults();
3447
+ return () => {
3448
+ controller.abort();
3449
+ };
3450
+ }, [searchTerm]);
3451
+ const selectedChoice = searchResults[active];
3452
+ useKeypress(async (key, rl) => {
3453
+ if (isEnterKey(key)) {
3454
+ if (selectedChoice) {
3455
+ setStatus("loading");
3456
+ const isValid = await validate(selectedChoice.value);
3457
+ setStatus("idle");
3458
+ if (isValid === true) {
3459
+ setStatus("done");
3460
+ done(selectedChoice.value);
3461
+ } else if (selectedChoice.name === searchTerm) {
3462
+ setSearchError(isValid || "You must provide a valid value");
3463
+ } else {
3464
+ rl.write(selectedChoice.name);
3465
+ setSearchTerm(selectedChoice.name);
3466
+ }
3467
+ } else {
3468
+ rl.write(searchTerm);
3469
+ }
3470
+ } else if (isTabKey(key) && selectedChoice) {
3471
+ rl.clearLine(0);
3472
+ rl.write(selectedChoice.name);
3473
+ setSearchTerm(selectedChoice.name);
3474
+ } else if (status !== "loading" && (isUpKey(key) || isDownKey(key))) {
3475
+ rl.clearLine(0);
3476
+ if (isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
3477
+ const offset = isUpKey(key) ? -1 : 1;
3478
+ let next = active;
3479
+ do {
3480
+ next = (next + offset + searchResults.length) % searchResults.length;
3481
+ } while (!isSelectable(searchResults[next]));
3482
+ setActive(next);
3483
+ }
3484
+ } else {
3485
+ setSearchTerm(rl.line);
3486
+ }
3487
+ });
3488
+ const message = theme.style.message(config.message, status);
3489
+ let helpLine;
3490
+ if (theme.helpMode !== "never") {
3491
+ if (config.instructions) {
3492
+ const { pager, navigation } = config.instructions;
3493
+ helpLine = theme.style.help(searchResults.length > pageSize ? pager : navigation);
3494
+ } else {
3495
+ helpLine = theme.style.keysHelpTip([
3496
+ ["\u2191\u2193", "navigate"],
3497
+ ["\u23CE", "select"]
3498
+ ]);
3499
+ }
3500
+ }
3501
+ const page = usePagination({
3502
+ items: searchResults,
3503
+ active,
3504
+ renderItem({ item, isActive }) {
3505
+ if (Separator.isSeparator(item)) {
3506
+ return ` ${item.separator}`;
3507
+ }
3508
+ if (item.disabled) {
3509
+ const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
3510
+ return theme.style.disabled(`${item.name} ${disabledLabel}`);
3511
+ }
3512
+ const color = isActive ? theme.style.highlight : (x) => x;
3513
+ const cursor = isActive ? theme.icon.cursor : ` `;
3514
+ return color(`${cursor} ${item.name}`);
3515
+ },
3516
+ pageSize,
3517
+ loop: false
3518
+ });
3519
+ let error;
3520
+ if (searchError) {
3521
+ error = theme.style.error(searchError);
3522
+ } else if (searchResults.length === 0 && searchTerm !== "" && status === "idle") {
3523
+ error = theme.style.error("No results found");
3524
+ }
3525
+ let searchStr;
3526
+ if (status === "done" && selectedChoice) {
3527
+ return [prefix, message, theme.style.answer(selectedChoice.short)].filter(Boolean).join(" ").trimEnd();
3528
+ } else {
3529
+ searchStr = theme.style.searchTerm(searchTerm);
3530
+ }
3531
+ const description = selectedChoice?.description;
3532
+ const header = [prefix, message, searchStr].filter(Boolean).join(" ").trimEnd();
3533
+ const body = [
3534
+ error ?? page,
3535
+ " ",
3536
+ description ? theme.style.description(description) : "",
3537
+ helpLine
3538
+ ].filter(Boolean).join("\n").trimEnd();
3539
+ return [header, body];
3540
+ });
3541
+
3542
+ // src/cli/prompts/repo-select.prompts.ts
3543
+ import { confirm } from "@inquirer/prompts";
3544
+ var CYAN = "\x1B[36m";
3545
+ var RESET = "\x1B[0m";
3546
+ async function promptRepoSelection(repos) {
3547
+ return esm_default2({
3548
+ message: "Select a repository to clone (type to filter):",
3549
+ source: (input2) => {
3550
+ const term = (input2 ?? "").toLowerCase();
3551
+ return repos.filter((r) => r.name.toLowerCase().includes(term)).map((r) => ({
3552
+ name: `[ ] ${r.name}`,
3553
+ value: r,
3554
+ description: r.defaultBranch ? `Default branch: ${r.defaultBranch}` : void 0
3555
+ }));
3556
+ },
3557
+ pageSize: 20,
3558
+ theme: {
3559
+ icon: { cursor: "" },
3560
+ style: {
3561
+ highlight: (text) => `${CYAN}${text.replace("[ ]", "[X]")}${RESET}`
3562
+ }
3563
+ }
3564
+ });
3565
+ }
3566
+ async function promptConfirmClone(repoName, targetPath) {
3567
+ return confirm({
3568
+ message: `Clone "${repoName}" into ${targetPath}?`,
3569
+ default: true
3570
+ });
3571
+ }
3572
+
3573
+ // src/cli/commands/list.command.ts
3574
+ import path3 from "path";
3575
+ function registerListCommand(program2) {
3576
+ program2.command("list").description("Browse and interactively clone repositories from your Azure DevOps project.").action(async () => {
3577
+ await runInteractiveList();
3578
+ });
3579
+ }
3580
+ async function runInteractiveList() {
3581
+ try {
3582
+ const configStore = new ConfStore();
3583
+ const secretStore = new KeytarStore();
3584
+ const adoClient = new AdoClient();
3585
+ const gitService = new GitService();
3586
+ const validateSetup = new ValidateSetupUseCase(configStore);
3587
+ const config = validateSetup.execute();
3588
+ Formatter.section(`ADO Repo Lister \u2014 ${config.projectName}`);
3589
+ Formatter.info("Fetching repositories...");
3590
+ let pat;
3591
+ if (config.authMode === "pat") {
3592
+ const stored = await secretStore.getSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
3593
+ if (stored) pat = stored;
3594
+ }
3595
+ const authProvider = config.authMode === "pat" && pat ? new PatAuthHeaderProvider(pat) : new DefaultAuthHeaderProvider(config.orgUrl);
3596
+ const listRepos = new ListRepositoriesUseCase(adoClient, authProvider);
3597
+ const repos = await listRepos.execute({
3598
+ orgUrl: config.orgUrl,
3599
+ projectId: config.projectId
3600
+ });
3601
+ if (repos.length === 0) {
3602
+ Formatter.warn("No repositories found in this project.");
3603
+ return;
3604
+ }
3605
+ Formatter.info(`Found ${repos.length} repositories.
3606
+ `);
3607
+ const selected = await promptRepoSelection(repos);
3608
+ const targetPath = path3.join(config.cloneRoot, selected.name);
3609
+ const confirmed = await promptConfirmClone(selected.name, targetPath);
3610
+ if (!confirmed) {
3611
+ Formatter.warn("Clone cancelled.");
3612
+ return;
3613
+ }
3614
+ Formatter.info(`Cloning "${selected.name}"...`);
3615
+ const cloneUseCase = new CloneRepositoryUseCase(adoClient, authProvider, gitService, secretStore);
3616
+ const result = await cloneUseCase.execute({
3617
+ orgUrl: config.orgUrl,
3618
+ projectId: config.projectId,
3619
+ repoName: selected.name,
3620
+ cloneRoot: config.cloneRoot,
3621
+ authMode: config.authMode
3622
+ });
3623
+ Formatter.success(
3624
+ `Cloned "${result.repository.name}" to:
3625
+ ${result.clonedTo}`
3626
+ );
3627
+ } catch (error) {
3628
+ if (error instanceof AppError) {
3629
+ Formatter.error(error.message);
3630
+ } else if (error instanceof Error) {
3631
+ if (error.message.includes("User force closed")) {
3632
+ Formatter.warn("Cancelled.");
3633
+ } else {
3634
+ Formatter.error(error.message);
3635
+ }
3636
+ } else {
3637
+ Formatter.error("An unexpected error occurred.");
3638
+ }
3639
+ process.exit(1);
3640
+ }
3641
+ }
3642
+
3643
+ // src/cli/commands/clone.command.ts
3644
+ function registerCloneCommand(program2) {
3645
+ program2.command("clone <name>").description("Clone a repository by name directly, without the interactive menu.").action(async (name) => {
3646
+ try {
3647
+ const configStore = new ConfStore();
3648
+ const secretStore = new KeytarStore();
3649
+ const adoClient = new AdoClient();
3650
+ const gitService = new GitService();
3651
+ const validateSetup = new ValidateSetupUseCase(configStore);
3652
+ const config = validateSetup.execute();
3653
+ let pat;
3654
+ if (config.authMode === "pat") {
3655
+ const stored = await secretStore.getSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
3656
+ if (stored) pat = stored;
3657
+ }
3658
+ const authProvider = config.authMode === "pat" && pat ? new PatAuthHeaderProvider(pat) : new DefaultAuthHeaderProvider(config.orgUrl);
3659
+ Formatter.info(`Cloning "${name}"...`);
3660
+ const cloneUseCase = new CloneRepositoryUseCase(
3661
+ adoClient,
3662
+ authProvider,
3663
+ gitService,
3664
+ secretStore
3665
+ );
3666
+ const result = await cloneUseCase.execute({
3667
+ orgUrl: config.orgUrl,
3668
+ projectId: config.projectId,
3669
+ repoName: name,
3670
+ cloneRoot: config.cloneRoot,
3671
+ authMode: config.authMode
3672
+ });
3673
+ Formatter.success(
3674
+ `Cloned "${result.repository.name}" to:
3675
+ ${result.clonedTo}`
3676
+ );
3677
+ } catch (error) {
3678
+ if (error instanceof AppError) {
3679
+ Formatter.error(error.message);
3680
+ } else if (error instanceof Error) {
3681
+ Formatter.error(error.message);
3682
+ } else {
3683
+ Formatter.error("An unexpected error occurred.");
3684
+ }
3685
+ process.exit(1);
3686
+ }
3687
+ });
3688
+ }
3689
+
3690
+ // src/application/use-cases/get-saved-config.use-case.ts
3691
+ var GetSavedConfigUseCase = class {
3692
+ constructor(configStore) {
3693
+ this.configStore = configStore;
3694
+ }
3695
+ execute() {
3696
+ const orgUrl = this.configStore.get(CONFIG_KEYS.ORG_URL);
3697
+ const projectId = this.configStore.get(CONFIG_KEYS.PROJECT_ID);
3698
+ const projectName = this.configStore.get(CONFIG_KEYS.PROJECT_NAME);
3699
+ const authMode = this.configStore.get(CONFIG_KEYS.AUTH_MODE);
3700
+ const cloneRoot = this.configStore.get(CONFIG_KEYS.CLONE_ROOT);
3701
+ if (!orgUrl || !projectId || !projectName || !authMode || !cloneRoot) {
3702
+ throw new MissingConfigError();
3703
+ }
3704
+ return { orgUrl, projectId, projectName, authMode, cloneRoot };
3705
+ }
3706
+ };
3707
+
3708
+ // src/application/use-cases/reset-config.use-case.ts
3709
+ var ResetConfigUseCase = class {
3710
+ constructor(configStore, secretStore) {
3711
+ this.configStore = configStore;
3712
+ this.secretStore = secretStore;
3713
+ }
3714
+ async execute() {
3715
+ try {
3716
+ this.configStore.clear();
3717
+ } catch (error) {
3718
+ throw new ConfigPersistenceError("Failed to clear configuration.", error);
3719
+ }
3720
+ try {
3721
+ await this.secretStore.deleteSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
3722
+ } catch {
3723
+ }
3724
+ }
3725
+ };
3726
+
3727
+ // src/cli/commands/config.command.ts
3728
+ import { confirm as confirm2 } from "@inquirer/prompts";
3729
+ function registerConfigCommand(program2) {
3730
+ const config = program2.command("config").description("Manage adograb configuration.");
3731
+ config.command("show").description("Show the current saved configuration.").action(() => {
3732
+ try {
3733
+ const configStore = new ConfStore();
3734
+ const getConfig = new GetSavedConfigUseCase(configStore);
3735
+ const cfg = getConfig.execute();
3736
+ Formatter.section("Current Configuration");
3737
+ Formatter.config({
3738
+ "Organization URL": cfg.orgUrl,
3739
+ "Project": `${cfg.projectName} (${cfg.projectId})`,
3740
+ "Auth mode": cfg.authMode,
3741
+ "Clone root": cfg.cloneRoot
3742
+ });
3743
+ } catch (error) {
3744
+ if (error instanceof MissingConfigError) {
3745
+ Formatter.warn("No configuration found. Run `adograb init` to set up the tool.");
3746
+ } else if (error instanceof AppError) {
3747
+ Formatter.error(error.message);
3748
+ } else if (error instanceof Error) {
3749
+ Formatter.error(error.message);
3750
+ } else {
3751
+ Formatter.error("An unexpected error occurred.");
3752
+ }
3753
+ process.exit(1);
3754
+ }
3755
+ });
3756
+ config.command("reset").description("Reset all configuration and remove stored credentials.").action(async () => {
3757
+ try {
3758
+ const confirmed = await confirm2({
3759
+ message: "This will remove all saved configuration and credentials. Continue?",
3760
+ default: false
3761
+ });
3762
+ if (!confirmed) {
3763
+ Formatter.warn("Reset cancelled.");
3764
+ return;
3765
+ }
3766
+ const configStore = new ConfStore();
3767
+ const secretStore = new KeytarStore();
3768
+ const resetConfig = new ResetConfigUseCase(configStore, secretStore);
3769
+ await resetConfig.execute();
3770
+ Formatter.success("Configuration reset. Run `adograb init` to set up again.");
3771
+ } catch (error) {
3772
+ if (error instanceof AppError) {
3773
+ Formatter.error(error.message);
3774
+ } else if (error instanceof Error) {
3775
+ if (error.message.includes("User force closed")) {
3776
+ Formatter.warn("Reset cancelled.");
3777
+ } else {
3778
+ Formatter.error(error.message);
3779
+ }
3780
+ } else {
3781
+ Formatter.error("An unexpected error occurred.");
3782
+ }
3783
+ process.exit(1);
3784
+ }
3785
+ });
3786
+ }
3787
+
3788
+ // src/application/use-cases/switch-project.use-case.ts
3789
+ var SwitchProjectUseCase = class {
3790
+ constructor(configStore) {
3791
+ this.configStore = configStore;
3792
+ }
3793
+ execute(input2) {
3794
+ try {
3795
+ this.configStore.set(CONFIG_KEYS.PROJECT_ID, input2.project.id);
3796
+ this.configStore.set(CONFIG_KEYS.PROJECT_NAME, input2.project.name);
3797
+ } catch (error) {
3798
+ throw new ConfigPersistenceError("Failed to save project selection.", error);
3799
+ }
3800
+ }
3801
+ };
3802
+
3803
+ // src/cli/prompts/project-select.prompts.ts
3804
+ import { select as select2 } from "@inquirer/prompts";
3805
+ async function promptProjectSwitch(projects) {
3806
+ return select2({
3807
+ message: "Select a project to switch to:",
3808
+ choices: projects.map((p) => ({
3809
+ name: p.name,
3810
+ value: p,
3811
+ description: p.description
3812
+ }))
3813
+ });
3814
+ }
3815
+
3816
+ // src/cli/commands/project.command.ts
3817
+ function registerProjectCommand(program2) {
3818
+ const project = program2.command("project").description("Manage the active Azure DevOps project.");
3819
+ project.command("switch").description("Switch to a different project in the same organization.").action(async () => {
3820
+ try {
3821
+ const configStore = new ConfStore();
3822
+ const secretStore = new KeytarStore();
3823
+ const adoClient = new AdoClient();
3824
+ const validateSetup = new ValidateSetupUseCase(configStore);
3825
+ const config = validateSetup.execute();
3826
+ let pat;
3827
+ if (config.authMode === "pat") {
3828
+ const stored = await secretStore.getSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
3829
+ if (stored) pat = stored;
3830
+ }
3831
+ const authProvider = config.authMode === "pat" && pat ? new PatAuthHeaderProvider(pat) : new DefaultAuthHeaderProvider(config.orgUrl);
3832
+ Formatter.info("Fetching projects...");
3833
+ const listProjects = new ListProjectsUseCase(adoClient, authProvider);
3834
+ const projects = await listProjects.execute({ orgUrl: config.orgUrl });
3835
+ if (projects.length === 0) {
3836
+ Formatter.warn("No projects found in this organization.");
3837
+ return;
3838
+ }
3839
+ const selected = await promptProjectSwitch(projects);
3840
+ const switchProject = new SwitchProjectUseCase(configStore);
3841
+ switchProject.execute({ project: selected });
3842
+ Formatter.success(`Switched to project "${selected.name}".`);
3843
+ } catch (error) {
3844
+ if (error instanceof AppError) {
3845
+ Formatter.error(error.message);
3846
+ } else if (error instanceof Error) {
3847
+ if (error.message.includes("User force closed")) {
3848
+ Formatter.warn("Cancelled.");
3849
+ } else {
3850
+ Formatter.error(error.message);
3851
+ }
3852
+ } else {
3853
+ Formatter.error("An unexpected error occurred.");
3854
+ }
3855
+ process.exit(1);
3856
+ }
3857
+ });
3858
+ }
3859
+
3860
+ // src/application/use-cases/switch-auth-mode.use-case.ts
3861
+ var SwitchAuthModeUseCase = class {
3862
+ constructor(configStore, secretStore) {
3863
+ this.configStore = configStore;
3864
+ this.secretStore = secretStore;
3865
+ }
3866
+ async execute(input2) {
3867
+ if (input2.authMode === "pat") {
3868
+ if (!input2.pat) {
3869
+ throw new SecureStoreError("A PAT is required when switching to PAT authentication mode.");
3870
+ }
3871
+ try {
3872
+ await this.secretStore.setSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT, input2.pat);
3873
+ } catch (error) {
3874
+ throw new SecureStoreError("Failed to store PAT in secure store.", error);
3875
+ }
3876
+ } else {
3877
+ try {
3878
+ await this.secretStore.deleteSecret(KEYTAR_SERVICE, KEYTAR_ACCOUNT_PAT);
3879
+ } catch {
3880
+ }
3881
+ }
3882
+ try {
3883
+ this.configStore.set(CONFIG_KEYS.AUTH_MODE, input2.authMode);
3884
+ } catch (error) {
3885
+ throw new ConfigPersistenceError("Failed to save authentication mode.", error);
3886
+ }
3887
+ }
3888
+ };
3889
+
3890
+ // src/cli/commands/auth.command.ts
3891
+ function registerAuthCommand(program2) {
3892
+ const auth = program2.command("auth").description("Manage authentication settings.");
3893
+ auth.command("switch").description("Switch between authentication modes (default Git credentials or PAT token).").action(async () => {
3894
+ try {
3895
+ const configStore = new ConfStore();
3896
+ const secretStore = new KeytarStore();
3897
+ const validateSetup = new ValidateSetupUseCase(configStore);
3898
+ const config = validateSetup.execute();
3899
+ Formatter.section("Switch Authentication Mode");
3900
+ Formatter.info(`Current mode: ${config.authMode}
3901
+ `);
3902
+ const authMode = await promptAuthMode();
3903
+ let pat;
3904
+ if (authMode === "pat") {
3905
+ pat = await promptPat();
3906
+ }
3907
+ const switchAuthMode = new SwitchAuthModeUseCase(configStore, secretStore);
3908
+ await switchAuthMode.execute({ authMode, pat });
3909
+ if (authMode === "pat") {
3910
+ Formatter.success("Switched to PAT authentication. PAT stored securely.");
3911
+ } else {
3912
+ Formatter.success("Switched to default Git Credential Manager authentication.");
3913
+ }
3914
+ } catch (error) {
3915
+ if (error instanceof AppError) {
3916
+ Formatter.error(error.message);
3917
+ } else if (error instanceof Error) {
3918
+ if (error.message.includes("User force closed")) {
3919
+ Formatter.warn("Cancelled.");
3920
+ } else {
3921
+ Formatter.error(error.message);
3922
+ }
3923
+ } else {
3924
+ Formatter.error("An unexpected error occurred.");
3925
+ }
3926
+ process.exit(1);
3927
+ }
3928
+ });
3929
+ }
3930
+
3931
+ // src/index.ts
3932
+ var program = new Command();
3933
+ program.name(APP_NAME).description("Browse and clone Azure DevOps repositories from the terminal.").version(APP_VERSION, "-v, --version", "Show version number").addHelpText(
3934
+ "after",
3935
+ `
3936
+ Examples:
3937
+ $ adograb init Run first-time setup
3938
+ $ adograb Browse and clone repositories (interactive)
3939
+ $ adograb list Browse and clone repositories (interactive)
3940
+ $ adograb clone <name> Clone a repository directly by name
3941
+ $ adograb config show Show current configuration
3942
+ $ adograb config reset Reset all configuration
3943
+ $ adograb project switch Switch to a different project
3944
+ $ adograb auth switch Switch authentication mode
3945
+
3946
+ Uninstall:
3947
+ $ adograb config reset Clear all saved config and credentials first
3948
+ $ npm uninstall -g adograb Then remove the tool`
3949
+ );
3950
+ registerInitCommand(program);
3951
+ registerListCommand(program);
3952
+ registerCloneCommand(program);
3953
+ registerConfigCommand(program);
3954
+ registerProjectCommand(program);
3955
+ registerAuthCommand(program);
3956
+ program.action(async () => {
3957
+ try {
3958
+ await runInteractiveList();
3959
+ } catch (error) {
3960
+ if (error instanceof MissingConfigError) {
3961
+ Formatter.warn(
3962
+ "Setup required. Run `adograb init` to configure the tool, then run `adograb` again to browse repositories."
3963
+ );
3964
+ process.exit(1);
3965
+ }
3966
+ throw error;
3967
+ }
3968
+ });
3969
+ program.parseAsync(process.argv).catch((error) => {
3970
+ if (error instanceof Error) {
3971
+ Formatter.error(error.message);
3972
+ } else {
3973
+ Formatter.error("An unexpected error occurred.");
3974
+ }
3975
+ process.exit(1);
3976
+ });