
import { dirname as _$_dirname } from "node:path";
import { createRequire as _$_createRequire } from "node:module";
import { fileURLToPath as _$_fileURLToPath } from "node:url";

const require = _$_createRequire(import.meta.url);
const __dirname = _$_dirname(_$_fileURLToPath(import.meta.url));

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() {
  try {
    return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  } catch (e) {
    throw mod = 0, e;
  }
};
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
));

// node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
  "node_modules/picocolors/picocolors.js"(exports, module) {
    var p = process || {};
    var argv = p.argv || [];
    var env = p.env || {};
    var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
    var formatter = (open, close, replace = open) => (input) => {
      let string = "" + input, 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 result = "", cursor = 0;
      do {
        result += string.substring(cursor, index) + replace;
        cursor = index + close.length;
        index = string.indexOf(close, cursor);
      } while (~index);
      return result + string.substring(cursor);
    };
    var createColors = (enabled = isColorSupported) => {
      let f = enabled ? formatter : () => String;
      return {
        isColorSupported: enabled,
        reset: f("\x1B[0m", "\x1B[0m"),
        bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
        dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
        italic: f("\x1B[3m", "\x1B[23m"),
        underline: f("\x1B[4m", "\x1B[24m"),
        inverse: f("\x1B[7m", "\x1B[27m"),
        hidden: f("\x1B[8m", "\x1B[28m"),
        strikethrough: f("\x1B[9m", "\x1B[29m"),
        black: f("\x1B[30m", "\x1B[39m"),
        red: f("\x1B[31m", "\x1B[39m"),
        green: f("\x1B[32m", "\x1B[39m"),
        yellow: f("\x1B[33m", "\x1B[39m"),
        blue: f("\x1B[34m", "\x1B[39m"),
        magenta: f("\x1B[35m", "\x1B[39m"),
        cyan: f("\x1B[36m", "\x1B[39m"),
        white: f("\x1B[37m", "\x1B[39m"),
        gray: f("\x1B[90m", "\x1B[39m"),
        bgBlack: f("\x1B[40m", "\x1B[49m"),
        bgRed: f("\x1B[41m", "\x1B[49m"),
        bgGreen: f("\x1B[42m", "\x1B[49m"),
        bgYellow: f("\x1B[43m", "\x1B[49m"),
        bgBlue: f("\x1B[44m", "\x1B[49m"),
        bgMagenta: f("\x1B[45m", "\x1B[49m"),
        bgCyan: f("\x1B[46m", "\x1B[49m"),
        bgWhite: f("\x1B[47m", "\x1B[49m"),
        blackBright: f("\x1B[90m", "\x1B[39m"),
        redBright: f("\x1B[91m", "\x1B[39m"),
        greenBright: f("\x1B[92m", "\x1B[39m"),
        yellowBright: f("\x1B[93m", "\x1B[39m"),
        blueBright: f("\x1B[94m", "\x1B[39m"),
        magentaBright: f("\x1B[95m", "\x1B[39m"),
        cyanBright: f("\x1B[96m", "\x1B[39m"),
        whiteBright: f("\x1B[97m", "\x1B[39m"),
        bgBlackBright: f("\x1B[100m", "\x1B[49m"),
        bgRedBright: f("\x1B[101m", "\x1B[49m"),
        bgGreenBright: f("\x1B[102m", "\x1B[49m"),
        bgYellowBright: f("\x1B[103m", "\x1B[49m"),
        bgBlueBright: f("\x1B[104m", "\x1B[49m"),
        bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
        bgCyanBright: f("\x1B[106m", "\x1B[49m"),
        bgWhiteBright: f("\x1B[107m", "\x1B[49m")
      };
    };
    module.exports = createColors();
    module.exports.createColors = createColors;
  }
});

// node_modules/@commitlint/format/lib/format.js
var import_picocolors = __toESM(require_picocolors(), 1);
var DEFAULT_SIGNS = [" ", "\u26A0", "\u2716"];
var DEFAULT_COLORS = [
  "white",
  "yellow",
  "red"
];
function format(report = {}, options = {}) {
  const { results = [] } = report;
  const fi = (result) => formatInput(result, options);
  const fr = (result) => formatResult(result, options);
  return results.filter((r) => Array.isArray(r.warnings) || Array.isArray(r.errors)).map((result) => [...fi(result), ...fr(result)]).reduce((acc, item) => Array.isArray(item) ? [...acc, ...item] : [...acc, item], []).join("\n");
}
function formatInput(result, options = {}) {
  const { color: enabled = true, legacyOutput = false } = options;
  const { errors = [], warnings = [], input = "" } = result;
  if (!input) {
    return [""];
  }
  const sign = "\u29D7";
  const decoration = enabled ? import_picocolors.default.gray(sign) : sign;
  const decoratedInput = enabled ? import_picocolors.default.bold(input) : input;
  const hasProblems = errors.length > 0 || warnings.length > 0;
  if (!(options.verbose || hasProblems)) {
    return [];
  }
  if (legacyOutput) {
    return [`${decoration}   input: ${decoratedInput}`];
  }
  return [`${decoration}   --- input ---
${decoratedInput}`];
}
function formatResult(result = {}, options = {}) {
  const { signs = DEFAULT_SIGNS, colors = DEFAULT_COLORS, color: enabled = true } = options;
  const { errors = [], warnings = [] } = result;
  const problems = [...errors, ...warnings].map((problem) => {
    const sign2 = signs[problem.level] || "";
    const colorName2 = colors[problem.level] || "white";
    const colorFn = import_picocolors.default[colorName2];
    const decoration = enabled ? colorFn(sign2) : sign2;
    const name = enabled ? import_picocolors.default.gray(`[${problem.name}]`) : `[${problem.name}]`;
    return `${decoration}   ${problem.message} ${name}`;
  });
  const sign = selectSign(result);
  const colorName = selectColor(result);
  const deco = enabled ? import_picocolors.default[colorName](sign) : sign;
  const el = errors.length;
  const wl = warnings.length;
  const hasProblems = problems.length > 0;
  const summary = options.verbose || hasProblems ? `${deco}   found ${el} problems, ${wl} warnings` : void 0;
  const fmtSummary = enabled && typeof summary === "string" ? import_picocolors.default.bold(summary) : summary;
  const help = hasProblems && options.helpUrl ? `\u24D8   Get help: ${options.helpUrl}` : void 0;
  return [
    ...problems,
    hasProblems ? "" : void 0,
    fmtSummary,
    help,
    hasProblems ? "" : void 0
  ].filter((line) => typeof line === "string");
}
function selectSign(result) {
  if ((result.errors || []).length > 0) {
    return "\u2716";
  }
  return (result.warnings || []).length ? "\u26A0" : "\u2714";
}
function selectColor(result) {
  if ((result.errors || []).length > 0) {
    return "red";
  }
  return (result.warnings || []).length ? "yellow" : "green";
}
export {
  format as default
};
