import { __name } from './chunk-6AXVLTU5.js';
import path from 'node: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
  };
}
__name(pluginCount, "pluginCount");
function formatMessage(dir, messages, filePath) {
  let fileName = path.posix.normalize(path.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;
}
__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
  };
}
__name(formatResults, "formatResults");

export { MessageSeverity, formatResults };
//# sourceMappingURL=chunk-4QZVQRKK.js.map
//# sourceMappingURL=chunk-4QZVQRKK.js.map