AK-21/Graphite-Industrial-Intelligence
0
1#!/usr/bin/env node2var __create = Object.create;3var __defProp = Object.defineProperty;4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;5var __getOwnPropNames = Object.getOwnPropertyNames;6var __getProtoOf = Object.getPrototypeOf;7var __hasOwnProp = Object.prototype.hasOwnProperty;8var __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});14var __commonJS = (cb, mod) => function __require2() {15 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;16};17var __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};25var __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 ESM27 // file that has been converted to a CommonJS file using a Babel-28 // compatible transform (i.e. "__esModule" has not been set), then set29 // "default" to the CommonJS "module.exports" for node compatibility.30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,31 mod32));33 34// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/readline.js35var require_readline = __commonJS({36 "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/readline.js"(exports) {37 "use strict";38 var __importDefault = exports && exports.__importDefault || function(mod) {39 return mod && mod.__esModule ? mod : { "default": mod };40 };41 Object.defineProperty(exports, "__esModule", { value: true });42 exports.createClosable = exports.stdout = exports.stdin = void 0;43 var readline_1 = __importDefault(__require("readline"));44 exports.stdin = process.stdin;45 exports.stdout = process.stdout;46 readline_1.default.emitKeypressEvents(exports.stdin);47 var createClosable = () => {48 return readline_1.default.createInterface({49 input: exports.stdin,50 escapeCodeTimeout: 5051 });52 };53 exports.createClosable = createClosable;54 }55});56 57// ../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js58var require_src = __commonJS({59 "../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {60 "use strict";61 var ESC = "\x1B";62 var CSI = `${ESC}[`;63 var beep = "\x07";64 var cursor = {65 to(x, y) {66 if (!y) return `${CSI}${x + 1}G`;67 return `${CSI}${y + 1};${x + 1}H`;68 },69 move(x, y) {70 let ret = "";71 if (x < 0) ret += `${CSI}${-x}D`;72 else if (x > 0) ret += `${CSI}${x}C`;73 if (y < 0) ret += `${CSI}${-y}A`;74 else if (y > 0) ret += `${CSI}${y}B`;75 return ret;76 },77 up: (count = 1) => `${CSI}${count}A`,78 down: (count = 1) => `${CSI}${count}B`,79 forward: (count = 1) => `${CSI}${count}C`,80 backward: (count = 1) => `${CSI}${count}D`,81 nextLine: (count = 1) => `${CSI}E`.repeat(count),82 prevLine: (count = 1) => `${CSI}F`.repeat(count),83 left: `${CSI}G`,84 hide: `${CSI}?25l`,85 show: `${CSI}?25h`,86 save: `${ESC}7`,87 restore: `${ESC}8`88 };89 var scroll = {90 up: (count = 1) => `${CSI}S`.repeat(count),91 down: (count = 1) => `${CSI}T`.repeat(count)92 };93 var erase = {94 screen: `${CSI}2J`,95 up: (count = 1) => `${CSI}1J`.repeat(count),96 down: (count = 1) => `${CSI}J`.repeat(count),97 line: `${CSI}2K`,98 lineEnd: `${CSI}K`,99 lineStart: `${CSI}1K`,100 lines(count) {101 let clear = "";102 for (let i = 0; i < count; i++)103 clear += this.line + (i < count - 1 ? cursor.up() : "");104 if (count)105 clear += cursor.left;106 return clear;107 }108 };109 module.exports = { cursor, scroll, erase, beep };110 }111});112 113// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/utils.js114var require_utils = __commonJS({115 "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/utils.js"(exports) {116 "use strict";117 Object.defineProperty(exports, "__esModule", { value: true });118 exports.clear = exports.stringWidth = exports.fallbackStringWidth = exports.stripAnsi = exports.strip = void 0;119 var sisteransi_1 = require_src();120 var strip = (str) => {121 const pattern = [122 "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",123 "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"124 ].join("|");125 const RGX = new RegExp(pattern, "g");126 return typeof str === "string" ? str.replace(RGX, "") : str;127 };128 exports.strip = strip;129 var stripAnsi = (str) => {130 if (typeof Bun !== "undefined" && Bun.stripANSI) {131 return Bun.stripANSI(str);132 }133 return (0, exports.strip)(str);134 };135 exports.stripAnsi = stripAnsi;136 var fallbackStringWidth = (str) => {137 let len = 0;138 const stripped = (0, exports.stripAnsi)(str);139 for (const _ of stripped)140 len++;141 return len;142 };143 exports.fallbackStringWidth = fallbackStringWidth;144 var stringWidth = (str) => {145 if (typeof Bun !== "undefined" && Bun.stringWidth)146 return Bun.stringWidth(str);147 return (0, exports.fallbackStringWidth)(str);148 };149 exports.stringWidth = stringWidth;150 var clear = function(prompt, perLine) {151 if (!perLine)152 return sisteransi_1.erase.line + sisteransi_1.cursor.to(0);153 let rows = 0;154 const lines = prompt.split(/\r?\n/);155 for (let line of lines) {156 rows += 1 + Math.floor(Math.max((0, exports.stringWidth)(line) - 1, 0) / perLine);157 }158 return sisteransi_1.erase.lines(rows);159 };160 exports.clear = clear;161 }162});163 164// ../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js165var require_lodash = __commonJS({166 "../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module) {167 var FUNC_ERROR_TEXT = "Expected a function";168 var NAN = 0 / 0;169 var symbolTag = "[object Symbol]";170 var reTrim = /^\s+|\s+$/g;171 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;172 var reIsBinary = /^0b[01]+$/i;173 var reIsOctal = /^0o[0-7]+$/i;174 var freeParseInt = parseInt;175 var freeGlobal = typeof global == "object" && global && global.Object === Object && global;176 var freeSelf = typeof self == "object" && self && self.Object === Object && self;177 var root = freeGlobal || freeSelf || Function("return this")();178 var objectProto = Object.prototype;179 var objectToString = objectProto.toString;180 var nativeMax = Math.max;181 var nativeMin = Math.min;182 var now = function() {183 return root.Date.now();184 };185 function debounce(func, wait, options) {186 var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;187 if (typeof func != "function") {188 throw new TypeError(FUNC_ERROR_TEXT);189 }190 wait = toNumber(wait) || 0;191 if (isObject(options)) {192 leading = !!options.leading;193 maxing = "maxWait" in options;194 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;195 trailing = "trailing" in options ? !!options.trailing : trailing;196 }197 function invokeFunc(time) {198 var args = lastArgs, thisArg = lastThis;199 lastArgs = lastThis = void 0;200 lastInvokeTime = time;201 result = func.apply(thisArg, args);202 return result;203 }204 function leadingEdge(time) {205 lastInvokeTime = time;206 timerId = setTimeout(timerExpired, wait);207 return leading ? invokeFunc(time) : result;208 }209 function remainingWait(time) {210 var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;211 return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;212 }213 function shouldInvoke(time) {214 var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;215 return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;216 }217 function timerExpired() {218 var time = now();219 if (shouldInvoke(time)) {220 return trailingEdge(time);221 }222 timerId = setTimeout(timerExpired, remainingWait(time));223 }224 function trailingEdge(time) {225 timerId = void 0;226 if (trailing && lastArgs) {227 return invokeFunc(time);228 }229 lastArgs = lastThis = void 0;230 return result;231 }232 function cancel() {233 if (timerId !== void 0) {234 clearTimeout(timerId);235 }236 lastInvokeTime = 0;237 lastArgs = lastCallTime = lastThis = timerId = void 0;238 }239 function flush() {240 return timerId === void 0 ? result : trailingEdge(now());241 }242 function debounced() {243 var time = now(), isInvoking = shouldInvoke(time);244 lastArgs = arguments;245 lastThis = this;246 lastCallTime = time;247 if (isInvoking) {248 if (timerId === void 0) {249 return leadingEdge(lastCallTime);250 }251 if (maxing) {252 timerId = setTimeout(timerExpired, wait);253 return invokeFunc(lastCallTime);254 }255 }256 if (timerId === void 0) {257 timerId = setTimeout(timerExpired, wait);258 }259 return result;260 }261 debounced.cancel = cancel;262 debounced.flush = flush;263 return debounced;264 }265 function throttle(func, wait, options) {266 var leading = true, trailing = true;267 if (typeof func != "function") {268 throw new TypeError(FUNC_ERROR_TEXT);269 }270 if (isObject(options)) {271 leading = "leading" in options ? !!options.leading : leading;272 trailing = "trailing" in options ? !!options.trailing : trailing;273 }274 return debounce(func, wait, {275 "leading": leading,276 "maxWait": wait,277 "trailing": trailing278 });279 }280 function isObject(value) {281 var type = typeof value;282 return !!value && (type == "object" || type == "function");283 }284 function isObjectLike(value) {285 return !!value && typeof value == "object";286 }287 function isSymbol(value) {288 return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;289 }290 function toNumber(value) {291 if (typeof value == "number") {292 return value;293 }294 if (isSymbol(value)) {295 return NAN;296 }297 if (isObject(value)) {298 var other = typeof value.valueOf == "function" ? value.valueOf() : value;299 value = isObject(other) ? other + "" : other;300 }301 if (typeof value != "string") {302 return value === 0 ? value : +value;303 }304 value = value.replace(reTrim, "");305 var isBinary = reIsBinary.test(value);306 return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;307 }308 module.exports = throttle;309 }310});311 312// ../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/index.js313var require_hanji = __commonJS({314 "../node_modules/.pnpm/hanji@0.0.8/node_modules/hanji/index.js"(exports) {315 "use strict";316 var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {317 function adopt(value) {318 return value instanceof P ? value : new P(function(resolve) {319 resolve(value);320 });321 }322 return new (P || (P = Promise))(function(resolve, reject) {323 function fulfilled(value) {324 try {325 step(generator.next(value));326 } catch (e) {327 reject(e);328 }329 }330 function rejected(value) {331 try {332 step(generator["throw"](value));333 } catch (e) {334 reject(e);335 }336 }337 function step(result) {338 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);339 }340 step((generator = generator.apply(thisArg, _arguments || [])).next());341 });342 };343 var __importDefault = exports && exports.__importDefault || function(mod) {344 return mod && mod.__esModule ? mod : { "default": mod };345 };346 Object.defineProperty(exports, "__esModule", { value: true });347 exports.TaskTerminal = exports.TaskView = exports.Terminal = exports.deferred = exports.SelectState = exports.Prompt = void 0;348 exports.render = render2;349 exports.renderWithTask = renderWithTask;350 exports.onTerminate = onTerminate;351 var readline_1 = require_readline();352 var sisteransi_1 = require_src();353 var utils_1 = require_utils();354 var lodash_throttle_1 = __importDefault(require_lodash());355 var Prompt2 = class {356 constructor() {357 this.attachCallbacks = [];358 this.detachCallbacks = [];359 this.inputCallbacks = [];360 }361 requestLayout() {362 this.terminal.requestLayout();363 }364 on(type, callback) {365 if (type === "attach") {366 this.attachCallbacks.push(callback);367 } else if (type === "detach") {368 this.detachCallbacks.push(callback);369 } else if (type === "input") {370 this.inputCallbacks.push(callback);371 }372 }373 attach(terminal) {374 this.terminal = terminal;375 this.attachCallbacks.forEach((it) => it(terminal));376 }377 detach(terminal) {378 this.detachCallbacks.forEach((it) => it(terminal));379 this.terminal = void 0;380 }381 input(str, key) {382 this.inputCallbacks.forEach((it) => it(str, key));383 }384 };385 exports.Prompt = Prompt2;386 var SelectState2 = class {387 constructor(items) {388 this.items = items;389 this.selectedIdx = 0;390 }391 bind(prompt) {392 prompt.on("input", (str, key) => {393 const invalidate = this.consume(str, key);394 if (invalidate)395 prompt.requestLayout();396 });397 }398 consume(str, key) {399 if (!key)400 return false;401 if (key.name === "down") {402 this.selectedIdx = (this.selectedIdx + 1) % this.items.length;403 return true;404 }405 if (key.name === "up") {406 this.selectedIdx -= 1;407 this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx;408 return true;409 }410 return false;411 }412 };413 exports.SelectState = SelectState2;414 var deferred = () => {415 let resolve;416 let reject;417 const promise = new Promise((res, rej) => {418 resolve = res;419 reject = rej;420 });421 return {422 resolve,423 reject,424 promise425 };426 };427 exports.deferred = deferred;428 var Terminal = class {429 constructor(view5, stdin, stdout, closable) {430 this.view = view5;431 this.stdin = stdin;432 this.stdout = stdout;433 this.closable = closable;434 this.text = "";435 this.status = "idle";436 if (this.stdin.isTTY)437 this.stdin.setRawMode(true);438 const keypress = (str, key) => {439 if (key.name === "c" && key.ctrl === true) {440 this.requestLayout();441 this.view.detach(this);442 this.tearDown(keypress);443 if (terminateHandler) {444 terminateHandler(this.stdin, this.stdout);445 return;446 }447 this.stdout.write(`448^C449`);450 process.exit(1);451 }452 if (key.name === "escape") {453 this.status = "aborted";454 this.requestLayout();455 this.view.detach(this);456 this.tearDown(keypress);457 this.resolve({ status: "aborted", data: void 0 });458 return;459 }460 if (key.name === "return") {461 this.status = "submitted";462 this.requestLayout();463 this.view.detach(this);464 this.tearDown(keypress);465 this.resolve({ status: "submitted", data: this.view.result() });466 return;467 }468 view5.input(str, key);469 };470 this.stdin.on("keypress", keypress);471 this.view.attach(this);472 const { resolve, promise } = (0, exports.deferred)();473 this.resolve = resolve;474 this.promise = promise;475 this.renderFunc = (0, lodash_throttle_1.default)((str) => {476 this.stdout.write(str);477 });478 }479 tearDown(keypress) {480 this.stdout.write(sisteransi_1.cursor.show);481 this.stdin.removeListener("keypress", keypress);482 if (this.stdin.isTTY)483 this.stdin.setRawMode(false);484 this.closable.close();485 }486 result() {487 return this.promise;488 }489 toggleCursor(state) {490 if (state === "hide") {491 this.stdout.write(sisteransi_1.cursor.hide);492 } else {493 this.stdout.write(sisteransi_1.cursor.show);494 }495 }496 requestLayout() {497 const string = this.view.render(this.status);498 const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";499 this.text = string;500 this.renderFunc(`${clearPrefix}${string}`);501 }502 };503 exports.Terminal = Terminal;504 var TaskView2 = class {505 constructor() {506 this.attachCallbacks = [];507 this.detachCallbacks = [];508 }509 requestLayout() {510 this.terminal.requestLayout();511 }512 attach(terminal) {513 this.terminal = terminal;514 this.attachCallbacks.forEach((it) => it(terminal));515 }516 detach(terminal) {517 this.detachCallbacks.forEach((it) => it(terminal));518 this.terminal = void 0;519 }520 on(type, callback) {521 if (type === "attach") {522 this.attachCallbacks.push(callback);523 } else if (type === "detach") {524 this.detachCallbacks.push(callback);525 }526 }527 };528 exports.TaskView = TaskView2;529 var TaskTerminal = class {530 constructor(view5, stdout) {531 this.view = view5;532 this.stdout = stdout;533 this.text = "";534 this.view.attach(this);535 }536 requestLayout() {537 const string = this.view.render("pending");538 const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";539 this.text = string;540 this.stdout.write(`${clearPrefix}${string}`);541 }542 clear() {543 const string = this.view.render("done");544 this.view.detach(this);545 const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";546 this.stdout.write(`${clearPrefix}${string}`);547 }548 reject(err) {549 const string = this.view.render("rejected", err);550 this.view.detach(this);551 const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : "";552 this.stdout.write(`${clearPrefix}${string}`);553 }554 };555 exports.TaskTerminal = TaskTerminal;556 function render2(view5) {557 if (typeof view5 === "string") {558 process.stdout.write(`${view5}559`);560 return;561 }562 if (!process.stdin.isTTY || !process.stdout.isTTY) {563 return Promise.reject(new Error("Interactive prompts require a TTY terminal (process.stdin.isTTY or process.stdout.isTTY is false). This can happen when running in CI, piped input, or non-interactive shells."));564 }565 const closable = (0, readline_1.createClosable)();566 const terminal = new Terminal(view5, readline_1.stdin, readline_1.stdout, closable);567 terminal.requestLayout();568 return terminal.result();569 }570 function renderWithTask(view5, task) {571 return __awaiter(this, void 0, void 0, function* () {572 const terminal = new TaskTerminal(view5, process.stdout);573 terminal.requestLayout();574 try {575 const result = yield task;576 terminal.clear();577 return result;578 } catch (err) {579 terminal.reject(err);580 process.exit(1);581 }582 });583 }584 var terminateHandler;585 function onTerminate(callback) {586 terminateHandler = callback;587 }588 }589});590 591// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js592var ANSI_BACKGROUND_OFFSET = 10;593var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;594var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;595var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;596var styles = {597 modifier: {598 reset: [0, 0],599 // 21 isn't widely supported and 22 does the same thing600 bold: [1, 22],601 dim: [2, 22],602 italic: [3, 23],603 underline: [4, 24],604 overline: [53, 55],605 inverse: [7, 27],606 hidden: [8, 28],607 strikethrough: [9, 29]608 },609 color: {610 black: [30, 39],611 red: [31, 39],612 green: [32, 39],613 yellow: [33, 39],614 blue: [34, 39],615 magenta: [35, 39],616 cyan: [36, 39],617 white: [37, 39],618 // Bright color619 blackBright: [90, 39],620 gray: [90, 39],621 // Alias of `blackBright`622 grey: [90, 39],623 // Alias of `blackBright`624 redBright: [91, 39],625 greenBright: [92, 39],626 yellowBright: [93, 39],627 blueBright: [94, 39],628 magentaBright: [95, 39],629 cyanBright: [96, 39],630 whiteBright: [97, 39]631 },632 bgColor: {633 bgBlack: [40, 49],634 bgRed: [41, 49],635 bgGreen: [42, 49],636 bgYellow: [43, 49],637 bgBlue: [44, 49],638 bgMagenta: [45, 49],639 bgCyan: [46, 49],640 bgWhite: [47, 49],641 // Bright color642 bgBlackBright: [100, 49],643 bgGray: [100, 49],644 // Alias of `bgBlackBright`645 bgGrey: [100, 49],646 // Alias of `bgBlackBright`647 bgRedBright: [101, 49],648 bgGreenBright: [102, 49],649 bgYellowBright: [103, 49],650 bgBlueBright: [104, 49],651 bgMagentaBright: [105, 49],652 bgCyanBright: [106, 49],653 bgWhiteBright: [107, 49]654 }655};656var modifierNames = Object.keys(styles.modifier);657var foregroundColorNames = Object.keys(styles.color);658var backgroundColorNames = Object.keys(styles.bgColor);659var colorNames = [...foregroundColorNames, ...backgroundColorNames];660function assembleStyles() {661 const codes = /* @__PURE__ */ new Map();662 for (const [groupName, group] of Object.entries(styles)) {663 for (const [styleName, style] of Object.entries(group)) {664 styles[styleName] = {665 open: `\x1B[${style[0]}m`,666 close: `\x1B[${style[1]}m`667 };668 group[styleName] = styles[styleName];669 codes.set(style[0], style[1]);670 }671 Object.defineProperty(styles, groupName, {672 value: group,673 enumerable: false674 });675 }676 Object.defineProperty(styles, "codes", {677 value: codes,678 enumerable: false679 });680 styles.color.close = "\x1B[39m";681 styles.bgColor.close = "\x1B[49m";682 styles.color.ansi = wrapAnsi16();683 styles.color.ansi256 = wrapAnsi256();684 styles.color.ansi16m = wrapAnsi16m();685 styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);686 styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);687 styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);688 Object.defineProperties(styles, {689 rgbToAnsi256: {690 value(red, green, blue) {691 if (red === green && green === blue) {692 if (red < 8) {693 return 16;694 }695 if (red > 248) {696 return 231;697 }698 return Math.round((red - 8) / 247 * 24) + 232;699 }700 return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);701 },702 enumerable: false703 },704 hexToRgb: {705 value(hex) {706 const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));707 if (!matches) {708 return [0, 0, 0];709 }710 let [colorString] = matches;711 if (colorString.length === 3) {712 colorString = [...colorString].map((character) => character + character).join("");713 }714 const integer = Number.parseInt(colorString, 16);715 return [716 /* eslint-disable no-bitwise */717 integer >> 16 & 255,718 integer >> 8 & 255,719 integer & 255720 /* eslint-enable no-bitwise */721 ];722 },723 enumerable: false724 },725 hexToAnsi256: {726 value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),727 enumerable: false728 },729 ansi256ToAnsi: {730 value(code) {731 if (code < 8) {732 return 30 + code;733 }734 if (code < 16) {735 return 90 + (code - 8);736 }737 let red;738 let green;739 let blue;740 if (code >= 232) {741 red = ((code - 232) * 10 + 8) / 255;742 green = red;743 blue = red;744 } else {745 code -= 16;746 const remainder = code % 36;747 red = Math.floor(code / 36) / 5;748 green = Math.floor(remainder / 6) / 5;749 blue = remainder % 6 / 5;750 }751 const value = Math.max(red, green, blue) * 2;752 if (value === 0) {753 return 30;754 }755 let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));756 if (value === 2) {757 result += 60;758 }759 return result;760 },761 enumerable: false762 },763 rgbToAnsi: {764 value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),765 enumerable: false766 },767 hexToAnsi: {768 value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),769 enumerable: false770 }771 });772 return styles;773}774var ansiStyles = assembleStyles();775var ansi_styles_default = ansiStyles;776 777// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js778import process2 from "node:process";779import os from "node:os";780import tty from "node:tty";781function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {782 const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";783 const position = argv.indexOf(prefix + flag);784 const terminatorPosition = argv.indexOf("--");785 return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);786}787var { env } = process2;788var flagForceColor;789if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {790 flagForceColor = 0;791} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {792 flagForceColor = 1;793}794function envForceColor() {795 if ("FORCE_COLOR" in env) {796 if (env.FORCE_COLOR === "true") {797 return 1;798 }799 if (env.FORCE_COLOR === "false") {800 return 0;801 }802 return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);803 }804}805function translateLevel(level) {806 if (level === 0) {807 return false;808 }809 return {810 level,811 hasBasic: true,812 has256: level >= 2,813 has16m: level >= 3814 };815}816function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {817 const noFlagForceColor = envForceColor();818 if (noFlagForceColor !== void 0) {819 flagForceColor = noFlagForceColor;820 }821 const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;822 if (forceColor === 0) {823 return 0;824 }825 if (sniffFlags) {826 if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {827 return 3;828 }829 if (hasFlag("color=256")) {830 return 2;831 }832 }833 if ("TF_BUILD" in env && "AGENT_NAME" in env) {834 return 1;835 }836 if (haveStream && !streamIsTTY && forceColor === void 0) {837 return 0;838 }839 const min = forceColor || 0;840 if (env.TERM === "dumb") {841 return min;842 }843 if (process2.platform === "win32") {844 const osRelease = os.release().split(".");845 if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {846 return Number(osRelease[2]) >= 14931 ? 3 : 2;847 }848 return 1;849 }850 if ("CI" in env) {851 if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {852 return 3;853 }854 if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {855 return 1;856 }857 return min;858 }859 if ("TEAMCITY_VERSION" in env) {860 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;861 }862 if (env.COLORTERM === "truecolor") {863 return 3;864 }865 if (env.TERM === "xterm-kitty") {866 return 3;867 }868 if ("TERM_PROGRAM" in env) {869 const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);870 switch (env.TERM_PROGRAM) {871 case "iTerm.app": {872 return version >= 3 ? 3 : 2;873 }874 case "Apple_Terminal": {875 return 2;876 }877 }878 }879 if (/-256(color)?$/i.test(env.TERM)) {880 return 2;881 }882 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {883 return 1;884 }885 if ("COLORTERM" in env) {886 return 1;887 }888 return min;889}890function createSupportsColor(stream, options = {}) {891 const level = _supportsColor(stream, {892 streamIsTTY: stream && stream.isTTY,893 ...options894 });895 return translateLevel(level);896}897var supportsColor = {898 stdout: createSupportsColor({ isTTY: tty.isatty(1) }),899 stderr: createSupportsColor({ isTTY: tty.isatty(2) })900};901var supports_color_default = supportsColor;902 903// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js904function stringReplaceAll(string, substring, replacer) {905 let index6 = string.indexOf(substring);906 if (index6 === -1) {907 return string;908 }909 const substringLength = substring.length;910 let endIndex = 0;911 let returnValue = "";912 do {913 returnValue += string.slice(endIndex, index6) + substring + replacer;914 endIndex = index6 + substringLength;915 index6 = string.indexOf(substring, endIndex);916 } while (index6 !== -1);917 returnValue += string.slice(endIndex);918 return returnValue;919}920function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index6) {921 let endIndex = 0;922 let returnValue = "";923 do {924 const gotCR = string[index6 - 1] === "\r";925 returnValue += string.slice(endIndex, gotCR ? index6 - 1 : index6) + prefix + (gotCR ? "\r\n" : "\n") + postfix;926 endIndex = index6 + 1;927 index6 = string.indexOf("\n", endIndex);928 } while (index6 !== -1);929 returnValue += string.slice(endIndex);930 return returnValue;931}932 933// ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js934var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;935var GENERATOR = Symbol("GENERATOR");936var STYLER = Symbol("STYLER");937var IS_EMPTY = Symbol("IS_EMPTY");938var levelMapping = [939 "ansi",940 "ansi",941 "ansi256",942 "ansi16m"943];944var styles2 = /* @__PURE__ */ Object.create(null);945var applyOptions = (object, options = {}) => {946 if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {947 throw new Error("The `level` option should be an integer from 0 to 3");948 }949 const colorLevel = stdoutColor ? stdoutColor.level : 0;950 object.level = options.level === void 0 ? colorLevel : options.level;951};952var chalkFactory = (options) => {953 const chalk2 = (...strings) => strings.join(" ");954 applyOptions(chalk2, options);955 Object.setPrototypeOf(chalk2, createChalk.prototype);956 return chalk2;957};958function createChalk(options) {959 return chalkFactory(options);960}961Object.setPrototypeOf(createChalk.prototype, Function.prototype);962for (const [styleName, style] of Object.entries(ansi_styles_default)) {963 styles2[styleName] = {964 get() {965 const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);966 Object.defineProperty(this, styleName, { value: builder });967 return builder;968 }969 };970}971styles2.visible = {972 get() {973 const builder = createBuilder(this, this[STYLER], true);974 Object.defineProperty(this, "visible", { value: builder });975 return builder;976 }977};978var getModelAnsi = (model, level, type, ...arguments_) => {979 if (model === "rgb") {980 if (level === "ansi16m") {981 return ansi_styles_default[type].ansi16m(...arguments_);982 }983 if (level === "ansi256") {984 return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));985 }986 return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));987 }988 if (model === "hex") {989 return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));990 }991 return ansi_styles_default[type][model](...arguments_);992};993var usedModels = ["rgb", "hex", "ansi256"];994for (const model of usedModels) {995 styles2[model] = {996 get() {997 const { level } = this;998 return function(...arguments_) {999 const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);1000 return createBuilder(this, styler, this[IS_EMPTY]);1001 };1002 }1003 };1004 const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);1005 styles2[bgModel] = {1006 get() {1007 const { level } = this;1008 return function(...arguments_) {1009 const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);1010 return createBuilder(this, styler, this[IS_EMPTY]);1011 };1012 }1013 };1014}1015var proto = Object.defineProperties(() => {1016}, {1017 ...styles2,1018 level: {1019 enumerable: true,1020 get() {1021 return this[GENERATOR].level;1022 },1023 set(level) {1024 this[GENERATOR].level = level;1025 }1026 }1027});1028var createStyler = (open, close, parent) => {1029 let openAll;1030 let closeAll;1031 if (parent === void 0) {1032 openAll = open;1033 closeAll = close;1034 } else {1035 openAll = parent.openAll + open;1036 closeAll = close + parent.closeAll;1037 }1038 return {1039 open,1040 close,1041 openAll,1042 closeAll,1043 parent1044 };1045};1046var createBuilder = (self2, _styler, _isEmpty) => {1047 const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));1048 Object.setPrototypeOf(builder, proto);1049 builder[GENERATOR] = self2;1050 builder[STYLER] = _styler;1051 builder[IS_EMPTY] = _isEmpty;1052 return builder;1053};1054var applyStyle = (self2, string) => {1055 if (self2.level <= 0 || !string) {1056 return self2[IS_EMPTY] ? "" : string;1057 }1058 let styler = self2[STYLER];1059 if (styler === void 0) {1060 return string;1061 }1062 const { openAll, closeAll } = styler;1063 if (string.includes("\x1B")) {1064 while (styler !== void 0) {1065 string = stringReplaceAll(string, styler.close, styler.open);1066 styler = styler.parent;1067 }1068 }1069 const lfIndex = string.indexOf("\n");1070 if (lfIndex !== -1) {1071 string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);1072 }1073 return openAll + string + closeAll;1074};1075Object.defineProperties(createChalk.prototype, styles2);1076var chalk = createChalk();1077var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });1078var source_default = chalk;1079 1080// src/utils.ts1081import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";1082import { join } from "path";1083import { parse } from "url";1084 1085// src/cli/views.ts1086var import_hanji = __toESM(require_hanji());1087var info = (msg, greyMsg = "") => {1088 return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();1089};1090 1091// src/global.ts1092var originUUID = "00000000-0000-0000-0000-000000000000";1093var snapshotVersion = "7";1094function assertUnreachable(x) {1095 throw new Error("Didn't expect to get here");1096}1097 1098// ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js1099var util;1100(function(util2) {1101 util2.assertEqual = (_) => {1102 };1103 function assertIs(_arg) {1104 }1105 util2.assertIs = assertIs;1106 function assertNever(_x) {1107 throw new Error();1108 }1109 util2.assertNever = assertNever;1110 util2.arrayToEnum = (items) => {1111 const obj = {};1112 for (const item of items) {1113 obj[item] = item;1114 }1115 return obj;1116 };1117 util2.getValidEnumValues = (obj) => {1118 const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");1119 const filtered = {};1120 for (const k of validKeys) {1121 filtered[k] = obj[k];1122 }1123 return util2.objectValues(filtered);1124 };1125 util2.objectValues = (obj) => {1126 return util2.objectKeys(obj).map(function(e) {1127 return obj[e];1128 });1129 };1130 util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {1131 const keys = [];1132 for (const key in object) {1133 if (Object.prototype.hasOwnProperty.call(object, key)) {1134 keys.push(key);1135 }1136 }1137 return keys;1138 };1139 util2.find = (arr, checker) => {1140 for (const item of arr) {1141 if (checker(item))1142 return item;1143 }1144 return void 0;1145 };1146 util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;1147 function joinValues(array, separator = " | ") {1148 return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);1149 }1150 util2.joinValues = joinValues;1151 util2.jsonStringifyReplacer = (_, value) => {1152 if (typeof value === "bigint") {1153 return value.toString();1154 }1155 return value;1156 };1157})(util || (util = {}));1158var objectUtil;1159(function(objectUtil2) {1160 objectUtil2.mergeShapes = (first, second) => {1161 return {1162 ...first,1163 ...second1164 // second overwrites first1165 };1166 };1167})(objectUtil || (objectUtil = {}));1168var ZodParsedType = util.arrayToEnum([1169 "string",1170 "nan",1171 "number",1172 "integer",1173 "float",1174 "boolean",1175 "date",1176 "bigint",1177 "symbol",1178 "function",1179 "undefined",1180 "null",1181 "array",1182 "object",1183 "unknown",1184 "promise",1185 "void",1186 "never",1187 "map",1188 "set"1189]);1190var getParsedType = (data) => {1191 const t = typeof data;1192 switch (t) {1193 case "undefined":1194 return ZodParsedType.undefined;1195 case "string":1196 return ZodParsedType.string;1197 case "number":1198 return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;1199 case "boolean":1200 return ZodParsedType.boolean;