UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

1,521 lines (1,495 loc) • 195 kB
import CJS_COMPAT_NODE_URL_q99y7iqlbzn from 'node:url'; import CJS_COMPAT_NODE_PATH_q99y7iqlbzn from 'node:path'; import CJS_COMPAT_NODE_MODULE_q99y7iqlbzn from "node:module"; var __filename = CJS_COMPAT_NODE_URL_q99y7iqlbzn.fileURLToPath(import.meta.url); var __dirname = CJS_COMPAT_NODE_PATH_q99y7iqlbzn.dirname(__filename); var require = CJS_COMPAT_NODE_MODULE_q99y7iqlbzn.createRequire(import.meta.url); // ------------------------------------------------------------ // end of CJS compatibility banner, injected by Storybook's esbuild configuration // ------------------------------------------------------------ import { require_pretty_hrtime } from "../_node-chunks/chunk-XANJ6OPT.js"; import { ansi_styles_default, boxen, require_string_width, stripAnsi } from "../_node-chunks/chunk-7KVBPQLP.js"; import "../_node-chunks/chunk-TNNFJ72G.js"; import { execaSync, optionalEnvToBoolean } from "../_node-chunks/chunk-CWTRQZTU.js"; import "../_node-chunks/chunk-ZJVEXDYR.js"; import { require_prompts, require_src } from "../_node-chunks/chunk-KCF2Q4OQ.js"; import { require_picocolors } from "../_node-chunks/chunk-KABHBSS3.js"; import { __commonJS, __export, __name, __require, __toESM } from "../_node-chunks/chunk-MB5KTO7X.js"; // ../node_modules/are-we-there-yet/lib/tracker-base.js var require_tracker_base = __commonJS({ "../node_modules/are-we-there-yet/lib/tracker-base.js"(exports, module) { "use strict"; var EventEmitter = __require("events"); var trackerId = 0; var TrackerBase = class extends EventEmitter { static { __name(this, "TrackerBase"); } constructor(name) { super(); this.id = ++trackerId; this.name = name; } }; module.exports = TrackerBase; } }); // ../node_modules/are-we-there-yet/lib/tracker.js var require_tracker = __commonJS({ "../node_modules/are-we-there-yet/lib/tracker.js"(exports, module) { "use strict"; var TrackerBase = require_tracker_base(); var Tracker = class extends TrackerBase { static { __name(this, "Tracker"); } constructor(name, todo) { super(name); this.workDone = 0; this.workTodo = todo || 0; } completed() { return this.workTodo === 0 ? 0 : this.workDone / this.workTodo; } addWork(work) { this.workTodo += work; this.emit("change", this.name, this.completed(), this); } completeWork(work) { this.workDone += work; if (this.workDone > this.workTodo) { this.workDone = this.workTodo; } this.emit("change", this.name, this.completed(), this); } finish() { this.workTodo = this.workDone = 1; this.emit("change", this.name, 1, this); } }; module.exports = Tracker; } }); // ../node_modules/are-we-there-yet/lib/tracker-stream.js var require_tracker_stream = __commonJS({ "../node_modules/are-we-there-yet/lib/tracker-stream.js"(exports, module) { "use strict"; var stream = __require("stream"); var Tracker = require_tracker(); var TrackerStream = class extends stream.Transform { static { __name(this, "TrackerStream"); } constructor(name, size, options) { super(options); this.tracker = new Tracker(name, size); this.name = name; this.id = this.tracker.id; this.tracker.on("change", this.trackerChange.bind(this)); } trackerChange(name, completion) { this.emit("change", name, completion, this); } _transform(data, encoding, cb) { this.tracker.completeWork(data.length ? data.length : 1); this.push(data); cb(); } _flush(cb) { this.tracker.finish(); cb(); } completed() { return this.tracker.completed(); } addWork(work) { return this.tracker.addWork(work); } finish() { return this.tracker.finish(); } }; module.exports = TrackerStream; } }); // ../node_modules/are-we-there-yet/lib/tracker-group.js var require_tracker_group = __commonJS({ "../node_modules/are-we-there-yet/lib/tracker-group.js"(exports, module) { "use strict"; var TrackerBase = require_tracker_base(); var Tracker = require_tracker(); var TrackerStream = require_tracker_stream(); var TrackerGroup = class _TrackerGroup extends TrackerBase { static { __name(this, "TrackerGroup"); } parentGroup = null; trackers = []; completion = {}; weight = {}; totalWeight = 0; finished = false; bubbleChange = bubbleChange(this); nameInTree() { var names = []; var from = this; while (from) { names.unshift(from.name); from = from.parentGroup; } return names.join("/"); } addUnit(unit, weight) { if (unit.addUnit) { var toTest = this; while (toTest) { if (unit === toTest) { throw new Error( "Attempted to add tracker group " + unit.name + " to tree that already includes it " + this.nameInTree(this) ); } toTest = toTest.parentGroup; } unit.parentGroup = this; } this.weight[unit.id] = weight || 1; this.totalWeight += this.weight[unit.id]; this.trackers.push(unit); this.completion[unit.id] = unit.completed(); unit.on("change", this.bubbleChange); if (!this.finished) { this.emit("change", unit.name, this.completion[unit.id], unit); } return unit; } completed() { if (this.trackers.length === 0) { return 0; } var valPerWeight = 1 / this.totalWeight; var completed = 0; for (var ii = 0; ii < this.trackers.length; ii++) { var trackerId = this.trackers[ii].id; completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]; } return completed; } newGroup(name, weight) { return this.addUnit(new _TrackerGroup(name), weight); } newItem(name, todo, weight) { return this.addUnit(new Tracker(name, todo), weight); } newStream(name, todo, weight) { return this.addUnit(new TrackerStream(name, todo), weight); } finish() { this.finished = true; if (!this.trackers.length) { this.addUnit(new Tracker(), 1, true); } for (var ii = 0; ii < this.trackers.length; ii++) { var tracker = this.trackers[ii]; tracker.finish(); tracker.removeListener("change", this.bubbleChange); } this.emit("change", this.name, 1, this); } debug(depth = 0) { const indent = " ".repeat(depth); let output = `${indent}${this.name || "top"}: ${this.completed()} `; this.trackers.forEach(function(tracker) { output += tracker instanceof _TrackerGroup ? tracker.debug(depth + 1) : `${indent} ${tracker.name}: ${tracker.completed()} `; }); return output; } }; function bubbleChange(trackerGroup) { return function(name, completed, tracker) { trackerGroup.completion[tracker.id] = completed; if (trackerGroup.finished) { return; } trackerGroup.emit("change", name || trackerGroup.name, trackerGroup.completed(), trackerGroup); }; } __name(bubbleChange, "bubbleChange"); module.exports = TrackerGroup; } }); // ../node_modules/are-we-there-yet/lib/index.js var require_lib = __commonJS({ "../node_modules/are-we-there-yet/lib/index.js"(exports) { "use strict"; exports.TrackerGroup = require_tracker_group(); exports.Tracker = require_tracker(); exports.TrackerStream = require_tracker_stream(); } }); // ../node_modules/console-control-strings/index.js var require_console_control_strings = __commonJS({ "../node_modules/console-control-strings/index.js"(exports) { "use strict"; var prefix = "\x1B["; exports.up = /* @__PURE__ */ __name(function up(num) { return prefix + (num || "") + "A"; }, "up"); exports.down = /* @__PURE__ */ __name(function down(num) { return prefix + (num || "") + "B"; }, "down"); exports.forward = /* @__PURE__ */ __name(function forward(num) { return prefix + (num || "") + "C"; }, "forward"); exports.back = /* @__PURE__ */ __name(function back(num) { return prefix + (num || "") + "D"; }, "back"); exports.nextLine = /* @__PURE__ */ __name(function nextLine(num) { return prefix + (num || "") + "E"; }, "nextLine"); exports.previousLine = /* @__PURE__ */ __name(function previousLine(num) { return prefix + (num || "") + "F"; }, "previousLine"); exports.horizontalAbsolute = /* @__PURE__ */ __name(function horizontalAbsolute(num) { if (num == null) throw new Error("horizontalAboslute requires a column to position to"); return prefix + num + "G"; }, "horizontalAbsolute"); exports.eraseData = /* @__PURE__ */ __name(function eraseData() { return prefix + "J"; }, "eraseData"); exports.eraseLine = /* @__PURE__ */ __name(function eraseLine() { return prefix + "K"; }, "eraseLine"); exports.goto = function(x, y2) { return prefix + y2 + ";" + x + "H"; }; exports.gotoSOL = function() { return "\r"; }; exports.beep = function() { return "\x07"; }; exports.hideCursor = /* @__PURE__ */ __name(function hideCursor() { return prefix + "?25l"; }, "hideCursor"); exports.showCursor = /* @__PURE__ */ __name(function showCursor() { return prefix + "?25h"; }, "showCursor"); var colors2 = { reset: 0, // styles bold: 1, italic: 3, underline: 4, inverse: 7, // resets stopBold: 22, stopItalic: 23, stopUnderline: 24, stopInverse: 27, // colors white: 37, black: 30, blue: 34, cyan: 36, green: 32, magenta: 35, red: 31, yellow: 33, bgWhite: 47, bgBlack: 40, bgBlue: 44, bgCyan: 46, bgGreen: 42, bgMagenta: 45, bgRed: 41, bgYellow: 43, grey: 90, brightBlack: 90, brightRed: 91, brightGreen: 92, brightYellow: 93, brightBlue: 94, brightMagenta: 95, brightCyan: 96, brightWhite: 97, bgGrey: 100, bgBrightBlack: 100, bgBrightRed: 101, bgBrightGreen: 102, bgBrightYellow: 103, bgBrightBlue: 104, bgBrightMagenta: 105, bgBrightCyan: 106, bgBrightWhite: 107 }; exports.color = /* @__PURE__ */ __name(function color(colorWith) { if (arguments.length !== 1 || !Array.isArray(colorWith)) { colorWith = Array.prototype.slice.call(arguments); } return prefix + colorWith.map(colorNameToCode).join(";") + "m"; }, "color"); function colorNameToCode(color) { if (colors2[color] != null) return colors2[color]; throw new Error("Unknown color or style name: " + color); } __name(colorNameToCode, "colorNameToCode"); } }); // ../node_modules/wide-align/align.js var require_align = __commonJS({ "../node_modules/wide-align/align.js"(exports) { "use strict"; var stringWidth2 = require_string_width(); exports.center = alignCenter; exports.left = alignLeft; exports.right = alignRight; function createPadding(width) { var result = ""; var string = " "; var n = width; do { if (n % 2) { result += string; } n = Math.floor(n / 2); string += string; } while (n); return result; } __name(createPadding, "createPadding"); function alignLeft(str, width) { var trimmed = str.trimRight(); if (trimmed.length === 0 && str.length >= width) return str; var padding = ""; var strWidth = stringWidth2(trimmed); if (strWidth < width) { padding = createPadding(width - strWidth); } return trimmed + padding; } __name(alignLeft, "alignLeft"); function alignRight(str, width) { var trimmed = str.trimLeft(); if (trimmed.length === 0 && str.length >= width) return str; var padding = ""; var strWidth = stringWidth2(trimmed); if (strWidth < width) { padding = createPadding(width - strWidth); } return padding + trimmed; } __name(alignRight, "alignRight"); function alignCenter(str, width) { var trimmed = str.trim(); if (trimmed.length === 0 && str.length >= width) return str; var padLeft = ""; var padRight = ""; var strWidth = stringWidth2(trimmed); if (strWidth < width) { var padLeftBy = parseInt((width - strWidth) / 2, 10); padLeft = createPadding(padLeftBy); padRight = createPadding(width - (strWidth + padLeftBy)); } return padLeft + trimmed + padRight; } __name(alignCenter, "alignCenter"); } }); // ../node_modules/aproba/index.js var require_aproba = __commonJS({ "../node_modules/aproba/index.js"(exports, module) { "use strict"; module.exports = validate; function isArguments(thingy) { return thingy != null && typeof thingy === "object" && thingy.hasOwnProperty("callee"); } __name(isArguments, "isArguments"); var types = { "*": { label: "any", check: /* @__PURE__ */ __name(() => true, "check") }, A: { label: "array", check: /* @__PURE__ */ __name((_2) => Array.isArray(_2) || isArguments(_2), "check") }, S: { label: "string", check: /* @__PURE__ */ __name((_2) => typeof _2 === "string", "check") }, N: { label: "number", check: /* @__PURE__ */ __name((_2) => typeof _2 === "number", "check") }, F: { label: "function", check: /* @__PURE__ */ __name((_2) => typeof _2 === "function", "check") }, O: { label: "object", check: /* @__PURE__ */ __name((_2) => typeof _2 === "object" && _2 != null && !types.A.check(_2) && !types.E.check(_2), "check") }, B: { label: "boolean", check: /* @__PURE__ */ __name((_2) => typeof _2 === "boolean", "check") }, E: { label: "error", check: /* @__PURE__ */ __name((_2) => _2 instanceof Error, "check") }, Z: { label: "null", check: /* @__PURE__ */ __name((_2) => _2 == null, "check") } }; function addSchema(schema, arity) { const group = arity[schema.length] = arity[schema.length] || []; if (group.indexOf(schema) === -1) group.push(schema); } __name(addSchema, "addSchema"); function validate(rawSchemas, args) { if (arguments.length !== 2) throw wrongNumberOfArgs(["SA"], arguments.length); if (!rawSchemas) throw missingRequiredArg(0, "rawSchemas"); if (!args) throw missingRequiredArg(1, "args"); if (!types.S.check(rawSchemas)) throw invalidType(0, ["string"], rawSchemas); if (!types.A.check(args)) throw invalidType(1, ["array"], args); const schemas = rawSchemas.split("|"); const arity = {}; schemas.forEach((schema) => { for (let ii = 0; ii < schema.length; ++ii) { const type = schema[ii]; if (!types[type]) throw unknownType(ii, type); } if (/E.*E/.test(schema)) throw moreThanOneError(schema); addSchema(schema, arity); if (/E/.test(schema)) { addSchema(schema.replace(/E.*$/, "E"), arity); addSchema(schema.replace(/E/, "Z"), arity); if (schema.length === 1) addSchema("", arity); } }); let matching = arity[args.length]; if (!matching) { throw wrongNumberOfArgs(Object.keys(arity), args.length); } for (let ii = 0; ii < args.length; ++ii) { let newMatching = matching.filter((schema) => { const type = schema[ii]; const typeCheck = types[type].check; return typeCheck(args[ii]); }); if (!newMatching.length) { const labels = matching.map((_2) => types[_2[ii]].label).filter((_2) => _2 != null); throw invalidType(ii, labels, args[ii]); } matching = newMatching; } } __name(validate, "validate"); function missingRequiredArg(num) { return newException("EMISSINGARG", "Missing required argument #" + (num + 1)); } __name(missingRequiredArg, "missingRequiredArg"); function unknownType(num, type) { return newException("EUNKNOWNTYPE", "Unknown type " + type + " in argument #" + (num + 1)); } __name(unknownType, "unknownType"); function invalidType(num, expectedTypes, value) { let valueType; Object.keys(types).forEach((typeCode) => { if (types[typeCode].check(value)) valueType = types[typeCode].label; }); return newException("EINVALIDTYPE", "Argument #" + (num + 1) + ": Expected " + englishList(expectedTypes) + " but got " + valueType); } __name(invalidType, "invalidType"); function englishList(list) { return list.join(", ").replace(/, ([^,]+)$/, " or $1"); } __name(englishList, "englishList"); function wrongNumberOfArgs(expected, got) { const english = englishList(expected); const args = expected.every((ex) => ex.length === 1) ? "argument" : "arguments"; return newException("EWRONGARGCOUNT", "Expected " + english + " " + args + " but got " + got); } __name(wrongNumberOfArgs, "wrongNumberOfArgs"); function moreThanOneError(schema) { return newException( "ETOOMANYERRORTYPES", 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"' ); } __name(moreThanOneError, "moreThanOneError"); function newException(code, msg) { const err = new TypeError(msg); err.code = code; if (Error.captureStackTrace) Error.captureStackTrace(err, validate); return err; } __name(newException, "newException"); } }); // ../node_modules/gauge/node_modules/ansi-regex/index.js var require_ansi_regex = __commonJS({ "../node_modules/gauge/node_modules/ansi-regex/index.js"(exports, module) { "use strict"; module.exports = ({ onlyFirst = false } = {}) => { const pattern = [ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))" ].join("|"); return new RegExp(pattern, onlyFirst ? void 0 : "g"); }; } }); // ../node_modules/gauge/node_modules/strip-ansi/index.js var require_strip_ansi = __commonJS({ "../node_modules/gauge/node_modules/strip-ansi/index.js"(exports, module) { "use strict"; var ansiRegex2 = require_ansi_regex(); module.exports = (string) => typeof string === "string" ? string.replace(ansiRegex2(), "") : string; } }); // ../node_modules/gauge/lib/wide-truncate.js var require_wide_truncate = __commonJS({ "../node_modules/gauge/lib/wide-truncate.js"(exports, module) { "use strict"; var stringWidth2 = require_string_width(); var stripAnsi3 = require_strip_ansi(); module.exports = wideTruncate; function wideTruncate(str, target) { if (stringWidth2(str) === 0) { return str; } if (target <= 0) { return ""; } if (stringWidth2(str) <= target) { return str; } var noAnsi = stripAnsi3(str); var ansiSize = str.length + noAnsi.length; var truncated = str.slice(0, target + ansiSize); while (stringWidth2(truncated) > target) { truncated = truncated.slice(0, -1); } return truncated; } __name(wideTruncate, "wideTruncate"); } }); // ../node_modules/gauge/lib/error.js var require_error = __commonJS({ "../node_modules/gauge/lib/error.js"(exports) { "use strict"; var util = __require("util"); var User = exports.User = /* @__PURE__ */ __name(function User2(msg) { var err = new Error(msg); Error.captureStackTrace(err, User2); err.code = "EGAUGE"; return err; }, "User"); exports.MissingTemplateValue = /* @__PURE__ */ __name(function MissingTemplateValue(item, values) { var err = new User(util.format('Missing template value "%s"', item.type)); Error.captureStackTrace(err, MissingTemplateValue); err.template = item; err.values = values; return err; }, "MissingTemplateValue"); exports.Internal = /* @__PURE__ */ __name(function Internal(msg) { var err = new Error(msg); Error.captureStackTrace(err, Internal); err.code = "EGAUGEINTERNAL"; return err; }, "Internal"); } }); // ../node_modules/gauge/lib/template-item.js var require_template_item = __commonJS({ "../node_modules/gauge/lib/template-item.js"(exports, module) { "use strict"; var stringWidth2 = require_string_width(); module.exports = TemplateItem; function isPercent(num) { if (typeof num !== "string") { return false; } return num.slice(-1) === "%"; } __name(isPercent, "isPercent"); function percent(num) { return Number(num.slice(0, -1)) / 100; } __name(percent, "percent"); function TemplateItem(values, outputLength) { this.overallOutputLength = outputLength; this.finished = false; this.type = null; this.value = null; this.length = null; this.maxLength = null; this.minLength = null; this.kerning = null; this.align = "left"; this.padLeft = 0; this.padRight = 0; this.index = null; this.first = null; this.last = null; if (typeof values === "string") { this.value = values; } else { for (var prop in values) { this[prop] = values[prop]; } } if (isPercent(this.length)) { this.length = Math.round(this.overallOutputLength * percent(this.length)); } if (isPercent(this.minLength)) { this.minLength = Math.round(this.overallOutputLength * percent(this.minLength)); } if (isPercent(this.maxLength)) { this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength)); } return this; } __name(TemplateItem, "TemplateItem"); TemplateItem.prototype = {}; TemplateItem.prototype.getBaseLength = function() { var length = this.length; if (length == null && typeof this.value === "string" && this.maxLength == null && this.minLength == null) { length = stringWidth2(this.value); } return length; }; TemplateItem.prototype.getLength = function() { var length = this.getBaseLength(); if (length == null) { return null; } return length + this.padLeft + this.padRight; }; TemplateItem.prototype.getMaxLength = function() { if (this.maxLength == null) { return null; } return this.maxLength + this.padLeft + this.padRight; }; TemplateItem.prototype.getMinLength = function() { if (this.minLength == null) { return null; } return this.minLength + this.padLeft + this.padRight; }; } }); // ../node_modules/gauge/lib/render-template.js var require_render_template = __commonJS({ "../node_modules/gauge/lib/render-template.js"(exports, module) { "use strict"; var align = require_align(); var validate = require_aproba(); var wideTruncate = require_wide_truncate(); var error2 = require_error(); var TemplateItem = require_template_item(); function renderValueWithValues(values) { return function(item) { return renderValue(item, values); }; } __name(renderValueWithValues, "renderValueWithValues"); var renderTemplate = module.exports = function(width, template, values) { var items = prepareItems(width, template, values); var rendered = items.map(renderValueWithValues(values)).join(""); return align.left(wideTruncate(rendered, width), width); }; function preType(item) { var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1); return "pre" + cappedTypeName; } __name(preType, "preType"); function postType(item) { var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1); return "post" + cappedTypeName; } __name(postType, "postType"); function hasPreOrPost(item, values) { if (!item.type) { return; } return values[preType(item)] || values[postType(item)]; } __name(hasPreOrPost, "hasPreOrPost"); function generatePreAndPost(baseItem, parentValues) { var item = Object.assign({}, baseItem); var values = Object.create(parentValues); var template = []; var pre = preType(item); var post = postType(item); if (values[pre]) { template.push({ value: values[pre] }); values[pre] = null; } item.minLength = null; item.length = null; item.maxLength = null; template.push(item); values[item.type] = values[item.type]; if (values[post]) { template.push({ value: values[post] }); values[post] = null; } return function($1, $2, length) { return renderTemplate(length, template, values); }; } __name(generatePreAndPost, "generatePreAndPost"); function prepareItems(width, template, values) { function cloneAndObjectify(item, index, arr) { var cloned = new TemplateItem(item, width); var type = cloned.type; if (cloned.value == null) { if (!(type in values)) { if (cloned.default == null) { throw new error2.MissingTemplateValue(cloned, values); } else { cloned.value = cloned.default; } } else { cloned.value = values[type]; } } if (cloned.value == null || cloned.value === "") { return null; } cloned.index = index; cloned.first = index === 0; cloned.last = index === arr.length - 1; if (hasPreOrPost(cloned, values)) { cloned.value = generatePreAndPost(cloned, values); } return cloned; } __name(cloneAndObjectify, "cloneAndObjectify"); var output = template.map(cloneAndObjectify).filter(function(item) { return item != null; }); var remainingSpace = width; var variableCount = output.length; function consumeSpace(length) { if (length > remainingSpace) { length = remainingSpace; } remainingSpace -= length; } __name(consumeSpace, "consumeSpace"); function finishSizing(item, length) { if (item.finished) { throw new error2.Internal("Tried to finish template item that was already finished"); } if (length === Infinity) { throw new error2.Internal("Length of template item cannot be infinity"); } if (length != null) { item.length = length; } item.minLength = null; item.maxLength = null; --variableCount; item.finished = true; if (item.length == null) { item.length = item.getBaseLength(); } if (item.length == null) { throw new error2.Internal("Finished template items must have a length"); } consumeSpace(item.getLength()); } __name(finishSizing, "finishSizing"); output.forEach(function(item) { if (!item.kerning) { return; } var prevPadRight = item.first ? 0 : output[item.index - 1].padRight; if (!item.first && prevPadRight < item.kerning) { item.padLeft = item.kerning - prevPadRight; } if (!item.last) { item.padRight = item.kerning; } }); output.forEach(function(item) { if (item.getBaseLength() == null) { return; } finishSizing(item); }); var resized = 0; var resizing; var hunkSize; do { resizing = false; hunkSize = Math.round(remainingSpace / variableCount); output.forEach(function(item) { if (item.finished) { return; } if (!item.maxLength) { return; } if (item.getMaxLength() < hunkSize) { finishSizing(item, item.maxLength); resizing = true; } }); } while (resizing && resized++ < output.length); if (resizing) { throw new error2.Internal("Resize loop iterated too many times while determining maxLength"); } resized = 0; do { resizing = false; hunkSize = Math.round(remainingSpace / variableCount); output.forEach(function(item) { if (item.finished) { return; } if (!item.minLength) { return; } if (item.getMinLength() >= hunkSize) { finishSizing(item, item.minLength); resizing = true; } }); } while (resizing && resized++ < output.length); if (resizing) { throw new error2.Internal("Resize loop iterated too many times while determining minLength"); } hunkSize = Math.round(remainingSpace / variableCount); output.forEach(function(item) { if (item.finished) { return; } finishSizing(item, hunkSize); }); return output; } __name(prepareItems, "prepareItems"); function renderFunction(item, values, length) { validate("OON", arguments); if (item.type) { return item.value(values, values[item.type + "Theme"] || {}, length); } else { return item.value(values, {}, length); } } __name(renderFunction, "renderFunction"); function renderValue(item, values) { var length = item.getBaseLength(); var value = typeof item.value === "function" ? renderFunction(item, values, length) : item.value; if (value == null || value === "") { return ""; } var alignWith = align[item.align] || align.left; var leftPadding = item.padLeft ? align.left("", item.padLeft) : ""; var rightPadding = item.padRight ? align.right("", item.padRight) : ""; var truncated = wideTruncate(String(value), length); var aligned = alignWith(truncated, length); return leftPadding + aligned + rightPadding; } __name(renderValue, "renderValue"); } }); // ../node_modules/gauge/lib/plumbing.js var require_plumbing = __commonJS({ "../node_modules/gauge/lib/plumbing.js"(exports, module) { "use strict"; var consoleControl = require_console_control_strings(); var renderTemplate = require_render_template(); var validate = require_aproba(); var Plumbing = module.exports = function(theme, template, width) { if (!width) { width = 80; } validate("OAN", [theme, template, width]); this.showing = false; this.theme = theme; this.width = width; this.template = template; }; Plumbing.prototype = {}; Plumbing.prototype.setTheme = function(theme) { validate("O", [theme]); this.theme = theme; }; Plumbing.prototype.setTemplate = function(template) { validate("A", [template]); this.template = template; }; Plumbing.prototype.setWidth = function(width) { validate("N", [width]); this.width = width; }; Plumbing.prototype.hide = function() { return consoleControl.gotoSOL() + consoleControl.eraseLine(); }; Plumbing.prototype.hideCursor = consoleControl.hideCursor; Plumbing.prototype.showCursor = consoleControl.showCursor; Plumbing.prototype.show = function(status) { var values = Object.create(this.theme); for (var key in status) { values[key] = status[key]; } return renderTemplate(this.width, this.template, values).trim() + consoleControl.color("reset") + consoleControl.eraseLine() + consoleControl.gotoSOL(); }; } }); // ../node_modules/has-unicode/index.js var require_has_unicode = __commonJS({ "../node_modules/has-unicode/index.js"(exports, module) { "use strict"; var os = __require("os"); var hasUnicode = module.exports = function() { if (os.type() == "Windows_NT") { return false; } var isUTF8 = /UTF-?8$/i; var ctype = process.env.LC_ALL || process.env.LC_CTYPE || process.env.LANG; return isUTF8.test(ctype); }; } }); // ../node_modules/color-support/index.js var require_color_support = __commonJS({ "../node_modules/color-support/index.js"(exports, module) { module.exports = colorSupport({ alwaysReturn: true }, colorSupport); function hasNone(obj, options) { obj.level = 0; obj.hasBasic = false; obj.has256 = false; obj.has16m = false; if (!options.alwaysReturn) { return false; } return obj; } __name(hasNone, "hasNone"); function hasBasic(obj) { obj.hasBasic = true; obj.has256 = false; obj.has16m = false; obj.level = 1; return obj; } __name(hasBasic, "hasBasic"); function has256(obj) { obj.hasBasic = true; obj.has256 = true; obj.has16m = false; obj.level = 2; return obj; } __name(has256, "has256"); function has16m(obj) { obj.hasBasic = true; obj.has256 = true; obj.has16m = true; obj.level = 3; return obj; } __name(has16m, "has16m"); function colorSupport(options, obj) { options = options || {}; obj = obj || {}; if (typeof options.level === "number") { switch (options.level) { case 0: return hasNone(obj, options); case 1: return hasBasic(obj); case 2: return has256(obj); case 3: return has16m(obj); } } obj.level = 0; obj.hasBasic = false; obj.has256 = false; obj.has16m = false; if (typeof process === "undefined" || !process || !process.stdout || !process.env || !process.platform) { return hasNone(obj, options); } var env = options.env || process.env; var stream = options.stream || process.stdout; var term = options.term || env.TERM || ""; var platform = options.platform || process.platform; if (!options.ignoreTTY && !stream.isTTY) { return hasNone(obj, options); } if (!options.ignoreDumb && term === "dumb" && !env.COLORTERM) { return hasNone(obj, options); } if (platform === "win32") { return hasBasic(obj); } if (env.TMUX) { return has256(obj); } if (!options.ignoreCI && (env.CI || env.TEAMCITY_VERSION)) { if (env.TRAVIS) { return has256(obj); } else { return hasNone(obj, options); } } switch (env.TERM_PROGRAM) { case "iTerm.app": var ver = env.TERM_PROGRAM_VERSION || "0."; if (/^[0-2]\./.test(ver)) { return has256(obj); } else { return has16m(obj); } case "HyperTerm": case "Hyper": return has16m(obj); case "MacTerm": return has16m(obj); case "Apple_Terminal": return has256(obj); } if (/^xterm-256/.test(term)) { return has256(obj); } if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(term)) { return hasBasic(obj); } if (env.COLORTERM) { return hasBasic(obj); } return hasNone(obj, options); } __name(colorSupport, "colorSupport"); } }); // ../node_modules/gauge/lib/has-color.js var require_has_color = __commonJS({ "../node_modules/gauge/lib/has-color.js"(exports, module) { "use strict"; var colorSupport = require_color_support(); module.exports = colorSupport().hasBasic; } }); // ../node_modules/gauge/node_modules/signal-exit/dist/cjs/signals.js var require_signals = __commonJS({ "../node_modules/gauge/node_modules/signal-exit/dist/cjs/signals.js"(exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.signals = void 0; exports.signals = []; exports.signals.push("SIGHUP", "SIGINT", "SIGTERM"); if (process.platform !== "win32") { exports.signals.push( "SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT" // should detect profiler and enable/disable accordingly. // see #21 // 'SIGPROF' ); } if (process.platform === "linux") { exports.signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT"); } } }); // ../node_modules/gauge/node_modules/signal-exit/dist/cjs/index.js var require_cjs = __commonJS({ "../node_modules/gauge/node_modules/signal-exit/dist/cjs/index.js"(exports) { "use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.unload = exports.load = exports.onExit = exports.signals = void 0; var signals_js_1 = require_signals(); Object.defineProperty(exports, "signals", { enumerable: true, get: /* @__PURE__ */ __name(function() { return signals_js_1.signals; }, "get") }); var processOk = /* @__PURE__ */ __name((process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function", "processOk"); var kExitEmitter = Symbol.for("signal-exit emitter"); var global = globalThis; var ObjectDefineProperty = Object.defineProperty.bind(Object); var Emitter = class { static { __name(this, "Emitter"); } emitted = { afterExit: false, exit: false }; listeners = { afterExit: [], exit: [] }; count = 0; id = Math.random(); constructor() { if (global[kExitEmitter]) { return global[kExitEmitter]; } ObjectDefineProperty(global, kExitEmitter, { value: this, writable: false, enumerable: false, configurable: false }); } on(ev, fn) { this.listeners[ev].push(fn); } removeListener(ev, fn) { const list = this.listeners[ev]; const i = list.indexOf(fn); if (i === -1) { return; } if (i === 0 && list.length === 1) { list.length = 0; } else { list.splice(i, 1); } } emit(ev, code, signal) { if (this.emitted[ev]) { return false; } this.emitted[ev] = true; let ret = false; for (const fn of this.listeners[ev]) { ret = fn(code, signal) === true || ret; } if (ev === "exit") { ret = this.emit("afterExit", code, signal) || ret; } return ret; } }; var SignalExitBase = class { static { __name(this, "SignalExitBase"); } }; var signalExitWrap = /* @__PURE__ */ __name((handler) => { return { onExit(cb, opts) { return handler.onExit(cb, opts); }, load() { return handler.load(); }, unload() { return handler.unload(); } }; }, "signalExitWrap"); var SignalExitFallback = class extends SignalExitBase { static { __name(this, "SignalExitFallback"); } onExit() { return () => { }; } load() { } unload() { } }; var SignalExit = class extends SignalExitBase { static { __name(this, "SignalExit"); } // "SIGHUP" throws an `ENOSYS` error on Windows, // so use a supported signal instead /* c8 ignore start */ #hupSig = process2.platform === "win32" ? "SIGINT" : "SIGHUP"; /* c8 ignore stop */ #emitter = new Emitter(); #process; #originalProcessEmit; #originalProcessReallyExit; #sigListeners = {}; #loaded = false; constructor(process3) { super(); this.#process = process3; this.#sigListeners = {}; for (const sig of signals_js_1.signals) { this.#sigListeners[sig] = () => { const listeners = this.#process.listeners(sig); let { count } = this.#emitter; const p = process3; if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") { count += p.__signal_exit_emitter__.count; } if (listeners.length === count) { this.unload(); const ret = this.#emitter.emit("exit", null, sig); const s = sig === "SIGHUP" ? this.#hupSig : sig; if (!ret) process3.kill(process3.pid, s); } }; } this.#originalProcessReallyExit = process3.reallyExit; this.#originalProcessEmit = process3.emit; } onExit(cb, opts) { if (!processOk(this.#process)) { return () => { }; } if (this.#loaded === false) { this.load(); } const ev = opts?.alwaysLast ? "afterExit" : "exit"; this.#emitter.on(ev, cb); return () => { this.#emitter.removeListener(ev, cb); if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) { this.unload(); } }; } load() { if (this.#loaded) { return; } this.#loaded = true; this.#emitter.count += 1; for (const sig of signals_js_1.signals) { try { const fn = this.#sigListeners[sig]; if (fn) this.#process.on(sig, fn); } catch (_2) { } } this.#process.emit = (ev, ...a) => { return this.#processEmit(ev, ...a); }; this.#process.reallyExit = (code) => { return this.#processReallyExit(code); }; } unload() { if (!this.#loaded) { return; } this.#loaded = false; signals_js_1.signals.forEach((sig) => { const listener = this.#sigListeners[sig]; if (!listener) { throw new Error("Listener not defined for signal: " + sig); } try { this.#process.removeListener(sig, listener); } catch (_2) { } }); this.#process.emit = this.#originalProcessEmit; this.#process.reallyExit = this.#originalProcessReallyExit; this.#emitter.count -= 1; } #processReallyExit(code) { if (!processOk(this.#process)) { return 0; } this.#process.exitCode = code || 0; this.#emitter.emit("exit", this.#process.exitCode, null); return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode); } #processEmit(ev, ...args) { const og = this.#originalProcessEmit; if (ev === "exit" && processOk(this.#process)) { if (typeof args[0] === "number") { this.#process.exitCode = args[0]; } const ret = og.call(this.#process, ev, ...args); this.#emitter.emit("exit", this.#process.exitCode, null); return ret; } else { return og.call(this.#process, ev, ...args); } } }; var process2 = globalThis.process; _a = signalExitWrap(processOk(process2) ? new SignalExit(process2) : new SignalExitFallback()), /** * Called when the process is exiting, whether via signal, explicit * exit, or running out of stuff to do. * * If the global process object is not suitable for instrumentation, * then this will be a no-op. * * Returns a function that may be used to unload signal-exit. */ exports.onExit = _a.onExit, /** * Load the listeners. Likely you never need to call this, unless * doing a rather deep integration with signal-exit functionality. * Mostly exposed for the benefit of testing. * * @internal */ exports.load = _a.load, /** * Unload the listeners. Likely you never need to call this, unless * doing a rather deep integration with signal-exit functionality. * Mostly exposed for the benefit of testing. * * @internal */ exports.unload = _a.unload; } }); // ../node_modules/gauge/lib/spin.js var require_spin = __commonJS({ "../node_modules/gauge/lib/spin.js"(exports, module) { "use strict"; module.exports = /* @__PURE__ */ __name(function spin(spinstr, spun) { return spinstr[spun % spinstr.length]; }, "spin"); } }); // ../node_modules/gauge/lib/progress-bar.js var require_progress_bar = __commonJS({ "../node_modules/gauge/lib/progress-bar.js"(exports, module) { "use strict"; var validate = require_aproba(); var renderTemplate = require_render_template(); var wideTruncate = require_wide_truncate(); var stringWidth2 = require_string_width(); module.exports = function(theme, width, completed) { validate("ONN", [theme, width, completed]); if (completed < 0) { completed = 0; } if (completed > 1) { completed = 1; } if (width <= 0) { return ""; } var sofar = Math.round(width * completed); var rest = width - sofar; var template = [ { type: "complete", value: repeat(theme.complete, sofar), length: sofar }, { type: "remaining", value: repeat(theme.remaining, rest), length: rest } ]; return renderTemplate(width, template, theme); }; function repeat(string, width) { var result = ""; var n = width; do { if (n % 2) { result += string; } n = Math.floor(n / 2); string += string; } while (n && stringWidth2(result) < width); return wideTruncate(result, width); } __name(repeat, "repeat"); } }); // ../node_modules/gauge/lib/base-theme.js var require_base_theme = __commonJS({ "../node_modules/gauge/lib/base-theme.js"(exports, module) { "use strict"; var spin = require_spin(); var progressBar = require_progress_bar(); module.exports = { activityIndicator: /* @__PURE__ */ __name(function(values, theme) { if (values.spun == null) { return; } return spin(theme, values.spun); }, "activityIndicator"), progressbar: /* @__PURE__ */ __name(function(values, theme, width) { if (values.completed == null) { return; } return progressBar(theme, width, values.completed); }, "progressbar") }; } }); // ../node_modules/gauge/lib/theme-set.js var require_theme_set = __commonJS({ "../node_modules/gauge/lib/theme-set.js"(exports, module) { "use strict"; module.exports = function() { return ThemeSetProto.newThemeSet(); }; var ThemeSetProto = {}; ThemeSetProto.baseTheme = require_base_theme(); ThemeSetProto.newTheme = function(parent, theme) { if (!theme) { theme = parent; parent = this.baseTheme; } return Object.assign({}, parent, theme); }; ThemeSetProto.getThemeNames = function() { return Object.keys(this.themes); }; ThemeSetProto.addTheme = function(name, parent, theme) { this.themes[name] = this.newTheme(parent, theme); }; ThemeSetProto.addToAllThemes = function(theme) { var themes = this.themes; Object.keys(themes).forEach(function(name) { Object.assign(themes[name], theme); }); Object.assign(this.baseTheme, theme); }; ThemeSetProto.getTheme = function(name) { if (!this.themes[name]) { throw this.newMissingThemeError(name); } return this.themes[name]; }; ThemeSetProto.setDefault = function(opts, name) { if (name == null) { name = opts; opts = {}; } var platform = opts.platform == null ? "fallback" : opts.platform; var hasUnicode = !!opts.hasUnicode; var hasColor = !!opts.hasColor; if (!this.defaults[platform]) { this.defaults[platform] = { true: {}, false: {} }; } this.defaults[platform][hasUnicode][hasColor] = name; }; ThemeSetProto.getDefault = function(opts) { if (!opts) { opts = {}; } var platformName = opts.platform || process.platform; var platform = this.defaults[platformName] || this.defaults.fallback; var hasUnicode = !!opts.hasUnicode; var hasColor = !!opts.hasColor; if (!platform) { throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor); } if (!platform[hasUnicode][hasColor]) { if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) { hasUnicode = false; } else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { hasColor = false; } else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) { hasUnicode =