import{t as e,u as t}from"./mermaid-parser.core-ChAxBF4_.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as r}from"./src-B6xuSHsQ.js";import"./chunk-DU6HZSFF-CWylCvIO.js";import{n as i,r as a,t as o}from"./chunk-SVP7TREG-CzCYAmAN.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";import"./mermaid.core-rMC1LMni.js";var c=t().RailroadPeg.parser.LangiumParser,l=n(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformOrderedChoice`),u=n(e=>{let t=e.elements.map(d);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformSequence`),d=n(e=>{let t=p(e.suffix);return e.operator?{type:`special`,text:e.operator===`&`?`&${f(t)}`:`!${f(t)}`}:t},`transformPrefix`),f=n(e=>{switch(e.type){case`terminal`:return`"${e.value}"`;case`nonterminal`:return e.name;case`special`:return e.text;default:return`(...)`}},`nodeToLabel`),p=n(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=n(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=n(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),g=n(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(h(e)))},`populateDb`),_={parser:{parse:n(t=>{o.clear(),r.debug(`[PEG Parser] Starting Langium parse`);let n=c.parse(t);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new e(n);let i=n.value;r.debug(`[PEG Parser] Parsed rules:`,i.rules.length),g(i),r.debug(`[PEG Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{_ as diagram};