UNPKG

@wreckingball/opencommit

Version:

Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫

1,515 lines (1,478 loc) • 1.86 MB
#!/usr/bin/env node "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all3) => { for (var name in all3) __defProp(target, name, { get: all3[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // node_modules/isexe/windows.js var require_windows = __commonJS({ "node_modules/isexe/windows.js"(exports, module2) { module2.exports = isexe; isexe.sync = sync; var fs4 = require("fs"); function checkPathExt(path5, options) { var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT; if (!pathext) { return true; } pathext = pathext.split(";"); if (pathext.indexOf("") !== -1) { return true; } for (var i2 = 0; i2 < pathext.length; i2++) { var p4 = pathext[i2].toLowerCase(); if (p4 && path5.substr(-p4.length).toLowerCase() === p4) { return true; } } return false; } function checkStat(stat, path5, options) { if (!stat.isSymbolicLink() && !stat.isFile()) { return false; } return checkPathExt(path5, options); } function isexe(path5, options, cb) { fs4.stat(path5, function(er, stat) { cb(er, er ? false : checkStat(stat, path5, options)); }); } function sync(path5, options) { return checkStat(fs4.statSync(path5), path5, options); } } }); // node_modules/isexe/mode.js var require_mode = __commonJS({ "node_modules/isexe/mode.js"(exports, module2) { module2.exports = isexe; isexe.sync = sync; var fs4 = require("fs"); function isexe(path5, options, cb) { fs4.stat(path5, function(er, stat) { cb(er, er ? false : checkStat(stat, options)); }); } function sync(path5, options) { return checkStat(fs4.statSync(path5), options); } function checkStat(stat, options) { return stat.isFile() && checkMode(stat, options); } function checkMode(stat, options) { var mod = stat.mode; var uid = stat.uid; var gid = stat.gid; var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(); var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(); var u2 = parseInt("100", 8); var g3 = parseInt("010", 8); var o2 = parseInt("001", 8); var ug = u2 | g3; var ret = mod & o2 || mod & g3 && gid === myGid || mod & u2 && uid === myUid || mod & ug && myUid === 0; return ret; } } }); // node_modules/isexe/index.js var require_isexe = __commonJS({ "node_modules/isexe/index.js"(exports, module2) { var fs4 = require("fs"); var core; if (process.platform === "win32" || global.TESTING_WINDOWS) { core = require_windows(); } else { core = require_mode(); } module2.exports = isexe; isexe.sync = sync; function isexe(path5, options, cb) { if (typeof options === "function") { cb = options; options = {}; } if (!cb) { if (typeof Promise !== "function") { throw new TypeError("callback not provided"); } return new Promise(function(resolve, reject) { isexe(path5, options || {}, function(er, is) { if (er) { reject(er); } else { resolve(is); } }); }); } core(path5, options || {}, function(er, is) { if (er) { if (er.code === "EACCES" || options && options.ignoreErrors) { er = null; is = false; } } cb(er, is); }); } function sync(path5, options) { try { return core.sync(path5, options || {}); } catch (er) { if (options && options.ignoreErrors || er.code === "EACCES") { return false; } else { throw er; } } } } }); // node_modules/which/which.js var require_which = __commonJS({ "node_modules/which/which.js"(exports, module2) { var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; var path5 = require("path"); var COLON = isWindows ? ";" : ":"; var isexe = require_isexe(); var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }); var getPathInfo = (cmd, opt) => { const colon = opt.colon || COLON; const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [ ...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH || "").split(colon) ]; const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : ""; const pathExt = isWindows ? pathExtExe.split(colon) : [""]; if (isWindows) { if (cmd.indexOf(".") !== -1 && pathExt[0] !== "") pathExt.unshift(""); } return { pathEnv, pathExt, pathExtExe }; }; var which = (cmd, opt, cb) => { if (typeof opt === "function") { cb = opt; opt = {}; } if (!opt) opt = {}; const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); const found = []; const step = (i2) => new Promise((resolve, reject) => { if (i2 === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd)); const ppRaw = pathEnv[i2]; const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; const pCmd = path5.join(pathPart, cmd); const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; resolve(subStep(p4, i2, 0)); }); const subStep = (p4, i2, ii) => new Promise((resolve, reject) => { if (ii === pathExt.length) return resolve(step(i2 + 1)); const ext = pathExt[ii]; isexe(p4 + ext, { pathExt: pathExtExe }, (er, is) => { if (!er && is) { if (opt.all) found.push(p4 + ext); else return resolve(p4 + ext); } return resolve(subStep(p4, i2, ii + 1)); }); }); return cb ? step(0).then((res) => cb(null, res), cb) : step(0); }; var whichSync = (cmd, opt) => { opt = opt || {}; const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); const found = []; for (let i2 = 0; i2 < pathEnv.length; i2++) { const ppRaw = pathEnv[i2]; const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; const pCmd = path5.join(pathPart, cmd); const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; for (let j3 = 0; j3 < pathExt.length; j3++) { const cur = p4 + pathExt[j3]; try { const is = isexe.sync(cur, { pathExt: pathExtExe }); if (is) { if (opt.all) found.push(cur); else return cur; } } catch (ex) { } } } if (opt.all && found.length) return found; if (opt.nothrow) return null; throw getNotFoundError(cmd); }; module2.exports = which; which.sync = whichSync; } }); // node_modules/path-key/index.js var require_path_key = __commonJS({ "node_modules/path-key/index.js"(exports, module2) { "use strict"; var pathKey2 = (options = {}) => { const environment = options.env || process.env; const platform = options.platform || process.platform; if (platform !== "win32") { return "PATH"; } return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path"; }; module2.exports = pathKey2; module2.exports.default = pathKey2; } }); // node_modules/cross-spawn/lib/util/resolveCommand.js var require_resolveCommand = __commonJS({ "node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) { "use strict"; var path5 = require("path"); var which = require_which(); var getPathKey = require_path_key(); function resolveCommandAttempt(parsed, withoutPathExt) { const env2 = parsed.options.env || process.env; const cwd = process.cwd(); const hasCustomCwd = parsed.options.cwd != null; const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled; if (shouldSwitchCwd) { try { process.chdir(parsed.options.cwd); } catch (err) { } } let resolved; try { resolved = which.sync(parsed.command, { path: env2[getPathKey({ env: env2 })], pathExt: withoutPathExt ? path5.delimiter : void 0 }); } catch (e2) { } finally { if (shouldSwitchCwd) { process.chdir(cwd); } } if (resolved) { resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved); } return resolved; } function resolveCommand(parsed) { return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true); } module2.exports = resolveCommand; } }); // node_modules/cross-spawn/lib/util/escape.js var require_escape = __commonJS({ "node_modules/cross-spawn/lib/util/escape.js"(exports, module2) { "use strict"; var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g; function escapeCommand(arg) { arg = arg.replace(metaCharsRegExp, "^$1"); return arg; } function escapeArgument(arg, doubleEscapeMetaChars) { arg = `${arg}`; arg = arg.replace(/(\\*)"/g, '$1$1\\"'); arg = arg.replace(/(\\*)$/, "$1$1"); arg = `"${arg}"`; arg = arg.replace(metaCharsRegExp, "^$1"); if (doubleEscapeMetaChars) { arg = arg.replace(metaCharsRegExp, "^$1"); } return arg; } module2.exports.command = escapeCommand; module2.exports.argument = escapeArgument; } }); // node_modules/shebang-regex/index.js var require_shebang_regex = __commonJS({ "node_modules/shebang-regex/index.js"(exports, module2) { "use strict"; module2.exports = /^#!(.*)/; } }); // node_modules/shebang-command/index.js var require_shebang_command = __commonJS({ "node_modules/shebang-command/index.js"(exports, module2) { "use strict"; var shebangRegex = require_shebang_regex(); module2.exports = (string = "") => { const match = string.match(shebangRegex); if (!match) { return null; } const [path5, argument] = match[0].replace(/#! ?/, "").split(" "); const binary = path5.split("/").pop(); if (binary === "env") { return argument; } return argument ? `${binary} ${argument}` : binary; }; } }); // node_modules/cross-spawn/lib/util/readShebang.js var require_readShebang = __commonJS({ "node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) { "use strict"; var fs4 = require("fs"); var shebangCommand = require_shebang_command(); function readShebang(command2) { const size = 150; const buffer = Buffer.alloc(size); let fd; try { fd = fs4.openSync(command2, "r"); fs4.readSync(fd, buffer, 0, size, 0); fs4.closeSync(fd); } catch (e2) { } return shebangCommand(buffer.toString()); } module2.exports = readShebang; } }); // node_modules/cross-spawn/lib/parse.js var require_parse = __commonJS({ "node_modules/cross-spawn/lib/parse.js"(exports, module2) { "use strict"; var path5 = require("path"); var resolveCommand = require_resolveCommand(); var escape = require_escape(); var readShebang = require_readShebang(); var isWin = process.platform === "win32"; var isExecutableRegExp = /\.(?:com|exe)$/i; var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; function detectShebang(parsed) { parsed.file = resolveCommand(parsed); const shebang = parsed.file && readShebang(parsed.file); if (shebang) { parsed.args.unshift(parsed.file); parsed.command = shebang; return resolveCommand(parsed); } return parsed.file; } function parseNonShell(parsed) { if (!isWin) { return parsed; } const commandFile = detectShebang(parsed); const needsShell = !isExecutableRegExp.test(commandFile); if (parsed.options.forceShell || needsShell) { const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); parsed.command = path5.normalize(parsed.command); parsed.command = escape.command(parsed.command); parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); const shellCommand = [parsed.command].concat(parsed.args).join(" "); parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`]; parsed.command = process.env.comspec || "cmd.exe"; parsed.options.windowsVerbatimArguments = true; } return parsed; } function parse(command2, args, options) { if (args && !Array.isArray(args)) { options = args; args = null; } args = args ? args.slice(0) : []; options = Object.assign({}, options); const parsed = { command: command2, args, options, file: void 0, original: { command: command2, args } }; return options.shell ? parsed : parseNonShell(parsed); } module2.exports = parse; } }); // node_modules/cross-spawn/lib/enoent.js var require_enoent = __commonJS({ "node_modules/cross-spawn/lib/enoent.js"(exports, module2) { "use strict"; var isWin = process.platform === "win32"; function notFoundError(original, syscall) { return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), { code: "ENOENT", errno: "ENOENT", syscall: `${syscall} ${original.command}`, path: original.command, spawnargs: original.args }); } function hookChildProcess(cp, parsed) { if (!isWin) { return; } const originalEmit = cp.emit; cp.emit = function(name, arg1) { if (name === "exit") { const err = verifyENOENT(arg1, parsed, "spawn"); if (err) { return originalEmit.call(cp, "error", err); } } return originalEmit.apply(cp, arguments); }; } function verifyENOENT(status, parsed) { if (isWin && status === 1 && !parsed.file) { return notFoundError(parsed.original, "spawn"); } return null; } function verifyENOENTSync(status, parsed) { if (isWin && status === 1 && !parsed.file) { return notFoundError(parsed.original, "spawnSync"); } return null; } module2.exports = { hookChildProcess, verifyENOENT, verifyENOENTSync, notFoundError }; } }); // node_modules/cross-spawn/index.js var require_cross_spawn = __commonJS({ "node_modules/cross-spawn/index.js"(exports, module2) { "use strict"; var cp = require("child_process"); var parse = require_parse(); var enoent = require_enoent(); function spawn(command2, args, options) { const parsed = parse(command2, args, options); const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); enoent.hookChildProcess(spawned, parsed); return spawned; } function spawnSync(command2, args, options) { const parsed = parse(command2, args, options); const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); return result; } module2.exports = spawn; module2.exports.spawn = spawn; module2.exports.sync = spawnSync; module2.exports._parse = parse; module2.exports._enoent = enoent; } }); // node_modules/signal-exit/signals.js var require_signals = __commonJS({ "node_modules/signal-exit/signals.js"(exports, module2) { module2.exports = [ "SIGABRT", "SIGALRM", "SIGHUP", "SIGINT", "SIGTERM" ]; if (process.platform !== "win32") { module2.exports.push( "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT" ); } if (process.platform === "linux") { module2.exports.push( "SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED" ); } } }); // node_modules/signal-exit/index.js var require_signal_exit = __commonJS({ "node_modules/signal-exit/index.js"(exports, module2) { var process5 = global.process; var processOk = function(process6) { return process6 && typeof process6 === "object" && typeof process6.removeListener === "function" && typeof process6.emit === "function" && typeof process6.reallyExit === "function" && typeof process6.listeners === "function" && typeof process6.kill === "function" && typeof process6.pid === "number" && typeof process6.on === "function"; }; if (!processOk(process5)) { module2.exports = function() { return function() { }; }; } else { assert = require("assert"); signals = require_signals(); isWin = /^win/i.test(process5.platform); EE = require("events"); if (typeof EE !== "function") { EE = EE.EventEmitter; } if (process5.__signal_exit_emitter__) { emitter = process5.__signal_exit_emitter__; } else { emitter = process5.__signal_exit_emitter__ = new EE(); emitter.count = 0; emitter.emitted = {}; } if (!emitter.infinite) { emitter.setMaxListeners(Infinity); emitter.infinite = true; } module2.exports = function(cb, opts) { if (!processOk(global.process)) { return function() { }; } assert.equal(typeof cb, "function", "a callback must be provided for exit handler"); if (loaded === false) { load(); } var ev = "exit"; if (opts && opts.alwaysLast) { ev = "afterexit"; } var remove = function() { emitter.removeListener(ev, cb); if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) { unload(); } }; emitter.on(ev, cb); return remove; }; unload = function unload2() { if (!loaded || !processOk(global.process)) { return; } loaded = false; signals.forEach(function(sig) { try { process5.removeListener(sig, sigListeners[sig]); } catch (er) { } }); process5.emit = originalProcessEmit; process5.reallyExit = originalProcessReallyExit; emitter.count -= 1; }; module2.exports.unload = unload; emit = function emit2(event, code, signal) { if (emitter.emitted[event]) { return; } emitter.emitted[event] = true; emitter.emit(event, code, signal); }; sigListeners = {}; signals.forEach(function(sig) { sigListeners[sig] = function listener() { if (!processOk(global.process)) { return; } var listeners = process5.listeners(sig); if (listeners.length === emitter.count) { unload(); emit("exit", null, sig); emit("afterexit", null, sig); if (isWin && sig === "SIGHUP") { sig = "SIGINT"; } process5.kill(process5.pid, sig); } }; }); module2.exports.signals = function() { return signals; }; loaded = false; load = function load2() { if (loaded || !processOk(global.process)) { return; } loaded = true; emitter.count += 1; signals = signals.filter(function(sig) { try { process5.on(sig, sigListeners[sig]); return true; } catch (er) { return false; } }); process5.emit = processEmit; process5.reallyExit = processReallyExit; }; module2.exports.load = load; originalProcessReallyExit = process5.reallyExit; processReallyExit = function processReallyExit2(code) { if (!processOk(global.process)) { return; } process5.exitCode = code || 0; emit("exit", process5.exitCode, null); emit("afterexit", process5.exitCode, null); originalProcessReallyExit.call(process5, process5.exitCode); }; originalProcessEmit = process5.emit; processEmit = function processEmit2(ev, arg) { if (ev === "exit" && processOk(global.process)) { if (arg !== void 0) { process5.exitCode = arg; } var ret = originalProcessEmit.apply(this, arguments); emit("exit", process5.exitCode, null); emit("afterexit", process5.exitCode, null); return ret; } else { return originalProcessEmit.apply(this, arguments); } }; } var assert; var signals; var isWin; var EE; var emitter; var unload; var emit; var sigListeners; var loaded; var load; var originalProcessReallyExit; var processReallyExit; var originalProcessEmit; var processEmit; } }); // node_modules/get-stream/buffer-stream.js var require_buffer_stream = __commonJS({ "node_modules/get-stream/buffer-stream.js"(exports, module2) { "use strict"; var { PassThrough: PassThroughStream } = require("stream"); module2.exports = (options) => { options = { ...options }; const { array } = options; let { encoding } = options; const isBuffer2 = encoding === "buffer"; let objectMode = false; if (array) { objectMode = !(encoding || isBuffer2); } else { encoding = encoding || "utf8"; } if (isBuffer2) { encoding = null; } const stream4 = new PassThroughStream({ objectMode }); if (encoding) { stream4.setEncoding(encoding); } let length = 0; const chunks = []; stream4.on("data", (chunk) => { chunks.push(chunk); if (objectMode) { length = chunks.length; } else { length += chunk.length; } }); stream4.getBufferedValue = () => { if (array) { return chunks; } return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join(""); }; stream4.getBufferedLength = () => length; return stream4; }; } }); // node_modules/get-stream/index.js var require_get_stream = __commonJS({ "node_modules/get-stream/index.js"(exports, module2) { "use strict"; var { constants: BufferConstants } = require("buffer"); var stream4 = require("stream"); var { promisify } = require("util"); var bufferStream = require_buffer_stream(); var streamPipelinePromisified = promisify(stream4.pipeline); var MaxBufferError = class extends Error { constructor() { super("maxBuffer exceeded"); this.name = "MaxBufferError"; } }; async function getStream2(inputStream, options) { if (!inputStream) { throw new Error("Expected a stream"); } options = { maxBuffer: Infinity, ...options }; const { maxBuffer } = options; const stream5 = bufferStream(options); await new Promise((resolve, reject) => { const rejectPromise = (error) => { if (error && stream5.getBufferedLength() <= BufferConstants.MAX_LENGTH) { error.bufferedData = stream5.getBufferedValue(); } reject(error); }; (async () => { try { await streamPipelinePromisified(inputStream, stream5); resolve(); } catch (error) { rejectPromise(error); } })(); stream5.on("data", () => { if (stream5.getBufferedLength() > maxBuffer) { rejectPromise(new MaxBufferError()); } }); }); return stream5.getBufferedValue(); } module2.exports = getStream2; module2.exports.buffer = (stream5, options) => getStream2(stream5, { ...options, encoding: "buffer" }); module2.exports.array = (stream5, options) => getStream2(stream5, { ...options, array: true }); module2.exports.MaxBufferError = MaxBufferError; } }); // node_modules/merge-stream/index.js var require_merge_stream = __commonJS({ "node_modules/merge-stream/index.js"(exports, module2) { "use strict"; var { PassThrough } = require("stream"); module2.exports = function() { var sources = []; var output = new PassThrough({ objectMode: true }); output.setMaxListeners(0); output.add = add; output.isEmpty = isEmpty; output.on("unpipe", remove); Array.prototype.slice.call(arguments).forEach(add); return output; function add(source) { if (Array.isArray(source)) { source.forEach(add); return this; } sources.push(source); source.once("end", remove.bind(null, source)); source.once("error", output.emit.bind(output, "error")); source.pipe(output, { end: false }); return this; } function isEmpty() { return sources.length == 0; } function remove(source) { sources = sources.filter(function(it) { return it !== source; }); if (!sources.length && output.readable) { output.end(); } } }; } }); // node_modules/sisteransi/src/index.js var require_src = __commonJS({ "node_modules/sisteransi/src/index.js"(exports, module2) { "use strict"; var ESC = "\x1B"; var CSI = `${ESC}[`; var beep = "\x07"; var cursor = { to(x4, y5) { if (!y5) return `${CSI}${x4 + 1}G`; return `${CSI}${y5 + 1};${x4 + 1}H`; }, move(x4, y5) { let ret = ""; if (x4 < 0) ret += `${CSI}${-x4}D`; else if (x4 > 0) ret += `${CSI}${x4}C`; if (y5 < 0) ret += `${CSI}${-y5}A`; else if (y5 > 0) ret += `${CSI}${y5}B`; return ret; }, up: (count = 1) => `${CSI}${count}A`, down: (count = 1) => `${CSI}${count}B`, forward: (count = 1) => `${CSI}${count}C`, backward: (count = 1) => `${CSI}${count}D`, nextLine: (count = 1) => `${CSI}E`.repeat(count), prevLine: (count = 1) => `${CSI}F`.repeat(count), left: `${CSI}G`, hide: `${CSI}?25l`, show: `${CSI}?25h`, save: `${ESC}7`, restore: `${ESC}8` }; var scroll = { up: (count = 1) => `${CSI}S`.repeat(count), down: (count = 1) => `${CSI}T`.repeat(count) }; var erase = { screen: `${CSI}2J`, up: (count = 1) => `${CSI}1J`.repeat(count), down: (count = 1) => `${CSI}J`.repeat(count), line: `${CSI}2K`, lineEnd: `${CSI}K`, lineStart: `${CSI}1K`, lines(count) { let clear = ""; for (let i2 = 0; i2 < count; i2++) clear += this.line + (i2 < count - 1 ? cursor.up() : ""); if (count) clear += cursor.left; return clear; } }; module2.exports = { cursor, scroll, erase, beep }; } }); // node_modules/picocolors/picocolors.js var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(exports, module2) { var tty2 = require("tty"); var isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || process.platform === "win32" || tty2.isatty(1) && process.env.TERM !== "dumb" || "CI" in process.env); var formatter = (open, close, replace = open) => (input) => { let string = "" + input; let index = string.indexOf(close, open.length); return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close; }; var replaceClose = (string, close, replace, index) => { let start = string.substring(0, index) + replace; let end = string.substring(index + close.length); let nextIndex = end.indexOf(close); return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end; }; var createColors = (enabled = isColorSupported) => ({ isColorSupported: enabled, reset: enabled ? (s) => `\x1B[0m${s}\x1B[0m` : String, bold: enabled ? formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m") : String, dim: enabled ? formatter("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m") : String, italic: enabled ? formatter("\x1B[3m", "\x1B[23m") : String, underline: enabled ? formatter("\x1B[4m", "\x1B[24m") : String, inverse: enabled ? formatter("\x1B[7m", "\x1B[27m") : String, hidden: enabled ? formatter("\x1B[8m", "\x1B[28m") : String, strikethrough: enabled ? formatter("\x1B[9m", "\x1B[29m") : String, black: enabled ? formatter("\x1B[30m", "\x1B[39m") : String, red: enabled ? formatter("\x1B[31m", "\x1B[39m") : String, green: enabled ? formatter("\x1B[32m", "\x1B[39m") : String, yellow: enabled ? formatter("\x1B[33m", "\x1B[39m") : String, blue: enabled ? formatter("\x1B[34m", "\x1B[39m") : String, magenta: enabled ? formatter("\x1B[35m", "\x1B[39m") : String, cyan: enabled ? formatter("\x1B[36m", "\x1B[39m") : String, white: enabled ? formatter("\x1B[37m", "\x1B[39m") : String, gray: enabled ? formatter("\x1B[90m", "\x1B[39m") : String, bgBlack: enabled ? formatter("\x1B[40m", "\x1B[49m") : String, bgRed: enabled ? formatter("\x1B[41m", "\x1B[49m") : String, bgGreen: enabled ? formatter("\x1B[42m", "\x1B[49m") : String, bgYellow: enabled ? formatter("\x1B[43m", "\x1B[49m") : String, bgBlue: enabled ? formatter("\x1B[44m", "\x1B[49m") : String, bgMagenta: enabled ? formatter("\x1B[45m", "\x1B[49m") : String, bgCyan: enabled ? formatter("\x1B[46m", "\x1B[49m") : String, bgWhite: enabled ? formatter("\x1B[47m", "\x1B[49m") : String }); module2.exports = createColors(); module2.exports.createColors = createColors; } }); // node_modules/openai/node_modules/axios/lib/helpers/bind.js var require_bind = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/bind.js"(exports, module2) { "use strict"; module2.exports = function bind2(fn, thisArg) { return function wrap() { var args = new Array(arguments.length); for (var i2 = 0; i2 < args.length; i2++) { args[i2] = arguments[i2]; } return fn.apply(thisArg, args); }; }; } }); // node_modules/openai/node_modules/axios/lib/utils.js var require_utils = __commonJS({ "node_modules/openai/node_modules/axios/lib/utils.js"(exports, module2) { "use strict"; var bind2 = require_bind(); var toString3 = Object.prototype.toString; function isArray2(val) { return Array.isArray(val); } function isUndefined2(val) { return typeof val === "undefined"; } function isBuffer2(val) { return val !== null && !isUndefined2(val) && val.constructor !== null && !isUndefined2(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val); } function isArrayBuffer2(val) { return toString3.call(val) === "[object ArrayBuffer]"; } function isFormData2(val) { return toString3.call(val) === "[object FormData]"; } function isArrayBufferView2(val) { var result; if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) { result = ArrayBuffer.isView(val); } else { result = val && val.buffer && isArrayBuffer2(val.buffer); } return result; } function isString2(val) { return typeof val === "string"; } function isNumber2(val) { return typeof val === "number"; } function isObject2(val) { return val !== null && typeof val === "object"; } function isPlainObject2(val) { if (toString3.call(val) !== "[object Object]") { return false; } var prototype3 = Object.getPrototypeOf(val); return prototype3 === null || prototype3 === Object.prototype; } function isDate2(val) { return toString3.call(val) === "[object Date]"; } function isFile2(val) { return toString3.call(val) === "[object File]"; } function isBlob2(val) { return toString3.call(val) === "[object Blob]"; } function isFunction2(val) { return toString3.call(val) === "[object Function]"; } function isStream3(val) { return isObject2(val) && isFunction2(val.pipe); } function isURLSearchParams2(val) { return toString3.call(val) === "[object URLSearchParams]"; } function trim2(str) { return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ""); } function isStandardBrowserEnv() { if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) { return false; } return typeof window !== "undefined" && typeof document !== "undefined"; } function forEach2(obj, fn) { if (obj === null || typeof obj === "undefined") { return; } if (typeof obj !== "object") { obj = [obj]; } if (isArray2(obj)) { for (var i2 = 0, l = obj.length; i2 < l; i2++) { fn.call(null, obj[i2], i2, obj); } } else { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { fn.call(null, obj[key], key, obj); } } } } function merge2() { var result = {}; function assignValue(val, key) { if (isPlainObject2(result[key]) && isPlainObject2(val)) { result[key] = merge2(result[key], val); } else if (isPlainObject2(val)) { result[key] = merge2({}, val); } else if (isArray2(val)) { result[key] = val.slice(); } else { result[key] = val; } } for (var i2 = 0, l = arguments.length; i2 < l; i2++) { forEach2(arguments[i2], assignValue); } return result; } function extend2(a2, b6, thisArg) { forEach2(b6, function assignValue(val, key) { if (thisArg && typeof val === "function") { a2[key] = bind2(val, thisArg); } else { a2[key] = val; } }); return a2; } function stripBOM2(content) { if (content.charCodeAt(0) === 65279) { content = content.slice(1); } return content; } module2.exports = { isArray: isArray2, isArrayBuffer: isArrayBuffer2, isBuffer: isBuffer2, isFormData: isFormData2, isArrayBufferView: isArrayBufferView2, isString: isString2, isNumber: isNumber2, isObject: isObject2, isPlainObject: isPlainObject2, isUndefined: isUndefined2, isDate: isDate2, isFile: isFile2, isBlob: isBlob2, isFunction: isFunction2, isStream: isStream3, isURLSearchParams: isURLSearchParams2, isStandardBrowserEnv, forEach: forEach2, merge: merge2, extend: extend2, trim: trim2, stripBOM: stripBOM2 }; } }); // node_modules/openai/node_modules/axios/lib/helpers/buildURL.js var require_buildURL = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/buildURL.js"(exports, module2) { "use strict"; var utils = require_utils(); function encode3(val) { return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); } module2.exports = function buildURL2(url3, params, paramsSerializer) { if (!params) { return url3; } var serializedParams; if (paramsSerializer) { serializedParams = paramsSerializer(params); } else if (utils.isURLSearchParams(params)) { serializedParams = params.toString(); } else { var parts = []; utils.forEach(params, function serialize(val, key) { if (val === null || typeof val === "undefined") { return; } if (utils.isArray(val)) { key = key + "[]"; } else { val = [val]; } utils.forEach(val, function parseValue(v4) { if (utils.isDate(v4)) { v4 = v4.toISOString(); } else if (utils.isObject(v4)) { v4 = JSON.stringify(v4); } parts.push(encode3(key) + "=" + encode3(v4)); }); }); serializedParams = parts.join("&"); } if (serializedParams) { var hashmarkIndex = url3.indexOf("#"); if (hashmarkIndex !== -1) { url3 = url3.slice(0, hashmarkIndex); } url3 += (url3.indexOf("?") === -1 ? "?" : "&") + serializedParams; } return url3; }; } }); // node_modules/openai/node_modules/axios/lib/core/InterceptorManager.js var require_InterceptorManager = __commonJS({ "node_modules/openai/node_modules/axios/lib/core/InterceptorManager.js"(exports, module2) { "use strict"; var utils = require_utils(); function InterceptorManager2() { this.handlers = []; } InterceptorManager2.prototype.use = function use(fulfilled, rejected, options) { this.handlers.push({ fulfilled, rejected, synchronous: options ? options.synchronous : false, runWhen: options ? options.runWhen : null }); return this.handlers.length - 1; }; InterceptorManager2.prototype.eject = function eject(id) { if (this.handlers[id]) { this.handlers[id] = null; } }; InterceptorManager2.prototype.forEach = function forEach2(fn) { utils.forEach(this.handlers, function forEachHandler(h4) { if (h4 !== null) { fn(h4); } }); }; module2.exports = InterceptorManager2; } }); // node_modules/openai/node_modules/axios/lib/helpers/normalizeHeaderName.js var require_normalizeHeaderName = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/normalizeHeaderName.js"(exports, module2) { "use strict"; var utils = require_utils(); module2.exports = function normalizeHeaderName(headers, normalizedName) { utils.forEach(headers, function processHeader(value, name) { if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { headers[normalizedName] = value; delete headers[name]; } }); }; } }); // node_modules/openai/node_modules/axios/lib/core/enhanceError.js var require_enhanceError = __commonJS({ "node_modules/openai/node_modules/axios/lib/core/enhanceError.js"(exports, module2) { "use strict"; module2.exports = function enhanceError(error, config8, code, request, response) { error.config = config8; if (code) { error.code = code; } error.request = request; error.response = response; error.isAxiosError = true; error.toJSON = function toJSON2() { return { message: this.message, name: this.name, description: this.description, number: this.number, fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, config: this.config, code: this.code, status: this.response && this.response.status ? this.response.status : null }; }; return error; }; } }); // node_modules/openai/node_modules/axios/lib/defaults/transitional.js var require_transitional = __commonJS({ "node_modules/openai/node_modules/axios/lib/defaults/transitional.js"(exports, module2) { "use strict"; module2.exports = { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }; } }); // node_modules/openai/node_modules/axios/lib/core/createError.js var require_createError = __commonJS({ "node_modules/openai/node_modules/axios/lib/core/createError.js"(exports, module2) { "use strict"; var enhanceError = require_enhanceError(); module2.exports = function createError(message, config8, code, request, response) { var error = new Error(message); return enhanceError(error, config8, code, request, response); }; } }); // node_modules/openai/node_modules/axios/lib/core/settle.js var require_settle = __commonJS({ "node_modules/openai/node_modules/axios/lib/core/settle.js"(exports, module2) { "use strict"; var createError = require_createError(); module2.exports = function settle2(resolve, reject, response) { var validateStatus2 = response.config.validateStatus; if (!response.status || !validateStatus2 || validateStatus2(response.status)) { resolve(response); } else { reject(createError( "Request failed with status code " + response.status, response.config, null, response.request, response )); } }; } }); // node_modules/openai/node_modules/axios/lib/helpers/cookies.js var require_cookies = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/cookies.js"(exports, module2) { "use strict"; var utils = require_utils(); module2.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv2() { return { write: function write(name, value, expires, path5, domain, secure) { var cookie = []; cookie.push(name + "=" + encodeURIComponent(value)); if (utils.isNumber(expires)) { cookie.push("expires=" + new Date(expires).toGMTString()); } if (utils.isString(path5)) { cookie.push("path=" + path5); } if (utils.isString(domain)) { cookie.push("domain=" + domain); } if (secure === true) { cookie.push("secure"); } document.cookie = cookie.join("; "); }, read: function read(name) { var match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)")); return match ? decodeURIComponent(match[3]) : null; }, remove: function remove(name) { this.write(name, "", Date.now() - 864e5); } }; }() : function nonStandardBrowserEnv2() { return { write: function write() { }, read: function read() { return null; }, remove: function remove() { } }; }(); } }); // node_modules/openai/node_modules/axios/lib/helpers/isAbsoluteURL.js var require_isAbsoluteURL = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/isAbsoluteURL.js"(exports, module2) { "use strict"; module2.exports = function isAbsoluteURL2(url3) { return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url3); }; } }); // node_modules/openai/node_modules/axios/lib/helpers/combineURLs.js var require_combineURLs = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/combineURLs.js"(exports, module2) { "use strict"; module2.exports = function combineURLs2(baseURL, relativeURL) { return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL; }; } }); // node_modules/openai/node_modules/axios/lib/core/buildFullPath.js var require_buildFullPath = __commonJS({ "node_modules/openai/node_modules/axios/lib/core/buildFullPath.js"(exports, module2) { "use strict"; var isAbsoluteURL2 = require_isAbsoluteURL(); var combineURLs2 = require_combineURLs(); module2.exports = function buildFullPath2(baseURL, requestedURL) { if (baseURL && !isAbsoluteURL2(requestedURL)) { return combineURLs2(baseURL, requestedURL); } return requestedURL; }; } }); // node_modules/openai/node_modules/axios/lib/helpers/parseHeaders.js var require_parseHeaders = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/parseHeaders.js"(exports, module2) { "use strict"; var utils = require_utils(); var ignoreDuplicateOf2 = [ "age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent" ]; module2.exports = function parseHeaders(headers) { var parsed = {}; var key; var val; var i2; if (!headers) { return parsed; } utils.forEach(headers.split("\n"), function parser(line) { i2 = line.indexOf(":"); key = utils.trim(line.substr(0, i2)).toLowerCase(); val = utils.trim(line.substr(i2 + 1)); if (key) { if (parsed[key] && ignoreDuplicateOf2.indexOf(key) >= 0) { return; } if (key === "set-cookie") { parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); } else { parsed[key] = parsed[key] ? parsed[key] + ", " + val : val; } } }); return parsed; }; } }); // node_modules/openai/node_modules/axios/lib/helpers/isURLSameOrigin.js var require_isURLSameOrigin = __commonJS({ "node_modules/openai/node_modules/axios/lib/helpers/isURLSameOrigin.js"(exports, module2) { "use strict"; var utils = require_utils(); module2.exports = utils.isStandardBrowserEnv() ? function standardBrowserEnv2() { var msie = /(msie|trident)/i.test(navigator.userAgent); var urlParsingNode = document.createElement("a"); var originURL; function resolveURL(url3) { var href = url3; if (msie) { urlParsingNode.setAttribute("href", href); href = urlParsingNode.href; } urlParsingNode.setAttribute("href", href); return { href: urlParsingNode.href, protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "", host: urlParsingNode.host, search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "", hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "", hostname: urlParsingNode.hostname, port: urlParsingNode.port, pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname }; } originURL = resolveURL(window.location.href); return function isURLSameOrigin(requestURL) { var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL; return parsed.protocol === originURL.protocol && parsed.host === originURL.host; }; }() : function nonStandardBrowserEnv2() { return function isURLSameOrigin() { return true; }; }(); } }); // node_modules/openai/node_modules/axios/lib/cancel/Cancel.js var require_Cancel = __commonJS({ "node_modules/openai/node_modules/axios/lib/cancel/Cancel.js"(exports, module2) { "use strict"; function Cancel2(message) { this.message = message; } Cancel2.prototype.toString = function toString3() { return "Cancel" + (this.message ? ": " + this.message : ""); }; Cancel2.prototype.__CANCEL__ = true; module2.exports = Cancel2; } }); // node_modules/openai/node_modules/axios/lib/adapters/xhr.js var require_xhr = __commonJS({ "node_modules/openai/node_modules/axios/lib/adapters/xhr.js"(exports, module2) { "use strict"; var utils = require_utils(); var settle2 = require_settle(); var cookies = require_cookies(); var buildURL2 = require_buildURL(); var buildFullPath2 = require_buildFullPath(); var parseHeaders = require_parseHeaders(); var isURLSameOrigin = require_isURLSameOrigin(); var createError = require_createError(); var transitionalDefaults = require_transitional(); var Cancel2 = require_Cancel(); module2.exports = function