Files
mermaid-live-editor/_app/immutable/chunks/gitGraph-YCYPL57B.CLlpuuhc.js
T
2024-11-08 10:01:45 +00:00

128 lines
290 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var Fl=Object.defineProperty;var Gl=(n,e,t)=>e in n?Fl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Je=(n,e,t)=>Gl(n,typeof e!="symbol"?e+"":e,t);import{_ as tn}from"./preload-helper.T-GT2vH5.js";import{c4 as Ul,c5 as Bl,aY as so,by as Vl,b2 as Wl,aZ as Z,au as jl,av as Ji,bq as Hl,bC as ao,c6 as oo,bE as Qi,br as Kl,ax as mt,ay as D,a$ as Zi,b0 as zl}from"./state.kJp46Jxq.js";import{k as Mt,h as Ti,e as Kt,S as ql,u as Yl,w as Xl,c as co,v as K,x as lo,j as Jl,y as Ql,z as Zl,A as eu,B as tu,a as uo,d as C,i as ze,r as oe,f as ve,C as q}from"./_baseUniq.CdrX5ow4.js";import{j as Ri,m as S,d as nu,f as Ne,g as Dt,i as Ai,h as _,l as Ft,e as ru}from"./_basePickBy.D_zNOii7.js";import{c as te}from"./clone.DrPzuFEe.js";var iu=Object.prototype,su=iu.hasOwnProperty,Ae=Ul(function(n,e){if(Bl(e)||so(e)){Vl(e,Mt(e),n);return}for(var t in e)su.call(e,t)&&Wl(n,t,e[t])});function fo(n,e,t){var r=-1,i=n.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=n[r+e];return s}function hn(n){for(var e=-1,t=n==null?0:n.length,r=0,i=[];++e<t;){var s=n[e];s&&(i[r++]=s)}return i}function au(n,e,t,r){for(var i=-1,s=n==null?0:n.length;++i<s;){var a=n[i];e(r,a,t(a),n)}return r}function ou(n,e,t,r){return Ti(n,function(i,s,a){e(r,i,t(i),a)}),r}function cu(n,e){return function(t,r){var i=Z(t)?au:ou,s=e?e():{};return i(t,n,Kt(r),s)}}var lu=200;function uu(n,e,t,r){var i=-1,s=Yl,a=!0,o=n.length,c=[],l=e.length;if(!o)return c;e.length>=lu&&(s=Xl,a=!1,e=new ql(e));e:for(;++i<o;){var u=n[i],d=u;if(u=u!==0?u:0,a&&d===d){for(var f=l;f--;)if(e[f]===d)continue e;c.push(u)}else s(e,d,r)||c.push(u)}return c}var nr=jl(function(n,e){return Ji(n)?uu(n,co(e,1,Ji,!0)):[]});function J(n,e,t){var r=n==null?0:n.length;return r?(e=e===void 0?1:Ri(e),fo(n,e<0?0:e,r)):[]}function ln(n,e,t){var r=n==null?0:n.length;return r?(e=e===void 0?1:Ri(e),e=r-e,fo(n,0,e<0?0:e)):[]}function du(n,e){for(var t=-1,r=n==null?0:n.length;++t<r;)if(!e(n[t],t,n))return!1;return!0}function fu(n,e){var t=!0;return Ti(n,function(r,i,s){return t=!!e(r,i,s),t}),t}function $e(n,e,t){var r=Z(n)?du:fu;return r(n,Kt(e))}function be(n){return n&&n.length?n[0]:void 0}function Re(n,e){return co(S(n,e))}var hu=Object.prototype,pu=hu.hasOwnProperty,mu=cu(function(n,e,t){pu.call(n,t)?n[t].push(e):Hl(n,t,[e])}),gu="[object String]";function fe(n){return typeof n=="string"||!Z(n)&&ao(n)&&oo(n)==gu}var yu=Math.max;function ue(n,e,t,r){n=so(n)?n:K(n),t=t&&!r?Ri(t):0;var i=n.length;return t<0&&(t=yu(i+t,0)),fe(n)?t<=i&&n.indexOf(e,t)>-1:!!i&&lo(n,e,t)>-1}function es(n,e,t){var r=n==null?0:n.length;if(!r)return-1;var i=0;return lo(n,e,i)}var Tu="[object RegExp]";function Ru(n){return ao(n)&&oo(n)==Tu}var ts=Qi&&Qi.isRegExp,qe=ts?Kl(ts):Ru,Au="Expected a function";function vu(n){if(typeof n!="function")throw new TypeError(Au);return function(){var e=arguments;switch(e.length){case 0:return!n.call(this);case 1:return!n.call(this,e[0]);case 2:return!n.call(this,e[0],e[1]);case 3:return!n.call(this,e[0],e[1],e[2])}return!n.apply(this,e)}}function Pe(n,e){if(n==null)return{};var t=Jl(Ql(n),function(r){return[r]});return e=Kt(e),nu(n,t,function(r,i){return e(r,i[0])})}function rr(n,e){var t=Z(n)?Zl:eu;return t(n,vu(Kt(e)))}function Eu(n,e){var t;return Ti(n,function(r,i,s){return t=e(r,i,s),!t}),!!t}function ho(n,e,t){var r=Z(n)?tu:Eu;return r(n,Kt(e))}function vi(n){return n&&n.length?uo(n):[]}function ku(n,e){return n&&n.length?uo(n,Kt(e)):[]}function ae(n){return typeof n=="object"&&n!==null&&typeof n.$type=="string"}function Ge(n){return typeof n=="object"&&n!==null&&typeof n.$refText=="string"}function Su(n){return typeof n=="object"&&n!==null&&typeof n.name=="string"&&typeof n.type=="string"&&typeof n.path=="string"}function xn(n){return typeof n=="object"&&n!==null&&ae(n.container)&&Ge(n.reference)&&typeof n.message=="string"}class po{constructor(){this.subtypes={},this.allSubtypes={}}isInstance(e,t){return ae(e)&&this.isSubtype(e.$type,t)}isSubtype(e,t){if(e===t)return!0;let r=this.subtypes[e];r||(r=this.subtypes[e]={});const i=r[t];if(i!==void 0)return i;{const s=this.computeIsSubtype(e,t);return r[t]=s,s}}getAllSubTypes(e){const t=this.allSubtypes[e];if(t)return t;{const r=this.getAllTypes(),i=[];for(const s of r)this.isSubtype(s,e)&&i.push(s);return this.allSubtypes[e]=i,i}}}function Gt(n){return typeof n=="object"&&n!==null&&Array.isArray(n.content)}function mo(n){return typeof n=="object"&&n!==null&&typeof n.tokenType=="object"}function go(n){return Gt(n)&&typeof n.fullText=="string"}class ie{constructor(e,t){this.startFn=e,this.nextFn=t}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),[Symbol.iterator]:()=>e};return e}[Symbol.iterator](){return this.iterator()}isEmpty(){return!!this.iterator().next().done}count(){const e=this.iterator();let t=0,r=e.next();for(;!r.done;)t++,r=e.next();return t}toArray(){const e=[],t=this.iterator();let r;do r=t.next(),r.value!==void 0&&e.push(r.value);while(!r.done);return e}toSet(){return new Set(this)}toMap(e,t){const r=this.map(i=>[e?e(i):i,t?t(i):i]);return new Map(r)}toString(){return this.join()}concat(e){const t=e[Symbol.iterator]();return new ie(()=>({first:this.startFn(),firstDone:!1}),r=>{let i;if(!r.firstDone){do if(i=this.nextFn(r.first),!i.done)return i;while(!i.done);r.firstDone=!0}do if(i=t.next(),!i.done)return i;while(!i.done);return xe})}join(e=","){const t=this.iterator();let r="",i,s=!1;do i=t.next(),i.done||(s&&(r+=e),r+=Iu(i.value)),s=!0;while(!i.done);return r}indexOf(e,t=0){const r=this.iterator();let i=0,s=r.next();for(;!s.done;){if(i>=t&&s.value===e)return i;s=r.next(),i++}return-1}every(e){const t=this.iterator();let r=t.next();for(;!r.done;){if(!e(r.value))return!1;r=t.next()}return!0}some(e){const t=this.iterator();let r=t.next();for(;!r.done;){if(e(r.value))return!0;r=t.next()}return!1}forEach(e){const t=this.iterator();let r=0,i=t.next();for(;!i.done;)e(i.value,r),i=t.next(),r++}map(e){return new ie(this.startFn,t=>{const{done:r,value:i}=this.nextFn(t);return r?xe:{done:!1,value:e(i)}})}filter(e){return new ie(this.startFn,t=>{let r;do if(r=this.nextFn(t),!r.done&&e(r.value))return r;while(!r.done);return xe})}nonNullable(){return this.filter(e=>e!=null)}reduce(e,t){const r=this.iterator();let i=t,s=r.next();for(;!s.done;)i===void 0?i=s.value:i=e(i,s.value),s=r.next();return i}reduceRight(e,t){return this.recursiveReduce(this.iterator(),e,t)}recursiveReduce(e,t,r){const i=e.next();if(i.done)return r;const s=this.recursiveReduce(e,t,r);return s===void 0?i.value:t(s,i.value)}find(e){const t=this.iterator();let r=t.next();for(;!r.done;){if(e(r.value))return r.value;r=t.next()}}findIndex(e){const t=this.iterator();let r=0,i=t.next();for(;!i.done;){if(e(i.value))return r;i=t.next(),r++}return-1}includes(e){const t=this.iterator();let r=t.next();for(;!r.done;){if(r.value===e)return!0;r=t.next()}return!1}flatMap(e){return new ie(()=>({this:this.startFn()}),t=>{do{if(t.iterator){const s=t.iterator.next();if(s.done)t.iterator=void 0;else return s}const{done:r,value:i}=this.nextFn(t.this);if(!r){const s=e(i);if($n(s))t.iterator=s[Symbol.iterator]();else return{done:!1,value:s}}}while(t.iterator);return xe})}flat(e){if(e===void 0&&(e=1),e<=0)return this;const t=e>1?this.flat(e-1):this;return new ie(()=>({this:t.startFn()}),r=>{do{if(r.iterator){const a=r.iterator.next();if(a.done)r.iterator=void 0;else return a}const{done:i,value:s}=t.nextFn(r.this);if(!i)if($n(s))r.iterator=s[Symbol.iterator]();else return{done:!1,value:s}}while(r.iterator);return xe})}head(){const t=this.iterator().next();if(!t.done)return t.value}tail(e=1){return new ie(()=>{const t=this.startFn();for(let r=0;r<e;r++)if(this.nextFn(t).done)return t;return t},this.nextFn)}limit(e){return new ie(()=>({size:0,state:this.startFn()}),t=>(t.size++,t.size>e?xe:this.nextFn(t.state)))}distinct(e){const t=new Set;return this.filter(r=>{const i=e?e(r):r;return t.has(i)?!1:(t.add(i),!0)})}exclude(e,t){const r=new Set;for(const i of e){const s=t?t(i):i;r.add(s)}return this.filter(i=>{const s=t?t(i):i;return!r.has(s)})}}function Iu(n){return typeof n=="string"?n:typeof n>"u"?"undefined":typeof n.toString=="function"?n.toString():Object.prototype.toString.call(n)}function $n(n){return!!n&&typeof n[Symbol.iterator]=="function"}const xu=new ie(()=>{},()=>xe),xe=Object.freeze({done:!0,value:void 0});function Q(...n){if(n.length===1){const e=n[0];if(e instanceof ie)return e;if($n(e))return new ie(()=>e[Symbol.iterator](),t=>t.next());if(typeof e.length=="number")return new ie(()=>({index:0}),t=>t.index<e.length?{done:!1,value:e[t.index++]}:xe)}return n.length>1?new ie(()=>({collIndex:0,arrIndex:0}),e=>{do{if(e.iterator){const t=e.iterator.next();if(!t.done)return t;e.iterator=void 0}if(e.array){if(e.arrIndex<e.array.length)return{done:!1,value:e.array[e.arrIndex++]};e.array=void 0,e.arrIndex=0}if(e.collIndex<n.length){const t=n[e.collIndex++];$n(t)?e.iterator=t[Symbol.iterator]():t&&typeof t.length=="number"&&(e.array=t)}}while(e.iterator||e.array||e.collIndex<n.length);return xe}):xu}class Ei extends ie{constructor(e,t,r){super(()=>({iterators:r!=null&&r.includeRoot?[[e][Symbol.iterator]()]:[t(e)[Symbol.iterator]()],pruned:!1}),i=>{for(i.pruned&&(i.iterators.pop(),i.pruned=!1);i.iterators.length>0;){const a=i.iterators[i.iterators.length-1].next();if(a.done)i.iterators.pop();else return i.iterators.push(t(a.value)[Symbol.iterator]()),a}return xe})}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),prune:()=>{e.state.pruned=!0},[Symbol.iterator]:()=>e};return e}}var br;(function(n){function e(s){return s.reduce((a,o)=>a+o,0)}n.sum=e;function t(s){return s.reduce((a,o)=>a*o,0)}n.product=t;function r(s){return s.reduce((a,o)=>Math.min(a,o))}n.min=r;function i(s){return s.reduce((a,o)=>Math.max(a,o))}n.max=i})(br||(br={}));function Pr(n){return new Ei(n,e=>Gt(e)?e.content:[],{includeRoot:!0})}function Nu(n,e){for(;n.container;)if(n=n.container,n===e)return!0;return!1}function Mr(n){return{start:{character:n.startColumn-1,line:n.startLine-1},end:{character:n.endColumn,line:n.endLine-1}}}function On(n){if(!n)return;const{offset:e,end:t,range:r}=n;return{range:r,offset:e,end:t,length:t-e}}var Ze;(function(n){n[n.Before=0]="Before",n[n.After=1]="After",n[n.OverlapFront=2]="OverlapFront",n[n.OverlapBack=3]="OverlapBack",n[n.Inside=4]="Inside"})(Ze||(Ze={}));function Cu(n,e){if(n.end.line<e.start.line||n.end.line===e.start.line&&n.end.character<n.start.character)return Ze.Before;if(n.start.line>e.end.line||n.start.line===e.end.line&&n.start.character>e.end.character)return Ze.After;const t=n.start.line>e.start.line||n.start.line===e.start.line&&n.start.character>=e.start.character,r=n.end.line<e.end.line||n.end.line===e.end.line&&n.end.character<=e.end.character;return t&&r?Ze.Inside:t?Ze.OverlapBack:Ze.OverlapFront}function _u(n,e){return Cu(n,e)>Ze.After}const wu=/^[\w\p{L}]$/u;function Lu(n,e){if(n){const t=$u(n,!0);if(t&&ns(t,e))return t;if(go(n)){const r=n.content.findIndex(i=>!i.hidden);for(let i=r-1;i>=0;i--){const s=n.content[i];if(ns(s,e))return s}}}}function ns(n,e){return mo(n)&&e.includes(n.tokenType.name)}function $u(n,e=!0){for(;n.container;){const t=n.container;let r=t.content.indexOf(n);for(;r>0;){r--;const i=t.content[r];if(e||!i.hidden)return i}n=t}}class yo extends Error{constructor(e,t){super(e?`${t} at ${e.range.start.line}:${e.range.start.character}`:t)}}function ir(n){throw new Error("Error! The input value was not handled.")}const Ar="AbstractRule",vr="AbstractType",rs="Condition",Ou="TypeDefinition",is="ValueLiteral",To="AbstractElement";function bu(n){return M.isInstance(n,To)}const Pu="ArrayLiteral",Mu="ArrayType",Ro="BooleanLiteral";function Du(n){return M.isInstance(n,Ro)}const Ao="Conjunction";function Fu(n){return M.isInstance(n,Ao)}const vo="Disjunction";function Gu(n){return M.isInstance(n,vo)}const Uu="Grammar",Eo="InferredType";function ko(n){return M.isInstance(n,Eo)}const So="Interface";function Io(n){return M.isInstance(n,So)}const xo="Negation";function Bu(n){return M.isInstance(n,xo)}const Vu="NumberLiteral",Wu="Parameter",No="ParameterReference";function ju(n){return M.isInstance(n,No)}const Co="ParserRule";function Ce(n){return M.isInstance(n,Co)}const Hu="ReferenceType",Ku="ReturnType";function zu(n){return M.isInstance(n,Ku)}const _o="SimpleType";function qu(n){return M.isInstance(n,_o)}const Yu="StringLiteral",Dr="TerminalRule";function gt(n){return M.isInstance(n,Dr)}const wo="Type";function Lo(n){return M.isInstance(n,wo)}const Xu="UnionType",$o="Action";function sr(n){return M.isInstance(n,$o)}const Oo="Alternatives";function bo(n){return M.isInstance(n,Oo)}const Po="Assignment";function ut(n){return M.isInstance(n,Po)}const Mo="CharacterRange";function Ju(n){return M.isInstance(n,Mo)}const Do="CrossReference";function ki(n){return M.isInstance(n,Do)}const Fo="EndOfFile";function Qu(n){return M.isInstance(n,Fo)}const Go="Group";function Si(n){return M.isInstance(n,Go)}const Uo="Keyword";function dt(n){return M.isInstance(n,Uo)}const Bo="NegatedToken";function Zu(n){return M.isInstance(n,Bo)}const Vo="RegexToken";function ed(n){return M.isInstance(n,Vo)}const Wo="RuleCall";function ft(n){return M.isInstance(n,Wo)}const jo="TerminalAlternatives";function td(n){return M.isInstance(n,jo)}const Ho="TerminalGroup";function nd(n){return M.isInstance(n,Ho)}const Ko="TerminalRuleCall";function rd(n){return M.isInstance(n,Ko)}const zo="UnorderedGroup";function qo(n){return M.isInstance(n,zo)}const Yo="UntilToken";function id(n){return M.isInstance(n,Yo)}const Xo="Wildcard";function sd(n){return M.isInstance(n,Xo)}class Jo extends po{getAllTypes(){return["AbstractElement","AbstractRule","AbstractType","Action","Alternatives","ArrayLiteral","ArrayType","Assignment","BooleanLiteral","CharacterRange","Condition","Conjunction","CrossReference","Disjunction","EndOfFile","Grammar","GrammarImport","Group","InferredType","Interface","Keyword","NamedArgument","NegatedToken","Negation","NumberLiteral","Parameter","ParameterReference","ParserRule","ReferenceType","RegexToken","ReturnType","RuleCall","SimpleType","StringLiteral","TerminalAlternatives","TerminalGroup","TerminalRule","TerminalRuleCall","Type","TypeAttribute","TypeDefinition","UnionType","UnorderedGroup","UntilToken","ValueLiteral","Wildcard"]}computeIsSubtype(e,t){switch(e){case $o:case Oo:case Po:case Mo:case Do:case Fo:case Go:case Uo:case Bo:case Vo:case Wo:case jo:case Ho:case Ko:case zo:case Yo:case Xo:return this.isSubtype(To,t);case Pu:case Vu:case Yu:return this.isSubtype(is,t);case Mu:case Hu:case _o:case Xu:return this.isSubtype(Ou,t);case Ro:return this.isSubtype(rs,t)||this.isSubtype(is,t);case Ao:case vo:case xo:case No:return this.isSubtype(rs,t);case Eo:case So:case wo:return this.isSubtype(vr,t);case Co:return this.isSubtype(Ar,t)||this.isSubtype(vr,t);case Dr:return this.isSubtype(Ar,t);default:return!1}}getReferenceType(e){const t=`${e.container.$type}:${e.property}`;switch(t){case"Action:type":case"CrossReference:type":case"Interface:superTypes":case"ParserRule:returnType":case"SimpleType:typeRef":return vr;case"Grammar:hiddenTokens":case"ParserRule:hiddenTokens":case"RuleCall:rule":return Ar;case"Grammar:usedGrammars":return Uu;case"NamedArgument:parameter":case"ParameterReference:parameter":return Wu;case"TerminalRuleCall:rule":return Dr;default:throw new Error(`${t} is not a valid reference id.`)}}getTypeMetaData(e){switch(e){case"AbstractElement":return{name:"AbstractElement",properties:[{name:"cardinality"},{name:"lookahead"}]};case"ArrayLiteral":return{name:"ArrayLiteral",properties:[{name:"elements",defaultValue:[]}]};case"ArrayType":return{name:"ArrayType",properties:[{name:"elementType"}]};case"BooleanLiteral":return{name:"BooleanLiteral",properties:[{name:"true",defaultValue:!1}]};case"Conjunction":return{name:"Conjunction",properties:[{name:"left"},{name:"right"}]};case"Disjunction":return{name:"Disjunction",properties:[{name:"left"},{name:"right"}]};case"Grammar":return{name:"Grammar",properties:[{name:"definesHiddenTokens",defaultValue:!1},{name:"hiddenTokens",defaultValue:[]},{name:"imports",defaultValue:[]},{name:"interfaces",defaultValue:[]},{name:"isDeclared",defaultValue:!1},{name:"name"},{name:"rules",defaultValue:[]},{name:"types",defaultValue:[]},{name:"usedGrammars",defaultValue:[]}]};case"GrammarImport":return{name:"GrammarImport",properties:[{name:"path"}]};case"InferredType":return{name:"InferredType",properties:[{name:"name"}]};case"Interface":return{name:"Interface",properties:[{name:"attributes",defaultValue:[]},{name:"name"},{name:"superTypes",defaultValue:[]}]};case"NamedArgument":return{name:"NamedArgument",properties:[{name:"calledByName",defaultValue:!1},{name:"parameter"},{name:"value"}]};case"Negation":return{name:"Negation",properties:[{name:"value"}]};case"NumberLiteral":return{name:"NumberLiteral",properties:[{name:"value"}]};case"Parameter":return{name:"Parameter",properties:[{name:"name"}]};case"ParameterReference":return{name:"ParameterReference",properties:[{name:"parameter"}]};case"ParserRule":return{name:"ParserRule",properties:[{name:"dataType"},{name:"definesHiddenTokens",defaultValue:!1},{name:"definition"},{name:"entry",defaultValue:!1},{name:"fragment",defaultValue:!1},{name:"hiddenTokens",defaultValue:[]},{name:"inferredType"},{name:"name"},{name:"parameters",defaultValue:[]},{name:"returnType"},{name:"wildcard",defaultValue:!1}]};case"ReferenceType":return{name:"ReferenceType",properties:[{name:"referenceType"}]};case"ReturnType":return{name:"ReturnType",properties:[{name:"name"}]};case"SimpleType":return{name:"SimpleType",properties:[{name:"primitiveType"},{name:"stringType"},{name:"typeRef"}]};case"StringLiteral":return{name:"StringLiteral",properties:[{name:"value"}]};case"TerminalRule":return{name:"TerminalRule",properties:[{name:"definition"},{name:"fragment",defaultValue:!1},{name:"hidden",defaultValue:!1},{name:"name"},{name:"type"}]};case"Type":return{name:"Type",properties:[{name:"name"},{name:"type"}]};case"TypeAttribute":return{name:"TypeAttribute",properties:[{name:"defaultValue"},{name:"isOptional",defaultValue:!1},{name:"name"},{name:"type"}]};case"UnionType":return{name:"UnionType",properties:[{name:"types",defaultValue:[]}]};case"Action":return{name:"Action",properties:[{name:"cardinality"},{name:"feature"},{name:"inferredType"},{name:"lookahead"},{name:"operator"},{name:"type"}]};case"Alternatives":return{name:"Alternatives",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"Assignment":return{name:"Assignment",properties:[{name:"cardinality"},{name:"feature"},{name:"lookahead"},{name:"operator"},{name:"terminal"}]};case"CharacterRange":return{name:"CharacterRange",properties:[{name:"cardinality"},{name:"left"},{name:"lookahead"},{name:"right"}]};case"CrossReference":return{name:"CrossReference",properties:[{name:"cardinality"},{name:"deprecatedSyntax",defaultValue:!1},{name:"lookahead"},{name:"terminal"},{name:"type"}]};case"EndOfFile":return{name:"EndOfFile",properties:[{name:"cardinality"},{name:"lookahead"}]};case"Group":return{name:"Group",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"guardCondition"},{name:"lookahead"}]};case"Keyword":return{name:"Keyword",properties:[{name:"cardinality"},{name:"lookahead"},{name:"value"}]};case"NegatedToken":return{name:"NegatedToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"terminal"}]};case"RegexToken":return{name:"RegexToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"regex"}]};case"RuleCall":return{name:"RuleCall",properties:[{name:"arguments",defaultValue:[]},{name:"cardinality"},{name:"lookahead"},{name:"rule"}]};case"TerminalAlternatives":return{name:"TerminalAlternatives",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"TerminalGroup":return{name:"TerminalGroup",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"TerminalRuleCall":return{name:"TerminalRuleCall",properties:[{name:"cardinality"},{name:"lookahead"},{name:"rule"}]};case"UnorderedGroup":return{name:"UnorderedGroup",properties:[{name:"cardinality"},{name:"elements",defaultValue:[]},{name:"lookahead"}]};case"UntilToken":return{name:"UntilToken",properties:[{name:"cardinality"},{name:"lookahead"},{name:"terminal"}]};case"Wildcard":return{name:"Wildcard",properties:[{name:"cardinality"},{name:"lookahead"}]};default:return{name:e,properties:[]}}}}const M=new Jo;function ad(n){for(const[e,t]of Object.entries(n))e.startsWith("$")||(Array.isArray(t)?t.forEach((r,i)=>{ae(r)&&(r.$container=n,r.$containerProperty=e,r.$containerIndex=i)}):ae(t)&&(t.$container=n,t.$containerProperty=e))}function ar(n,e){let t=n;for(;t;){if(e(t))return t;t=t.$container}}function Ue(n){const t=od(n).$document;if(!t)throw new Error("AST node has no document.");return t}function od(n){for(;n.$container;)n=n.$container;return n}function Ii(n,e){if(!n)throw new Error("Node must be an AstNode.");const t=e==null?void 0:e.range;return new ie(()=>({keys:Object.keys(n),keyIndex:0,arrayIndex:0}),r=>{for(;r.keyIndex<r.keys.length;){const i=r.keys[r.keyIndex];if(!i.startsWith("$")){const s=n[i];if(ae(s)){if(r.keyIndex++,ss(s,t))return{done:!1,value:s}}else if(Array.isArray(s)){for(;r.arrayIndex<s.length;){const a=r.arrayIndex++,o=s[a];if(ae(o)&&ss(o,t))return{done:!1,value:o}}r.arrayIndex=0}}r.keyIndex++}return xe})}function pn(n,e){if(!n)throw new Error("Root node must be an AstNode.");return new Ei(n,t=>Ii(t,e))}function vt(n,e){if(!n)throw new Error("Root node must be an AstNode.");return new Ei(n,t=>Ii(t,e),{includeRoot:!0})}function ss(n,e){var t;if(!e)return!0;const r=(t=n.$cstNode)===null||t===void 0?void 0:t.range;return r?_u(r,e):!1}function Qo(n){return new ie(()=>({keys:Object.keys(n),keyIndex:0,arrayIndex:0}),e=>{for(;e.keyIndex<e.keys.length;){const t=e.keys[e.keyIndex];if(!t.startsWith("$")){const r=n[t];if(Ge(r))return e.keyIndex++,{done:!1,value:{reference:r,container:n,property:t}};if(Array.isArray(r)){for(;e.arrayIndex<r.length;){const i=e.arrayIndex++,s=r[i];if(Ge(s))return{done:!1,value:{reference:s,container:n,property:t,index:i}}}e.arrayIndex=0}}e.keyIndex++}return xe})}function cd(n,e){const t=n.getTypeMetaData(e.$type),r=e;for(const i of t.properties)i.defaultValue!==void 0&&r[i.name]===void 0&&(r[i.name]=Zo(i.defaultValue))}function Zo(n){return Array.isArray(n)?[...n.map(Zo)]:n}function w(n){return n.charCodeAt(0)}function Er(n,e){Array.isArray(n)?n.forEach(function(t){e.push(t)}):e.push(n)}function nn(n,e){if(n[e]===!0)throw"duplicate flag "+e;n[e],n[e]=!0}function Rt(n){if(n===void 0)throw Error("Internal Error - Should never get here!");return!0}function ld(){throw Error("Internal Error - Should never get here!")}function as(n){return n.type==="Character"}const bn=[];for(let n=w("0");n<=w("9");n++)bn.push(n);const Pn=[w("_")].concat(bn);for(let n=w("a");n<=w("z");n++)Pn.push(n);for(let n=w("A");n<=w("Z");n++)Pn.push(n);const os=[w(" "),w("\f"),w(`
`),w("\r"),w(" "),w("\v"),w(" "),w(" "),w(""),w(" "),w(""),w(""),w(""),w(""),w(""),w(""),w(""),w(""),w(""),w(""),w("\u2028"),w("\u2029"),w(""),w(""),w(" "),w("\uFEFF")],ud=/[0-9a-fA-F]/,En=/[0-9]/,dd=/[1-9]/;class ec{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");const t=this.disjunction();this.consumeChar("/");const r={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":nn(r,"global");break;case"i":nn(r,"ignoreCase");break;case"m":nn(r,"multiLine");break;case"u":nn(r,"unicode");break;case"y":nn(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:t,loc:this.loc(0)}}disjunction(){const e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){const e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break}Rt(t);const r=this.disjunction();return this.consumeChar(")"),{type:t,value:r,loc:this.loc(e)}}return ld()}quantifier(e=!1){let t;const r=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":const i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":let s;this.isDigit()?(s=this.integerIncludingZero(),t={atLeast:i,atMost:s}):t={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;Rt(t);break}if(!(e===!0&&t===void 0)&&Rt(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(r),t}atom(){let e;const t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Rt(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[w(`
`),w("\r"),w("\u2028"),w("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=bn;break;case"D":e=bn,t=!0;break;case"s":e=os;break;case"S":e=os,t=!0;break;case"w":e=Pn;break;case"W":e=Pn,t=!0;break}if(Rt(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=w("\f");break;case"n":e=w(`
`);break;case"r":e=w("\r");break;case"t":e=w(" ");break;case"v":e=w("\v");break}if(Rt(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:w("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:w(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:w(e)}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const r=this.classAtom();if(r.type,as(r)&&this.isRangeDash()){this.consumeChar("-");const i=this.classAtom();if(i.type,as(i)){if(i.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:i.value})}else Er(r.value,e),e.push(w("-")),Er(i.value,e)}else Er(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:w("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}const t=this.disjunction();this.consumeChar(")");const r={type:"Group",capturing:e,value:t};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(dd.test(e)===!1)throw Error("Expecting a positive integer");for(;En.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(En.test(e)===!1)throw Error("Expecting an integer");for(;En.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:w(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return En.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}}isQuantifier(){const e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let i=0;i<e;i++){const s=this.popChar();if(ud.test(s)===!1)throw Error("Expecting a HexDecimal digits");t+=s}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class or{visitChildren(e){for(const t in e){const r=e[t];e.hasOwnProperty(t)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}const fd=/\r?\n/gm,hd=new ec;class pd extends or{constructor(){super(...arguments),this.isStarting=!0,this.endRegexpStack=[],this.multiline=!1}get endRegex(){return this.endRegexpStack.join("")}reset(e){this.multiline=!1,this.regex=e,this.startRegexp="",this.isStarting=!0,this.endRegexpStack=[]}visitGroup(e){e.quantifier&&(this.isStarting=!1,this.endRegexpStack=[])}visitCharacter(e){const t=String.fromCharCode(e.value);if(!this.multiline&&t===`
`&&(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const r=cr(t);this.endRegexpStack.push(r),this.isStarting&&(this.startRegexp+=r)}}visitSet(e){if(!this.multiline){const t=this.regex.substring(e.loc.begin,e.loc.end),r=new RegExp(t);this.multiline=!!`
`.match(r)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const t=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(t),this.isStarting&&(this.startRegexp+=t)}}visitChildren(e){e.type==="Group"&&e.quantifier||super.visitChildren(e)}}const kr=new pd;function md(n){try{return typeof n=="string"&&(n=new RegExp(n)),n=n.toString(),kr.reset(n),kr.visit(hd.pattern(n)),kr.multiline}catch{return!1}}function cs(n){return(typeof n=="string"?new RegExp(n):n).test(" ")}function cr(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gd(n){return Array.prototype.map.call(n,e=>/\w/.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:cr(e)).join("")}function yd(n,e){const t=Td(n),r=e.match(t);return!!r&&r[0].length>0}function Td(n){typeof n=="string"&&(n=new RegExp(n));const e=n,t=n.source;let r=0;function i(){let s="",a;function o(l){s+=t.substr(r,l),r+=l}function c(l){s+="(?:"+t.substr(r,l)+"|$)",r+=l}for(;r<t.length;)switch(t[r]){case"\\":switch(t[r+1]){case"c":c(3);break;case"x":c(4);break;case"u":e.unicode?t[r+2]==="{"?c(t.indexOf("}",r)-r+1):c(6):c(2);break;case"p":case"P":e.unicode?c(t.indexOf("}",r)-r+1):c(2);break;case"k":c(t.indexOf(">",r)-r+1);break;default:c(2);break}break;case"[":a=/\[(?:\\.|.)*?\]/g,a.lastIndex=r,a=a.exec(t)||[],c(a[0].length);break;case"|":case"^":case"$":case"*":case"+":case"?":o(1);break;case"{":a=/\{\d+,?\d*\}/g,a.lastIndex=r,a=a.exec(t),a?o(a[0].length):c(1);break;case"(":if(t[r+1]==="?")switch(t[r+2]){case":":s+="(?:",r+=3,s+=i()+"|$)";break;case"=":s+="(?=",r+=3,s+=i()+")";break;case"!":a=r,r+=3,i(),s+=t.substr(a,r-a);break;case"<":switch(t[r+3]){case"=":case"!":a=r,r+=4,i(),s+=t.substr(a,r-a);break;default:o(t.indexOf(">",r)-r+1),s+=i()+"|$)";break}break}else o(1),s+=i()+"|$)";break;case")":return++r,s;default:c(1);break}return s}return new RegExp(i(),n.flags)}function Rd(n){return n.rules.find(e=>Ce(e)&&e.entry)}function Ad(n){return n.rules.filter(e=>gt(e)&&e.hidden)}function tc(n,e){const t=new Set,r=Rd(n);if(!r)return new Set(n.rules);const i=[r].concat(Ad(n));for(const a of i)nc(a,t,e);const s=new Set;for(const a of n.rules)(t.has(a.name)||gt(a)&&a.hidden)&&s.add(a);return s}function nc(n,e,t){e.add(n.name),pn(n).forEach(r=>{if(ft(r)||t){const i=r.rule.ref;i&&!e.has(i.name)&&nc(i,e,t)}})}function vd(n){if(n.terminal)return n.terminal;if(n.type.ref){const e=ic(n.type.ref);return e==null?void 0:e.terminal}}function Ed(n){return n.hidden&&!Ci(n).test(" ")}function kd(n,e){return!n||!e?[]:xi(n,e,n.astNode,!0)}function rc(n,e,t){if(!n||!e)return;const r=xi(n,e,n.astNode,!0);if(r.length!==0)return t!==void 0?t=Math.max(0,Math.min(t,r.length-1)):t=0,r[t]}function xi(n,e,t,r){if(!r){const i=ar(n.grammarSource,ut);if(i&&i.feature===e)return[n]}return Gt(n)&&n.astNode===t?n.content.flatMap(i=>xi(i,e,t,!1)):[]}function Sd(n,e,t){if(!n)return;const r=Id(n,e,n==null?void 0:n.astNode);if(r.length!==0)return t!==void 0?t=Math.max(0,Math.min(t,r.length-1)):t=0,r[t]}function Id(n,e,t){if(n.astNode!==t)return[];if(dt(n.grammarSource)&&n.grammarSource.value===e)return[n];const r=Pr(n).iterator();let i;const s=[];do if(i=r.next(),!i.done){const a=i.value;a.astNode===t?dt(a.grammarSource)&&a.grammarSource.value===e&&s.push(a):r.prune()}while(!i.done);return s}function xd(n){var e;const t=n.astNode;for(;t===((e=n.container)===null||e===void 0?void 0:e.astNode);){const r=ar(n.grammarSource,ut);if(r)return r;n=n.container}}function ic(n){let e=n;return ko(e)&&(sr(e.$container)?e=e.$container.$container:Ce(e.$container)?e=e.$container:ir(e.$container)),sc(n,e,new Map)}function sc(n,e,t){var r;function i(s,a){let o;return ar(s,ut)||(o=sc(a,a,t)),t.set(n,o),o}if(t.has(n))return t.get(n);t.set(n,void 0);for(const s of pn(e)){if(ut(s)&&s.feature.toLowerCase()==="name")return t.set(n,s),s;if(ft(s)&&Ce(s.rule.ref))return i(s,s.rule.ref);if(qu(s)&&(!((r=s.typeRef)===null||r===void 0)&&r.ref))return i(s,s.typeRef.ref)}}function Ni(n){return ac(n,new Set)}function ac(n,e){if(e.has(n))return!0;e.add(n);for(const t of pn(n))if(ft(t)){if(!t.rule.ref||Ce(t.rule.ref)&&!ac(t.rule.ref,e))return!1}else{if(ut(t))return!1;if(sr(t))return!1}return!!n.definition}function oc(n){if(n.inferredType)return n.inferredType.name;if(n.dataType)return n.dataType;if(n.returnType){const e=n.returnType.ref;if(e){if(Ce(e))return e.name;if(Io(e)||Lo(e))return e.name}}}function lr(n){var e;if(Ce(n))return Ni(n)?n.name:(e=oc(n))!==null&&e!==void 0?e:n.name;if(Io(n)||Lo(n)||zu(n))return n.name;if(sr(n)){const t=Nd(n);if(t)return t}else if(ko(n))return n.name;throw new Error("Cannot get name of Unknown Type")}function Nd(n){var e;if(n.inferredType)return n.inferredType.name;if(!((e=n.type)===null||e===void 0)&&e.ref)return lr(n.type.ref)}function Cd(n){var e,t,r;return gt(n)?(t=(e=n.type)===null||e===void 0?void 0:e.name)!==null&&t!==void 0?t:"string":Ni(n)?n.name:(r=oc(n))!==null&&r!==void 0?r:n.name}function Ci(n){const e={s:!1,i:!1,u:!1},t=zt(n.definition,e),r=Object.entries(e).filter(([,i])=>i).map(([i])=>i).join("");return new RegExp(t,r)}const _i=/[\s\S]/.source;function zt(n,e){if(td(n))return _d(n);if(nd(n))return wd(n);if(Ju(n))return Od(n);if(rd(n)){const t=n.rule.ref;if(!t)throw new Error("Missing rule reference.");return Ke(zt(t.definition),{cardinality:n.cardinality,lookahead:n.lookahead})}else{if(Zu(n))return $d(n);if(id(n))return Ld(n);if(ed(n)){const t=n.regex.lastIndexOf("/"),r=n.regex.substring(1,t),i=n.regex.substring(t+1);return e&&(e.i=i.includes("i"),e.s=i.includes("s"),e.u=i.includes("u")),Ke(r,{cardinality:n.cardinality,lookahead:n.lookahead,wrap:!1})}else{if(sd(n))return Ke(_i,{cardinality:n.cardinality,lookahead:n.lookahead});throw new Error(`Invalid terminal element: ${n==null?void 0:n.$type}`)}}}function _d(n){return Ke(n.elements.map(e=>zt(e)).join("|"),{cardinality:n.cardinality,lookahead:n.lookahead})}function wd(n){return Ke(n.elements.map(e=>zt(e)).join(""),{cardinality:n.cardinality,lookahead:n.lookahead})}function Ld(n){return Ke(`${_i}*?${zt(n.terminal)}`,{cardinality:n.cardinality,lookahead:n.lookahead})}function $d(n){return Ke(`(?!${zt(n.terminal)})${_i}*?`,{cardinality:n.cardinality,lookahead:n.lookahead})}function Od(n){return n.right?Ke(`[${Sr(n.left)}-${Sr(n.right)}]`,{cardinality:n.cardinality,lookahead:n.lookahead,wrap:!1}):Ke(Sr(n.left),{cardinality:n.cardinality,lookahead:n.lookahead,wrap:!1})}function Sr(n){return cr(n.value)}function Ke(n,e){var t;return(e.wrap!==!1||e.lookahead)&&(n=`(${(t=e.lookahead)!==null&&t!==void 0?t:""}${n})`),e.cardinality?`${n}${e.cardinality}`:n}function bd(n){const e=[],t=n.Grammar;for(const r of t.rules)gt(r)&&Ed(r)&&md(Ci(r))&&e.push(r.name);return{multilineCommentRules:e,nameRegexp:wu}}function Fr(n){console&&console.error&&console.error(`Error: ${n}`)}function cc(n){console&&console.warn&&console.warn(`Warning: ${n}`)}function lc(n){const e=new Date().getTime(),t=n();return{time:new Date().getTime()-e,value:t}}function uc(n){function e(){}e.prototype=n;const t=new e;function r(){return typeof t.bar}return r(),r(),n}function Pd(n){return Md(n)?n.LABEL:n.name}function Md(n){return fe(n.LABEL)&&n.LABEL!==""}class Be{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),C(this.definition,t=>{t.accept(e)})}}class ce extends Be{constructor(e){super([]),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class qt extends Be{constructor(e){super(e.definition),this.orgText="",Ae(this,Pe(e,t=>t!==void 0))}}class he extends Be{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Ae(this,Pe(e,t=>t!==void 0))}}class ee extends Be{constructor(e){super(e.definition),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}}class Ee extends Be{constructor(e){super(e.definition),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}}class ke extends Be{constructor(e){super(e.definition),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}}class W extends Be{constructor(e){super(e.definition),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}}class pe extends Be{constructor(e){super(e.definition),this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}}class me extends Be{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Ae(this,Pe(e,t=>t!==void 0))}}class G{constructor(e){this.idx=1,Ae(this,Pe(e,t=>t!==void 0))}accept(e){e.visit(this)}}function Dd(n){return S(n,Nn)}function Nn(n){function e(t){return S(t,Nn)}if(n instanceof ce){const t={type:"NonTerminal",name:n.nonTerminalName,idx:n.idx};return fe(n.label)&&(t.label=n.label),t}else{if(n instanceof he)return{type:"Alternative",definition:e(n.definition)};if(n instanceof ee)return{type:"Option",idx:n.idx,definition:e(n.definition)};if(n instanceof Ee)return{type:"RepetitionMandatory",idx:n.idx,definition:e(n.definition)};if(n instanceof ke)return{type:"RepetitionMandatoryWithSeparator",idx:n.idx,separator:Nn(new G({terminalType:n.separator})),definition:e(n.definition)};if(n instanceof pe)return{type:"RepetitionWithSeparator",idx:n.idx,separator:Nn(new G({terminalType:n.separator})),definition:e(n.definition)};if(n instanceof W)return{type:"Repetition",idx:n.idx,definition:e(n.definition)};if(n instanceof me)return{type:"Alternation",idx:n.idx,definition:e(n.definition)};if(n instanceof G){const t={type:"Terminal",name:n.terminalType.name,label:Pd(n.terminalType),idx:n.idx};fe(n.label)&&(t.terminalLabel=n.label);const r=n.terminalType.PATTERN;return n.terminalType.PATTERN&&(t.pattern=qe(r)?r.source:r),t}else{if(n instanceof qt)return{type:"Rule",name:n.name,orgText:n.orgText,definition:e(n.definition)};throw Error("non exhaustive match")}}}class Yt{visit(e){const t=e;switch(t.constructor){case ce:return this.visitNonTerminal(t);case he:return this.visitAlternative(t);case ee:return this.visitOption(t);case Ee:return this.visitRepetitionMandatory(t);case ke:return this.visitRepetitionMandatoryWithSeparator(t);case pe:return this.visitRepetitionWithSeparator(t);case W:return this.visitRepetition(t);case me:return this.visitAlternation(t);case G:return this.visitTerminal(t);case qt:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function Fd(n){return n instanceof he||n instanceof ee||n instanceof W||n instanceof Ee||n instanceof ke||n instanceof pe||n instanceof G||n instanceof qt}function Mn(n,e=[]){return n instanceof ee||n instanceof W||n instanceof pe?!0:n instanceof me?ho(n.definition,r=>Mn(r,e)):n instanceof ce&&ue(e,n)?!1:n instanceof Be?(n instanceof ce&&e.push(n),$e(n.definition,r=>Mn(r,e))):!1}function Gd(n){return n instanceof me}function Fe(n){if(n instanceof ce)return"SUBRULE";if(n instanceof ee)return"OPTION";if(n instanceof me)return"OR";if(n instanceof Ee)return"AT_LEAST_ONE";if(n instanceof ke)return"AT_LEAST_ONE_SEP";if(n instanceof pe)return"MANY_SEP";if(n instanceof W)return"MANY";if(n instanceof G)return"CONSUME";throw Error("non exhaustive match")}class ur{walk(e,t=[]){C(e.definition,(r,i)=>{const s=J(e.definition,i+1);if(r instanceof ce)this.walkProdRef(r,s,t);else if(r instanceof G)this.walkTerminal(r,s,t);else if(r instanceof he)this.walkFlat(r,s,t);else if(r instanceof ee)this.walkOption(r,s,t);else if(r instanceof Ee)this.walkAtLeastOne(r,s,t);else if(r instanceof ke)this.walkAtLeastOneSep(r,s,t);else if(r instanceof pe)this.walkManySep(r,s,t);else if(r instanceof W)this.walkMany(r,s,t);else if(r instanceof me)this.walkOr(r,s,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,r){}walkProdRef(e,t,r){}walkFlat(e,t,r){const i=t.concat(r);this.walk(e,i)}walkOption(e,t,r){const i=t.concat(r);this.walk(e,i)}walkAtLeastOne(e,t,r){const i=[new ee({definition:e.definition})].concat(t,r);this.walk(e,i)}walkAtLeastOneSep(e,t,r){const i=ls(e,t,r);this.walk(e,i)}walkMany(e,t,r){const i=[new ee({definition:e.definition})].concat(t,r);this.walk(e,i)}walkManySep(e,t,r){const i=ls(e,t,r);this.walk(e,i)}walkOr(e,t,r){const i=t.concat(r);C(e.definition,s=>{const a=new he({definition:[s]});this.walk(a,i)})}}function ls(n,e,t){return[new ee({definition:[new G({terminalType:n.separator})].concat(n.definition)})].concat(e,t)}function mn(n){if(n instanceof ce)return mn(n.referencedRule);if(n instanceof G)return Vd(n);if(Fd(n))return Ud(n);if(Gd(n))return Bd(n);throw Error("non exhaustive match")}function Ud(n){let e=[];const t=n.definition;let r=0,i=t.length>r,s,a=!0;for(;i&&a;)s=t[r],a=Mn(s),e=e.concat(mn(s)),r=r+1,i=t.length>r;return vi(e)}function Bd(n){const e=S(n.definition,t=>mn(t));return vi(Ne(e))}function Vd(n){return[n.terminalType]}const dc="_~IN~_";class Wd extends ur{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,r){}walkProdRef(e,t,r){const i=Hd(e.referencedRule,e.idx)+this.topProd.name,s=t.concat(r),a=new he({definition:s}),o=mn(a);this.follows[i]=o}}function jd(n){const e={};return C(n,t=>{const r=new Wd(t).startWalking();Ae(e,r)}),e}function Hd(n,e){return n.name+e+dc}let Cn={};const Kd=new ec;function dr(n){const e=n.toString();if(Cn.hasOwnProperty(e))return Cn[e];{const t=Kd.pattern(e);return Cn[e]=t,t}}function zd(){Cn={}}const fc="Complement Sets are not supported for first char optimization",Dn=`Unable to use "first char" lexer optimizations:
`;function qd(n,e=!1){try{const t=dr(n);return Gr(t.value,{},t.flags.ignoreCase)}catch(t){if(t.message===fc)e&&cc(`${Dn} Unable to optimize: < ${n.toString()} >
Complement Sets cannot be automatically optimized.
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let r="";e&&(r=`
This will disable the lexer's first char optimizations.
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Fr(`${Dn}
Failed parsing: < ${n.toString()} >
Using the @chevrotain/regexp-to-ast library
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Gr(n,e,t){switch(n.type){case"Disjunction":for(let i=0;i<n.value.length;i++)Gr(n.value[i],e,t);break;case"Alternative":const r=n.value;for(let i=0;i<r.length;i++){const s=r[i];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const a=s;switch(a.type){case"Character":kn(a.value,e,t);break;case"Set":if(a.complement===!0)throw Error(fc);C(a.value,c=>{if(typeof c=="number")kn(c,e,t);else{const l=c;if(t===!0)for(let u=l.from;u<=l.to;u++)kn(u,e,t);else{for(let u=l.from;u<=l.to&&u<on;u++)kn(u,e,t);if(l.to>=on){const u=l.from>=on?l.from:on,d=l.to,f=et(u),h=et(d);for(let m=f;m<=h;m++)e[m]=m}}}});break;case"Group":Gr(a.value,e,t);break;default:throw Error("Non Exhaustive Match")}const o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&Ur(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return K(e)}function kn(n,e,t){const r=et(n);e[r]=r,t===!0&&Yd(n,e)}function Yd(n,e){const t=String.fromCharCode(n),r=t.toUpperCase();if(r!==t){const i=et(r.charCodeAt(0));e[i]=i}else{const i=t.toLowerCase();if(i!==t){const s=et(i.charCodeAt(0));e[s]=s}}}function us(n,e){return Dt(n.value,t=>{if(typeof t=="number")return ue(e,t);{const r=t;return Dt(e,i=>r.from<=i&&i<=r.to)!==void 0}})}function Ur(n){const e=n.quantifier;return e&&e.atLeast===0?!0:n.value?Z(n.value)?$e(n.value,Ur):Ur(n.value):!1}class Xd extends or{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return}super.visitChildren(e)}}visitCharacter(e){ue(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?us(e,this.targetCharCodes)===void 0&&(this.found=!0):us(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function wi(n,e){if(e instanceof RegExp){const t=dr(e),r=new Xd(n);return r.visit(t),r.found}else return Dt(e,t=>ue(n,t.charCodeAt(0)))!==void 0}const ht="PATTERN",an="defaultMode",Sn="modes";let hc=typeof new RegExp("(?:)").sticky=="boolean";function Jd(n,e){e=Ai(e,{useSticky:hc,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:(v,R)=>R()});const t=e.tracer;t("initCharCodeToOptimizedIndexMap",()=>{vf()});let r;t("Reject Lexer.NA",()=>{r=rr(n,v=>v[ht]===de.NA)});let i=!1,s;t("Transform Patterns",()=>{i=!1,s=S(r,v=>{const R=v[ht];if(qe(R)){const N=R.source;return N.length===1&&N!=="^"&&N!=="$"&&N!=="."&&!R.ignoreCase?N:N.length===2&&N[0]==="\\"&&!ue(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],N[1])?N[1]:e.useSticky?fs(R):ds(R)}else{if(mt(R))return i=!0,{exec:R};if(typeof R=="object")return i=!0,R;if(typeof R=="string"){if(R.length===1)return R;{const N=R.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),F=new RegExp(N);return e.useSticky?fs(F):ds(F)}}else throw Error("non exhaustive match")}})});let a,o,c,l,u;t("misc mapping",()=>{a=S(r,v=>v.tokenTypeIdx),o=S(r,v=>{const R=v.GROUP;if(R!==de.SKIPPED){if(fe(R))return R;if(ze(R))return!1;throw Error("non exhaustive match")}}),c=S(r,v=>{const R=v.LONGER_ALT;if(R)return Z(R)?S(R,F=>es(r,F)):[es(r,R)]}),l=S(r,v=>v.PUSH_MODE),u=S(r,v=>_(v,"POP_MODE"))});let d;t("Line Terminator Handling",()=>{const v=gc(e.lineTerminatorCharacters);d=S(r,R=>!1),e.positionTracking!=="onlyOffset"&&(d=S(r,R=>_(R,"LINE_BREAKS")?!!R.LINE_BREAKS:mc(R,v)===!1&&wi(v,R.PATTERN)))});let f,h,m,g;t("Misc Mapping #2",()=>{f=S(r,pc),h=S(s,Tf),m=oe(r,(v,R)=>{const N=R.GROUP;return fe(N)&&N!==de.SKIPPED&&(v[N]=[]),v},{}),g=S(s,(v,R)=>({pattern:s[R],longerAlt:c[R],canLineTerminator:d[R],isCustom:f[R],short:h[R],group:o[R],push:l[R],pop:u[R],tokenTypeIdx:a[R],tokenType:r[R]}))});let A=!0,y=[];return e.safeMode||t("First Char Optimization",()=>{y=oe(r,(v,R,N)=>{if(typeof R.PATTERN=="string"){const F=R.PATTERN.charCodeAt(0),ne=et(F);Ir(v,ne,g[N])}else if(Z(R.START_CHARS_HINT)){let F;C(R.START_CHARS_HINT,ne=>{const we=typeof ne=="string"?ne.charCodeAt(0):ne,ge=et(we);F!==ge&&(F=ge,Ir(v,ge,g[N]))})}else if(qe(R.PATTERN))if(R.PATTERN.unicode)A=!1,e.ensureOptimizations&&Fr(`${Dn} Unable to analyze < ${R.PATTERN.toString()} > pattern.
The regexp unicode flag is not currently supported by the regexp-to-ast library.
This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const F=qd(R.PATTERN,e.ensureOptimizations);D(F)&&(A=!1),C(F,ne=>{Ir(v,ne,g[N])})}else e.ensureOptimizations&&Fr(`${Dn} TokenType: <${R.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
This will disable the lexer's first char optimizations.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),A=!1;return v},[])}),{emptyGroups:m,patternIdxToConfig:g,charCodeToPatternIdxToConfig:y,hasCustom:i,canBeOptimized:A}}function Qd(n,e){let t=[];const r=ef(n);t=t.concat(r.errors);const i=tf(r.valid),s=i.valid;return t=t.concat(i.errors),t=t.concat(Zd(s)),t=t.concat(uf(s)),t=t.concat(df(s,e)),t=t.concat(ff(s)),t}function Zd(n){let e=[];const t=ve(n,r=>qe(r[ht]));return e=e.concat(rf(t)),e=e.concat(of(t)),e=e.concat(cf(t)),e=e.concat(lf(t)),e=e.concat(sf(t)),e}function ef(n){const e=ve(n,i=>!_(i,ht)),t=S(e,i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[i]})),r=nr(n,e);return{errors:t,valid:r}}function tf(n){const e=ve(n,i=>{const s=i[ht];return!qe(s)&&!mt(s)&&!_(s,"exec")&&!fe(s)}),t=S(e,i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:j.INVALID_PATTERN,tokenTypes:[i]})),r=nr(n,e);return{errors:t,valid:r}}const nf=/[^\\][$]/;function rf(n){class e extends or{constructor(){super(...arguments),this.found=!1}visitEndAnchor(s){this.found=!0}}const t=ve(n,i=>{const s=i.PATTERN;try{const a=dr(s),o=new e;return o.visit(a),o.found}catch{return nf.test(s.source)}});return S(t,i=>({message:`Unexpected RegExp Anchor Error:
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function sf(n){const e=ve(n,r=>r.PATTERN.test(""));return S(e,r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[r]}))}const af=/[^\\[][\^]|^\^/;function of(n){class e extends or{constructor(){super(...arguments),this.found=!1}visitStartAnchor(s){this.found=!0}}const t=ve(n,i=>{const s=i.PATTERN;try{const a=dr(s),o=new e;return o.visit(a),o.found}catch{return af.test(s.source)}});return S(t,i=>({message:`Unexpected RegExp Anchor Error:
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function cf(n){const e=ve(n,r=>{const i=r[ht];return i instanceof RegExp&&(i.multiline||i.global)});return S(e,r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}))}function lf(n){const e=[];let t=S(n,s=>oe(n,(a,o)=>(s.PATTERN.source===o.PATTERN.source&&!ue(e,o)&&o.PATTERN!==de.NA&&(e.push(o),a.push(o)),a),[]));t=hn(t);const r=ve(t,s=>s.length>1);return S(r,s=>{const a=S(s,c=>c.name);return{message:`The same RegExp pattern ->${be(s).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}})}function uf(n){const e=ve(n,r=>{if(!_(r,"GROUP"))return!1;const i=r.GROUP;return i!==de.SKIPPED&&i!==de.NA&&!fe(i)});return S(e,r=>({message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}))}function df(n,e){const t=ve(n,i=>i.PUSH_MODE!==void 0&&!ue(e,i.PUSH_MODE));return S(t,i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function ff(n){const e=[],t=oe(n,(r,i,s)=>{const a=i.PATTERN;return a===de.NA||(fe(a)?r.push({str:a,idx:s,tokenType:i}):qe(a)&&pf(a)&&r.push({str:a.source,idx:s,tokenType:i})),r},[]);return C(n,(r,i)=>{C(t,({str:s,idx:a,tokenType:o})=>{if(i<a&&hf(s,r.PATTERN)){const c=`Token: ->${o.name}<- can never be matched.
Because it appears AFTER the Token Type ->${r.name}<-in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:c,type:j.UNREACHABLE_PATTERN,tokenTypes:[r,o]})}})}),e}function hf(n,e){if(qe(e)){const t=e.exec(n);return t!==null&&t.index===0}else{if(mt(e))return e(n,0,[],{});if(_(e,"exec"))return e.exec(n,0,[],{});if(typeof e=="string")return e===n;throw Error("non exhaustive match")}}function pf(n){return Dt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],t=>n.source.indexOf(t)!==-1)===void 0}function ds(n){const e=n.ignoreCase?"i":"";return new RegExp(`^(?:${n.source})`,e)}function fs(n){const e=n.ignoreCase?"iy":"y";return new RegExp(`${n.source}`,e)}function mf(n,e,t){const r=[];return _(n,an)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+an+`> property in its definition
`,type:j.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),_(n,Sn)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+Sn+`> property in its definition
`,type:j.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),_(n,Sn)&&_(n,an)&&!_(n.modes,n.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${an}: <${n.defaultMode}>which does not exist
`,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),_(n,Sn)&&C(n.modes,(i,s)=>{C(i,(a,o)=>{if(ze(a))r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${o}>
`,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(_(a,"LONGER_ALT")){const c=Z(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];C(c,l=>{!ze(l)&&!ue(i,l)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${a.name}> outside of mode <${s}>
`,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),r}function gf(n,e,t){const r=[];let i=!1;const s=hn(Ne(K(n.modes))),a=rr(s,c=>c[ht]===de.NA),o=gc(t);return e&&C(a,c=>{const l=mc(c,o);if(l!==!1){const d={message:Af(c,l),type:l.issue,tokenType:c};r.push(d)}else _(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(i=!0):wi(o,c.PATTERN)&&(i=!0)}),e&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
This Lexer has been defined to track line and column information,
But none of the Token Types can be identified as matching a line terminator.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
for details.`,type:j.NO_LINE_BREAKS_FLAGS}),r}function yf(n){const e={},t=Mt(n);return C(t,r=>{const i=n[r];if(Z(i))e[r]=[];else throw Error("non exhaustive match")}),e}function pc(n){const e=n.PATTERN;if(qe(e))return!1;if(mt(e))return!0;if(_(e,"exec"))return!0;if(fe(e))return!1;throw Error("non exhaustive match")}function Tf(n){return fe(n)&&n.length===1?n.charCodeAt(0):!1}const Rf={test:function(n){const e=n.length;for(let t=this.lastIndex;t<e;t++){const r=n.charCodeAt(t);if(r===10)return this.lastIndex=t+1,!0;if(r===13)return n.charCodeAt(t+1)===10?this.lastIndex=t+2:this.lastIndex=t+1,!0}return!1},lastIndex:0};function mc(n,e){if(_(n,"LINE_BREAKS"))return!1;if(qe(n.PATTERN)){try{wi(e,n.PATTERN)}catch(t){return{issue:j.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}else{if(fe(n.PATTERN))return!1;if(pc(n))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function Af(n,e){if(e.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
The problem is in the <${n.name}> Token Type
Root cause: ${e.errMsg}.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===j.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
The problem is in the <${n.name}> Token Type
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function gc(n){return S(n,t=>fe(t)?t.charCodeAt(0):t)}function Ir(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}const on=256;let _n=[];function et(n){return n<on?n:_n[n]}function vf(){if(D(_n)){_n=new Array(65536);for(let n=0;n<65536;n++)_n[n]=n>255?255+~~(n/255):n}}function gn(n,e){const t=n.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}function Fn(n,e){return n.tokenTypeIdx===e.tokenTypeIdx}let hs=1;const yc={};function yn(n){const e=Ef(n);kf(e),If(e),Sf(e),C(e,t=>{t.isParent=t.categoryMatches.length>0})}function Ef(n){let e=te(n),t=n,r=!0;for(;r;){t=hn(Ne(S(t,s=>s.CATEGORIES)));const i=nr(t,e);e=e.concat(i),D(i)?r=!1:t=i}return e}function kf(n){C(n,e=>{Rc(e)||(yc[hs]=e,e.tokenTypeIdx=hs++),ps(e)&&!Z(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),ps(e)||(e.CATEGORIES=[]),xf(e)||(e.categoryMatches=[]),Nf(e)||(e.categoryMatchesMap={})})}function Sf(n){C(n,e=>{e.categoryMatches=[],C(e.categoryMatchesMap,(t,r)=>{e.categoryMatches.push(yc[r].tokenTypeIdx)})})}function If(n){C(n,e=>{Tc([],e)})}function Tc(n,e){C(n,t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),C(e.CATEGORIES,t=>{const r=n.concat(e);ue(r,t)||Tc(r,t)})}function Rc(n){return _(n,"tokenTypeIdx")}function ps(n){return _(n,"CATEGORIES")}function xf(n){return _(n,"categoryMatches")}function Nf(n){return _(n,"categoryMatchesMap")}function Cf(n){return _(n,"tokenTypeIdx")}const _f={buildUnableToPopLexerModeMessage(n){return`Unable to pop Lexer Mode after encountering Token ->${n.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(n,e,t,r,i){return`unexpected character: ->${n.charAt(e)}<- at offset: ${e}, skipped ${t} characters.`}};var j;(function(n){n[n.MISSING_PATTERN=0]="MISSING_PATTERN",n[n.INVALID_PATTERN=1]="INVALID_PATTERN",n[n.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",n[n.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",n[n.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",n[n.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",n[n.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",n[n.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",n[n.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",n[n.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",n[n.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",n[n.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",n[n.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",n[n.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",n[n.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",n[n.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",n[n.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",n[n.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));const cn={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:_f,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(cn);class de{constructor(e,t=cn){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,s)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;const a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${a}--> <${i}>`);const{time:o,value:c}=lc(s),l=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${a}<-- <${i}> time: ${o}ms`),this.traceInitIndent--,c}else return s()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
a boolean 2nd argument is no longer supported`);this.config=Ae({},cn,t);const r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,s=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===cn.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Rf;else if(this.config.lineTerminatorCharacters===cn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Z(e)?i={modes:{defaultMode:te(e)},defaultMode:an}:(s=!1,i=te(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(mf(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(gf(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},C(i.modes,(o,c)=>{i.modes[c]=rr(o,l=>ze(l))});const a=Mt(i.modes);if(C(i.modes,(o,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Qd(o,a))}),D(this.lexerDefinitionErrors)){yn(o);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Jd(o,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=Ae({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=i.defaultMode,!D(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const c=S(this.lexerDefinitionErrors,l=>l.message).join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+c)}C(this.lexerDefinitionWarning,o=>{cc(o.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(hc?(this.chopInput=Zi,this.match=this.matchWithTest):(this.updateLastIndex=q,this.match=this.matchWithExec),s&&(this.handleModes=q),this.trackStartLines===!1&&(this.computeNewColumn=Zi),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=q),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const o=oe(this.canModeBeOptimized,(c,l,u)=>(l===!1&&c.push(u),c),[]);if(t.ensureOptimizations&&!D(o))throw Error(`Lexer Modes: < ${o.join(", ")} > cannot be optimized.
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{zd()}),this.TRACE_INIT("toFastProperties",()=>{uc(this)})})}tokenize(e,t=this.defaultMode){if(!D(this.lexerDefinitionErrors)){const i=S(this.lexerDefinitionErrors,s=>s.message).join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+i)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let r,i,s,a,o,c,l,u,d,f,h,m,g,A,y;const v=e,R=v.length;let N=0,F=0;const ne=this.hasCustom?0:Math.floor(e.length/10),we=new Array(ne),ge=[];let De=this.trackStartLines?1:void 0,Se=this.trackStartLines?1:void 0;const k=yf(this.emptyGroups),T=this.trackStartLines,E=this.config.lineTerminatorsPattern;let I=0,O=[],$=[];const L=[],ye=[];Object.freeze(ye);let z;function V(){return O}function at(re){const Ie=et(re),Tt=$[Ie];return Tt===void 0?ye:Tt}const Dl=re=>{if(L.length===1&&re.tokenType.PUSH_MODE===void 0){const Ie=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(re);ge.push({offset:re.startOffset,line:re.startLine,column:re.startColumn,length:re.image.length,message:Ie})}else{L.pop();const Ie=Ft(L);O=this.patternIdxToConfig[Ie],$=this.charCodeToPatternIdxToConfig[Ie],I=O.length;const Tt=this.canModeBeOptimized[Ie]&&this.config.safeMode===!1;$&&Tt?z=at:z=V}};function qi(re){L.push(re),$=this.charCodeToPatternIdxToConfig[re],O=this.patternIdxToConfig[re],I=O.length,I=O.length;const Ie=this.canModeBeOptimized[re]&&this.config.safeMode===!1;$&&Ie?z=at:z=V}qi.call(this,t);let Le;const Yi=this.config.recoveryEnabled;for(;N<R;){c=null;const re=v.charCodeAt(N),Ie=z(re),Tt=Ie.length;for(r=0;r<Tt;r++){Le=Ie[r];const Te=Le.pattern;l=null;const Ve=Le.short;if(Ve!==!1?re===Ve&&(c=Te):Le.isCustom===!0?(y=Te.exec(v,N,we,k),y!==null?(c=y[0],y.payload!==void 0&&(l=y.payload)):c=null):(this.updateLastIndex(Te,N),c=this.match(Te,e,N)),c!==null){if(o=Le.longerAlt,o!==void 0){const Xe=o.length;for(s=0;s<Xe;s++){const We=O[o[s]],ot=We.pattern;if(u=null,We.isCustom===!0?(y=ot.exec(v,N,we,k),y!==null?(a=y[0],y.payload!==void 0&&(u=y.payload)):a=null):(this.updateLastIndex(ot,N),a=this.match(ot,e,N)),a&&a.length>c.length){c=a,l=u,Le=We;break}}}break}}if(c!==null){if(d=c.length,f=Le.group,f!==void 0&&(h=Le.tokenTypeIdx,m=this.createTokenInstance(c,N,h,Le.tokenType,De,Se,d),this.handlePayload(m,l),f===!1?F=this.addToken(we,F,m):k[f].push(m)),e=this.chopInput(e,d),N=N+d,Se=this.computeNewColumn(Se,d),T===!0&&Le.canLineTerminator===!0){let Te=0,Ve,Xe;E.lastIndex=0;do Ve=E.test(c),Ve===!0&&(Xe=E.lastIndex-1,Te++);while(Ve===!0);Te!==0&&(De=De+Te,Se=d-Xe,this.updateTokenEndLineColumnLocation(m,f,Xe,Te,De,Se,d))}this.handleModes(Le,Dl,qi,m)}else{const Te=N,Ve=De,Xe=Se;let We=Yi===!1;for(;We===!1&&N<R;)for(e=this.chopInput(e,1),N++,i=0;i<I;i++){const ot=O[i],Rr=ot.pattern,Xi=ot.short;if(Xi!==!1?v.charCodeAt(N)===Xi&&(We=!0):ot.isCustom===!0?We=Rr.exec(v,N,we,k)!==null:(this.updateLastIndex(Rr,N),We=Rr.exec(e)!==null),We===!0)break}if(g=N-Te,Se=this.computeNewColumn(Se,g),A=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(v,Te,g,Ve,Xe),ge.push({offset:Te,line:Ve,column:Xe,length:g,message:A}),Yi===!1)break}}return this.hasCustom||(we.length=F),{tokens:we,groups:k,errors:ge}}handleModes(e,t,r,i){if(e.pop===!0){const s=e.push;t(i),s!==void 0&&r.call(this,s)}else e.push!==void 0&&r.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,r,i,s,a,o){let c,l;t!==void 0&&(c=r===o-1,l=c?-1:0,i===1&&c===!0||(e.endLine=s+l,e.endColumn=a-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,r,i){return{image:e,startOffset:t,tokenTypeIdx:r,tokenType:i}}createStartOnlyToken(e,t,r,i,s,a){return{image:e,startOffset:t,startLine:s,startColumn:a,tokenTypeIdx:r,tokenType:i}}createFullToken(e,t,r,i,s,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:s,endLine:s,startColumn:a,endColumn:a+o-1,tokenTypeIdx:r,tokenType:i}}addTokenUsingPush(e,t,r){return e.push(r),t}addTokenUsingMemberAccess(e,t,r){return e[t]=r,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}matchWithTest(e,t,r){return e.test(t)===!0?t.substring(r,e.lastIndex):null}matchWithExec(e,t){const r=e.exec(t);return r!==null?r[0]:null}}de.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";de.NA=/NOT_APPLICABLE/;function Et(n){return Ac(n)?n.LABEL:n.name}function Ac(n){return fe(n.LABEL)&&n.LABEL!==""}const wf="parent",ms="categories",gs="label",ys="group",Ts="push_mode",Rs="pop_mode",As="longer_alt",vs="line_breaks",Es="start_chars_hint";function vc(n){return Lf(n)}function Lf(n){const e=n.pattern,t={};if(t.name=n.name,ze(e)||(t.PATTERN=e),_(n,wf))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return _(n,ms)&&(t.CATEGORIES=n[ms]),yn([t]),_(n,gs)&&(t.LABEL=n[gs]),_(n,ys)&&(t.GROUP=n[ys]),_(n,Rs)&&(t.POP_MODE=n[Rs]),_(n,Ts)&&(t.PUSH_MODE=n[Ts]),_(n,As)&&(t.LONGER_ALT=n[As]),_(n,vs)&&(t.LINE_BREAKS=n[vs]),_(n,Es)&&(t.START_CHARS_HINT=n[Es]),t}const tt=vc({name:"EOF",pattern:de.NA});yn([tt]);function Li(n,e,t,r,i,s,a,o){return{image:e,startOffset:t,endOffset:r,startLine:i,endLine:s,startColumn:a,endColumn:o,tokenTypeIdx:n.tokenTypeIdx,tokenType:n}}function Ec(n,e){return gn(n,e)}const At={buildMismatchTokenMessage({expected:n,actual:e,previous:t,ruleName:r}){return`Expecting ${Ac(n)?`--> ${Et(n)} <--`:`token of type --> ${n.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:n,ruleName:e}){return"Redundant input, expecting EOF but found: "+n.image},buildNoViableAltMessage({expectedPathsPerAlt:n,actual:e,previous:t,customUserDescription:r,ruleName:i}){const s="Expecting: ",o=`
but found: '`+be(e).image+"'";if(r)return s+r+o;{const c=oe(n,(f,h)=>f.concat(h),[]),l=S(c,f=>`[${S(f,h=>Et(h)).join(", ")}]`),d=`one of these possible Token sequences:
${S(l,(f,h)=>` ${h+1}. ${f}`).join(`
`)}`;return s+d+o}},buildEarlyExitMessage({expectedIterationPaths:n,actual:e,customUserDescription:t,ruleName:r}){const i="Expecting: ",a=`
but found: '`+be(e).image+"'";if(t)return i+t+a;{const c=`expecting at least one iteration which starts with one of these possible Token sequences::
<${S(n,l=>`[${S(l,u=>Et(u)).join(",")}]`).join(" ,")}>`;return i+c+a}}};Object.freeze(At);const $f={buildRuleNotFoundError(n,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
inside top level rule: ->`+n.name+"<-"}},lt={buildDuplicateFoundError(n,e){function t(u){return u instanceof G?u.terminalType.name:u instanceof ce?u.nonTerminalName:""}const r=n.name,i=be(e),s=i.idx,a=Fe(i),o=t(i),c=s>0;let l=`->${a}${c?s:""}<- ${o?`with argument: ->${o}<-`:""}
appears more than once (${e.length} times) in the top level rule: ->${r}<-.
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
`;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,`
`),l},buildNamespaceConflictError(n){return`Namespace conflict found in grammar.
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${n.name}>.
To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(n){const e=S(n.prefixPath,i=>Et(i)).join(", "),t=n.alternation.idx===0?"":n.alternation.idx;return`Ambiguous alternatives: <${n.ambiguityIndices.join(" ,")}> due to common lookahead prefix
in <OR${t}> inside <${n.topLevelRule.name}> Rule,
<${e}> may appears as a prefix path in all these alternatives.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details.`},buildAlternationAmbiguityError(n){const e=S(n.prefixPath,i=>Et(i)).join(", "),t=n.alternation.idx===0?"":n.alternation.idx;let r=`Ambiguous Alternatives Detected: <${n.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${n.topLevelRule.name}> Rule,
<${e}> may appears as a prefix path in all these alternatives.
`;return r=r+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,r},buildEmptyRepetitionError(n){let e=Fe(n.repetition);return n.repetition.idx!==0&&(e+=n.repetition.idx),`The repetition <${e}> within Rule <${n.topLevelRule.name}> can never consume any tokens.
This could lead to an infinite loop.`},buildTokenNameError(n){return"deprecated"},buildEmptyAlternationError(n){return`Ambiguous empty alternative: <${n.emptyChoiceIdx+1}> in <OR${n.alternation.idx}> inside <${n.topLevelRule.name}> Rule.
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(n){return`An Alternation cannot have more than 256 alternatives:
<OR${n.alternation.idx}> inside <${n.topLevelRule.name}> Rule.
has ${n.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(n){const e=n.topLevelRule.name,t=S(n.leftRecursionPath,s=>s.name),r=`${e} --> ${t.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
rule: <${e}> can be invoked from itself (directly or indirectly)
without consuming any Tokens. The grammar path that causes this is:
${r}
To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(n){return"deprecated"},buildDuplicateRuleNameError(n){let e;return n.topLevelRule instanceof qt?e=n.topLevelRule.name:e=n.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${n.grammarName}<-`}};function Of(n,e){const t=new bf(n,e);return t.resolveRefs(),t.errors}class bf extends Yt{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){C(K(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:le.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Pf extends ur{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=te(this.path.ruleStack).reverse(),this.occurrenceStack=te(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const i=t.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){D(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Mf extends Pf{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const i=t.concat(r),s=new he({definition:i});this.possibleTokTypes=mn(s),this.found=!0}}}class fr extends ur{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Df extends fr{walkMany(e,t,r){if(e.idx===this.occurrence){const i=be(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,t,r)}}class ks extends fr{walkManySep(e,t,r){if(e.idx===this.occurrence){const i=be(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,t,r)}}class Ff extends fr{walkAtLeastOne(e,t,r){if(e.idx===this.occurrence){const i=be(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,t,r)}}class Ss extends fr{walkAtLeastOneSep(e,t,r){if(e.idx===this.occurrence){const i=be(t.concat(r));this.result.isEndOfRule=i===void 0,i instanceof G&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,t,r)}}function Br(n,e,t=[]){t=te(t);let r=[],i=0;function s(o){return o.concat(J(n,i+1))}function a(o){const c=Br(s(o),e,t);return r.concat(c)}for(;t.length<e&&i<n.length;){const o=n[i];if(o instanceof he)return a(o.definition);if(o instanceof ce)return a(o.definition);if(o instanceof ee)r=a(o.definition);else if(o instanceof Ee){const c=o.definition.concat([new W({definition:o.definition})]);return a(c)}else if(o instanceof ke){const c=[new he({definition:o.definition}),new W({definition:[new G({terminalType:o.separator})].concat(o.definition)})];return a(c)}else if(o instanceof pe){const c=o.definition.concat([new W({definition:[new G({terminalType:o.separator})].concat(o.definition)})]);r=a(c)}else if(o instanceof W){const c=o.definition.concat([new W({definition:o.definition})]);r=a(c)}else{if(o instanceof me)return C(o.definition,c=>{D(c.definition)===!1&&(r=a(c.definition))}),r;if(o instanceof G)t.push(o.terminalType);else throw Error("non exhaustive match")}i++}return r.push({partialPath:t,suffixDef:J(n,i)}),r}function kc(n,e,t,r){const i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE";let o=!1;const c=e.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:n,ruleStack:[],occurrenceStack:[]});!D(d);){const f=d.pop();if(f===a){o&&Ft(d).idx<=l&&d.pop();continue}const h=f.def,m=f.idx,g=f.ruleStack,A=f.occurrenceStack;if(D(h))continue;const y=h[0];if(y===i){const v={idx:m,def:J(h),ruleStack:ln(g),occurrenceStack:ln(A)};d.push(v)}else if(y instanceof G)if(m<c-1){const v=m+1,R=e[v];if(t(R,y.terminalType)){const N={idx:v,def:J(h),ruleStack:g,occurrenceStack:A};d.push(N)}}else if(m===c-1)u.push({nextTokenType:y.terminalType,nextTokenOccurrence:y.idx,ruleStack:g,occurrenceStack:A}),o=!0;else throw Error("non exhaustive match");else if(y instanceof ce){const v=te(g);v.push(y.nonTerminalName);const R=te(A);R.push(y.idx);const N={idx:m,def:y.definition.concat(s,J(h)),ruleStack:v,occurrenceStack:R};d.push(N)}else if(y instanceof ee){const v={idx:m,def:J(h),ruleStack:g,occurrenceStack:A};d.push(v),d.push(a);const R={idx:m,def:y.definition.concat(J(h)),ruleStack:g,occurrenceStack:A};d.push(R)}else if(y instanceof Ee){const v=new W({definition:y.definition,idx:y.idx}),R=y.definition.concat([v],J(h)),N={idx:m,def:R,ruleStack:g,occurrenceStack:A};d.push(N)}else if(y instanceof ke){const v=new G({terminalType:y.separator}),R=new W({definition:[v].concat(y.definition),idx:y.idx}),N=y.definition.concat([R],J(h)),F={idx:m,def:N,ruleStack:g,occurrenceStack:A};d.push(F)}else if(y instanceof pe){const v={idx:m,def:J(h),ruleStack:g,occurrenceStack:A};d.push(v),d.push(a);const R=new G({terminalType:y.separator}),N=new W({definition:[R].concat(y.definition),idx:y.idx}),F=y.definition.concat([N],J(h)),ne={idx:m,def:F,ruleStack:g,occurrenceStack:A};d.push(ne)}else if(y instanceof W){const v={idx:m,def:J(h),ruleStack:g,occurrenceStack:A};d.push(v),d.push(a);const R=new W({definition:y.definition,idx:y.idx}),N=y.definition.concat([R],J(h)),F={idx:m,def:N,ruleStack:g,occurrenceStack:A};d.push(F)}else if(y instanceof me)for(let v=y.definition.length-1;v>=0;v--){const R=y.definition[v],N={idx:m,def:R.definition.concat(J(h)),ruleStack:g,occurrenceStack:A};d.push(N),d.push(a)}else if(y instanceof he)d.push({idx:m,def:y.definition.concat(J(h)),ruleStack:g,occurrenceStack:A});else if(y instanceof qt)d.push(Gf(y,m,g,A));else throw Error("non exhaustive match")}return u}function Gf(n,e,t,r){const i=te(t);i.push(n.name);const s=te(r);return s.push(1),{idx:e,def:n.definition,ruleStack:i,occurrenceStack:s}}var B;(function(n){n[n.OPTION=0]="OPTION",n[n.REPETITION=1]="REPETITION",n[n.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",n[n.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",n[n.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",n[n.ALTERNATION=5]="ALTERNATION"})(B||(B={}));function $i(n){if(n instanceof ee||n==="Option")return B.OPTION;if(n instanceof W||n==="Repetition")return B.REPETITION;if(n instanceof Ee||n==="RepetitionMandatory")return B.REPETITION_MANDATORY;if(n instanceof ke||n==="RepetitionMandatoryWithSeparator")return B.REPETITION_MANDATORY_WITH_SEPARATOR;if(n instanceof pe||n==="RepetitionWithSeparator")return B.REPETITION_WITH_SEPARATOR;if(n instanceof me||n==="Alternation")return B.ALTERNATION;throw Error("non exhaustive match")}function Is(n){const{occurrence:e,rule:t,prodType:r,maxLookahead:i}=n,s=$i(r);return s===B.ALTERNATION?hr(e,t,i):pr(e,t,s,i)}function Uf(n,e,t,r,i,s){const a=hr(n,e,t),o=xc(a)?Fn:gn;return s(a,r,o,i)}function Bf(n,e,t,r,i,s){const a=pr(n,e,i,t),o=xc(a)?Fn:gn;return s(a[0],o,r)}function Vf(n,e,t,r){const i=n.length,s=$e(n,a=>$e(a,o=>o.length===1));if(e)return function(a){const o=S(a,c=>c.GATE);for(let c=0;c<i;c++){const l=n[c],u=l.length,d=o[c];if(!(d!==void 0&&d.call(this)===!1))e:for(let f=0;f<u;f++){const h=l[f],m=h.length;for(let g=0;g<m;g++){const A=this.LA(g+1);if(t(A,h[g])===!1)continue e}return c}}};if(s&&!r){const a=S(n,c=>Ne(c)),o=oe(a,(c,l,u)=>(C(l,d=>{_(c,d.tokenTypeIdx)||(c[d.tokenTypeIdx]=u),C(d.categoryMatches,f=>{_(c,f)||(c[f]=u)})}),c),{});return function(){const c=this.LA(1);return o[c.tokenTypeIdx]}}else return function(){for(let a=0;a<i;a++){const o=n[a],c=o.length;e:for(let l=0;l<c;l++){const u=o[l],d=u.length;for(let f=0;f<d;f++){const h=this.LA(f+1);if(t(h,u[f])===!1)continue e}return a}}}}function Wf(n,e,t){const r=$e(n,s=>s.length===1),i=n.length;if(r&&!t){const s=Ne(n);if(s.length===1&&D(s[0].categoryMatches)){const o=s[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===o}}else{const a=oe(s,(o,c,l)=>(o[c.tokenTypeIdx]=!0,C(c.categoryMatches,u=>{o[u]=!0}),o),[]);return function(){const o=this.LA(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let s=0;s<i;s++){const a=n[s],o=a.length;for(let c=0;c<o;c++){const l=this.LA(c+1);if(e(l,a[c])===!1)continue e}return!0}return!1}}class jf extends ur{constructor(e,t,r){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=r}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,r,i){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=r.concat(i),!0):!1}walkOption(e,t,r){this.checkIsTarget(e,B.OPTION,t,r)||super.walkOption(e,t,r)}walkAtLeastOne(e,t,r){this.checkIsTarget(e,B.REPETITION_MANDATORY,t,r)||super.walkOption(e,t,r)}walkAtLeastOneSep(e,t,r){this.checkIsTarget(e,B.REPETITION_MANDATORY_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}walkMany(e,t,r){this.checkIsTarget(e,B.REPETITION,t,r)||super.walkOption(e,t,r)}walkManySep(e,t,r){this.checkIsTarget(e,B.REPETITION_WITH_SEPARATOR,t,r)||super.walkOption(e,t,r)}}class Sc extends Yt{constructor(e,t,r){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=r,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,B.OPTION)}visitRepetition(e){this.checkIsTarget(e,B.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,B.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,B.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,B.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,B.ALTERNATION)}}function xs(n){const e=new Array(n);for(let t=0;t<n;t++)e[t]=[];return e}function xr(n){let e=[""];for(let t=0;t<n.length;t++){const r=n[t],i=[];for(let s=0;s<e.length;s++){const a=e[s];i.push(a+"_"+r.tokenTypeIdx);for(let o=0;o<r.categoryMatches.length;o++){const c="_"+r.categoryMatches[o];i.push(a+c)}}e=i}return e}function Hf(n,e,t){for(let r=0;r<n.length;r++){if(r===t)continue;const i=n[r];for(let s=0;s<e.length;s++){const a=e[s];if(i[a]===!0)return!1}}return!0}function Ic(n,e){const t=S(n,a=>Br([a],1)),r=xs(t.length),i=S(t,a=>{const o={};return C(a,c=>{const l=xr(c.partialPath);C(l,u=>{o[u]=!0})}),o});let s=t;for(let a=1;a<=e;a++){const o=s;s=xs(o.length);for(let c=0;c<o.length;c++){const l=o[c];for(let u=0;u<l.length;u++){const d=l[u].partialPath,f=l[u].suffixDef,h=xr(d);if(Hf(i,h,c)||D(f)||d.length===e){const g=r[c];if(Vr(g,d)===!1){g.push(d);for(let A=0;A<h.length;A++){const y=h[A];i[c][y]=!0}}}else{const g=Br(f,a+1,d);s[c]=s[c].concat(g),C(g,A=>{const y=xr(A.partialPath);C(y,v=>{i[c][v]=!0})})}}}}return r}function hr(n,e,t,r){const i=new Sc(n,B.ALTERNATION,r);return e.accept(i),Ic(i.result,t)}function pr(n,e,t,r){const i=new Sc(n,t);e.accept(i);const s=i.result,o=new jf(e,n,t).startWalking(),c=new he({definition:s}),l=new he({definition:o});return Ic([c,l],r)}function Vr(n,e){e:for(let t=0;t<n.length;t++){const r=n[t];if(r.length===e.length){for(let i=0;i<r.length;i++){const s=e[i],a=r[i];if((s===a||a.categoryMatchesMap[s.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function Kf(n,e){return n.length<e.length&&$e(n,(t,r)=>{const i=e[r];return t===i||i.categoryMatchesMap[t.tokenTypeIdx]})}function xc(n){return $e(n,e=>$e(e,t=>$e(t,r=>D(r.categoryMatches))))}function zf(n){const e=n.lookaheadStrategy.validate({rules:n.rules,tokenTypes:n.tokenTypes,grammarName:n.grammarName});return S(e,t=>Object.assign({type:le.CUSTOM_LOOKAHEAD_VALIDATION},t))}function qf(n,e,t,r){const i=Re(n,c=>Yf(c,t)),s=oh(n,e,t),a=Re(n,c=>rh(c,t)),o=Re(n,c=>Qf(c,n,r,t));return i.concat(s,a,o)}function Yf(n,e){const t=new Jf;n.accept(t);const r=t.allProductions,i=mu(r,Xf),s=Pe(i,o=>o.length>1);return S(K(s),o=>{const c=be(o),l=e.buildDuplicateFoundError(n,o),u=Fe(c),d={message:l,type:le.DUPLICATE_PRODUCTIONS,ruleName:n.name,dslName:u,occurrence:c.idx},f=Nc(c);return f&&(d.parameter=f),d})}function Xf(n){return`${Fe(n)}_#_${n.idx}_#_${Nc(n)}`}function Nc(n){return n instanceof G?n.terminalType.name:n instanceof ce?n.nonTerminalName:""}class Jf extends Yt{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}function Qf(n,e,t,r){const i=[];if(oe(e,(a,o)=>o.name===n.name?a+1:a,0)>1){const a=r.buildDuplicateRuleNameError({topLevelRule:n,grammarName:t});i.push({message:a,type:le.DUPLICATE_RULE_NAME,ruleName:n.name})}return i}function Zf(n,e,t){const r=[];let i;return ue(e,n)||(i=`Invalid rule override, rule: ->${n}<- cannot be overridden in the grammar: ->${t}<-as it is not defined in any of the super grammars `,r.push({message:i,type:le.INVALID_RULE_OVERRIDE,ruleName:n})),r}function Cc(n,e,t,r=[]){const i=[],s=wn(e.definition);if(D(s))return[];{const a=n.name;ue(s,n)&&i.push({message:t.buildLeftRecursionError({topLevelRule:n,leftRecursionPath:r}),type:le.LEFT_RECURSION,ruleName:a});const c=nr(s,r.concat([n])),l=Re(c,u=>{const d=te(r);return d.push(u),Cc(n,u,t,d)});return i.concat(l)}}function wn(n){let e=[];if(D(n))return e;const t=be(n);if(t instanceof ce)e.push(t.referencedRule);else if(t instanceof he||t instanceof ee||t instanceof Ee||t instanceof ke||t instanceof pe||t instanceof W)e=e.concat(wn(t.definition));else if(t instanceof me)e=Ne(S(t.definition,s=>wn(s.definition)));else if(!(t instanceof G))throw Error("non exhaustive match");const r=Mn(t),i=n.length>1;if(r&&i){const s=J(n);return e.concat(wn(s))}else return e}class Oi extends Yt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function eh(n,e){const t=new Oi;n.accept(t);const r=t.alternations;return Re(r,s=>{const a=ln(s.definition);return Re(a,(o,c)=>{const l=kc([o],[],gn,1);return D(l)?[{message:e.buildEmptyAlternationError({topLevelRule:n,alternation:s,emptyChoiceIdx:c}),type:le.NONE_LAST_EMPTY_ALT,ruleName:n.name,occurrence:s.idx,alternative:c+1}]:[]})})}function th(n,e,t){const r=new Oi;n.accept(r);let i=r.alternations;return i=rr(i,a=>a.ignoreAmbiguities===!0),Re(i,a=>{const o=a.idx,c=a.maxLookahead||e,l=hr(o,n,c,a),u=sh(l,a,n,t),d=ah(l,a,n,t);return u.concat(d)})}class nh extends Yt{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}function rh(n,e){const t=new Oi;n.accept(t);const r=t.alternations;return Re(r,s=>s.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:n,alternation:s}),type:le.TOO_MANY_ALTS,ruleName:n.name,occurrence:s.idx}]:[])}function ih(n,e,t){const r=[];return C(n,i=>{const s=new nh;i.accept(s);const a=s.allProductions;C(a,o=>{const c=$i(o),l=o.maxLookahead||e,u=o.idx,f=pr(u,i,c,l)[0];if(D(Ne(f))){const h=t.buildEmptyRepetitionError({topLevelRule:i,repetition:o});r.push({message:h,type:le.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),r}function sh(n,e,t,r){const i=[],s=oe(n,(o,c,l)=>(e.definition[l].ignoreAmbiguities===!0||C(c,u=>{const d=[l];C(n,(f,h)=>{l!==h&&Vr(f,u)&&e.definition[h].ignoreAmbiguities!==!0&&d.push(h)}),d.length>1&&!Vr(i,u)&&(i.push(u),o.push({alts:d,path:u}))}),o),[]);return S(s,o=>{const c=S(o.alts,u=>u+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:c,prefixPath:o.path}),type:le.AMBIGUOUS_ALTS,ruleName:t.name,occurrence:e.idx,alternatives:o.alts}})}function ah(n,e,t,r){const i=oe(n,(a,o,c)=>{const l=S(o,u=>({idx:c,path:u}));return a.concat(l)},[]);return hn(Re(i,a=>{if(e.definition[a.idx].ignoreAmbiguities===!0)return[];const c=a.idx,l=a.path,u=ve(i,f=>e.definition[f.idx].ignoreAmbiguities!==!0&&f.idx<c&&Kf(f.path,l));return S(u,f=>{const h=[f.idx+1,c+1],m=e.idx===0?"":e.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:h,prefixPath:f.path}),type:le.AMBIGUOUS_PREFIX_ALTS,ruleName:t.name,occurrence:m,alternatives:h}})}))}function oh(n,e,t){const r=[],i=S(e,s=>s.name);return C(n,s=>{const a=s.name;if(ue(i,a)){const o=t.buildNamespaceConflictError(s);r.push({message:o,type:le.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),r}function ch(n){const e=Ai(n,{errMsgProvider:$f}),t={};return C(n.rules,r=>{t[r.name]=r}),Of(t,e.errMsgProvider)}function lh(n){return n=Ai(n,{errMsgProvider:lt}),qf(n.rules,n.tokenTypes,n.errMsgProvider,n.grammarName)}const _c="MismatchedTokenException",wc="NoViableAltException",Lc="EarlyExitException",$c="NotAllInputParsedException",Oc=[_c,wc,Lc,$c];Object.freeze(Oc);function Gn(n){return ue(Oc,n.name)}class mr extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class bc extends mr{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=_c}}class uh extends mr{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=wc}}class dh extends mr{constructor(e,t){super(e,t),this.name=$c}}class fh extends mr{constructor(e,t,r){super(e,t),this.previousToken=r,this.name=Lc}}const Nr={},Pc="InRuleRecoveryException";class hh extends Error{constructor(e){super(e),this.name=Pc}}class ph{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=_(e,"recoveryEnabled")?e.recoveryEnabled:Ye.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=mh)}getTokenToInsert(e){const t=Li(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,r,i){const s=this.findReSyncTokenType(),a=this.exportLexerState(),o=[];let c=!1;const l=this.LA(1);let u=this.LA(1);const d=()=>{const f=this.LA(0),h=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:f,ruleName:this.getCurrRuleFullName()}),m=new bc(h,l,this.LA(0));m.resyncedTokens=ln(o),this.SAVE_ERROR(m)};for(;!c;)if(this.tokenMatcher(u,i)){d();return}else if(r.call(this)){d(),e.apply(this,t);return}else this.tokenMatcher(u,s)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,r){return!(r===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){const r=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(r)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const r=this.SKIP_TOKEN();return this.consumeToken(),r}throw new hh("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||D(t))return!1;const r=this.LA(1);return Dt(t,s=>this.tokenMatcher(r,s))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey(),r=this.getFollowSetFromFollowKey(t);return ue(r,e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA(1),r=2;for(;;){const i=Dt(e,s=>Ec(t,s));if(i!==void 0)return i;t=this.LA(r),r++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Nr;const e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),r=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(r)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return S(e,(r,i)=>i===0?Nr:{ruleName:this.shortRuleNameToFullName(r),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])})}flattenFollowSet(){const e=S(this.buildFullFollowKeyStack(),t=>this.getFollowSetFromFollowKey(t));return Ne(e)}getFollowSetFromFollowKey(e){if(e===Nr)return[tt];const t=e.ruleName+e.idxInCallingRule+dc+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,tt)||t.push(e),t}reSyncTo(e){const t=[];let r=this.LA(1);for(;this.tokenMatcher(r,e)===!1;)r=this.SKIP_TOKEN(),this.addToResyncTokens(r,t);return ln(t)}attemptInRepetitionRecovery(e,t,r,i,s,a,o){}getCurrentGrammarPath(e,t){const r=this.getHumanReadableRuleStack(),i=te(this.RULE_OCCURRENCE_STACK);return{ruleStack:r,occurrenceStack:i,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return S(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}}function mh(n,e,t,r,i,s,a){const o=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[o];if(c===void 0){const f=this.getCurrRuleFullName(),h=this.getGAstProductions()[f];c=new s(h,i).startWalking(),this.firstAfterRepMap[o]=c}let l=c.token,u=c.occurrence;const d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=tt,u=1),!(l===void 0||u===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,u,a)&&this.tryInRepetitionRecovery(n,e,t,l)}const gh=4,it=8,Mc=1<<it,Dc=2<<it,Wr=3<<it,jr=4<<it,Hr=5<<it,Ln=6<<it;function Cr(n,e,t){return t|e|n}class bi{constructor(e){var t;this.maxLookahead=(t=e==null?void 0:e.maxLookahead)!==null&&t!==void 0?t:Ye.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(D(t)){const r=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),s=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...r,...i,...s]}return t}validateNoLeftRecursion(e){return Re(e,t=>Cc(t,t,lt))}validateEmptyOrAlternatives(e){return Re(e,t=>eh(t,lt))}validateAmbiguousAlternationAlternatives(e,t){return Re(e,r=>th(r,t,lt))}validateSomeNonEmptyLookaheadPath(e,t){return ih(e,t,lt)}buildLookaheadForAlternation(e){return Uf(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Vf)}buildLookaheadForOptional(e){return Bf(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,$i(e.prodType),Wf)}}class yh{initLooksAhead(e){this.dynamicTokensEnabled=_(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:Ye.dynamicTokensEnabled,this.maxLookahead=_(e,"maxLookahead")?e.maxLookahead:Ye.maxLookahead,this.lookaheadStrategy=_(e,"lookaheadStrategy")?e.lookaheadStrategy:new bi({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){C(e,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{const{alternation:r,repetition:i,option:s,repetitionMandatory:a,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:c}=Rh(t);C(r,l=>{const u=l.idx===0?"":l.idx;this.TRACE_INIT(`${Fe(l)}${u}`,()=>{const d=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:t,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),f=Cr(this.fullRuleNameToShort[t.name],Mc,l.idx);this.setLaFuncCache(f,d)})}),C(i,l=>{this.computeLookaheadFunc(t,l.idx,Wr,"Repetition",l.maxLookahead,Fe(l))}),C(s,l=>{this.computeLookaheadFunc(t,l.idx,Dc,"Option",l.maxLookahead,Fe(l))}),C(a,l=>{this.computeLookaheadFunc(t,l.idx,jr,"RepetitionMandatory",l.maxLookahead,Fe(l))}),C(o,l=>{this.computeLookaheadFunc(t,l.idx,Ln,"RepetitionMandatoryWithSeparator",l.maxLookahead,Fe(l))}),C(c,l=>{this.computeLookaheadFunc(t,l.idx,Hr,"RepetitionWithSeparator",l.maxLookahead,Fe(l))})})})}computeLookaheadFunc(e,t,r,i,s,a){this.TRACE_INIT(`${a}${t===0?"":t}`,()=>{const o=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:s||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),c=Cr(this.fullRuleNameToShort[e.name],r,t);this.setLaFuncCache(c,o)})}getKeyForAutomaticLookahead(e,t){const r=this.getLastExplicitRuleShortName();return Cr(r,e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}}class Th extends Yt{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}}const In=new Th;function Rh(n){In.reset(),n.accept(In);const e=In.dslMethods;return In.reset(),e}function Ns(n,e){isNaN(n.startOffset)===!0?(n.startOffset=e.startOffset,n.endOffset=e.endOffset):n.endOffset<e.endOffset&&(n.endOffset=e.endOffset)}function Cs(n,e){isNaN(n.startOffset)===!0?(n.startOffset=e.startOffset,n.startColumn=e.startColumn,n.startLine=e.startLine,n.endOffset=e.endOffset,n.endColumn=e.endColumn,n.endLine=e.endLine):n.endOffset<e.endOffset&&(n.endOffset=e.endOffset,n.endColumn=e.endColumn,n.endLine=e.endLine)}function Ah(n,e,t){n.children[t]===void 0?n.children[t]=[e]:n.children[t].push(e)}function vh(n,e,t){n.children[e]===void 0?n.children[e]=[t]:n.children[e].push(t)}const Eh="name";function Fc(n,e){Object.defineProperty(n,Eh,{enumerable:!1,configurable:!0,writable:!1,value:e})}function kh(n,e){const t=Mt(n),r=t.length;for(let i=0;i<r;i++){const s=t[i],a=n[s],o=a.length;for(let c=0;c<o;c++){const l=a[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,e)}}}function Sh(n,e){const t=function(){};Fc(t,n+"BaseSemantics");const r={visit:function(i,s){if(Z(i)&&(i=i[0]),!ze(i))return this[i.name](i.children,s)},validateVisitor:function(){const i=xh(this,e);if(!D(i)){const s=S(i,a=>a.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
${s.join(`
`).replace(/\n/g,`
`)}`)}}};return t.prototype=r,t.prototype.constructor=t,t._RULE_NAMES=e,t}function Ih(n,e,t){const r=function(){};Fc(r,n+"BaseSemanticsWithDefaults");const i=Object.create(t.prototype);return C(e,s=>{i[s]=kh}),r.prototype=i,r.prototype.constructor=r,r}var Kr;(function(n){n[n.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",n[n.MISSING_METHOD=1]="MISSING_METHOD"})(Kr||(Kr={}));function xh(n,e){return Nh(n,e)}function Nh(n,e){const t=ve(e,i=>mt(n[i])===!1),r=S(t,i=>({msg:`Missing visitor method: <${i}> on ${n.constructor.name} CST Visitor.`,type:Kr.MISSING_METHOD,methodName:i}));return hn(r)}class Ch{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=_(e,"nodeLocationTracking")?e.nodeLocationTracking:Ye.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=q,this.cstFinallyStateUpdate=q,this.cstPostTerminal=q,this.cstPostNonTerminal=q,this.cstPostRule=q;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Cs,this.setNodeLocationFromNode=Cs,this.cstPostRule=q,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=q,this.setNodeLocationFromNode=q,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ns,this.setNodeLocationFromNode=Ns,this.cstPostRule=q,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=q,this.setNodeLocationFromNode=q,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=q,this.setNodeLocationFromNode=q,this.cstPostRule=q,this.setInitialNodeLocation=q;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){const t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){const t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){const t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?(r.endOffset=t.endOffset,r.endLine=t.endLine,r.endColumn=t.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)}cstPostRuleOnlyOffset(e){const t=this.LA(0),r=e.location;r.startOffset<=t.startOffset?r.endOffset=t.endOffset:r.startOffset=NaN}cstPostTerminal(e,t){const r=this.CST_STACK[this.CST_STACK.length-1];Ah(r,t,e),this.setNodeLocationFromToken(r.location,t)}cstPostNonTerminal(e,t){const r=this.CST_STACK[this.CST_STACK.length-1];vh(r,t,e),this.setNodeLocationFromNode(r.location,e.location)}getBaseCstVisitorConstructor(){if(ze(this.baseCstVisitorConstructor)){const e=Sh(this.className,Mt(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(ze(this.baseCstVisitorWithDefaultsConstructor)){const e=Ih(this.className,Mt(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){const e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}}class _h{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Bn}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Bn:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}}class wh{ACTION(e){return e.call(this)}consume(e,t,r){return this.consumeInternal(t,e,r)}subrule(e,t,r){return this.subruleInternal(t,e,r)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,r=Vn){if(ue(this.definedRulesNames,e)){const a={message:lt.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:le.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);const i=this.defineRule(e,t,r);return this[e]=i,i}OVERRIDE_RULE(e,t,r=Vn){const i=Zf(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);const s=this.defineRule(e,t,r);return this[e]=s,s}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);const r=this.saveRecogState();try{return e.apply(this,t),!0}catch(i){if(Gn(i))return!1;throw i}finally{this.reloadRecogState(r),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Dd(K(this.gastProductionsCache))}}class Lh{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Fn,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},_(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
For Further details.`);if(Z(e)){if(D(e))throw Error(`A Token Vocabulary cannot be empty.
Note that the first argument for the parser constructor
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
For Further details.`)}if(Z(e))this.tokensMap=oe(e,(s,a)=>(s[a.name]=a,s),{});else if(_(e,"modes")&&$e(Ne(K(e.modes)),Cf)){const s=Ne(K(e.modes)),a=vi(s);this.tokensMap=oe(a,(o,c)=>(o[c.name]=c,o),{})}else if(zl(e))this.tokensMap=te(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=tt;const r=_(e,"modes")?Ne(K(e.modes)):K(e),i=$e(r,s=>D(s.categoryMatches));this.tokenMatcher=i?Fn:gn,yn(K(this.tokensMap))}defineRule(e,t,r){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const i=_(r,"resyncEnabled")?r.resyncEnabled:Vn.resyncEnabled,s=_(r,"recoveryValueFunc")?r.recoveryValueFunc:Vn.recoveryValueFunc,a=this.ruleShortNameIdx<<gh+it;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return this.outputCst===!0?o=function(...u){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u);const d=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(d),d}catch(d){return this.invokeRuleCatch(d,i,s)}finally{this.ruleFinallyStateUpdate()}}:o=function(...u){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,u)}catch(d){return this.invokeRuleCatch(d,i,s)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,r){const i=this.RULE_STACK.length===1,s=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Gn(e)){const a=e;if(s){const o=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(o))if(a.resyncedTokens=this.reSyncTo(o),this.outputCst){const c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return r(e);else{if(this.outputCst){const c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,a.partialCstResult=c}throw a}}else{if(i)return this.moveToTerminatedState(),r(e);throw a}}else throw e}optionInternal(e,t){const r=this.getKeyForAutomaticLookahead(Dc,t);return this.optionInternalLogic(e,t,r)}optionInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof e!="function"){s=e.DEF;const a=e.GATE;if(a!==void 0){const o=i;i=()=>a.call(this)&&o.call(this)}}else s=e;if(i.call(this)===!0)return s.call(this)}atLeastOneInternal(e,t){const r=this.getKeyForAutomaticLookahead(jr,e);return this.atLeastOneInternalLogic(e,t,r)}atLeastOneInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;const a=t.GATE;if(a!==void 0){const o=i;i=()=>a.call(this)&&o.call(this)}}else s=t;if(i.call(this)===!0){let a=this.doSingleRepetition(s);for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(s)}else throw this.raiseEarlyExitException(e,B.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,jr,e,Ff)}atLeastOneSepFirstInternal(e,t){const r=this.getKeyForAutomaticLookahead(Ln,e);this.atLeastOneSepFirstInternalLogic(e,t,r)}atLeastOneSepFirstInternalLogic(e,t,r){const i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA(1),s);for(;this.tokenMatcher(this.LA(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,o,i,Ss],o,Ln,e,Ss)}else throw this.raiseEarlyExitException(e,B.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){const r=this.getKeyForAutomaticLookahead(Wr,e);return this.manyInternalLogic(e,t,r)}manyInternalLogic(e,t,r){let i=this.getLaFuncFromCache(r),s;if(typeof t!="function"){s=t.DEF;const o=t.GATE;if(o!==void 0){const c=i;i=()=>o.call(this)&&c.call(this)}}else s=t;let a=!0;for(;i.call(this)===!0&&a===!0;)a=this.doSingleRepetition(s);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,Wr,e,Df,a)}manySepFirstInternal(e,t){const r=this.getKeyForAutomaticLookahead(Hr,e);this.manySepFirstInternalLogic(e,t,r)}manySepFirstInternalLogic(e,t,r){const i=t.DEF,s=t.SEP;if(this.getLaFuncFromCache(r).call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA(1),s);for(;this.tokenMatcher(this.LA(1),s)===!0;)this.CONSUME(s),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,s,o,i,ks],o,Hr,e,ks)}}repetitionSepSecondInternal(e,t,r,i,s){for(;r();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,r,i,s],r,Ln,e,s)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const r=this.getKeyForAutomaticLookahead(Mc,t),i=Z(e)?e:e.DEF,a=this.getLaFuncFromCache(r).call(this,i);if(a!==void 0)return i[a].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){const e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new dh(t,e))}}subruleInternal(e,t,r){let i;try{const s=r!==void 0?r.ARGS:void 0;return this.subruleIdx=t,i=e.apply(this,s),this.cstPostNonTerminal(i,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),i}catch(s){throw this.subruleInternalError(s,r,e.ruleName)}}subruleInternalError(e,t,r){throw Gn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:r),delete e.partialCstResult),e}consumeInternal(e,t,r){let i;try{const s=this.LA(1);this.tokenMatcher(s,e)===!0?(this.consumeToken(),i=s):this.consumeInternalError(e,s,r)}catch(s){i=this.consumeInternalRecovery(e,t,s)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,i),i}consumeInternalError(e,t,r){let i;const s=this.LA(0);throw r!==void 0&&r.ERR_MSG?i=r.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:s,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new bc(i,t,s))}consumeInternalRecovery(e,t,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){const i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(s){throw s.name===Pc?r:s}}else throw r}saveRecogState(){const e=this.errors,t=te(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,r){this.RULE_OCCURRENCE_STACK.push(r),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){const e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),tt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}}class $h{initErrorHandler(e){this._errors=[],this.errorMessageProvider=_(e,"errorMessageProvider")?e.errorMessageProvider:Ye.errorMessageProvider}SAVE_ERROR(e){if(Gn(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:te(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return te(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,r){const i=this.getCurrRuleFullName(),s=this.getGAstProductions()[i],o=pr(e,s,t,this.maxLookahead)[0],c=[];for(let u=1;u<=this.maxLookahead;u++)c.push(this.LA(u));const l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:o,actual:c,previous:this.LA(0),customUserDescription:r,ruleName:i});throw this.SAVE_ERROR(new fh(l,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],s=hr(e,i,this.maxLookahead),a=[];for(let l=1;l<=this.maxLookahead;l++)a.push(this.LA(l));const o=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new uh(c,this.LA(1),o))}}class Oh{initContentAssist(){}computeContentAssist(e,t){const r=this.gastProductionsCache[e];if(ze(r))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return kc([r],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const t=be(e.ruleStack),i=this.getGAstProductions()[t];return new Mf(i,e).startWalking()}}const gr={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(gr);const _s=!0,ws=Math.pow(2,it)-1,Gc=vc({name:"RECORDING_PHASE_TOKEN",pattern:de.NA});yn([Gc]);const Uc=Li(Gc,`This IToken indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Uc);const bh={name:`This CSTNode indicates the Parser is in Recording Phase
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class Ph{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const t=e>0?e:"";this[`CONSUME${t}`]=function(r,i){return this.consumeInternalRecord(r,e,i)},this[`SUBRULE${t}`]=function(r,i){return this.subruleInternalRecord(r,e,i)},this[`OPTION${t}`]=function(r){return this.optionInternalRecord(r,e)},this[`OR${t}`]=function(r){return this.orInternalRecord(r,e)},this[`MANY${t}`]=function(r){this.manyInternalRecord(e,r)},this[`MANY_SEP${t}`]=function(r){this.manySepFirstInternalRecord(e,r)},this[`AT_LEAST_ONE${t}`]=function(r){this.atLeastOneInternalRecord(e,r)},this[`AT_LEAST_ONE_SEP${t}`]=function(r){this.atLeastOneSepFirstInternalRecord(e,r)}}this.consume=function(e,t,r){return this.consumeInternalRecord(t,e,r)},this.subrule=function(e,t,r){return this.subruleInternalRecord(t,e,r)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let t=0;t<10;t++){const r=t>0?t:"";delete e[`CONSUME${r}`],delete e[`SUBRULE${r}`],delete e[`OPTION${r}`],delete e[`OR${r}`],delete e[`MANY${r}`],delete e[`MANY_SEP${r}`],delete e[`AT_LEAST_ONE${r}`],delete e[`AT_LEAST_ONE_SEP${r}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Bn}topLevelRuleRecord(e,t){try{const r=new qt({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),t.call(this),this.recordingProdStack.pop(),r}catch(r){if(r.KNOWN_RECORDER_ERROR!==!0)try{r.message=r.message+`
This error was thrown during the "grammar recording phase" For more info see:
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw r}throw r}}optionInternalRecord(e,t){return rn.call(this,ee,e,t)}atLeastOneInternalRecord(e,t){rn.call(this,Ee,t,e)}atLeastOneSepFirstInternalRecord(e,t){rn.call(this,ke,t,e,_s)}manyInternalRecord(e,t){rn.call(this,W,t,e)}manySepFirstInternalRecord(e,t){rn.call(this,pe,t,e,_s)}orInternalRecord(e,t){return Mh.call(this,e,t)}subruleInternalRecord(e,t,r){if(Un(t),!e||_(e,"ruleName")===!1){const o=new Error(`<SUBRULE${Ls(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}const i=Ft(this.recordingProdStack),s=e.ruleName,a=new ce({idx:t,nonTerminalName:s,label:r==null?void 0:r.LABEL,referencedRule:void 0});return i.definition.push(a),this.outputCst?bh:gr}consumeInternalRecord(e,t,r){if(Un(t),!Rc(e)){const a=new Error(`<CONSUME${Ls(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}const i=Ft(this.recordingProdStack),s=new G({idx:t,terminalType:e,label:r==null?void 0:r.LABEL});return i.definition.push(s),Uc}}function rn(n,e,t,r=!1){Un(t);const i=Ft(this.recordingProdStack),s=mt(e)?e:e.DEF,a=new n({definition:[],idx:t});return r&&(a.separator=e.SEP),_(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),gr}function Mh(n,e){Un(e);const t=Ft(this.recordingProdStack),r=Z(n)===!1,i=r===!1?n:n.DEF,s=new me({definition:[],idx:e,ignoreAmbiguities:r&&n.IGNORE_AMBIGUITIES===!0});_(n,"MAX_LOOKAHEAD")&&(s.maxLookahead=n.MAX_LOOKAHEAD);const a=ho(i,o=>mt(o.GATE));return s.hasPredicates=a,t.definition.push(s),C(i,o=>{const c=new he({definition:[]});s.definition.push(c),_(o,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:_(o,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),o.ALT.call(this),this.recordingProdStack.pop()}),gr}function Ls(n){return n===0?"":`${n}`}function Un(n){if(n<0||n>ws){const e=new Error(`Invalid DSL Method idx value: <${n}>
Idx value must be a none negative value smaller than ${ws+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}class Dh{initPerformanceTracer(e){if(_(e,"traceInitPerf")){const t=e.traceInitPerf,r=typeof t=="number";this.traceInitMaxIdent=r?t:1/0,this.traceInitPerf=r?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Ye.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;const r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${r}--> <${e}>`);const{time:i,value:s}=lc(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${r}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,s}else return t()}}function Fh(n,e){e.forEach(t=>{const r=t.prototype;Object.getOwnPropertyNames(r).forEach(i=>{if(i==="constructor")return;const s=Object.getOwnPropertyDescriptor(r,i);s&&(s.get||s.set)?Object.defineProperty(n.prototype,i,s):n.prototype[i]=t.prototype[i]})})}const Bn=Li(tt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Bn);const Ye=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:At,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Vn=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var le;(function(n){n[n.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",n[n.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",n[n.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",n[n.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",n[n.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",n[n.LEFT_RECURSION=5]="LEFT_RECURSION",n[n.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",n[n.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",n[n.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",n[n.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",n[n.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",n[n.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",n[n.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",n[n.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(le||(le={}));function $s(n=void 0){return function(){return n}}class Tn{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const t=this.className;this.TRACE_INIT("toFastProps",()=>{uc(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),C(this.definedRulesNames,i=>{const a=this[i].originalGrammarAction;let o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,a)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT("Grammar Resolving",()=>{r=ch({rules:K(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT("Grammar Validations",()=>{if(D(r)&&this.skipValidations===!1){const i=lh({rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),errMsgProvider:lt,grammarName:t}),s=zf({lookaheadStrategy:this.lookaheadStrategy,rules:K(this.gastProductionsCache),tokenTypes:K(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(i,s)}}),D(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const i=jd(K(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,s;(s=(i=this.lookaheadStrategy).initialize)===null||s===void 0||s.call(i,{rules:K(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(K(this.gastProductionsCache))})),!Tn.DEFER_DEFINITION_ERRORS_HANDLING&&!D(this.definitionErrors))throw e=S(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
${e.join(`
-------------------------------
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const r=this;if(r.initErrorHandler(t),r.initLexerAdapter(),r.initLooksAhead(t),r.initRecognizerEngine(e,t),r.initRecoverable(t),r.initTreeBuilder(t),r.initContentAssist(),r.initGastRecorder(t),r.initPerformanceTracer(t),_(t,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
For further details.`);this.skipValidations=_(t,"skipValidations")?t.skipValidations:Ye.skipValidations}}Tn.DEFER_DEFINITION_ERRORS_HANDLING=!1;Fh(Tn,[ph,yh,Ch,_h,Lh,wh,$h,Oh,Ph,Dh]);class Gh extends Tn{constructor(e,t=Ye){const r=te(t);r.outputCst=!1,super(e,r)}}function Ut(n,e,t){return`${n.name}_${e}_${t}`}const nt=1,Uh=2,Bc=4,Vc=5,Rn=7,Bh=8,Vh=9,Wh=10,jh=11,Wc=12;class Pi{constructor(e){this.target=e}isEpsilon(){return!1}}class Mi extends Pi{constructor(e,t){super(e),this.tokenType=t}}class jc extends Pi{constructor(e){super(e)}isEpsilon(){return!0}}class Di extends Pi{constructor(e,t,r){super(e),this.rule=t,this.followState=r}isEpsilon(){return!0}}function Hh(n){const e={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};Kh(e,n);const t=n.length;for(let r=0;r<t;r++){const i=n[r],s=yt(e,i,i);s!==void 0&&rp(e,i,s)}return e}function Kh(n,e){const t=e.length;for(let r=0;r<t;r++){const i=e[r],s=Y(n,i,void 0,{type:Uh}),a=Y(n,i,void 0,{type:Rn});s.stop=a,n.ruleToStartState.set(i,s),n.ruleToStopState.set(i,a)}}function Hc(n,e,t){return t instanceof G?Fi(n,e,t.terminalType,t):t instanceof ce?np(n,e,t):t instanceof me?Jh(n,e,t):t instanceof ee?Qh(n,e,t):t instanceof W?zh(n,e,t):t instanceof pe?qh(n,e,t):t instanceof Ee?Yh(n,e,t):t instanceof ke?Xh(n,e,t):yt(n,e,t)}function zh(n,e,t){const r=Y(n,e,t,{type:Vc});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return zc(n,e,t,i)}function qh(n,e,t){const r=Y(n,e,t,{type:Vc});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t)),s=Fi(n,e,t.separator,t);return zc(n,e,t,i,s)}function Yh(n,e,t){const r=Y(n,e,t,{type:Bc});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return Kc(n,e,t,i)}function Xh(n,e,t){const r=Y(n,e,t,{type:Bc});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t)),s=Fi(n,e,t.separator,t);return Kc(n,e,t,i,s)}function Jh(n,e,t){const r=Y(n,e,t,{type:nt});st(n,r);const i=S(t.definition,a=>Hc(n,e,a));return Xt(n,e,r,t,...i)}function Qh(n,e,t){const r=Y(n,e,t,{type:nt});st(n,r);const i=Xt(n,e,r,t,yt(n,e,t));return Zh(n,e,t,i)}function yt(n,e,t){const r=ve(S(t.definition,i=>Hc(n,e,i)),i=>i!==void 0);return r.length===1?r[0]:r.length===0?void 0:tp(n,r)}function Kc(n,e,t,r,i){const s=r.left,a=r.right,o=Y(n,e,t,{type:jh});st(n,o);const c=Y(n,e,t,{type:Wc});return s.loopback=o,c.loopback=o,n.decisionMap[Ut(e,i?"RepetitionMandatoryWithSeparator":"RepetitionMandatory",t.idx)]=o,H(a,o),i===void 0?(H(o,s),H(o,c)):(H(o,c),H(o,i.left),H(i.right,s)),{left:s,right:c}}function zc(n,e,t,r,i){const s=r.left,a=r.right,o=Y(n,e,t,{type:Wh});st(n,o);const c=Y(n,e,t,{type:Wc}),l=Y(n,e,t,{type:Vh});return o.loopback=l,c.loopback=l,H(o,s),H(o,c),H(a,l),i!==void 0?(H(l,c),H(l,i.left),H(i.right,s)):H(l,o),n.decisionMap[Ut(e,i?"RepetitionWithSeparator":"Repetition",t.idx)]=o,{left:o,right:c}}function Zh(n,e,t,r){const i=r.left,s=r.right;return H(i,s),n.decisionMap[Ut(e,"Option",t.idx)]=i,r}function st(n,e){return n.decisionStates.push(e),e.decision=n.decisionStates.length-1,e.decision}function Xt(n,e,t,r,...i){const s=Y(n,e,r,{type:Bh,start:t});t.end=s;for(const o of i)o!==void 0?(H(t,o.left),H(o.right,s)):H(t,s);const a={left:t,right:s};return n.decisionMap[Ut(e,ep(r),r.idx)]=t,a}function ep(n){if(n instanceof me)return"Alternation";if(n instanceof ee)return"Option";if(n instanceof W)return"Repetition";if(n instanceof pe)return"RepetitionWithSeparator";if(n instanceof Ee)return"RepetitionMandatory";if(n instanceof ke)return"RepetitionMandatoryWithSeparator";throw new Error("Invalid production type encountered")}function tp(n,e){const t=e.length;for(let s=0;s<t-1;s++){const a=e[s];let o;a.left.transitions.length===1&&(o=a.left.transitions[0]);const c=o instanceof Di,l=o,u=e[s+1].left;a.left.type===nt&&a.right.type===nt&&o!==void 0&&(c&&l.followState===a.right||o.target===a.right)?(c?l.followState=u:o.target=u,ip(n,a.right)):H(a.right,u)}const r=e[0],i=e[t-1];return{left:r.left,right:i.right}}function Fi(n,e,t,r){const i=Y(n,e,r,{type:nt}),s=Y(n,e,r,{type:nt});return Gi(i,new Mi(s,t)),{left:i,right:s}}function np(n,e,t){const r=t.referencedRule,i=n.ruleToStartState.get(r),s=Y(n,e,t,{type:nt}),a=Y(n,e,t,{type:nt}),o=new Di(i,r,a);return Gi(s,o),{left:s,right:a}}function rp(n,e,t){const r=n.ruleToStartState.get(e);H(r,t.left);const i=n.ruleToStopState.get(e);return H(t.right,i),{left:r,right:i}}function H(n,e){const t=new jc(e);Gi(n,t)}function Y(n,e,t,r){const i=Object.assign({atn:n,production:t,epsilonOnlyTransitions:!1,rule:e,transitions:[],nextTokenWithinRule:[],stateNumber:n.states.length},r);return n.states.push(i),i}function Gi(n,e){n.transitions.length===0&&(n.epsilonOnlyTransitions=e.isEpsilon()),n.transitions.push(e)}function ip(n,e){n.states.splice(n.states.indexOf(e),1)}const Wn={};class zr{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){const t=qc(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return S(this.configs,e=>e.alt)}get key(){let e="";for(const t in this.map)e+=t+":";return e}}function qc(n,e=!0){return`${e?`a${n.alt}`:""}s${n.state.stateNumber}:${n.stack.map(t=>t.stateNumber.toString()).join("_")}`}function sp(n,e){const t={};return r=>{const i=r.toString();let s=t[i];return s!==void 0||(s={atnStartState:n,decision:e,states:{}},t[i]=s),s}}class Yc{constructor(){this.predicates=[]}is(e){return e>=this.predicates.length||this.predicates[e]}set(e,t){this.predicates[e]=t}toString(){let e="";const t=this.predicates.length;for(let r=0;r<t;r++)e+=this.predicates[r]===!0?"1":"0";return e}}const Os=new Yc;class ap extends bi{constructor(e){var t;super(),this.logging=(t=e==null?void 0:e.logging)!==null&&t!==void 0?t:r=>console.log(r)}initialize(e){this.atn=Hh(e.rules),this.dfas=op(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){const{prodOccurrence:t,rule:r,hasPredicates:i,dynamicTokensEnabled:s}=e,a=this.dfas,o=this.logging,c=Ut(r,"Alternation",t),u=this.atn.decisionMap[c].decision,d=S(Is({maxLookahead:1,occurrence:t,prodType:"Alternation",rule:r}),f=>S(f,h=>h[0]));if(bs(d,!1)&&!s){const f=oe(d,(h,m,g)=>(C(m,A=>{A&&(h[A.tokenTypeIdx]=g,C(A.categoryMatches,y=>{h[y]=g}))}),h),{});return i?function(h){var m;const g=this.LA(1),A=f[g.tokenTypeIdx];if(h!==void 0&&A!==void 0){const y=(m=h[A])===null||m===void 0?void 0:m.GATE;if(y!==void 0&&y.call(this)===!1)return}return A}:function(){const h=this.LA(1);return f[h.tokenTypeIdx]}}else return i?function(f){const h=new Yc,m=f===void 0?0:f.length;for(let A=0;A<m;A++){const y=f==null?void 0:f[A].GATE;h.set(A,y===void 0||y.call(this))}const g=_r.call(this,a,u,h,o);return typeof g=="number"?g:void 0}:function(){const f=_r.call(this,a,u,Os,o);return typeof f=="number"?f:void 0}}buildLookaheadForOptional(e){const{prodOccurrence:t,rule:r,prodType:i,dynamicTokensEnabled:s}=e,a=this.dfas,o=this.logging,c=Ut(r,i,t),u=this.atn.decisionMap[c].decision,d=S(Is({maxLookahead:1,occurrence:t,prodType:i,rule:r}),f=>S(f,h=>h[0]));if(bs(d)&&d[0][0]&&!s){const f=d[0],h=Ne(f);if(h.length===1&&D(h[0].categoryMatches)){const g=h[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===g}}else{const m=oe(h,(g,A)=>(A!==void 0&&(g[A.tokenTypeIdx]=!0,C(A.categoryMatches,y=>{g[y]=!0})),g),{});return function(){const g=this.LA(1);return m[g.tokenTypeIdx]===!0}}}return function(){const f=_r.call(this,a,u,Os,o);return typeof f=="object"?!1:f===0}}}function bs(n,e=!0){const t=new Set;for(const r of n){const i=new Set;for(const s of r){if(s===void 0){if(e)break;return!1}const a=[s.tokenTypeIdx].concat(s.categoryMatches);for(const o of a)if(t.has(o)){if(!i.has(o))return!1}else t.add(o),i.add(o)}}return!0}function op(n){const e=n.decisionStates.length,t=Array(e);for(let r=0;r<e;r++)t[r]=sp(n.decisionStates[r],r);return t}function _r(n,e,t,r){const i=n[e](t);let s=i.start;if(s===void 0){const o=Tp(i.atnStartState);s=Jc(i,Xc(o)),i.start=s}return cp.apply(this,[i,s,t,r])}function cp(n,e,t,r){let i=e,s=1;const a=[];let o=this.LA(s++);for(;;){let c=pp(i,o);if(c===void 0&&(c=lp.apply(this,[n,i,o,s,t,r])),c===Wn)return hp(a,i,o);if(c.isAcceptState===!0)return c.prediction;i=c,a.push(o),o=this.LA(s++)}}function lp(n,e,t,r,i,s){const a=mp(e.configs,t,i);if(a.size===0)return Ps(n,e,t,Wn),Wn;let o=Xc(a);const c=yp(a,i);if(c!==void 0)o.isAcceptState=!0,o.prediction=c,o.configs.uniqueAlt=c;else if(Ep(a)){const l=ru(a.alts);o.isAcceptState=!0,o.prediction=l,o.configs.uniqueAlt=l,up.apply(this,[n,r,a.alts,s])}return o=Ps(n,e,t,o),o}function up(n,e,t,r){const i=[];for(let l=1;l<=e;l++)i.push(this.LA(l).tokenType);const s=n.atnStartState,a=s.rule,o=s.production,c=dp({topLevelRule:a,ambiguityIndices:t,production:o,prefixPath:i});r(c)}function dp(n){const e=S(n.prefixPath,i=>Et(i)).join(", "),t=n.production.idx===0?"":n.production.idx;let r=`Ambiguous Alternatives Detected: <${n.ambiguityIndices.join(", ")}> in <${fp(n.production)}${t}> inside <${n.topLevelRule.name}> Rule,
<${e}> may appears as a prefix path in all these alternatives.
`;return r=r+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,r}function fp(n){if(n instanceof ce)return"SUBRULE";if(n instanceof ee)return"OPTION";if(n instanceof me)return"OR";if(n instanceof Ee)return"AT_LEAST_ONE";if(n instanceof ke)return"AT_LEAST_ONE_SEP";if(n instanceof pe)return"MANY_SEP";if(n instanceof W)return"MANY";if(n instanceof G)return"CONSUME";throw Error("non exhaustive match")}function hp(n,e,t){const r=Re(e.configs.elements,s=>s.state.transitions),i=ku(r.filter(s=>s instanceof Mi).map(s=>s.tokenType),s=>s.tokenTypeIdx);return{actualToken:t,possibleTokenTypes:i,tokenPath:n}}function pp(n,e){return n.edges[e.tokenTypeIdx]}function mp(n,e,t){const r=new zr,i=[];for(const a of n.elements){if(t.is(a.alt)===!1)continue;if(a.state.type===Rn){i.push(a);continue}const o=a.state.transitions.length;for(let c=0;c<o;c++){const l=a.state.transitions[c],u=gp(l,e);u!==void 0&&r.add({state:u,alt:a.alt,stack:a.stack})}}let s;if(i.length===0&&r.size===1&&(s=r),s===void 0){s=new zr;for(const a of r.elements)jn(a,s)}if(i.length>0&&!Ap(s))for(const a of i)s.add(a);return s}function gp(n,e){if(n instanceof Mi&&Ec(e,n.tokenType))return n.target}function yp(n,e){let t;for(const r of n.elements)if(e.is(r.alt)===!0){if(t===void 0)t=r.alt;else if(t!==r.alt)return}return t}function Xc(n){return{configs:n,edges:{},isAcceptState:!1,prediction:-1}}function Ps(n,e,t,r){return r=Jc(n,r),e.edges[t.tokenTypeIdx]=r,r}function Jc(n,e){if(e===Wn)return e;const t=e.configs.key,r=n.states[t];return r!==void 0?r:(e.configs.finalize(),n.states[t]=e,e)}function Tp(n){const e=new zr,t=n.transitions.length;for(let r=0;r<t;r++){const s={state:n.transitions[r].target,alt:r,stack:[]};jn(s,e)}return e}function jn(n,e){const t=n.state;if(t.type===Rn){if(n.stack.length>0){const i=[...n.stack],a={state:i.pop(),alt:n.alt,stack:i};jn(a,e)}else e.add(n);return}t.epsilonOnlyTransitions||e.add(n);const r=t.transitions.length;for(let i=0;i<r;i++){const s=t.transitions[i],a=Rp(n,s);a!==void 0&&jn(a,e)}}function Rp(n,e){if(e instanceof jc)return{state:e.target,alt:n.alt,stack:n.stack};if(e instanceof Di){const t=[...n.stack,e.followState];return{state:e.target,alt:n.alt,stack:t}}}function Ap(n){for(const e of n.elements)if(e.state.type===Rn)return!0;return!1}function vp(n){for(const e of n.elements)if(e.state.type!==Rn)return!1;return!0}function Ep(n){if(vp(n))return!0;const e=kp(n.elements);return Sp(e)&&!Ip(e)}function kp(n){const e=new Map;for(const t of n){const r=qc(t,!1);let i=e.get(r);i===void 0&&(i={},e.set(r,i)),i[t.alt]=!0}return e}function Sp(n){for(const e of Array.from(n.values()))if(Object.keys(e).length>1)return!0;return!1}function Ip(n){for(const e of Array.from(n.values()))if(Object.keys(e).length===1)return!0;return!1}var Ms;(function(n){function e(t){return typeof t=="string"}n.is=e})(Ms||(Ms={}));var qr;(function(n){function e(t){return typeof t=="string"}n.is=e})(qr||(qr={}));var Ds;(function(n){n.MIN_VALUE=-2147483648,n.MAX_VALUE=2147483647;function e(t){return typeof t=="number"&&n.MIN_VALUE<=t&&t<=n.MAX_VALUE}n.is=e})(Ds||(Ds={}));var Hn;(function(n){n.MIN_VALUE=0,n.MAX_VALUE=2147483647;function e(t){return typeof t=="number"&&n.MIN_VALUE<=t&&t<=n.MAX_VALUE}n.is=e})(Hn||(Hn={}));var P;(function(n){function e(r,i){return r===Number.MAX_VALUE&&(r=Hn.MAX_VALUE),i===Number.MAX_VALUE&&(i=Hn.MAX_VALUE),{line:r,character:i}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&p.uinteger(i.line)&&p.uinteger(i.character)}n.is=t})(P||(P={}));var b;(function(n){function e(r,i,s,a){if(p.uinteger(r)&&p.uinteger(i)&&p.uinteger(s)&&p.uinteger(a))return{start:P.create(r,i),end:P.create(s,a)};if(P.is(r)&&P.is(i))return{start:r,end:i};throw new Error(`Range#create called with invalid arguments[${r}, ${i}, ${s}, ${a}]`)}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&P.is(i.start)&&P.is(i.end)}n.is=t})(b||(b={}));var Kn;(function(n){function e(r,i){return{uri:r,range:i}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&b.is(i.range)&&(p.string(i.uri)||p.undefined(i.uri))}n.is=t})(Kn||(Kn={}));var Fs;(function(n){function e(r,i,s,a){return{targetUri:r,targetRange:i,targetSelectionRange:s,originSelectionRange:a}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&b.is(i.targetRange)&&p.string(i.targetUri)&&b.is(i.targetSelectionRange)&&(b.is(i.originSelectionRange)||p.undefined(i.originSelectionRange))}n.is=t})(Fs||(Fs={}));var Yr;(function(n){function e(r,i,s,a){return{red:r,green:i,blue:s,alpha:a}}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&p.numberRange(i.red,0,1)&&p.numberRange(i.green,0,1)&&p.numberRange(i.blue,0,1)&&p.numberRange(i.alpha,0,1)}n.is=t})(Yr||(Yr={}));var Gs;(function(n){function e(r,i){return{range:r,color:i}}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&b.is(i.range)&&Yr.is(i.color)}n.is=t})(Gs||(Gs={}));var Us;(function(n){function e(r,i,s){return{label:r,textEdit:i,additionalTextEdits:s}}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&p.string(i.label)&&(p.undefined(i.textEdit)||Vt.is(i))&&(p.undefined(i.additionalTextEdits)||p.typedArray(i.additionalTextEdits,Vt.is))}n.is=t})(Us||(Us={}));var Bs;(function(n){n.Comment="comment",n.Imports="imports",n.Region="region"})(Bs||(Bs={}));var Vs;(function(n){function e(r,i,s,a,o,c){const l={startLine:r,endLine:i};return p.defined(s)&&(l.startCharacter=s),p.defined(a)&&(l.endCharacter=a),p.defined(o)&&(l.kind=o),p.defined(c)&&(l.collapsedText=c),l}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&p.uinteger(i.startLine)&&p.uinteger(i.startLine)&&(p.undefined(i.startCharacter)||p.uinteger(i.startCharacter))&&(p.undefined(i.endCharacter)||p.uinteger(i.endCharacter))&&(p.undefined(i.kind)||p.string(i.kind))}n.is=t})(Vs||(Vs={}));var Xr;(function(n){function e(r,i){return{location:r,message:i}}n.create=e;function t(r){let i=r;return p.defined(i)&&Kn.is(i.location)&&p.string(i.message)}n.is=t})(Xr||(Xr={}));var Ws;(function(n){n.Error=1,n.Warning=2,n.Information=3,n.Hint=4})(Ws||(Ws={}));var js;(function(n){n.Unnecessary=1,n.Deprecated=2})(js||(js={}));var Hs;(function(n){function e(t){const r=t;return p.objectLiteral(r)&&p.string(r.href)}n.is=e})(Hs||(Hs={}));var zn;(function(n){function e(r,i,s,a,o,c){let l={range:r,message:i};return p.defined(s)&&(l.severity=s),p.defined(a)&&(l.code=a),p.defined(o)&&(l.source=o),p.defined(c)&&(l.relatedInformation=c),l}n.create=e;function t(r){var i;let s=r;return p.defined(s)&&b.is(s.range)&&p.string(s.message)&&(p.number(s.severity)||p.undefined(s.severity))&&(p.integer(s.code)||p.string(s.code)||p.undefined(s.code))&&(p.undefined(s.codeDescription)||p.string((i=s.codeDescription)===null||i===void 0?void 0:i.href))&&(p.string(s.source)||p.undefined(s.source))&&(p.undefined(s.relatedInformation)||p.typedArray(s.relatedInformation,Xr.is))}n.is=t})(zn||(zn={}));var Bt;(function(n){function e(r,i,...s){let a={title:r,command:i};return p.defined(s)&&s.length>0&&(a.arguments=s),a}n.create=e;function t(r){let i=r;return p.defined(i)&&p.string(i.title)&&p.string(i.command)}n.is=t})(Bt||(Bt={}));var Vt;(function(n){function e(s,a){return{range:s,newText:a}}n.replace=e;function t(s,a){return{range:{start:s,end:s},newText:a}}n.insert=t;function r(s){return{range:s,newText:""}}n.del=r;function i(s){const a=s;return p.objectLiteral(a)&&p.string(a.newText)&&b.is(a.range)}n.is=i})(Vt||(Vt={}));var Jr;(function(n){function e(r,i,s){const a={label:r};return i!==void 0&&(a.needsConfirmation=i),s!==void 0&&(a.description=s),a}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&p.string(i.label)&&(p.boolean(i.needsConfirmation)||i.needsConfirmation===void 0)&&(p.string(i.description)||i.description===void 0)}n.is=t})(Jr||(Jr={}));var Wt;(function(n){function e(t){const r=t;return p.string(r)}n.is=e})(Wt||(Wt={}));var Ks;(function(n){function e(s,a,o){return{range:s,newText:a,annotationId:o}}n.replace=e;function t(s,a,o){return{range:{start:s,end:s},newText:a,annotationId:o}}n.insert=t;function r(s,a){return{range:s,newText:"",annotationId:a}}n.del=r;function i(s){const a=s;return Vt.is(a)&&(Jr.is(a.annotationId)||Wt.is(a.annotationId))}n.is=i})(Ks||(Ks={}));var Qr;(function(n){function e(r,i){return{textDocument:r,edits:i}}n.create=e;function t(r){let i=r;return p.defined(i)&&ri.is(i.textDocument)&&Array.isArray(i.edits)}n.is=t})(Qr||(Qr={}));var Zr;(function(n){function e(r,i,s){let a={kind:"create",uri:r};return i!==void 0&&(i.overwrite!==void 0||i.ignoreIfExists!==void 0)&&(a.options=i),s!==void 0&&(a.annotationId=s),a}n.create=e;function t(r){let i=r;return i&&i.kind==="create"&&p.string(i.uri)&&(i.options===void 0||(i.options.overwrite===void 0||p.boolean(i.options.overwrite))&&(i.options.ignoreIfExists===void 0||p.boolean(i.options.ignoreIfExists)))&&(i.annotationId===void 0||Wt.is(i.annotationId))}n.is=t})(Zr||(Zr={}));var ei;(function(n){function e(r,i,s,a){let o={kind:"rename",oldUri:r,newUri:i};return s!==void 0&&(s.overwrite!==void 0||s.ignoreIfExists!==void 0)&&(o.options=s),a!==void 0&&(o.annotationId=a),o}n.create=e;function t(r){let i=r;return i&&i.kind==="rename"&&p.string(i.oldUri)&&p.string(i.newUri)&&(i.options===void 0||(i.options.overwrite===void 0||p.boolean(i.options.overwrite))&&(i.options.ignoreIfExists===void 0||p.boolean(i.options.ignoreIfExists)))&&(i.annotationId===void 0||Wt.is(i.annotationId))}n.is=t})(ei||(ei={}));var ti;(function(n){function e(r,i,s){let a={kind:"delete",uri:r};return i!==void 0&&(i.recursive!==void 0||i.ignoreIfNotExists!==void 0)&&(a.options=i),s!==void 0&&(a.annotationId=s),a}n.create=e;function t(r){let i=r;return i&&i.kind==="delete"&&p.string(i.uri)&&(i.options===void 0||(i.options.recursive===void 0||p.boolean(i.options.recursive))&&(i.options.ignoreIfNotExists===void 0||p.boolean(i.options.ignoreIfNotExists)))&&(i.annotationId===void 0||Wt.is(i.annotationId))}n.is=t})(ti||(ti={}));var ni;(function(n){function e(t){let r=t;return r&&(r.changes!==void 0||r.documentChanges!==void 0)&&(r.documentChanges===void 0||r.documentChanges.every(i=>p.string(i.kind)?Zr.is(i)||ei.is(i)||ti.is(i):Qr.is(i)))}n.is=e})(ni||(ni={}));var zs;(function(n){function e(r){return{uri:r}}n.create=e;function t(r){let i=r;return p.defined(i)&&p.string(i.uri)}n.is=t})(zs||(zs={}));var qs;(function(n){function e(r,i){return{uri:r,version:i}}n.create=e;function t(r){let i=r;return p.defined(i)&&p.string(i.uri)&&p.integer(i.version)}n.is=t})(qs||(qs={}));var ri;(function(n){function e(r,i){return{uri:r,version:i}}n.create=e;function t(r){let i=r;return p.defined(i)&&p.string(i.uri)&&(i.version===null||p.integer(i.version))}n.is=t})(ri||(ri={}));var Ys;(function(n){function e(r,i,s,a){return{uri:r,languageId:i,version:s,text:a}}n.create=e;function t(r){let i=r;return p.defined(i)&&p.string(i.uri)&&p.string(i.languageId)&&p.integer(i.version)&&p.string(i.text)}n.is=t})(Ys||(Ys={}));var ii;(function(n){n.PlainText="plaintext",n.Markdown="markdown";function e(t){const r=t;return r===n.PlainText||r===n.Markdown}n.is=e})(ii||(ii={}));var un;(function(n){function e(t){const r=t;return p.objectLiteral(t)&&ii.is(r.kind)&&p.string(r.value)}n.is=e})(un||(un={}));var Xs;(function(n){n.Text=1,n.Method=2,n.Function=3,n.Constructor=4,n.Field=5,n.Variable=6,n.Class=7,n.Interface=8,n.Module=9,n.Property=10,n.Unit=11,n.Value=12,n.Enum=13,n.Keyword=14,n.Snippet=15,n.Color=16,n.File=17,n.Reference=18,n.Folder=19,n.EnumMember=20,n.Constant=21,n.Struct=22,n.Event=23,n.Operator=24,n.TypeParameter=25})(Xs||(Xs={}));var Js;(function(n){n.PlainText=1,n.Snippet=2})(Js||(Js={}));var Qs;(function(n){n.Deprecated=1})(Qs||(Qs={}));var Zs;(function(n){function e(r,i,s){return{newText:r,insert:i,replace:s}}n.create=e;function t(r){const i=r;return i&&p.string(i.newText)&&b.is(i.insert)&&b.is(i.replace)}n.is=t})(Zs||(Zs={}));var ea;(function(n){n.asIs=1,n.adjustIndentation=2})(ea||(ea={}));var ta;(function(n){function e(t){const r=t;return r&&(p.string(r.detail)||r.detail===void 0)&&(p.string(r.description)||r.description===void 0)}n.is=e})(ta||(ta={}));var na;(function(n){function e(t){return{label:t}}n.create=e})(na||(na={}));var ra;(function(n){function e(t,r){return{items:t||[],isIncomplete:!!r}}n.create=e})(ra||(ra={}));var qn;(function(n){function e(r){return r.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")}n.fromPlainText=e;function t(r){const i=r;return p.string(i)||p.objectLiteral(i)&&p.string(i.language)&&p.string(i.value)}n.is=t})(qn||(qn={}));var ia;(function(n){function e(t){let r=t;return!!r&&p.objectLiteral(r)&&(un.is(r.contents)||qn.is(r.contents)||p.typedArray(r.contents,qn.is))&&(t.range===void 0||b.is(t.range))}n.is=e})(ia||(ia={}));var sa;(function(n){function e(t,r){return r?{label:t,documentation:r}:{label:t}}n.create=e})(sa||(sa={}));var aa;(function(n){function e(t,r,...i){let s={label:t};return p.defined(r)&&(s.documentation=r),p.defined(i)?s.parameters=i:s.parameters=[],s}n.create=e})(aa||(aa={}));var oa;(function(n){n.Text=1,n.Read=2,n.Write=3})(oa||(oa={}));var ca;(function(n){function e(t,r){let i={range:t};return p.number(r)&&(i.kind=r),i}n.create=e})(ca||(ca={}));var la;(function(n){n.File=1,n.Module=2,n.Namespace=3,n.Package=4,n.Class=5,n.Method=6,n.Property=7,n.Field=8,n.Constructor=9,n.Enum=10,n.Interface=11,n.Function=12,n.Variable=13,n.Constant=14,n.String=15,n.Number=16,n.Boolean=17,n.Array=18,n.Object=19,n.Key=20,n.Null=21,n.EnumMember=22,n.Struct=23,n.Event=24,n.Operator=25,n.TypeParameter=26})(la||(la={}));var ua;(function(n){n.Deprecated=1})(ua||(ua={}));var da;(function(n){function e(t,r,i,s,a){let o={name:t,kind:r,location:{uri:s,range:i}};return a&&(o.containerName=a),o}n.create=e})(da||(da={}));var fa;(function(n){function e(t,r,i,s){return s!==void 0?{name:t,kind:r,location:{uri:i,range:s}}:{name:t,kind:r,location:{uri:i}}}n.create=e})(fa||(fa={}));var ha;(function(n){function e(r,i,s,a,o,c){let l={name:r,detail:i,kind:s,range:a,selectionRange:o};return c!==void 0&&(l.children=c),l}n.create=e;function t(r){let i=r;return i&&p.string(i.name)&&p.number(i.kind)&&b.is(i.range)&&b.is(i.selectionRange)&&(i.detail===void 0||p.string(i.detail))&&(i.deprecated===void 0||p.boolean(i.deprecated))&&(i.children===void 0||Array.isArray(i.children))&&(i.tags===void 0||Array.isArray(i.tags))}n.is=t})(ha||(ha={}));var pa;(function(n){n.Empty="",n.QuickFix="quickfix",n.Refactor="refactor",n.RefactorExtract="refactor.extract",n.RefactorInline="refactor.inline",n.RefactorRewrite="refactor.rewrite",n.Source="source",n.SourceOrganizeImports="source.organizeImports",n.SourceFixAll="source.fixAll"})(pa||(pa={}));var Yn;(function(n){n.Invoked=1,n.Automatic=2})(Yn||(Yn={}));var ma;(function(n){function e(r,i,s){let a={diagnostics:r};return i!=null&&(a.only=i),s!=null&&(a.triggerKind=s),a}n.create=e;function t(r){let i=r;return p.defined(i)&&p.typedArray(i.diagnostics,zn.is)&&(i.only===void 0||p.typedArray(i.only,p.string))&&(i.triggerKind===void 0||i.triggerKind===Yn.Invoked||i.triggerKind===Yn.Automatic)}n.is=t})(ma||(ma={}));var ga;(function(n){function e(r,i,s){let a={title:r},o=!0;return typeof i=="string"?(o=!1,a.kind=i):Bt.is(i)?a.command=i:a.edit=i,o&&s!==void 0&&(a.kind=s),a}n.create=e;function t(r){let i=r;return i&&p.string(i.title)&&(i.diagnostics===void 0||p.typedArray(i.diagnostics,zn.is))&&(i.kind===void 0||p.string(i.kind))&&(i.edit!==void 0||i.command!==void 0)&&(i.command===void 0||Bt.is(i.command))&&(i.isPreferred===void 0||p.boolean(i.isPreferred))&&(i.edit===void 0||ni.is(i.edit))}n.is=t})(ga||(ga={}));var ya;(function(n){function e(r,i){let s={range:r};return p.defined(i)&&(s.data=i),s}n.create=e;function t(r){let i=r;return p.defined(i)&&b.is(i.range)&&(p.undefined(i.command)||Bt.is(i.command))}n.is=t})(ya||(ya={}));var Ta;(function(n){function e(r,i){return{tabSize:r,insertSpaces:i}}n.create=e;function t(r){let i=r;return p.defined(i)&&p.uinteger(i.tabSize)&&p.boolean(i.insertSpaces)}n.is=t})(Ta||(Ta={}));var Ra;(function(n){function e(r,i,s){return{range:r,target:i,data:s}}n.create=e;function t(r){let i=r;return p.defined(i)&&b.is(i.range)&&(p.undefined(i.target)||p.string(i.target))}n.is=t})(Ra||(Ra={}));var Aa;(function(n){function e(r,i){return{range:r,parent:i}}n.create=e;function t(r){let i=r;return p.objectLiteral(i)&&b.is(i.range)&&(i.parent===void 0||n.is(i.parent))}n.is=t})(Aa||(Aa={}));var va;(function(n){n.namespace="namespace",n.type="type",n.class="class",n.enum="enum",n.interface="interface",n.struct="struct",n.typeParameter="typeParameter",n.parameter="parameter",n.variable="variable",n.property="property",n.enumMember="enumMember",n.event="event",n.function="function",n.method="method",n.macro="macro",n.keyword="keyword",n.modifier="modifier",n.comment="comment",n.string="string",n.number="number",n.regexp="regexp",n.operator="operator",n.decorator="decorator"})(va||(va={}));var Ea;(function(n){n.declaration="declaration",n.definition="definition",n.readonly="readonly",n.static="static",n.deprecated="deprecated",n.abstract="abstract",n.async="async",n.modification="modification",n.documentation="documentation",n.defaultLibrary="defaultLibrary"})(Ea||(Ea={}));var ka;(function(n){function e(t){const r=t;return p.objectLiteral(r)&&(r.resultId===void 0||typeof r.resultId=="string")&&Array.isArray(r.data)&&(r.data.length===0||typeof r.data[0]=="number")}n.is=e})(ka||(ka={}));var Sa;(function(n){function e(r,i){return{range:r,text:i}}n.create=e;function t(r){const i=r;return i!=null&&b.is(i.range)&&p.string(i.text)}n.is=t})(Sa||(Sa={}));var Ia;(function(n){function e(r,i,s){return{range:r,variableName:i,caseSensitiveLookup:s}}n.create=e;function t(r){const i=r;return i!=null&&b.is(i.range)&&p.boolean(i.caseSensitiveLookup)&&(p.string(i.variableName)||i.variableName===void 0)}n.is=t})(Ia||(Ia={}));var xa;(function(n){function e(r,i){return{range:r,expression:i}}n.create=e;function t(r){const i=r;return i!=null&&b.is(i.range)&&(p.string(i.expression)||i.expression===void 0)}n.is=t})(xa||(xa={}));var Na;(function(n){function e(r,i){return{frameId:r,stoppedLocation:i}}n.create=e;function t(r){const i=r;return p.defined(i)&&b.is(r.stoppedLocation)}n.is=t})(Na||(Na={}));var si;(function(n){n.Type=1,n.Parameter=2;function e(t){return t===1||t===2}n.is=e})(si||(si={}));var ai;(function(n){function e(r){return{value:r}}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&(i.tooltip===void 0||p.string(i.tooltip)||un.is(i.tooltip))&&(i.location===void 0||Kn.is(i.location))&&(i.command===void 0||Bt.is(i.command))}n.is=t})(ai||(ai={}));var Ca;(function(n){function e(r,i,s){const a={position:r,label:i};return s!==void 0&&(a.kind=s),a}n.create=e;function t(r){const i=r;return p.objectLiteral(i)&&P.is(i.position)&&(p.string(i.label)||p.typedArray(i.label,ai.is))&&(i.kind===void 0||si.is(i.kind))&&i.textEdits===void 0||p.typedArray(i.textEdits,Vt.is)&&(i.tooltip===void 0||p.string(i.tooltip)||un.is(i.tooltip))&&(i.paddingLeft===void 0||p.boolean(i.paddingLeft))&&(i.paddingRight===void 0||p.boolean(i.paddingRight))}n.is=t})(Ca||(Ca={}));var _a;(function(n){function e(t){return{kind:"snippet",value:t}}n.createSnippet=e})(_a||(_a={}));var wa;(function(n){function e(t,r,i,s){return{insertText:t,filterText:r,range:i,command:s}}n.create=e})(wa||(wa={}));var La;(function(n){function e(t){return{items:t}}n.create=e})(La||(La={}));var $a;(function(n){n.Invoked=0,n.Automatic=1})($a||($a={}));var Oa;(function(n){function e(t,r){return{range:t,text:r}}n.create=e})(Oa||(Oa={}));var ba;(function(n){function e(t,r){return{triggerKind:t,selectedCompletionInfo:r}}n.create=e})(ba||(ba={}));var Pa;(function(n){function e(t){const r=t;return p.objectLiteral(r)&&qr.is(r.uri)&&p.string(r.name)}n.is=e})(Pa||(Pa={}));var Ma;(function(n){function e(s,a,o,c){return new xp(s,a,o,c)}n.create=e;function t(s){let a=s;return!!(p.defined(a)&&p.string(a.uri)&&(p.undefined(a.languageId)||p.string(a.languageId))&&p.uinteger(a.lineCount)&&p.func(a.getText)&&p.func(a.positionAt)&&p.func(a.offsetAt))}n.is=t;function r(s,a){let o=s.getText(),c=i(a,(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),l=o.length;for(let u=c.length-1;u>=0;u--){let d=c[u],f=s.offsetAt(d.range.start),h=s.offsetAt(d.range.end);if(h<=l)o=o.substring(0,f)+d.newText+o.substring(h,o.length);else throw new Error("Overlapping edit");l=f}return o}n.applyEdits=r;function i(s,a){if(s.length<=1)return s;const o=s.length/2|0,c=s.slice(0,o),l=s.slice(o);i(c,a),i(l,a);let u=0,d=0,f=0;for(;u<c.length&&d<l.length;)a(c[u],l[d])<=0?s[f++]=c[u++]:s[f++]=l[d++];for(;u<c.length;)s[f++]=c[u++];for(;d<l.length;)s[f++]=l[d++];return s}})(Ma||(Ma={}));let xp=class{constructor(e,t,r,i){this._uri=e,this._languageId=t,this._version=r,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),r=this.offsetAt(e.end);return this._content.substring(t,r)}return this._content}update(e,t){this._content=e.text,this._version=t,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let e=[],t=this._content,r=!0;for(let i=0;i<t.length;i++){r&&(e.push(i),r=!1);let s=t.charAt(i);r=s==="\r"||s===`
`,s==="\r"&&i+1<t.length&&t.charAt(i+1)===`
`&&i++}r&&t.length>0&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),r=0,i=t.length;if(i===0)return P.create(0,e);for(;r<i;){let a=Math.floor((r+i)/2);t[a]>e?i=a:r=a+1}let s=r-1;return P.create(s,e-t[s])}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let r=t[e.line],i=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(r+e.character,i),r)}get lineCount(){return this.getLineOffsets().length}};var p;(function(n){const e=Object.prototype.toString;function t(h){return typeof h<"u"}n.defined=t;function r(h){return typeof h>"u"}n.undefined=r;function i(h){return h===!0||h===!1}n.boolean=i;function s(h){return e.call(h)==="[object String]"}n.string=s;function a(h){return e.call(h)==="[object Number]"}n.number=a;function o(h,m,g){return e.call(h)==="[object Number]"&&m<=h&&h<=g}n.numberRange=o;function c(h){return e.call(h)==="[object Number]"&&-2147483648<=h&&h<=2147483647}n.integer=c;function l(h){return e.call(h)==="[object Number]"&&0<=h&&h<=2147483647}n.uinteger=l;function u(h){return e.call(h)==="[object Function]"}n.func=u;function d(h){return h!==null&&typeof h=="object"}n.objectLiteral=d;function f(h,m){return Array.isArray(h)&&h.every(m)}n.typedArray=f})(p||(p={}));class Np{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]}buildRootNode(e){return this.rootNode=new Zc(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){const t=new Ui;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){const r=new oi(e.startOffset,e.image.length,Mr(e),e.tokenType,!1);return r.grammarSource=t,r.root=this.rootNode,this.current.content.push(r),r}removeNode(e){const t=e.container;if(t){const r=t.content.indexOf(e);r>=0&&t.content.splice(r,1)}}construct(e){const t=this.current;typeof e.$type=="string"&&(this.current.astNode=e),e.$cstNode=t;const r=this.nodeStack.pop();(r==null?void 0:r.content.length)===0&&this.removeNode(r)}addHiddenTokens(e){for(const t of e){const r=new oi(t.startOffset,t.image.length,Mr(t),t.tokenType,!0);r.root=this.rootNode,this.addHiddenToken(this.rootNode,r)}}addHiddenToken(e,t){const{offset:r,end:i}=t;for(let s=0;s<e.content.length;s++){const a=e.content[s],{offset:o,end:c}=a;if(Gt(a)&&r>o&&i<c){this.addHiddenToken(a,t);return}else if(i<=o){e.content.splice(s,0,t);return}}e.content.push(t)}}class Qc{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){var e,t;const r=typeof((e=this._astNode)===null||e===void 0?void 0:e.$type)=="string"?this._astNode:(t=this.container)===null||t===void 0?void 0:t.astNode;if(!r)throw new Error("This node has no associated AST element");return r}set astNode(e){this._astNode=e}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}}class oi extends Qc{get offset(){return this._offset}get length(){return this._length}get end(){return this._offset+this._length}get hidden(){return this._hidden}get tokenType(){return this._tokenType}get range(){return this._range}constructor(e,t,r,i,s=!1){super(),this._hidden=s,this._offset=e,this._tokenType=i,this._length=t,this._range=r}}class Ui extends Qc{constructor(){super(...arguments),this.content=new Bi(this)}get children(){return this.content}get offset(){var e,t;return(t=(e=this.firstNonHiddenNode)===null||e===void 0?void 0:e.offset)!==null&&t!==void 0?t:0}get length(){return this.end-this.offset}get end(){var e,t;return(t=(e=this.lastNonHiddenNode)===null||e===void 0?void 0:e.end)!==null&&t!==void 0?t:0}get range(){const e=this.firstNonHiddenNode,t=this.lastNonHiddenNode;if(e&&t){if(this._rangeCache===void 0){const{range:r}=e,{range:i}=t;this._rangeCache={start:r.start,end:i.end.line<r.start.line?r.start:i.end}}return this._rangeCache}else return{start:P.create(0,0),end:P.create(0,0)}}get firstNonHiddenNode(){for(const e of this.content)if(!e.hidden)return e;return this.content[0]}get lastNonHiddenNode(){for(let e=this.content.length-1;e>=0;e--){const t=this.content[e];if(!t.hidden)return t}return this.content[this.content.length-1]}}class Bi extends Array{constructor(e){super(),this.parent=e,Object.setPrototypeOf(this,Bi.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,t,...r){return this.addParents(r),super.splice(e,t,...r)}addParents(e){for(const t of e)t.container=this.parent}}class Zc extends Ui{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text="",this._text=e??""}}const ci=Symbol("Datatype");function wr(n){return n.$type===ci}const Da="",el=n=>n.endsWith(Da)?n:n+Da;class tl{constructor(e){this._unorderedGroups=new Map,this.lexer=e.parser.Lexer;const t=this.lexer.definition;this.wrapper=new $p(t,Object.assign(Object.assign({},e.parser.ParserConfig),{errorMessageProvider:e.parser.ParserErrorMessageProvider}))}alternatives(e,t){this.wrapper.wrapOr(e,t)}optional(e,t){this.wrapper.wrapOption(e,t)}many(e,t){this.wrapper.wrapMany(e,t)}atLeastOne(e,t){this.wrapper.wrapAtLeastOne(e,t)}isRecording(){return this.wrapper.IS_RECORDING}get unorderedGroups(){return this._unorderedGroups}getRuleStack(){return this.wrapper.RULE_STACK}finalize(){this.wrapper.wrapSelfAnalysis()}}class Cp extends tl{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new Np,this.stack=[],this.assignmentMap=new Map,this.linker=e.references.Linker,this.converter=e.parser.ValueConverter,this.astReflection=e.shared.AstReflection}rule(e,t){const r=e.fragment?void 0:Ni(e)?ci:lr(e),i=this.wrapper.DEFINE_RULE(el(e.name),this.startImplementation(r,t).bind(this));return e.entry&&(this.mainRule=i),i}parse(e){this.nodeBuilder.buildRootNode(e);const t=this.lexer.tokenize(e);this.wrapper.input=t.tokens;const r=this.mainRule.call(this.wrapper,{});return this.nodeBuilder.addHiddenTokens(t.hidden),this.unorderedGroups.clear(),{value:r,lexerErrors:t.errors,parserErrors:this.wrapper.errors}}startImplementation(e,t){return r=>{if(!this.isRecording()){const s={$type:e};this.stack.push(s),e===ci&&(s.value="")}let i;try{i=t(r)}catch{i=void 0}return!this.isRecording()&&i===void 0&&(i=this.construct()),i}}consume(e,t,r){const i=this.wrapper.wrapConsume(e,t);if(!this.isRecording()&&this.isValidToken(i)){const s=this.nodeBuilder.buildLeafNode(i,r),{assignment:a,isCrossRef:o}=this.getAssignment(r),c=this.current;if(a){const l=dt(r)?i.image:this.converter.convert(i.image,s);this.assign(a.operator,a.feature,l,s,o)}else if(wr(c)){let l=i.image;dt(r)||(l=this.converter.convert(l,s).toString()),c.value+=l}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&typeof e.endOffset=="number"&&!isNaN(e.endOffset)}subrule(e,t,r,i){let s;this.isRecording()||(s=this.nodeBuilder.buildCompositeNode(r));const a=this.wrapper.wrapSubrule(e,t,i);!this.isRecording()&&s&&s.length>0&&this.performSubruleAssignment(a,r,s)}performSubruleAssignment(e,t,r){const{assignment:i,isCrossRef:s}=this.getAssignment(t);if(i)this.assign(i.operator,i.feature,e,r,s);else if(!i){const a=this.current;if(wr(a))a.value+=e.toString();else if(typeof e=="object"&&e){const o=e.$type,c=this.assignWithoutOverride(e,a);o&&(c.$type=o);const l=c;this.stack.pop(),this.stack.push(l)}}}action(e,t){if(!this.isRecording()){let r=this.current;if(!r.$cstNode&&t.feature&&t.operator){r=this.construct(!1);const s=r.$cstNode.feature;this.nodeBuilder.buildCompositeNode(s)}const i={$type:e};this.stack.pop(),this.stack.push(i),t.feature&&t.operator&&this.assign(t.operator,t.feature,r,r.$cstNode,!1)}}construct(e=!0){if(this.isRecording())return;const t=this.current;return ad(t),this.nodeBuilder.construct(t),e&&this.stack.pop(),wr(t)?this.converter.convert(t.value,t.$cstNode):(cd(this.astReflection,t),t)}getAssignment(e){if(!this.assignmentMap.has(e)){const t=ar(e,ut);this.assignmentMap.set(e,{assignment:t,isCrossRef:t?ki(t.terminal):!1})}return this.assignmentMap.get(e)}assign(e,t,r,i,s){const a=this.current;let o;switch(s&&typeof r=="string"?o=this.linker.buildReference(a,t,i,r):o=r,e){case"=":{a[t]=o;break}case"?=":{a[t]=!0;break}case"+=":Array.isArray(a[t])||(a[t]=[]),a[t].push(o)}}assignWithoutOverride(e,t){for(const[r,i]of Object.entries(t)){const s=e[r];s===void 0?e[r]=i:Array.isArray(s)&&Array.isArray(i)&&(i.push(...s),e[r]=i)}return e}get definitionErrors(){return this.wrapper.definitionErrors}}class _p{buildMismatchTokenMessage(e){return At.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return At.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return At.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return At.buildEarlyExitMessage(e)}}class nl extends _p{buildMismatchTokenMessage({expected:e,actual:t}){return`Expecting ${e.LABEL?"`"+e.LABEL+"`":e.name.endsWith(":KW")?`keyword '${e.name.substring(0,e.name.length-3)}'`:`token of type '${e.name}'`} but found \`${t.image}\`.`}buildNotAllInputParsedMessage({firstRedundant:e}){return`Expecting end of file but found \`${e.image}\`.`}}class wp extends tl{constructor(){super(...arguments),this.tokens=[],this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}action(){}construct(){}parse(e){this.resetState();const t=this.lexer.tokenize(e);return this.tokens=t.tokens,this.wrapper.input=[...this.tokens],this.mainRule.call(this.wrapper,{}),this.unorderedGroups.clear(),{tokens:this.tokens,elementStack:[...this.lastElementStack],tokenIndex:this.nextTokenIndex}}rule(e,t){const r=this.wrapper.DEFINE_RULE(el(e.name),this.startImplementation(t).bind(this));return e.entry&&(this.mainRule=r),r}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(e){return t=>{const r=this.keepStackSize();try{e(t)}finally{this.resetStackSize(r)}}}removeUnexpectedElements(){this.elementStack.splice(this.stackSize)}keepStackSize(){const e=this.elementStack.length;return this.stackSize=e,e}resetStackSize(e){this.removeUnexpectedElements(),this.stackSize=e}consume(e,t,r){this.wrapper.wrapConsume(e,t),this.isRecording()||(this.lastElementStack=[...this.elementStack,r],this.nextTokenIndex=this.currIdx+1)}subrule(e,t,r,i){this.before(r),this.wrapper.wrapSubrule(e,t,i),this.after(r)}before(e){this.isRecording()||this.elementStack.push(e)}after(e){if(!this.isRecording()){const t=this.elementStack.lastIndexOf(e);t>=0&&this.elementStack.splice(t)}}get currIdx(){return this.wrapper.currIdx}}const Lp={recoveryEnabled:!0,nodeLocationTracking:"full",skipValidations:!0,errorMessageProvider:new nl};class $p extends Gh{constructor(e,t){const r=t&&"maxLookahead"in t;super(e,Object.assign(Object.assign(Object.assign({},Lp),{lookaheadStrategy:r?new bi({maxLookahead:t.maxLookahead}):new ap}),t))}get IS_RECORDING(){return this.RECORDING_PHASE}DEFINE_RULE(e,t){return this.RULE(e,t)}wrapSelfAnalysis(){this.performSelfAnalysis()}wrapConsume(e,t){return this.consume(e,t)}wrapSubrule(e,t,r){return this.subrule(e,t,{ARGS:[r]})}wrapOr(e,t){this.or(e,t)}wrapOption(e,t){this.option(e,t)}wrapMany(e,t){this.many(e,t)}wrapAtLeastOne(e,t){this.atLeastOne(e,t)}}function rl(n,e,t){return Op({parser:e,tokens:t,rules:new Map,ruleNames:new Map},n),e}function Op(n,e){const t=tc(e,!1),r=Q(e.rules).filter(Ce).filter(i=>t.has(i));for(const i of r){const s=Object.assign(Object.assign({},n),{consume:1,optional:1,subrule:1,many:1,or:1});s.rules.set(i.name,n.parser.rule(i,pt(s,i.definition)))}}function pt(n,e,t=!1){let r;if(dt(e))r=Up(n,e);else if(sr(e))r=bp(n,e);else if(ut(e))r=pt(n,e.terminal);else if(ki(e))r=il(n,e);else if(ft(e))r=Pp(n,e);else if(bo(e))r=Dp(n,e);else if(qo(e))r=Fp(n,e);else if(Si(e))r=Gp(n,e);else if(Qu(e)){const i=n.consume++;r=()=>n.parser.consume(i,tt,e)}else throw new yo(e.$cstNode,`Unexpected element type: ${e.$type}`);return sl(n,t?void 0:Xn(e),r,e.cardinality)}function bp(n,e){const t=lr(e);return()=>n.parser.action(t,e)}function Pp(n,e){const t=e.rule.ref;if(Ce(t)){const r=n.subrule++,i=e.arguments.length>0?Mp(t,e.arguments):()=>({});return s=>n.parser.subrule(r,al(n,t),e,i(s))}else if(gt(t)){const r=n.consume++,i=li(n,t.name);return()=>n.parser.consume(r,i,e)}else if(t)ir();else throw new yo(e.$cstNode,`Undefined rule type: ${e.$type}`)}function Mp(n,e){const t=e.map(r=>He(r.value));return r=>{const i={};for(let s=0;s<t.length;s++){const a=n.parameters[s],o=t[s];i[a.name]=o(r)}return i}}function He(n){if(Gu(n)){const e=He(n.left),t=He(n.right);return r=>e(r)||t(r)}else if(Fu(n)){const e=He(n.left),t=He(n.right);return r=>e(r)&&t(r)}else if(Bu(n)){const e=He(n.value);return t=>!e(t)}else if(ju(n)){const e=n.parameter.ref.name;return t=>t!==void 0&&t[e]===!0}else if(Du(n)){const e=!!n.true;return()=>e}ir()}function Dp(n,e){if(e.elements.length===1)return pt(n,e.elements[0]);{const t=[];for(const i of e.elements){const s={ALT:pt(n,i,!0)},a=Xn(i);a&&(s.GATE=He(a)),t.push(s)}const r=n.or++;return i=>n.parser.alternatives(r,t.map(s=>{const a={ALT:()=>s.ALT(i)},o=s.GATE;return o&&(a.GATE=()=>o(i)),a}))}}function Fp(n,e){if(e.elements.length===1)return pt(n,e.elements[0]);const t=[];for(const o of e.elements){const c={ALT:pt(n,o,!0)},l=Xn(o);l&&(c.GATE=He(l)),t.push(c)}const r=n.or++,i=(o,c)=>{const l=c.getRuleStack().join("-");return`uGroup_${o}_${l}`},s=o=>n.parser.alternatives(r,t.map((c,l)=>{const u={ALT:()=>!0},d=n.parser;u.ALT=()=>{if(c.ALT(o),!d.isRecording()){const h=i(r,d);d.unorderedGroups.get(h)||d.unorderedGroups.set(h,[]);const m=d.unorderedGroups.get(h);typeof(m==null?void 0:m[l])>"u"&&(m[l]=!0)}};const f=c.GATE;return f?u.GATE=()=>f(o):u.GATE=()=>{const h=d.unorderedGroups.get(i(r,d));return!(h!=null&&h[l])},u})),a=sl(n,Xn(e),s,"*");return o=>{a(o),n.parser.isRecording()||n.parser.unorderedGroups.delete(i(r,n.parser))}}function Gp(n,e){const t=e.elements.map(r=>pt(n,r));return r=>t.forEach(i=>i(r))}function Xn(n){if(Si(n))return n.guardCondition}function il(n,e,t=e.terminal){if(t)if(ft(t)&&Ce(t.rule.ref)){const r=n.subrule++;return i=>n.parser.subrule(r,al(n,t.rule.ref),e,i)}else if(ft(t)&&gt(t.rule.ref)){const r=n.consume++,i=li(n,t.rule.ref.name);return()=>n.parser.consume(r,i,e)}else if(dt(t)){const r=n.consume++,i=li(n,t.value);return()=>n.parser.consume(r,i,e)}else throw new Error("Could not build cross reference parser");else{if(!e.type.ref)throw new Error("Could not resolve reference to type: "+e.type.$refText);const r=ic(e.type.ref),i=r==null?void 0:r.terminal;if(!i)throw new Error("Could not find name assignment for type: "+lr(e.type.ref));return il(n,e,i)}}function Up(n,e){const t=n.consume++,r=n.tokens[e.value];if(!r)throw new Error("Could not find token for keyword: "+e.value);return()=>n.parser.consume(t,r,e)}function sl(n,e,t,r){const i=e&&He(e);if(!r)if(i){const s=n.or++;return a=>n.parser.alternatives(s,[{ALT:()=>t(a),GATE:()=>i(a)},{ALT:$s(),GATE:()=>!i(a)}])}else return t;if(r==="*"){const s=n.many++;return a=>n.parser.many(s,{DEF:()=>t(a),GATE:i?()=>i(a):void 0})}else if(r==="+"){const s=n.many++;if(i){const a=n.or++;return o=>n.parser.alternatives(a,[{ALT:()=>n.parser.atLeastOne(s,{DEF:()=>t(o)}),GATE:()=>i(o)},{ALT:$s(),GATE:()=>!i(o)}])}else return a=>n.parser.atLeastOne(s,{DEF:()=>t(a)})}else if(r==="?"){const s=n.optional++;return a=>n.parser.optional(s,{DEF:()=>t(a),GATE:i?()=>i(a):void 0})}else ir()}function al(n,e){const t=Bp(n,e),r=n.rules.get(t);if(!r)throw new Error(`Rule "${t}" not found."`);return r}function Bp(n,e){if(Ce(e))return e.name;if(n.ruleNames.has(e))return n.ruleNames.get(e);{let t=e,r=t.$container,i=e.$type;for(;!Ce(r);)(Si(r)||bo(r)||qo(r))&&(i=r.elements.indexOf(t).toString()+":"+i),t=r,r=r.$container;return i=r.name+":"+i,n.ruleNames.set(e,i),i}}function li(n,e){const t=n.tokens[e];if(!t)throw new Error(`Token "${e}" not found."`);return t}function Vp(n){const e=n.Grammar,t=n.parser.Lexer,r=new wp(n);return rl(e,r,t.definition),r.finalize(),r}function Wp(n){const e=jp(n);return e.finalize(),e}function jp(n){const e=n.Grammar,t=n.parser.Lexer,r=new Cp(n);return rl(e,r,t.definition)}class ol{buildTokens(e,t){const r=Q(tc(e,!1)),i=this.buildTerminalTokens(r),s=this.buildKeywordTokens(r,i,t);return i.forEach(a=>{const o=a.PATTERN;typeof o=="object"&&o&&"test"in o&&cs(o)?s.unshift(a):s.push(a)}),s}buildTerminalTokens(e){return e.filter(gt).filter(t=>!t.fragment).map(t=>this.buildTerminalToken(t)).toArray()}buildTerminalToken(e){const t=Ci(e),r=this.requiresCustomPattern(t)?this.regexPatternFunction(t):t,i={name:e.name,PATTERN:r,LINE_BREAKS:!0};return e.hidden&&(i.GROUP=cs(t)?de.SKIPPED:"hidden"),i}requiresCustomPattern(e){return e.flags.includes("u")?!0:!!(e.source.includes("?<=")||e.source.includes("?<!"))}regexPatternFunction(e){const t=new RegExp(e,e.flags+"y");return(r,i)=>(t.lastIndex=i,t.exec(r))}buildKeywordTokens(e,t,r){return e.filter(Ce).flatMap(i=>pn(i).filter(dt)).distinct(i=>i.value).toArray().sort((i,s)=>s.value.length-i.value.length).map(i=>this.buildKeywordToken(i,t,!!(r!=null&&r.caseInsensitive)))}buildKeywordToken(e,t,r){return{name:e.value,PATTERN:this.buildKeywordPattern(e,r),LONGER_ALT:this.findLongerAlt(e,t)}}buildKeywordPattern(e,t){return t?new RegExp(gd(e.value)):e.value}findLongerAlt(e,t){return t.reduce((r,i)=>{const s=i==null?void 0:i.PATTERN;return s!=null&&s.source&&yd("^"+s.source+"$",e.value)&&r.push(i),r},[])}}class cl{convert(e,t){let r=t.grammarSource;if(ki(r)&&(r=vd(r)),ft(r)){const i=r.rule.ref;if(!i)throw new Error("This cst node was not parsed by a rule.");return this.runConverter(i,e,t)}return e}runConverter(e,t,r){var i;switch(e.name.toUpperCase()){case"INT":return je.convertInt(t);case"STRING":return je.convertString(t);case"ID":return je.convertID(t)}switch((i=Cd(e))===null||i===void 0?void 0:i.toLowerCase()){case"number":return je.convertNumber(t);case"boolean":return je.convertBoolean(t);case"bigint":return je.convertBigint(t);case"date":return je.convertDate(t);default:return t}}}var je;(function(n){function e(l){let u="";for(let d=1;d<l.length-1;d++){const f=l.charAt(d);if(f==="\\"){const h=l.charAt(++d);u+=t(h)}else u+=f}return u}n.convertString=e;function t(l){switch(l){case"b":return"\b";case"f":return"\f";case"n":return`
`;case"r":return"\r";case"t":return" ";case"v":return"\v";case"0":return"\0";default:return l}}function r(l){return l.charAt(0)==="^"?l.substring(1):l}n.convertID=r;function i(l){return parseInt(l)}n.convertInt=i;function s(l){return BigInt(l)}n.convertBigint=s;function a(l){return new Date(l)}n.convertDate=a;function o(l){return Number(l)}n.convertNumber=o;function c(l){return l.toLowerCase()==="true"}n.convertBoolean=c})(je||(je={}));var dn={},yr={};Object.defineProperty(yr,"__esModule",{value:!0});let ui;function di(){if(ui===void 0)throw new Error("No runtime abstraction layer installed");return ui}(function(n){function e(t){if(t===void 0)throw new Error("No runtime abstraction layer provided");ui=t}n.install=e})(di||(di={}));yr.default=di;var se={};Object.defineProperty(se,"__esModule",{value:!0});se.stringArray=se.array=se.func=se.error=se.number=se.string=se.boolean=void 0;function Hp(n){return n===!0||n===!1}se.boolean=Hp;function ll(n){return typeof n=="string"||n instanceof String}se.string=ll;function Kp(n){return typeof n=="number"||n instanceof Number}se.number=Kp;function zp(n){return n instanceof Error}se.error=zp;function qp(n){return typeof n=="function"}se.func=qp;function ul(n){return Array.isArray(n)}se.array=ul;function Yp(n){return ul(n)&&n.every(e=>ll(e))}se.stringArray=Yp;var jt={};Object.defineProperty(jt,"__esModule",{value:!0});jt.Emitter=jt.Event=void 0;const Xp=yr;var Fa;(function(n){const e={dispose(){}};n.None=function(){return e}})(Fa||(jt.Event=Fa={}));class Jp{add(e,t=null,r){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(e),this._contexts.push(t),Array.isArray(r)&&r.push({dispose:()=>this.remove(e,t)})}remove(e,t=null){if(!this._callbacks)return;let r=!1;for(let i=0,s=this._callbacks.length;i<s;i++)if(this._callbacks[i]===e)if(this._contexts[i]===t){this._callbacks.splice(i,1),this._contexts.splice(i,1);return}else r=!0;if(r)throw new Error("When adding a listener with a context, you should remove it with the same context")}invoke(...e){if(!this._callbacks)return[];const t=[],r=this._callbacks.slice(0),i=this._contexts.slice(0);for(let s=0,a=r.length;s<a;s++)try{t.push(r[s].apply(i[s],e))}catch(o){(0,Xp.default)().console.error(o)}return t}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}}class Tr{constructor(e){this._options=e}get event(){return this._event||(this._event=(e,t,r)=>{this._callbacks||(this._callbacks=new Jp),this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callbacks.add(e,t);const i={dispose:()=>{this._callbacks&&(this._callbacks.remove(e,t),i.dispose=Tr._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty()&&this._options.onLastListenerRemove(this))}};return Array.isArray(r)&&r.push(i),i}),this._event}fire(e){this._callbacks&&this._callbacks.invoke.call(this._callbacks,e)}dispose(){this._callbacks&&(this._callbacks.dispose(),this._callbacks=void 0)}}jt.Emitter=Tr;Tr._noop=function(){};var X;Object.defineProperty(dn,"__esModule",{value:!0});var fi=dn.CancellationTokenSource=X=dn.CancellationToken=void 0;const Qp=yr,Zp=se,hi=jt;var Jn;(function(n){n.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:hi.Event.None}),n.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:hi.Event.None});function e(t){const r=t;return r&&(r===n.None||r===n.Cancelled||Zp.boolean(r.isCancellationRequested)&&!!r.onCancellationRequested)}n.is=e})(Jn||(X=dn.CancellationToken=Jn={}));const em=Object.freeze(function(n,e){const t=(0,Qp.default)().timer.setTimeout(n.bind(e),0);return{dispose(){t.dispose()}}});class Ga{constructor(){this._isCancelled=!1}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?em:(this._emitter||(this._emitter=new hi.Emitter),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=void 0)}}class tm{get token(){return this._token||(this._token=new Ga),this._token}cancel(){this._token?this._token.cancel():this._token=Jn.Cancelled}dispose(){this._token?this._token instanceof Ga&&this._token.dispose():this._token=Jn.None}}fi=dn.CancellationTokenSource=tm;function nm(){return new Promise(n=>{typeof setImmediate>"u"?setTimeout(n,0):setImmediate(n)})}let Ua=0,rm=10;const Qn=Symbol("OperationCancelled");function Vi(n){return n===Qn}async function Oe(n){if(n===X.None)return;const e=Date.now();if(e-Ua>=rm&&(Ua=e,await nm()),n.isCancellationRequested)throw Qn}class Wi{constructor(){this.promise=new Promise((e,t)=>{this.resolve=r=>(e(r),this),this.reject=r=>(t(r),this)})}}class fn{constructor(e,t,r,i){this._uri=e,this._languageId=t,this._version=r,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){const t=this.offsetAt(e.start),r=this.offsetAt(e.end);return this._content.substring(t,r)}return this._content}update(e,t){for(const r of e)if(fn.isIncremental(r)){const i=fl(r.range),s=this.offsetAt(i.start),a=this.offsetAt(i.end);this._content=this._content.substring(0,s)+r.text+this._content.substring(a,this._content.length);const o=Math.max(i.start.line,0),c=Math.max(i.end.line,0);let l=this._lineOffsets;const u=Ba(r.text,!1,s);if(c-o===u.length)for(let f=0,h=u.length;f<h;f++)l[f+o+1]=u[f];else u.length<1e4?l.splice(o+1,c-o,...u):this._lineOffsets=l=l.slice(0,o+1).concat(u,l.slice(c+1));const d=r.text.length-(a-s);if(d!==0)for(let f=o+1+u.length,h=l.length;f<h;f++)l[f]=l[f]+d}else if(fn.isFull(r))this._content=r.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=t}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Ba(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);const t=this.getLineOffsets();let r=0,i=t.length;if(i===0)return{line:0,character:e};for(;r<i;){const a=Math.floor((r+i)/2);t[a]>e?i=a:r=a+1}const s=r-1;return e=this.ensureBeforeEOL(e,t[s]),{line:s,character:e-t[s]}}offsetAt(e){const t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;const r=t[e.line];if(e.character<=0)return r;const i=e.line+1<t.length?t[e.line+1]:this._content.length,s=Math.min(r+e.character,i);return this.ensureBeforeEOL(s,r)}ensureBeforeEOL(e,t){for(;e>t&&dl(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){const t=e;return t!=null&&typeof t.text=="string"&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength=="number")}static isFull(e){const t=e;return t!=null&&typeof t.text=="string"&&t.range===void 0&&t.rangeLength===void 0}}var pi;(function(n){function e(i,s,a,o){return new fn(i,s,a,o)}n.create=e;function t(i,s,a){if(i instanceof fn)return i.update(s,a),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}n.update=t;function r(i,s){const a=i.getText(),o=mi(s.map(im),(u,d)=>{const f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f});let c=0;const l=[];for(const u of o){const d=i.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(a.substring(c,d)),u.newText.length&&l.push(u.newText),c=i.offsetAt(u.range.end)}return l.push(a.substr(c)),l.join("")}n.applyEdits=r})(pi||(pi={}));function mi(n,e){if(n.length<=1)return n;const t=n.length/2|0,r=n.slice(0,t),i=n.slice(t);mi(r,e),mi(i,e);let s=0,a=0,o=0;for(;s<r.length&&a<i.length;)e(r[s],i[a])<=0?n[o++]=r[s++]:n[o++]=i[a++];for(;s<r.length;)n[o++]=r[s++];for(;a<i.length;)n[o++]=i[a++];return n}function Ba(n,e,t=0){const r=e?[t]:[];for(let i=0;i<n.length;i++){const s=n.charCodeAt(i);dl(s)&&(s===13&&i+1<n.length&&n.charCodeAt(i+1)===10&&i++,r.push(t+i+1))}return r}function dl(n){return n===13||n===10}function fl(n){const e=n.start,t=n.end;return e.line>t.line||e.line===t.line&&e.character>t.character?{start:t,end:e}:n}function im(n){const e=fl(n.range);return e!==n.range?{newText:n.newText,range:e}:n}var hl;(()=>{var n={470:i=>{function s(c){if(typeof c!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(c))}function a(c,l){for(var u,d="",f=0,h=-1,m=0,g=0;g<=c.length;++g){if(g<c.length)u=c.charCodeAt(g);else{if(u===47)break;u=47}if(u===47){if(!(h===g-1||m===1))if(h!==g-1&&m===2){if(d.length<2||f!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){var A=d.lastIndexOf("/");if(A!==d.length-1){A===-1?(d="",f=0):f=(d=d.slice(0,A)).length-1-d.lastIndexOf("/"),h=g,m=0;continue}}else if(d.length===2||d.length===1){d="",f=0,h=g,m=0;continue}}l&&(d.length>0?d+="/..":d="..",f=2)}else d.length>0?d+="/"+c.slice(h+1,g):d=c.slice(h+1,g),f=g-h-1;h=g,m=0}else u===46&&m!==-1?++m:m=-1}return d}var o={resolve:function(){for(var c,l="",u=!1,d=arguments.length-1;d>=-1&&!u;d--){var f;d>=0?f=arguments[d]:(c===void 0&&(c=process.cwd()),f=c),s(f),f.length!==0&&(l=f+"/"+l,u=f.charCodeAt(0)===47)}return l=a(l,!u),u?l.length>0?"/"+l:"/":l.length>0?l:"."},normalize:function(c){if(s(c),c.length===0)return".";var l=c.charCodeAt(0)===47,u=c.charCodeAt(c.length-1)===47;return(c=a(c,!l)).length!==0||l||(c="."),c.length>0&&u&&(c+="/"),l?"/"+c:c},isAbsolute:function(c){return s(c),c.length>0&&c.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var c,l=0;l<arguments.length;++l){var u=arguments[l];s(u),u.length>0&&(c===void 0?c=u:c+="/"+u)}return c===void 0?".":o.normalize(c)},relative:function(c,l){if(s(c),s(l),c===l||(c=o.resolve(c))===(l=o.resolve(l)))return"";for(var u=1;u<c.length&&c.charCodeAt(u)===47;++u);for(var d=c.length,f=d-u,h=1;h<l.length&&l.charCodeAt(h)===47;++h);for(var m=l.length-h,g=f<m?f:m,A=-1,y=0;y<=g;++y){if(y===g){if(m>g){if(l.charCodeAt(h+y)===47)return l.slice(h+y+1);if(y===0)return l.slice(h+y)}else f>g&&(c.charCodeAt(u+y)===47?A=y:y===0&&(A=0));break}var v=c.charCodeAt(u+y);if(v!==l.charCodeAt(h+y))break;v===47&&(A=y)}var R="";for(y=u+A+1;y<=d;++y)y!==d&&c.charCodeAt(y)!==47||(R.length===0?R+="..":R+="/..");return R.length>0?R+l.slice(h+A):(h+=A,l.charCodeAt(h)===47&&++h,l.slice(h))},_makeLong:function(c){return c},dirname:function(c){if(s(c),c.length===0)return".";for(var l=c.charCodeAt(0),u=l===47,d=-1,f=!0,h=c.length-1;h>=1;--h)if((l=c.charCodeAt(h))===47){if(!f){d=h;break}}else f=!1;return d===-1?u?"/":".":u&&d===1?"//":c.slice(0,d)},basename:function(c,l){if(l!==void 0&&typeof l!="string")throw new TypeError('"ext" argument must be a string');s(c);var u,d=0,f=-1,h=!0;if(l!==void 0&&l.length>0&&l.length<=c.length){if(l.length===c.length&&l===c)return"";var m=l.length-1,g=-1;for(u=c.length-1;u>=0;--u){var A=c.charCodeAt(u);if(A===47){if(!h){d=u+1;break}}else g===-1&&(h=!1,g=u+1),m>=0&&(A===l.charCodeAt(m)?--m==-1&&(f=u):(m=-1,f=g))}return d===f?f=g:f===-1&&(f=c.length),c.slice(d,f)}for(u=c.length-1;u>=0;--u)if(c.charCodeAt(u)===47){if(!h){d=u+1;break}}else f===-1&&(h=!1,f=u+1);return f===-1?"":c.slice(d,f)},extname:function(c){s(c);for(var l=-1,u=0,d=-1,f=!0,h=0,m=c.length-1;m>=0;--m){var g=c.charCodeAt(m);if(g!==47)d===-1&&(f=!1,d=m+1),g===46?l===-1?l=m:h!==1&&(h=1):l!==-1&&(h=-1);else if(!f){u=m+1;break}}return l===-1||d===-1||h===0||h===1&&l===d-1&&l===u+1?"":c.slice(l,d)},format:function(c){if(c===null||typeof c!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof c);return function(l,u){var d=u.dir||u.root,f=u.base||(u.name||"")+(u.ext||"");return d?d===u.root?d+f:d+"/"+f:f}(0,c)},parse:function(c){s(c);var l={root:"",dir:"",base:"",ext:"",name:""};if(c.length===0)return l;var u,d=c.charCodeAt(0),f=d===47;f?(l.root="/",u=1):u=0;for(var h=-1,m=0,g=-1,A=!0,y=c.length-1,v=0;y>=u;--y)if((d=c.charCodeAt(y))!==47)g===-1&&(A=!1,g=y+1),d===46?h===-1?h=y:v!==1&&(v=1):h!==-1&&(v=-1);else if(!A){m=y+1;break}return h===-1||g===-1||v===0||v===1&&h===g-1&&h===m+1?g!==-1&&(l.base=l.name=m===0&&f?c.slice(1,g):c.slice(m,g)):(m===0&&f?(l.name=c.slice(1,h),l.base=c.slice(1,g)):(l.name=c.slice(m,h),l.base=c.slice(m,g)),l.ext=c.slice(h,g)),m>0?l.dir=c.slice(0,m-1):f&&(l.dir="/"),l},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,i.exports=o}},e={};function t(i){var s=e[i];if(s!==void 0)return s.exports;var a=e[i]={exports:{}};return n[i](a,a.exports,t),a.exports}t.d=(i,s)=>{for(var a in s)t.o(s,a)&&!t.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:s[a]})},t.o=(i,s)=>Object.prototype.hasOwnProperty.call(i,s),t.r=i=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var r={};(()=>{let i;t.r(r),t.d(r,{URI:()=>f,Utils:()=>Se}),typeof process=="object"?i=process.platform==="win32":typeof navigator=="object"&&(i=navigator.userAgent.indexOf("Windows")>=0);const s=/^\w[\w\d+.-]*$/,a=/^\//,o=/^\/\//;function c(k,T){if(!k.scheme&&T)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${k.authority}", path: "${k.path}", query: "${k.query}", fragment: "${k.fragment}"}`);if(k.scheme&&!s.test(k.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(k.path){if(k.authority){if(!a.test(k.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(o.test(k.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}}const l="",u="/",d=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class f{constructor(T,E,I,O,$,L=!1){Je(this,"scheme");Je(this,"authority");Je(this,"path");Je(this,"query");Je(this,"fragment");typeof T=="object"?(this.scheme=T.scheme||l,this.authority=T.authority||l,this.path=T.path||l,this.query=T.query||l,this.fragment=T.fragment||l):(this.scheme=function(ye,z){return ye||z?ye:"file"}(T,L),this.authority=E||l,this.path=function(ye,z){switch(ye){case"https":case"http":case"file":z?z[0]!==u&&(z=u+z):z=u}return z}(this.scheme,I||l),this.query=O||l,this.fragment=$||l,c(this,L))}static isUri(T){return T instanceof f||!!T&&typeof T.authority=="string"&&typeof T.fragment=="string"&&typeof T.path=="string"&&typeof T.query=="string"&&typeof T.scheme=="string"&&typeof T.fsPath=="string"&&typeof T.with=="function"&&typeof T.toString=="function"}get fsPath(){return v(this)}with(T){if(!T)return this;let{scheme:E,authority:I,path:O,query:$,fragment:L}=T;return E===void 0?E=this.scheme:E===null&&(E=l),I===void 0?I=this.authority:I===null&&(I=l),O===void 0?O=this.path:O===null&&(O=l),$===void 0?$=this.query:$===null&&($=l),L===void 0?L=this.fragment:L===null&&(L=l),E===this.scheme&&I===this.authority&&O===this.path&&$===this.query&&L===this.fragment?this:new m(E,I,O,$,L)}static parse(T,E=!1){const I=d.exec(T);return I?new m(I[2]||l,ne(I[4]||l),ne(I[5]||l),ne(I[7]||l),ne(I[9]||l),E):new m(l,l,l,l,l)}static file(T){let E=l;if(i&&(T=T.replace(/\\/g,u)),T[0]===u&&T[1]===u){const I=T.indexOf(u,2);I===-1?(E=T.substring(2),T=u):(E=T.substring(2,I),T=T.substring(I)||u)}return new m("file",E,T,l,l)}static from(T){const E=new m(T.scheme,T.authority,T.path,T.query,T.fragment);return c(E,!0),E}toString(T=!1){return R(this,T)}toJSON(){return this}static revive(T){if(T){if(T instanceof f)return T;{const E=new m(T);return E._formatted=T.external,E._fsPath=T._sep===h?T.fsPath:null,E}}return T}}const h=i?1:void 0;class m extends f{constructor(){super(...arguments);Je(this,"_formatted",null);Je(this,"_fsPath",null)}get fsPath(){return this._fsPath||(this._fsPath=v(this)),this._fsPath}toString(E=!1){return E?R(this,!0):(this._formatted||(this._formatted=R(this,!1)),this._formatted)}toJSON(){const E={$mid:1};return this._fsPath&&(E.fsPath=this._fsPath,E._sep=h),this._formatted&&(E.external=this._formatted),this.path&&(E.path=this.path),this.scheme&&(E.scheme=this.scheme),this.authority&&(E.authority=this.authority),this.query&&(E.query=this.query),this.fragment&&(E.fragment=this.fragment),E}}const g={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function A(k,T,E){let I,O=-1;for(let $=0;$<k.length;$++){const L=k.charCodeAt($);if(L>=97&&L<=122||L>=65&&L<=90||L>=48&&L<=57||L===45||L===46||L===95||L===126||T&&L===47||E&&L===91||E&&L===93||E&&L===58)O!==-1&&(I+=encodeURIComponent(k.substring(O,$)),O=-1),I!==void 0&&(I+=k.charAt($));else{I===void 0&&(I=k.substr(0,$));const ye=g[L];ye!==void 0?(O!==-1&&(I+=encodeURIComponent(k.substring(O,$)),O=-1),I+=ye):O===-1&&(O=$)}}return O!==-1&&(I+=encodeURIComponent(k.substring(O))),I!==void 0?I:k}function y(k){let T;for(let E=0;E<k.length;E++){const I=k.charCodeAt(E);I===35||I===63?(T===void 0&&(T=k.substr(0,E)),T+=g[I]):T!==void 0&&(T+=k[E])}return T!==void 0?T:k}function v(k,T){let E;return E=k.authority&&k.path.length>1&&k.scheme==="file"?`//${k.authority}${k.path}`:k.path.charCodeAt(0)===47&&(k.path.charCodeAt(1)>=65&&k.path.charCodeAt(1)<=90||k.path.charCodeAt(1)>=97&&k.path.charCodeAt(1)<=122)&&k.path.charCodeAt(2)===58?k.path[1].toLowerCase()+k.path.substr(2):k.path,i&&(E=E.replace(/\//g,"\\")),E}function R(k,T){const E=T?y:A;let I="",{scheme:O,authority:$,path:L,query:ye,fragment:z}=k;if(O&&(I+=O,I+=":"),($||O==="file")&&(I+=u,I+=u),$){let V=$.indexOf("@");if(V!==-1){const at=$.substr(0,V);$=$.substr(V+1),V=at.lastIndexOf(":"),V===-1?I+=E(at,!1,!1):(I+=E(at.substr(0,V),!1,!1),I+=":",I+=E(at.substr(V+1),!1,!0)),I+="@"}$=$.toLowerCase(),V=$.lastIndexOf(":"),V===-1?I+=E($,!1,!0):(I+=E($.substr(0,V),!1,!0),I+=$.substr(V))}if(L){if(L.length>=3&&L.charCodeAt(0)===47&&L.charCodeAt(2)===58){const V=L.charCodeAt(1);V>=65&&V<=90&&(L=`/${String.fromCharCode(V+32)}:${L.substr(3)}`)}else if(L.length>=2&&L.charCodeAt(1)===58){const V=L.charCodeAt(0);V>=65&&V<=90&&(L=`${String.fromCharCode(V+32)}:${L.substr(2)}`)}I+=E(L,!0,!1)}return ye&&(I+="?",I+=E(ye,!1,!1)),z&&(I+="#",I+=T?z:A(z,!1,!1)),I}function N(k){try{return decodeURIComponent(k)}catch{return k.length>3?k.substr(0,3)+N(k.substr(3)):k}}const F=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function ne(k){return k.match(F)?k.replace(F,T=>N(T)):k}var we=t(470);const ge=we.posix||we,De="/";var Se;(function(k){k.joinPath=function(T,...E){return T.with({path:ge.join(T.path,...E)})},k.resolvePath=function(T,...E){let I=T.path,O=!1;I[0]!==De&&(I=De+I,O=!0);let $=ge.resolve(I,...E);return O&&$[0]===De&&!T.authority&&($=$.substring(1)),T.with({path:$})},k.dirname=function(T){if(T.path.length===0||T.path===De)return T;let E=ge.dirname(T.path);return E.length===1&&E.charCodeAt(0)===46&&(E=""),T.with({path:E})},k.basename=function(T){return ge.basename(T.path)},k.extname=function(T){return ge.extname(T.path)}})(Se||(Se={}))})(),hl=r})();const{URI:Ht,Utils:sn}=hl;var rt;(function(n){n.basename=sn.basename,n.dirname=sn.dirname,n.extname=sn.extname,n.joinPath=sn.joinPath,n.resolvePath=sn.resolvePath;function e(r,i){return(r==null?void 0:r.toString())===(i==null?void 0:i.toString())}n.equals=e;function t(r,i){const s=typeof r=="string"?r:r.path,a=typeof i=="string"?i:i.path,o=s.split("/").filter(f=>f.length>0),c=a.split("/").filter(f=>f.length>0);let l=0;for(;l<o.length&&o[l]===c[l];l++);const u="../".repeat(o.length-l),d=c.slice(l).join("/");return u+d}n.relative=t})(rt||(rt={}));var U;(function(n){n[n.Changed=0]="Changed",n[n.Parsed=1]="Parsed",n[n.IndexedContent=2]="IndexedContent",n[n.ComputedScopes=3]="ComputedScopes",n[n.Linked=4]="Linked",n[n.IndexedReferences=5]="IndexedReferences",n[n.Validated=6]="Validated"})(U||(U={}));class sm{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}async fromUri(e,t=X.None){const r=await this.fileSystemProvider.readFile(e);return this.createAsync(e,r,t)}fromTextDocument(e,t,r){return t=t??Ht.parse(e.uri),r?this.createAsync(t,e,r):this.create(t,e)}fromString(e,t,r){return r?this.createAsync(t,e,r):this.create(t,e)}fromModel(e,t){return this.create(t,{$model:e})}create(e,t){if(typeof t=="string"){const r=this.parse(e,t);return this.createLangiumDocument(r,e,void 0,t)}else if("$model"in t){const r={value:t.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(r,e)}else{const r=this.parse(e,t.getText());return this.createLangiumDocument(r,e,t)}}async createAsync(e,t,r){if(typeof t=="string"){const i=await this.parseAsync(e,t,r);return this.createLangiumDocument(i,e,void 0,t)}else{const i=await this.parseAsync(e,t.getText(),r);return this.createLangiumDocument(i,e,t)}}createLangiumDocument(e,t,r,i){let s;if(r)s={parseResult:e,uri:t,state:U.Parsed,references:[],textDocument:r};else{const a=this.createTextDocumentGetter(t,i);s={parseResult:e,uri:t,state:U.Parsed,references:[],get textDocument(){return a()}}}return e.value.$document=s,s}async update(e,t){var r,i;const s=(r=e.parseResult.value.$cstNode)===null||r===void 0?void 0:r.root.fullText,a=(i=this.textDocuments)===null||i===void 0?void 0:i.get(e.uri.toString()),o=a?a.getText():await this.fileSystemProvider.readFile(e.uri);if(a)Object.defineProperty(e,"textDocument",{value:a});else{const c=this.createTextDocumentGetter(e.uri,o);Object.defineProperty(e,"textDocument",{get:c})}return s!==o&&(e.parseResult=await this.parseAsync(e.uri,o,t),e.parseResult.value.$document=e),e.state=U.Parsed,e}parse(e,t){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(t)}parseAsync(e,t,r){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(t,r)}createTextDocumentGetter(e,t){const r=this.serviceRegistry;let i;return()=>i??(i=pi.create(e.toString(),r.getServices(e).LanguageMetaData.languageId,0,t??""))}}class am{constructor(e){this.documentMap=new Map,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory}get all(){return Q(this.documentMap.values())}addDocument(e){const t=e.uri.toString();if(this.documentMap.has(t))throw new Error(`A document with the URI '${t}' is already present.`);this.documentMap.set(t,e)}getDocument(e){const t=e.toString();return this.documentMap.get(t)}async getOrCreateDocument(e,t){let r=this.getDocument(e);return r||(r=await this.langiumDocumentFactory.fromUri(e,t),this.addDocument(r),r)}createDocument(e,t,r){if(r)return this.langiumDocumentFactory.fromString(t,e,r).then(i=>(this.addDocument(i),i));{const i=this.langiumDocumentFactory.fromString(t,e);return this.addDocument(i),i}}hasDocument(e){return this.documentMap.has(e.toString())}invalidateDocument(e){const t=e.toString(),r=this.documentMap.get(t);return r&&(r.state=U.Changed,r.precomputedScopes=void 0,r.references=[],r.diagnostics=void 0),r}deleteDocument(e){const t=e.toString(),r=this.documentMap.get(t);return r&&(r.state=U.Changed,this.documentMap.delete(t)),r}}class om{constructor(e){this.reflection=e.shared.AstReflection,this.langiumDocuments=()=>e.shared.workspace.LangiumDocuments,this.scopeProvider=e.references.ScopeProvider,this.astNodeLocator=e.workspace.AstNodeLocator}async link(e,t=X.None){for(const r of vt(e.parseResult.value))await Oe(t),Qo(r).forEach(i=>this.doLink(i,e))}doLink(e,t){const r=e.reference;if(r._ref===void 0)try{const i=this.getCandidate(e);if(xn(i))r._ref=i;else if(r._nodeDescription=i,this.langiumDocuments().hasDocument(i.documentUri)){const s=this.loadAstNode(i);r._ref=s??this.createLinkingError(e,i)}}catch(i){r._ref=Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${r.$refText}': ${i}`})}t.references.push(r)}unlink(e){for(const t of e.references)delete t._ref,delete t._nodeDescription;e.references=[]}getCandidate(e){const r=this.scopeProvider.getScope(e).getElement(e.reference.$refText);return r??this.createLinkingError(e)}buildReference(e,t,r,i){const s=this,a={$refNode:r,$refText:i,get ref(){var o;if(ae(this._ref))return this._ref;if(Su(this._nodeDescription)){const c=s.loadAstNode(this._nodeDescription);this._ref=c??s.createLinkingError({reference:a,container:e,property:t},this._nodeDescription)}else if(this._ref===void 0){const c=s.getLinkedNode({reference:a,container:e,property:t});if(c.error&&Ue(e).state<U.ComputedScopes)return;this._ref=(o=c.node)!==null&&o!==void 0?o:c.error,this._nodeDescription=c.descr}return ae(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return xn(this._ref)?this._ref:void 0}};return a}getLinkedNode(e){try{const t=this.getCandidate(e);if(xn(t))return{error:t};const r=this.loadAstNode(t);return r?{node:r,descr:t}:{descr:t,error:this.createLinkingError(e,t)}}catch(t){return{error:Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${e.reference.$refText}': ${t}`})}}}loadAstNode(e){if(e.node)return e.node;const t=this.langiumDocuments().getDocument(e.documentUri);if(t)return this.astNodeLocator.getAstNode(t.parseResult.value,e.path)}createLinkingError(e,t){const r=Ue(e.container);r.state<U.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${r.uri}).`);const i=this.reflection.getReferenceType(e);return Object.assign(Object.assign({},e),{message:`Could not resolve reference to ${i} named '${e.reference.$refText}'.`,targetDescription:t})}}function cm(n){return typeof n.name=="string"}class lm{getName(e){if(cm(e))return e.name}getNameNode(e){return rc(e.$cstNode,"name")}}class um{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator}findDeclaration(e){if(e){const t=xd(e),r=e.astNode;if(t&&r){const i=r[t.feature];if(Ge(i))return i.ref;if(Array.isArray(i)){for(const s of i)if(Ge(s)&&s.$refNode&&s.$refNode.offset<=e.offset&&s.$refNode.end>=e.end)return s.ref}}if(r){const i=this.nameProvider.getNameNode(r);if(i&&(i===e||Nu(e,i)))return r}}}findDeclarationNode(e){const t=this.findDeclaration(e);if(t!=null&&t.$cstNode){const r=this.nameProvider.getNameNode(t);return r??t.$cstNode}}findReferences(e,t){const r=[];if(t.includeDeclaration){const s=this.getReferenceToSelf(e);s&&r.push(s)}let i=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return t.documentUri&&(i=i.filter(s=>rt.equals(s.sourceUri,t.documentUri))),r.push(...i),Q(r)}getReferenceToSelf(e){const t=this.nameProvider.getNameNode(e);if(t){const r=Ue(e),i=this.nodeLocator.getAstNodePath(e);return{sourceUri:r.uri,sourcePath:i,targetUri:r.uri,targetPath:i,segment:On(t),local:!0}}}}class ji{constructor(e){if(this.map=new Map,e)for(const[t,r]of e)this.add(t,r)}get size(){return br.sum(Q(this.map.values()).map(e=>e.length))}clear(){this.map.clear()}delete(e,t){if(t===void 0)return this.map.delete(e);{const r=this.map.get(e);if(r){const i=r.indexOf(t);if(i>=0)return r.length===1?this.map.delete(e):r.splice(i,1),!0}return!1}}get(e){var t;return(t=this.map.get(e))!==null&&t!==void 0?t:[]}has(e,t){if(t===void 0)return this.map.has(e);{const r=this.map.get(e);return r?r.indexOf(t)>=0:!1}}add(e,t){return this.map.has(e)?this.map.get(e).push(t):this.map.set(e,[t]),this}addAll(e,t){return this.map.has(e)?this.map.get(e).push(...t):this.map.set(e,Array.from(t)),this}forEach(e){this.map.forEach((t,r)=>t.forEach(i=>e(i,r,this)))}[Symbol.iterator](){return this.entries().iterator()}entries(){return Q(this.map.entries()).flatMap(([e,t])=>t.map(r=>[e,r]))}keys(){return Q(this.map.keys())}values(){return Q(this.map.values()).flat()}entriesGroupedByKey(){return Q(this.map.entries())}}class Va{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(const[t,r]of e)this.set(t,r)}clear(){this.map.clear(),this.inverse.clear()}set(e,t){return this.map.set(e,t),this.inverse.set(t,e),this}get(e){return this.map.get(e)}getKey(e){return this.inverse.get(e)}delete(e){const t=this.map.get(e);return t!==void 0?(this.map.delete(e),this.inverse.delete(t),!0):!1}}class dm{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}async computeExports(e,t=X.None){return this.computeExportsForNode(e.parseResult.value,e,void 0,t)}async computeExportsForNode(e,t,r=Ii,i=X.None){const s=[];this.exportNode(e,s,t);for(const a of r(e))await Oe(i),this.exportNode(a,s,t);return s}exportNode(e,t,r){const i=this.nameProvider.getName(e);i&&t.push(this.descriptions.createDescription(e,i,r))}async computeLocalScopes(e,t=X.None){const r=e.parseResult.value,i=new ji;for(const s of pn(r))await Oe(t),this.processNode(s,e,i);return i}processNode(e,t,r){const i=e.$container;if(i){const s=this.nameProvider.getName(e);s&&r.add(i,this.descriptions.createDescription(e,s,t))}}}class Wa{constructor(e,t,r){var i;this.elements=e,this.outerScope=t,this.caseInsensitive=(i=r==null?void 0:r.caseInsensitive)!==null&&i!==void 0?i:!1}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){const t=this.caseInsensitive?this.elements.find(r=>r.name.toLowerCase()===e.toLowerCase()):this.elements.find(r=>r.name===e);if(t)return t;if(this.outerScope)return this.outerScope.getElement(e)}}class fm{constructor(e,t,r){var i;this.elements=new Map,this.caseInsensitive=(i=r==null?void 0:r.caseInsensitive)!==null&&i!==void 0?i:!1;for(const s of e){const a=this.caseInsensitive?s.name.toLowerCase():s.name;this.elements.set(a,s)}this.outerScope=t}getElement(e){const t=this.caseInsensitive?e.toLowerCase():e,r=this.elements.get(t);if(r)return r;if(this.outerScope)return this.outerScope.getElement(e)}getAllElements(){let e=Q(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}}class pl{constructor(){this.toDispose=[],this.isDisposed=!1}onDispose(e){this.toDispose.push(e)}dispose(){this.throwIfDisposed(),this.clear(),this.isDisposed=!0,this.toDispose.forEach(e=>e.dispose())}throwIfDisposed(){if(this.isDisposed)throw new Error("This cache has already been disposed")}}class hm extends pl{constructor(){super(...arguments),this.cache=new Map}has(e){return this.throwIfDisposed(),this.cache.has(e)}set(e,t){this.throwIfDisposed(),this.cache.set(e,t)}get(e,t){if(this.throwIfDisposed(),this.cache.has(e))return this.cache.get(e);if(t){const r=t();return this.cache.set(e,r),r}else return}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}}class pm extends pl{constructor(e){super(),this.cache=new Map,this.converter=e??(t=>t)}has(e,t){return this.throwIfDisposed(),this.cacheForContext(e).has(t)}set(e,t,r){this.throwIfDisposed(),this.cacheForContext(e).set(t,r)}get(e,t,r){this.throwIfDisposed();const i=this.cacheForContext(e);if(i.has(t))return i.get(t);if(r){const s=r();return i.set(t,s),s}else return}delete(e,t){return this.throwIfDisposed(),this.cacheForContext(e).delete(t)}clear(e){if(this.throwIfDisposed(),e){const t=this.converter(e);this.cache.delete(t)}else this.cache.clear()}cacheForContext(e){const t=this.converter(e);let r=this.cache.get(t);return r||(r=new Map,this.cache.set(t,r)),r}}class mm extends hm{constructor(e){super(),this.onDispose(e.workspace.DocumentBuilder.onUpdate(()=>{this.clear()}))}}class gm{constructor(e){this.reflection=e.shared.AstReflection,this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider,this.indexManager=e.shared.workspace.IndexManager,this.globalScopeCache=new mm(e.shared)}getScope(e){const t=[],r=this.reflection.getReferenceType(e),i=Ue(e.container).precomputedScopes;if(i){let a=e.container;do{const o=i.get(a);o.length>0&&t.push(Q(o).filter(c=>this.reflection.isSubtype(c.type,r))),a=a.$container}while(a)}let s=this.getGlobalScope(r,e);for(let a=t.length-1;a>=0;a--)s=this.createScope(t[a],s);return s}createScope(e,t,r){return new Wa(Q(e),t,r)}createScopeForNodes(e,t,r){const i=Q(e).map(s=>{const a=this.nameProvider.getName(s);if(a)return this.descriptions.createDescription(s,a)}).nonNullable();return new Wa(i,t,r)}getGlobalScope(e,t){return this.globalScopeCache.get(e,()=>new fm(this.indexManager.allElements(e)))}}function ym(n){return typeof n.$comment=="string"}function ja(n){return typeof n=="object"&&!!n&&("$ref"in n||"$error"in n)}class Tm{constructor(e){this.ignoreProperties=new Set(["$container","$containerProperty","$containerIndex","$document","$cstNode"]),this.langiumDocuments=e.shared.workspace.LangiumDocuments,this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider,this.commentProvider=e.documentation.CommentProvider}serialize(e,t={}){const r=t==null?void 0:t.replacer,i=(a,o)=>this.replacer(a,o,t),s=r?(a,o)=>r(a,o,i):i;try{return this.currentDocument=Ue(e),JSON.stringify(e,s,t==null?void 0:t.space)}finally{this.currentDocument=void 0}}deserialize(e,t={}){const r=JSON.parse(e);return this.linkNode(r,r,t),r}replacer(e,t,{refText:r,sourceText:i,textRegions:s,comments:a,uriConverter:o}){var c,l,u,d;if(!this.ignoreProperties.has(e))if(Ge(t)){const f=t.ref,h=r?t.$refText:void 0;if(f){const m=Ue(f);let g="";this.currentDocument&&this.currentDocument!==m&&(o?g=o(m.uri,t):g=m.uri.toString());const A=this.astNodeLocator.getAstNodePath(f);return{$ref:`${g}#${A}`,$refText:h}}else return{$error:(l=(c=t.error)===null||c===void 0?void 0:c.message)!==null&&l!==void 0?l:"Could not resolve reference",$refText:h}}else if(ae(t)){let f;if(s&&(f=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},t)),(!e||t.$document)&&(f!=null&&f.$textRegion)&&(f.$textRegion.documentURI=(u=this.currentDocument)===null||u===void 0?void 0:u.uri.toString())),i&&!e&&(f??(f=Object.assign({},t)),f.$sourceText=(d=t.$cstNode)===null||d===void 0?void 0:d.text),a){f??(f=Object.assign({},t));const h=this.commentProvider.getComment(t);h&&(f.$comment=h.replace(/\r/g,""))}return f??t}else return t}addAstNodeRegionWithAssignmentsTo(e){const t=r=>({offset:r.offset,end:r.end,length:r.length,range:r.range});if(e.$cstNode){const r=e.$textRegion=t(e.$cstNode),i=r.assignments={};return Object.keys(e).filter(s=>!s.startsWith("$")).forEach(s=>{const a=kd(e.$cstNode,s).map(t);a.length!==0&&(i[s]=a)}),e}}linkNode(e,t,r,i,s,a){for(const[c,l]of Object.entries(e))if(Array.isArray(l))for(let u=0;u<l.length;u++){const d=l[u];ja(d)?l[u]=this.reviveReference(e,c,t,d,r):ae(d)&&this.linkNode(d,t,r,e,c,u)}else ja(l)?e[c]=this.reviveReference(e,c,t,l,r):ae(l)&&this.linkNode(l,t,r,e,c);const o=e;o.$container=i,o.$containerProperty=s,o.$containerIndex=a}reviveReference(e,t,r,i,s){let a=i.$refText,o=i.$error;if(i.$ref){const c=this.getRefNode(r,i.$ref,s.uriConverter);if(ae(c))return a||(a=this.nameProvider.getName(c)),{$refText:a??"",ref:c};o=c}if(o){const c={$refText:a??""};return c.error={container:e,property:t,message:o,reference:c},c}else return}getRefNode(e,t,r){try{const i=t.indexOf("#");if(i===0){const c=this.astNodeLocator.getAstNode(e,t.substring(1));return c||"Could not resolve path: "+t}if(i<0){const c=r?r(t):Ht.parse(t),l=this.langiumDocuments.getDocument(c);return l?l.parseResult.value:"Could not find document for URI: "+t}const s=r?r(t.substring(0,i)):Ht.parse(t.substring(0,i)),a=this.langiumDocuments.getDocument(s);if(!a)return"Could not find document for URI: "+t;if(i===t.length-1)return a.parseResult.value;const o=this.astNodeLocator.getAstNode(a.parseResult.value,t.substring(i+1));return o||"Could not resolve URI: "+t}catch(i){return String(i)}}}class Rm{register(e){if(!this.singleton&&!this.map){this.singleton=e;return}if(!this.map&&(this.map={},this.singleton)){for(const t of this.singleton.LanguageMetaData.fileExtensions)this.map[t]=this.singleton;this.singleton=void 0}for(const t of e.LanguageMetaData.fileExtensions)this.map[t]!==void 0&&this.map[t]!==e&&console.warn(`The file extension ${t} is used by multiple languages. It is now assigned to '${e.LanguageMetaData.languageId}'.`),this.map[t]=e}getServices(e){if(this.singleton!==void 0)return this.singleton;if(this.map===void 0)throw new Error("The service registry is empty. Use `register` to register the services of a language.");const t=rt.extname(e),r=this.map[t];if(!r)throw new Error(`The service registry contains no services for the extension '${t}'.`);return r}get all(){return this.singleton!==void 0?[this.singleton]:this.map!==void 0?Object.values(this.map):[]}}function Ha(n){return{code:n}}var Zn;(function(n){n.all=["fast","slow","built-in"]})(Zn||(Zn={}));class Am{constructor(e){this.entries=new ji,this.reflection=e.shared.AstReflection}register(e,t=this,r="fast"){if(r==="built-in")throw new Error("The 'built-in' category is reserved for lexer, parser, and linker errors.");for(const[i,s]of Object.entries(e)){const a=s;if(Array.isArray(a))for(const o of a){const c={check:this.wrapValidationException(o,t),category:r};this.addEntry(i,c)}else if(typeof a=="function"){const o={check:this.wrapValidationException(a,t),category:r};this.addEntry(i,o)}}}wrapValidationException(e,t){return async(r,i,s)=>{try{await e.call(t,r,i,s)}catch(a){if(Vi(a))throw a;console.error("An error occurred during validation:",a);const o=a instanceof Error?a.message:String(a);a instanceof Error&&a.stack&&console.error(a.stack),i("error","An error occurred during validation: "+o,{node:r})}}}addEntry(e,t){if(e==="AstNode"){this.entries.add("AstNode",t);return}for(const r of this.reflection.getAllSubTypes(e))this.entries.add(r,t)}getChecks(e,t){let r=Q(this.entries.get(e)).concat(this.entries.get("AstNode"));return t&&(r=r.filter(i=>t.includes(i.category))),r.map(i=>i.check)}}class vm{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},r=X.None){const i=e.parseResult,s=[];if(await Oe(r),(!t.categories||t.categories.includes("built-in"))&&(this.processLexingErrors(i,s,t),t.stopAfterLexingErrors&&s.some(a=>{var o;return((o=a.data)===null||o===void 0?void 0:o.code)===Qe.LexingError})||(this.processParsingErrors(i,s,t),t.stopAfterParsingErrors&&s.some(a=>{var o;return((o=a.data)===null||o===void 0?void 0:o.code)===Qe.ParsingError}))||(this.processLinkingErrors(e,s,t),t.stopAfterLinkingErrors&&s.some(a=>{var o;return((o=a.data)===null||o===void 0?void 0:o.code)===Qe.LinkingError}))))return s;try{s.push(...await this.validateAst(i.value,t,r))}catch(a){if(Vi(a))throw a;console.error("An error occurred during validation:",a)}return await Oe(r),s}processLexingErrors(e,t,r){for(const i of e.lexerErrors){const s={severity:Lr("error"),range:{start:{line:i.line-1,character:i.column-1},end:{line:i.line-1,character:i.column+i.length-1}},message:i.message,data:Ha(Qe.LexingError),source:this.getSource()};t.push(s)}}processParsingErrors(e,t,r){for(const i of e.parserErrors){let s;if(isNaN(i.token.startOffset)){if("previousToken"in i){const a=i.previousToken;if(isNaN(a.startOffset)){const o={line:0,character:0};s={start:o,end:o}}else{const o={line:a.endLine-1,character:a.endColumn};s={start:o,end:o}}}}else s=Mr(i.token);if(s){const a={severity:Lr("error"),range:s,message:i.message,data:Ha(Qe.ParsingError),source:this.getSource()};t.push(a)}}}processLinkingErrors(e,t,r){for(const i of e.references){const s=i.error;if(s){const a={node:s.container,property:s.property,index:s.index,data:{code:Qe.LinkingError,containerType:s.container.$type,property:s.property,refText:s.reference.$refText}};t.push(this.toDiagnostic("error",s.message,a))}}}async validateAst(e,t,r=X.None){const i=[],s=(a,o,c)=>{i.push(this.toDiagnostic(a,o,c))};return await Promise.all(vt(e).map(async a=>{await Oe(r);const o=this.validationRegistry.getChecks(a.$type,t.categories);for(const c of o)await c(a,s,r)})),i}toDiagnostic(e,t,r){return{message:t,range:Em(r),severity:Lr(e),code:r.code,codeDescription:r.codeDescription,tags:r.tags,relatedInformation:r.relatedInformation,data:r.data,source:this.getSource()}}getSource(){return this.metadata.languageId}}function Em(n){if(n.range)return n.range;let e;return typeof n.property=="string"?e=rc(n.node.$cstNode,n.property,n.index):typeof n.keyword=="string"&&(e=Sd(n.node.$cstNode,n.keyword,n.index)),e??(e=n.node.$cstNode),e?e.range:{start:{line:0,character:0},end:{line:0,character:0}}}function Lr(n){switch(n){case"error":return 1;case"warning":return 2;case"info":return 3;case"hint":return 4;default:throw new Error("Invalid diagnostic severity: "+n)}}var Qe;(function(n){n.LexingError="lexing-error",n.ParsingError="parsing-error",n.LinkingError="linking-error"})(Qe||(Qe={}));class km{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,r=Ue(e)){t??(t=this.nameProvider.getName(e));const i=this.astNodeLocator.getAstNodePath(e);if(!t)throw new Error(`Node at path ${i} has no name.`);let s;const a=()=>{var o;return s??(s=On((o=this.nameProvider.getNameNode(e))!==null&&o!==void 0?o:e.$cstNode))};return{node:e,name:t,get nameSegment(){return a()},selectionSegment:On(e.$cstNode),type:e.$type,documentUri:r.uri,path:i}}}class Sm{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=X.None){const r=[],i=e.parseResult.value;for(const s of vt(i))await Oe(t),Qo(s).filter(a=>!xn(a)).forEach(a=>{const o=this.createDescription(a);o&&r.push(o)});return r}createDescription(e){const t=e.reference.$nodeDescription,r=e.reference.$refNode;if(!t||!r)return;const i=Ue(e.container).uri;return{sourceUri:i,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:On(r),local:rt.equals(t.documentUri,i)}}}class Im{constructor(){this.segmentSeparator="/",this.indexSeparator="@"}getAstNodePath(e){if(e.$container){const t=this.getAstNodePath(e.$container),r=this.getPathSegment(e);return t+this.segmentSeparator+r}return""}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw new Error("Missing '$containerProperty' in AST node.");return t!==void 0?e+this.indexSeparator+t:e}getAstNode(e,t){return t.split(this.segmentSeparator).reduce((i,s)=>{if(!i||s.length===0)return i;const a=s.indexOf(this.indexSeparator);if(a>0){const o=s.substring(0,a),c=parseInt(s.substring(a+1)),l=i[o];return l==null?void 0:l[c]}return i[s]},e)}}class xm{constructor(e){this._ready=new Wi,this.settings={},this.workspaceConfig=!1,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){var t,r;this.workspaceConfig=(r=(t=e.capabilities.workspace)===null||t===void 0?void 0:t.configuration)!==null&&r!==void 0?r:!1}async initialized(e){if(this.workspaceConfig){if(e.register){const t=this.serviceRegistry.all;e.register({section:t.map(r=>this.toSectionName(r.LanguageMetaData.languageId))})}if(e.fetchConfiguration){const t=this.serviceRegistry.all.map(i=>({section:this.toSectionName(i.LanguageMetaData.languageId)})),r=await e.fetchConfiguration(t);t.forEach((i,s)=>{this.updateSectionConfiguration(i.section,r[s])})}}this._ready.resolve()}updateConfiguration(e){e.settings&&Object.keys(e.settings).forEach(t=>{this.updateSectionConfiguration(t,e.settings[t])})}updateSectionConfiguration(e,t){this.settings[e]=t}async getConfiguration(e,t){await this.ready;const r=this.toSectionName(e);if(this.settings[r])return this.settings[r][t]}toSectionName(e){return`${e}`}}var er;(function(n){function e(t){return{dispose:async()=>await t()}}n.create=e})(er||(er={}));class Nm{constructor(e){this.updateBuildOptions={validation:{categories:["built-in","fast"]}},this.updateListeners=[],this.buildPhaseListeners=new ji,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=U.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},r=X.None){var i,s;for(const a of e){const o=a.uri.toString();if(a.state===U.Validated){if(typeof t.validation=="boolean"&&t.validation)a.state=U.IndexedReferences,a.diagnostics=void 0,this.buildState.delete(o);else if(typeof t.validation=="object"){const c=this.buildState.get(o),l=(i=c==null?void 0:c.result)===null||i===void 0?void 0:i.validationChecks;if(l){const d=((s=t.validation.categories)!==null&&s!==void 0?s:Zn.all).filter(f=>!l.includes(f));d.length>0&&(this.buildState.set(o,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:d})},result:c.result}),a.state=U.IndexedReferences)}}}else this.buildState.delete(o)}this.currentState=U.Changed,await this.emitUpdate(e.map(a=>a.uri),[]),await this.buildDocuments(e,t,r)}async update(e,t,r=X.None){this.currentState=U.Changed;for(const a of t)this.langiumDocuments.deleteDocument(a),this.buildState.delete(a.toString()),this.indexManager.remove(a);for(const a of e){if(!this.langiumDocuments.invalidateDocument(a)){const c=this.langiumDocumentFactory.fromModel({$type:"INVALID"},a);c.state=U.Changed,this.langiumDocuments.addDocument(c)}this.buildState.delete(a.toString())}const i=Q(e).concat(t).map(a=>a.toString()).toSet();this.langiumDocuments.all.filter(a=>!i.has(a.uri.toString())&&this.shouldRelink(a,i)).forEach(a=>{this.serviceRegistry.getServices(a.uri).references.Linker.unlink(a),a.state=Math.min(a.state,U.ComputedScopes),a.diagnostics=void 0}),await this.emitUpdate(e,t),await Oe(r);const s=this.langiumDocuments.all.filter(a=>{var o;return a.state<U.Linked||!(!((o=this.buildState.get(a.uri.toString()))===null||o===void 0)&&o.completed)}).toArray();await this.buildDocuments(s,this.updateBuildOptions,r)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map(r=>r(e,t)))}shouldRelink(e,t){return e.references.some(r=>r.error!==void 0)?!0:this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),er.create(()=>{const t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)})}async buildDocuments(e,t,r){this.prepareBuild(e,t),await this.runCancelable(e,U.Parsed,r,s=>this.langiumDocumentFactory.update(s,r)),await this.runCancelable(e,U.IndexedContent,r,s=>this.indexManager.updateContent(s,r)),await this.runCancelable(e,U.ComputedScopes,r,async s=>{const a=this.serviceRegistry.getServices(s.uri).references.ScopeComputation;s.precomputedScopes=await a.computeLocalScopes(s,r)}),await this.runCancelable(e,U.Linked,r,s=>this.serviceRegistry.getServices(s.uri).references.Linker.link(s,r)),await this.runCancelable(e,U.IndexedReferences,r,s=>this.indexManager.updateReferences(s,r));const i=e.filter(s=>this.shouldValidate(s));await this.runCancelable(i,U.Validated,r,s=>this.validate(s,r));for(const s of e){const a=this.buildState.get(s.uri.toString());a&&(a.completed=!0)}}prepareBuild(e,t){for(const r of e){const i=r.uri.toString(),s=this.buildState.get(i);(!s||s.completed)&&this.buildState.set(i,{completed:!1,options:t,result:s==null?void 0:s.result})}}async runCancelable(e,t,r,i){const s=e.filter(a=>a.state<t);for(const a of s)await Oe(r),await i(a),a.state=t;await this.notifyBuildPhase(s,t,r),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),er.create(()=>{this.buildPhaseListeners.delete(e,t)})}waitUntil(e,t,r){let i;if(t&&"path"in t?i=t:r=t,r??(r=X.None),i){const s=this.langiumDocuments.getDocument(i);if(s&&s.state>e)return Promise.resolve(i)}return this.currentState>=e?Promise.resolve(void 0):r.isCancellationRequested?Promise.reject(Qn):new Promise((s,a)=>{const o=this.onBuildPhase(e,()=>{if(o.dispose(),c.dispose(),i){const l=this.langiumDocuments.getDocument(i);s(l==null?void 0:l.uri)}else s(void 0)}),c=r.onCancellationRequested(()=>{o.dispose(),c.dispose(),a(Qn)})})}async notifyBuildPhase(e,t,r){if(e.length===0)return;const i=this.buildPhaseListeners.get(t);for(const s of i)await Oe(r),await s(e,r)}shouldValidate(e){return!!this.getBuildOptions(e).validation}async validate(e,t){var r,i;const s=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,a=this.getBuildOptions(e).validation,o=typeof a=="object"?a:void 0,c=await s.validateDocument(e,o,t);e.diagnostics?e.diagnostics.push(...c):e.diagnostics=c;const l=this.buildState.get(e.uri.toString());if(l){(r=l.result)!==null&&r!==void 0||(l.result={});const u=(i=o==null?void 0:o.categories)!==null&&i!==void 0?i:Zn.all;l.result.validationChecks?l.result.validationChecks.push(...u):l.result.validationChecks=[...u]}}getBuildOptions(e){var t,r;return(r=(t=this.buildState.get(e.uri.toString()))===null||t===void 0?void 0:t.options)!==null&&r!==void 0?r:{}}}class Cm{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new pm,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){const r=Ue(e).uri,i=[];return this.referenceIndex.forEach(s=>{s.forEach(a=>{rt.equals(a.targetUri,r)&&a.targetPath===t&&i.push(a)})}),Q(i)}allElements(e,t){let r=Q(this.symbolIndex.keys());return t&&(r=r.filter(i=>!t||t.has(i))),r.map(i=>this.getFileDescriptions(i,e)).flat()}getFileDescriptions(e,t){var r;return t?this.symbolByTypeIndex.get(e,t,()=>{var s;return((s=this.symbolIndex.get(e))!==null&&s!==void 0?s:[]).filter(o=>this.astReflection.isSubtype(o.type,t))}):(r=this.symbolIndex.get(e))!==null&&r!==void 0?r:[]}remove(e){const t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=X.None){const i=await this.serviceRegistry.getServices(e.uri).references.ScopeComputation.computeExports(e,t),s=e.uri.toString();this.symbolIndex.set(s,i),this.symbolByTypeIndex.clear(s)}async updateReferences(e,t=X.None){const i=await this.serviceRegistry.getServices(e.uri).workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),i)}isAffected(e,t){const r=this.referenceIndex.get(e.uri.toString());return r?r.some(i=>!i.local&&t.has(i.targetUri.toString())):!1}}class _m{constructor(e){this.initialBuildOptions={},this._ready=new Wi,this.serviceRegistry=e.ServiceRegistry,this.langiumDocuments=e.workspace.LangiumDocuments,this.documentBuilder=e.workspace.DocumentBuilder,this.fileSystemProvider=e.workspace.FileSystemProvider,this.mutex=e.workspace.WorkspaceLock}get ready(){return this._ready.promise}initialize(e){var t;this.folders=(t=e.workspaceFolders)!==null&&t!==void 0?t:void 0}initialized(e){return this.mutex.write(t=>{var r;return this.initializeWorkspace((r=this.folders)!==null&&r!==void 0?r:[],t)})}async initializeWorkspace(e,t=X.None){const r=await this.performStartup(e);await Oe(t),await this.documentBuilder.build(r,this.initialBuildOptions,t)}async performStartup(e){const t=this.serviceRegistry.all.flatMap(s=>s.LanguageMetaData.fileExtensions),r=[],i=s=>{r.push(s),this.langiumDocuments.hasDocument(s.uri)||this.langiumDocuments.addDocument(s)};return await this.loadAdditionalDocuments(e,i),await Promise.all(e.map(s=>[s,this.getRootFolder(s)]).map(async s=>this.traverseFolder(...s,t,i))),this._ready.resolve(),r}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Ht.parse(e.uri)}async traverseFolder(e,t,r,i){const s=await this.fileSystemProvider.readDirectory(t);await Promise.all(s.map(async a=>{if(this.includeEntry(e,a,r)){if(a.isDirectory)await this.traverseFolder(e,a.uri,r,i);else if(a.isFile){const o=await this.langiumDocuments.getOrCreateDocument(a.uri);i(o)}}}))}includeEntry(e,t,r){const i=rt.basename(t.uri);if(i.startsWith("."))return!1;if(t.isDirectory)return i!=="node_modules"&&i!=="out";if(t.isFile){const s=rt.extname(t.uri);return r.includes(s)}return!1}}class wm{constructor(e){const t=e.parser.TokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(t);const r=Ka(t)?Object.values(t):t;this.chevrotainLexer=new de(r,{positionTracking:"full"})}get definition(){return this.tokenTypes}tokenize(e){var t;const r=this.chevrotainLexer.tokenize(e);return{tokens:r.tokens,errors:r.errors,hidden:(t=r.groups.hidden)!==null&&t!==void 0?t:[]}}toTokenTypeDictionary(e){if(Ka(e))return e;const t=ml(e)?Object.values(e.modes).flat():e,r={};return t.forEach(i=>r[i.name]=i),r}}function Lm(n){return Array.isArray(n)&&(n.length===0||"name"in n[0])}function ml(n){return n&&"modes"in n&&"defaultMode"in n}function Ka(n){return!Lm(n)&&!ml(n)}function $m(n,e,t){let r,i;typeof n=="string"?(i=e,r=t):(i=n.range.start,r=e),i||(i=P.create(0,0));const s=gl(n),a=Hi(r),o=Pm({lines:s,position:i,options:a});return Um({index:0,tokens:o,position:i})}function Om(n,e){const t=Hi(e),r=gl(n);if(r.length===0)return!1;const i=r[0],s=r[r.length-1],a=t.start,o=t.end;return!!(a!=null&&a.exec(i))&&!!(o!=null&&o.exec(s))}function gl(n){let e="";return typeof n=="string"?e=n:e=n.text,e.split(fd)}const za=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,bm=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function Pm(n){var e,t,r;const i=[];let s=n.position.line,a=n.position.character;for(let o=0;o<n.lines.length;o++){const c=o===0,l=o===n.lines.length-1;let u=n.lines[o],d=0;if(c&&n.options.start){const h=(e=n.options.start)===null||e===void 0?void 0:e.exec(u);h&&(d=h.index+h[0].length)}else{const h=(t=n.options.line)===null||t===void 0?void 0:t.exec(u);h&&(d=h.index+h[0].length)}if(l){const h=(r=n.options.end)===null||r===void 0?void 0:r.exec(u);h&&(u=u.substring(0,h.index))}if(u=u.substring(0,Gm(u)),gi(u,d)>=u.length){if(i.length>0){const h=P.create(s,a);i.push({type:"break",content:"",range:b.create(h,h)})}}else{za.lastIndex=d;const h=za.exec(u);if(h){const m=h[0],g=h[1],A=P.create(s,a+d),y=P.create(s,a+d+m.length);i.push({type:"tag",content:g,range:b.create(A,y)}),d+=m.length,d=gi(u,d)}if(d<u.length){const m=u.substring(d),g=Array.from(m.matchAll(bm));i.push(...Mm(g,m,s,a+d))}}s++,a=0}return i.length>0&&i[i.length-1].type==="break"?i.slice(0,-1):i}function Mm(n,e,t,r){const i=[];if(n.length===0){const s=P.create(t,r),a=P.create(t,r+e.length);i.push({type:"text",content:e,range:b.create(s,a)})}else{let s=0;for(const o of n){const c=o.index,l=e.substring(s,c);l.length>0&&i.push({type:"text",content:e.substring(s,c),range:b.create(P.create(t,s+r),P.create(t,c+r))});let u=l.length+1;const d=o[1];if(i.push({type:"inline-tag",content:d,range:b.create(P.create(t,s+u+r),P.create(t,s+u+d.length+r))}),u+=d.length,o.length===4){u+=o[2].length;const f=o[3];i.push({type:"text",content:f,range:b.create(P.create(t,s+u+r),P.create(t,s+u+f.length+r))})}else i.push({type:"text",content:"",range:b.create(P.create(t,s+u+r),P.create(t,s+u+r))});s=c+o[0].length}const a=e.substring(s);a.length>0&&i.push({type:"text",content:a,range:b.create(P.create(t,s+r),P.create(t,s+r+a.length))})}return i}const Dm=/\S/,Fm=/\s*$/;function gi(n,e){const t=n.substring(e).match(Dm);return t?e+t.index:n.length}function Gm(n){const e=n.match(Fm);if(e&&typeof e.index=="number")return e.index}function Um(n){var e,t,r,i;const s=P.create(n.position.line,n.position.character);if(n.tokens.length===0)return new qa([],b.create(s,s));const a=[];for(;n.index<n.tokens.length;){const l=Bm(n,a[a.length-1]);l&&a.push(l)}const o=(t=(e=a[0])===null||e===void 0?void 0:e.range.start)!==null&&t!==void 0?t:s,c=(i=(r=a[a.length-1])===null||r===void 0?void 0:r.range.end)!==null&&i!==void 0?i:s;return new qa(a,b.create(o,c))}function Bm(n,e){const t=n.tokens[n.index];if(t.type==="tag")return Tl(n,!1);if(t.type==="text"||t.type==="inline-tag")return yl(n);Vm(t,e),n.index++}function Vm(n,e){if(e){const t=new Al("",n.range);"inlines"in e?e.inlines.push(t):e.content.inlines.push(t)}}function yl(n){let e=n.tokens[n.index];const t=e;let r=e;const i=[];for(;e&&e.type!=="break"&&e.type!=="tag";)i.push(Wm(n)),r=e,e=n.tokens[n.index];return new yi(i,b.create(t.range.start,r.range.end))}function Wm(n){return n.tokens[n.index].type==="inline-tag"?Tl(n,!0):Rl(n)}function Tl(n,e){const t=n.tokens[n.index++],r=t.content.substring(1),i=n.tokens[n.index];if((i==null?void 0:i.type)==="text")if(e){const s=Rl(n);return new Or(r,new yi([s],s.range),e,b.create(t.range.start,s.range.end))}else{const s=yl(n);return new Or(r,s,e,b.create(t.range.start,s.range.end))}else{const s=t.range;return new Or(r,new yi([],s),e,s)}}function Rl(n){const e=n.tokens[n.index++];return new Al(e.content,e.range)}function Hi(n){if(!n)return Hi({start:"/**",end:"*/",line:"*"});const{start:e,end:t,line:r}=n;return{start:$r(e,!0),end:$r(t,!1),line:$r(r,!0)}}function $r(n,e){if(typeof n=="string"||typeof n=="object"){const t=typeof n=="string"?cr(n):n.source;return e?new RegExp(`^\\s*${t}`):new RegExp(`\\s*${t}\\s*$`)}else return n}class qa{constructor(e,t){this.elements=e,this.range=t}getTag(e){return this.getAllTags().find(t=>t.name===e)}getTags(e){return this.getAllTags().filter(t=>t.name===e)}getAllTags(){return this.elements.filter(e=>"name"in e)}toString(){let e="";for(const t of this.elements)if(e.length===0)e=t.toString();else{const r=t.toString();e+=Ya(e)+r}return e.trim()}toMarkdown(e){let t="";for(const r of this.elements)if(t.length===0)t=r.toMarkdown(e);else{const i=r.toMarkdown(e);t+=Ya(t)+i}return t.trim()}}class Or{constructor(e,t,r,i){this.name=e,this.content=t,this.inline=r,this.range=i}toString(){let e=`@${this.name}`;const t=this.content.toString();return this.content.inlines.length===1?e=`${e} ${t}`:this.content.inlines.length>1&&(e=`${e}
${t}`),this.inline?`{${e}}`:e}toMarkdown(e){var t,r;return(r=(t=e==null?void 0:e.renderTag)===null||t===void 0?void 0:t.call(e,this))!==null&&r!==void 0?r:this.toMarkdownDefault(e)}toMarkdownDefault(e){const t=this.content.toMarkdown(e);if(this.inline){const s=jm(this.name,t,e??{});if(typeof s=="string")return s}let r="";(e==null?void 0:e.tag)==="italic"||(e==null?void 0:e.tag)===void 0?r="*":(e==null?void 0:e.tag)==="bold"?r="**":(e==null?void 0:e.tag)==="bold-italic"&&(r="***");let i=`${r}@${this.name}${r}`;return this.content.inlines.length===1?i=`${i}${t}`:this.content.inlines.length>1&&(i=`${i}
${t}`),this.inline?`{${i}}`:i}}function jm(n,e,t){var r,i;if(n==="linkplain"||n==="linkcode"||n==="link"){const s=e.indexOf(" ");let a=e;if(s>0){const c=gi(e,s);a=e.substring(c),e=e.substring(0,s)}return(n==="linkcode"||n==="link"&&t.link==="code")&&(a=`\`${a}\``),(i=(r=t.renderLink)===null||r===void 0?void 0:r.call(t,e,a))!==null&&i!==void 0?i:Hm(e,a)}}function Hm(n,e){try{return Ht.parse(n,!0),`[${e}](${n})`}catch{return n}}class yi{constructor(e,t){this.inlines=e,this.range=t}toString(){let e="";for(let t=0;t<this.inlines.length;t++){const r=this.inlines[t],i=this.inlines[t+1];e+=r.toString(),i&&i.range.start.line>r.range.start.line&&(e+=`
`)}return e}toMarkdown(e){let t="";for(let r=0;r<this.inlines.length;r++){const i=this.inlines[r],s=this.inlines[r+1];t+=i.toMarkdown(e),s&&s.range.start.line>i.range.start.line&&(t+=`
`)}return t}}class Al{constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}}function Ya(n){return n.endsWith(`
`)?`
`:`
`}class Km{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){const t=this.commentProvider.getComment(e);if(t&&Om(t))return $m(t).toMarkdown({renderLink:(i,s)=>this.documentationLinkRenderer(e,i,s),renderTag:i=>this.documentationTagRenderer(e,i)})}documentationLinkRenderer(e,t,r){var i;const s=(i=this.findNameInPrecomputedScopes(e,t))!==null&&i!==void 0?i:this.findNameInGlobalScope(e,t);if(s&&s.nameSegment){const a=s.nameSegment.range.start.line+1,o=s.nameSegment.range.start.character+1,c=s.documentUri.with({fragment:`L${a},${o}`});return`[${r}](${c.toString()})`}else return}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){const i=Ue(e).precomputedScopes;if(!i)return;let s=e;do{const o=i.get(s).find(c=>c.name===t);if(o)return o;s=s.$container}while(s)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find(i=>i.name===t)}}class zm{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){var t;return ym(e)?e.$comment:(t=Lu(e.$cstNode,this.grammarConfig().multilineCommentRules))===null||t===void 0?void 0:t.text}}class qm{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e){return Promise.resolve(this.syncParser.parse(e))}}class Ym{constructor(){this.previousTokenSource=new fi,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();const t=new fi;return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,r){const i=new Wi,s={action:t,deferred:i,cancellationToken:r??X.None};return e.push(s),this.performNextOperation(),i.promise}async performNextOperation(){if(!this.done)return;const e=[];if(this.writeQueue.length>0)e.push(this.writeQueue.shift());else if(this.readQueue.length>0)e.push(...this.readQueue.splice(0,this.readQueue.length));else return;this.done=!1,await Promise.all(e.map(async({action:t,deferred:r,cancellationToken:i})=>{try{const s=await Promise.resolve().then(()=>t(i));r.resolve(s)}catch(s){Vi(s)?r.resolve(void 0):r.reject(s)}})),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}}class Xm{constructor(e){this.grammarElementIdMap=new Va,this.tokenTypeIdMap=new Va,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors.map(t=>Object.assign({},t)),parserErrors:e.parserErrors.map(t=>Object.assign({},t)),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}createDehyrationContext(e){const t=new Map,r=new Map;for(const i of vt(e))t.set(i,{});if(e.$cstNode)for(const i of Pr(e.$cstNode))r.set(i,{});return{astNodes:t,cstNodes:r}}dehydrateAstNode(e,t){const r=t.astNodes.get(e);r.$type=e.$type,r.$containerIndex=e.$containerIndex,r.$containerProperty=e.$containerProperty,e.$cstNode!==void 0&&(r.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(const[i,s]of Object.entries(e))if(!i.startsWith("$"))if(Array.isArray(s)){const a=[];r[i]=a;for(const o of s)ae(o)?a.push(this.dehydrateAstNode(o,t)):Ge(o)?a.push(this.dehydrateReference(o,t)):a.push(o)}else ae(s)?r[i]=this.dehydrateAstNode(s,t):Ge(s)?r[i]=this.dehydrateReference(s,t):s!==void 0&&(r[i]=s);return r}dehydrateReference(e,t){const r={};return r.$refText=e.$refText,e.$refNode&&(r.$refNode=t.cstNodes.get(e.$refNode)),r}dehydrateCstNode(e,t){const r=t.cstNodes.get(e);return go(e)?r.fullText=e.fullText:r.grammarSource=this.getGrammarElementId(e.grammarSource),r.hidden=e.hidden,r.astNode=t.astNodes.get(e.astNode),Gt(e)?r.content=e.content.map(i=>this.dehydrateCstNode(i,t)):mo(e)&&(r.tokenType=e.tokenType.name,r.offset=e.offset,r.length=e.length,r.startLine=e.range.start.line,r.startColumn=e.range.start.character,r.endLine=e.range.end.line,r.endColumn=e.range.end.character),r}hydrate(e){const t=e.value,r=this.createHydrationContext(t);return"$cstNode"in t&&this.hydrateCstNode(t.$cstNode,r),{lexerErrors:e.lexerErrors,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,r)}}createHydrationContext(e){const t=new Map,r=new Map;for(const s of vt(e))t.set(s,{});let i;if(e.$cstNode)for(const s of Pr(e.$cstNode)){let a;"fullText"in s?(a=new Zc(s.fullText),i=a):"content"in s?a=new Ui:"tokenType"in s&&(a=this.hydrateCstLeafNode(s)),a&&(r.set(s,a),a.root=i)}return{astNodes:t,cstNodes:r}}hydrateAstNode(e,t){const r=t.astNodes.get(e);r.$type=e.$type,r.$containerIndex=e.$containerIndex,r.$containerProperty=e.$containerProperty,e.$cstNode&&(r.$cstNode=t.cstNodes.get(e.$cstNode));for(const[i,s]of Object.entries(e))if(!i.startsWith("$"))if(Array.isArray(s)){const a=[];r[i]=a;for(const o of s)ae(o)?a.push(this.setParent(this.hydrateAstNode(o,t),r)):Ge(o)?a.push(this.hydrateReference(o,r,i,t)):a.push(o)}else ae(s)?r[i]=this.setParent(this.hydrateAstNode(s,t),r):Ge(s)?r[i]=this.hydrateReference(s,r,i,t):s!==void 0&&(r[i]=s);return r}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,r,i){return this.linker.buildReference(t,r,i.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,r=0){const i=t.cstNodes.get(e);if(typeof e.grammarSource=="number"&&(i.grammarSource=this.getGrammarElement(e.grammarSource)),i.astNode=t.astNodes.get(e.astNode),Gt(i))for(const s of e.content){const a=this.hydrateCstNode(s,t,r++);i.content.push(a)}return i}hydrateCstLeafNode(e){const t=this.getTokenType(e.tokenType),r=e.offset,i=e.length,s=e.startLine,a=e.startColumn,o=e.endLine,c=e.endColumn,l=e.hidden;return new oi(r,i,{start:{line:s,character:a},end:{line:o,character:c}},t,l)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){return this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){this.grammarElementIdMap.size===0&&this.createGrammarElementIdMap();const t=this.grammarElementIdMap.getKey(e);if(t)return t;throw new Error("Invalid grammar element id: "+e)}createGrammarElementIdMap(){let e=0;for(const t of vt(this.grammar))bu(t)&&this.grammarElementIdMap.set(t,e++)}}function Jt(n){return{documentation:{CommentProvider:e=>new zm(e),DocumentationProvider:e=>new Km(e)},parser:{AsyncParser:e=>new qm(e),GrammarConfig:e=>bd(e),LangiumParser:e=>Wp(e),CompletionParser:e=>Vp(e),ValueConverter:()=>new cl,TokenBuilder:()=>new ol,Lexer:e=>new wm(e),ParserErrorMessageProvider:()=>new nl},workspace:{AstNodeLocator:()=>new Im,AstNodeDescriptionProvider:e=>new km(e),ReferenceDescriptionProvider:e=>new Sm(e)},references:{Linker:e=>new om(e),NameProvider:()=>new lm,ScopeProvider:e=>new gm(e),ScopeComputation:e=>new dm(e),References:e=>new um(e)},serializer:{Hydrator:e=>new Xm(e),JsonSerializer:e=>new Tm(e)},validation:{DocumentValidator:e=>new vm(e),ValidationRegistry:e=>new Am(e)},shared:()=>n.shared}}function Qt(n){return{ServiceRegistry:()=>new Rm,workspace:{LangiumDocuments:e=>new am(e),LangiumDocumentFactory:e=>new sm(e),DocumentBuilder:e=>new Nm(e),IndexManager:e=>new Cm(e),WorkspaceManager:e=>new _m(e),FileSystemProvider:e=>n.fileSystemProvider(e),WorkspaceLock:()=>new Ym,ConfigurationProvider:e=>new xm(e)}}}var Xa;(function(n){n.merge=(e,t)=>tr(tr({},e),t)})(Xa||(Xa={}));function _e(n,e,t,r,i,s,a,o,c){const l=[n,e,t,r,i,s,a,o,c].reduce(tr,{});return vl(l)}const Ja=Symbol("isProxy");function vl(n,e){const t=new Proxy({},{deleteProperty:()=>!1,get:(r,i)=>Za(r,i,n,e||t),getOwnPropertyDescriptor:(r,i)=>(Za(r,i,n,e||t),Object.getOwnPropertyDescriptor(r,i)),has:(r,i)=>i in n,ownKeys:()=>[...Reflect.ownKeys(n),Ja]});return t[Ja]=!0,t}const Qa=Symbol();function Za(n,e,t,r){if(e in n){if(n[e]instanceof Error)throw new Error("Construction failure. Please make sure that your dependencies are constructable.",{cause:n[e]});if(n[e]===Qa)throw new Error('Cycle detected. Please make "'+String(e)+'" lazy. See https://langium.org/docs/configuration-services/#resolving-cyclic-dependencies');return n[e]}else if(e in t){const i=t[e];n[e]=Qa;try{n[e]=typeof i=="function"?i(r):vl(i,r)}catch(s){throw n[e]=s instanceof Error?s:void 0,s}return n[e]}else return}function tr(n,e){if(e){for(const[t,r]of Object.entries(e))if(r!==void 0){const i=n[t];i!==null&&r!==null&&typeof i=="object"&&typeof r=="object"?n[t]=tr(i,r):n[t]=r}}return n}class Jm{readFile(){throw new Error("No file system is available.")}async readDirectory(){return[]}}const Zt={fileSystemProvider:()=>new Jm},Qm={Grammar:()=>{},LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[".langium"],languageId:"langium"})},Zm={AstReflection:()=>new Jo};function eg(){const n=_e(Qt(Zt),Zm),e=_e(Jt({shared:n}),Qm);return n.ServiceRegistry.register(e),e}function An(n){var e;const t=eg(),r=t.serializer.JsonSerializer.deserialize(n);return t.shared.workspace.LangiumDocumentFactory.fromModel(r,Ht.parse(`memory://${(e=r.name)!==null&&e!==void 0?e:"grammar"}.langium`)),r}var tg=Object.defineProperty,x=(n,e)=>tg(n,"name",{value:e,configurable:!0}),ng="Statement",rg="Architecture";function ig(n){return Me.isInstance(n,rg)}x(ig,"isArchitecture");var El="Branch";function sg(n){return Me.isInstance(n,El)}x(sg,"isBranch");var ag="Checkout",og="CherryPicking",kl="Commit";function cg(n){return Me.isInstance(n,kl)}x(cg,"isCommit");var lg="Common";function ug(n){return Me.isInstance(n,lg)}x(ug,"isCommon");var Sl="GitGraph";function dg(n){return Me.isInstance(n,Sl)}x(dg,"isGitGraph");var fg="Info";function hg(n){return Me.isInstance(n,fg)}x(hg,"isInfo");var Il="Merge";function pg(n){return Me.isInstance(n,Il)}x(pg,"isMerge");var mg="Packet";function gg(n){return Me.isInstance(n,mg)}x(gg,"isPacket");var yg="PacketBlock";function Tg(n){return Me.isInstance(n,yg)}x(Tg,"isPacketBlock");var Rg="Pie";function Ag(n){return Me.isInstance(n,Rg)}x(Ag,"isPie");var vg="PieSection";function Eg(n){return Me.isInstance(n,vg)}x(Eg,"isPieSection");var kg="Direction",kt,xl=(kt=class extends po{getAllTypes(){return["Architecture","Branch","Checkout","CherryPicking","Commit","Common","Direction","Edge","GitGraph","Group","Info","Junction","Merge","Packet","PacketBlock","Pie","PieSection","Service","Statement"]}computeIsSubtype(e,t){switch(e){case El:case ag:case og:case kl:case Il:return this.isSubtype(ng,t);case kg:return this.isSubtype(Sl,t);default:return!1}}getReferenceType(e){const t=`${e.container.$type}:${e.property}`;switch(t){default:throw new Error(`${t} is not a valid reference id.`)}}getTypeMetaData(e){switch(e){case"Architecture":return{name:"Architecture",properties:[{name:"accDescr"},{name:"accTitle"},{name:"edges",defaultValue:[]},{name:"groups",defaultValue:[]},{name:"junctions",defaultValue:[]},{name:"services",defaultValue:[]},{name:"title"}]};case"Branch":return{name:"Branch",properties:[{name:"name"},{name:"order"}]};case"Checkout":return{name:"Checkout",properties:[{name:"branch"}]};case"CherryPicking":return{name:"CherryPicking",properties:[{name:"id"},{name:"parent"},{name:"tags",defaultValue:[]}]};case"Commit":return{name:"Commit",properties:[{name:"id"},{name:"message"},{name:"tags",defaultValue:[]},{name:"type"}]};case"Common":return{name:"Common",properties:[{name:"accDescr"},{name:"accTitle"},{name:"title"}]};case"Edge":return{name:"Edge",properties:[{name:"lhsDir"},{name:"lhsGroup",defaultValue:!1},{name:"lhsId"},{name:"lhsInto",defaultValue:!1},{name:"rhsDir"},{name:"rhsGroup",defaultValue:!1},{name:"rhsId"},{name:"rhsInto",defaultValue:!1},{name:"title"}]};case"GitGraph":return{name:"GitGraph",properties:[{name:"accDescr"},{name:"accTitle"},{name:"statements",defaultValue:[]},{name:"title"}]};case"Group":return{name:"Group",properties:[{name:"icon"},{name:"id"},{name:"in"},{name:"title"}]};case"Info":return{name:"Info",properties:[{name:"accDescr"},{name:"accTitle"},{name:"title"}]};case"Junction":return{name:"Junction",properties:[{name:"id"},{name:"in"}]};case"Merge":return{name:"Merge",properties:[{name:"branch"},{name:"id"},{name:"tags",defaultValue:[]},{name:"type"}]};case"Packet":return{name:"Packet",properties:[{name:"accDescr"},{name:"accTitle"},{name:"blocks",defaultValue:[]},{name:"title"}]};case"PacketBlock":return{name:"PacketBlock",properties:[{name:"end"},{name:"label"},{name:"start"}]};case"Pie":return{name:"Pie",properties:[{name:"accDescr"},{name:"accTitle"},{name:"sections",defaultValue:[]},{name:"showData",defaultValue:!1},{name:"title"}]};case"PieSection":return{name:"PieSection",properties:[{name:"label"},{name:"value"}]};case"Service":return{name:"Service",properties:[{name:"icon"},{name:"iconText"},{name:"id"},{name:"in"},{name:"title"}]};case"Direction":return{name:"Direction",properties:[{name:"accDescr"},{name:"accTitle"},{name:"dir"},{name:"statements",defaultValue:[]},{name:"title"}]};default:return{name:e,properties:[]}}}},x(kt,"MermaidAstReflection"),kt),Me=new xl,eo,Sg=x(()=>eo??(eo=An('{"$type":"Grammar","isDeclared":true,"name":"Info","imports":[],"rules":[{"$type":"ParserRule","name":"Info","entry":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[],"cardinality":"*"},{"$type":"Keyword","value":"info"},{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[],"cardinality":"*"},{"$type":"Group","elements":[{"$type":"Keyword","value":"showInfo"},{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[],"cardinality":"*"}],"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[],"cardinality":"?"}]},"definesHiddenTokens":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"TitleAndAccessibilities","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"accDescr","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@4"},"arguments":[]}},{"$type":"Assignment","feature":"accTitle","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[]}}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]}],"cardinality":"+"},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"EOL","fragment":true,"dataType":"string","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[],"cardinality":"+"},{"$type":"EndOfFile"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"NEWLINE","definition":{"$type":"RegexToken","regex":"/\\\\r?\\\\n/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_DESCR","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accDescr(?:[\\\\t ]*:([^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)|\\\\s*{([^}]*)})/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accTitle[\\\\t ]*:(?:[^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*title(?:[\\\\t ][^\\\\n\\\\r]*?(?=%%)|[\\\\t ][^\\\\n\\\\r]*|)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","hidden":true,"name":"WHITESPACE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]+/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"YAML","definition":{"$type":"RegexToken","regex":"/---[\\\\t ]*\\\\r?\\\\n(?:[\\\\S\\\\s]*?\\\\r?\\\\n)?---(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"DIRECTIVE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%{[\\\\S\\\\s]*?}%%(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"SINGLE_LINE_COMMENT","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%[^\\\\n\\\\r]*/"},"fragment":false}],"definesHiddenTokens":false,"hiddenTokens":[],"interfaces":[{"$type":"Interface","name":"Common","attributes":[{"$type":"TypeAttribute","name":"accDescr","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"accTitle","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"title","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}}],"superTypes":[]}],"types":[],"usedGrammars":[]}')),"InfoGrammar"),to,Ig=x(()=>to??(to=An(`{"$type":"Grammar","isDeclared":true,"name":"Packet","imports":[],"rules":[{"$type":"ParserRule","name":"Packet","entry":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"},{"$type":"Keyword","value":"packet-beta"},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@4"},"arguments":[]},{"$type":"Assignment","feature":"blocks","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]},"cardinality":"*"}]},{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"+"},{"$type":"Assignment","feature":"blocks","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]},"cardinality":"+"}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"}]}]},"definesHiddenTokens":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"PacketBlock","definition":{"$type":"Group","elements":[{"$type":"Assignment","feature":"start","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]}},{"$type":"Group","elements":[{"$type":"Keyword","value":"-"},{"$type":"Assignment","feature":"end","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]}}],"cardinality":"?"},{"$type":"Keyword","value":":"},{"$type":"Assignment","feature":"label","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[]}},{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"INT","type":{"$type":"ReturnType","name":"number"},"definition":{"$type":"RegexToken","regex":"/0|[1-9][0-9]*/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"STRING","definition":{"$type":"RegexToken","regex":"/\\"[^\\"]*\\"|'[^']*'/"},"fragment":false,"hidden":false},{"$type":"ParserRule","name":"TitleAndAccessibilities","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"accDescr","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@7"},"arguments":[]}},{"$type":"Assignment","feature":"accTitle","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@8"},"arguments":[]}},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@9"},"arguments":[]}}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}],"cardinality":"+"},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"EOL","fragment":true,"dataType":"string","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"+"},{"$type":"EndOfFile"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"NEWLINE","definition":{"$type":"RegexToken","regex":"/\\\\r?\\\\n/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_DESCR","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accDescr(?:[\\\\t ]*:([^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)|\\\\s*{([^}]*)})/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accTitle[\\\\t ]*:(?:[^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*title(?:[\\\\t ][^\\\\n\\\\r]*?(?=%%)|[\\\\t ][^\\\\n\\\\r]*|)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","hidden":true,"name":"WHITESPACE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]+/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"YAML","definition":{"$type":"RegexToken","regex":"/---[\\\\t ]*\\\\r?\\\\n(?:[\\\\S\\\\s]*?\\\\r?\\\\n)?---(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"DIRECTIVE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%{[\\\\S\\\\s]*?}%%(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"SINGLE_LINE_COMMENT","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%[^\\\\n\\\\r]*/"},"fragment":false}],"definesHiddenTokens":false,"hiddenTokens":[],"interfaces":[{"$type":"Interface","name":"Common","attributes":[{"$type":"TypeAttribute","name":"accDescr","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"accTitle","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"title","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}}],"superTypes":[]}],"types":[],"usedGrammars":[]}`)),"PacketGrammar"),no,xg=x(()=>no??(no=An('{"$type":"Grammar","isDeclared":true,"name":"Pie","imports":[],"rules":[{"$type":"ParserRule","name":"Pie","entry":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"},{"$type":"Keyword","value":"pie"},{"$type":"Assignment","feature":"showData","operator":"?=","terminal":{"$type":"Keyword","value":"showData"},"cardinality":"?"},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@4"},"arguments":[]},{"$type":"Assignment","feature":"sections","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]},"cardinality":"*"}]},{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"+"},{"$type":"Assignment","feature":"sections","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]},"cardinality":"+"}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"*"}]}]},"definesHiddenTokens":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"PieSection","definition":{"$type":"Group","elements":[{"$type":"Assignment","feature":"label","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]}},{"$type":"Keyword","value":":"},{"$type":"Assignment","feature":"value","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[]}},{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"PIE_SECTION_LABEL","definition":{"$type":"RegexToken","regex":"/\\"[^\\"]+\\"/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"PIE_SECTION_VALUE","type":{"$type":"ReturnType","name":"number"},"definition":{"$type":"RegexToken","regex":"/(0|[1-9][0-9]*)(\\\\.[0-9]+)?/"},"fragment":false,"hidden":false},{"$type":"ParserRule","name":"TitleAndAccessibilities","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"accDescr","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@7"},"arguments":[]}},{"$type":"Assignment","feature":"accTitle","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@8"},"arguments":[]}},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@9"},"arguments":[]}}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}],"cardinality":"+"},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"EOL","fragment":true,"dataType":"string","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[],"cardinality":"+"},{"$type":"EndOfFile"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"NEWLINE","definition":{"$type":"RegexToken","regex":"/\\\\r?\\\\n/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_DESCR","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accDescr(?:[\\\\t ]*:([^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)|\\\\s*{([^}]*)})/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accTitle[\\\\t ]*:(?:[^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*title(?:[\\\\t ][^\\\\n\\\\r]*?(?=%%)|[\\\\t ][^\\\\n\\\\r]*|)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","hidden":true,"name":"WHITESPACE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]+/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"YAML","definition":{"$type":"RegexToken","regex":"/---[\\\\t ]*\\\\r?\\\\n(?:[\\\\S\\\\s]*?\\\\r?\\\\n)?---(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"DIRECTIVE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%{[\\\\S\\\\s]*?}%%(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"SINGLE_LINE_COMMENT","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%[^\\\\n\\\\r]*/"},"fragment":false}],"definesHiddenTokens":false,"hiddenTokens":[],"interfaces":[{"$type":"Interface","name":"Common","attributes":[{"$type":"TypeAttribute","name":"accDescr","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"accTitle","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"title","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}}],"superTypes":[]}],"types":[],"usedGrammars":[]}')),"PieGrammar"),ro,Ng=x(()=>ro??(ro=An('{"$type":"Grammar","isDeclared":true,"name":"Architecture","imports":[],"rules":[{"$type":"ParserRule","name":"Architecture","entry":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[],"cardinality":"*"},{"$type":"Keyword","value":"architecture-beta"},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@16"},"arguments":[]}]},{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[],"cardinality":"*"}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[],"cardinality":"*"}]}]},"definesHiddenTokens":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Statement","fragment":true,"definition":{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"groups","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}},{"$type":"Assignment","feature":"services","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@6"},"arguments":[]}},{"$type":"Assignment","feature":"junctions","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@7"},"arguments":[]}},{"$type":"Assignment","feature":"edges","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@8"},"arguments":[]}}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"LeftPort","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Keyword","value":":"},{"$type":"Assignment","feature":"lhsDir","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@9"},"arguments":[]}}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"RightPort","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Assignment","feature":"rhsDir","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@9"},"arguments":[]}},{"$type":"Keyword","value":":"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Arrow","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]},{"$type":"Assignment","feature":"lhsInto","operator":"?=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@15"},"arguments":[]},"cardinality":"?"},{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"--"},{"$type":"Group","elements":[{"$type":"Keyword","value":"-"},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@13"},"arguments":[]}},{"$type":"Keyword","value":"-"}]}]},{"$type":"Assignment","feature":"rhsInto","operator":"?=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@15"},"arguments":[]},"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Group","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"group"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}},{"$type":"Assignment","feature":"icon","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@12"},"arguments":[]},"cardinality":"?"},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@13"},"arguments":[]},"cardinality":"?"},{"$type":"Group","elements":[{"$type":"Keyword","value":"in"},{"$type":"Assignment","feature":"in","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}}],"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Service","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"service"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}},{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"iconText","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@11"},"arguments":[]}},{"$type":"Assignment","feature":"icon","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@12"},"arguments":[]}}],"cardinality":"?"},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@13"},"arguments":[]},"cardinality":"?"},{"$type":"Group","elements":[{"$type":"Keyword","value":"in"},{"$type":"Assignment","feature":"in","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}}],"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Junction","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"junction"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}},{"$type":"Group","elements":[{"$type":"Keyword","value":"in"},{"$type":"Assignment","feature":"in","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}}],"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Edge","definition":{"$type":"Group","elements":[{"$type":"Assignment","feature":"lhsId","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}},{"$type":"Assignment","feature":"lhsGroup","operator":"?=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@14"},"arguments":[]},"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@4"},"arguments":[]},{"$type":"Assignment","feature":"rhsId","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@10"},"arguments":[]}},{"$type":"Assignment","feature":"rhsGroup","operator":"?=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@14"},"arguments":[]},"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"ARROW_DIRECTION","definition":{"$type":"TerminalAlternatives","elements":[{"$type":"TerminalAlternatives","elements":[{"$type":"TerminalAlternatives","elements":[{"$type":"CharacterRange","left":{"$type":"Keyword","value":"L"}},{"$type":"CharacterRange","left":{"$type":"Keyword","value":"R"}}]},{"$type":"CharacterRange","left":{"$type":"Keyword","value":"T"}}]},{"$type":"CharacterRange","left":{"$type":"Keyword","value":"B"}}]},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARCH_ID","definition":{"$type":"RegexToken","regex":"/[\\\\w]+/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARCH_TEXT_ICON","definition":{"$type":"RegexToken","regex":"/\\\\(\\"[^\\"]+\\"\\\\)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARCH_ICON","definition":{"$type":"RegexToken","regex":"/\\\\([\\\\w-:]+\\\\)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARCH_TITLE","definition":{"$type":"RegexToken","regex":"/\\\\[[\\\\w ]+\\\\]/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARROW_GROUP","definition":{"$type":"RegexToken","regex":"/\\\\{group\\\\}/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ARROW_INTO","definition":{"$type":"RegexToken","regex":"/<|>/"},"fragment":false,"hidden":false},{"$type":"ParserRule","name":"TitleAndAccessibilities","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"accDescr","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@19"},"arguments":[]}},{"$type":"Assignment","feature":"accTitle","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@21"},"arguments":[]}}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}],"cardinality":"+"},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"EOL","fragment":true,"dataType":"string","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[],"cardinality":"+"},{"$type":"EndOfFile"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"NEWLINE","definition":{"$type":"RegexToken","regex":"/\\\\r?\\\\n/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_DESCR","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accDescr(?:[\\\\t ]*:([^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)|\\\\s*{([^}]*)})/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accTitle[\\\\t ]*:(?:[^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*title(?:[\\\\t ][^\\\\n\\\\r]*?(?=%%)|[\\\\t ][^\\\\n\\\\r]*|)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","hidden":true,"name":"WHITESPACE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]+/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"YAML","definition":{"$type":"RegexToken","regex":"/---[\\\\t ]*\\\\r?\\\\n(?:[\\\\S\\\\s]*?\\\\r?\\\\n)?---(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"DIRECTIVE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%{[\\\\S\\\\s]*?}%%(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"SINGLE_LINE_COMMENT","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%[^\\\\n\\\\r]*/"},"fragment":false}],"definesHiddenTokens":false,"hiddenTokens":[],"interfaces":[{"$type":"Interface","name":"Common","attributes":[{"$type":"TypeAttribute","name":"accDescr","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"accTitle","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"title","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}}],"superTypes":[]}],"types":[],"usedGrammars":[]}')),"ArchitectureGrammar"),io,Cg=x(()=>io??(io=An(`{"$type":"Grammar","isDeclared":true,"name":"GitGraph","interfaces":[{"$type":"Interface","name":"Common","attributes":[{"$type":"TypeAttribute","name":"accDescr","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"accTitle","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}},{"$type":"TypeAttribute","name":"title","isOptional":true,"type":{"$type":"SimpleType","primitiveType":"string"}}],"superTypes":[]}],"rules":[{"$type":"ParserRule","name":"TitleAndAccessibilities","fragment":true,"definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Assignment","feature":"accDescr","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@3"},"arguments":[]}},{"$type":"Assignment","feature":"accTitle","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@4"},"arguments":[]}},{"$type":"Assignment","feature":"title","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@5"},"arguments":[]}}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}],"cardinality":"+"},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"EOL","fragment":true,"dataType":"string","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[],"cardinality":"+"},{"$type":"EndOfFile"}]},"definesHiddenTokens":false,"entry":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"NEWLINE","definition":{"$type":"RegexToken","regex":"/\\\\r?\\\\n/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_DESCR","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accDescr(?:[\\\\t ]*:([^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)|\\\\s*{([^}]*)})/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ACC_TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*accTitle[\\\\t ]*:(?:[^\\\\n\\\\r]*?(?=%%)|[^\\\\n\\\\r]*)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"TITLE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*title(?:[\\\\t ][^\\\\n\\\\r]*?(?=%%)|[\\\\t ][^\\\\n\\\\r]*|)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","hidden":true,"name":"WHITESPACE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]+/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"YAML","definition":{"$type":"RegexToken","regex":"/---[\\\\t ]*\\\\r?\\\\n(?:[\\\\S\\\\s]*?\\\\r?\\\\n)?---(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"DIRECTIVE","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%{[\\\\S\\\\s]*?}%%(?:\\\\r?\\\\n|(?!\\\\S))/"},"fragment":false},{"$type":"TerminalRule","hidden":true,"name":"SINGLE_LINE_COMMENT","definition":{"$type":"RegexToken","regex":"/[\\\\t ]*%%[^\\\\n\\\\r]*/"},"fragment":false},{"$type":"ParserRule","name":"GitGraph","entry":true,"definition":{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[],"cardinality":"*"},{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"gitGraph"},{"$type":"Group","elements":[{"$type":"Keyword","value":"gitGraph"},{"$type":"Keyword","value":":"}]},{"$type":"Keyword","value":"gitGraph:"},{"$type":"Group","elements":[{"$type":"Keyword","value":"gitGraph"},{"$type":"RuleCall","rule":{"$ref":"#/rules@12"},"arguments":[]},{"$type":"Keyword","value":":"}]}]},{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[],"cardinality":"*"},{"$type":"Group","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[],"cardinality":"*"},{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@0"},"arguments":[]},{"$type":"Assignment","feature":"statements","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@11"},"arguments":[]}},{"$type":"RuleCall","rule":{"$ref":"#/rules@2"},"arguments":[]}],"cardinality":"*"}]}]},"definesHiddenTokens":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Statement","definition":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@13"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@14"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@15"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@16"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@17"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Direction","definition":{"$type":"Assignment","feature":"dir","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"LR"},{"$type":"Keyword","value":"TB"},{"$type":"Keyword","value":"BT"}]}},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Commit","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"commit"},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"Keyword","value":"id:"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"msg:","cardinality":"?"},{"$type":"Assignment","feature":"message","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"tag:"},{"$type":"Assignment","feature":"tags","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"type:"},{"$type":"Assignment","feature":"type","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"NORMAL"},{"$type":"Keyword","value":"REVERSE"},{"$type":"Keyword","value":"HIGHLIGHT"}]}}]}],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Branch","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"branch"},{"$type":"Assignment","feature":"name","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@19"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}]}},{"$type":"Group","elements":[{"$type":"Keyword","value":"order:"},{"$type":"Assignment","feature":"order","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@18"},"arguments":[]}}],"cardinality":"?"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Merge","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"merge"},{"$type":"Assignment","feature":"branch","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@19"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}]}},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"Keyword","value":"id:"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"tag:"},{"$type":"Assignment","feature":"tags","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"type:"},{"$type":"Assignment","feature":"type","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"NORMAL"},{"$type":"Keyword","value":"REVERSE"},{"$type":"Keyword","value":"HIGHLIGHT"}]}}]}],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"Checkout","definition":{"$type":"Group","elements":[{"$type":"Alternatives","elements":[{"$type":"Keyword","value":"checkout"},{"$type":"Keyword","value":"switch"}]},{"$type":"Assignment","feature":"branch","operator":"=","terminal":{"$type":"Alternatives","elements":[{"$type":"RuleCall","rule":{"$ref":"#/rules@19"},"arguments":[]},{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}]}},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"ParserRule","name":"CherryPicking","definition":{"$type":"Group","elements":[{"$type":"Keyword","value":"cherry-pick"},{"$type":"Alternatives","elements":[{"$type":"Group","elements":[{"$type":"Keyword","value":"id:"},{"$type":"Assignment","feature":"id","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"tag:"},{"$type":"Assignment","feature":"tags","operator":"+=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]},{"$type":"Group","elements":[{"$type":"Keyword","value":"parent:"},{"$type":"Assignment","feature":"parent","operator":"=","terminal":{"$type":"RuleCall","rule":{"$ref":"#/rules@20"},"arguments":[]}}]}],"cardinality":"*"},{"$type":"RuleCall","rule":{"$ref":"#/rules@1"},"arguments":[]}]},"definesHiddenTokens":false,"entry":false,"fragment":false,"hiddenTokens":[],"parameters":[],"wildcard":false},{"$type":"TerminalRule","name":"INT","type":{"$type":"ReturnType","name":"number"},"definition":{"$type":"RegexToken","regex":"/[0-9]+(?=\\\\s)/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"ID","type":{"$type":"ReturnType","name":"string"},"definition":{"$type":"RegexToken","regex":"/\\\\w([-\\\\./\\\\w]*[-\\\\w])?/"},"fragment":false,"hidden":false},{"$type":"TerminalRule","name":"STRING","definition":{"$type":"RegexToken","regex":"/\\"[^\\"]*\\"|'[^']*'/"},"fragment":false,"hidden":false}],"definesHiddenTokens":false,"hiddenTokens":[],"imports":[],"types":[],"usedGrammars":[]}`)),"GitGraphGrammar"),_g={languageId:"info",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},wg={languageId:"packet",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Lg={languageId:"pie",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},$g={languageId:"architecture",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Og={languageId:"gitGraph",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},vn={AstReflection:x(()=>new xl,"AstReflection")},bg={Grammar:x(()=>Sg(),"Grammar"),LanguageMetaData:x(()=>_g,"LanguageMetaData"),parser:{}},Pg={Grammar:x(()=>Ig(),"Grammar"),LanguageMetaData:x(()=>wg,"LanguageMetaData"),parser:{}},Mg={Grammar:x(()=>xg(),"Grammar"),LanguageMetaData:x(()=>Lg,"LanguageMetaData"),parser:{}},Dg={Grammar:x(()=>Ng(),"Grammar"),LanguageMetaData:x(()=>$g,"LanguageMetaData"),parser:{}},Fg={Grammar:x(()=>Cg(),"Grammar"),LanguageMetaData:x(()=>Og,"LanguageMetaData"),parser:{}},Gg=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,Ug=/accTitle[\t ]*:([^\n\r]*)/,Bg=/title([\t ][^\n\r]*|)/,Vg={ACC_DESCR:Gg,ACC_TITLE:Ug,TITLE:Bg},St,Ki=(St=class extends cl{runConverter(e,t,r){let i=this.runCommonConverter(e,t,r);return i===void 0&&(i=this.runCustomConverter(e,t,r)),i===void 0?super.runConverter(e,t,r):i}runCommonConverter(e,t,r){const i=Vg[e.name];if(i===void 0)return;const s=i.exec(t);if(s!==null){if(s[1]!==void 0)return s[1].trim().replace(/[\t ]{2,}/gm," ");if(s[2]!==void 0)return s[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
`)}}},x(St,"AbstractMermaidValueConverter"),St),It,zi=(It=class extends Ki{runCustomConverter(e,t,r){}},x(It,"CommonValueConverter"),It),xt,en=(xt=class extends ol{constructor(e){super(),this.keywords=new Set(e)}buildKeywordTokens(e,t,r){const i=super.buildKeywordTokens(e,t,r);return i.forEach(s=>{this.keywords.has(s.name)&&s.PATTERN!==void 0&&(s.PATTERN=new RegExp(s.PATTERN.toString()+"(?:(?=%%)|(?!\\S))"))}),i}},x(xt,"AbstractMermaidTokenBuilder"),xt),Nt;Nt=class extends en{},x(Nt,"CommonTokenBuilder");var Ct,Wg=(Ct=class extends en{constructor(){super(["gitGraph"])}},x(Ct,"GitGraphTokenBuilder"),Ct),Nl={parser:{TokenBuilder:x(()=>new Wg,"TokenBuilder"),ValueConverter:x(()=>new zi,"ValueConverter")}};function Cl(n=Zt){const e=_e(Qt(n),vn),t=_e(Jt({shared:e}),Fg,Nl);return e.ServiceRegistry.register(t),{shared:e,GitGraph:t}}x(Cl,"createGitGraphServices");var _t,jg=(_t=class extends en{constructor(){super(["info","showInfo"])}},x(_t,"InfoTokenBuilder"),_t),_l={parser:{TokenBuilder:x(()=>new jg,"TokenBuilder"),ValueConverter:x(()=>new zi,"ValueConverter")}};function wl(n=Zt){const e=_e(Qt(n),vn),t=_e(Jt({shared:e}),bg,_l);return e.ServiceRegistry.register(t),{shared:e,Info:t}}x(wl,"createInfoServices");var wt,Hg=(wt=class extends en{constructor(){super(["packet-beta"])}},x(wt,"PacketTokenBuilder"),wt),Ll={parser:{TokenBuilder:x(()=>new Hg,"TokenBuilder"),ValueConverter:x(()=>new zi,"ValueConverter")}};function $l(n=Zt){const e=_e(Qt(n),vn),t=_e(Jt({shared:e}),Pg,Ll);return e.ServiceRegistry.register(t),{shared:e,Packet:t}}x($l,"createPacketServices");var Lt,Kg=(Lt=class extends en{constructor(){super(["pie","showData"])}},x(Lt,"PieTokenBuilder"),Lt),$t,zg=($t=class extends Ki{runCustomConverter(e,t,r){if(e.name==="PIE_SECTION_LABEL")return t.replace(/"/g,"").trim()}},x($t,"PieValueConverter"),$t),Ol={parser:{TokenBuilder:x(()=>new Kg,"TokenBuilder"),ValueConverter:x(()=>new zg,"ValueConverter")}};function bl(n=Zt){const e=_e(Qt(n),vn),t=_e(Jt({shared:e}),Mg,Ol);return e.ServiceRegistry.register(t),{shared:e,Pie:t}}x(bl,"createPieServices");var Ot,qg=(Ot=class extends en{constructor(){super(["architecture"])}},x(Ot,"ArchitectureTokenBuilder"),Ot),bt,Yg=(bt=class extends Ki{runCustomConverter(e,t,r){if(e.name==="ARCH_ICON")return t.replace(/[()]/g,"").trim();if(e.name==="ARCH_TEXT_ICON")return t.replace(/["()]/g,"");if(e.name==="ARCH_TITLE")return t.replace(/[[\]]/g,"").trim()}},x(bt,"ArchitectureValueConverter"),bt),Pl={parser:{TokenBuilder:x(()=>new qg,"TokenBuilder"),ValueConverter:x(()=>new Yg,"ValueConverter")}};function Ml(n=Zt){const e=_e(Qt(n),vn),t=_e(Jt({shared:e}),Dg,Pl);return e.ServiceRegistry.register(t),{shared:e,Architecture:t}}x(Ml,"createArchitectureServices");var ct={},Xg={info:x(async()=>{const{createInfoServices:n}=await tn(async()=>{const{createInfoServices:t}=await Promise.resolve().then(()=>Zg);return{createInfoServices:t}},void 0,import.meta.url),e=n().Info.parser.LangiumParser;ct.info=e},"info"),packet:x(async()=>{const{createPacketServices:n}=await tn(async()=>{const{createPacketServices:t}=await Promise.resolve().then(()=>ey);return{createPacketServices:t}},void 0,import.meta.url),e=n().Packet.parser.LangiumParser;ct.packet=e},"packet"),pie:x(async()=>{const{createPieServices:n}=await tn(async()=>{const{createPieServices:t}=await Promise.resolve().then(()=>ty);return{createPieServices:t}},void 0,import.meta.url),e=n().Pie.parser.LangiumParser;ct.pie=e},"pie"),architecture:x(async()=>{const{createArchitectureServices:n}=await tn(async()=>{const{createArchitectureServices:t}=await Promise.resolve().then(()=>ny);return{createArchitectureServices:t}},void 0,import.meta.url),e=n().Architecture.parser.LangiumParser;ct.architecture=e},"architecture"),gitGraph:x(async()=>{const{createGitGraphServices:n}=await tn(async()=>{const{createGitGraphServices:t}=await Promise.resolve().then(()=>ry);return{createGitGraphServices:t}},void 0,import.meta.url),e=n().GitGraph.parser.LangiumParser;ct.gitGraph=e},"gitGraph")};async function Jg(n,e){const t=Xg[n];if(!t)throw new Error(`Unknown diagram type: ${n}`);ct[n]||await t();const i=ct[n].parse(e);if(i.lexerErrors.length>0||i.parserErrors.length>0)throw new Qg(i);return i.value}x(Jg,"parse");var Pt,Qg=(Pt=class extends Error{constructor(e){const t=e.lexerErrors.map(i=>i.message).join(`
`),r=e.parserErrors.map(i=>i.message).join(`
`);super(`Parsing failed: ${t} ${r}`),this.result=e}},x(Pt,"MermaidParseError"),Pt);const Zg=Object.freeze(Object.defineProperty({__proto__:null,InfoModule:_l,createInfoServices:wl},Symbol.toStringTag,{value:"Module"})),ey=Object.freeze(Object.defineProperty({__proto__:null,PacketModule:Ll,createPacketServices:$l},Symbol.toStringTag,{value:"Module"})),ty=Object.freeze(Object.defineProperty({__proto__:null,PieModule:Ol,createPieServices:bl},Symbol.toStringTag,{value:"Module"})),ny=Object.freeze(Object.defineProperty({__proto__:null,ArchitectureModule:Pl,createArchitectureServices:Ml},Symbol.toStringTag,{value:"Module"})),ry=Object.freeze(Object.defineProperty({__proto__:null,GitGraphModule:Nl,createGitGraphServices:Cl},Symbol.toStringTag,{value:"Module"}));export{Jg as p};