"use strict";
/* Socket Lib - Built with esbuild */
"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 __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc2) => {
  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: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var format_exports = {};
__export(format_exports, {
  COLOR_INHERIT: () => COLOR_INHERIT,
  ciSpinner: () => ciSpinner,
  desc: () => desc,
  formatProgress: () => formatProgress,
  normalizeText: () => normalizeText,
  renderProgressBar: () => renderProgressBar
});
module.exports = __toCommonJS(format_exports);
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
var import_math = require("../primordials/math");
const COLOR_INHERIT = "inherit";
const ciSpinner = {
  frames: [""],
  interval: 2147483647
};
function desc(value) {
  return {
    __proto__: null,
    configurable: true,
    value,
    writable: true
  };
}
function formatProgress(progress) {
  const { current, total, unit } = progress;
  const percentage = total === 0 ? 0 : (0, import_math.MathRound)(current / total * 100);
  const bar = renderProgressBar(percentage);
  const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`;
  return `${bar} ${percentage}% (${count})`;
}
function normalizeText(value) {
  return typeof value === "string" ? value.trimStart() : "";
}
function renderProgressBar(percentage, width = 20) {
  const filled = (0, import_math.MathMax)(
    0,
    Math.min(width, Math.round(percentage / 100 * width))
  );
  const empty = (0, import_math.MathMax)(0, width - filled);
  const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
  return import_yoctocolors_cjs.default.cyan(bar);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  COLOR_INHERIT,
  ciSpinner,
  desc,
  formatProgress,
  normalizeText,
  renderProgressBar
});
