import{n as e}from"./chunk-JG7HCLWE.DU0AHNtt.js";import{n as t}from"./chunk-Y2CYZVJY.DsF7k-Jl.js";import{t as n}from"./src.DMVfaFne.js";import"./chunk-I66GZJ75.DE9AwV3O.js";import"./chunk-3NCLNEKW.ceKyfhHo.js";import{n as r,r as i,t as a}from"./chunk-6Q2QTUOP.BnFhCSJK.js";import{t as o}from"./chunk-JWPE2WC7.A3RzWITa.js";import{t as s}from"./mermaid-parser.core.CG5TU4Z9.js";var c=e().RailroadPeg.parser.LangiumParser,l=t(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformOrderedChoice`),u=t(e=>{let t=e.elements.map(d);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformSequence`),d=t(e=>{let t=p(e.suffix);return e.operator?{type:`special`,text:e.operator===`&`?`&${f(t)}`:`!${f(t)}`}:t},`transformPrefix`),f=t(e=>{switch(e.type){case`terminal`:return`"${e.value}"`;case`nonterminal`:return e.name;case`special`:return e.text;default:return`(...)`}},`nodeToLabel`),p=t(e=>{let t=m(e.primary);if(!e.operator)return t;switch(e.operator){case`?`:return{type:`optional`,element:t};case`*`:return{type:`repetition`,element:t,min:0,max:1/0};case`+`:return{type:`repetition`,element:t,min:1,max:1/0};default:throw Error(`Unsupported PEG suffix operator: ${e.operator}`)}},`transformSuffix`),m=t(e=>{switch(e.$type){case`PegLiteral`:return{type:`terminal`,value:e.value};case`PegIdentifier`:return{type:`nonterminal`,name:e.name};case`PegGroup`:return l(e.element);case`PegAny`:return{type:`special`,text:e.dot};default:throw Error(`Unsupported PEG primary node: ${e.$type}`)}},`transformPrimary`),h=t(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),g=t(e=>{o(e,a),e.title&&a.setTitle(e.title),e.rules.map(e=>a.addRule(h(e)))},`populateDb`),_={parser:{parse:t(e=>{a.clear(),n.debug(`[PEG Parser] Starting Langium parse`);let t=c.parse(e);if(t.lexerErrors.length>0||t.parserErrors.length>0)throw new s(t);let r=t.value;n.debug(`[PEG Parser] Parsed rules:`,r.rules.length),g(r),n.debug(`[PEG Parser] Parse complete`)},`parse`),parser:{yy:a}},db:a,renderer:i,styles:r};export{_ as diagram};