export { GitGraphModule, createGitGraphServices } from './chunks/mermaid-parser.core/chunk-S6J4BHB3.mjs';
export { InfoModule, createInfoServices } from './chunks/mermaid-parser.core/chunk-LBM3YZW2.mjs';
export { PacketModule, createPacketServices } from './chunks/mermaid-parser.core/chunk-76Q3JFCE.mjs';
export { PieModule, createPieServices } from './chunks/mermaid-parser.core/chunk-T53DSG4Q.mjs';
export { ArchitectureModule, createArchitectureServices } from './chunks/mermaid-parser.core/chunk-O7ZBX7Z2.mjs';
export { RadarModule, createRadarServices } from './chunks/mermaid-parser.core/chunk-LHMN2FUI.mjs';
export { TreemapModule, createTreemapServices } from './chunks/mermaid-parser.core/chunk-FWNWRKHM.mjs';
import { __name } from './chunks/mermaid-parser.core/chunk-FPAJGGOC.mjs';
export { AbstractMermaidTokenBuilder, AbstractMermaidValueConverter, Architecture, ArchitectureGeneratedModule, Branch, Commit, CommonValueConverter, GitGraph, GitGraphGeneratedModule, Info, InfoGeneratedModule, Merge, MermaidGeneratedSharedModule, Packet, PacketBlock, PacketGeneratedModule, Pie, PieGeneratedModule, PieSection, Radar, RadarGeneratedModule, Statement, Treemap, TreemapGeneratedModule, isArchitecture, isBranch, isCommit, isGitGraph, isInfo, isMerge, isPacket, isPacketBlock, isPie, isPieSection, isTreemap } from './chunks/mermaid-parser.core/chunk-FPAJGGOC.mjs';

// src/parse.ts
var parsers = {};
var initializers = {
  info: /* @__PURE__ */ __name(async () => {
    const { createInfoServices: createInfoServices2 } = await import('./chunks/mermaid-parser.core/info-NVLQJR56.mjs');
    const parser = createInfoServices2().Info.parser.LangiumParser;
    parsers.info = parser;
  }, "info"),
  packet: /* @__PURE__ */ __name(async () => {
    const { createPacketServices: createPacketServices2 } = await import('./chunks/mermaid-parser.core/packet-BFZMPI3H.mjs');
    const parser = createPacketServices2().Packet.parser.LangiumParser;
    parsers.packet = parser;
  }, "packet"),
  pie: /* @__PURE__ */ __name(async () => {
    const { createPieServices: createPieServices2 } = await import('./chunks/mermaid-parser.core/pie-7BOR55EZ.mjs');
    const parser = createPieServices2().Pie.parser.LangiumParser;
    parsers.pie = parser;
  }, "pie"),
  architecture: /* @__PURE__ */ __name(async () => {
    const { createArchitectureServices: createArchitectureServices2 } = await import('./chunks/mermaid-parser.core/architecture-U656AL7Q.mjs');
    const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
    parsers.architecture = parser;
  }, "architecture"),
  gitGraph: /* @__PURE__ */ __name(async () => {
    const { createGitGraphServices: createGitGraphServices2 } = await import('./chunks/mermaid-parser.core/gitGraph-F6HP7TQM.mjs');
    const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
    parsers.gitGraph = parser;
  }, "gitGraph"),
  radar: /* @__PURE__ */ __name(async () => {
    const { createRadarServices: createRadarServices2 } = await import('./chunks/mermaid-parser.core/radar-NHE76QYJ.mjs');
    const parser = createRadarServices2().Radar.parser.LangiumParser;
    parsers.radar = parser;
  }, "radar"),
  treemap: /* @__PURE__ */ __name(async () => {
    const { createTreemapServices: createTreemapServices2 } = await import('./chunks/mermaid-parser.core/treemap-KMMF4GRG.mjs');
    const parser = createTreemapServices2().Treemap.parser.LangiumParser;
    parsers.treemap = parser;
  }, "treemap")
};
async function parse(diagramType, text) {
  const initializer = initializers[diagramType];
  if (!initializer) {
    throw new Error(`Unknown diagram type: ${diagramType}`);
  }
  if (!parsers[diagramType]) {
    await initializer();
  }
  const parser = parsers[diagramType];
  const result = parser.parse(text);
  if (result.lexerErrors.length > 0 || result.parserErrors.length > 0) {
    throw new MermaidParseError(result);
  }
  return result.value;
}
__name(parse, "parse");
var MermaidParseError = class extends Error {
  constructor(result) {
    const lexerErrors = result.lexerErrors.map((err) => err.message).join("\n");
    const parserErrors = result.parserErrors.map((err) => err.message).join("\n");
    super(`Parsing failed: ${lexerErrors} ${parserErrors}`);
    this.result = result;
  }
  static {
    __name(this, "MermaidParseError");
  }
};

export { MermaidParseError, parse };
