"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, 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(
  // 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 footer_exports = {};
__export(footer_exports, {
  createFooter: () => createFooter,
  createSummaryFooter: () => createSummaryFooter,
  printFooter: () => printFooter
});
module.exports = __toCommonJS(footer_exports);
var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
var import_format = require("../strings/format");
var import_array = require("../primordials/array");
var import_logger = require("../logger/logger");
var import_symbols = require("../logger/symbols");
var import_date = require("../primordials/date");
const logger = (0, import_logger.getDefaultLogger)();
function createFooter(message, options) {
  const {
    borderChar = "=",
    color = "gray",
    showDuration = false,
    showTimestamp = false,
    startTime,
    width = 80
  } = { __proto__: null, ...options };
  const border = (0, import_format.repeatString)(borderChar, width);
  const lines = [];
  if (message) {
    const colorFn = color && import_yoctocolors_cjs.default[color] ? import_yoctocolors_cjs.default[color] : (s) => s;
    (0, import_array.ArrayPrototypePush)(lines, colorFn(message));
  }
  if (showTimestamp) {
    const timestamp = new import_date.DateCtor().toISOString();
    (0, import_array.ArrayPrototypePush)(lines, import_yoctocolors_cjs.default.gray(`Completed at: ${timestamp}`));
  }
  if (showDuration && startTime) {
    const duration = (0, import_date.DateNow)() - startTime;
    const seconds = (duration / 1e3).toFixed(2);
    (0, import_array.ArrayPrototypePush)(lines, import_yoctocolors_cjs.default.gray(`Duration: ${seconds}s`));
  }
  (0, import_array.ArrayPrototypePush)(lines, border);
  return lines.join("\n");
}
function createSummaryFooter(stats, options) {
  const parts = [];
  if (stats.total !== void 0) {
    (0, import_array.ArrayPrototypePush)(parts, `Total: ${stats.total}`);
  }
  if (stats.success !== void 0) {
    (0, import_array.ArrayPrototypePush)(
      parts,
      `${import_symbols.LOG_SYMBOLS["success"]} ${stats.success} passed`
    );
  }
  if (stats.failed !== void 0 && stats.failed > 0) {
    (0, import_array.ArrayPrototypePush)(parts, `${import_symbols.LOG_SYMBOLS["fail"]} ${stats.failed} failed`);
  }
  if (stats.skipped !== void 0 && stats.skipped > 0) {
    (0, import_array.ArrayPrototypePush)(parts, `${import_symbols.LOG_SYMBOLS["skip"]} ${stats.skipped} skipped`);
  }
  if (stats.warnings !== void 0 && stats.warnings > 0) {
    (0, import_array.ArrayPrototypePush)(
      parts,
      `${import_symbols.LOG_SYMBOLS["warn"]} ${stats.warnings} warnings`
    );
  }
  if (stats.errors !== void 0 && stats.errors > 0) {
    (0, import_array.ArrayPrototypePush)(parts, `${import_symbols.LOG_SYMBOLS["fail"]} ${stats.errors} errors`);
  }
  const message = parts.join(" | ");
  return createFooter(message, {
    ...options,
    showDuration: stats.duration !== void 0,
    ...stats.duration !== void 0 && { startTime: stats.duration }
  });
}
function printFooter(message) {
  const border = (0, import_format.repeatString)("\u2500", 55);
  logger.log(border);
  if (message) {
    logger.log(import_yoctocolors_cjs.default.green(message));
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createFooter,
  createSummaryFooter,
  printFooter
});
