const OM_LOG_LEVEL_ENV = "OM_LOG_LEVEL";
const LOG_LEVEL_WEIGHTS = {
  debug: 10,
  info: 20,
  warn: 30,
  error: 40
};
const VALID_LEVEL_TOKENS = /* @__PURE__ */ new Set(["debug", "info", "warn", "error"]);
function readProcessEnv() {
  return typeof process === "undefined" ? {} : process.env;
}
function defaultLevelFor(env) {
  return env.NODE_ENV === "production" ? "info" : "debug";
}
function resolveLevel(env = readProcessEnv()) {
  const raw = env[OM_LOG_LEVEL_ENV];
  if (typeof raw !== "string" || !raw.trim()) return defaultLevelFor(env);
  const normalized = raw.trim().toLowerCase();
  if (VALID_LEVEL_TOKENS.has(normalized)) return normalized;
  const fallback = defaultLevelFor(env);
  console.warn(`[logger] Unrecognized ${OM_LOG_LEVEL_ENV} value "${raw}"; falling back to "${fallback}"`);
  return fallback;
}
let cachedLevel = null;
function getLogLevel() {
  if (cachedLevel === null) cachedLevel = resolveLevel();
  return cachedLevel;
}
function isLevelEnabled(level) {
  return LOG_LEVEL_WEIGHTS[level] >= LOG_LEVEL_WEIGHTS[getLogLevel()];
}
function resetLogLevelCache() {
  cachedLevel = null;
}
export {
  LOG_LEVEL_WEIGHTS,
  OM_LOG_LEVEL_ENV,
  getLogLevel,
  isLevelEnabled,
  resetLogLevelCache,
  resolveLevel
};
//# sourceMappingURL=level.js.map
