"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 formats_exports = {};
__export(formats_exports, {
  getParser: () => getParser,
  getRegisteredParsers: () => getRegisteredParsers,
  getSupportedExtensions: () => getSupportedExtensions,
  isSupportedDocFormat: () => isSupportedDocFormat,
  parseDocFile: () => parseDocFile
});
module.exports = __toCommonJS(formats_exports);
var import_markdown = require("./markdown");
var import_rst = require("./rst");
var import_asciidoc = require("./asciidoc");
var import_rdoc = require("./rdoc");
var import_org = require("./org");
var import_html = require("./html");
var import_plaintext = require("./plaintext");
var import_openapi = require("./openapi");
const parsers = [
  import_markdown.markdownParser,
  import_rst.rstParser,
  import_asciidoc.asciidocParser,
  import_rdoc.rdocParser,
  import_org.orgParser,
  import_html.htmlParser,
  import_plaintext.plaintextParser
];
const extensionMap = /* @__PURE__ */ new Map();
for (const parser of parsers) {
  for (const ext of parser.extensions) {
    extensionMap.set(ext.toLowerCase(), parser);
  }
}
function getParser(filePath) {
  const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
  return extensionMap.get(ext) ?? null;
}
function parseDocFile(content, filePath) {
  const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
  if ((ext === ".yaml" || ext === ".yml" || ext === ".json") && (0, import_openapi.isOpenAPI)(content, filePath)) {
    return import_openapi.openapiParser.parse(content, filePath);
  }
  const parser = getParser(filePath);
  if (!parser) return null;
  return parser.parse(content, filePath);
}
function isSupportedDocFormat(filePath) {
  return getParser(filePath) !== null;
}
function getSupportedExtensions() {
  return [...extensionMap.keys()];
}
function getRegisteredParsers() {
  return parsers.map((p) => p.name);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getParser,
  getRegisteredParsers,
  getSupportedExtensions,
  isSupportedDocFormat,
  parseDocFile
});
//# sourceMappingURL=index.js.map
