"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var errors_exports = {};
__export(errors_exports, {
  ConfigError: () => ConfigError,
  DatabaseError: () => DatabaseError,
  EmbeddingError: () => EmbeddingError,
  FileError: () => FileError,
  IndexError: () => IndexError,
  KiroGraphError: () => KiroGraphError,
  ParseError: () => ParseError,
  ResolutionError: () => ResolutionError,
  TraversalError: () => TraversalError,
  defaultLogger: () => defaultLogger,
  getLogger: () => getLogger,
  logDebug: () => logDebug,
  logError: () => logError,
  logWarn: () => logWarn,
  setLogger: () => setLogger,
  silentLogger: () => silentLogger
});
module.exports = __toCommonJS(errors_exports);
const defaultLogger = {
  debug(msg, ...args) {
    if (process.env.KIROGRAPH_DEBUG) {
      console.debug("[kirograph:debug]", msg, ...args);
    }
  },
  info(msg, ...args) {
    console.info("[kirograph:info]", msg, ...args);
  },
  warn(msg, ...args) {
    console.warn("[kirograph:warn]", msg, ...args);
  },
  error(msg, ...args) {
    console.error("[kirograph:error]", msg, ...args);
  }
};
const silentLogger = {
  debug() {
  },
  info() {
  },
  warn() {
  },
  error() {
  }
};
let _logger = defaultLogger;
function setLogger(l) {
  _logger = l;
}
function getLogger() {
  return _logger;
}
function logDebug(msg, ...args) {
  _logger.debug(msg, ...args);
}
function logWarn(msg, ...args) {
  _logger.warn(msg, ...args);
}
function logError(msg, ...args) {
  _logger.error(msg, ...args);
}
class KiroGraphError extends Error {
  constructor(message, code, context) {
    super(message);
    this.code = code;
    this.context = context;
    this.name = "KiroGraphError";
    Object.setPrototypeOf(this, new.target.prototype);
  }
}
class IndexError extends KiroGraphError {
  constructor(message, context) {
    super(message, "INDEX_ERROR", context);
    this.name = "IndexError";
  }
}
class ResolutionError extends KiroGraphError {
  constructor(message, context) {
    super(message, "RESOLUTION_ERROR", context);
    this.name = "ResolutionError";
  }
}
class EmbeddingError extends KiroGraphError {
  constructor(message, context) {
    super(message, "EMBEDDING_ERROR", context);
    this.name = "EmbeddingError";
  }
}
class ConfigError extends KiroGraphError {
  constructor(message, context) {
    super(message, "CONFIG_ERROR", context);
    this.name = "ConfigError";
  }
}
class TraversalError extends KiroGraphError {
  constructor(message, context) {
    super(message, "TRAVERSAL_ERROR", context);
    this.name = "TraversalError";
  }
}
class FileError extends KiroGraphError {
  constructor(message, filePath) {
    super(message, "FILE_ERROR", { filePath });
    this.filePath = filePath;
    this.name = "FileError";
  }
}
class ParseError extends KiroGraphError {
  constructor(message, filePath, line) {
    super(message, "PARSE_ERROR", { filePath, line });
    this.filePath = filePath;
    this.line = line;
    this.name = "ParseError";
  }
}
class DatabaseError extends KiroGraphError {
  constructor(message) {
    super(message, "DATABASE_ERROR");
    this.name = "DatabaseError";
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ConfigError,
  DatabaseError,
  EmbeddingError,
  FileError,
  IndexError,
  KiroGraphError,
  ParseError,
  ResolutionError,
  TraversalError,
  defaultLogger,
  getLogger,
  logDebug,
  logError,
  logWarn,
  setLogger,
  silentLogger
});
//# sourceMappingURL=errors.js.map
