'use strict';

var chunkAF3E2D32_cjs = require('./chunk-AF3E2D32.cjs');
var path = require('path');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var path__default = /*#__PURE__*/_interopDefault(path);

var MessageSeverity = /* @__PURE__ */ function(MessageSeverity2) {
  MessageSeverity2[MessageSeverity2["Warning"] = 1] = "Warning";
  MessageSeverity2[MessageSeverity2["Error"] = 2] = "Error";
  return MessageSeverity2;
}({});
function pluginCount(messages) {
  let nextPluginWarningCount = 0;
  let nextPluginErrorCount = 0;
  for (let i = 0; i < messages.length; i++) {
    const { severity, ruleId } = messages[i];
    if (ruleId?.includes("storm-stack")) {
      if (severity === 1) {
        nextPluginWarningCount += 1;
      } else {
        nextPluginErrorCount += 1;
      }
    }
  }
  return {
    nextPluginErrorCount,
    nextPluginWarningCount
  };
}
chunkAF3E2D32_cjs.__name(pluginCount, "pluginCount");
function formatMessage(dir, messages, filePath) {
  let fileName = path__default.default.posix.normalize(path__default.default.relative(dir, filePath).replace(/\\/g, "/"));
  if (!fileName.startsWith(".")) {
    fileName = `./${fileName}`;
  }
  let output = `
${fileName}`;
  for (let i = 0; i < messages.length; i++) {
    const { message, severity, line, column, ruleId } = messages[i];
    output += "\n";
    if (line && column) {
      output = `${output + line.toString()}:${column.toString()}  `;
    }
    if (severity === 1) {
      output += `Warning: `;
    } else {
      output += `Error: `;
    }
    output += message;
    if (ruleId) {
      output += `  ${ruleId}`;
    }
  }
  return output;
}
chunkAF3E2D32_cjs.__name(formatMessage, "formatMessage");
async function formatResults(baseDir, results, format) {
  let totalPluginErrorCount = 0;
  let totalPluginWarningCount = 0;
  const resultsWithMessages = results.filter(({ messages }) => messages?.length);
  resultsWithMessages.forEach(({ messages }) => {
    const res = pluginCount(messages);
    totalPluginErrorCount += res.nextPluginErrorCount;
    totalPluginWarningCount += res.nextPluginWarningCount;
  });
  const output = format ? await format(resultsWithMessages) : resultsWithMessages.map(({ messages, filePath }) => formatMessage(baseDir, messages, filePath)).join("\n");
  return {
    output,
    outputWithMessages: resultsWithMessages.length > 0 ? `${output}

Info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules` : "",
    totalPluginErrorCount,
    totalPluginWarningCount
  };
}
chunkAF3E2D32_cjs.__name(formatResults, "formatResults");

exports.MessageSeverity = MessageSeverity;
exports.formatResults = formatResults;
//# sourceMappingURL=chunk-6MFRUH4E.cjs.map
//# sourceMappingURL=chunk-6MFRUH4E.cjs.map