@marimo-team/frontend 0.11.32-dev5 → 0.11.32-dev6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/assets/{ConnectedDataExplorerComponent-CQXlnMdE.js → ConnectedDataExplorerComponent-BC3iGE3d.js} +1 -1
  2. package/dist/assets/{VegaLite-D7d_ualJ.js → VegaLite-DO7G0f_H.js} +1 -1
  3. package/dist/assets/{_baseEach-CIsL5usq.js → _baseEach-DpbbGUyy.js} +1 -1
  4. package/dist/assets/_baseMap-CVBxxmb-.js +1 -0
  5. package/dist/assets/{_baseUniq-D-A_IFP9.js → _baseUniq-CvL-RqJ5.js} +1 -1
  6. package/dist/assets/{any-language-editor-BHYfqg7H.js → any-language-editor-BezjFcI8.js} +1 -1
  7. package/dist/assets/{architectureDiagram-UYN6MBPD-c8Zz1OxN.js → architectureDiagram-UYN6MBPD-BQxXuanB.js} +1 -1
  8. package/dist/assets/{blockDiagram-ZHA2E4KO-Ce6rkJ6q.js → blockDiagram-ZHA2E4KO-pDWh8siv.js} +1 -1
  9. package/dist/assets/{c4Diagram-6F5ED5ID-Cmuphdmf.js → c4Diagram-6F5ED5ID-DfGZ3ef1.js} +1 -1
  10. package/dist/assets/channel-bl3EhdNf.js +1 -0
  11. package/dist/assets/{chunk-5HRBRIJM-I1UwhM7H.js → chunk-5HRBRIJM-CM-j_YUt.js} +1 -1
  12. package/dist/assets/{chunk-7U56Z5CX-Wao8qUGR.js → chunk-7U56Z5CX-OYUAX-Il.js} +1 -1
  13. package/dist/assets/{chunk-ASOPGD6M-BvXzs8c4.js → chunk-ASOPGD6M-Cnjg4L7t.js} +1 -1
  14. package/dist/assets/{chunk-KFBOBJHC-By_PqNaa.js → chunk-KFBOBJHC-C3Ww6bgi.js} +1 -1
  15. package/dist/assets/{chunk-T2TOU4HS-BSjDq4yR.js → chunk-T2TOU4HS-BhuiU2Ge.js} +1 -1
  16. package/dist/assets/{chunk-TMUBEWPD-Br1hkDZs.js → chunk-TMUBEWPD-G7gidNyp.js} +1 -1
  17. package/dist/assets/classDiagram-LNE6IOMH-Dm6LkoYT.js +1 -0
  18. package/dist/assets/classDiagram-v2-MQ7JQ4JX-Dm6LkoYT.js +1 -0
  19. package/dist/assets/clone-B99LlreQ.js +1 -0
  20. package/dist/assets/{compile-Btp_Lfo5.js → compile-B7Pr4-Oc.js} +1 -1
  21. package/dist/assets/{dagre-4EVJKHTY-DC2by2Xz.js → dagre-4EVJKHTY-BZOqOO-x.js} +1 -1
  22. package/dist/assets/{data-editor-DTDWCXpe.js → data-editor-DkANsa7A.js} +1 -1
  23. package/dist/assets/{diagram-QW4FP2JN-D9-WvKjD.js → diagram-QW4FP2JN-CuV4iWJO.js} +1 -1
  24. package/dist/assets/{edit-page-CqVmRRKs.js → edit-page-CG9gObCn.js} +3 -3
  25. package/dist/assets/{erDiagram-6RL3IURR-oFkRbDam.js → erDiagram-6RL3IURR-V0UFVFZF.js} +1 -1
  26. package/dist/assets/{flowDiagram-7ASYPVHJ-Db5X4uej.js → flowDiagram-7ASYPVHJ-CdUqPZ5R.js} +1 -1
  27. package/dist/assets/{ganttDiagram-NTVNEXSI-BbUx0tft.js → ganttDiagram-NTVNEXSI-Ds80QcOV.js} +1 -1
  28. package/dist/assets/{gitGraph-YCYPL57B-DAdvAY3U.js → gitGraph-YCYPL57B-Ci_agIEd.js} +1 -1
  29. package/dist/assets/{gitGraphDiagram-NRZ2UAAF-DcYdkKfa.js → gitGraphDiagram-NRZ2UAAF-CrfWR2rB.js} +1 -1
  30. package/dist/assets/{graph-Ddyk21Kh.js → graph-rrfozC8h.js} +1 -1
  31. package/dist/assets/{home-page-BMrjnW1C.js → home-page-aJll6mZj.js} +1 -1
  32. package/dist/assets/{index-BedAp7CO.js → index-6eT98qWP.js} +1 -1
  33. package/dist/assets/{index-41PYUwHy.js → index-AMKaNHii.js} +1 -1
  34. package/dist/assets/{index-kbICcpKx.js → index-BWk3jiBX.js} +6 -6
  35. package/dist/assets/{index-C-5vqzq0.js → index-BteGdyKG.js} +1 -1
  36. package/dist/assets/{index-Cyjl5EFG.js → index-CAXah5y2.js} +1 -1
  37. package/dist/assets/{index-CnqsF6Vj.js → index-CPVoptLG.js} +1 -1
  38. package/dist/assets/{index-CZXIWN_V.js → index-CXCvY-Zo.js} +1 -1
  39. package/dist/assets/{index-BC_w9xFd.js → index-CeAFa12t.js} +1 -1
  40. package/dist/assets/{index-BW9sUGex.js → index-Cq1mPmf9.js} +1 -1
  41. package/dist/assets/{index-Cf7uaJKY.js → index-DDjBFbVK.js} +1 -1
  42. package/dist/assets/{index-CCngs23d.js → index-DLd1WGT7.js} +1 -1
  43. package/dist/assets/{index-C5T3eJ4f.js → index-DaiqUYiN.js} +1 -1
  44. package/dist/assets/{index-Dj9IU6k3.js → index-DwwFwgel.js} +1 -1
  45. package/dist/assets/{index-DkUTjBlH.js → index-HDq76YhA.js} +1 -1
  46. package/dist/assets/{index-CZ0zSvwg.js → index-Z3Oya8YV.js} +1 -1
  47. package/dist/assets/{index-9OqBoZSF.js → index-fdCO7afL.js} +1 -1
  48. package/dist/assets/{index-BfKvy_Nt.js → index-kUQEcsMP.js} +1 -1
  49. package/dist/assets/{infoDiagram-A4XQUW5V-DSDaImdM.js → infoDiagram-A4XQUW5V-D-7oYxHD.js} +1 -1
  50. package/dist/assets/{journeyDiagram-G5WM74LC-Dx98s5so.js → journeyDiagram-G5WM74LC-DxzLtPn2.js} +1 -1
  51. package/dist/assets/{kanban-definition-QRCXZQQD-5A_ARpXJ.js → kanban-definition-QRCXZQQD-CJ8QftVz.js} +1 -1
  52. package/dist/assets/{layout-BrlV2_5Q.js → layout-B9Dri2JR.js} +1 -1
  53. package/dist/assets/{linear-C2CJnR5t.js → linear-BecizTSI.js} +1 -1
  54. package/dist/assets/{mermaid-B0ipmvW6.js → mermaid-CHaP3AnD.js} +3 -3
  55. package/dist/assets/{min-Cfz4tNDD.js → min-UyCMjPNL.js} +1 -1
  56. package/dist/assets/{mindmap-definition-GWI6TPTV-DWgG92d4.js → mindmap-definition-GWI6TPTV-DWadk5yU.js} +1 -1
  57. package/dist/assets/{pieDiagram-YF2LJOPJ-BP-K8Ii6.js → pieDiagram-YF2LJOPJ-DZZY2-Sz.js} +1 -1
  58. package/dist/assets/{quadrantDiagram-OS5C2QUG-Bay25YLr.js → quadrantDiagram-OS5C2QUG-Df79q6z5.js} +1 -1
  59. package/dist/assets/{react-plotly-DVt2ChwI.js → react-plotly-DeJ1ok6E.js} +1 -1
  60. package/dist/assets/{requirementDiagram-MIRIMTAZ-BXodOm63.js → requirementDiagram-MIRIMTAZ-B5dsrqkz.js} +1 -1
  61. package/dist/assets/{run-page-C3MhDTzL.js → run-page-DPH4lByY.js} +1 -1
  62. package/dist/assets/{sankeyDiagram-Y46BX6SQ-B_6VhY49.js → sankeyDiagram-Y46BX6SQ-Bwv2IJbs.js} +1 -1
  63. package/dist/assets/{sequenceDiagram-G6AWOVSC-B-KaAtdv.js → sequenceDiagram-G6AWOVSC-Cm9mfXrD.js} +1 -1
  64. package/dist/assets/{slides-component-BEfV7XF2.js → slides-component-Bg9eRQ24.js} +1 -1
  65. package/dist/assets/{sortBy-DlSEDbdY.js → sortBy-usy_5Xwl.js} +1 -1
  66. package/dist/assets/{stateDiagram-MAYHULR4-D_737yKP.js → stateDiagram-MAYHULR4-DDCuvqHf.js} +1 -1
  67. package/dist/assets/stateDiagram-v2-4JROLMXI-ByLppbVs.js +1 -0
  68. package/dist/assets/{terminal-Bn-_OHQ2.js → terminal-6RFJyMYC.js} +1 -1
  69. package/dist/assets/{time-CmEFH_8Y.js → time-rLD3Qi79.js} +1 -1
  70. package/dist/assets/{timeline-definition-U7ZMHBDA-1PoBDVOh.js → timeline-definition-U7ZMHBDA-UL4sauao.js} +1 -1
  71. package/dist/assets/{tree-BMoJrVuZ.js → tree-QRHv3Uwe.js} +1 -1
  72. package/dist/assets/{useMarimoWebSocket-DZMVuVOo.js → useMarimoWebSocket-DaeW9NJe.js} +3 -3
  73. package/dist/assets/{vega-component-1XntqPil.js → vega-component-D4p6Gurz.js} +1 -1
  74. package/dist/assets/{xychartDiagram-6QU3TZC5-FogXBrhc.js → xychartDiagram-6QU3TZC5-ClOk33aG.js} +1 -1
  75. package/dist/index.html +1 -1
  76. package/package.json +1 -1
  77. package/dist/assets/_baseMap-3p3azeyY.js +0 -1
  78. package/dist/assets/channel-Cj3JRAU_.js +0 -1
  79. package/dist/assets/classDiagram-LNE6IOMH-Xr2ve7vl.js +0 -1
  80. package/dist/assets/classDiagram-v2-MQ7JQ4JX-Xr2ve7vl.js +0 -1
  81. package/dist/assets/clone-CirVQUCN.js +0 -1
  82. package/dist/assets/stateDiagram-v2-4JROLMXI-DWh5g1x4.js +0 -1
@@ -1 +1 @@
1
- var e,t,n,r,i,s,a,o,c,l,u,h,d=Object.defineProperty,f=(e,t,n)=>((e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);import{mW as p,d1 as m,m as g,cx as y,F as T,cO as v,af as R,cT as E,cU as A,y as k,A as S,z as I,bI as x,mX as N,cV as $,cG as C,mY as w,ai as L,cI as O,ae as _,mZ as b,cP as P,m_ as M,cX as D,D as U,ah as F,bM as G,m$ as B,n0 as K,n1 as j,n2 as V,d3 as H}from"./index-kbICcpKx.js";import{b as W,a as z}from"./_baseEach-CIsL5usq.js";import{g as Y,v as q,h as X,j as Q,k as J,a as Z,c as ee,i as te,r as ne,f as re,n as ie}from"./_baseUniq-D-A_IFP9.js";import{m as se,f as ae,h as oe,d as ce,l as le,c as ue}from"./min-Cfz4tNDD.js";import{a8 as he}from"./mermaid-B0ipmvW6.js";import{c as de}from"./clone-CirVQUCN.js";var fe=Object.prototype.hasOwnProperty,pe=p((function(e,t){if(m(t)||g(t))y(t,T(t),e);else for(var n in t)fe.call(t,n)&&v(e,n,t[n])}));function me(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var s=e[t];s&&(i[r++]=s)}return i}function ge(e,t,n,r){for(var i=-1,s=null==e?0:e.length;++i<s;){var a=e[i];t(r,a,n(a),e)}return r}function ye(e,t,n,r){return W(e,(function(e,i,s){t(r,e,n(e),s)})),r}var Te=k((function(e,t){return S(e)?function(e,t,n,r){var i=-1,s=Y,a=!0,o=e.length,c=[],l=t.length;if(!o)return c;t.length>=200&&(s=A,a=!1,t=new E(t));e:for(;++i<o;){var u=e[i],h=u;if(u=0!==u?u:0,a&&h==h){for(var d=l;d--;)if(t[d]===h)continue e;c.push(u)}else s(t,h,r)||c.push(u)}return c}(e,I(t,1,S,!0)):[]}));function ve(e,t,n){var r=null==e?0:e.length;return r?(t=void 0===t?1:x(t),N(e,t<0?0:t,r)):[]}function Re(e,t,n){var r=null==e?0:e.length;return r?(t=void 0===t?1:x(t),N(e,0,(t=r-t)<0?0:t)):[]}function Ee(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Ae(e,t){var n=!0;return W(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ke(e,t,n){return(R(e)?Ee:Ae)(e,z(t))}function Se(e){return e&&e.length?e[0]:void 0}function Ie(e,t){return I(se(e,t))}var xe,Ne,$e=Object.prototype.hasOwnProperty,Ce=(xe=function(e,t,n){$e.call(e,n)?e[n].push(t):$(e,n,[t])},function(e,t){var n=R(e)?ge:ye,r=Ne?Ne():{};return n(e,xe,z(t),r)});function we(e){return"string"==typeof e||!R(e)&&C(e)&&"[object String]"==w(e)}var Le=Math.max;function Oe(e,t,n,r){e=g(e)?e:q(e),n=n?x(n):0;var i=e.length;return n<0&&(n=Le(i+n,0)),we(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&X(e,t,n)>-1}function _e(e,t,n){if(!(null==e?0:e.length))return-1;return X(e,t,0)}var be=O&&O.isRegExp,Pe=be?L(be):function(e){return C(e)&&"[object RegExp]"==w(e)};function Me(e,t){if(null==e)return{};var n=_(Q(e),(function(e){return[e]}));return t=z(t),b(e,n,(function(e,n){return t(e,n[0])}))}function De(e,t){return(R(e)?P:J)(e,function(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}(z(t)))}function Ue(e,t){var n;return W(e,(function(e,r,i){return!(n=t(e,r,i))})),!!n}function Fe(e,t,n){return(R(e)?M:Ue)(e,z(t))}function Ge(e){return e&&e.length?Z(e):[]}function Be(e){return"object"==typeof e&&null!==e&&"string"==typeof e.$type}function Ke(e){return"object"==typeof e&&null!==e&&"string"==typeof e.$refText}function je(e){return"object"==typeof e&&null!==e&&Be(e.container)&&Ke(e.reference)&&"string"==typeof e.message}class Ve{constructor(){this.subtypes={},this.allSubtypes={}}isInstance(e,t){return Be(e)&&this.isSubtype(e.$type,t)}isSubtype(e,t){if(e===t)return!0;let n=this.subtypes[e];n||(n=this.subtypes[e]={});const r=n[t];if(void 0!==r)return r;{const r=this.computeIsSubtype(e,t);return n[t]=r,r}}getAllSubTypes(e){const t=this.allSubtypes[e];if(t)return t;{const t=this.getAllTypes(),n=[];for(const r of t)this.isSubtype(r,e)&&n.push(r);return this.allSubtypes[e]=n,n}}}function He(e){return"object"==typeof e&&null!==e&&Array.isArray(e.content)}function We(e){return"object"==typeof e&&null!==e&&"object"==typeof e.tokenType}function ze(e){return He(e)&&"string"==typeof e.fullText}class Ye{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(){const e=this.iterator();return Boolean(e.next().done)}count(){const e=this.iterator();let t=0,n=e.next();for(;!n.done;)t++,n=e.next();return t}toArray(){const e=[],t=this.iterator();let n;do{n=t.next(),void 0!==n.value&&e.push(n.value)}while(!n.done);return e}toSet(){return new Set(this)}toMap(e,t){const n=this.map((n=>[e?e(n):n,t?t(n):n]));return new Map(n)}toString(){return this.join()}concat(e){const t=e[Symbol.iterator]();return new Ye((()=>({first:this.startFn(),firstDone:!1})),(e=>{let n;if(!e.firstDone){do{if(n=this.nextFn(e.first),!n.done)return n}while(!n.done);e.firstDone=!0}do{if(n=t.next(),!n.done)return n}while(!n.done);return Je}))}join(e=","){const t=this.iterator();let n,r="",i=!1;do{n=t.next(),n.done||(i&&(r+=e),r+=qe(n.value)),i=!0}while(!n.done);return r}indexOf(e,t=0){const n=this.iterator();let r=0,i=n.next();for(;!i.done;){if(r>=t&&i.value===e)return r;i=n.next(),r++}return-1}every(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(!e(n.value))return!1;n=t.next()}return!0}some(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(e(n.value))return!0;n=t.next()}return!1}forEach(e){const t=this.iterator();let n=0,r=t.next();for(;!r.done;)e(r.value,n),r=t.next(),n++}map(e){return new Ye(this.startFn,(t=>{const{done:n,value:r}=this.nextFn(t);return n?Je:{done:!1,value:e(r)}}))}filter(e){return new Ye(this.startFn,(t=>{let n;do{if(n=this.nextFn(t),!n.done&&e(n.value))return n}while(!n.done);return Je}))}nonNullable(){return this.filter((e=>null!=e))}reduce(e,t){const n=this.iterator();let r=t,i=n.next();for(;!i.done;)r=void 0===r?i.value:e(r,i.value),i=n.next();return r}reduceRight(e,t){return this.recursiveReduce(this.iterator(),e,t)}recursiveReduce(e,t,n){const r=e.next();if(r.done)return n;const i=this.recursiveReduce(e,t,n);return void 0===i?r.value:t(i,r.value)}find(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(e(n.value))return n.value;n=t.next()}}findIndex(e){const t=this.iterator();let n=0,r=t.next();for(;!r.done;){if(e(r.value))return n;r=t.next(),n++}return-1}includes(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(n.value===e)return!0;n=t.next()}return!1}flatMap(e){return new Ye((()=>({this:this.startFn()})),(t=>{do{if(t.iterator){const e=t.iterator.next();if(!e.done)return e;t.iterator=void 0}const{done:n,value:r}=this.nextFn(t.this);if(!n){const n=e(r);if(!Xe(n))return{done:!1,value:n};t.iterator=n[Symbol.iterator]()}}while(t.iterator);return Je}))}flat(e){if(void 0===e&&(e=1),e<=0)return this;const t=e>1?this.flat(e-1):this;return new Ye((()=>({this:t.startFn()})),(e=>{do{if(e.iterator){const t=e.iterator.next();if(!t.done)return t;e.iterator=void 0}const{done:n,value:r}=t.nextFn(e.this);if(!n){if(!Xe(r))return{done:!1,value:r};e.iterator=r[Symbol.iterator]()}}while(e.iterator);return Je}))}head(){const e=this.iterator().next();if(!e.done)return e.value}tail(e=1){return new Ye((()=>{const t=this.startFn();for(let n=0;n<e;n++){if(this.nextFn(t).done)return t}return t}),this.nextFn)}limit(e){return new Ye((()=>({size:0,state:this.startFn()})),(t=>(t.size++,t.size>e?Je:this.nextFn(t.state))))}distinct(e){const t=new Set;return this.filter((n=>{const r=e?e(n):n;return!t.has(r)&&(t.add(r),!0)}))}exclude(e,t){const n=new Set;for(const r of e){const e=t?t(r):r;n.add(e)}return this.filter((e=>{const r=t?t(e):e;return!n.has(r)}))}}function qe(e){return"string"==typeof e?e:void 0===e?"undefined":"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)}function Xe(e){return!!e&&"function"==typeof e[Symbol.iterator]}const Qe=new Ye((()=>{}),(()=>Je)),Je=Object.freeze({done:!0,value:void 0});function Ze(...e){if(1===e.length){const t=e[0];if(t instanceof Ye)return t;if(Xe(t))return new Ye((()=>t[Symbol.iterator]()),(e=>e.next()));if("number"==typeof t.length)return new Ye((()=>({index:0})),(e=>e.index<t.length?{done:!1,value:t[e.index++]}:Je))}return e.length>1?new Ye((()=>({collIndex:0,arrIndex:0})),(t=>{do{if(t.iterator){const e=t.iterator.next();if(!e.done)return e;t.iterator=void 0}if(t.array){if(t.arrIndex<t.array.length)return{done:!1,value:t.array[t.arrIndex++]};t.array=void 0,t.arrIndex=0}if(t.collIndex<e.length){const n=e[t.collIndex++];Xe(n)?t.iterator=n[Symbol.iterator]():n&&"number"==typeof n.length&&(t.array=n)}}while(t.iterator||t.array||t.collIndex<e.length);return Je})):Qe}class et extends Ye{constructor(e,t,n){super((()=>({iterators:(null==n?void 0:n.includeRoot)?[[e][Symbol.iterator]()]:[t(e)[Symbol.iterator]()],pruned:!1})),(e=>{for(e.pruned&&(e.iterators.pop(),e.pruned=!1);e.iterators.length>0;){const n=e.iterators[e.iterators.length-1].next();if(!n.done)return e.iterators.push(t(n.value)[Symbol.iterator]()),n;e.iterators.pop()}return Je}))}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),prune:()=>{e.state.pruned=!0},[Symbol.iterator]:()=>e};return e}}var tt,nt,rt,it;function st(e){return new et(e,(e=>He(e)?e.content:[]),{includeRoot:!0})}function at(e){return{start:{character:e.startColumn-1,line:e.startLine-1},end:{character:e.endColumn,line:e.endLine-1}}}function ot(e){if(!e)return;const{offset:t,end:n,range:r}=e;return{range:r,offset:t,end:n,length:n-t}}function ct(e,t){const n=function(e,t){if(e.end.line<t.start.line||e.end.line===t.start.line&&e.end.character<e.start.character)return rt.Before;if(e.start.line>t.end.line||e.start.line===t.end.line&&e.start.character>t.end.character)return rt.After;const n=e.start.line>t.start.line||e.start.line===t.start.line&&e.start.character>=t.start.character,r=e.end.line<t.end.line||e.end.line===t.end.line&&e.end.character<=t.end.character;return n&&r?rt.Inside:n?rt.OverlapBack:rt.OverlapFront}(e,t);return n>rt.After}(nt=tt||(tt={})).sum=function(e){return e.reduce(((e,t)=>e+t),0)},nt.product=function(e){return e.reduce(((e,t)=>e*t),0)},nt.min=function(e){return e.reduce(((e,t)=>Math.min(e,t)))},nt.max=function(e){return e.reduce(((e,t)=>Math.max(e,t)))},(it=rt||(rt={}))[it.Before=0]="Before",it[it.After=1]="After",it[it.OverlapFront=2]="OverlapFront",it[it.OverlapBack=3]="OverlapBack",it[it.Inside=4]="Inside";const lt=/^[\w\p{L}]$/u;function ut(e,t){return We(e)&&t.includes(e.tokenType.name)}class ht extends Error{constructor(e,t){super(e?`${t} at ${e.range.start.line}:${e.range.start.character}`:t)}}function dt(e){throw new Error("Error! The input value was not handled.")}const ft="AbstractRule",pt="AbstractType",mt="Condition",gt="ValueLiteral",yt="AbstractElement";const Tt="BooleanLiteral";const vt="Conjunction";const Rt="Disjunction";const Et="InferredType";function At(e){return on.isInstance(e,Et)}const kt="Interface";function St(e){return on.isInstance(e,kt)}const It="Negation";const xt="ParameterReference";const Nt="ParserRule";function $t(e){return on.isInstance(e,Nt)}const Ct="SimpleType";const wt="TerminalRule";function Lt(e){return on.isInstance(e,wt)}const Ot="Type";function _t(e){return on.isInstance(e,Ot)}const bt="Action";function Pt(e){return on.isInstance(e,bt)}const Mt="Alternatives";function Dt(e){return on.isInstance(e,Mt)}const Ut="Assignment";function Ft(e){return on.isInstance(e,Ut)}const Gt="CharacterRange";const Bt="CrossReference";function Kt(e){return on.isInstance(e,Bt)}const jt="EndOfFile";const Vt="Group";function Ht(e){return on.isInstance(e,Vt)}const Wt="Keyword";function zt(e){return on.isInstance(e,Wt)}const Yt="NegatedToken";const qt="RegexToken";const Xt="RuleCall";function Qt(e){return on.isInstance(e,Xt)}const Jt="TerminalAlternatives";const Zt="TerminalGroup";const en="TerminalRuleCall";const tn="UnorderedGroup";function nn(e){return on.isInstance(e,tn)}const rn="UntilToken";const sn="Wildcard";class an extends Ve{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 bt:case Mt:case Ut:case Gt:case Bt:case jt:case Vt:case Wt:case Yt:case qt:case Xt:case Jt:case Zt:case en:case tn:case rn:case sn:return this.isSubtype(yt,t);case"ArrayLiteral":case"NumberLiteral":case"StringLiteral":return this.isSubtype(gt,t);case"ArrayType":case"ReferenceType":case Ct:case"UnionType":return this.isSubtype("TypeDefinition",t);case Tt:return this.isSubtype(mt,t)||this.isSubtype(gt,t);case vt:case Rt:case It:case xt:return this.isSubtype(mt,t);case Et:case kt:case Ot:return this.isSubtype(pt,t);case Nt:return this.isSubtype(ft,t)||this.isSubtype(pt,t);case wt:return this.isSubtype(ft,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 pt;case"Grammar:hiddenTokens":case"ParserRule:hiddenTokens":case"RuleCall:rule":return ft;case"Grammar:usedGrammars":return"Grammar";case"NamedArgument:parameter":case"ParameterReference:parameter":return"Parameter";case"TerminalRuleCall:rule":return wt;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 on=new an;function cn(e,t){let n=e;for(;n;){if(t(n))return n;n=n.$container}}function ln(e){const t=function(e){for(;e.$container;)e=e.$container;return e}(e),n=t.$document;if(!n)throw new Error("AST node has no document.");return n}function un(e,t){if(!e)throw new Error("Node must be an AstNode.");const n=null==t?void 0:t.range;return new Ye((()=>({keys:Object.keys(e),keyIndex:0,arrayIndex:0})),(t=>{for(;t.keyIndex<t.keys.length;){const r=t.keys[t.keyIndex];if(!r.startsWith("$")){const i=e[r];if(Be(i)){if(t.keyIndex++,fn(i,n))return{done:!1,value:i}}else if(Array.isArray(i)){for(;t.arrayIndex<i.length;){const e=i[t.arrayIndex++];if(Be(e)&&fn(e,n))return{done:!1,value:e}}t.arrayIndex=0}}t.keyIndex++}return Je}))}function hn(e,t){if(!e)throw new Error("Root node must be an AstNode.");return new et(e,(e=>un(e,t)))}function dn(e,t){if(!e)throw new Error("Root node must be an AstNode.");return new et(e,(e=>un(e,t)),{includeRoot:!0})}function fn(e,t){var n;if(!t)return!0;const r=null===(n=e.$cstNode)||void 0===n?void 0:n.range;return!!r&&ct(r,t)}function pn(e){return new Ye((()=>({keys:Object.keys(e),keyIndex:0,arrayIndex:0})),(t=>{for(;t.keyIndex<t.keys.length;){const n=t.keys[t.keyIndex];if(!n.startsWith("$")){const r=e[n];if(Ke(r))return t.keyIndex++,{done:!1,value:{reference:r,container:e,property:n}};if(Array.isArray(r)){for(;t.arrayIndex<r.length;){const i=t.arrayIndex++,s=r[i];if(Ke(s))return{done:!1,value:{reference:s,container:e,property:n,index:i}}}t.arrayIndex=0}}t.keyIndex++}return Je}))}function mn(e){return Array.isArray(e)?[...e.map(mn)]:e}function gn(e){return e.charCodeAt(0)}function yn(e,t){Array.isArray(e)?e.forEach((function(e){t.push(e)})):t.push(e)}function Tn(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function vn(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function Rn(e){return"Character"===e.type}const En=[];for(let gu=gn("0");gu<=gn("9");gu++)En.push(gu);const An=[gn("_")].concat(En);for(let gu=gn("a");gu<=gn("z");gu++)An.push(gu);for(let gu=gn("A");gu<=gn("Z");gu++)An.push(gu);const kn=[gn(" "),gn("\f"),gn("\n"),gn("\r"),gn("\t"),gn("\v"),gn("\t"),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn("\u2028"),gn("\u2029"),gn(" "),gn(" "),gn(" "),gn("\ufeff")],Sn=/[0-9a-fA-F]/,In=/[0-9]/,xn=/[1-9]/;class Nn{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 n={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":Tn(n,"global");break;case"i":Tn(n,"ignoreCase");break;case"m":Tn(n,"multiLine");break;case"u":Tn(n,"unicode");break;case"y":Tn(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,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"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead"}vn(t);const n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}return function(){throw Error("Internal Error - Should never get here!")}()}quantifier(e=!1){let t;const n=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 n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;vn(t)}if(!0!==e||void 0!==t)return vn(t)?("?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t):void 0}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()}if(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),vn(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[gn("\n"),gn("\r"),gn("\u2028"),gn("\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=En;break;case"D":e=En,t=!0;break;case"s":e=kn;break;case"S":e=kn,t=!0;break;case"w":e=An;break;case"W":e=An,t=!0}if(vn(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=gn("\f");break;case"n":e=gn("\n");break;case"r":e=gn("\r");break;case"t":e=gn("\t");break;case"v":e=gn("\v")}if(vn(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:gn("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:gn(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:gn(this.popChar())}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const t=this.classAtom();if(t.type,Rn(t)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,Rn(n)){if(n.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:n.value})}else yn(t.value,e),e.push(gn("-")),yn(n.value,e)}else yn(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":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:gn("\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;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),e=!1;else this.groupIdx++;const t=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(!1===xn.test(e))throw Error("Expecting a positive integer");for(;In.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===In.test(e))throw Error("Expecting an integer");for(;In.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case"\n":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:gn(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 In.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":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 void 0!==this.quantifier(!0)}catch(t){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let n=0;n<e;n++){const e=this.popChar();if(!1===Sn.test(e))throw Error("Expecting a HexDecimal digits");t+=e}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(void 0!==e&&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 $n{visitChildren(e){for(const t in e){const n=e[t];e.hasOwnProperty(t)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((e=>{this.visit(e)}),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)}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 Cn=/\r?\n/gm,wn=new Nn;const Ln=new class extends $n{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||"\n"!==t||(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const e=bn(t);this.endRegexpStack.push(e),this.isStarting&&(this.startRegexp+=e)}}visitSet(e){if(!this.multiline){const t=this.regex.substring(e.loc.begin,e.loc.end),n=new RegExp(t);this.multiline=Boolean("\n".match(n))}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){if("Group"===e.type){if(e.quantifier)return}super.visitChildren(e)}};function On(e){try{return"string"==typeof e&&(e=new RegExp(e)),e=e.toString(),Ln.reset(e),Ln.visit(wn.pattern(e)),Ln.multiline}catch(t){return!1}}function _n(e){return("string"==typeof e?new RegExp(e):e).test(" ")}function bn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pn(e,t){const n=function(e){"string"==typeof e&&(e=new RegExp(e));const t=e,n=e.source;let r=0;function i(){let e,s="";function a(e){s+=n.substr(r,e),r+=e}function o(e){s+="(?:"+n.substr(r,e)+"|$)",r+=e}for(;r<n.length;)switch(n[r]){case"\\":switch(n[r+1]){case"c":o(3);break;case"x":o(4);break;case"u":t.unicode?"{"===n[r+2]?o(n.indexOf("}",r)-r+1):o(6):o(2);break;case"p":case"P":t.unicode?o(n.indexOf("}",r)-r+1):o(2);break;case"k":o(n.indexOf(">",r)-r+1);break;default:o(2)}break;case"[":e=/\[(?:\\.|.)*?\]/g,e.lastIndex=r,e=e.exec(n)||[],o(e[0].length);break;case"|":case"^":case"$":case"*":case"+":case"?":a(1);break;case"{":e=/\{\d+,?\d*\}/g,e.lastIndex=r,e=e.exec(n),e?a(e[0].length):o(1);break;case"(":if("?"===n[r+1])switch(n[r+2]){case":":s+="(?:",r+=3,s+=i()+"|$)";break;case"=":s+="(?=",r+=3,s+=i()+")";break;case"!":e=r,r+=3,i(),s+=n.substr(e,r-e);break;case"<":switch(n[r+3]){case"=":case"!":e=r,r+=4,i(),s+=n.substr(e,r-e);break;default:a(n.indexOf(">",r)-r+1),s+=i()+"|$)"}}else a(1),s+=i()+"|$)";break;case")":return++r,s;default:o(1)}return s}return new RegExp(i(),e.flags)}(e),r=t.match(n);return!!r&&r[0].length>0}function Mn(e,t){const n=new Set,r=function(e){return e.rules.find((e=>$t(e)&&e.entry))}(e);if(!r)return new Set(e.rules);const i=[r].concat(function(e){return e.rules.filter((e=>Lt(e)&&e.hidden))}(e));for(const a of i)Dn(a,n,t);const s=new Set;for(const a of e.rules)(n.has(a.name)||Lt(a)&&a.hidden)&&s.add(a);return s}function Dn(e,t,n){t.add(e.name),hn(e).forEach((e=>{if(Qt(e)||n){const r=e.rule.ref;r&&!t.has(r.name)&&Dn(r,t,n)}}))}function Un(e,t,n){if(!e||!t)return;const r=Fn(e,t,e.astNode,!0);return 0!==r.length?r[n=void 0!==n?Math.max(0,Math.min(n,r.length-1)):0]:void 0}function Fn(e,t,n,r){if(!r){const n=cn(e.grammarSource,Ft);if(n&&n.feature===t)return[e]}return He(e)&&e.astNode===n?e.content.flatMap((e=>Fn(e,t,n,!1))):[]}function Gn(e,t,n){if(!e)return;const r=function(e,t,n){if(e.astNode!==n)return[];if(zt(e.grammarSource)&&e.grammarSource.value===t)return[e];const r=st(e).iterator();let i;const s=[];do{if(i=r.next(),!i.done){const e=i.value;e.astNode===n?zt(e.grammarSource)&&e.grammarSource.value===t&&s.push(e):r.prune()}}while(!i.done);return s}(e,t,null==e?void 0:e.astNode);return 0!==r.length?r[n=void 0!==n?Math.max(0,Math.min(n,r.length-1)):0]:void 0}function Bn(e){let t=e;return At(t)&&(Pt(t.$container)?t=t.$container.$container:$t(t.$container)?t=t.$container:dt(t.$container)),Kn(e,t,new Map)}function Kn(e,t,n){var r,i;function s(t,r){let i;return cn(t,Ft)||(i=Kn(r,r,n)),n.set(e,i),i}if(n.has(e))return n.get(e);n.set(e,void 0);for(const a of hn(t)){if(Ft(a)&&"name"===a.feature.toLowerCase())return n.set(e,a),a;if(Qt(a)&&$t(a.rule.ref))return s(a,a.rule.ref);if(i=a,on.isInstance(i,Ct)&&(null===(r=a.typeRef)||void 0===r?void 0:r.ref))return s(a,a.typeRef.ref)}}function jn(e){return Vn(e,new Set)}function Vn(e,t){if(t.has(e))return!0;t.add(e);for(const n of hn(e))if(Qt(n)){if(!n.rule.ref)return!1;if($t(n.rule.ref)&&!Vn(n.rule.ref,t))return!1}else{if(Ft(n))return!1;if(Pt(n))return!1}return Boolean(e.definition)}function Hn(e){if(e.inferredType)return e.inferredType.name;if(e.dataType)return e.dataType;if(e.returnType){const t=e.returnType.ref;if(t){if($t(t))return t.name;if(St(t)||_t(t))return t.name}}}function Wn(e){var t,n;if($t(e))return jn(e)?e.name:null!==(t=Hn(e))&&void 0!==t?t:e.name;if(St(e)||_t(e)||(n=e,on.isInstance(n,"ReturnType")))return e.name;if(Pt(e)){const t=function(e){var t;if(e.inferredType)return e.inferredType.name;if(null===(t=e.type)||void 0===t?void 0:t.ref)return Wn(e.type.ref);return}(e);if(t)return t}else if(At(e))return e.name;throw new Error("Cannot get name of Unknown Type")}function zn(e){const t={s:!1,i:!1,u:!1},n=qn(e.definition,t),r=Object.entries(t).filter((([,e])=>e)).map((([e])=>e)).join("");return new RegExp(n,r)}const Yn=/[\s\S]/.source;function qn(e,t){if(a=e,on.isInstance(a,Jt))return Qn((s=e).elements.map((e=>qn(e))).join("|"),{cardinality:s.cardinality,lookahead:s.lookahead});if(function(e){return on.isInstance(e,Zt)}(e))return Qn((i=e).elements.map((e=>qn(e))).join(""),{cardinality:i.cardinality,lookahead:i.lookahead});if(function(e){return on.isInstance(e,Gt)}(e))return function(e){if(e.right)return Qn(`[${Xn(e.left)}-${Xn(e.right)}]`,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1});return Qn(Xn(e.left),{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}(e);if(function(e){return on.isInstance(e,en)}(e)){const t=e.rule.ref;if(!t)throw new Error("Missing rule reference.");return Qn(qn(t.definition),{cardinality:e.cardinality,lookahead:e.lookahead})}if(function(e){return on.isInstance(e,Yt)}(e))return Qn(`(?!${qn((r=e).terminal)})${Yn}*?`,{cardinality:r.cardinality,lookahead:r.lookahead});if(function(e){return on.isInstance(e,rn)}(e))return Qn(`${Yn}*?${qn((n=e).terminal)}`,{cardinality:n.cardinality,lookahead:n.lookahead});if(function(e){return on.isInstance(e,qt)}(e)){const n=e.regex.lastIndexOf("/"),r=e.regex.substring(1,n),i=e.regex.substring(n+1);return t&&(t.i=i.includes("i"),t.s=i.includes("s"),t.u=i.includes("u")),Qn(r,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}if(function(e){return on.isInstance(e,sn)}(e))return Qn(Yn,{cardinality:e.cardinality,lookahead:e.lookahead});throw new Error(`Invalid terminal element: ${null==e?void 0:e.$type}`);var n,r,i,s,a}function Xn(e){return bn(e.value)}function Qn(e,t){var n;return(!1!==t.wrap||t.lookahead)&&(e=`(${null!==(n=t.lookahead)&&void 0!==n?n:""}${e})`),t.cardinality?`${e}${t.cardinality}`:e}function Jn(e){console&&console.error&&console.error(`Error: ${e}`)}function Zn(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function er(e){const t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}}function tr(e){function t(){}t.prototype=e;const n=new t;function r(){return typeof n.bar}return r(),r(),e}function nr(e){return we((t=e).LABEL)&&""!==t.LABEL?e.LABEL:e.name;var t}class rr{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),ee(this.definition,(t=>{t.accept(e)}))}}class ir extends rr{constructor(e){super([]),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class sr extends rr{constructor(e){super(e.definition),this.orgText="",pe(this,Me(e,(e=>void 0!==e)))}}class ar extends rr{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,pe(this,Me(e,(e=>void 0!==e)))}}class or extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class cr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class lr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class ur extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class hr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class dr extends rr{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,pe(this,Me(e,(e=>void 0!==e)))}}class fr{constructor(e){this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}accept(e){e.visit(this)}}function pr(e){function t(e){return se(e,pr)}if(e instanceof ir){const t={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return we(e.label)&&(t.label=e.label),t}if(e instanceof ar)return{type:"Alternative",definition:t(e.definition)};if(e instanceof or)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof cr)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof lr)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:pr(new fr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof hr)return{type:"RepetitionWithSeparator",idx:e.idx,separator:pr(new fr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ur)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof dr)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof fr){const t={type:"Terminal",name:e.terminalType.name,label:nr(e.terminalType),idx:e.idx};we(e.label)&&(t.terminalLabel=e.label);const n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=Pe(n)?n.source:n),t}if(e instanceof sr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}class mr{visit(e){const t=e;switch(t.constructor){case ir:return this.visitNonTerminal(t);case ar:return this.visitAlternative(t);case or:return this.visitOption(t);case cr:return this.visitRepetitionMandatory(t);case lr:return this.visitRepetitionMandatoryWithSeparator(t);case hr:return this.visitRepetitionWithSeparator(t);case ur:return this.visitRepetition(t);case dr:return this.visitAlternation(t);case fr:return this.visitTerminal(t);case sr: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 gr(e,t=[]){return!!(e instanceof or||e instanceof ur||e instanceof hr)||(e instanceof dr?Fe(e.definition,(e=>gr(e,t))):!(e instanceof ir&&Oe(t,e))&&(e instanceof rr&&(e instanceof ir&&t.push(e),ke(e.definition,(e=>gr(e,t))))))}function yr(e){if(e instanceof ir)return"SUBRULE";if(e instanceof or)return"OPTION";if(e instanceof dr)return"OR";if(e instanceof cr)return"AT_LEAST_ONE";if(e instanceof lr)return"AT_LEAST_ONE_SEP";if(e instanceof hr)return"MANY_SEP";if(e instanceof ur)return"MANY";if(e instanceof fr)return"CONSUME";throw Error("non exhaustive match")}class Tr{walk(e,t=[]){ee(e.definition,((n,r)=>{const i=ve(e.definition,r+1);if(n instanceof ir)this.walkProdRef(n,i,t);else if(n instanceof fr)this.walkTerminal(n,i,t);else if(n instanceof ar)this.walkFlat(n,i,t);else if(n instanceof or)this.walkOption(n,i,t);else if(n instanceof cr)this.walkAtLeastOne(n,i,t);else if(n instanceof lr)this.walkAtLeastOneSep(n,i,t);else if(n instanceof hr)this.walkManySep(n,i,t);else if(n instanceof ur)this.walkMany(n,i,t);else{if(!(n instanceof dr))throw Error("non exhaustive match");this.walkOr(n,i,t)}}))}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){const r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){const r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){const r=[new or({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){const r=vr(e,t,n);this.walk(e,r)}walkMany(e,t,n){const r=[new or({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){const r=vr(e,t,n);this.walk(e,r)}walkOr(e,t,n){const r=t.concat(n);ee(e.definition,(e=>{const t=new ar({definition:[e]});this.walk(t,r)}))}}function vr(e,t,n){return[new or({definition:[new fr({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function Rr(e){if(e instanceof ir)return Rr(e.referencedRule);if(e instanceof fr)return[e.terminalType];if(function(e){return e instanceof ar||e instanceof or||e instanceof ur||e instanceof cr||e instanceof lr||e instanceof hr||e instanceof fr||e instanceof sr}(e))return function(e){let t=[];const n=e.definition;let r,i=0,s=n.length>i,a=!0;for(;s&&a;)r=n[i],a=gr(r),t=t.concat(Rr(r)),i+=1,s=n.length>i;return Ge(t)}(e);if(function(e){return e instanceof dr}(e))return function(e){const t=se(e.definition,(e=>Rr(e)));return Ge(D(t))}(e);throw Error("non exhaustive match")}const Er="_~IN~_";class Ar extends Tr{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){const r=(i=e.referencedRule,s=e.idx,i.name+s+Er+this.topProd.name);var i,s;const a=t.concat(n),o=Rr(new ar({definition:a}));this.follows[r]=o}}let kr={};const Sr=new Nn;function Ir(e){const t=e.toString();if(kr.hasOwnProperty(t))return kr[t];{const e=Sr.pattern(t);return kr[t]=e,e}}const xr="Complement Sets are not supported for first char optimization",Nr='Unable to use "first char" lexer optimizations:\n';function $r(e,t=!1){try{const t=Ir(e);return Cr(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===xr)t&&Zn(`${Nr}\tUnable to optimize: < ${e.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Jn(`${Nr}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Cr(e,t,n){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)Cr(e.value[i],t,n);break;case"Alternative":const r=e.value;for(let e=0;e<r.length;e++){const i=r[e];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const s=i;switch(s.type){case"Character":wr(s.value,t,n);break;case"Set":if(!0===s.complement)throw Error(xr);ee(s.value,(e=>{if("number"==typeof e)wr(e,t,n);else{const r=e;if(!0===n)for(let e=r.from;e<=r.to;e++)wr(e,t,n);else{for(let e=r.from;e<=r.to&&e<Jr;e++)wr(e,t,n);if(r.to>=Jr){const e=r.from>=Jr?r.from:Jr,n=r.to,i=ei(e),s=ei(n);for(let r=i;r<=s;r++)t[r]=r}}}}));break;case"Group":Cr(s.value,t,n);break;default:throw Error("Non Exhaustive Match")}const a=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===Or(s)||"Group"!==s.type&&!1===a)break}break;default:throw Error("non exhaustive match!")}return q(t)}function wr(e,t,n){const r=ei(e);t[r]=r,!0===n&&function(e,t){const n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){const e=ei(r.charCodeAt(0));t[e]=e}else{const e=n.toLowerCase();if(e!==n){const n=ei(e.charCodeAt(0));t[n]=n}}}(e,t)}function Lr(e,t){return ae(e.value,(e=>{if("number"==typeof e)return Oe(t,e);{const n=e;return void 0!==ae(t,(e=>n.from<=e&&e<=n.to))}}))}function Or(e){const t=e.quantifier;return!(!t||0!==t.atLeast)||!!e.value&&(R(e.value)?ke(e.value,Or):Or(e.value))}class _r extends $n{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}super.visitChildren(e)}}visitCharacter(e){Oe(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===Lr(e,this.targetCharCodes)&&(this.found=!0):void 0!==Lr(e,this.targetCharCodes)&&(this.found=!0)}}function br(e,t){if(t instanceof RegExp){const n=Ir(t),r=new _r(e);return r.visit(n),r.found}return void 0!==ae(t,(t=>Oe(e,t.charCodeAt(0))))}const Pr="PATTERN",Mr="defaultMode",Dr="modes";let Ur="boolean"==typeof new RegExp("(?:)").sticky;function Fr(e,t){const n=(t=ce(t,{useSticky:Ur,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",(()=>{!function(){if(he(Zr)){Zr=new Array(65536);for(let e=0;e<65536;e++)Zr[e]=e>255?255+~~(e/255):e}}()})),n("Reject Lexer.NA",(()=>{r=De(e,(e=>e[Pr]===pi.NA))}));let i,s,a,o,c,l,u,h,d,f,p,m=!1;n("Transform Patterns",(()=>{m=!1,i=se(r,(e=>{const n=e[Pr];if(Pe(n)){const e=n.source;return 1!==e.length||"^"===e||"$"===e||"."===e||n.ignoreCase?2!==e.length||"\\"!==e[0]||Oe(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?t.useSticky?Vr(n):jr(n):e[1]:e}if(U(n))return m=!0,{exec:n};if("object"==typeof n)return m=!0,n;if("string"==typeof n){if(1===n.length)return n;{const e=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=new RegExp(e);return t.useSticky?Vr(r):jr(r)}}throw Error("non exhaustive match")}))})),n("misc mapping",(()=>{s=se(r,(e=>e.tokenTypeIdx)),a=se(r,(e=>{const t=e.GROUP;if(t!==pi.SKIPPED){if(we(t))return t;if(te(t))return!1;throw Error("non exhaustive match")}})),o=se(r,(e=>{const t=e.LONGER_ALT;if(t){return R(t)?se(t,(e=>_e(r,e))):[_e(r,t)]}})),c=se(r,(e=>e.PUSH_MODE)),l=se(r,(e=>oe(e,"POP_MODE")))})),n("Line Terminator Handling",(()=>{const e=Xr(t.lineTerminatorCharacters);u=se(r,(e=>!1)),"onlyOffset"!==t.positionTracking&&(u=se(r,(t=>oe(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===qr(t,e)&&br(e,t.PATTERN))))})),n("Misc Mapping #2",(()=>{h=se(r,Wr),d=se(i,zr),f=ne(r,((e,t)=>{const n=t.GROUP;return we(n)&&n!==pi.SKIPPED&&(e[n]=[]),e}),{}),p=se(i,((e,t)=>({pattern:i[t],longerAlt:o[t],canLineTerminator:u[t],isCustom:h[t],short:d[t],group:a[t],push:c[t],pop:l[t],tokenTypeIdx:s[t],tokenType:r[t]})))}));let g=!0,y=[];return t.safeMode||n("First Char Optimization",(()=>{y=ne(r,((e,n,r)=>{if("string"==typeof n.PATTERN){const t=ei(n.PATTERN.charCodeAt(0));Qr(e,t,p[r])}else if(R(n.START_CHARS_HINT)){let t;ee(n.START_CHARS_HINT,(n=>{const i=ei("string"==typeof n?n.charCodeAt(0):n);t!==i&&(t=i,Qr(e,i,p[r]))}))}else if(Pe(n.PATTERN))if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&Jn(`${Nr}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const i=$r(n.PATTERN,t.ensureOptimizations);he(i)&&(g=!1),ee(i,(t=>{Qr(e,t,p[r])}))}else t.ensureOptimizations&&Jn(`${Nr}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e}),[])})),{emptyGroups:f,patternIdxToConfig:p,charCodeToPatternIdxToConfig:y,hasCustom:m,canBeOptimized:g}}function Gr(e,t){let n=[];const r=function(e){const t=re(e,(e=>!oe(e,Pr))),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:hi.MISSING_PATTERN,tokenTypes:[e]}))),r=Te(e,t);return{errors:n,valid:r}}(e);n=n.concat(r.errors);const i=function(e){const t=re(e,(e=>{const t=e[Pr];return!(Pe(t)||U(t)||oe(t,"exec")||we(t))})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:hi.INVALID_PATTERN,tokenTypes:[e]}))),r=Te(e,t);return{errors:n,valid:r}}(r.valid),s=i.valid;return n=n.concat(i.errors),n=n.concat(function(e){let t=[];const n=re(e,(e=>Pe(e[Pr])));return t=t.concat(function(e){class t extends $n{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}const n=re(e,(e=>{const n=e.PATTERN;try{const e=Ir(n),r=new t;return r.visit(e),r.found}catch(r){return Br.test(n.source)}})),r=se(n,(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:hi.EOI_ANCHOR_FOUND,tokenTypes:[e]})));return r}(n)),t=t.concat(function(e){class t extends $n{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}const n=re(e,(e=>{const n=e.PATTERN;try{const e=Ir(n),r=new t;return r.visit(e),r.found}catch(r){return Kr.test(n.source)}})),r=se(n,(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:hi.SOI_ANCHOR_FOUND,tokenTypes:[e]})));return r}(n)),t=t.concat(function(e){const t=re(e,(e=>{const t=e[Pr];return t instanceof RegExp&&(t.multiline||t.global)})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:hi.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]})));return n}(n)),t=t.concat(function(e){const t=[];let n=se(e,(n=>ne(e,((e,r)=>(n.PATTERN.source!==r.PATTERN.source||Oe(t,r)||r.PATTERN===pi.NA||(t.push(r),e.push(r)),e)),[])));n=me(n);const r=re(n,(e=>e.length>1)),i=se(r,(e=>{const t=se(e,(e=>e.name));return{message:`The same RegExp pattern ->${Se(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:hi.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}}));return i}(n)),t=t.concat(function(e){const t=re(e,(e=>e.PATTERN.test(""))),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:hi.EMPTY_MATCH_PATTERN,tokenTypes:[e]})));return n}(n)),t}(s)),n=n.concat(function(e){const t=re(e,(e=>{if(!oe(e,"GROUP"))return!1;const t=e.GROUP;return t!==pi.SKIPPED&&t!==pi.NA&&!we(t)})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:hi.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]})));return n}(s)),n=n.concat(function(e,t){const n=re(e,(e=>void 0!==e.PUSH_MODE&&!Oe(t,e.PUSH_MODE))),r=se(n,(e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:hi.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]})));return r}(s,t)),n=n.concat(function(e){const t=[],n=ne(e,((e,t,n)=>{const r=t.PATTERN;return r===pi.NA||(we(r)?e.push({str:r,idx:n,tokenType:t}):Pe(r)&&(i=r,void 0===ae([".","\\","[","]","|","^","$","(",")","?","*","+","{"],(e=>-1!==i.source.indexOf(e))))&&e.push({str:r.source,idx:n,tokenType:t})),e;var i}),[]);return ee(e,((e,r)=>{ee(n,(({str:n,idx:i,tokenType:s})=>{if(r<i&&function(e,t){if(Pe(t)){const n=t.exec(e);return null!==n&&0===n.index}if(U(t))return t(e,0,[],{});if(oe(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(n,e.PATTERN)){const n=`Token: ->${s.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:hi.UNREACHABLE_PATTERN,tokenTypes:[e,s]})}}))})),t}(s)),n}const Br=/[^\\][$]/;const Kr=/[^\\[][\^]|^\^/;function jr(e){const t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function Vr(e){const t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function Hr(e,t,n){const r=[];let i=!1;const s=De(me(D(q(e.modes))),(e=>e[Pr]===pi.NA)),a=Xr(n);return t&&ee(s,(e=>{const t=qr(e,a);if(!1!==t){const n=function(e,t){if(t.issue===hi.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===hi.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${e.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),i={message:n,type:t.issue,tokenType:e};r.push(i)}else oe(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(i=!0):br(a,e.PATTERN)&&(i=!0)})),t&&!i&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:hi.NO_LINE_BREAKS_FLAGS}),r}function Wr(e){const t=e.PATTERN;if(Pe(t))return!1;if(U(t))return!0;if(oe(t,"exec"))return!0;if(we(t))return!1;throw Error("non exhaustive match")}function zr(e){return!(!we(e)||1!==e.length)&&e.charCodeAt(0)}const Yr={test:function(e){const t=e.length;for(let n=this.lastIndex;n<t;n++){const t=e.charCodeAt(n);if(10===t)return this.lastIndex=n+1,!0;if(13===t)return 10===e.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function qr(e,t){if(oe(e,"LINE_BREAKS"))return!1;if(Pe(e.PATTERN)){try{br(t,e.PATTERN)}catch(n){return{issue:hi.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}if(we(e.PATTERN))return!1;if(Wr(e))return{issue:hi.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function Xr(e){return se(e,(e=>we(e)?e.charCodeAt(0):e))}function Qr(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}const Jr=256;let Zr=[];function ei(e){return e<Jr?e:Zr[e]}function ti(e,t){const n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]}function ni(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let ri=1;const ii={};function si(e){const t=function(e){let t=de(e),n=e,r=!0;for(;r;){n=me(D(se(n,(e=>e.CATEGORIES))));const e=Te(n,t);t=t.concat(e),he(e)?r=!1:n=e}return t}(e);!function(e){ee(e,(e=>{oi(e)||(ii[ri]=e,e.tokenTypeIdx=ri++),ci(e)&&!R(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),ci(e)||(e.CATEGORIES=[]),oe(e,"categoryMatches")||(e.categoryMatches=[]),function(e){return oe(e,"categoryMatchesMap")}(e)||(e.categoryMatchesMap={})}))}(t),function(e){ee(e,(e=>{ai([],e)}))}(t),function(e){ee(e,(e=>{e.categoryMatches=[],ee(e.categoryMatchesMap,((t,n)=>{e.categoryMatches.push(ii[n].tokenTypeIdx)}))}))}(t),ee(t,(e=>{e.isParent=e.categoryMatches.length>0}))}function ai(e,t){ee(e,(e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0})),ee(t.CATEGORIES,(n=>{const r=e.concat(t);Oe(r,n)||ai(r,n)}))}function oi(e){return oe(e,"tokenTypeIdx")}function ci(e){return oe(e,"CATEGORIES")}function li(e){return oe(e,"tokenTypeIdx")}const ui={buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,n,r,i)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`};var hi,di;(di=hi||(hi={}))[di.MISSING_PATTERN=0]="MISSING_PATTERN",di[di.INVALID_PATTERN=1]="INVALID_PATTERN",di[di.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",di[di.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",di[di.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",di[di.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",di[di.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",di[di.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",di[di.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",di[di.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",di[di.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",di[di.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",di[di.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",di[di.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",di[di.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",di[di.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",di[di.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",di[di.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";const fi={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ui,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(fi);class pi{constructor(e,t=fi){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=(e,t)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=er(t),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=pe({},fi,t);const n=this.config.traceInitPerf;!0===n?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof n&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(()=>{let n,r=!0;this.TRACE_INIT("Lexer Config handling",(()=>{if(this.config.lineTerminatorsPattern===fi.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Yr;else if(this.config.lineTerminatorCharacters===fi.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor 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),R(e)?n={modes:{defaultMode:de(e)},defaultMode:Mr}:(r=!1,n=de(e))})),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",(()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e){const t=[];return oe(e,Mr)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+Mr+"> property in its definition\n",type:hi.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),oe(e,Dr)||t.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:hi.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),oe(e,Dr)&&oe(e,Mr)&&!oe(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${Mr}: <${e.defaultMode}>which does not exist\n`,type:hi.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),oe(e,Dr)&&ee(e.modes,((e,n)=>{ee(e,((r,i)=>{if(te(r))t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,type:hi.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(oe(r,"LONGER_ALT")){const i=R(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT];ee(i,(i=>{te(i)||Oe(e,i)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${r.name}> outside of mode <${n}>\n`,type:hi.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})}))}}))})),t}(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),this.TRACE_INIT("performWarningRuntimeChecks",(()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Hr(n,this.trackStartLines,this.config.lineTerminatorCharacters))}))),n.modes=n.modes?n.modes:{},ee(n.modes,((e,t)=>{n.modes[t]=De(e,(e=>te(e)))}));const i=T(n.modes);if(ee(n.modes,((e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,(()=>{if(this.modes.push(n),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",(()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Gr(e,i))})),he(this.lexerDefinitionErrors)){let r;si(e),this.TRACE_INIT("analyzeTokenTypes",(()=>{r=Fr(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})})),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=pe({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}}))})),this.defaultMode=n.defaultMode,!he(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const e=se(this.lexerDefinitionErrors,(e=>e.message)).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+e)}ee(this.lexerDefinitionWarning,(e=>{Zn(e.message)})),this.TRACE_INIT("Choosing sub-methods implementations",(()=>{if(Ur?(this.chopInput=F,this.match=this.matchWithTest):(this.updateLastIndex=ie,this.match=this.matchWithExec),r&&(this.handleModes=ie),!1===this.trackStartLines&&(this.computeNewColumn=F),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=ie),/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))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}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 e=ne(this.canModeBeOptimized,((e,t,n)=>(!1===t&&e.push(n),e)),[]);if(t.ensureOptimizations&&!he(e))throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)})),this.TRACE_INIT("clearRegExpParserCache",(()=>{kr={}})),this.TRACE_INIT("toFastProperties",(()=>{tr(this)}))}))}tokenize(e,t=this.defaultMode){if(!he(this.lexerDefinitionErrors)){const e=se(this.lexerDefinitionErrors,(e=>e.message)).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,s,a,o,c,l,u,h,d,f,p,m,g;const y=e,v=y.length;let E=0,A=0;const k=this.hasCustom?0:Math.floor(e.length/10),S=new Array(k),I=[];let x=this.trackStartLines?1:void 0,N=this.trackStartLines?1:void 0;const $=function(e){const t={},n=T(e);return ee(n,(n=>{const r=e[n];if(!R(r))throw Error("non exhaustive match");t[n]=[]})),t}(this.emptyGroups),C=this.trackStartLines,w=this.config.lineTerminatorsPattern;let L=0,O=[],_=[];const b=[],P=[];let M;function D(){return O}function U(e){const t=ei(e),n=_[t];return void 0===n?P:n}Object.freeze(P);const F=e=>{if(1===b.length&&void 0===e.tokenType.PUSH_MODE){const t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);I.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{b.pop();const e=le(b);O=this.patternIdxToConfig[e],_=this.charCodeToPatternIdxToConfig[e],L=O.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=_&&t?U:D}};function G(e){b.push(e),_=this.charCodeToPatternIdxToConfig[e],O=this.patternIdxToConfig[e],L=O.length,L=O.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=_&&t?U:D}let B;G.call(this,t);const K=this.config.recoveryEnabled;for(;E<v;){o=null;const t=y.charCodeAt(E),T=M(t),R=T.length;for(n=0;n<R;n++){B=T[n];const r=B.pattern;c=null;const u=B.short;if(!1!==u?t===u&&(o=r):!0===B.isCustom?(g=r.exec(y,E,S,$),null!==g?(o=g[0],void 0!==g.payload&&(c=g.payload)):o=null):(this.updateLastIndex(r,E),o=this.match(r,e,E)),null!==o){if(a=B.longerAlt,void 0!==a){const t=a.length;for(i=0;i<t;i++){const t=O[a[i]],n=t.pattern;if(l=null,!0===t.isCustom?(g=n.exec(y,E,S,$),null!==g?(s=g[0],void 0!==g.payload&&(l=g.payload)):s=null):(this.updateLastIndex(n,E),s=this.match(n,e,E)),s&&s.length>o.length){o=s,c=l,B=t;break}}}break}}if(null!==o){if(u=o.length,h=B.group,void 0!==h&&(d=B.tokenTypeIdx,f=this.createTokenInstance(o,E,d,B.tokenType,x,N,u),this.handlePayload(f,c),!1===h?A=this.addToken(S,A,f):$[h].push(f)),e=this.chopInput(e,u),E+=u,N=this.computeNewColumn(N,u),!0===C&&!0===B.canLineTerminator){let e,t,n=0;w.lastIndex=0;do{e=w.test(o),!0===e&&(t=w.lastIndex-1,n++)}while(!0===e);0!==n&&(x+=n,N=u-t,this.updateTokenEndLineColumnLocation(f,h,t,n,x,N,u))}this.handleModes(B,F,G,f)}else{const t=E,n=x,i=N;let s=!1===K;for(;!1===s&&E<v;)for(e=this.chopInput(e,1),E++,r=0;r<L;r++){const t=O[r],n=t.pattern,i=t.short;if(!1!==i?y.charCodeAt(E)===i&&(s=!0):!0===t.isCustom?s=null!==n.exec(y,E,S,$):(this.updateLastIndex(n,E),s=null!==n.exec(e)),!0===s)break}if(p=E-t,N=this.computeNewColumn(N,p),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(y,t,p,n,i),I.push({offset:t,line:n,column:i,length:p,message:m}),!1===K)break}}return this.hasCustom||(S.length=A),{tokens:S,groups:$,errors:I}}handleModes(e,t,n,r){if(!0===e.pop){const i=e.push;t(r),void 0!==i&&n.call(this,i)}else void 0!==e.push&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,s,a){let o,c;void 0!==t&&(o=n===a-1,c=o?-1:0,1===r&&!0===o||(e.endLine=i+c,e.endColumn=s-1-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,s){return{image:e,startOffset:t,startLine:i,startColumn:s,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,s,a){return{image:e,startOffset:t,endOffset:t+a-1,startLine:i,endLine:i,startColumn:s,endColumn:s+a-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}matchWithTest(e,t,n){return!0===e.test(t)?t.substring(n,e.lastIndex):null}matchWithExec(e,t){const n=e.exec(t);return null!==n?n[0]:null}}function mi(e){return gi(e)?e.LABEL:e.name}function gi(e){return we(e.LABEL)&&""!==e.LABEL}pi.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.",pi.NA=/NOT_APPLICABLE/;const yi="parent",Ti="categories",vi="label",Ri="group",Ei="push_mode",Ai="pop_mode",ki="longer_alt",Si="line_breaks",Ii="start_chars_hint";function xi(e){return function(e){const t=e.pattern,n={};n.name=e.name,te(t)||(n.PATTERN=t);if(oe(e,yi))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";oe(e,Ti)&&(n.CATEGORIES=e[Ti]);si([n]),oe(e,vi)&&(n.LABEL=e[vi]);oe(e,Ri)&&(n.GROUP=e[Ri]);oe(e,Ai)&&(n.POP_MODE=e[Ai]);oe(e,Ei)&&(n.PUSH_MODE=e[Ei]);oe(e,ki)&&(n.LONGER_ALT=e[ki]);oe(e,Si)&&(n.LINE_BREAKS=e[Si]);oe(e,Ii)&&(n.START_CHARS_HINT=e[Ii]);return n}(e)}const Ni=xi({name:"EOF",pattern:pi.NA});function $i(e,t,n,r,i,s,a,o){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:s,startColumn:a,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function Ci(e,t){return ti(e,t)}si([Ni]);const wi={buildMismatchTokenMessage:({expected:e,actual:t,previous:n,ruleName:r})=>`Expecting ${gi(e)?`--\x3e ${mi(e)} <--`:`token of type --\x3e ${e.name} <--`} but found --\x3e '${t.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){const s="Expecting: ",a="\nbut found: '"+Se(t).image+"'";if(r)return s+r+a;{const t=ne(e,((e,t)=>e.concat(t)),[]),n=se(t,(e=>`[${se(e,(e=>mi(e))).join(", ")}]`));return s+`one of these possible Token sequences:\n${se(n,((e,t)=>` ${t+1}. ${e}`)).join("\n")}`+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){const i="Expecting: ",s="\nbut found: '"+Se(t).image+"'";if(n)return i+n+s;return i+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${se(e,(e=>`[${se(e,(e=>mi(e))).join(",")}]`)).join(" ,")}>`+s}};Object.freeze(wi);const Li={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},Oi={buildDuplicateFoundError(e,t){const n=e.name,r=Se(t),i=r.idx,s=yr(r),a=(o=r)instanceof fr?o.terminalType.name:o instanceof ir?o.nonTerminalName:"";var o;let c=`->${s}${i>0?i:""}<- ${a?`with argument: ->${a}<-`:""}\n appears more than once (${t.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;let r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r},buildEmptyRepetitionError(e){let t=yr(e.repetition);0!==e.repetition.idx&&(t+=e.repetition.idx);return`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){const t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --\x3e ${se(e.leftRecursionPath,(e=>e.name)).concat([t]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;t=e.topLevelRule instanceof sr?e.topLevelRule.name:e.topLevelRule;return`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class _i extends mr{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){ee(q(this.nameToTopRule),(e=>{this.currTopLevel=e,e.accept(this)}))}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:ra.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class bi extends Tr{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=de(this.path.ruleStack).reverse(),this.occurrenceStack=de(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,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){he(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Pi extends bi{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,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const e=t.concat(n),r=new ar({definition:e});this.possibleTokTypes=Rr(r),this.found=!0}}}class Mi extends Tr{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 Di extends Mi{walkMany(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}}class Ui extends Mi{walkManySep(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}}class Fi extends Mi{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}}class Gi extends Mi{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}}function Bi(e,t,n=[]){n=de(n);let r=[],i=0;function s(s){const a=Bi(s.concat(ve(e,i+1)),t,n);return r.concat(a)}for(;n.length<t&&i<e.length;){const t=e[i];if(t instanceof ar)return s(t.definition);if(t instanceof ir)return s(t.definition);if(t instanceof or)r=s(t.definition);else{if(t instanceof cr){return s(t.definition.concat([new ur({definition:t.definition})]))}if(t instanceof lr){return s([new ar({definition:t.definition}),new ur({definition:[new fr({terminalType:t.separator})].concat(t.definition)})])}if(t instanceof hr){const e=t.definition.concat([new ur({definition:[new fr({terminalType:t.separator})].concat(t.definition)})]);r=s(e)}else if(t instanceof ur){const e=t.definition.concat([new ur({definition:t.definition})]);r=s(e)}else{if(t instanceof dr)return ee(t.definition,(e=>{!1===he(e.definition)&&(r=s(e.definition))})),r;if(!(t instanceof fr))throw Error("non exhaustive match");n.push(t.terminalType)}}i++}return r.push({partialPath:n,suffixDef:ve(e,i)}),r}function Ki(e,t,n,r){const i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE";let o=!1;const c=t.length,l=c-r-1,u=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!he(h);){const e=h.pop();if(e===a){o&&le(h).idx<=l&&h.pop();continue}const r=e.def,d=e.idx,f=e.ruleStack,p=e.occurrenceStack;if(he(r))continue;const m=r[0];if(m===i){const e={idx:d,def:ve(r),ruleStack:Re(f),occurrenceStack:Re(p)};h.push(e)}else if(m instanceof fr)if(d<c-1){const e=d+1;if(n(t[e],m.terminalType)){const t={idx:e,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(t)}}else{if(d!==c-1)throw Error("non exhaustive match");u.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:f,occurrenceStack:p}),o=!0}else if(m instanceof ir){const e=de(f);e.push(m.nonTerminalName);const t=de(p);t.push(m.idx);const n={idx:d,def:m.definition.concat(s,ve(r)),ruleStack:e,occurrenceStack:t};h.push(n)}else if(m instanceof or){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t={idx:d,def:m.definition.concat(ve(r)),ruleStack:f,occurrenceStack:p};h.push(t)}else if(m instanceof cr){const e=new ur({definition:m.definition,idx:m.idx}),t={idx:d,def:m.definition.concat([e],ve(r)),ruleStack:f,occurrenceStack:p};h.push(t)}else if(m instanceof lr){const e=new fr({terminalType:m.separator}),t=new ur({definition:[e].concat(m.definition),idx:m.idx}),n={idx:d,def:m.definition.concat([t],ve(r)),ruleStack:f,occurrenceStack:p};h.push(n)}else if(m instanceof hr){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t=new fr({terminalType:m.separator}),n=new ur({definition:[t].concat(m.definition),idx:m.idx}),i={idx:d,def:m.definition.concat([n],ve(r)),ruleStack:f,occurrenceStack:p};h.push(i)}else if(m instanceof ur){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t=new ur({definition:m.definition,idx:m.idx}),n={idx:d,def:m.definition.concat([t],ve(r)),ruleStack:f,occurrenceStack:p};h.push(n)}else if(m instanceof dr)for(let t=m.definition.length-1;t>=0;t--){const e={idx:d,def:m.definition[t].definition.concat(ve(r)),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a)}else if(m instanceof ar)h.push({idx:d,def:m.definition.concat(ve(r)),ruleStack:f,occurrenceStack:p});else{if(!(m instanceof sr))throw Error("non exhaustive match");h.push(ji(m,d,f,p))}}return u}function ji(e,t,n,r){const i=de(n);i.push(e.name);const s=de(r);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var Vi,Hi;function Wi(e){if(e instanceof or||"Option"===e)return Vi.OPTION;if(e instanceof ur||"Repetition"===e)return Vi.REPETITION;if(e instanceof cr||"RepetitionMandatory"===e)return Vi.REPETITION_MANDATORY;if(e instanceof lr||"RepetitionMandatoryWithSeparator"===e)return Vi.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof hr||"RepetitionWithSeparator"===e)return Vi.REPETITION_WITH_SEPARATOR;if(e instanceof dr||"Alternation"===e)return Vi.ALTERNATION;throw Error("non exhaustive match")}function zi(e){const{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,s=Wi(r);return s===Vi.ALTERNATION?ns(t,n,i):rs(t,n,s,i)}function Yi(e,t,n,r){const i=e.length,s=ke(e,(e=>ke(e,(e=>1===e.length))));if(t)return function(t){const r=se(t,(e=>e.GATE));for(let s=0;s<i;s++){const t=e[s],i=t.length,a=r[s];if(void 0===a||!1!==a.call(this))e:for(let e=0;e<i;e++){const r=t[e],i=r.length;for(let e=0;e<i;e++){const t=this.LA(e+1);if(!1===n(t,r[e]))continue e}return s}}};if(s&&!r){const t=se(e,(e=>D(e))),n=ne(t,((e,t,n)=>(ee(t,(t=>{oe(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),ee(t.categoryMatches,(t=>{oe(e,t)||(e[t]=n)}))})),e)),{});return function(){const e=this.LA(1);return n[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){const r=e[t],i=r.length;e:for(let e=0;e<i;e++){const i=r[e],s=i.length;for(let e=0;e<s;e++){const t=this.LA(e+1);if(!1===n(t,i[e]))continue e}return t}}}}function qi(e,t,n){const r=ke(e,(e=>1===e.length)),i=e.length;if(r&&!n){const t=D(e);if(1===t.length&&he(t[0].categoryMatches)){const e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{const e=ne(t,((e,t,n)=>(e[t.tokenTypeIdx]=!0,ee(t.categoryMatches,(t=>{e[t]=!0})),e)),[]);return function(){const t=this.LA(1);return!0===e[t.tokenTypeIdx]}}}return function(){e:for(let n=0;n<i;n++){const r=e[n],i=r.length;for(let e=0;e<i;e++){const n=this.LA(e+1);if(!1===t(n,r[e]))continue e}return!0}return!1}}(Hi=Vi||(Vi={}))[Hi.OPTION=0]="OPTION",Hi[Hi.REPETITION=1]="REPETITION",Hi[Hi.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",Hi[Hi.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",Hi[Hi.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",Hi[Hi.ALTERNATION=5]="ALTERNATION";class Xi extends Tr{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)}walkOption(e,t,n){this.checkIsTarget(e,Vi.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Vi.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Vi.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Vi.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}}class Qi extends mr{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx!==this.targetOccurrence||this.targetProdType!==t||void 0!==this.targetRef&&e!==this.targetRef||(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Vi.OPTION)}visitRepetition(e){this.checkIsTarget(e,Vi.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Vi.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Vi.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Vi.ALTERNATION)}}function Ji(e){const t=new Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function Zi(e){let t=[""];for(let n=0;n<e.length;n++){const r=e[n],i=[];for(let e=0;e<t.length;e++){const n=t[e];i.push(n+"_"+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){const t="_"+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function es(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;const i=e[r];for(let e=0;e<t.length;e++){if(!0===i[t[e]])return!1}}return!0}function ts(e,t){const n=se(e,(e=>Bi([e],1))),r=Ji(n.length),i=se(n,(e=>{const t={};return ee(e,(e=>{const n=Zi(e.partialPath);ee(n,(e=>{t[e]=!0}))})),t}));let s=n;for(let a=1;a<=t;a++){const e=s;s=Ji(e.length);for(let n=0;n<e.length;n++){const o=e[n];for(let e=0;e<o.length;e++){const c=o[e].partialPath,l=o[e].suffixDef,u=Zi(c);if(es(i,u,n)||he(l)||c.length===t){const e=r[n];if(!1===is(e,c)){e.push(c);for(let e=0;e<u.length;e++){const t=u[e];i[n][t]=!0}}}else{const e=Bi(l,a+1,c);s[n]=s[n].concat(e),ee(e,(e=>{const t=Zi(e.partialPath);ee(t,(e=>{i[n][e]=!0}))}))}}}}return r}function ns(e,t,n,r){const i=new Qi(e,Vi.ALTERNATION,r);return t.accept(i),ts(i.result,n)}function rs(e,t,n,r){const i=new Qi(e,n);t.accept(i);const s=i.result,a=new Xi(t,e,n).startWalking();return ts([new ar({definition:s}),new ar({definition:a})],r)}function is(e,t){e:for(let n=0;n<e.length;n++){const r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){const n=t[e],i=r[e];if(!1===(n===i||void 0!==i.categoryMatchesMap[n.tokenTypeIdx]))continue e}return!0}}return!1}function ss(e){return ke(e,(e=>ke(e,(e=>ke(e,(e=>he(e.categoryMatches)))))))}function as(e,t,n,r){const i=Ie(e,(e=>function(e,t){const n=new ls;e.accept(n);const r=n.allProductions,i=Me(Ce(r,os),(e=>e.length>1)),s=se(q(i),(n=>{const r=Se(n),i=t.buildDuplicateFoundError(e,n),s=yr(r),a={message:i,type:ra.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:s,occurrence:r.idx},o=cs(r);return o&&(a.parameter=o),a}));return s}(e,n))),s=function(e,t,n){const r=[],i=se(t,(e=>e.name));return ee(e,(e=>{const t=e.name;if(Oe(i,t)){const i=n.buildNamespaceConflictError(e);r.push({message:i,type:ra.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}})),r}(e,t,n),a=Ie(e,(e=>function(e,t){const n=new ds;e.accept(n);const r=Ie(n.alternations,(n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:ra.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[]));return r}(e,n))),o=Ie(e,(t=>function(e,t,n,r){const i=[],s=ne(t,((t,n)=>n.name===e.name?t+1:t),0);if(s>1){const t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:ra.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}(t,e,r,n)));return i.concat(s,a,o)}function os(e){return`${yr(e)}_#_${e.idx}_#_${cs(e)}`}function cs(e){return e instanceof fr?e.terminalType.name:e instanceof ir?e.nonTerminalName:""}class ls extends mr{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 us(e,t,n,r=[]){const i=[],s=hs(t.definition);if(he(s))return[];{const t=e.name;Oe(s,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:ra.LEFT_RECURSION,ruleName:t});const a=Ie(Te(s,r.concat([e])),(t=>{const i=de(r);return i.push(t),us(e,t,n,i)}));return i.concat(a)}}function hs(e){let t=[];if(he(e))return t;const n=Se(e);if(n instanceof ir)t.push(n.referencedRule);else if(n instanceof ar||n instanceof or||n instanceof cr||n instanceof lr||n instanceof hr||n instanceof ur)t=t.concat(hs(n.definition));else if(n instanceof dr)t=D(se(n.definition,(e=>hs(e.definition))));else if(!(n instanceof fr))throw Error("non exhaustive match");const r=gr(n),i=e.length>1;if(r&&i){const n=ve(e);return t.concat(hs(n))}return t}class ds extends mr{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function fs(e,t,n){const r=new ds;e.accept(r);let i=r.alternations;i=De(i,(e=>!0===e.ignoreAmbiguities));const s=Ie(i,(r=>{const i=r.idx,s=r.maxLookahead||t,a=ns(i,e,s,r),o=function(e,t,n,r){const i=[],s=ne(e,((n,r,s)=>(!0===t.definition[s].ignoreAmbiguities||ee(r,(r=>{const a=[s];ee(e,((e,n)=>{s!==n&&is(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&a.push(n)})),a.length>1&&!is(i,r)&&(i.push(r),n.push({alts:a,path:r}))})),n)),[]),a=se(s,(e=>{const i=se(e.alts,(e=>e+1));return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ra.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}}));return a}(a,r,e,n),c=function(e,t,n,r){const i=ne(e,((e,t,n)=>{const r=se(t,(e=>({idx:n,path:e})));return e.concat(r)}),[]),s=me(Ie(i,(e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];const s=e.idx,a=e.path,o=re(i,(e=>{return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<s&&(n=e.path,r=a,n.length<r.length&&ke(n,((e,t)=>{const n=r[t];return e===n||n.categoryMatchesMap[e.tokenTypeIdx]})));var n,r}));return se(o,(e=>{const i=[e.idx+1,s+1],a=0===t.idx?"":t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ra.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:i}}))})));return s}(a,r,e,n);return o.concat(c)}));return s}class ps extends mr{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 ms(e){const t=ce(e,{errMsgProvider:Li}),n={};return ee(e.rules,(e=>{n[e.name]=e})),function(e,t){const n=new _i(e,t);return n.resolveRefs(),n.errors}(n,t.errMsgProvider)}const gs="MismatchedTokenException",ys="NoViableAltException",Ts="EarlyExitException",vs="NotAllInputParsedException",Rs=[gs,ys,Ts,vs];function Es(e){return Oe(Rs,e.name)}Object.freeze(Rs);class As 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 ks extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=gs}}class Ss extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=ys}}class Is extends As{constructor(e,t){super(e,t),this.name=vs}}class xs extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ts}}const Ns={},$s="InRuleRecoveryException";class Cs extends Error{constructor(e){super(e),this.name=$s}}function ws(e,t,n,r,i,s,a){const o=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[o];if(void 0===c){const e=this.getCurrRuleFullName();c=new s(this.getGAstProductions()[e],i).startWalking(),this.firstAfterRepMap[o]=c}let l=c.token,u=c.occurrence;const h=c.isEndOfRule;1===this.RULE_STACK.length&&h&&void 0===l&&(l=Ni,u=1),void 0!==l&&void 0!==u&&this.shouldInRepetitionRecoveryBeTried(l,u,a)&&this.tryInRepetitionRecovery(e,t,n,l)}const Ls=1024,Os=1280,_s=1536;function bs(e,t,n){return n|t|e}class Ps{constructor(e){var t;this.maxLookahead=null!==(t=null==e?void 0:e.maxLookahead)&&void 0!==t?t:ta.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(he(t)){const n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return Ie(e,(e=>us(e,e,Oi)))}validateEmptyOrAlternatives(e){return Ie(e,(e=>function(e,t){const n=new ds;return e.accept(n),Ie(n.alternations,(n=>Ie(Re(n.definition),((r,i)=>{const s=Ki([r],[],ti,1);return he(s)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:ra.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]}))))}(e,Oi)))}validateAmbiguousAlternationAlternatives(e,t){return Ie(e,(e=>fs(e,t,Oi)))}validateSomeNonEmptyLookaheadPath(e,t){return function(e,t,n){const r=[];return ee(e,(e=>{const i=new ps;e.accept(i);const s=i.allProductions;ee(s,(i=>{const s=Wi(i),a=i.maxLookahead||t,o=rs(i.idx,e,s,a)[0];if(he(D(o))){const t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:ra.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}}))})),r}(e,t,Oi)}buildLookaheadForAlternation(e){return function(e,t,n,r,i,s){const a=ns(e,t,n);return s(a,r,ss(a)?ni:ti,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Yi)}buildLookaheadForOptional(e){return function(e,t,n,r,i,s){const a=rs(e,t,i,n),o=ss(a)?ni:ti;return s(a[0],o,r)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Wi(e.prodType),qi)}}const Ms=new class extends mr{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)}};function Ds(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function Us(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Fs(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function Gs(e,t){const n=T(e),r=n.length;for(let i=0;i<r;i++){const r=e[n[i]],s=r.length;for(let e=0;e<s;e++){const n=r[e];void 0===n.tokenTypeIdx&&this[n.name](n.children,t)}}}function Bs(e,t){const n=function(){};Fs(n,e+"BaseSemantics");const r={visit:function(e,t){if(R(e)&&(e=e[0]),!te(e))return this[e.name](e.children,t)},validateVisitor:function(){const e=function(e,t){const n=function(e,t){const n=re(t,(t=>!1===U(e[t]))),r=se(n,(t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Ks.MISSING_METHOD,methodName:t})));return me(r)}(e,t);return n}(this,t);if(!he(e)){const t=se(e,(e=>e.msg));throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(n.prototype=r).constructor=n,n._RULE_NAMES=t,n}var Ks,js;(js=Ks||(Ks={}))[js.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",js[js.MISSING_METHOD=1]="MISSING_METHOD";const Vs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Vs);const Hs=!0,Ws=Math.pow(2,8)-1,zs=xi({name:"RECORDING_PHASE_TOKEN",pattern:pi.NA});si([zs]);const Ys=$i(zs,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(Ys);const qs={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function Xs(e,t,n,r=!1){Zs(n);const i=le(this.recordingProdStack),s=U(t)?t:t.DEF,a=new e({definition:[],idx:n});return r&&(a.separator=t.SEP),oe(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),Vs}function Qs(e,t){Zs(t);const n=le(this.recordingProdStack),r=!1===R(e),i=!1===r?e:e.DEF,s=new dr({definition:[],idx:t,ignoreAmbiguities:r&&!0===e.IGNORE_AMBIGUITIES});oe(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);const a=Fe(i,(e=>U(e.GATE)));return s.hasPredicates=a,n.definition.push(s),ee(i,(e=>{const t=new ar({definition:[]});s.definition.push(t),oe(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:oe(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()})),Vs}function Js(e){return 0===e?"":`${e}`}function Zs(e){if(e<0||e>Ws){const t=new Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${Ws+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}const ea=$i(Ni,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ea);const ta=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:wi,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),na=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ra,ia,sa;function aa(e=void 0){return function(){return e}}(ia=ra||(ra={}))[ia.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",ia[ia.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",ia[ia.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",ia[ia.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",ia[ia.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",ia[ia.LEFT_RECURSION=5]="LEFT_RECURSION",ia[ia.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",ia[ia.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",ia[ia.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",ia[ia.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",ia[ia.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",ia[ia.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",ia[ia.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",ia[ia.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class oa{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\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",(()=>{tr(this)})),this.TRACE_INIT("Grammar Recording",(()=>{try{this.enableRecording(),ee(this.definedRulesNames,(e=>{const t=this[e].originalGrammarAction;let n;this.TRACE_INIT(`${e} Rule`,(()=>{n=this.topLevelRuleRecord(e,t)})),this.gastProductionsCache[e]=n}))}finally{this.disableRecording()}}));let n=[];if(this.TRACE_INIT("Grammar Resolving",(()=>{n=ms({rules:q(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)})),this.TRACE_INIT("Grammar Validations",(()=>{if(he(n)&&!1===this.skipValidations){const n=(e={rules:q(this.gastProductionsCache),tokenTypes:q(this.tokensMap),errMsgProvider:Oi,grammarName:t},as((e=ce(e,{errMsgProvider:Oi})).rules,e.tokenTypes,e.errMsgProvider,e.grammarName)),r=function(e){const t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return se(t,(e=>Object.assign({type:ra.CUSTOM_LOOKAHEAD_VALIDATION},e)))}({lookaheadStrategy:this.lookaheadStrategy,rules:q(this.gastProductionsCache),tokenTypes:q(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(n,r)}var e})),he(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",(()=>{const e=function(e){const t={};return ee(e,(e=>{const n=new Ar(e).startWalking();pe(t,n)})),t}(q(this.gastProductionsCache));this.resyncFollows=e})),this.TRACE_INIT("ComputeLookaheadFunctions",(()=>{var e,t;null===(t=(e=this.lookaheadStrategy).initialize)||void 0===t||t.call(e,{rules:q(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(q(this.gastProductionsCache))}))),!oa.DEFER_DEFINITION_ERRORS_HANDLING&&!he(this.definitionErrors))throw e=se(this.definitionErrors,(e=>e.message)),new Error(`Parser Definition Errors detected:\n ${e.join("\n-------------------------------\n")}`)}))}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),oe(t,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=oe(t,"skipValidations")?t.skipValidations:ta.skipValidations}}oa.DEFER_DEFINITION_ERRORS_HANDLING=!1,sa=oa,[class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=oe(e,"recoveryEnabled")?e.recoveryEnabled:ta.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=ws)}getTokenToInsert(e){const t=$i(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){const i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[];let o=!1;const c=this.LA(1);let l=this.LA(1);const u=()=>{const e=this.LA(0),t=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),n=new ks(t,c,this.LA(0));n.resyncedTokens=Re(a),this.SAVE_ERROR(n)};for(;!o;){if(this.tokenMatcher(l,r))return void u();if(n.call(this))return u(),void e.apply(this,t);this.tokenMatcher(l,i)?o=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,a))}this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,n){return!1!==n&&!this.tokenMatcher(this.LA(1),e)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t))}getFollowsForInRuleRecovery(e,t){const n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new Cs("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(he(t))return!1;const n=this.LA(1);return void 0!==ae(t,(e=>this.tokenMatcher(n,e)))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey();return Oe(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA(1),n=2;for(;;){const r=ae(e,(e=>Ci(t,e)));if(void 0!==r)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return Ns;const e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return se(e,((n,r)=>0===r?Ns:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])}))}flattenFollowSet(){const e=se(this.buildFullFollowKeyStack(),(e=>this.getFollowSetFromFollowKey(e)));return D(e)}getFollowSetFromFollowKey(e){if(e===Ns)return[Ni];const t=e.ruleName+e.idxInCallingRule+Er+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ni)||t.push(e),t}reSyncTo(e){const t=[];let n=this.LA(1);for(;!1===this.tokenMatcher(n,e);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return Re(t)}attemptInRepetitionRecovery(e,t,n,r,i,s,a){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:de(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return se(this.RULE_STACK,(e=>this.shortRuleNameToFullName(e)))}},class{initLooksAhead(e){this.dynamicTokensEnabled=oe(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ta.dynamicTokensEnabled,this.maxLookahead=oe(e,"maxLookahead")?e.maxLookahead:ta.maxLookahead,this.lookaheadStrategy=oe(e,"lookaheadStrategy")?e.lookaheadStrategy:new Ps({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){ee(e,(e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,(()=>{const{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:a}=function(e){Ms.reset(),e.accept(Ms);const t=Ms.dslMethods;return Ms.reset(),t}(e);ee(t,(t=>{const n=0===t.idx?"":t.idx;this.TRACE_INIT(`${yr(t)}${n}`,(()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=bs(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)}))})),ee(n,(t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,yr(t))})),ee(r,(t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,yr(t))})),ee(i,(t=>{this.computeLookaheadFunc(e,t.idx,Ls,"RepetitionMandatory",t.maxLookahead,yr(t))})),ee(s,(t=>{this.computeLookaheadFunc(e,t.idx,_s,"RepetitionMandatoryWithSeparator",t.maxLookahead,yr(t))})),ee(a,(t=>{this.computeLookaheadFunc(e,t.idx,Os,"RepetitionWithSeparator",t.maxLookahead,yr(t))}))}))}))}computeLookaheadFunc(e,t,n,r,i,s){this.TRACE_INIT(`${s}${0===t?"":t}`,(()=>{const s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),a=bs(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(a,s)}))}getKeyForAutomaticLookahead(e,t){return bs(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=oe(e,"nodeLocationTracking")?e.nodeLocationTracking:ta.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Us,this.setNodeLocationFromNode=Us,this.cstPostRule=ie,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ds,this.setNodeLocationFromNode=Ds,this.cstPostRule=ie,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=ie,this.setInitialNodeLocation=ie}else this.cstInvocationStateUpdate=ie,this.cstFinallyStateUpdate=ie,this.cstPostTerminal=ie,this.cstPostNonTerminal=ie,this.cstPostRule=ie}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),n=e.location;n.startOffset<=t.startOffset==1?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){const t=this.LA(0),n=e.location;n.startOffset<=t.startOffset==1?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];var r,i,s;i=t,s=e,void 0===(r=n).children[s]?r.children[s]=[i]:r.children[s].push(i),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];!function(e,t,n){void 0===e.children[t]?e.children[t]=[n]:e.children[t].push(n)}(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(te(this.baseCstVisitorConstructor)){const e=Bs(this.className,T(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(te(this.baseCstVisitorWithDefaultsConstructor)){const e=function(e,t,n){const r=function(){};Fs(r,e+"BaseSemanticsWithDefaults");const i=Object.create(n.prototype);return ee(t,(e=>{i[e]=Gs})),(r.prototype=i).constructor=r,r}(this.className,T(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{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)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)):ea}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ea: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{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=ni,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},oe(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(R(e)){if(he(e))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(R(e))this.tokensMap=ne(e,((e,t)=>(e[t.name]=t,e)),{});else if(oe(e,"modes")&&ke(D(q(e.modes)),li)){const t=Ge(D(q(e.modes)));this.tokensMap=ne(t,((e,t)=>(e[t.name]=t,e)),{})}else{if(!G(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=de(e)}this.tokensMap.EOF=Ni;const n=ke(oe(e,"modes")?D(q(e.modes)):q(e),(e=>he(e.categoryMatches)));this.tokenMatcher=n?ni:ti,si(q(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=oe(n,"resyncEnabled")?n.resyncEnabled:na.resyncEnabled,i=oe(n,"recoveryValueFunc")?n.recoveryValueFunc:na.recoveryValueFunc,s=this.ruleShortNameIdx<<12;let a;return this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=e,this.fullRuleNameToShort[e]=s,a=!0===this.outputCst?function(...n){try{this.ruleInvocationStateUpdate(s,e,this.subruleIdx),t.apply(this,n);const r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(a){return this.invokeRuleCatch(a,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(s,e,this.subruleIdx),t.apply(this,n)}catch(a){return this.invokeRuleCatch(a,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(a,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){const r=1===this.RULE_STACK.length,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Es(e)){const t=e;if(i){const r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(r)return this.moveToTerminatedState(),n(e);throw t}throw e}optionInternal(e,t){const n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof e){r=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else r=e;if(!0===i.call(this))return r.call(this)}atLeastOneInternal(e,t){const n=this.getKeyForAutomaticLookahead(Ls,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;if(!0!==i.call(this))throw this.raiseEarlyExitException(e,Vi.REPETITION_MANDATORY,t.ERR_MSG);{let e=this.doSingleRepetition(r);for(;!0===i.call(this)&&!0===e;)e=this.doSingleRepetition(r)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Ls,e,Fi)}atLeastOneSepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(_s,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);{r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Gi],t,_s,e,Gi)}}manyInternal(e,t){const n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;let s=!0;for(;!0===i.call(this)&&!0===s;)s=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,768,e,Di,s)}manySepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(Os,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Ui],t,Os,e,Ui)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,_s,e,i)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const n=this.getKeyForAutomaticLookahead(256,t),r=R(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(void 0!==i)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){const e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Is(t,e))}}subruleInternal(e,t,n){let r;try{const i=void 0!==n?n.ARGS:void 0;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:e.ruleName),r}catch(i){throw this.subruleInternalError(i,n,e.ruleName)}}subruleInternalError(e,t,n){throw Es(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{const t=this.LA(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(i){r=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r;const i=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new ks(r,t,i))}consumeInternalRecovery(e,t,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;{const i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(r){throw r.name===$s?n:r}}}saveRecogState(){const e=this.errors,t=de(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,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ni)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}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,n=na){if(Oe(this.definedRulesNames,e)){const t={message:Oi.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ra.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);const r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=na){const r=function(e,t,n){const r=[];let i;return Oe(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:ra.INVALID_RULE_OVERRIDE,ruleName:e})),r}(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);const i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);const n=this.saveRecogState();try{return e.apply(this,t),!0}catch(r){if(Es(r))return!1;throw r}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return e=q(this.gastProductionsCache),se(e,pr);var e}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=oe(e,"errorMessageProvider")?e.errorMessageProvider:ta.errorMessageProvider}SAVE_ERROR(e){if(Es(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:de(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return de(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){const r=this.getCurrRuleFullName(),i=rs(e,this.getGAstProductions()[r],t,this.maxLookahead)[0],s=[];for(let o=1;o<=this.maxLookahead;o++)s.push(this.LA(o));const a=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:s,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new xs(a,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const n=this.getCurrRuleFullName(),r=ns(e,this.getGAstProductions()[n],this.maxLookahead),i=[];for(let o=1;o<=this.maxLookahead;o++)i.push(this.LA(o));const s=this.LA(0),a=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:s,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Ss(a,this.LA(1),s))}},class{initContentAssist(){}computeContentAssist(e,t){const n=this.gastProductionsCache[e];if(te(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Ki([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const t=Se(e.ruleStack),n=this.getGAstProductions()[t];return new Pi(n,e).startWalking()}},class{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(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},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 n=t>0?t:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}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 ea}topLevelRuleRecord(e,t){try{const n=new sr({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(n){if(!0!==n.KNOWN_RECORDER_ERROR)try{n.message=n.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(r){throw n}throw n}}optionInternalRecord(e,t){return Xs.call(this,or,e,t)}atLeastOneInternalRecord(e,t){Xs.call(this,cr,t,e)}atLeastOneSepFirstInternalRecord(e,t){Xs.call(this,lr,t,e,Hs)}manyInternalRecord(e,t){Xs.call(this,ur,t,e)}manySepFirstInternalRecord(e,t){Xs.call(this,hr,t,e,Hs)}orInternalRecord(e,t){return Qs.call(this,e,t)}subruleInternalRecord(e,t,n){if(Zs(t),!e||!1===oe(e,"ruleName")){const n=new Error(`<SUBRULE${Js(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=le(this.recordingProdStack),i=e.ruleName,s=new ir({idx:t,nonTerminalName:i,label:null==n?void 0:n.LABEL,referencedRule:void 0});return r.definition.push(s),this.outputCst?qs:Vs}consumeInternalRecord(e,t,n){if(Zs(t),!oi(e)){const n=new Error(`<CONSUME${Js(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=le(this.recordingProdStack),i=new fr({idx:t,terminalType:e,label:null==n?void 0:n.LABEL});return r.definition.push(i),Ys}},class{initPerformanceTracer(e){if(oe(e,"traceInitPerf")){const t=e.traceInitPerf,n="number"==typeof t;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ta.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=er(t),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}}].forEach((e=>{const t=e.prototype;Object.getOwnPropertyNames(t).forEach((n=>{if("constructor"===n)return;const r=Object.getOwnPropertyDescriptor(t,n);r&&(r.get||r.set)?Object.defineProperty(sa.prototype,n,r):sa.prototype[n]=e.prototype[n]}))}));class ca extends oa{constructor(e,t=ta){const n=de(t);n.outputCst=!1,super(e,n)}}function la(e,t,n){return`${e.name}_${t}_${n}`}class ua{constructor(e){this.target=e}isEpsilon(){return!1}}class ha extends ua{constructor(e,t){super(e),this.tokenType=t}}class da extends ua{constructor(e){super(e)}isEpsilon(){return!0}}class fa extends ua{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}}function pa(e){const t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};!function(e,t){const n=t.length;for(let r=0;r<n;r++){const n=t[r],i=Sa(e,n,void 0,{type:2}),s=Sa(e,n,void 0,{type:7});i.stop=s,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,s)}}(t,e);const n=e.length;for(let r=0;r<n;r++){const n=e[r],i=ga(t,n,n);void 0!==i&&Aa(t,n,i)}return t}function ma(e,t,n){return n instanceof fr?Ea(e,t,n.terminalType,n):n instanceof ir?function(e,t,n){const r=n.referencedRule,i=e.ruleToStartState.get(r),s=Sa(e,t,n,{type:1}),a=Sa(e,t,n,{type:1}),o=new fa(i,r,a);return Ia(s,o),{left:s,right:a}}(e,t,n):n instanceof dr?function(e,t,n){const r=Sa(e,t,n,{type:1});va(e,r);const i=se(n.definition,(n=>ma(e,t,n))),s=Ra(e,t,r,n,...i);return s}(e,t,n):n instanceof or?function(e,t,n){const r=Sa(e,t,n,{type:1});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return function(e,t,n,r){const i=r.left,s=r.right;return ka(i,s),e.decisionMap[la(t,"Option",n.idx)]=i,r}(e,t,n,i)}(e,t,n):n instanceof ur?function(e,t,n){const r=Sa(e,t,n,{type:5});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return Ta(e,t,n,i)}(e,t,n):n instanceof hr?function(e,t,n){const r=Sa(e,t,n,{type:5});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n)),s=Ea(e,t,n.separator,n);return Ta(e,t,n,i,s)}(e,t,n):n instanceof cr?function(e,t,n){const r=Sa(e,t,n,{type:4});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return ya(e,t,n,i)}(e,t,n):n instanceof lr?function(e,t,n){const r=Sa(e,t,n,{type:4});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n)),s=Ea(e,t,n.separator,n);return ya(e,t,n,i,s)}(e,t,n):ga(e,t,n)}function ga(e,t,n){const r=re(se(n.definition,(n=>ma(e,t,n))),(e=>void 0!==e));return 1===r.length?r[0]:0===r.length?void 0:function(e,t){const n=t.length;for(let s=0;s<n-1;s++){const n=t[s];let r;1===n.left.transitions.length&&(r=n.left.transitions[0]);const i=r instanceof fa,a=r,o=t[s+1].left;1===n.left.type&&1===n.right.type&&void 0!==r&&(i&&a.followState===n.right||r.target===n.right)?(i?a.followState=o:r.target=o,xa(e,n.right)):ka(n.right,o)}const r=t[0],i=t[n-1];return{left:r.left,right:i.right}}(e,r)}function ya(e,t,n,r,i){const s=r.left,a=r.right,o=Sa(e,t,n,{type:11});va(e,o);const c=Sa(e,t,n,{type:12});return s.loopback=o,c.loopback=o,e.decisionMap[la(t,i?"RepetitionMandatoryWithSeparator":"RepetitionMandatory",n.idx)]=o,ka(a,o),void 0===i?(ka(o,s),ka(o,c)):(ka(o,c),ka(o,i.left),ka(i.right,s)),{left:s,right:c}}function Ta(e,t,n,r,i){const s=r.left,a=r.right,o=Sa(e,t,n,{type:10});va(e,o);const c=Sa(e,t,n,{type:12}),l=Sa(e,t,n,{type:9});return o.loopback=l,c.loopback=l,ka(o,s),ka(o,c),ka(a,l),void 0!==i?(ka(l,c),ka(l,i.left),ka(i.right,s)):ka(l,o),e.decisionMap[la(t,i?"RepetitionWithSeparator":"Repetition",n.idx)]=o,{left:o,right:c}}function va(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function Ra(e,t,n,r,...i){const s=Sa(e,t,r,{type:8,start:n});n.end=s;for(const o of i)void 0!==o?(ka(n,o.left),ka(o.right,s)):ka(n,s);const a={left:n,right:s};return e.decisionMap[la(t,function(e){if(e instanceof dr)return"Alternation";if(e instanceof or)return"Option";if(e instanceof ur)return"Repetition";if(e instanceof hr)return"RepetitionWithSeparator";if(e instanceof cr)return"RepetitionMandatory";if(e instanceof lr)return"RepetitionMandatoryWithSeparator";throw new Error("Invalid production type encountered")}(r),r.idx)]=n,a}function Ea(e,t,n,r){const i=Sa(e,t,r,{type:1}),s=Sa(e,t,r,{type:1});return Ia(i,new ha(s,n)),{left:i,right:s}}function Aa(e,t,n){const r=e.ruleToStartState.get(t);ka(r,n.left);const i=e.ruleToStopState.get(t);ka(n.right,i);return{left:r,right:i}}function ka(e,t){Ia(e,new da(t))}function Sa(e,t,n,r){const i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function Ia(e,t){0===e.transitions.length&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function xa(e,t){e.states.splice(e.states.indexOf(t),1)}const Na={};class $a{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){const t=Ca(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return se(this.configs,(e=>e.alt))}get key(){let e="";for(const t in this.map)e+=t+":";return e}}function Ca(e,t=!0){return`${t?`a${e.alt}`:""}s${e.state.stateNumber}:${e.stack.map((e=>e.stateNumber.toString())).join("_")}`}function wa(e,t){const n={};return r=>{const i=r.toString();let s=n[i];return void 0!==s||(s={atnStartState:e,decision:t,states:{}},n[i]=s),s}}class La{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 n=0;n<t;n++)e+=!0===this.predicates[n]?"1":"0";return e}}const Oa=new La;class _a extends Ps{constructor(e){var t;super(),this.logging=null!==(t=null==e?void 0:e.logging)&&void 0!==t?t:e=>console.log(e)}initialize(e){this.atn=pa(e.rules),this.dfas=function(e){const t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=wa(e.decisionStates[r],r);return n}(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){const{prodOccurrence:t,rule:n,hasPredicates:r,dynamicTokensEnabled:i}=e,s=this.dfas,a=this.logging,o=la(n,"Alternation",t),c=this.atn.decisionMap[o].decision,l=se(zi({maxLookahead:1,occurrence:t,prodType:"Alternation",rule:n}),(e=>se(e,(e=>e[0]))));if(ba(l,!1)&&!i){const e=ne(l,((e,t,n)=>(ee(t,(t=>{t&&(e[t.tokenTypeIdx]=n,ee(t.categoryMatches,(t=>{e[t]=n})))})),e)),{});return r?function(t){var n;const r=this.LA(1),i=e[r.tokenTypeIdx];if(void 0!==t&&void 0!==i){const e=null===(n=t[i])||void 0===n?void 0:n.GATE;if(void 0!==e&&!1===e.call(this))return}return i}:function(){const t=this.LA(1);return e[t.tokenTypeIdx]}}return r?function(e){const t=new La,n=void 0===e?0:e.length;for(let i=0;i<n;i++){const n=null==e?void 0:e[i].GATE;t.set(i,void 0===n||n.call(this))}const r=Pa.call(this,s,c,t,a);return"number"==typeof r?r:void 0}:function(){const e=Pa.call(this,s,c,Oa,a);return"number"==typeof e?e:void 0}}buildLookaheadForOptional(e){const{prodOccurrence:t,rule:n,prodType:r,dynamicTokensEnabled:i}=e,s=this.dfas,a=this.logging,o=la(n,r,t),c=this.atn.decisionMap[o].decision,l=se(zi({maxLookahead:1,occurrence:t,prodType:r,rule:n}),(e=>se(e,(e=>e[0]))));if(ba(l)&&l[0][0]&&!i){const e=l[0],t=D(e);if(1===t.length&&he(t[0].categoryMatches)){const e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{const e=ne(t,((e,t)=>(void 0!==t&&(e[t.tokenTypeIdx]=!0,ee(t.categoryMatches,(t=>{e[t]=!0}))),e)),{});return function(){const t=this.LA(1);return!0===e[t.tokenTypeIdx]}}}return function(){const e=Pa.call(this,s,c,Oa,a);return"object"!=typeof e&&0===e}}}function ba(e,t=!0){const n=new Set;for(const r of e){const e=new Set;for(const i of r){if(void 0===i){if(t)break;return!1}const r=[i.tokenTypeIdx].concat(i.categoryMatches);for(const t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function Pa(e,t,n,r){const i=e[t](n);let s=i.start;if(void 0===s){s=ja(i,Ba(function(e){const t=new $a,n=e.transitions.length;for(let r=0;r<n;r++){Va({state:e.transitions[r].target,alt:r,stack:[]},t)}return t}(i.atnStartState))),i.start=s}return Ma.apply(this,[i,s,n,r])}function Ma(e,t,n,r){let i=t,s=1;const a=[];let o=this.LA(s++);for(;;){let t=(c=o,i.edges[c.tokenTypeIdx]);if(void 0===t&&(t=Da.apply(this,[e,i,o,s,n,r])),t===Na)return Fa(a,i,o);if(!0===t.isAcceptState)return t.prediction;i=t,a.push(o),o=this.LA(s++)}var c}function Da(e,t,n,r,i,s){const a=function(e,t,n){const r=new $a,i=[];for(const a of e.elements){if(!1===n.is(a.alt))continue;if(7===a.state.type){i.push(a);continue}const e=a.state.transitions.length;for(let n=0;n<e;n++){const e=Ga(a.state.transitions[n],t);void 0!==e&&r.add({state:e,alt:a.alt,stack:a.stack})}}let s;0===i.length&&1===r.size&&(s=r);if(void 0===s){s=new $a;for(const e of r.elements)Va(e,s)}if(i.length>0&&!function(e){for(const t of e.elements)if(7===t.state.type)return!0;return!1}(s))for(const a of i)s.add(a);return s}(t.configs,n,i);if(0===a.size)return Ka(e,t,n,Na),Na;let o=Ba(a);const c=function(e,t){let n;for(const r of e.elements)if(!0===t.is(r.alt))if(void 0===n)n=r.alt;else if(n!==r.alt)return;return n}(a,i);if(void 0!==c)o.isAcceptState=!0,o.prediction=c,o.configs.uniqueAlt=c;else if(function(e){if(function(e){for(const t of e.elements)if(7!==t.state.type)return!1;return!0}(e))return!0;const t=function(e){const t=new Map;for(const n of e){const e=Ca(n,!1);let r=t.get(e);void 0===r&&(r={},t.set(e,r)),r[n.alt]=!0}return t}(e.elements);return function(e){for(const t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}(t)&&!function(e){for(const t of Array.from(e.values()))if(1===Object.keys(t).length)return!0;return!1}(t)}(a)){const t=ue(a.alts);o.isAcceptState=!0,o.prediction=t,o.configs.uniqueAlt=t,Ua.apply(this,[e,r,a.alts,s])}return o=Ka(e,t,n,o),o}function Ua(e,t,n,r){const i=[];for(let a=1;a<=t;a++)i.push(this.LA(a).tokenType);const s=e.atnStartState;r(function(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.production.idx?"":e.production.idx;let r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(", ")}> in <${function(e){if(e instanceof ir)return"SUBRULE";if(e instanceof or)return"OPTION";if(e instanceof dr)return"OR";if(e instanceof cr)return"AT_LEAST_ONE";if(e instanceof lr)return"AT_LEAST_ONE_SEP";if(e instanceof hr)return"MANY_SEP";if(e instanceof ur)return"MANY";if(e instanceof fr)return"CONSUME";throw Error("non exhaustive match")}(e.production)}${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r}({topLevelRule:s.rule,ambiguityIndices:n,production:s.production,prefixPath:i}))}function Fa(e,t,n){const r=Ie(t.configs.elements,(e=>e.state.transitions));var i,s;return{actualToken:n,possibleTokenTypes:(i=r.filter((e=>e instanceof ha)).map((e=>e.tokenType)),s=e=>e.tokenTypeIdx,i&&i.length?Z(i,z(s)):[]),tokenPath:e}}function Ga(e,t){if(e instanceof ha&&Ci(t,e.tokenType))return e.target}function Ba(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}function Ka(e,t,n,r){return r=ja(e,r),t.edges[n.tokenTypeIdx]=r,r}function ja(e,t){if(t===Na)return t;const n=t.configs.key,r=e.states[n];return void 0!==r?r:(t.configs.finalize(),e.states[n]=t,t)}function Va(e,t){const n=e.state;if(7===n.type){if(e.stack.length>0){const n=[...e.stack];Va({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);const r=n.transitions.length;for(let i=0;i<r;i++){const r=Ha(e,n.transitions[i]);void 0!==r&&Va(r,t)}}function Ha(e,t){if(t instanceof da)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof fa){const n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}class Wa{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]}buildRootNode(e){return this.rootNode=new Qa(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){const t=new qa;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){const n=new Ya(e.startOffset,e.image.length,at(e),e.tokenType,!1);return n.grammarSource=t,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){const t=e.container;if(t){const n=t.content.indexOf(e);n>=0&&t.content.splice(n,1)}}construct(e){const t=this.current;"string"==typeof e.$type&&(this.current.astNode=e),e.$cstNode=t;const n=this.nodeStack.pop();0===(null==n?void 0:n.content.length)&&this.removeNode(n)}addHiddenTokens(e){for(const t of e){const e=new Ya(t.startOffset,t.image.length,at(t),t.tokenType,!0);e.root=this.rootNode,this.addHiddenToken(this.rootNode,e)}}addHiddenToken(e,t){const{offset:n,end:r}=t;for(let i=0;i<e.content.length;i++){const s=e.content[i],{offset:a,end:o}=s;if(He(s)&&n>a&&r<o)return void this.addHiddenToken(s,t);if(r<=a)return void e.content.splice(i,0,t)}e.content.push(t)}}class za{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){var e,t;const n="string"==typeof(null===(e=this._astNode)||void 0===e?void 0:e.$type)?this._astNode:null===(t=this.container)||void 0===t?void 0:t.astNode;if(!n)throw new Error("This node has no associated AST element");return n}set astNode(e){this._astNode=e}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}}class Ya extends za{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,n,r,i=!1){super(),this._hidden=i,this._offset=e,this._tokenType=r,this._length=t,this._range=n}}class qa extends za{constructor(){super(...arguments),this.content=new Xa(this)}get children(){return this.content}get offset(){var e,t;return null!==(t=null===(e=this.firstNonHiddenNode)||void 0===e?void 0:e.offset)&&void 0!==t?t:0}get length(){return this.end-this.offset}get end(){var e,t;return null!==(t=null===(e=this.lastNonHiddenNode)||void 0===e?void 0:e.end)&&void 0!==t?t:0}get range(){const e=this.firstNonHiddenNode,t=this.lastNonHiddenNode;if(e&&t){if(void 0===this._rangeCache){const{range:n}=e,{range:r}=t;this._rangeCache={start:n.start,end:r.end.line<n.start.line?n.start:r.end}}return this._rangeCache}return{start:B.create(0,0),end:B.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 Xa extends Array{constructor(e){super(),this.parent=e,Object.setPrototypeOf(this,Xa.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,t,...n){return this.addParents(n),super.splice(e,t,...n)}addParents(e){for(const t of e)t.container=this.parent}}class Qa extends qa{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text="",this._text=null!=e?e:""}}const Ja=Symbol("Datatype");function Za(e){return e.$type===Ja}const eo=e=>e.endsWith("​")?e:e+"​";class to{constructor(e){this._unorderedGroups=new Map,this.lexer=e.parser.Lexer;const t=this.lexer.definition;this.wrapper=new oo(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 no extends to{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new Wa,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 n=e.fragment?void 0:jn(e)?Ja:Wn(e),r=this.wrapper.DEFINE_RULE(eo(e.name),this.startImplementation(n,t).bind(this));return e.entry&&(this.mainRule=r),r}parse(e){this.nodeBuilder.buildRootNode(e);const t=this.lexer.tokenize(e);this.wrapper.input=t.tokens;const n=this.mainRule.call(this.wrapper,{});return this.nodeBuilder.addHiddenTokens(t.hidden),this.unorderedGroups.clear(),{value:n,lexerErrors:t.errors,parserErrors:this.wrapper.errors}}startImplementation(e,t){return n=>{if(!this.isRecording()){const t={$type:e};this.stack.push(t),e===Ja&&(t.value="")}let r;try{r=t(n)}catch(i){r=void 0}return this.isRecording()||void 0!==r||(r=this.construct()),r}}consume(e,t,n){const r=this.wrapper.wrapConsume(e,t);if(!this.isRecording()&&this.isValidToken(r)){const e=this.nodeBuilder.buildLeafNode(r,n),{assignment:t,isCrossRef:i}=this.getAssignment(n),s=this.current;if(t){const s=zt(n)?r.image:this.converter.convert(r.image,e);this.assign(t.operator,t.feature,s,e,i)}else if(Za(s)){let t=r.image;zt(n)||(t=this.converter.convert(t,e).toString()),s.value+=t}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&"number"==typeof e.endOffset&&!isNaN(e.endOffset)}subrule(e,t,n,r){let i;this.isRecording()||(i=this.nodeBuilder.buildCompositeNode(n));const s=this.wrapper.wrapSubrule(e,t,r);!this.isRecording()&&i&&i.length>0&&this.performSubruleAssignment(s,n,i)}performSubruleAssignment(e,t,n){const{assignment:r,isCrossRef:i}=this.getAssignment(t);if(r)this.assign(r.operator,r.feature,e,n,i);else if(!r){const t=this.current;if(Za(t))t.value+=e.toString();else if("object"==typeof e&&e){const n=e.$type,r=this.assignWithoutOverride(e,t);n&&(r.$type=n);const i=r;this.stack.pop(),this.stack.push(i)}}}action(e,t){if(!this.isRecording()){let n=this.current;if(!n.$cstNode&&t.feature&&t.operator){n=this.construct(!1);const e=n.$cstNode.feature;this.nodeBuilder.buildCompositeNode(e)}const r={$type:e};this.stack.pop(),this.stack.push(r),t.feature&&t.operator&&this.assign(t.operator,t.feature,n,n.$cstNode,!1)}}construct(e=!0){if(this.isRecording())return;const t=this.current;return function(e){for(const[t,n]of Object.entries(e))t.startsWith("$")||(Array.isArray(n)?n.forEach(((n,r)=>{Be(n)&&(n.$container=e,n.$containerProperty=t,n.$containerIndex=r)})):Be(n)&&(n.$container=e,n.$containerProperty=t))}(t),this.nodeBuilder.construct(t),e&&this.stack.pop(),Za(t)?this.converter.convert(t.value,t.$cstNode):(function(e,t){const n=e.getTypeMetaData(t.$type),r=t;for(const i of n.properties)void 0!==i.defaultValue&&void 0===r[i.name]&&(r[i.name]=mn(i.defaultValue))}(this.astReflection,t),t)}getAssignment(e){if(!this.assignmentMap.has(e)){const t=cn(e,Ft);this.assignmentMap.set(e,{assignment:t,isCrossRef:!!t&&Kt(t.terminal)})}return this.assignmentMap.get(e)}assign(e,t,n,r,i){const s=this.current;let a;switch(a=i&&"string"==typeof n?this.linker.buildReference(s,t,r,n):n,e){case"=":s[t]=a;break;case"?=":s[t]=!0;break;case"+=":Array.isArray(s[t])||(s[t]=[]),s[t].push(a)}}assignWithoutOverride(e,t){for(const[n,r]of Object.entries(t)){const t=e[n];void 0===t?e[n]=r:Array.isArray(t)&&Array.isArray(r)&&(r.push(...t),e[n]=r)}return e}get definitionErrors(){return this.wrapper.definitionErrors}}class ro{buildMismatchTokenMessage(e){return wi.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return wi.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return wi.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return wi.buildEarlyExitMessage(e)}}class io extends ro{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 so extends to{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 n=this.wrapper.DEFINE_RULE(eo(e.name),this.startImplementation(t).bind(this));return e.entry&&(this.mainRule=n),n}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(e){return t=>{const n=this.keepStackSize();try{e(t)}finally{this.resetStackSize(n)}}}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,n){this.wrapper.wrapConsume(e,t),this.isRecording()||(this.lastElementStack=[...this.elementStack,n],this.nextTokenIndex=this.currIdx+1)}subrule(e,t,n,r){this.before(n),this.wrapper.wrapSubrule(e,t,r),this.after(n)}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 ao={recoveryEnabled:!0,nodeLocationTracking:"full",skipValidations:!0,errorMessageProvider:new io};class oo extends ca{constructor(e,t){const n=t&&"maxLookahead"in t;super(e,Object.assign(Object.assign(Object.assign({},ao),{lookaheadStrategy:n?new Ps({maxLookahead:t.maxLookahead}):new _a}),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,n){return this.subrule(e,t,{ARGS:[n]})}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 co(e,t,n){return function(e,t){const n=Mn(t,!1),r=Ze(t.rules).filter($t).filter((e=>n.has(e)));for(const i of r){const t=Object.assign(Object.assign({},e),{consume:1,optional:1,subrule:1,many:1,or:1});t.rules.set(i.name,e.parser.rule(i,lo(t,i.definition)))}}({parser:t,tokens:n,rules:new Map,ruleNames:new Map},e),t}function lo(e,t,n=!1){let r;if(zt(t))r=function(e,t){const n=e.consume++,r=e.tokens[t.value];if(!r)throw new Error("Could not find token for keyword: "+t.value);return()=>e.parser.consume(n,r,t)}(e,t);else if(Pt(t))r=function(e,t){const n=Wn(t);return()=>e.parser.action(n,t)}(e,t);else if(Ft(t))r=lo(e,t.terminal);else if(Kt(t))r=fo(e,t);else if(Qt(t))r=function(e,t){const n=t.rule.ref;if($t(n)){const r=e.subrule++,i=t.arguments.length>0?function(e,t){const n=t.map((e=>uo(e.value)));return t=>{const r={};for(let i=0;i<n.length;i++){const s=e.parameters[i],a=n[i];r[s.name]=a(t)}return r}}(n,t.arguments):()=>({});return s=>e.parser.subrule(r,mo(e,n),t,i(s))}if(Lt(n)){const r=e.consume++,i=go(e,n.name);return()=>e.parser.consume(r,i,t)}if(!n)throw new ht(t.$cstNode,`Undefined rule type: ${t.$type}`);dt()}(e,t);else if(Dt(t))r=function(e,t){if(1===t.elements.length)return lo(e,t.elements[0]);{const n=[];for(const i of t.elements){const t={ALT:lo(e,i,!0)},r=ho(i);r&&(t.GATE=uo(r)),n.push(t)}const r=e.or++;return t=>e.parser.alternatives(r,n.map((e=>{const n={ALT:()=>e.ALT(t)},r=e.GATE;return r&&(n.GATE=()=>r(t)),n})))}}(e,t);else if(nn(t))r=function(e,t){if(1===t.elements.length)return lo(e,t.elements[0]);const n=[];for(const o of t.elements){const t={ALT:lo(e,o,!0)},r=ho(o);r&&(t.GATE=uo(r)),n.push(t)}const r=e.or++,i=(e,t)=>`uGroup_${e}_${t.getRuleStack().join("-")}`,s=t=>e.parser.alternatives(r,n.map(((n,s)=>{const a={ALT:()=>!0},o=e.parser;a.ALT=()=>{if(n.ALT(t),!o.isRecording()){const e=i(r,o);o.unorderedGroups.get(e)||o.unorderedGroups.set(e,[]);const t=o.unorderedGroups.get(e);void 0===(null==t?void 0:t[s])&&(t[s]=!0)}};const c=n.GATE;return a.GATE=c?()=>c(t):()=>{const e=o.unorderedGroups.get(i(r,o));return!(null==e?void 0:e[s])},a}))),a=po(e,ho(t),s,"*");return t=>{a(t),e.parser.isRecording()||e.parser.unorderedGroups.delete(i(r,e.parser))}}(e,t);else if(Ht(t))r=function(e,t){const n=t.elements.map((t=>lo(e,t)));return e=>n.forEach((t=>t(e)))}(e,t);else{if(i=t,!on.isInstance(i,jt))throw new ht(t.$cstNode,`Unexpected element type: ${t.$type}`);{const n=e.consume++;r=()=>e.parser.consume(n,Ni,t)}}var i;return po(e,n?void 0:ho(t),r,t.cardinality)}function uo(e){if(t=e,on.isInstance(t,Rt)){const t=uo(e.left),n=uo(e.right);return e=>t(e)||n(e)}if(function(e){return on.isInstance(e,vt)}(e)){const t=uo(e.left),n=uo(e.right);return e=>t(e)&&n(e)}if(function(e){return on.isInstance(e,It)}(e)){const t=uo(e.value);return e=>!t(e)}if(function(e){return on.isInstance(e,xt)}(e)){const t=e.parameter.ref.name;return e=>void 0!==e&&!0===e[t]}if(function(e){return on.isInstance(e,Tt)}(e)){const t=Boolean(e.true);return()=>t}var t;dt()}function ho(e){if(Ht(e))return e.guardCondition}function fo(e,t,n=t.terminal){if(n){if(Qt(n)&&$t(n.rule.ref)){const r=e.subrule++;return i=>e.parser.subrule(r,mo(e,n.rule.ref),t,i)}if(Qt(n)&&Lt(n.rule.ref)){const r=e.consume++,i=go(e,n.rule.ref.name);return()=>e.parser.consume(r,i,t)}if(zt(n)){const r=e.consume++,i=go(e,n.value);return()=>e.parser.consume(r,i,t)}throw new Error("Could not build cross reference parser")}{if(!t.type.ref)throw new Error("Could not resolve reference to type: "+t.type.$refText);const n=Bn(t.type.ref),r=null==n?void 0:n.terminal;if(!r)throw new Error("Could not find name assignment for type: "+Wn(t.type.ref));return fo(e,t,r)}}function po(e,t,n,r){const i=t&&uo(t);if(!r){if(i){const t=e.or++;return r=>e.parser.alternatives(t,[{ALT:()=>n(r),GATE:()=>i(r)},{ALT:aa(),GATE:()=>!i(r)}])}return n}if("*"===r){const t=e.many++;return r=>e.parser.many(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}if("+"===r){const t=e.many++;if(i){const r=e.or++;return s=>e.parser.alternatives(r,[{ALT:()=>e.parser.atLeastOne(t,{DEF:()=>n(s)}),GATE:()=>i(s)},{ALT:aa(),GATE:()=>!i(s)}])}return r=>e.parser.atLeastOne(t,{DEF:()=>n(r)})}if("?"===r){const t=e.optional++;return r=>e.parser.optional(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}dt()}function mo(e,t){const n=function(e,t){if($t(t))return t.name;if(e.ruleNames.has(t))return e.ruleNames.get(t);{let n=t,r=n.$container,i=t.$type;for(;!$t(r);){if(Ht(r)||Dt(r)||nn(r)){i=r.elements.indexOf(n).toString()+":"+i}n=r,r=r.$container}return i=r.name+":"+i,e.ruleNames.set(t,i),i}}(e,t),r=e.rules.get(n);if(!r)throw new Error(`Rule "${n}" not found."`);return r}function go(e,t){const n=e.tokens[t];if(!n)throw new Error(`Token "${t}" not found."`);return n}function yo(e){const t=function(e){const t=e.Grammar,n=e.parser.Lexer,r=new no(e);return co(t,r,n.definition)}(e);return t.finalize(),t}class To{buildTokens(e,t){const n=Ze(Mn(e,!1)),r=this.buildTerminalTokens(n),i=this.buildKeywordTokens(n,r,t);return r.forEach((e=>{const t=e.PATTERN;"object"==typeof t&&t&&"test"in t&&_n(t)?i.unshift(e):i.push(e)})),i}buildTerminalTokens(e){return e.filter(Lt).filter((e=>!e.fragment)).map((e=>this.buildTerminalToken(e))).toArray()}buildTerminalToken(e){const t=zn(e),n=this.requiresCustomPattern(t)?this.regexPatternFunction(t):t,r={name:e.name,PATTERN:n,LINE_BREAKS:!0};return e.hidden&&(r.GROUP=_n(t)?pi.SKIPPED:"hidden"),r}requiresCustomPattern(e){return!!e.flags.includes("u")||!(!e.source.includes("?<=")&&!e.source.includes("?<!"))}regexPatternFunction(e){const t=new RegExp(e,e.flags+"y");return(e,n)=>{t.lastIndex=n;return t.exec(e)}}buildKeywordTokens(e,t,n){return e.filter($t).flatMap((e=>hn(e).filter(zt))).distinct((e=>e.value)).toArray().sort(((e,t)=>t.value.length-e.value.length)).map((e=>this.buildKeywordToken(e,t,Boolean(null==n?void 0:n.caseInsensitive))))}buildKeywordToken(e,t,n){return{name:e.value,PATTERN:this.buildKeywordPattern(e,n),LONGER_ALT:this.findLongerAlt(e,t)}}buildKeywordPattern(e,t){return t?new RegExp(function(e){return Array.prototype.map.call(e,(e=>/\w/.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:bn(e))).join("")}(e.value)):e.value}findLongerAlt(e,t){return t.reduce(((t,n)=>{const r=null==n?void 0:n.PATTERN;return(null==r?void 0:r.source)&&Pn("^"+r.source+"$",e.value)&&t.push(n),t}),[])}}class vo{convert(e,t){let n=t.grammarSource;if(Kt(n)&&(n=function(e){if(e.terminal)return e.terminal;if(e.type.ref){const t=Bn(e.type.ref);return null==t?void 0:t.terminal}}(n)),Qt(n)){const r=n.rule.ref;if(!r)throw new Error("This cst node was not parsed by a rule.");return this.runConverter(r,e,t)}return e}runConverter(e,t,n){var r;switch(e.name.toUpperCase()){case"INT":return Ro.convertInt(t);case"STRING":return Ro.convertString(t);case"ID":return Ro.convertID(t)}switch(null===(r=function(e){var t,n,r;return Lt(e)?null!==(n=null===(t=e.type)||void 0===t?void 0:t.name)&&void 0!==n?n:"string":jn(e)?e.name:null!==(r=Hn(e))&&void 0!==r?r:e.name}(e))||void 0===r?void 0:r.toLowerCase()){case"number":return Ro.convertNumber(t);case"boolean":return Ro.convertBoolean(t);case"bigint":return Ro.convertBigint(t);case"date":return Ro.convertDate(t);default:return t}}}var Ro;!function(e){function t(e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"0":return"\0";default:return e}}e.convertString=function(e){let n="";for(let r=1;r<e.length-1;r++){const i=e.charAt(r);if("\\"===i){n+=t(e.charAt(++r))}else n+=i}return n},e.convertID=function(e){return"^"===e.charAt(0)?e.substring(1):e},e.convertInt=function(e){return parseInt(e)},e.convertBigint=function(e){return BigInt(e)},e.convertDate=function(e){return new Date(e)},e.convertNumber=function(e){return Number(e)},e.convertBoolean=function(e){return"true"===e.toLowerCase()}}(Ro||(Ro={}));var Eo=K();let Ao=0;const ko=Symbol("OperationCancelled");function So(e){return e===ko}async function Io(e){if(e===Eo.CancellationToken.None)return;const t=Date.now();if(t-Ao>=10&&(Ao=t,await new Promise((e=>{"undefined"==typeof setImmediate?setTimeout(e,0):setImmediate(e)}))),e.isCancellationRequested)throw ko}class xo{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=t=>(e(t),this),this.reject=e=>(t(e),this)}))}}class No{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,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),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){for(const n of e)if(No.isIncremental(n)){const e=bo(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);const i=Math.max(e.start.line,0),s=Math.max(e.end.line,0);let a=this._lineOffsets;const o=Oo(n.text,!1,t);if(s-i===o.length)for(let n=0,l=o.length;n<l;n++)a[n+i+1]=o[n];else o.length<1e4?a.splice(i+1,s-i,...o):this._lineOffsets=a=a.slice(0,i+1).concat(o,a.slice(s+1));const c=n.text.length-(r-t);if(0!==c)for(let n=i+1+o.length,l=a.length;n<l;n++)a[n]=a[n]+c}else{if(!No.isFull(n))throw new Error("Unknown change event received");this._content=n.text,this._lineOffsets=void 0}this._version=t}getLineOffsets(){return void 0===this._lineOffsets&&(this._lineOffsets=Oo(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);const t=this.getLineOffsets();let n=0,r=t.length;if(0===r)return{line:0,character:e};for(;n<r;){const i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}const i=n-1;return{line:i,character:(e=this.ensureBeforeEOL(e,t[i]))-t[i]}}offsetAt(e){const t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;const n=t[e.line];if(e.character<=0)return n;const r=e.line+1<t.length?t[e.line+1]:this._content.length,i=Math.min(n+e.character,r);return this.ensureBeforeEOL(i,n)}ensureBeforeEOL(e,t){for(;e>t&&_o(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){const t=e;return null!=t&&"string"==typeof t.text&&void 0!==t.range&&(void 0===t.rangeLength||"number"==typeof t.rangeLength)}static isFull(e){const t=e;return null!=t&&"string"==typeof t.text&&void 0===t.range&&void 0===t.rangeLength}}var $o,Co,wo;function Lo(e,t){if(e.length<=1)return e;const n=e.length/2|0,r=e.slice(0,n),i=e.slice(n);Lo(r,t),Lo(i,t);let s=0,a=0,o=0;for(;s<r.length&&a<i.length;){const n=t(r[s],i[a]);e[o++]=n<=0?r[s++]:i[a++]}for(;s<r.length;)e[o++]=r[s++];for(;a<i.length;)e[o++]=i[a++];return e}function Oo(e,t,n=0){const r=t?[n]:[];for(let i=0;i<e.length;i++){const t=e.charCodeAt(i);_o(t)&&(13===t&&i+1<e.length&&10===e.charCodeAt(i+1)&&i++,r.push(n+i+1))}return r}function _o(e){return 13===e||10===e}function bo(e){const t=e.start,n=e.end;return t.line>n.line||t.line===n.line&&t.character>n.character?{start:n,end:t}:e}function Po(e){const t=bo(e.range);return t!==e.range?{newText:e.newText,range:t}:e}(Co=$o||($o={})).create=function(e,t,n,r){return new No(e,t,n,r)},Co.update=function(e,t,n){if(e instanceof No)return e.update(t,n),e;throw new Error("TextDocument.update: document must be created by TextDocument.create")},Co.applyEdits=function(e,t){const n=e.getText(),r=Lo(t.map(Po),((e,t)=>{const n=e.range.start.line-t.range.start.line;return 0===n?e.range.start.character-t.range.start.character:n}));let i=0;const s=[];for(const a of r){const t=e.offsetAt(a.range.start);if(t<i)throw new Error("Overlapping edit");t>i&&s.push(n.substring(i,t)),a.newText.length&&s.push(a.newText),i=e.offsetAt(a.range.end)}return s.push(n.substr(i)),s.join("")},(()=>{var e={470:e=>{function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",i=0,s=-1,a=0,o=0;o<=e.length;++o){if(o<e.length)n=e.charCodeAt(o);else{if(47===n)break;n=47}if(47===n){if(s===o-1||1===a);else if(s!==o-1&&2===a){if(r.length<2||2!==i||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var c=r.lastIndexOf("/");if(c!==r.length-1){-1===c?(r="",i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf("/"),s=o,a=0;continue}}else if(2===r.length||1===r.length){r="",i=0,s=o,a=0;continue}t&&(r.length>0?r+="/..":r="..",i=2)}else r.length>0?r+="/"+e.slice(s+1,o):r=e.slice(s+1,o),i=o-s-1;s=o,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var r={resolve:function(){for(var e,r="",i=!1,s=arguments.length-1;s>=-1&&!i;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=process.cwd()),a=e),t(a),0!==a.length&&(r=a+"/"+r,i=47===a.charCodeAt(0))}return r=n(r,!i),i?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),i=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&i&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var i=arguments[n];t(i),i.length>0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var i=1;i<e.length&&47===e.charCodeAt(i);++i);for(var s=e.length,a=s-i,o=1;o<n.length&&47===n.charCodeAt(o);++o);for(var c=n.length-o,l=a<c?a:c,u=-1,h=0;h<=l;++h){if(h===l){if(c>l){if(47===n.charCodeAt(o+h))return n.slice(o+h+1);if(0===h)return n.slice(o+h)}else a>l&&(47===e.charCodeAt(i+h)?u=h:0===h&&(u=0));break}var d=e.charCodeAt(i+h);if(d!==n.charCodeAt(o+h))break;47===d&&(u=h)}var f="";for(h=i+u+1;h<=s;++h)h!==s&&47!==e.charCodeAt(h)||(0===f.length?f+="..":f+="/..");return f.length>0?f+n.slice(o+u):(o+=u,47===n.charCodeAt(o)&&++o,n.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,i=-1,s=!0,a=e.length-1;a>=1;--a)if(47===(n=e.charCodeAt(a))){if(!s){i=a;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,i=0,s=-1,a=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var o=n.length-1,c=-1;for(r=e.length-1;r>=0;--r){var l=e.charCodeAt(r);if(47===l){if(!a){i=r+1;break}}else-1===c&&(a=!1,c=r+1),o>=0&&(l===n.charCodeAt(o)?-1==--o&&(s=r):(o=-1,s=c))}return i===s?s=c:-1===s&&(s=e.length),e.slice(i,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!a){i=r+1;break}}else-1===s&&(a=!1,s=r+1);return-1===s?"":e.slice(i,s)},extname:function(e){t(e);for(var n=-1,r=0,i=-1,s=!0,a=0,o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(47!==c)-1===i&&(s=!1,i=o+1),46===c?-1===n?n=o:1!==a&&(a=1):-1!==n&&(a=-1);else if(!s){r=o+1;break}}return-1===n||-1===i||0===a||1===a&&n===i-1&&n===r+1?"":e.slice(n,i)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return n=(t=e).dir||t.root,r=t.base||(t.name||"")+(t.ext||""),n?n===t.root?n+r:n+"/"+r:r;var t,n,r},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,i=e.charCodeAt(0),s=47===i;s?(n.root="/",r=1):r=0;for(var a=-1,o=0,c=-1,l=!0,u=e.length-1,h=0;u>=r;--u)if(47!==(i=e.charCodeAt(u)))-1===c&&(l=!1,c=u+1),46===i?-1===a?a=u:1!==h&&(h=1):-1!==a&&(h=-1);else if(!l){o=u+1;break}return-1===a||-1===c||0===h||1===h&&a===c-1&&a===o+1?-1!==c&&(n.base=n.name=0===o&&s?e.slice(1,c):e.slice(o,c)):(0===o&&s?(n.name=e.slice(1,a),n.base=e.slice(1,c)):(n.name=e.slice(o,a),n.base=e.slice(o,c)),n.ext=e.slice(a,c)),o>0?n.dir=e.slice(0,o-1):s&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{let e;if(n.r(r),n.d(r,{URI:()=>u,Utils:()=>I}),"object"==typeof process)e="win32"===process.platform;else if("object"==typeof navigator){let t=navigator.userAgent;e=t.indexOf("Windows")>=0}const t=/^\w[\w\d+.-]*$/,i=/^\//,s=/^\/\//;function a(e,n){if(!e.scheme&&n)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!t.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!i.test(e.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(s.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}const o="",c="/",l=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class u{constructor(e,t,n,r,i,s=!1){f(this,"scheme"),f(this,"authority"),f(this,"path"),f(this,"query"),f(this,"fragment"),"object"==typeof e?(this.scheme=e.scheme||o,this.authority=e.authority||o,this.path=e.path||o,this.query=e.query||o,this.fragment=e.fragment||o):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t||o,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==c&&(t=c+t):t=c}return t}(this.scheme,n||o),this.query=r||o,this.fragment=i||o,a(this,s))}static isUri(e){return e instanceof u||!!e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"string"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}get fsPath(){return y(this)}with(e){if(!e)return this;let{scheme:t,authority:n,path:r,query:i,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=o),void 0===n?n=this.authority:null===n&&(n=o),void 0===r?r=this.path:null===r&&(r=o),void 0===i?i=this.query:null===i&&(i=o),void 0===s?s=this.fragment:null===s&&(s=o),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&s===this.fragment?this:new d(t,n,r,i,s)}static parse(e,t=!1){const n=l.exec(e);return n?new d(n[2]||o,E(n[4]||o),E(n[5]||o),E(n[7]||o),E(n[9]||o),t):new d(o,o,o,o,o)}static file(t){let n=o;if(e&&(t=t.replace(/\\/g,c)),t[0]===c&&t[1]===c){const e=t.indexOf(c,2);-1===e?(n=t.substring(2),t=c):(n=t.substring(2,e),t=t.substring(e)||c)}return new d("file",n,t,o,o)}static from(e){const t=new d(e.scheme,e.authority,e.path,e.query,e.fragment);return a(t,!0),t}toString(e=!1){return T(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof u)return e;{const t=new d(e);return t._formatted=e.external,t._fsPath=e._sep===h?e.fsPath:null,t}}return e}}const h=e?1:void 0;class d extends u{constructor(){super(...arguments),f(this,"_formatted",null),f(this,"_fsPath",null)}get fsPath(){return this._fsPath||(this._fsPath=y(this)),this._fsPath}toString(e=!1){return e?T(this,!0):(this._formatted||(this._formatted=T(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 p={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 m(e,t,n){let r,i=-1;for(let s=0;s<e.length;s++){const a=e.charCodeAt(s);if(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57||45===a||46===a||95===a||126===a||t&&47===a||n&&91===a||n&&93===a||n&&58===a)-1!==i&&(r+=encodeURIComponent(e.substring(i,s)),i=-1),void 0!==r&&(r+=e.charAt(s));else{void 0===r&&(r=e.substr(0,s));const t=p[a];void 0!==t?(-1!==i&&(r+=encodeURIComponent(e.substring(i,s)),i=-1),r+=t):-1===i&&(i=s)}}return-1!==i&&(r+=encodeURIComponent(e.substring(i))),void 0!==r?r:e}function g(e){let t;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);35===r||63===r?(void 0===t&&(t=e.substr(0,n)),t+=p[r]):void 0!==t&&(t+=e[n])}return void 0!==t?t:e}function y(t,n){let r;return r=t.authority&&t.path.length>1&&"file"===t.scheme?`//${t.authority}${t.path}`:47===t.path.charCodeAt(0)&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&58===t.path.charCodeAt(2)?t.path[1].toLowerCase()+t.path.substr(2):t.path,e&&(r=r.replace(/\//g,"\\")),r}function T(e,t){const n=t?g:m;let r="",{scheme:i,authority:s,path:a,query:o,fragment:l}=e;if(i&&(r+=i,r+=":"),(s||"file"===i)&&(r+=c,r+=c),s){let e=s.indexOf("@");if(-1!==e){const t=s.substr(0,e);s=s.substr(e+1),e=t.lastIndexOf(":"),-1===e?r+=n(t,!1,!1):(r+=n(t.substr(0,e),!1,!1),r+=":",r+=n(t.substr(e+1),!1,!0)),r+="@"}s=s.toLowerCase(),e=s.lastIndexOf(":"),-1===e?r+=n(s,!1,!0):(r+=n(s.substr(0,e),!1,!0),r+=s.substr(e))}if(a){if(a.length>=3&&47===a.charCodeAt(0)&&58===a.charCodeAt(2)){const e=a.charCodeAt(1);e>=65&&e<=90&&(a=`/${String.fromCharCode(e+32)}:${a.substr(3)}`)}else if(a.length>=2&&58===a.charCodeAt(1)){const e=a.charCodeAt(0);e>=65&&e<=90&&(a=`${String.fromCharCode(e+32)}:${a.substr(2)}`)}r+=n(a,!0,!1)}return o&&(r+="?",r+=n(o,!1,!1)),l&&(r+="#",r+=t?l:m(l,!1,!1)),r}function v(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+v(e.substr(3)):e}}const R=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function E(e){return e.match(R)?e.replace(R,(e=>v(e))):e}var A=n(470);const k=A.posix||A,S="/";var I,x;(x=I||(I={})).joinPath=function(e,...t){return e.with({path:k.join(e.path,...t)})},x.resolvePath=function(e,...t){let n=e.path,r=!1;n[0]!==S&&(n=S+n,r=!0);let i=k.resolve(n,...t);return r&&i[0]===S&&!e.authority&&(i=i.substring(1)),e.with({path:i})},x.dirname=function(e){if(0===e.path.length||e.path===S)return e;let t=k.dirname(e.path);return 1===t.length&&46===t.charCodeAt(0)&&(t=""),e.with({path:t})},x.basename=function(e){return k.basename(e.path)},x.extname=function(e){return k.extname(e.path)}})(),wo=r})();const{URI:Mo,Utils:Do}=wo;var Uo,Fo,Go,Bo,Ko,jo,Vo,Ho;(Fo=Uo||(Uo={})).basename=Do.basename,Fo.dirname=Do.dirname,Fo.extname=Do.extname,Fo.joinPath=Do.joinPath,Fo.resolvePath=Do.resolvePath,Fo.equals=function(e,t){return(null==e?void 0:e.toString())===(null==t?void 0:t.toString())},Fo.relative=function(e,t){const n="string"==typeof e?e:e.path,r="string"==typeof t?t:t.path,i=n.split("/").filter((e=>e.length>0)),s=r.split("/").filter((e=>e.length>0));let a=0;for(;a<i.length&&i[a]===s[a];a++);return"../".repeat(i.length-a)+s.slice(a).join("/")},(Bo=Go||(Go={}))[Bo.Changed=0]="Changed",Bo[Bo.Parsed=1]="Parsed",Bo[Bo.IndexedContent=2]="IndexedContent",Bo[Bo.ComputedScopes=3]="ComputedScopes",Bo[Bo.Linked=4]="Linked",Bo[Bo.IndexedReferences=5]="IndexedReferences",Bo[Bo.Validated=6]="Validated";class Wo{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}async fromUri(e,t=Eo.CancellationToken.None){const n=await this.fileSystemProvider.readFile(e);return this.createAsync(e,n,t)}fromTextDocument(e,t,n){return t=null!=t?t:Mo.parse(e.uri),n?this.createAsync(t,e,n):this.create(t,e)}fromString(e,t,n){return n?this.createAsync(t,e,n):this.create(t,e)}fromModel(e,t){return this.create(t,{$model:e})}create(e,t){if("string"==typeof t){const n=this.parse(e,t);return this.createLangiumDocument(n,e,void 0,t)}if("$model"in t){const n={value:t.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(n,e)}{const n=this.parse(e,t.getText());return this.createLangiumDocument(n,e,t)}}async createAsync(e,t,n){if("string"==typeof t){const r=await this.parseAsync(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}{const r=await this.parseAsync(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}createLangiumDocument(e,t,n,r){let i;if(n)i={parseResult:e,uri:t,state:Go.Parsed,references:[],textDocument:n};else{const n=this.createTextDocumentGetter(t,r);i={parseResult:e,uri:t,state:Go.Parsed,references:[],get textDocument(){return n()}}}return e.value.$document=i,i}async update(e,t){var n,r;const i=null===(n=e.parseResult.value.$cstNode)||void 0===n?void 0:n.root.fullText,s=null===(r=this.textDocuments)||void 0===r?void 0:r.get(e.uri.toString()),a=s?s.getText():await this.fileSystemProvider.readFile(e.uri);if(s)Object.defineProperty(e,"textDocument",{value:s});else{const t=this.createTextDocumentGetter(e.uri,a);Object.defineProperty(e,"textDocument",{get:t})}return i!==a&&(e.parseResult=await this.parseAsync(e.uri,a,t),e.parseResult.value.$document=e),e.state=Go.Parsed,e}parse(e,t){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(t)}parseAsync(e,t,n){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(t,n)}createTextDocumentGetter(e,t){const n=this.serviceRegistry;let r;return()=>null!=r?r:r=$o.create(e.toString(),n.getServices(e).LanguageMetaData.languageId,0,null!=t?t:"")}}class zo{constructor(e){this.documentMap=new Map,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory}get all(){return Ze(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 n=this.getDocument(e);return n||(n=await this.langiumDocumentFactory.fromUri(e,t),this.addDocument(n),n)}createDocument(e,t,n){if(n)return this.langiumDocumentFactory.fromString(t,e,n).then((e=>(this.addDocument(e),e)));{const n=this.langiumDocumentFactory.fromString(t,e);return this.addDocument(n),n}}hasDocument(e){return this.documentMap.has(e.toString())}invalidateDocument(e){const t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=Go.Changed,n.precomputedScopes=void 0,n.references=[],n.diagnostics=void 0),n}deleteDocument(e){const t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=Go.Changed,this.documentMap.delete(t)),n}}class Yo{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=Eo.CancellationToken.None){for(const n of dn(e.parseResult.value))await Io(t),pn(n).forEach((t=>this.doLink(t,e)))}doLink(e,t){const n=e.reference;if(void 0===n._ref)try{const t=this.getCandidate(e);if(je(t))n._ref=t;else if(n._nodeDescription=t,this.langiumDocuments().hasDocument(t.documentUri)){const r=this.loadAstNode(t);n._ref=null!=r?r:this.createLinkingError(e,t)}}catch(r){n._ref=Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${n.$refText}': ${r}`})}t.references.push(n)}unlink(e){for(const t of e.references)delete t._ref,delete t._nodeDescription;e.references=[]}getCandidate(e){const t=this.scopeProvider.getScope(e).getElement(e.reference.$refText);return null!=t?t:this.createLinkingError(e)}buildReference(e,t,n,r){const i=this,s={$refNode:n,$refText:r,get ref(){var n,r;if(Be(this._ref))return this._ref;if("object"==typeof(r=this._nodeDescription)&&null!==r&&"string"==typeof r.name&&"string"==typeof r.type&&"string"==typeof r.path){const n=i.loadAstNode(this._nodeDescription);this._ref=null!=n?n:i.createLinkingError({reference:s,container:e,property:t},this._nodeDescription)}else if(void 0===this._ref){const r=i.getLinkedNode({reference:s,container:e,property:t});if(r.error&&ln(e).state<Go.ComputedScopes)return;this._ref=null!==(n=r.node)&&void 0!==n?n:r.error,this._nodeDescription=r.descr}return Be(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return je(this._ref)?this._ref:void 0}};return s}getLinkedNode(e){try{const t=this.getCandidate(e);if(je(t))return{error:t};const n=this.loadAstNode(t);return n?{node:n,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);return t?this.astNodeLocator.getAstNode(t.parseResult.value,e.path):void 0}createLinkingError(e,t){const n=ln(e.container);n.state<Go.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${n.uri}).`);const r=this.reflection.getReferenceType(e);return Object.assign(Object.assign({},e),{message:`Could not resolve reference to ${r} named '${e.reference.$refText}'.`,targetDescription:t})}}class qo{getName(e){if(function(e){return"string"==typeof e.name}(e))return e.name}getNameNode(e){return Un(e.$cstNode,"name")}}class Xo{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator}findDeclaration(e){if(e){const t=function(e){var t;const n=e.astNode;for(;n===(null===(t=e.container)||void 0===t?void 0:t.astNode);){const t=cn(e.grammarSource,Ft);if(t)return t;e=e.container}}(e),n=e.astNode;if(t&&n){const r=n[t.feature];if(Ke(r))return r.ref;if(Array.isArray(r))for(const t of r)if(Ke(t)&&t.$refNode&&t.$refNode.offset<=e.offset&&t.$refNode.end>=e.end)return t.ref}if(n){const t=this.nameProvider.getNameNode(n);if(t&&(t===e||function(e,t){for(;e.container;)if((e=e.container)===t)return!0;return!1}(e,t)))return n}}}findDeclarationNode(e){const t=this.findDeclaration(e);if(null==t?void 0:t.$cstNode){const e=this.nameProvider.getNameNode(t);return null!=e?e:t.$cstNode}}findReferences(e,t){const n=[];if(t.includeDeclaration){const t=this.getReferenceToSelf(e);t&&n.push(t)}let r=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return t.documentUri&&(r=r.filter((e=>Uo.equals(e.sourceUri,t.documentUri)))),n.push(...r),Ze(n)}getReferenceToSelf(e){const t=this.nameProvider.getNameNode(e);if(t){const n=ln(e),r=this.nodeLocator.getAstNodePath(e);return{sourceUri:n.uri,sourcePath:r,targetUri:n.uri,targetPath:r,segment:ot(t),local:!0}}}}class Qo{constructor(e){if(this.map=new Map,e)for(const[t,n]of e)this.add(t,n)}get size(){return tt.sum(Ze(this.map.values()).map((e=>e.length)))}clear(){this.map.clear()}delete(e,t){if(void 0===t)return this.map.delete(e);{const n=this.map.get(e);if(n){const r=n.indexOf(t);if(r>=0)return 1===n.length?this.map.delete(e):n.splice(r,1),!0}return!1}}get(e){var t;return null!==(t=this.map.get(e))&&void 0!==t?t:[]}has(e,t){if(void 0===t)return this.map.has(e);{const n=this.map.get(e);return!!n&&n.indexOf(t)>=0}}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,n)=>t.forEach((t=>e(t,n,this)))))}[Symbol.iterator](){return this.entries().iterator()}entries(){return Ze(this.map.entries()).flatMap((([e,t])=>t.map((t=>[e,t]))))}keys(){return Ze(this.map.keys())}values(){return Ze(this.map.values()).flat()}entriesGroupedByKey(){return Ze(this.map.entries())}}class Jo{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(const[t,n]of e)this.set(t,n)}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 void 0!==t&&(this.map.delete(e),this.inverse.delete(t),!0)}}class Zo{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}async computeExports(e,t=Eo.CancellationToken.None){return this.computeExportsForNode(e.parseResult.value,e,void 0,t)}async computeExportsForNode(e,t,n=un,r=Eo.CancellationToken.None){const i=[];this.exportNode(e,i,t);for(const s of n(e))await Io(r),this.exportNode(s,i,t);return i}exportNode(e,t,n){const r=this.nameProvider.getName(e);r&&t.push(this.descriptions.createDescription(e,r,n))}async computeLocalScopes(e,t=Eo.CancellationToken.None){const n=e.parseResult.value,r=new Qo;for(const i of hn(n))await Io(t),this.processNode(i,e,r);return r}processNode(e,t,n){const r=e.$container;if(r){const i=this.nameProvider.getName(e);i&&n.add(r,this.descriptions.createDescription(e,i,t))}}}class ec{constructor(e,t,n){var r;this.elements=e,this.outerScope=t,this.caseInsensitive=null!==(r=null==n?void 0:n.caseInsensitive)&&void 0!==r&&r}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){const t=this.caseInsensitive?this.elements.find((t=>t.name.toLowerCase()===e.toLowerCase())):this.elements.find((t=>t.name===e));return t||(this.outerScope?this.outerScope.getElement(e):void 0)}}class tc{constructor(e,t,n){var r;this.elements=new Map,this.caseInsensitive=null!==(r=null==n?void 0:n.caseInsensitive)&&void 0!==r&&r;for(const i of e){const e=this.caseInsensitive?i.name.toLowerCase():i.name;this.elements.set(e,i)}this.outerScope=t}getElement(e){const t=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(t);return n||(this.outerScope?this.outerScope.getElement(e):void 0)}getAllElements(){let e=Ze(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}}class nc{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 rc extends nc{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 n=t();return this.cache.set(e,n),n}}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}}class ic extends nc{constructor(e){super(),this.cache=new Map,this.converter=null!=e?e:e=>e}has(e,t){return this.throwIfDisposed(),this.cacheForContext(e).has(t)}set(e,t,n){this.throwIfDisposed(),this.cacheForContext(e).set(t,n)}get(e,t,n){this.throwIfDisposed();const r=this.cacheForContext(e);if(r.has(t))return r.get(t);if(n){const e=n();return r.set(t,e),e}}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 n=this.cache.get(t);return n||(n=new Map,this.cache.set(t,n)),n}}class sc extends rc{constructor(e){super(),this.onDispose(e.workspace.DocumentBuilder.onUpdate((()=>{this.clear()})))}}class ac{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 sc(e.shared)}getScope(e){const t=[],n=this.reflection.getReferenceType(e),r=ln(e.container).precomputedScopes;if(r){let i=e.container;do{const e=r.get(i);e.length>0&&t.push(Ze(e).filter((e=>this.reflection.isSubtype(e.type,n)))),i=i.$container}while(i)}let i=this.getGlobalScope(n,e);for(let s=t.length-1;s>=0;s--)i=this.createScope(t[s],i);return i}createScope(e,t,n){return new ec(Ze(e),t,n)}createScopeForNodes(e,t,n){const r=Ze(e).map((e=>{const t=this.nameProvider.getName(e);if(t)return this.descriptions.createDescription(e,t)})).nonNullable();return new ec(r,t,n)}getGlobalScope(e,t){return this.globalScopeCache.get(e,(()=>new tc(this.indexManager.allElements(e))))}}function oc(e){return"object"==typeof e&&!!e&&("$ref"in e||"$error"in e)}class cc{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 n=null==t?void 0:t.replacer,r=(e,n)=>this.replacer(e,n,t),i=n?(e,t)=>n(e,t,r):r;try{return this.currentDocument=ln(e),JSON.stringify(e,i,null==t?void 0:t.space)}finally{this.currentDocument=void 0}}deserialize(e,t={}){const n=JSON.parse(e);return this.linkNode(n,n,t),n}replacer(e,t,{refText:n,sourceText:r,textRegions:i,comments:s,uriConverter:a}){var o,c,l,u;if(!this.ignoreProperties.has(e)){if(Ke(t)){const e=t.ref,r=n?t.$refText:void 0;if(e){const n=ln(e);let i="";this.currentDocument&&this.currentDocument!==n&&(i=a?a(n.uri,t):n.uri.toString());return{$ref:`${i}#${this.astNodeLocator.getAstNodePath(e)}`,$refText:r}}return{$error:null!==(c=null===(o=t.error)||void 0===o?void 0:o.message)&&void 0!==c?c:"Could not resolve reference",$refText:r}}if(Be(t)){let n;if(i&&(n=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},t)),e&&!t.$document||!(null==n?void 0:n.$textRegion)||(n.$textRegion.documentURI=null===(l=this.currentDocument)||void 0===l?void 0:l.uri.toString())),r&&!e&&(null!=n||(n=Object.assign({},t)),n.$sourceText=null===(u=t.$cstNode)||void 0===u?void 0:u.text),s){null!=n||(n=Object.assign({},t));const e=this.commentProvider.getComment(t);e&&(n.$comment=e.replace(/\r/g,""))}return null!=n?n:t}return t}}addAstNodeRegionWithAssignmentsTo(e){const t=e=>({offset:e.offset,end:e.end,length:e.length,range:e.range});if(e.$cstNode){const n=(e.$textRegion=t(e.$cstNode)).assignments={};return Object.keys(e).filter((e=>!e.startsWith("$"))).forEach((r=>{const i=function(e,t){return e&&t?Fn(e,t,e.astNode,!0):[]}(e.$cstNode,r).map(t);0!==i.length&&(n[r]=i)})),e}}linkNode(e,t,n,r,i,s){for(const[o,c]of Object.entries(e))if(Array.isArray(c))for(let r=0;r<c.length;r++){const i=c[r];oc(i)?c[r]=this.reviveReference(e,o,t,i,n):Be(i)&&this.linkNode(i,t,n,e,o,r)}else oc(c)?e[o]=this.reviveReference(e,o,t,c,n):Be(c)&&this.linkNode(c,t,n,e,o);const a=e;a.$container=r,a.$containerProperty=i,a.$containerIndex=s}reviveReference(e,t,n,r,i){let s=r.$refText,a=r.$error;if(r.$ref){const e=this.getRefNode(n,r.$ref,i.uriConverter);if(Be(e))return s||(s=this.nameProvider.getName(e)),{$refText:null!=s?s:"",ref:e};a=e}if(a){const n={$refText:null!=s?s:""};return n.error={container:e,property:t,message:a,reference:n},n}}getRefNode(e,t,n){try{const r=t.indexOf("#");if(0===r){const n=this.astNodeLocator.getAstNode(e,t.substring(1));return n||"Could not resolve path: "+t}if(r<0){const e=n?n(t):Mo.parse(t),r=this.langiumDocuments.getDocument(e);return r?r.parseResult.value:"Could not find document for URI: "+t}const i=n?n(t.substring(0,r)):Mo.parse(t.substring(0,r)),s=this.langiumDocuments.getDocument(i);if(!s)return"Could not find document for URI: "+t;if(r===t.length-1)return s.parseResult.value;const a=this.astNodeLocator.getAstNode(s.parseResult.value,t.substring(r+1));return a||"Could not resolve URI: "+t}catch(r){return String(r)}}}class lc{register(e){if(this.singleton||this.map){if(!this.map&&(this.map={},this.singleton)){for(const e of this.singleton.LanguageMetaData.fileExtensions)this.map[e]=this.singleton;this.singleton=void 0}for(const t of e.LanguageMetaData.fileExtensions)void 0!==this.map[t]&&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}else this.singleton=e}getServices(e){if(void 0!==this.singleton)return this.singleton;if(void 0===this.map)throw new Error("The service registry is empty. Use `register` to register the services of a language.");const t=Uo.extname(e),n=this.map[t];if(!n)throw new Error(`The service registry contains no services for the extension '${t}'.`);return n}get all(){return void 0!==this.singleton?[this.singleton]:void 0!==this.map?Object.values(this.map):[]}}function uc(e){return{code:e}}(Ko||(Ko={})).all=["fast","slow","built-in"];class hc{constructor(e){this.entries=new Qo,this.reflection=e.shared.AstReflection}register(e,t=this,n="fast"){if("built-in"===n)throw new Error("The 'built-in' category is reserved for lexer, parser, and linker errors.");for(const[r,i]of Object.entries(e)){const e=i;if(Array.isArray(e))for(const i of e){const e={check:this.wrapValidationException(i,t),category:n};this.addEntry(r,e)}else if("function"==typeof e){const i={check:this.wrapValidationException(e,t),category:n};this.addEntry(r,i)}}}wrapValidationException(e,t){return async(n,r,i)=>{try{await e.call(t,n,r,i)}catch(s){if(So(s))throw s;console.error("An error occurred during validation:",s);const e=s instanceof Error?s.message:String(s);s instanceof Error&&s.stack&&console.error(s.stack),r("error","An error occurred during validation: "+e,{node:n})}}}addEntry(e,t){if("AstNode"!==e)for(const n of this.reflection.getAllSubTypes(e))this.entries.add(n,t);else this.entries.add("AstNode",t)}getChecks(e,t){let n=Ze(this.entries.get(e)).concat(this.entries.get("AstNode"));return t&&(n=n.filter((e=>t.includes(e.category)))),n.map((e=>e.check))}}class dc{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},n=Eo.CancellationToken.None){const r=e.parseResult,i=[];if(await Io(n),!t.categories||t.categories.includes("built-in")){if(this.processLexingErrors(r,i,t),t.stopAfterLexingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.LexingError})))return i;if(this.processParsingErrors(r,i,t),t.stopAfterParsingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.ParsingError})))return i;if(this.processLinkingErrors(e,i,t),t.stopAfterLinkingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.LinkingError})))return i}try{i.push(...await this.validateAst(r.value,t,n))}catch(s){if(So(s))throw s;console.error("An error occurred during validation:",s)}return await Io(n),i}processLexingErrors(e,t,n){for(const r of e.lexerErrors){const e={severity:pc("error"),range:{start:{line:r.line-1,character:r.column-1},end:{line:r.line-1,character:r.column+r.length-1}},message:r.message,data:uc(jo.LexingError),source:this.getSource()};t.push(e)}}processParsingErrors(e,t,n){for(const r of e.parserErrors){let e;if(isNaN(r.token.startOffset)){if("previousToken"in r){const t=r.previousToken;if(isNaN(t.startOffset)){const t={line:0,character:0};e={start:t,end:t}}else{const n={line:t.endLine-1,character:t.endColumn};e={start:n,end:n}}}}else e=at(r.token);if(e){const n={severity:pc("error"),range:e,message:r.message,data:uc(jo.ParsingError),source:this.getSource()};t.push(n)}}}processLinkingErrors(e,t,n){for(const r of e.references){const e=r.error;if(e){const n={node:e.container,property:e.property,index:e.index,data:{code:jo.LinkingError,containerType:e.container.$type,property:e.property,refText:e.reference.$refText}};t.push(this.toDiagnostic("error",e.message,n))}}}async validateAst(e,t,n=Eo.CancellationToken.None){const r=[],i=(e,t,n)=>{r.push(this.toDiagnostic(e,t,n))};return await Promise.all(dn(e).map((async e=>{await Io(n);const r=this.validationRegistry.getChecks(e.$type,t.categories);for(const t of r)await t(e,i,n)}))),r}toDiagnostic(e,t,n){return{message:t,range:fc(n),severity:pc(e),code:n.code,codeDescription:n.codeDescription,tags:n.tags,relatedInformation:n.relatedInformation,data:n.data,source:this.getSource()}}getSource(){return this.metadata.languageId}}function fc(e){if(e.range)return e.range;let t;return"string"==typeof e.property?t=Un(e.node.$cstNode,e.property,e.index):"string"==typeof e.keyword&&(t=Gn(e.node.$cstNode,e.keyword,e.index)),null!=t||(t=e.node.$cstNode),t?t.range:{start:{line:0,character:0},end:{line:0,character:0}}}function pc(e){switch(e){case"error":return 1;case"warning":return 2;case"info":return 3;case"hint":return 4;default:throw new Error("Invalid diagnostic severity: "+e)}}(Vo=jo||(jo={})).LexingError="lexing-error",Vo.ParsingError="parsing-error",Vo.LinkingError="linking-error";class mc{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,n=ln(e)){null!=t||(t=this.nameProvider.getName(e));const r=this.astNodeLocator.getAstNodePath(e);if(!t)throw new Error(`Node at path ${r} has no name.`);let i;const s=()=>{var t;return null!=i?i:i=ot(null!==(t=this.nameProvider.getNameNode(e))&&void 0!==t?t:e.$cstNode)};return{node:e,name:t,get nameSegment(){return s()},selectionSegment:ot(e.$cstNode),type:e.$type,documentUri:n.uri,path:r}}}class gc{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=Eo.CancellationToken.None){const n=[],r=e.parseResult.value;for(const i of dn(r))await Io(t),pn(i).filter((e=>!je(e))).forEach((e=>{const t=this.createDescription(e);t&&n.push(t)}));return n}createDescription(e){const t=e.reference.$nodeDescription,n=e.reference.$refNode;if(!t||!n)return;const r=ln(e.container).uri;return{sourceUri:r,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:ot(n),local:Uo.equals(t.documentUri,r)}}}class yc{constructor(){this.segmentSeparator="/",this.indexSeparator="@"}getAstNodePath(e){if(e.$container){const t=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return t+this.segmentSeparator+n}return""}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw new Error("Missing '$containerProperty' in AST node.");return void 0!==t?e+this.indexSeparator+t:e}getAstNode(e,t){return t.split(this.segmentSeparator).reduce(((e,t)=>{if(!e||0===t.length)return e;const n=t.indexOf(this.indexSeparator);if(n>0){const r=t.substring(0,n),i=parseInt(t.substring(n+1)),s=e[r];return null==s?void 0:s[i]}return e[t]}),e)}}class Tc{constructor(e){this._ready=new xo,this.settings={},this.workspaceConfig=!1,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){var t,n;this.workspaceConfig=null!==(n=null===(t=e.capabilities.workspace)||void 0===t?void 0:t.configuration)&&void 0!==n&&n}async initialized(e){if(this.workspaceConfig){if(e.register){const t=this.serviceRegistry.all;e.register({section:t.map((e=>this.toSectionName(e.LanguageMetaData.languageId)))})}if(e.fetchConfiguration){const t=this.serviceRegistry.all.map((e=>({section:this.toSectionName(e.LanguageMetaData.languageId)}))),n=await e.fetchConfiguration(t);t.forEach(((e,t)=>{this.updateSectionConfiguration(e.section,n[t])}))}}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 n=this.toSectionName(e);if(this.settings[n])return this.settings[n][t]}toSectionName(e){return`${e}`}}(Ho||(Ho={})).create=function(e){return{dispose:async()=>await e()}};class vc{constructor(e){this.updateBuildOptions={validation:{categories:["built-in","fast"]}},this.updateListeners=[],this.buildPhaseListeners=new Qo,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=Go.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},n=Eo.CancellationToken.None){var r,i;for(const s of e){const e=s.uri.toString();if(s.state===Go.Validated){if("boolean"==typeof t.validation&&t.validation)s.state=Go.IndexedReferences,s.diagnostics=void 0,this.buildState.delete(e);else if("object"==typeof t.validation){const n=this.buildState.get(e),a=null===(r=null==n?void 0:n.result)||void 0===r?void 0:r.validationChecks;if(a){const r=(null!==(i=t.validation.categories)&&void 0!==i?i:Ko.all).filter((e=>!a.includes(e)));r.length>0&&(this.buildState.set(e,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:r})},result:n.result}),s.state=Go.IndexedReferences)}}}else this.buildState.delete(e)}this.currentState=Go.Changed,await this.emitUpdate(e.map((e=>e.uri)),[]),await this.buildDocuments(e,t,n)}async update(e,t,n=Eo.CancellationToken.None){this.currentState=Go.Changed;for(const s of t)this.langiumDocuments.deleteDocument(s),this.buildState.delete(s.toString()),this.indexManager.remove(s);for(const s of e){if(!this.langiumDocuments.invalidateDocument(s)){const e=this.langiumDocumentFactory.fromModel({$type:"INVALID"},s);e.state=Go.Changed,this.langiumDocuments.addDocument(e)}this.buildState.delete(s.toString())}const r=Ze(e).concat(t).map((e=>e.toString())).toSet();this.langiumDocuments.all.filter((e=>!r.has(e.uri.toString())&&this.shouldRelink(e,r))).forEach((e=>{this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e),e.state=Math.min(e.state,Go.ComputedScopes),e.diagnostics=void 0})),await this.emitUpdate(e,t),await Io(n);const i=this.langiumDocuments.all.filter((e=>{var t;return e.state<Go.Linked||!(null===(t=this.buildState.get(e.uri.toString()))||void 0===t?void 0:t.completed)})).toArray();await this.buildDocuments(i,this.updateBuildOptions,n)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map((n=>n(e,t))))}shouldRelink(e,t){return!!e.references.some((e=>void 0!==e.error))||this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),Ho.create((()=>{const t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)}))}async buildDocuments(e,t,n){this.prepareBuild(e,t),await this.runCancelable(e,Go.Parsed,n,(e=>this.langiumDocumentFactory.update(e,n))),await this.runCancelable(e,Go.IndexedContent,n,(e=>this.indexManager.updateContent(e,n))),await this.runCancelable(e,Go.ComputedScopes,n,(async e=>{const t=this.serviceRegistry.getServices(e.uri).references.ScopeComputation;e.precomputedScopes=await t.computeLocalScopes(e,n)})),await this.runCancelable(e,Go.Linked,n,(e=>this.serviceRegistry.getServices(e.uri).references.Linker.link(e,n))),await this.runCancelable(e,Go.IndexedReferences,n,(e=>this.indexManager.updateReferences(e,n)));const r=e.filter((e=>this.shouldValidate(e)));await this.runCancelable(r,Go.Validated,n,(e=>this.validate(e,n)));for(const i of e){const e=this.buildState.get(i.uri.toString());e&&(e.completed=!0)}}prepareBuild(e,t){for(const n of e){const e=n.uri.toString(),r=this.buildState.get(e);r&&!r.completed||this.buildState.set(e,{completed:!1,options:t,result:null==r?void 0:r.result})}}async runCancelable(e,t,n,r){const i=e.filter((e=>e.state<t));for(const s of i)await Io(n),await r(s),s.state=t;await this.notifyBuildPhase(i,t,n),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),Ho.create((()=>{this.buildPhaseListeners.delete(e,t)}))}waitUntil(e,t,n){let r;if(t&&"path"in t?r=t:n=t,null!=n||(n=Eo.CancellationToken.None),r){const t=this.langiumDocuments.getDocument(r);if(t&&t.state>e)return Promise.resolve(r)}return this.currentState>=e?Promise.resolve(void 0):n.isCancellationRequested?Promise.reject(ko):new Promise(((t,i)=>{const s=this.onBuildPhase(e,(()=>{if(s.dispose(),a.dispose(),r){const e=this.langiumDocuments.getDocument(r);t(null==e?void 0:e.uri)}else t(void 0)})),a=n.onCancellationRequested((()=>{s.dispose(),a.dispose(),i(ko)}))}))}async notifyBuildPhase(e,t,n){if(0===e.length)return;const r=this.buildPhaseListeners.get(t);for(const i of r)await Io(n),await i(e,n)}shouldValidate(e){return Boolean(this.getBuildOptions(e).validation)}async validate(e,t){var n,r;const i=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,s=this.getBuildOptions(e).validation,a="object"==typeof s?s:void 0,o=await i.validateDocument(e,a,t);e.diagnostics?e.diagnostics.push(...o):e.diagnostics=o;const c=this.buildState.get(e.uri.toString());if(c){null!==(n=c.result)&&void 0!==n||(c.result={});const e=null!==(r=null==a?void 0:a.categories)&&void 0!==r?r:Ko.all;c.result.validationChecks?c.result.validationChecks.push(...e):c.result.validationChecks=[...e]}}getBuildOptions(e){var t,n;return null!==(n=null===(t=this.buildState.get(e.uri.toString()))||void 0===t?void 0:t.options)&&void 0!==n?n:{}}}class Rc{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new ic,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){const n=ln(e).uri,r=[];return this.referenceIndex.forEach((e=>{e.forEach((e=>{Uo.equals(e.targetUri,n)&&e.targetPath===t&&r.push(e)}))})),Ze(r)}allElements(e,t){let n=Ze(this.symbolIndex.keys());return t&&(n=n.filter((e=>!t||t.has(e)))),n.map((t=>this.getFileDescriptions(t,e))).flat()}getFileDescriptions(e,t){var n;if(!t)return null!==(n=this.symbolIndex.get(e))&&void 0!==n?n:[];return this.symbolByTypeIndex.get(e,t,(()=>{var n;return(null!==(n=this.symbolIndex.get(e))&&void 0!==n?n:[]).filter((e=>this.astReflection.isSubtype(e.type,t)))}))}remove(e){const t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=Eo.CancellationToken.None){const n=this.serviceRegistry.getServices(e.uri),r=await n.references.ScopeComputation.computeExports(e,t),i=e.uri.toString();this.symbolIndex.set(i,r),this.symbolByTypeIndex.clear(i)}async updateReferences(e,t=Eo.CancellationToken.None){const n=this.serviceRegistry.getServices(e.uri),r=await n.workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),r)}isAffected(e,t){const n=this.referenceIndex.get(e.uri.toString());return!!n&&n.some((e=>!e.local&&t.has(e.targetUri.toString())))}}class Ec{constructor(e){this.initialBuildOptions={},this._ready=new xo,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=null!==(t=e.workspaceFolders)&&void 0!==t?t:void 0}initialized(e){return this.mutex.write((e=>{var t;return this.initializeWorkspace(null!==(t=this.folders)&&void 0!==t?t:[],e)}))}async initializeWorkspace(e,t=Eo.CancellationToken.None){const n=await this.performStartup(e);await Io(t),await this.documentBuilder.build(n,this.initialBuildOptions,t)}async performStartup(e){const t=this.serviceRegistry.all.flatMap((e=>e.LanguageMetaData.fileExtensions)),n=[],r=e=>{n.push(e),this.langiumDocuments.hasDocument(e.uri)||this.langiumDocuments.addDocument(e)};return await this.loadAdditionalDocuments(e,r),await Promise.all(e.map((e=>[e,this.getRootFolder(e)])).map((async e=>this.traverseFolder(...e,t,r)))),this._ready.resolve(),n}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Mo.parse(e.uri)}async traverseFolder(e,t,n,r){const i=await this.fileSystemProvider.readDirectory(t);await Promise.all(i.map((async t=>{if(this.includeEntry(e,t,n))if(t.isDirectory)await this.traverseFolder(e,t.uri,n,r);else if(t.isFile){const e=await this.langiumDocuments.getOrCreateDocument(t.uri);r(e)}})))}includeEntry(e,t,n){const r=Uo.basename(t.uri);if(r.startsWith("."))return!1;if(t.isDirectory)return"node_modules"!==r&&"out"!==r;if(t.isFile){const e=Uo.extname(t.uri);return n.includes(e)}return!1}}class Ac{constructor(e){const t=e.parser.TokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(t);const n=Sc(t)?Object.values(t):t;this.chevrotainLexer=new pi(n,{positionTracking:"full"})}get definition(){return this.tokenTypes}tokenize(e){var t;const n=this.chevrotainLexer.tokenize(e);return{tokens:n.tokens,errors:n.errors,hidden:null!==(t=n.groups.hidden)&&void 0!==t?t:[]}}toTokenTypeDictionary(e){if(Sc(e))return e;const t=kc(e)?Object.values(e.modes).flat():e,n={};return t.forEach((e=>n[e.name]=e)),n}}function kc(e){return e&&"modes"in e&&"defaultMode"in e}function Sc(e){return!function(e){return Array.isArray(e)&&(0===e.length||"name"in e[0])}(e)&&!kc(e)}function Ic(e,t,n){let r,i;"string"==typeof e?(i=t,r=n):(i=e.range.start,r=t),i||(i=B.create(0,0));const s=function(e){var t,n,r;const i=[];let s=e.position.line,a=e.position.character;for(let o=0;o<e.lines.length;o++){const c=0===o,l=o===e.lines.length-1;let u=e.lines[o],h=0;if(c&&e.options.start){const n=null===(t=e.options.start)||void 0===t?void 0:t.exec(u);n&&(h=n.index+n[0].length)}else{const t=null===(n=e.options.line)||void 0===n?void 0:n.exec(u);t&&(h=t.index+t[0].length)}if(l){const t=null===(r=e.options.end)||void 0===r?void 0:r.exec(u);t&&(u=u.substring(0,t.index))}u=u.substring(0,_c(u));if(Oc(u,h)>=u.length){if(i.length>0){const e=B.create(s,a);i.push({type:"break",content:"",range:j.create(e,e)})}}else{Nc.lastIndex=h;const e=Nc.exec(u);if(e){const t=e[0],n=e[1],r=B.create(s,a+h),o=B.create(s,a+h+t.length);i.push({type:"tag",content:n,range:j.create(r,o)}),h+=t.length,h=Oc(u,h)}if(h<u.length){const e=u.substring(h),t=Array.from(e.matchAll($c));i.push(...Cc(t,e,s,a+h))}}s++,a=0}if(i.length>0&&"break"===i[i.length-1].type)return i.slice(0,-1);return i}({lines:xc(e),position:i,options:Fc(r)});return function(e){var t,n,r,i;const s=B.create(e.position.line,e.position.character);if(0===e.tokens.length)return new Bc([],j.create(s,s));const a=[];for(;e.index<e.tokens.length;){const t=bc(e,a[a.length-1]);t&&a.push(t)}const o=null!==(n=null===(t=a[0])||void 0===t?void 0:t.range.start)&&void 0!==n?n:s,c=null!==(i=null===(r=a[a.length-1])||void 0===r?void 0:r.range.end)&&void 0!==i?i:s;return new Bc(a,j.create(o,c))}({index:0,tokens:s,position:i})}function xc(e){let t="";t="string"==typeof e?e:e.text;return t.split(Cn)}const Nc=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,$c=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function Cc(e,t,n,r){const i=[];if(0===e.length){const e=B.create(n,r),s=B.create(n,r+t.length);i.push({type:"text",content:t,range:j.create(e,s)})}else{let s=0;for(const o of e){const e=o.index,a=t.substring(s,e);a.length>0&&i.push({type:"text",content:t.substring(s,e),range:j.create(B.create(n,s+r),B.create(n,e+r))});let c=a.length+1;const l=o[1];if(i.push({type:"inline-tag",content:l,range:j.create(B.create(n,s+c+r),B.create(n,s+c+l.length+r))}),c+=l.length,4===o.length){c+=o[2].length;const e=o[3];i.push({type:"text",content:e,range:j.create(B.create(n,s+c+r),B.create(n,s+c+e.length+r))})}else i.push({type:"text",content:"",range:j.create(B.create(n,s+c+r),B.create(n,s+c+r))});s=e+o[0].length}const a=t.substring(s);a.length>0&&i.push({type:"text",content:a,range:j.create(B.create(n,s+r),B.create(n,s+r+a.length))})}return i}const wc=/\S/,Lc=/\s*$/;function Oc(e,t){const n=e.substring(t).match(wc);return n?t+n.index:e.length}function _c(e){const t=e.match(Lc);if(t&&"number"==typeof t.index)return t.index}function bc(e,t){const n=e.tokens[e.index];return"tag"===n.type?Dc(e,!1):"text"===n.type||"inline-tag"===n.type?Pc(e):(function(e,t){if(t){const n=new Vc("",e.range);"inlines"in t?t.inlines.push(n):t.content.inlines.push(n)}}(n,t),void e.index++)}function Pc(e){let t=e.tokens[e.index];const n=t;let r=t;const i=[];for(;t&&"break"!==t.type&&"tag"!==t.type;)i.push(Mc(e)),r=t,t=e.tokens[e.index];return new jc(i,j.create(n.range.start,r.range.end))}function Mc(e){return"inline-tag"===e.tokens[e.index].type?Dc(e,!0):Uc(e)}function Dc(e,t){const n=e.tokens[e.index++],r=n.content.substring(1),i=e.tokens[e.index];if("text"===(null==i?void 0:i.type)){if(t){const i=Uc(e);return new Kc(r,new jc([i],i.range),t,j.create(n.range.start,i.range.end))}{const i=Pc(e);return new Kc(r,i,t,j.create(n.range.start,i.range.end))}}{const e=n.range;return new Kc(r,new jc([],e),t,e)}}function Uc(e){const t=e.tokens[e.index++];return new Vc(t.content,t.range)}function Fc(e){if(!e)return Fc({start:"/**",end:"*/",line:"*"});const{start:t,end:n,line:r}=e;return{start:Gc(t,!0),end:Gc(n,!1),line:Gc(r,!0)}}function Gc(e,t){if("string"==typeof e||"object"==typeof e){const n="string"==typeof e?bn(e):e.source;return t?new RegExp(`^\\s*${n}`):new RegExp(`\\s*${n}\\s*$`)}return e}class Bc{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(0===e.length)e=t.toString();else{const n=t.toString();e+=Hc(e)+n}return e.trim()}toMarkdown(e){let t="";for(const n of this.elements)if(0===t.length)t=n.toMarkdown(e);else{const r=n.toMarkdown(e);t+=Hc(t)+r}return t.trim()}}class Kc{constructor(e,t,n,r){this.name=e,this.content=t,this.inline=n,this.range=r}toString(){let e=`@${this.name}`;const t=this.content.toString();return 1===this.content.inlines.length?e=`${e} ${t}`:this.content.inlines.length>1&&(e=`${e}\n${t}`),this.inline?`{${e}}`:e}toMarkdown(e){var t,n;return null!==(n=null===(t=null==e?void 0:e.renderTag)||void 0===t?void 0:t.call(e,this))&&void 0!==n?n:this.toMarkdownDefault(e)}toMarkdownDefault(e){const t=this.content.toMarkdown(e);if(this.inline){const n=function(e,t,n){var r,i;if("linkplain"===e||"linkcode"===e||"link"===e){const s=t.indexOf(" ");let a=t;if(s>0){const e=Oc(t,s);a=t.substring(e),t=t.substring(0,s)}("linkcode"===e||"link"===e&&"code"===n.link)&&(a=`\`${a}\``);const o=null!==(i=null===(r=n.renderLink)||void 0===r?void 0:r.call(n,t,a))&&void 0!==i?i:function(e,t){try{return Mo.parse(e,!0),`[${t}](${e})`}catch(r){return e}}(t,a);return o}return}(this.name,t,null!=e?e:{});if("string"==typeof n)return n}let n="";"italic"===(null==e?void 0:e.tag)||void 0===(null==e?void 0:e.tag)?n="*":"bold"===(null==e?void 0:e.tag)?n="**":"bold-italic"===(null==e?void 0:e.tag)&&(n="***");let r=`${n}@${this.name}${n}`;return 1===this.content.inlines.length?r=`${r} — ${t}`:this.content.inlines.length>1&&(r=`${r}\n${t}`),this.inline?`{${r}}`:r}}class jc{constructor(e,t){this.inlines=e,this.range=t}toString(){let e="";for(let t=0;t<this.inlines.length;t++){const n=this.inlines[t],r=this.inlines[t+1];e+=n.toString(),r&&r.range.start.line>n.range.start.line&&(e+="\n")}return e}toMarkdown(e){let t="";for(let n=0;n<this.inlines.length;n++){const r=this.inlines[n],i=this.inlines[n+1];t+=r.toMarkdown(e),i&&i.range.start.line>r.range.start.line&&(t+="\n")}return t}}class Vc{constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}}function Hc(e){return e.endsWith("\n")?"\n":"\n\n"}class Wc{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){const t=this.commentProvider.getComment(e);if(t&&function(e,t){const n=Fc(t),r=xc(e);if(0===r.length)return!1;const i=r[0],s=r[r.length-1],a=n.start,o=n.end;return Boolean(null==a?void 0:a.exec(i))&&Boolean(null==o?void 0:o.exec(s))}(t)){return Ic(t).toMarkdown({renderLink:(t,n)=>this.documentationLinkRenderer(e,t,n),renderTag:t=>this.documentationTagRenderer(e,t)})}}documentationLinkRenderer(e,t,n){var r;const i=null!==(r=this.findNameInPrecomputedScopes(e,t))&&void 0!==r?r:this.findNameInGlobalScope(e,t);if(i&&i.nameSegment){const e=i.nameSegment.range.start.line+1,t=i.nameSegment.range.start.character+1;return`[${n}](${i.documentUri.with({fragment:`L${e},${t}`}).toString()})`}}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){const n=ln(e).precomputedScopes;if(!n)return;let r=e;do{const e=n.get(r).find((e=>e.name===t));if(e)return e;r=r.$container}while(r)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find((e=>e.name===t))}}class zc{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){var t;return function(e){return"string"==typeof e.$comment}(e)?e.$comment:null===(t=function(e,t){if(e){const n=function(e,t=!0){for(;e.container;){const n=e.container;let r=n.content.indexOf(e);for(;r>0;){r--;const e=n.content[r];if(t||!e.hidden)return e}e=n}}(e,!0);if(n&&ut(n,t))return n;if(ze(e))for(let r=e.content.findIndex((e=>!e.hidden))-1;r>=0;r--){const n=e.content[r];if(ut(n,t))return n}}}(e.$cstNode,this.grammarConfig().multilineCommentRules))||void 0===t?void 0:t.text}}V();class Yc{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e){return Promise.resolve(this.syncParser.parse(e))}}class qc{constructor(){this.previousTokenSource=new Eo.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();const t=new Eo.CancellationTokenSource;return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n){const r=new xo,i={action:t,deferred:r,cancellationToken:null!=n?n:Eo.CancellationToken.None};return e.push(i),this.performNextOperation(),r.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))return;e.push(...this.readQueue.splice(0,this.readQueue.length))}this.done=!1,await Promise.all(e.map((async({action:e,deferred:t,cancellationToken:n})=>{try{const r=await Promise.resolve().then((()=>e(n)));t.resolve(r)}catch(r){So(r)?t.resolve(void 0):t.reject(r)}}))),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}}class Xc{constructor(e){this.grammarElementIdMap=new Jo,this.tokenTypeIdMap=new Jo,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors.map((e=>Object.assign({},e))),parserErrors:e.parserErrors.map((e=>Object.assign({},e))),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}createDehyrationContext(e){const t=new Map,n=new Map;for(const r of dn(e))t.set(r,{});if(e.$cstNode)for(const r of st(e.$cstNode))n.set(r,{});return{astNodes:t,cstNodes:n}}dehydrateAstNode(e,t){const n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,void 0!==e.$cstNode&&(n.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(const[r,i]of Object.entries(e))if(!r.startsWith("$"))if(Array.isArray(i)){const e=[];n[r]=e;for(const n of i)Be(n)?e.push(this.dehydrateAstNode(n,t)):Ke(n)?e.push(this.dehydrateReference(n,t)):e.push(n)}else Be(i)?n[r]=this.dehydrateAstNode(i,t):Ke(i)?n[r]=this.dehydrateReference(i,t):void 0!==i&&(n[r]=i);return n}dehydrateReference(e,t){const n={};return n.$refText=e.$refText,e.$refNode&&(n.$refNode=t.cstNodes.get(e.$refNode)),n}dehydrateCstNode(e,t){const n=t.cstNodes.get(e);return ze(e)?n.fullText=e.fullText:n.grammarSource=this.getGrammarElementId(e.grammarSource),n.hidden=e.hidden,n.astNode=t.astNodes.get(e.astNode),He(e)?n.content=e.content.map((e=>this.dehydrateCstNode(e,t))):We(e)&&(n.tokenType=e.tokenType.name,n.offset=e.offset,n.length=e.length,n.startLine=e.range.start.line,n.startColumn=e.range.start.character,n.endLine=e.range.end.line,n.endColumn=e.range.end.character),n}hydrate(e){const t=e.value,n=this.createHydrationContext(t);return"$cstNode"in t&&this.hydrateCstNode(t.$cstNode,n),{lexerErrors:e.lexerErrors,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,n)}}createHydrationContext(e){const t=new Map,n=new Map;for(const i of dn(e))t.set(i,{});let r;if(e.$cstNode)for(const i of st(e.$cstNode)){let e;"fullText"in i?(e=new Qa(i.fullText),r=e):"content"in i?e=new qa:"tokenType"in i&&(e=this.hydrateCstLeafNode(i)),e&&(n.set(i,e),e.root=r)}return{astNodes:t,cstNodes:n}}hydrateAstNode(e,t){const n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode&&(n.$cstNode=t.cstNodes.get(e.$cstNode));for(const[r,i]of Object.entries(e))if(!r.startsWith("$"))if(Array.isArray(i)){const e=[];n[r]=e;for(const s of i)Be(s)?e.push(this.setParent(this.hydrateAstNode(s,t),n)):Ke(s)?e.push(this.hydrateReference(s,n,r,t)):e.push(s)}else Be(i)?n[r]=this.setParent(this.hydrateAstNode(i,t),n):Ke(i)?n[r]=this.hydrateReference(i,n,r,t):void 0!==i&&(n[r]=i);return n}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,n,r){return this.linker.buildReference(t,n,r.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,n=0){const r=t.cstNodes.get(e);if("number"==typeof e.grammarSource&&(r.grammarSource=this.getGrammarElement(e.grammarSource)),r.astNode=t.astNodes.get(e.astNode),He(r))for(const i of e.content){const e=this.hydrateCstNode(i,t,n++);r.content.push(e)}return r}hydrateCstLeafNode(e){const t=this.getTokenType(e.tokenType),n=e.offset,r=e.length,i=e.startLine,s=e.startColumn,a=e.endLine,o=e.endColumn,c=e.hidden;return new Ya(n,r,{start:{line:i,character:s},end:{line:a,character:o}},t,c)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){return 0===this.grammarElementIdMap.size&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){0===this.grammarElementIdMap.size&&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 n of dn(this.grammar))t=n,on.isInstance(t,yt)&&this.grammarElementIdMap.set(n,e++);var t}}function Qc(e){return{documentation:{CommentProvider:e=>new zc(e),DocumentationProvider:e=>new Wc(e)},parser:{AsyncParser:e=>new Yc(e),GrammarConfig:e=>function(e){const t=[],n=e.Grammar;for(const i of n.rules)Lt(i)&&(r=i).hidden&&!zn(r).test(" ")&&On(zn(i))&&t.push(i.name);var r;return{multilineCommentRules:t,nameRegexp:lt}}(e),LangiumParser:e=>yo(e),CompletionParser:e=>function(e){const t=e.Grammar,n=e.parser.Lexer,r=new so(e);return co(t,r,n.definition),r.finalize(),r}(e),ValueConverter:()=>new vo,TokenBuilder:()=>new To,Lexer:e=>new Ac(e),ParserErrorMessageProvider:()=>new io},workspace:{AstNodeLocator:()=>new yc,AstNodeDescriptionProvider:e=>new mc(e),ReferenceDescriptionProvider:e=>new gc(e)},references:{Linker:e=>new Yo(e),NameProvider:()=>new qo,ScopeProvider:e=>new ac(e),ScopeComputation:e=>new Zo(e),References:e=>new Xo(e)},serializer:{Hydrator:e=>new Xc(e),JsonSerializer:e=>new cc(e)},validation:{DocumentValidator:e=>new dc(e),ValidationRegistry:e=>new hc(e)},shared:()=>e.shared}}function Jc(e){return{ServiceRegistry:()=>new lc,workspace:{LangiumDocuments:e=>new zo(e),LangiumDocumentFactory:e=>new Wo(e),DocumentBuilder:e=>new vc(e),IndexManager:e=>new Rc(e),WorkspaceManager:e=>new Ec(e),FileSystemProvider:t=>e.fileSystemProvider(t),WorkspaceLock:()=>new qc,ConfigurationProvider:e=>new Tc(e)}}}var Zc;function el(e,t,n,r,i,s,a,o,c){return nl([e,t,n,r,i,s,a,o,c].reduce(sl,{}))}(Zc||(Zc={})).merge=(e,t)=>sl(sl({},e),t);const tl=Symbol("isProxy");function nl(e,t){const n=new Proxy({},{deleteProperty:()=>!1,get:(r,i)=>il(r,i,e,t||n),getOwnPropertyDescriptor:(r,i)=>(il(r,i,e,t||n),Object.getOwnPropertyDescriptor(r,i)),has:(t,n)=>n in e,ownKeys:()=>[...Reflect.ownKeys(e),tl]});return n[tl]=!0,n}const rl=Symbol();function il(e,t,n,r){if(t in e){if(e[t]instanceof Error)throw new Error("Construction failure. Please make sure that your dependencies are constructable.",{cause:e[t]});if(e[t]===rl)throw new Error('Cycle detected. Please make "'+String(t)+'" lazy. See https://langium.org/docs/configuration-services/#resolving-cyclic-dependencies');return e[t]}if(t in n){const s=n[t];e[t]=rl;try{e[t]="function"==typeof s?s(r):nl(s,r)}catch(i){throw e[t]=i instanceof Error?i:void 0,i}return e[t]}}function sl(e,t){if(t)for(const[n,r]of Object.entries(t))if(void 0!==r){const t=e[n];e[n]=null!==t&&null!==r&&"object"==typeof t&&"object"==typeof r?sl(t,r):r}return e}class al{readFile(){throw new Error("No file system is available.")}async readDirectory(){return[]}}const ol={fileSystemProvider:()=>new al},cl={Grammar:()=>{},LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[".langium"],languageId:"langium"})},ll={AstReflection:()=>new an};function ul(e){var t;const n=function(){const e=el(Jc(ol),ll),t=el(Qc({shared:e}),cl);return e.ServiceRegistry.register(t),t}(),r=n.serializer.JsonSerializer.deserialize(e);return n.shared.workspace.LangiumDocumentFactory.fromModel(r,Mo.parse(`memory://${null!==(t=r.name)&&void 0!==t?t:"grammar"}.langium`)),r}var hl=Object.defineProperty,dl=(e,t)=>hl(e,"name",{value:t,configurable:!0});dl((function(e){return kl.isInstance(e,"Architecture")}),"isArchitecture");var fl="Branch";dl((function(e){return kl.isInstance(e,fl)}),"isBranch");var pl="Commit";dl((function(e){return kl.isInstance(e,pl)}),"isCommit");dl((function(e){return kl.isInstance(e,"Common")}),"isCommon");var ml="GitGraph";dl((function(e){return kl.isInstance(e,ml)}),"isGitGraph");dl((function(e){return kl.isInstance(e,"Info")}),"isInfo");var gl="Merge";dl((function(e){return kl.isInstance(e,gl)}),"isMerge");dl((function(e){return kl.isInstance(e,"Packet")}),"isPacket");dl((function(e){return kl.isInstance(e,"PacketBlock")}),"isPacketBlock");dl((function(e){return kl.isInstance(e,"Pie")}),"isPie");dl((function(e){return kl.isInstance(e,"PieSection")}),"isPieSection");var yl,Tl,vl,Rl,El,Al=(dl(e=class extends Ve{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 fl:case"Checkout":case"CherryPicking":case pl:case gl:return this.isSubtype("Statement",t);case"Direction":return this.isSubtype(ml,t);default:return!1}}getReferenceType(e){const t=`${e.container.$type}:${e.property}`;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:[]}}}},"MermaidAstReflection"),e),kl=new Al,Sl=dl((()=>yl??(yl=ul('{"$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"),Il=dl((()=>Tl??(Tl=ul('{"$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"),xl=dl((()=>vl??(vl=ul('{"$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"),Nl=dl((()=>Rl??(Rl=ul('{"$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"),$l=dl((()=>El??(El=ul('{"$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"),Cl={languageId:"info",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},wl={languageId:"packet",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Ll={languageId:"pie",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Ol={languageId:"architecture",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},_l={languageId:"gitGraph",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},bl={AstReflection:dl((()=>new Al),"AstReflection")},Pl={Grammar:dl((()=>Sl()),"Grammar"),LanguageMetaData:dl((()=>Cl),"LanguageMetaData"),parser:{}},Ml={Grammar:dl((()=>Il()),"Grammar"),LanguageMetaData:dl((()=>wl),"LanguageMetaData"),parser:{}},Dl={Grammar:dl((()=>xl()),"Grammar"),LanguageMetaData:dl((()=>Ll),"LanguageMetaData"),parser:{}},Ul={Grammar:dl((()=>Nl()),"Grammar"),LanguageMetaData:dl((()=>Ol),"LanguageMetaData"),parser:{}},Fl={Grammar:dl((()=>$l()),"Grammar"),LanguageMetaData:dl((()=>_l),"LanguageMetaData"),parser:{}},Gl={ACC_DESCR:/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,ACC_TITLE:/accTitle[\t ]*:([^\n\r]*)/,TITLE:/title([\t ][^\n\r]*|)/},Bl=(dl(t=class extends vo{runConverter(e,t,n){let r=this.runCommonConverter(e,t,n);return void 0===r&&(r=this.runCustomConverter(e,t,n)),void 0===r?super.runConverter(e,t,n):r}runCommonConverter(e,t,n){const r=Gl[e.name];if(void 0===r)return;const i=r.exec(t);return null!==i?void 0!==i[1]?i[1].trim().replace(/[\t ]{2,}/gm," "):void 0!==i[2]?i[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,"\n"):void 0:void 0}},"AbstractMermaidValueConverter"),t),Kl=(dl(n=class extends Bl{runCustomConverter(e,t,n){}},"CommonValueConverter"),n),jl=(dl(r=class extends To{constructor(e){super(),this.keywords=new Set(e)}buildKeywordTokens(e,t,n){const r=super.buildKeywordTokens(e,t,n);return r.forEach((e=>{this.keywords.has(e.name)&&void 0!==e.PATTERN&&(e.PATTERN=new RegExp(e.PATTERN.toString()+"(?:(?=%%)|(?!\\S))"))})),r}},"AbstractMermaidTokenBuilder"),r);dl(class extends jl{},"CommonTokenBuilder");var Vl=(dl(i=class extends jl{constructor(){super(["gitGraph"])}},"GitGraphTokenBuilder"),i),Hl={parser:{TokenBuilder:dl((()=>new Vl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function Wl(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Fl,Hl);return t.ServiceRegistry.register(n),{shared:t,GitGraph:n}}dl(Wl,"createGitGraphServices");var zl=(dl(s=class extends jl{constructor(){super(["info","showInfo"])}},"InfoTokenBuilder"),s),Yl={parser:{TokenBuilder:dl((()=>new zl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function ql(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Pl,Yl);return t.ServiceRegistry.register(n),{shared:t,Info:n}}dl(ql,"createInfoServices");var Xl=(dl(a=class extends jl{constructor(){super(["packet-beta"])}},"PacketTokenBuilder"),a),Ql={parser:{TokenBuilder:dl((()=>new Xl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function Jl(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Ml,Ql);return t.ServiceRegistry.register(n),{shared:t,Packet:n}}dl(Jl,"createPacketServices");var Zl=(dl(o=class extends jl{constructor(){super(["pie","showData"])}},"PieTokenBuilder"),o),eu=(dl(c=class extends Bl{runCustomConverter(e,t,n){if("PIE_SECTION_LABEL"===e.name)return t.replace(/"/g,"").trim()}},"PieValueConverter"),c),tu={parser:{TokenBuilder:dl((()=>new Zl),"TokenBuilder"),ValueConverter:dl((()=>new eu),"ValueConverter")}};function nu(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Dl,tu);return t.ServiceRegistry.register(n),{shared:t,Pie:n}}dl(nu,"createPieServices");var ru=(dl(l=class extends jl{constructor(){super(["architecture"])}},"ArchitectureTokenBuilder"),l),iu=(dl(u=class extends Bl{runCustomConverter(e,t,n){return"ARCH_ICON"===e.name?t.replace(/[()]/g,"").trim():"ARCH_TEXT_ICON"===e.name?t.replace(/["()]/g,""):"ARCH_TITLE"===e.name?t.replace(/[[\]]/g,"").trim():void 0}},"ArchitectureValueConverter"),u),su={parser:{TokenBuilder:dl((()=>new ru),"TokenBuilder"),ValueConverter:dl((()=>new iu),"ValueConverter")}};function au(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Ul,su);return t.ServiceRegistry.register(n),{shared:t,Architecture:n}}dl(au,"createArchitectureServices");var ou={},cu={info:dl((async()=>{const{createInfoServices:e}=await H((async()=>{const{createInfoServices:e}=await Promise.resolve().then((()=>hu));return{createInfoServices:e}}),void 0,import.meta.url),t=e().Info.parser.LangiumParser;ou.info=t}),"info"),packet:dl((async()=>{const{createPacketServices:e}=await H((async()=>{const{createPacketServices:e}=await Promise.resolve().then((()=>du));return{createPacketServices:e}}),void 0,import.meta.url),t=e().Packet.parser.LangiumParser;ou.packet=t}),"packet"),pie:dl((async()=>{const{createPieServices:e}=await H((async()=>{const{createPieServices:e}=await Promise.resolve().then((()=>fu));return{createPieServices:e}}),void 0,import.meta.url),t=e().Pie.parser.LangiumParser;ou.pie=t}),"pie"),architecture:dl((async()=>{const{createArchitectureServices:e}=await H((async()=>{const{createArchitectureServices:e}=await Promise.resolve().then((()=>pu));return{createArchitectureServices:e}}),void 0,import.meta.url),t=e().Architecture.parser.LangiumParser;ou.architecture=t}),"architecture"),gitGraph:dl((async()=>{const{createGitGraphServices:e}=await H((async()=>{const{createGitGraphServices:e}=await Promise.resolve().then((()=>mu));return{createGitGraphServices:e}}),void 0,import.meta.url),t=e().GitGraph.parser.LangiumParser;ou.gitGraph=t}),"gitGraph")};async function lu(e,t){const n=cu[e];if(!n)throw new Error(`Unknown diagram type: ${e}`);ou[e]||await n();const r=ou[e].parse(t);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new uu(r);return r.value}dl(lu,"parse");var uu=(dl(h=class extends Error{constructor(e){super(`Parsing failed: ${e.lexerErrors.map((e=>e.message)).join("\n")} ${e.parserErrors.map((e=>e.message)).join("\n")}`),this.result=e}},"MermaidParseError"),h);const hu=Object.freeze(Object.defineProperty({__proto__:null,InfoModule:Yl,createInfoServices:ql},Symbol.toStringTag,{value:"Module"})),du=Object.freeze(Object.defineProperty({__proto__:null,PacketModule:Ql,createPacketServices:Jl},Symbol.toStringTag,{value:"Module"})),fu=Object.freeze(Object.defineProperty({__proto__:null,PieModule:tu,createPieServices:nu},Symbol.toStringTag,{value:"Module"})),pu=Object.freeze(Object.defineProperty({__proto__:null,ArchitectureModule:su,createArchitectureServices:au},Symbol.toStringTag,{value:"Module"})),mu=Object.freeze(Object.defineProperty({__proto__:null,GitGraphModule:Hl,createGitGraphServices:Wl},Symbol.toStringTag,{value:"Module"}));export{lu as p};
1
+ var e,t,n,r,i,s,a,o,c,l,u,h,d=Object.defineProperty,f=(e,t,n)=>((e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);import{mW as p,d1 as m,m as g,cx as y,F as T,cO as v,af as R,cT as E,cU as A,y as k,A as S,z as I,bI as x,mX as N,cV as $,cG as C,mY as w,ai as L,cI as O,ae as _,mZ as b,cP as P,m_ as M,cX as D,D as U,ah as F,bM as G,m$ as B,n0 as K,n1 as j,n2 as V,d3 as H}from"./index-BWk3jiBX.js";import{b as W,a as z}from"./_baseEach-DpbbGUyy.js";import{g as Y,v as q,h as X,j as Q,k as J,a as Z,c as ee,i as te,r as ne,f as re,n as ie}from"./_baseUniq-CvL-RqJ5.js";import{m as se,f as ae,h as oe,d as ce,l as le,c as ue}from"./min-UyCMjPNL.js";import{a8 as he}from"./mermaid-CHaP3AnD.js";import{c as de}from"./clone-B99LlreQ.js";var fe=Object.prototype.hasOwnProperty,pe=p((function(e,t){if(m(t)||g(t))y(t,T(t),e);else for(var n in t)fe.call(t,n)&&v(e,n,t[n])}));function me(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var s=e[t];s&&(i[r++]=s)}return i}function ge(e,t,n,r){for(var i=-1,s=null==e?0:e.length;++i<s;){var a=e[i];t(r,a,n(a),e)}return r}function ye(e,t,n,r){return W(e,(function(e,i,s){t(r,e,n(e),s)})),r}var Te=k((function(e,t){return S(e)?function(e,t,n,r){var i=-1,s=Y,a=!0,o=e.length,c=[],l=t.length;if(!o)return c;t.length>=200&&(s=A,a=!1,t=new E(t));e:for(;++i<o;){var u=e[i],h=u;if(u=0!==u?u:0,a&&h==h){for(var d=l;d--;)if(t[d]===h)continue e;c.push(u)}else s(t,h,r)||c.push(u)}return c}(e,I(t,1,S,!0)):[]}));function ve(e,t,n){var r=null==e?0:e.length;return r?(t=void 0===t?1:x(t),N(e,t<0?0:t,r)):[]}function Re(e,t,n){var r=null==e?0:e.length;return r?(t=void 0===t?1:x(t),N(e,0,(t=r-t)<0?0:t)):[]}function Ee(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Ae(e,t){var n=!0;return W(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ke(e,t,n){return(R(e)?Ee:Ae)(e,z(t))}function Se(e){return e&&e.length?e[0]:void 0}function Ie(e,t){return I(se(e,t))}var xe,Ne,$e=Object.prototype.hasOwnProperty,Ce=(xe=function(e,t,n){$e.call(e,n)?e[n].push(t):$(e,n,[t])},function(e,t){var n=R(e)?ge:ye,r=Ne?Ne():{};return n(e,xe,z(t),r)});function we(e){return"string"==typeof e||!R(e)&&C(e)&&"[object String]"==w(e)}var Le=Math.max;function Oe(e,t,n,r){e=g(e)?e:q(e),n=n?x(n):0;var i=e.length;return n<0&&(n=Le(i+n,0)),we(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&X(e,t,n)>-1}function _e(e,t,n){if(!(null==e?0:e.length))return-1;return X(e,t,0)}var be=O&&O.isRegExp,Pe=be?L(be):function(e){return C(e)&&"[object RegExp]"==w(e)};function Me(e,t){if(null==e)return{};var n=_(Q(e),(function(e){return[e]}));return t=z(t),b(e,n,(function(e,n){return t(e,n[0])}))}function De(e,t){return(R(e)?P:J)(e,function(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}(z(t)))}function Ue(e,t){var n;return W(e,(function(e,r,i){return!(n=t(e,r,i))})),!!n}function Fe(e,t,n){return(R(e)?M:Ue)(e,z(t))}function Ge(e){return e&&e.length?Z(e):[]}function Be(e){return"object"==typeof e&&null!==e&&"string"==typeof e.$type}function Ke(e){return"object"==typeof e&&null!==e&&"string"==typeof e.$refText}function je(e){return"object"==typeof e&&null!==e&&Be(e.container)&&Ke(e.reference)&&"string"==typeof e.message}class Ve{constructor(){this.subtypes={},this.allSubtypes={}}isInstance(e,t){return Be(e)&&this.isSubtype(e.$type,t)}isSubtype(e,t){if(e===t)return!0;let n=this.subtypes[e];n||(n=this.subtypes[e]={});const r=n[t];if(void 0!==r)return r;{const r=this.computeIsSubtype(e,t);return n[t]=r,r}}getAllSubTypes(e){const t=this.allSubtypes[e];if(t)return t;{const t=this.getAllTypes(),n=[];for(const r of t)this.isSubtype(r,e)&&n.push(r);return this.allSubtypes[e]=n,n}}}function He(e){return"object"==typeof e&&null!==e&&Array.isArray(e.content)}function We(e){return"object"==typeof e&&null!==e&&"object"==typeof e.tokenType}function ze(e){return He(e)&&"string"==typeof e.fullText}class Ye{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(){const e=this.iterator();return Boolean(e.next().done)}count(){const e=this.iterator();let t=0,n=e.next();for(;!n.done;)t++,n=e.next();return t}toArray(){const e=[],t=this.iterator();let n;do{n=t.next(),void 0!==n.value&&e.push(n.value)}while(!n.done);return e}toSet(){return new Set(this)}toMap(e,t){const n=this.map((n=>[e?e(n):n,t?t(n):n]));return new Map(n)}toString(){return this.join()}concat(e){const t=e[Symbol.iterator]();return new Ye((()=>({first:this.startFn(),firstDone:!1})),(e=>{let n;if(!e.firstDone){do{if(n=this.nextFn(e.first),!n.done)return n}while(!n.done);e.firstDone=!0}do{if(n=t.next(),!n.done)return n}while(!n.done);return Je}))}join(e=","){const t=this.iterator();let n,r="",i=!1;do{n=t.next(),n.done||(i&&(r+=e),r+=qe(n.value)),i=!0}while(!n.done);return r}indexOf(e,t=0){const n=this.iterator();let r=0,i=n.next();for(;!i.done;){if(r>=t&&i.value===e)return r;i=n.next(),r++}return-1}every(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(!e(n.value))return!1;n=t.next()}return!0}some(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(e(n.value))return!0;n=t.next()}return!1}forEach(e){const t=this.iterator();let n=0,r=t.next();for(;!r.done;)e(r.value,n),r=t.next(),n++}map(e){return new Ye(this.startFn,(t=>{const{done:n,value:r}=this.nextFn(t);return n?Je:{done:!1,value:e(r)}}))}filter(e){return new Ye(this.startFn,(t=>{let n;do{if(n=this.nextFn(t),!n.done&&e(n.value))return n}while(!n.done);return Je}))}nonNullable(){return this.filter((e=>null!=e))}reduce(e,t){const n=this.iterator();let r=t,i=n.next();for(;!i.done;)r=void 0===r?i.value:e(r,i.value),i=n.next();return r}reduceRight(e,t){return this.recursiveReduce(this.iterator(),e,t)}recursiveReduce(e,t,n){const r=e.next();if(r.done)return n;const i=this.recursiveReduce(e,t,n);return void 0===i?r.value:t(i,r.value)}find(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(e(n.value))return n.value;n=t.next()}}findIndex(e){const t=this.iterator();let n=0,r=t.next();for(;!r.done;){if(e(r.value))return n;r=t.next(),n++}return-1}includes(e){const t=this.iterator();let n=t.next();for(;!n.done;){if(n.value===e)return!0;n=t.next()}return!1}flatMap(e){return new Ye((()=>({this:this.startFn()})),(t=>{do{if(t.iterator){const e=t.iterator.next();if(!e.done)return e;t.iterator=void 0}const{done:n,value:r}=this.nextFn(t.this);if(!n){const n=e(r);if(!Xe(n))return{done:!1,value:n};t.iterator=n[Symbol.iterator]()}}while(t.iterator);return Je}))}flat(e){if(void 0===e&&(e=1),e<=0)return this;const t=e>1?this.flat(e-1):this;return new Ye((()=>({this:t.startFn()})),(e=>{do{if(e.iterator){const t=e.iterator.next();if(!t.done)return t;e.iterator=void 0}const{done:n,value:r}=t.nextFn(e.this);if(!n){if(!Xe(r))return{done:!1,value:r};e.iterator=r[Symbol.iterator]()}}while(e.iterator);return Je}))}head(){const e=this.iterator().next();if(!e.done)return e.value}tail(e=1){return new Ye((()=>{const t=this.startFn();for(let n=0;n<e;n++){if(this.nextFn(t).done)return t}return t}),this.nextFn)}limit(e){return new Ye((()=>({size:0,state:this.startFn()})),(t=>(t.size++,t.size>e?Je:this.nextFn(t.state))))}distinct(e){const t=new Set;return this.filter((n=>{const r=e?e(n):n;return!t.has(r)&&(t.add(r),!0)}))}exclude(e,t){const n=new Set;for(const r of e){const e=t?t(r):r;n.add(e)}return this.filter((e=>{const r=t?t(e):e;return!n.has(r)}))}}function qe(e){return"string"==typeof e?e:void 0===e?"undefined":"function"==typeof e.toString?e.toString():Object.prototype.toString.call(e)}function Xe(e){return!!e&&"function"==typeof e[Symbol.iterator]}const Qe=new Ye((()=>{}),(()=>Je)),Je=Object.freeze({done:!0,value:void 0});function Ze(...e){if(1===e.length){const t=e[0];if(t instanceof Ye)return t;if(Xe(t))return new Ye((()=>t[Symbol.iterator]()),(e=>e.next()));if("number"==typeof t.length)return new Ye((()=>({index:0})),(e=>e.index<t.length?{done:!1,value:t[e.index++]}:Je))}return e.length>1?new Ye((()=>({collIndex:0,arrIndex:0})),(t=>{do{if(t.iterator){const e=t.iterator.next();if(!e.done)return e;t.iterator=void 0}if(t.array){if(t.arrIndex<t.array.length)return{done:!1,value:t.array[t.arrIndex++]};t.array=void 0,t.arrIndex=0}if(t.collIndex<e.length){const n=e[t.collIndex++];Xe(n)?t.iterator=n[Symbol.iterator]():n&&"number"==typeof n.length&&(t.array=n)}}while(t.iterator||t.array||t.collIndex<e.length);return Je})):Qe}class et extends Ye{constructor(e,t,n){super((()=>({iterators:(null==n?void 0:n.includeRoot)?[[e][Symbol.iterator]()]:[t(e)[Symbol.iterator]()],pruned:!1})),(e=>{for(e.pruned&&(e.iterators.pop(),e.pruned=!1);e.iterators.length>0;){const n=e.iterators[e.iterators.length-1].next();if(!n.done)return e.iterators.push(t(n.value)[Symbol.iterator]()),n;e.iterators.pop()}return Je}))}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),prune:()=>{e.state.pruned=!0},[Symbol.iterator]:()=>e};return e}}var tt,nt,rt,it;function st(e){return new et(e,(e=>He(e)?e.content:[]),{includeRoot:!0})}function at(e){return{start:{character:e.startColumn-1,line:e.startLine-1},end:{character:e.endColumn,line:e.endLine-1}}}function ot(e){if(!e)return;const{offset:t,end:n,range:r}=e;return{range:r,offset:t,end:n,length:n-t}}function ct(e,t){const n=function(e,t){if(e.end.line<t.start.line||e.end.line===t.start.line&&e.end.character<e.start.character)return rt.Before;if(e.start.line>t.end.line||e.start.line===t.end.line&&e.start.character>t.end.character)return rt.After;const n=e.start.line>t.start.line||e.start.line===t.start.line&&e.start.character>=t.start.character,r=e.end.line<t.end.line||e.end.line===t.end.line&&e.end.character<=t.end.character;return n&&r?rt.Inside:n?rt.OverlapBack:rt.OverlapFront}(e,t);return n>rt.After}(nt=tt||(tt={})).sum=function(e){return e.reduce(((e,t)=>e+t),0)},nt.product=function(e){return e.reduce(((e,t)=>e*t),0)},nt.min=function(e){return e.reduce(((e,t)=>Math.min(e,t)))},nt.max=function(e){return e.reduce(((e,t)=>Math.max(e,t)))},(it=rt||(rt={}))[it.Before=0]="Before",it[it.After=1]="After",it[it.OverlapFront=2]="OverlapFront",it[it.OverlapBack=3]="OverlapBack",it[it.Inside=4]="Inside";const lt=/^[\w\p{L}]$/u;function ut(e,t){return We(e)&&t.includes(e.tokenType.name)}class ht extends Error{constructor(e,t){super(e?`${t} at ${e.range.start.line}:${e.range.start.character}`:t)}}function dt(e){throw new Error("Error! The input value was not handled.")}const ft="AbstractRule",pt="AbstractType",mt="Condition",gt="ValueLiteral",yt="AbstractElement";const Tt="BooleanLiteral";const vt="Conjunction";const Rt="Disjunction";const Et="InferredType";function At(e){return on.isInstance(e,Et)}const kt="Interface";function St(e){return on.isInstance(e,kt)}const It="Negation";const xt="ParameterReference";const Nt="ParserRule";function $t(e){return on.isInstance(e,Nt)}const Ct="SimpleType";const wt="TerminalRule";function Lt(e){return on.isInstance(e,wt)}const Ot="Type";function _t(e){return on.isInstance(e,Ot)}const bt="Action";function Pt(e){return on.isInstance(e,bt)}const Mt="Alternatives";function Dt(e){return on.isInstance(e,Mt)}const Ut="Assignment";function Ft(e){return on.isInstance(e,Ut)}const Gt="CharacterRange";const Bt="CrossReference";function Kt(e){return on.isInstance(e,Bt)}const jt="EndOfFile";const Vt="Group";function Ht(e){return on.isInstance(e,Vt)}const Wt="Keyword";function zt(e){return on.isInstance(e,Wt)}const Yt="NegatedToken";const qt="RegexToken";const Xt="RuleCall";function Qt(e){return on.isInstance(e,Xt)}const Jt="TerminalAlternatives";const Zt="TerminalGroup";const en="TerminalRuleCall";const tn="UnorderedGroup";function nn(e){return on.isInstance(e,tn)}const rn="UntilToken";const sn="Wildcard";class an extends Ve{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 bt:case Mt:case Ut:case Gt:case Bt:case jt:case Vt:case Wt:case Yt:case qt:case Xt:case Jt:case Zt:case en:case tn:case rn:case sn:return this.isSubtype(yt,t);case"ArrayLiteral":case"NumberLiteral":case"StringLiteral":return this.isSubtype(gt,t);case"ArrayType":case"ReferenceType":case Ct:case"UnionType":return this.isSubtype("TypeDefinition",t);case Tt:return this.isSubtype(mt,t)||this.isSubtype(gt,t);case vt:case Rt:case It:case xt:return this.isSubtype(mt,t);case Et:case kt:case Ot:return this.isSubtype(pt,t);case Nt:return this.isSubtype(ft,t)||this.isSubtype(pt,t);case wt:return this.isSubtype(ft,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 pt;case"Grammar:hiddenTokens":case"ParserRule:hiddenTokens":case"RuleCall:rule":return ft;case"Grammar:usedGrammars":return"Grammar";case"NamedArgument:parameter":case"ParameterReference:parameter":return"Parameter";case"TerminalRuleCall:rule":return wt;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 on=new an;function cn(e,t){let n=e;for(;n;){if(t(n))return n;n=n.$container}}function ln(e){const t=function(e){for(;e.$container;)e=e.$container;return e}(e),n=t.$document;if(!n)throw new Error("AST node has no document.");return n}function un(e,t){if(!e)throw new Error("Node must be an AstNode.");const n=null==t?void 0:t.range;return new Ye((()=>({keys:Object.keys(e),keyIndex:0,arrayIndex:0})),(t=>{for(;t.keyIndex<t.keys.length;){const r=t.keys[t.keyIndex];if(!r.startsWith("$")){const i=e[r];if(Be(i)){if(t.keyIndex++,fn(i,n))return{done:!1,value:i}}else if(Array.isArray(i)){for(;t.arrayIndex<i.length;){const e=i[t.arrayIndex++];if(Be(e)&&fn(e,n))return{done:!1,value:e}}t.arrayIndex=0}}t.keyIndex++}return Je}))}function hn(e,t){if(!e)throw new Error("Root node must be an AstNode.");return new et(e,(e=>un(e,t)))}function dn(e,t){if(!e)throw new Error("Root node must be an AstNode.");return new et(e,(e=>un(e,t)),{includeRoot:!0})}function fn(e,t){var n;if(!t)return!0;const r=null===(n=e.$cstNode)||void 0===n?void 0:n.range;return!!r&&ct(r,t)}function pn(e){return new Ye((()=>({keys:Object.keys(e),keyIndex:0,arrayIndex:0})),(t=>{for(;t.keyIndex<t.keys.length;){const n=t.keys[t.keyIndex];if(!n.startsWith("$")){const r=e[n];if(Ke(r))return t.keyIndex++,{done:!1,value:{reference:r,container:e,property:n}};if(Array.isArray(r)){for(;t.arrayIndex<r.length;){const i=t.arrayIndex++,s=r[i];if(Ke(s))return{done:!1,value:{reference:s,container:e,property:n,index:i}}}t.arrayIndex=0}}t.keyIndex++}return Je}))}function mn(e){return Array.isArray(e)?[...e.map(mn)]:e}function gn(e){return e.charCodeAt(0)}function yn(e,t){Array.isArray(e)?e.forEach((function(e){t.push(e)})):t.push(e)}function Tn(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function vn(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function Rn(e){return"Character"===e.type}const En=[];for(let gu=gn("0");gu<=gn("9");gu++)En.push(gu);const An=[gn("_")].concat(En);for(let gu=gn("a");gu<=gn("z");gu++)An.push(gu);for(let gu=gn("A");gu<=gn("Z");gu++)An.push(gu);const kn=[gn(" "),gn("\f"),gn("\n"),gn("\r"),gn("\t"),gn("\v"),gn("\t"),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn(" "),gn("\u2028"),gn("\u2029"),gn(" "),gn(" "),gn(" "),gn("\ufeff")],Sn=/[0-9a-fA-F]/,In=/[0-9]/,xn=/[1-9]/;class Nn{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 n={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":Tn(n,"global");break;case"i":Tn(n,"ignoreCase");break;case"m":Tn(n,"multiLine");break;case"u":Tn(n,"unicode");break;case"y":Tn(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,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"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead"}vn(t);const n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}return function(){throw Error("Internal Error - Should never get here!")}()}quantifier(e=!1){let t;const n=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 n=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:n,atMost:n};break;case",":let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;vn(t)}if(!0!==e||void 0!==t)return vn(t)?("?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t):void 0}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()}if(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),vn(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[gn("\n"),gn("\r"),gn("\u2028"),gn("\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=En;break;case"D":e=En,t=!0;break;case"s":e=kn;break;case"S":e=kn,t=!0;break;case"w":e=An;break;case"W":e=An,t=!0}if(vn(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=gn("\f");break;case"n":e=gn("\n");break;case"r":e=gn("\r");break;case"t":e=gn("\t");break;case"v":e=gn("\v")}if(vn(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:gn("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:gn(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:gn(this.popChar())}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const t=this.classAtom();if(t.type,Rn(t)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,Rn(n)){if(n.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:n.value})}else yn(t.value,e),e.push(gn("-")),yn(n.value,e)}else yn(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":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:gn("\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;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),e=!1;else this.groupIdx++;const t=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(!1===xn.test(e))throw Error("Expecting a positive integer");for(;In.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===In.test(e))throw Error("Expecting an integer");for(;In.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case"\n":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:gn(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 In.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":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 void 0!==this.quantifier(!0)}catch(t){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let n=0;n<e;n++){const e=this.popChar();if(!1===Sn.test(e))throw Error("Expecting a HexDecimal digits");t+=e}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(void 0!==e&&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 $n{visitChildren(e){for(const t in e){const n=e[t];e.hasOwnProperty(t)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((e=>{this.visit(e)}),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)}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 Cn=/\r?\n/gm,wn=new Nn;const Ln=new class extends $n{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||"\n"!==t||(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const e=bn(t);this.endRegexpStack.push(e),this.isStarting&&(this.startRegexp+=e)}}visitSet(e){if(!this.multiline){const t=this.regex.substring(e.loc.begin,e.loc.end),n=new RegExp(t);this.multiline=Boolean("\n".match(n))}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){if("Group"===e.type){if(e.quantifier)return}super.visitChildren(e)}};function On(e){try{return"string"==typeof e&&(e=new RegExp(e)),e=e.toString(),Ln.reset(e),Ln.visit(wn.pattern(e)),Ln.multiline}catch(t){return!1}}function _n(e){return("string"==typeof e?new RegExp(e):e).test(" ")}function bn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pn(e,t){const n=function(e){"string"==typeof e&&(e=new RegExp(e));const t=e,n=e.source;let r=0;function i(){let e,s="";function a(e){s+=n.substr(r,e),r+=e}function o(e){s+="(?:"+n.substr(r,e)+"|$)",r+=e}for(;r<n.length;)switch(n[r]){case"\\":switch(n[r+1]){case"c":o(3);break;case"x":o(4);break;case"u":t.unicode?"{"===n[r+2]?o(n.indexOf("}",r)-r+1):o(6):o(2);break;case"p":case"P":t.unicode?o(n.indexOf("}",r)-r+1):o(2);break;case"k":o(n.indexOf(">",r)-r+1);break;default:o(2)}break;case"[":e=/\[(?:\\.|.)*?\]/g,e.lastIndex=r,e=e.exec(n)||[],o(e[0].length);break;case"|":case"^":case"$":case"*":case"+":case"?":a(1);break;case"{":e=/\{\d+,?\d*\}/g,e.lastIndex=r,e=e.exec(n),e?a(e[0].length):o(1);break;case"(":if("?"===n[r+1])switch(n[r+2]){case":":s+="(?:",r+=3,s+=i()+"|$)";break;case"=":s+="(?=",r+=3,s+=i()+")";break;case"!":e=r,r+=3,i(),s+=n.substr(e,r-e);break;case"<":switch(n[r+3]){case"=":case"!":e=r,r+=4,i(),s+=n.substr(e,r-e);break;default:a(n.indexOf(">",r)-r+1),s+=i()+"|$)"}}else a(1),s+=i()+"|$)";break;case")":return++r,s;default:o(1)}return s}return new RegExp(i(),e.flags)}(e),r=t.match(n);return!!r&&r[0].length>0}function Mn(e,t){const n=new Set,r=function(e){return e.rules.find((e=>$t(e)&&e.entry))}(e);if(!r)return new Set(e.rules);const i=[r].concat(function(e){return e.rules.filter((e=>Lt(e)&&e.hidden))}(e));for(const a of i)Dn(a,n,t);const s=new Set;for(const a of e.rules)(n.has(a.name)||Lt(a)&&a.hidden)&&s.add(a);return s}function Dn(e,t,n){t.add(e.name),hn(e).forEach((e=>{if(Qt(e)||n){const r=e.rule.ref;r&&!t.has(r.name)&&Dn(r,t,n)}}))}function Un(e,t,n){if(!e||!t)return;const r=Fn(e,t,e.astNode,!0);return 0!==r.length?r[n=void 0!==n?Math.max(0,Math.min(n,r.length-1)):0]:void 0}function Fn(e,t,n,r){if(!r){const n=cn(e.grammarSource,Ft);if(n&&n.feature===t)return[e]}return He(e)&&e.astNode===n?e.content.flatMap((e=>Fn(e,t,n,!1))):[]}function Gn(e,t,n){if(!e)return;const r=function(e,t,n){if(e.astNode!==n)return[];if(zt(e.grammarSource)&&e.grammarSource.value===t)return[e];const r=st(e).iterator();let i;const s=[];do{if(i=r.next(),!i.done){const e=i.value;e.astNode===n?zt(e.grammarSource)&&e.grammarSource.value===t&&s.push(e):r.prune()}}while(!i.done);return s}(e,t,null==e?void 0:e.astNode);return 0!==r.length?r[n=void 0!==n?Math.max(0,Math.min(n,r.length-1)):0]:void 0}function Bn(e){let t=e;return At(t)&&(Pt(t.$container)?t=t.$container.$container:$t(t.$container)?t=t.$container:dt(t.$container)),Kn(e,t,new Map)}function Kn(e,t,n){var r,i;function s(t,r){let i;return cn(t,Ft)||(i=Kn(r,r,n)),n.set(e,i),i}if(n.has(e))return n.get(e);n.set(e,void 0);for(const a of hn(t)){if(Ft(a)&&"name"===a.feature.toLowerCase())return n.set(e,a),a;if(Qt(a)&&$t(a.rule.ref))return s(a,a.rule.ref);if(i=a,on.isInstance(i,Ct)&&(null===(r=a.typeRef)||void 0===r?void 0:r.ref))return s(a,a.typeRef.ref)}}function jn(e){return Vn(e,new Set)}function Vn(e,t){if(t.has(e))return!0;t.add(e);for(const n of hn(e))if(Qt(n)){if(!n.rule.ref)return!1;if($t(n.rule.ref)&&!Vn(n.rule.ref,t))return!1}else{if(Ft(n))return!1;if(Pt(n))return!1}return Boolean(e.definition)}function Hn(e){if(e.inferredType)return e.inferredType.name;if(e.dataType)return e.dataType;if(e.returnType){const t=e.returnType.ref;if(t){if($t(t))return t.name;if(St(t)||_t(t))return t.name}}}function Wn(e){var t,n;if($t(e))return jn(e)?e.name:null!==(t=Hn(e))&&void 0!==t?t:e.name;if(St(e)||_t(e)||(n=e,on.isInstance(n,"ReturnType")))return e.name;if(Pt(e)){const t=function(e){var t;if(e.inferredType)return e.inferredType.name;if(null===(t=e.type)||void 0===t?void 0:t.ref)return Wn(e.type.ref);return}(e);if(t)return t}else if(At(e))return e.name;throw new Error("Cannot get name of Unknown Type")}function zn(e){const t={s:!1,i:!1,u:!1},n=qn(e.definition,t),r=Object.entries(t).filter((([,e])=>e)).map((([e])=>e)).join("");return new RegExp(n,r)}const Yn=/[\s\S]/.source;function qn(e,t){if(a=e,on.isInstance(a,Jt))return Qn((s=e).elements.map((e=>qn(e))).join("|"),{cardinality:s.cardinality,lookahead:s.lookahead});if(function(e){return on.isInstance(e,Zt)}(e))return Qn((i=e).elements.map((e=>qn(e))).join(""),{cardinality:i.cardinality,lookahead:i.lookahead});if(function(e){return on.isInstance(e,Gt)}(e))return function(e){if(e.right)return Qn(`[${Xn(e.left)}-${Xn(e.right)}]`,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1});return Qn(Xn(e.left),{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}(e);if(function(e){return on.isInstance(e,en)}(e)){const t=e.rule.ref;if(!t)throw new Error("Missing rule reference.");return Qn(qn(t.definition),{cardinality:e.cardinality,lookahead:e.lookahead})}if(function(e){return on.isInstance(e,Yt)}(e))return Qn(`(?!${qn((r=e).terminal)})${Yn}*?`,{cardinality:r.cardinality,lookahead:r.lookahead});if(function(e){return on.isInstance(e,rn)}(e))return Qn(`${Yn}*?${qn((n=e).terminal)}`,{cardinality:n.cardinality,lookahead:n.lookahead});if(function(e){return on.isInstance(e,qt)}(e)){const n=e.regex.lastIndexOf("/"),r=e.regex.substring(1,n),i=e.regex.substring(n+1);return t&&(t.i=i.includes("i"),t.s=i.includes("s"),t.u=i.includes("u")),Qn(r,{cardinality:e.cardinality,lookahead:e.lookahead,wrap:!1})}if(function(e){return on.isInstance(e,sn)}(e))return Qn(Yn,{cardinality:e.cardinality,lookahead:e.lookahead});throw new Error(`Invalid terminal element: ${null==e?void 0:e.$type}`);var n,r,i,s,a}function Xn(e){return bn(e.value)}function Qn(e,t){var n;return(!1!==t.wrap||t.lookahead)&&(e=`(${null!==(n=t.lookahead)&&void 0!==n?n:""}${e})`),t.cardinality?`${e}${t.cardinality}`:e}function Jn(e){console&&console.error&&console.error(`Error: ${e}`)}function Zn(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function er(e){const t=(new Date).getTime(),n=e();return{time:(new Date).getTime()-t,value:n}}function tr(e){function t(){}t.prototype=e;const n=new t;function r(){return typeof n.bar}return r(),r(),e}function nr(e){return we((t=e).LABEL)&&""!==t.LABEL?e.LABEL:e.name;var t}class rr{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),ee(this.definition,(t=>{t.accept(e)}))}}class ir extends rr{constructor(e){super([]),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class sr extends rr{constructor(e){super(e.definition),this.orgText="",pe(this,Me(e,(e=>void 0!==e)))}}class ar extends rr{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,pe(this,Me(e,(e=>void 0!==e)))}}class or extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class cr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class lr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class ur extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class hr extends rr{constructor(e){super(e.definition),this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}}class dr extends rr{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,pe(this,Me(e,(e=>void 0!==e)))}}class fr{constructor(e){this.idx=1,pe(this,Me(e,(e=>void 0!==e)))}accept(e){e.visit(this)}}function pr(e){function t(e){return se(e,pr)}if(e instanceof ir){const t={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return we(e.label)&&(t.label=e.label),t}if(e instanceof ar)return{type:"Alternative",definition:t(e.definition)};if(e instanceof or)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof cr)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof lr)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:pr(new fr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof hr)return{type:"RepetitionWithSeparator",idx:e.idx,separator:pr(new fr({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof ur)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof dr)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof fr){const t={type:"Terminal",name:e.terminalType.name,label:nr(e.terminalType),idx:e.idx};we(e.label)&&(t.terminalLabel=e.label);const n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=Pe(n)?n.source:n),t}if(e instanceof sr)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match")}class mr{visit(e){const t=e;switch(t.constructor){case ir:return this.visitNonTerminal(t);case ar:return this.visitAlternative(t);case or:return this.visitOption(t);case cr:return this.visitRepetitionMandatory(t);case lr:return this.visitRepetitionMandatoryWithSeparator(t);case hr:return this.visitRepetitionWithSeparator(t);case ur:return this.visitRepetition(t);case dr:return this.visitAlternation(t);case fr:return this.visitTerminal(t);case sr: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 gr(e,t=[]){return!!(e instanceof or||e instanceof ur||e instanceof hr)||(e instanceof dr?Fe(e.definition,(e=>gr(e,t))):!(e instanceof ir&&Oe(t,e))&&(e instanceof rr&&(e instanceof ir&&t.push(e),ke(e.definition,(e=>gr(e,t))))))}function yr(e){if(e instanceof ir)return"SUBRULE";if(e instanceof or)return"OPTION";if(e instanceof dr)return"OR";if(e instanceof cr)return"AT_LEAST_ONE";if(e instanceof lr)return"AT_LEAST_ONE_SEP";if(e instanceof hr)return"MANY_SEP";if(e instanceof ur)return"MANY";if(e instanceof fr)return"CONSUME";throw Error("non exhaustive match")}class Tr{walk(e,t=[]){ee(e.definition,((n,r)=>{const i=ve(e.definition,r+1);if(n instanceof ir)this.walkProdRef(n,i,t);else if(n instanceof fr)this.walkTerminal(n,i,t);else if(n instanceof ar)this.walkFlat(n,i,t);else if(n instanceof or)this.walkOption(n,i,t);else if(n instanceof cr)this.walkAtLeastOne(n,i,t);else if(n instanceof lr)this.walkAtLeastOneSep(n,i,t);else if(n instanceof hr)this.walkManySep(n,i,t);else if(n instanceof ur)this.walkMany(n,i,t);else{if(!(n instanceof dr))throw Error("non exhaustive match");this.walkOr(n,i,t)}}))}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){const r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){const r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){const r=[new or({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){const r=vr(e,t,n);this.walk(e,r)}walkMany(e,t,n){const r=[new or({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){const r=vr(e,t,n);this.walk(e,r)}walkOr(e,t,n){const r=t.concat(n);ee(e.definition,(e=>{const t=new ar({definition:[e]});this.walk(t,r)}))}}function vr(e,t,n){return[new or({definition:[new fr({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function Rr(e){if(e instanceof ir)return Rr(e.referencedRule);if(e instanceof fr)return[e.terminalType];if(function(e){return e instanceof ar||e instanceof or||e instanceof ur||e instanceof cr||e instanceof lr||e instanceof hr||e instanceof fr||e instanceof sr}(e))return function(e){let t=[];const n=e.definition;let r,i=0,s=n.length>i,a=!0;for(;s&&a;)r=n[i],a=gr(r),t=t.concat(Rr(r)),i+=1,s=n.length>i;return Ge(t)}(e);if(function(e){return e instanceof dr}(e))return function(e){const t=se(e.definition,(e=>Rr(e)));return Ge(D(t))}(e);throw Error("non exhaustive match")}const Er="_~IN~_";class Ar extends Tr{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){const r=(i=e.referencedRule,s=e.idx,i.name+s+Er+this.topProd.name);var i,s;const a=t.concat(n),o=Rr(new ar({definition:a}));this.follows[r]=o}}let kr={};const Sr=new Nn;function Ir(e){const t=e.toString();if(kr.hasOwnProperty(t))return kr[t];{const e=Sr.pattern(t);return kr[t]=e,e}}const xr="Complement Sets are not supported for first char optimization",Nr='Unable to use "first char" lexer optimizations:\n';function $r(e,t=!1){try{const t=Ir(e);return Cr(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===xr)t&&Zn(`${Nr}\tUnable to optimize: < ${e.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";t&&(n="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Jn(`${Nr}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Cr(e,t,n){switch(e.type){case"Disjunction":for(let i=0;i<e.value.length;i++)Cr(e.value[i],t,n);break;case"Alternative":const r=e.value;for(let e=0;e<r.length;e++){const i=r[e];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const s=i;switch(s.type){case"Character":wr(s.value,t,n);break;case"Set":if(!0===s.complement)throw Error(xr);ee(s.value,(e=>{if("number"==typeof e)wr(e,t,n);else{const r=e;if(!0===n)for(let e=r.from;e<=r.to;e++)wr(e,t,n);else{for(let e=r.from;e<=r.to&&e<Jr;e++)wr(e,t,n);if(r.to>=Jr){const e=r.from>=Jr?r.from:Jr,n=r.to,i=ei(e),s=ei(n);for(let r=i;r<=s;r++)t[r]=r}}}}));break;case"Group":Cr(s.value,t,n);break;default:throw Error("Non Exhaustive Match")}const a=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===Or(s)||"Group"!==s.type&&!1===a)break}break;default:throw Error("non exhaustive match!")}return q(t)}function wr(e,t,n){const r=ei(e);t[r]=r,!0===n&&function(e,t){const n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){const e=ei(r.charCodeAt(0));t[e]=e}else{const e=n.toLowerCase();if(e!==n){const n=ei(e.charCodeAt(0));t[n]=n}}}(e,t)}function Lr(e,t){return ae(e.value,(e=>{if("number"==typeof e)return Oe(t,e);{const n=e;return void 0!==ae(t,(e=>n.from<=e&&e<=n.to))}}))}function Or(e){const t=e.quantifier;return!(!t||0!==t.atLeast)||!!e.value&&(R(e.value)?ke(e.value,Or):Or(e.value))}class _r extends $n{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}super.visitChildren(e)}}visitCharacter(e){Oe(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===Lr(e,this.targetCharCodes)&&(this.found=!0):void 0!==Lr(e,this.targetCharCodes)&&(this.found=!0)}}function br(e,t){if(t instanceof RegExp){const n=Ir(t),r=new _r(e);return r.visit(n),r.found}return void 0!==ae(t,(t=>Oe(e,t.charCodeAt(0))))}const Pr="PATTERN",Mr="defaultMode",Dr="modes";let Ur="boolean"==typeof new RegExp("(?:)").sticky;function Fr(e,t){const n=(t=ce(t,{useSticky:Ur,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",(()=>{!function(){if(he(Zr)){Zr=new Array(65536);for(let e=0;e<65536;e++)Zr[e]=e>255?255+~~(e/255):e}}()})),n("Reject Lexer.NA",(()=>{r=De(e,(e=>e[Pr]===pi.NA))}));let i,s,a,o,c,l,u,h,d,f,p,m=!1;n("Transform Patterns",(()=>{m=!1,i=se(r,(e=>{const n=e[Pr];if(Pe(n)){const e=n.source;return 1!==e.length||"^"===e||"$"===e||"."===e||n.ignoreCase?2!==e.length||"\\"!==e[0]||Oe(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?t.useSticky?Vr(n):jr(n):e[1]:e}if(U(n))return m=!0,{exec:n};if("object"==typeof n)return m=!0,n;if("string"==typeof n){if(1===n.length)return n;{const e=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),r=new RegExp(e);return t.useSticky?Vr(r):jr(r)}}throw Error("non exhaustive match")}))})),n("misc mapping",(()=>{s=se(r,(e=>e.tokenTypeIdx)),a=se(r,(e=>{const t=e.GROUP;if(t!==pi.SKIPPED){if(we(t))return t;if(te(t))return!1;throw Error("non exhaustive match")}})),o=se(r,(e=>{const t=e.LONGER_ALT;if(t){return R(t)?se(t,(e=>_e(r,e))):[_e(r,t)]}})),c=se(r,(e=>e.PUSH_MODE)),l=se(r,(e=>oe(e,"POP_MODE")))})),n("Line Terminator Handling",(()=>{const e=Xr(t.lineTerminatorCharacters);u=se(r,(e=>!1)),"onlyOffset"!==t.positionTracking&&(u=se(r,(t=>oe(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===qr(t,e)&&br(e,t.PATTERN))))})),n("Misc Mapping #2",(()=>{h=se(r,Wr),d=se(i,zr),f=ne(r,((e,t)=>{const n=t.GROUP;return we(n)&&n!==pi.SKIPPED&&(e[n]=[]),e}),{}),p=se(i,((e,t)=>({pattern:i[t],longerAlt:o[t],canLineTerminator:u[t],isCustom:h[t],short:d[t],group:a[t],push:c[t],pop:l[t],tokenTypeIdx:s[t],tokenType:r[t]})))}));let g=!0,y=[];return t.safeMode||n("First Char Optimization",(()=>{y=ne(r,((e,n,r)=>{if("string"==typeof n.PATTERN){const t=ei(n.PATTERN.charCodeAt(0));Qr(e,t,p[r])}else if(R(n.START_CHARS_HINT)){let t;ee(n.START_CHARS_HINT,(n=>{const i=ei("string"==typeof n?n.charCodeAt(0):n);t!==i&&(t=i,Qr(e,i,p[r]))}))}else if(Pe(n.PATTERN))if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&Jn(`${Nr}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const i=$r(n.PATTERN,t.ensureOptimizations);he(i)&&(g=!1),ee(i,(t=>{Qr(e,t,p[r])}))}else t.ensureOptimizations&&Jn(`${Nr}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e}),[])})),{emptyGroups:f,patternIdxToConfig:p,charCodeToPatternIdxToConfig:y,hasCustom:m,canBeOptimized:g}}function Gr(e,t){let n=[];const r=function(e){const t=re(e,(e=>!oe(e,Pr))),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:hi.MISSING_PATTERN,tokenTypes:[e]}))),r=Te(e,t);return{errors:n,valid:r}}(e);n=n.concat(r.errors);const i=function(e){const t=re(e,(e=>{const t=e[Pr];return!(Pe(t)||U(t)||oe(t,"exec")||we(t))})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:hi.INVALID_PATTERN,tokenTypes:[e]}))),r=Te(e,t);return{errors:n,valid:r}}(r.valid),s=i.valid;return n=n.concat(i.errors),n=n.concat(function(e){let t=[];const n=re(e,(e=>Pe(e[Pr])));return t=t.concat(function(e){class t extends $n{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}const n=re(e,(e=>{const n=e.PATTERN;try{const e=Ir(n),r=new t;return r.visit(e),r.found}catch(r){return Br.test(n.source)}})),r=se(n,(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:hi.EOI_ANCHOR_FOUND,tokenTypes:[e]})));return r}(n)),t=t.concat(function(e){class t extends $n{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}const n=re(e,(e=>{const n=e.PATTERN;try{const e=Ir(n),r=new t;return r.visit(e),r.found}catch(r){return Kr.test(n.source)}})),r=se(n,(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:hi.SOI_ANCHOR_FOUND,tokenTypes:[e]})));return r}(n)),t=t.concat(function(e){const t=re(e,(e=>{const t=e[Pr];return t instanceof RegExp&&(t.multiline||t.global)})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:hi.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]})));return n}(n)),t=t.concat(function(e){const t=[];let n=se(e,(n=>ne(e,((e,r)=>(n.PATTERN.source!==r.PATTERN.source||Oe(t,r)||r.PATTERN===pi.NA||(t.push(r),e.push(r)),e)),[])));n=me(n);const r=re(n,(e=>e.length>1)),i=se(r,(e=>{const t=se(e,(e=>e.name));return{message:`The same RegExp pattern ->${Se(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:hi.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}}));return i}(n)),t=t.concat(function(e){const t=re(e,(e=>e.PATTERN.test(""))),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:hi.EMPTY_MATCH_PATTERN,tokenTypes:[e]})));return n}(n)),t}(s)),n=n.concat(function(e){const t=re(e,(e=>{if(!oe(e,"GROUP"))return!1;const t=e.GROUP;return t!==pi.SKIPPED&&t!==pi.NA&&!we(t)})),n=se(t,(e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:hi.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]})));return n}(s)),n=n.concat(function(e,t){const n=re(e,(e=>void 0!==e.PUSH_MODE&&!Oe(t,e.PUSH_MODE))),r=se(n,(e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:hi.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]})));return r}(s,t)),n=n.concat(function(e){const t=[],n=ne(e,((e,t,n)=>{const r=t.PATTERN;return r===pi.NA||(we(r)?e.push({str:r,idx:n,tokenType:t}):Pe(r)&&(i=r,void 0===ae([".","\\","[","]","|","^","$","(",")","?","*","+","{"],(e=>-1!==i.source.indexOf(e))))&&e.push({str:r.source,idx:n,tokenType:t})),e;var i}),[]);return ee(e,((e,r)=>{ee(n,(({str:n,idx:i,tokenType:s})=>{if(r<i&&function(e,t){if(Pe(t)){const n=t.exec(e);return null!==n&&0===n.index}if(U(t))return t(e,0,[],{});if(oe(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(n,e.PATTERN)){const n=`Token: ->${s.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:hi.UNREACHABLE_PATTERN,tokenTypes:[e,s]})}}))})),t}(s)),n}const Br=/[^\\][$]/;const Kr=/[^\\[][\^]|^\^/;function jr(e){const t=e.ignoreCase?"i":"";return new RegExp(`^(?:${e.source})`,t)}function Vr(e){const t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function Hr(e,t,n){const r=[];let i=!1;const s=De(me(D(q(e.modes))),(e=>e[Pr]===pi.NA)),a=Xr(n);return t&&ee(s,(e=>{const t=qr(e,a);if(!1!==t){const n=function(e,t){if(t.issue===hi.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===hi.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${e.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),i={message:n,type:t.issue,tokenType:e};r.push(i)}else oe(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(i=!0):br(a,e.PATTERN)&&(i=!0)})),t&&!i&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:hi.NO_LINE_BREAKS_FLAGS}),r}function Wr(e){const t=e.PATTERN;if(Pe(t))return!1;if(U(t))return!0;if(oe(t,"exec"))return!0;if(we(t))return!1;throw Error("non exhaustive match")}function zr(e){return!(!we(e)||1!==e.length)&&e.charCodeAt(0)}const Yr={test:function(e){const t=e.length;for(let n=this.lastIndex;n<t;n++){const t=e.charCodeAt(n);if(10===t)return this.lastIndex=n+1,!0;if(13===t)return 10===e.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function qr(e,t){if(oe(e,"LINE_BREAKS"))return!1;if(Pe(e.PATTERN)){try{br(t,e.PATTERN)}catch(n){return{issue:hi.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}if(we(e.PATTERN))return!1;if(Wr(e))return{issue:hi.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function Xr(e){return se(e,(e=>we(e)?e.charCodeAt(0):e))}function Qr(e,t,n){void 0===e[t]?e[t]=[n]:e[t].push(n)}const Jr=256;let Zr=[];function ei(e){return e<Jr?e:Zr[e]}function ti(e,t){const n=e.tokenTypeIdx;return n===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[n]}function ni(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let ri=1;const ii={};function si(e){const t=function(e){let t=de(e),n=e,r=!0;for(;r;){n=me(D(se(n,(e=>e.CATEGORIES))));const e=Te(n,t);t=t.concat(e),he(e)?r=!1:n=e}return t}(e);!function(e){ee(e,(e=>{oi(e)||(ii[ri]=e,e.tokenTypeIdx=ri++),ci(e)&&!R(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),ci(e)||(e.CATEGORIES=[]),oe(e,"categoryMatches")||(e.categoryMatches=[]),function(e){return oe(e,"categoryMatchesMap")}(e)||(e.categoryMatchesMap={})}))}(t),function(e){ee(e,(e=>{ai([],e)}))}(t),function(e){ee(e,(e=>{e.categoryMatches=[],ee(e.categoryMatchesMap,((t,n)=>{e.categoryMatches.push(ii[n].tokenTypeIdx)}))}))}(t),ee(t,(e=>{e.isParent=e.categoryMatches.length>0}))}function ai(e,t){ee(e,(e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0})),ee(t.CATEGORIES,(n=>{const r=e.concat(t);Oe(r,n)||ai(r,n)}))}function oi(e){return oe(e,"tokenTypeIdx")}function ci(e){return oe(e,"CATEGORIES")}function li(e){return oe(e,"tokenTypeIdx")}const ui={buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,n,r,i)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`};var hi,di;(di=hi||(hi={}))[di.MISSING_PATTERN=0]="MISSING_PATTERN",di[di.INVALID_PATTERN=1]="INVALID_PATTERN",di[di.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",di[di.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",di[di.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",di[di.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",di[di.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",di[di.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",di[di.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",di[di.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",di[di.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",di[di.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",di[di.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",di[di.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",di[di.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",di[di.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",di[di.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",di[di.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";const fi={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ui,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(fi);class pi{constructor(e,t=fi){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=(e,t)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=er(t),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=pe({},fi,t);const n=this.config.traceInitPerf;!0===n?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof n&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(()=>{let n,r=!0;this.TRACE_INIT("Lexer Config handling",(()=>{if(this.config.lineTerminatorsPattern===fi.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Yr;else if(this.config.lineTerminatorCharacters===fi.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor 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),R(e)?n={modes:{defaultMode:de(e)},defaultMode:Mr}:(r=!1,n=de(e))})),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",(()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e){const t=[];return oe(e,Mr)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+Mr+"> property in its definition\n",type:hi.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),oe(e,Dr)||t.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:hi.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),oe(e,Dr)&&oe(e,Mr)&&!oe(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${Mr}: <${e.defaultMode}>which does not exist\n`,type:hi.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),oe(e,Dr)&&ee(e.modes,((e,n)=>{ee(e,((r,i)=>{if(te(r))t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,type:hi.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(oe(r,"LONGER_ALT")){const i=R(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT];ee(i,(i=>{te(i)||Oe(e,i)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${r.name}> outside of mode <${n}>\n`,type:hi.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})}))}}))})),t}(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),this.TRACE_INIT("performWarningRuntimeChecks",(()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Hr(n,this.trackStartLines,this.config.lineTerminatorCharacters))}))),n.modes=n.modes?n.modes:{},ee(n.modes,((e,t)=>{n.modes[t]=De(e,(e=>te(e)))}));const i=T(n.modes);if(ee(n.modes,((e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,(()=>{if(this.modes.push(n),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",(()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Gr(e,i))})),he(this.lexerDefinitionErrors)){let r;si(e),this.TRACE_INIT("analyzeTokenTypes",(()=>{r=Fr(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})})),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=pe({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}}))})),this.defaultMode=n.defaultMode,!he(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const e=se(this.lexerDefinitionErrors,(e=>e.message)).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+e)}ee(this.lexerDefinitionWarning,(e=>{Zn(e.message)})),this.TRACE_INIT("Choosing sub-methods implementations",(()=>{if(Ur?(this.chopInput=F,this.match=this.matchWithTest):(this.updateLastIndex=ie,this.match=this.matchWithExec),r&&(this.handleModes=ie),!1===this.trackStartLines&&(this.computeNewColumn=F),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=ie),/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))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}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 e=ne(this.canModeBeOptimized,((e,t,n)=>(!1===t&&e.push(n),e)),[]);if(t.ensureOptimizations&&!he(e))throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)})),this.TRACE_INIT("clearRegExpParserCache",(()=>{kr={}})),this.TRACE_INIT("toFastProperties",(()=>{tr(this)}))}))}tokenize(e,t=this.defaultMode){if(!he(this.lexerDefinitionErrors)){const e=se(this.lexerDefinitionErrors,(e=>e.message)).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,s,a,o,c,l,u,h,d,f,p,m,g;const y=e,v=y.length;let E=0,A=0;const k=this.hasCustom?0:Math.floor(e.length/10),S=new Array(k),I=[];let x=this.trackStartLines?1:void 0,N=this.trackStartLines?1:void 0;const $=function(e){const t={},n=T(e);return ee(n,(n=>{const r=e[n];if(!R(r))throw Error("non exhaustive match");t[n]=[]})),t}(this.emptyGroups),C=this.trackStartLines,w=this.config.lineTerminatorsPattern;let L=0,O=[],_=[];const b=[],P=[];let M;function D(){return O}function U(e){const t=ei(e),n=_[t];return void 0===n?P:n}Object.freeze(P);const F=e=>{if(1===b.length&&void 0===e.tokenType.PUSH_MODE){const t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);I.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{b.pop();const e=le(b);O=this.patternIdxToConfig[e],_=this.charCodeToPatternIdxToConfig[e],L=O.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=_&&t?U:D}};function G(e){b.push(e),_=this.charCodeToPatternIdxToConfig[e],O=this.patternIdxToConfig[e],L=O.length,L=O.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;M=_&&t?U:D}let B;G.call(this,t);const K=this.config.recoveryEnabled;for(;E<v;){o=null;const t=y.charCodeAt(E),T=M(t),R=T.length;for(n=0;n<R;n++){B=T[n];const r=B.pattern;c=null;const u=B.short;if(!1!==u?t===u&&(o=r):!0===B.isCustom?(g=r.exec(y,E,S,$),null!==g?(o=g[0],void 0!==g.payload&&(c=g.payload)):o=null):(this.updateLastIndex(r,E),o=this.match(r,e,E)),null!==o){if(a=B.longerAlt,void 0!==a){const t=a.length;for(i=0;i<t;i++){const t=O[a[i]],n=t.pattern;if(l=null,!0===t.isCustom?(g=n.exec(y,E,S,$),null!==g?(s=g[0],void 0!==g.payload&&(l=g.payload)):s=null):(this.updateLastIndex(n,E),s=this.match(n,e,E)),s&&s.length>o.length){o=s,c=l,B=t;break}}}break}}if(null!==o){if(u=o.length,h=B.group,void 0!==h&&(d=B.tokenTypeIdx,f=this.createTokenInstance(o,E,d,B.tokenType,x,N,u),this.handlePayload(f,c),!1===h?A=this.addToken(S,A,f):$[h].push(f)),e=this.chopInput(e,u),E+=u,N=this.computeNewColumn(N,u),!0===C&&!0===B.canLineTerminator){let e,t,n=0;w.lastIndex=0;do{e=w.test(o),!0===e&&(t=w.lastIndex-1,n++)}while(!0===e);0!==n&&(x+=n,N=u-t,this.updateTokenEndLineColumnLocation(f,h,t,n,x,N,u))}this.handleModes(B,F,G,f)}else{const t=E,n=x,i=N;let s=!1===K;for(;!1===s&&E<v;)for(e=this.chopInput(e,1),E++,r=0;r<L;r++){const t=O[r],n=t.pattern,i=t.short;if(!1!==i?y.charCodeAt(E)===i&&(s=!0):!0===t.isCustom?s=null!==n.exec(y,E,S,$):(this.updateLastIndex(n,E),s=null!==n.exec(e)),!0===s)break}if(p=E-t,N=this.computeNewColumn(N,p),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(y,t,p,n,i),I.push({offset:t,line:n,column:i,length:p,message:m}),!1===K)break}}return this.hasCustom||(S.length=A),{tokens:S,groups:$,errors:I}}handleModes(e,t,n,r){if(!0===e.pop){const i=e.push;t(r),void 0!==i&&n.call(this,i)}else void 0!==e.push&&n.call(this,e.push)}chopInput(e,t){return e.substring(t)}updateLastIndex(e,t){e.lastIndex=t}updateTokenEndLineColumnLocation(e,t,n,r,i,s,a){let o,c;void 0!==t&&(o=n===a-1,c=o?-1:0,1===r&&!0===o||(e.endLine=i+c,e.endColumn=s-1-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,s){return{image:e,startOffset:t,startLine:i,startColumn:s,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,s,a){return{image:e,startOffset:t,endOffset:t+a-1,startLine:i,endLine:i,startColumn:s,endColumn:s+a-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}matchWithTest(e,t,n){return!0===e.test(t)?t.substring(n,e.lastIndex):null}matchWithExec(e,t){const n=e.exec(t);return null!==n?n[0]:null}}function mi(e){return gi(e)?e.LABEL:e.name}function gi(e){return we(e.LABEL)&&""!==e.LABEL}pi.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.",pi.NA=/NOT_APPLICABLE/;const yi="parent",Ti="categories",vi="label",Ri="group",Ei="push_mode",Ai="pop_mode",ki="longer_alt",Si="line_breaks",Ii="start_chars_hint";function xi(e){return function(e){const t=e.pattern,n={};n.name=e.name,te(t)||(n.PATTERN=t);if(oe(e,yi))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";oe(e,Ti)&&(n.CATEGORIES=e[Ti]);si([n]),oe(e,vi)&&(n.LABEL=e[vi]);oe(e,Ri)&&(n.GROUP=e[Ri]);oe(e,Ai)&&(n.POP_MODE=e[Ai]);oe(e,Ei)&&(n.PUSH_MODE=e[Ei]);oe(e,ki)&&(n.LONGER_ALT=e[ki]);oe(e,Si)&&(n.LINE_BREAKS=e[Si]);oe(e,Ii)&&(n.START_CHARS_HINT=e[Ii]);return n}(e)}const Ni=xi({name:"EOF",pattern:pi.NA});function $i(e,t,n,r,i,s,a,o){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:s,startColumn:a,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function Ci(e,t){return ti(e,t)}si([Ni]);const wi={buildMismatchTokenMessage:({expected:e,actual:t,previous:n,ruleName:r})=>`Expecting ${gi(e)?`--\x3e ${mi(e)} <--`:`token of type --\x3e ${e.name} <--`} but found --\x3e '${t.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){const s="Expecting: ",a="\nbut found: '"+Se(t).image+"'";if(r)return s+r+a;{const t=ne(e,((e,t)=>e.concat(t)),[]),n=se(t,(e=>`[${se(e,(e=>mi(e))).join(", ")}]`));return s+`one of these possible Token sequences:\n${se(n,((e,t)=>` ${t+1}. ${e}`)).join("\n")}`+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){const i="Expecting: ",s="\nbut found: '"+Se(t).image+"'";if(n)return i+n+s;return i+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${se(e,(e=>`[${se(e,(e=>mi(e))).join(",")}]`)).join(" ,")}>`+s}};Object.freeze(wi);const Li={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},Oi={buildDuplicateFoundError(e,t){const n=e.name,r=Se(t),i=r.idx,s=yr(r),a=(o=r)instanceof fr?o.terminalType.name:o instanceof ir?o.nonTerminalName:"";var o;let c=`->${s}${i>0?i:""}<- ${a?`with argument: ->${a}<-`:""}\n appears more than once (${t.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.alternation.idx?"":e.alternation.idx;let r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r},buildEmptyRepetitionError(e){let t=yr(e.repetition);0!==e.repetition.idx&&(t+=e.repetition.idx);return`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){const t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --\x3e ${se(e.leftRecursionPath,(e=>e.name)).concat([t]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;t=e.topLevelRule instanceof sr?e.topLevelRule.name:e.topLevelRule;return`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class _i extends mr{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){ee(q(this.nameToTopRule),(e=>{this.currTopLevel=e,e.accept(this)}))}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:ra.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class bi extends Tr{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=de(this.path.ruleStack).reverse(),this.occurrenceStack=de(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,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){he(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Pi extends bi{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,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const e=t.concat(n),r=new ar({definition:e});this.possibleTokTypes=Rr(r),this.found=!0}}}class Mi extends Tr{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 Di extends Mi{walkMany(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}}class Ui extends Mi{walkManySep(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}}class Fi extends Mi{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}}class Gi extends Mi{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){const e=Se(t.concat(n));this.result.isEndOfRule=void 0===e,e instanceof fr&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}}function Bi(e,t,n=[]){n=de(n);let r=[],i=0;function s(s){const a=Bi(s.concat(ve(e,i+1)),t,n);return r.concat(a)}for(;n.length<t&&i<e.length;){const t=e[i];if(t instanceof ar)return s(t.definition);if(t instanceof ir)return s(t.definition);if(t instanceof or)r=s(t.definition);else{if(t instanceof cr){return s(t.definition.concat([new ur({definition:t.definition})]))}if(t instanceof lr){return s([new ar({definition:t.definition}),new ur({definition:[new fr({terminalType:t.separator})].concat(t.definition)})])}if(t instanceof hr){const e=t.definition.concat([new ur({definition:[new fr({terminalType:t.separator})].concat(t.definition)})]);r=s(e)}else if(t instanceof ur){const e=t.definition.concat([new ur({definition:t.definition})]);r=s(e)}else{if(t instanceof dr)return ee(t.definition,(e=>{!1===he(e.definition)&&(r=s(e.definition))})),r;if(!(t instanceof fr))throw Error("non exhaustive match");n.push(t.terminalType)}}i++}return r.push({partialPath:n,suffixDef:ve(e,i)}),r}function Ki(e,t,n,r){const i="EXIT_NONE_TERMINAL",s=[i],a="EXIT_ALTERNATIVE";let o=!1;const c=t.length,l=c-r-1,u=[],h=[];for(h.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!he(h);){const e=h.pop();if(e===a){o&&le(h).idx<=l&&h.pop();continue}const r=e.def,d=e.idx,f=e.ruleStack,p=e.occurrenceStack;if(he(r))continue;const m=r[0];if(m===i){const e={idx:d,def:ve(r),ruleStack:Re(f),occurrenceStack:Re(p)};h.push(e)}else if(m instanceof fr)if(d<c-1){const e=d+1;if(n(t[e],m.terminalType)){const t={idx:e,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(t)}}else{if(d!==c-1)throw Error("non exhaustive match");u.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:f,occurrenceStack:p}),o=!0}else if(m instanceof ir){const e=de(f);e.push(m.nonTerminalName);const t=de(p);t.push(m.idx);const n={idx:d,def:m.definition.concat(s,ve(r)),ruleStack:e,occurrenceStack:t};h.push(n)}else if(m instanceof or){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t={idx:d,def:m.definition.concat(ve(r)),ruleStack:f,occurrenceStack:p};h.push(t)}else if(m instanceof cr){const e=new ur({definition:m.definition,idx:m.idx}),t={idx:d,def:m.definition.concat([e],ve(r)),ruleStack:f,occurrenceStack:p};h.push(t)}else if(m instanceof lr){const e=new fr({terminalType:m.separator}),t=new ur({definition:[e].concat(m.definition),idx:m.idx}),n={idx:d,def:m.definition.concat([t],ve(r)),ruleStack:f,occurrenceStack:p};h.push(n)}else if(m instanceof hr){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t=new fr({terminalType:m.separator}),n=new ur({definition:[t].concat(m.definition),idx:m.idx}),i={idx:d,def:m.definition.concat([n],ve(r)),ruleStack:f,occurrenceStack:p};h.push(i)}else if(m instanceof ur){const e={idx:d,def:ve(r),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a);const t=new ur({definition:m.definition,idx:m.idx}),n={idx:d,def:m.definition.concat([t],ve(r)),ruleStack:f,occurrenceStack:p};h.push(n)}else if(m instanceof dr)for(let t=m.definition.length-1;t>=0;t--){const e={idx:d,def:m.definition[t].definition.concat(ve(r)),ruleStack:f,occurrenceStack:p};h.push(e),h.push(a)}else if(m instanceof ar)h.push({idx:d,def:m.definition.concat(ve(r)),ruleStack:f,occurrenceStack:p});else{if(!(m instanceof sr))throw Error("non exhaustive match");h.push(ji(m,d,f,p))}}return u}function ji(e,t,n,r){const i=de(n);i.push(e.name);const s=de(r);return s.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:s}}var Vi,Hi;function Wi(e){if(e instanceof or||"Option"===e)return Vi.OPTION;if(e instanceof ur||"Repetition"===e)return Vi.REPETITION;if(e instanceof cr||"RepetitionMandatory"===e)return Vi.REPETITION_MANDATORY;if(e instanceof lr||"RepetitionMandatoryWithSeparator"===e)return Vi.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof hr||"RepetitionWithSeparator"===e)return Vi.REPETITION_WITH_SEPARATOR;if(e instanceof dr||"Alternation"===e)return Vi.ALTERNATION;throw Error("non exhaustive match")}function zi(e){const{occurrence:t,rule:n,prodType:r,maxLookahead:i}=e,s=Wi(r);return s===Vi.ALTERNATION?ns(t,n,i):rs(t,n,s,i)}function Yi(e,t,n,r){const i=e.length,s=ke(e,(e=>ke(e,(e=>1===e.length))));if(t)return function(t){const r=se(t,(e=>e.GATE));for(let s=0;s<i;s++){const t=e[s],i=t.length,a=r[s];if(void 0===a||!1!==a.call(this))e:for(let e=0;e<i;e++){const r=t[e],i=r.length;for(let e=0;e<i;e++){const t=this.LA(e+1);if(!1===n(t,r[e]))continue e}return s}}};if(s&&!r){const t=se(e,(e=>D(e))),n=ne(t,((e,t,n)=>(ee(t,(t=>{oe(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),ee(t.categoryMatches,(t=>{oe(e,t)||(e[t]=n)}))})),e)),{});return function(){const e=this.LA(1);return n[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){const r=e[t],i=r.length;e:for(let e=0;e<i;e++){const i=r[e],s=i.length;for(let e=0;e<s;e++){const t=this.LA(e+1);if(!1===n(t,i[e]))continue e}return t}}}}function qi(e,t,n){const r=ke(e,(e=>1===e.length)),i=e.length;if(r&&!n){const t=D(e);if(1===t.length&&he(t[0].categoryMatches)){const e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{const e=ne(t,((e,t,n)=>(e[t.tokenTypeIdx]=!0,ee(t.categoryMatches,(t=>{e[t]=!0})),e)),[]);return function(){const t=this.LA(1);return!0===e[t.tokenTypeIdx]}}}return function(){e:for(let n=0;n<i;n++){const r=e[n],i=r.length;for(let e=0;e<i;e++){const n=this.LA(e+1);if(!1===t(n,r[e]))continue e}return!0}return!1}}(Hi=Vi||(Vi={}))[Hi.OPTION=0]="OPTION",Hi[Hi.REPETITION=1]="REPETITION",Hi[Hi.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",Hi[Hi.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",Hi[Hi.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",Hi[Hi.ALTERNATION=5]="ALTERNATION";class Xi extends Tr{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)}walkOption(e,t,n){this.checkIsTarget(e,Vi.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,Vi.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,Vi.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,Vi.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}}class Qi extends mr{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx!==this.targetOccurrence||this.targetProdType!==t||void 0!==this.targetRef&&e!==this.targetRef||(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,Vi.OPTION)}visitRepetition(e){this.checkIsTarget(e,Vi.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,Vi.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,Vi.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,Vi.ALTERNATION)}}function Ji(e){const t=new Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function Zi(e){let t=[""];for(let n=0;n<e.length;n++){const r=e[n],i=[];for(let e=0;e<t.length;e++){const n=t[e];i.push(n+"_"+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){const t="_"+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function es(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;const i=e[r];for(let e=0;e<t.length;e++){if(!0===i[t[e]])return!1}}return!0}function ts(e,t){const n=se(e,(e=>Bi([e],1))),r=Ji(n.length),i=se(n,(e=>{const t={};return ee(e,(e=>{const n=Zi(e.partialPath);ee(n,(e=>{t[e]=!0}))})),t}));let s=n;for(let a=1;a<=t;a++){const e=s;s=Ji(e.length);for(let n=0;n<e.length;n++){const o=e[n];for(let e=0;e<o.length;e++){const c=o[e].partialPath,l=o[e].suffixDef,u=Zi(c);if(es(i,u,n)||he(l)||c.length===t){const e=r[n];if(!1===is(e,c)){e.push(c);for(let e=0;e<u.length;e++){const t=u[e];i[n][t]=!0}}}else{const e=Bi(l,a+1,c);s[n]=s[n].concat(e),ee(e,(e=>{const t=Zi(e.partialPath);ee(t,(e=>{i[n][e]=!0}))}))}}}}return r}function ns(e,t,n,r){const i=new Qi(e,Vi.ALTERNATION,r);return t.accept(i),ts(i.result,n)}function rs(e,t,n,r){const i=new Qi(e,n);t.accept(i);const s=i.result,a=new Xi(t,e,n).startWalking();return ts([new ar({definition:s}),new ar({definition:a})],r)}function is(e,t){e:for(let n=0;n<e.length;n++){const r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){const n=t[e],i=r[e];if(!1===(n===i||void 0!==i.categoryMatchesMap[n.tokenTypeIdx]))continue e}return!0}}return!1}function ss(e){return ke(e,(e=>ke(e,(e=>ke(e,(e=>he(e.categoryMatches)))))))}function as(e,t,n,r){const i=Ie(e,(e=>function(e,t){const n=new ls;e.accept(n);const r=n.allProductions,i=Me(Ce(r,os),(e=>e.length>1)),s=se(q(i),(n=>{const r=Se(n),i=t.buildDuplicateFoundError(e,n),s=yr(r),a={message:i,type:ra.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:s,occurrence:r.idx},o=cs(r);return o&&(a.parameter=o),a}));return s}(e,n))),s=function(e,t,n){const r=[],i=se(t,(e=>e.name));return ee(e,(e=>{const t=e.name;if(Oe(i,t)){const i=n.buildNamespaceConflictError(e);r.push({message:i,type:ra.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}})),r}(e,t,n),a=Ie(e,(e=>function(e,t){const n=new ds;e.accept(n);const r=Ie(n.alternations,(n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:ra.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[]));return r}(e,n))),o=Ie(e,(t=>function(e,t,n,r){const i=[],s=ne(t,((t,n)=>n.name===e.name?t+1:t),0);if(s>1){const t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:ra.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}(t,e,r,n)));return i.concat(s,a,o)}function os(e){return`${yr(e)}_#_${e.idx}_#_${cs(e)}`}function cs(e){return e instanceof fr?e.terminalType.name:e instanceof ir?e.nonTerminalName:""}class ls extends mr{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 us(e,t,n,r=[]){const i=[],s=hs(t.definition);if(he(s))return[];{const t=e.name;Oe(s,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:ra.LEFT_RECURSION,ruleName:t});const a=Ie(Te(s,r.concat([e])),(t=>{const i=de(r);return i.push(t),us(e,t,n,i)}));return i.concat(a)}}function hs(e){let t=[];if(he(e))return t;const n=Se(e);if(n instanceof ir)t.push(n.referencedRule);else if(n instanceof ar||n instanceof or||n instanceof cr||n instanceof lr||n instanceof hr||n instanceof ur)t=t.concat(hs(n.definition));else if(n instanceof dr)t=D(se(n.definition,(e=>hs(e.definition))));else if(!(n instanceof fr))throw Error("non exhaustive match");const r=gr(n),i=e.length>1;if(r&&i){const n=ve(e);return t.concat(hs(n))}return t}class ds extends mr{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function fs(e,t,n){const r=new ds;e.accept(r);let i=r.alternations;i=De(i,(e=>!0===e.ignoreAmbiguities));const s=Ie(i,(r=>{const i=r.idx,s=r.maxLookahead||t,a=ns(i,e,s,r),o=function(e,t,n,r){const i=[],s=ne(e,((n,r,s)=>(!0===t.definition[s].ignoreAmbiguities||ee(r,(r=>{const a=[s];ee(e,((e,n)=>{s!==n&&is(e,r)&&!0!==t.definition[n].ignoreAmbiguities&&a.push(n)})),a.length>1&&!is(i,r)&&(i.push(r),n.push({alts:a,path:r}))})),n)),[]),a=se(s,(e=>{const i=se(e.alts,(e=>e+1));return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ra.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}}));return a}(a,r,e,n),c=function(e,t,n,r){const i=ne(e,((e,t,n)=>{const r=se(t,(e=>({idx:n,path:e})));return e.concat(r)}),[]),s=me(Ie(i,(e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];const s=e.idx,a=e.path,o=re(i,(e=>{return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<s&&(n=e.path,r=a,n.length<r.length&&ke(n,((e,t)=>{const n=r[t];return e===n||n.categoryMatchesMap[e.tokenTypeIdx]})));var n,r}));return se(o,(e=>{const i=[e.idx+1,s+1],a=0===t.idx?"":t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:ra.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:a,alternatives:i}}))})));return s}(a,r,e,n);return o.concat(c)}));return s}class ps extends mr{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 ms(e){const t=ce(e,{errMsgProvider:Li}),n={};return ee(e.rules,(e=>{n[e.name]=e})),function(e,t){const n=new _i(e,t);return n.resolveRefs(),n.errors}(n,t.errMsgProvider)}const gs="MismatchedTokenException",ys="NoViableAltException",Ts="EarlyExitException",vs="NotAllInputParsedException",Rs=[gs,ys,Ts,vs];function Es(e){return Oe(Rs,e.name)}Object.freeze(Rs);class As 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 ks extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=gs}}class Ss extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=ys}}class Is extends As{constructor(e,t){super(e,t),this.name=vs}}class xs extends As{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ts}}const Ns={},$s="InRuleRecoveryException";class Cs extends Error{constructor(e){super(e),this.name=$s}}function ws(e,t,n,r,i,s,a){const o=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[o];if(void 0===c){const e=this.getCurrRuleFullName();c=new s(this.getGAstProductions()[e],i).startWalking(),this.firstAfterRepMap[o]=c}let l=c.token,u=c.occurrence;const h=c.isEndOfRule;1===this.RULE_STACK.length&&h&&void 0===l&&(l=Ni,u=1),void 0!==l&&void 0!==u&&this.shouldInRepetitionRecoveryBeTried(l,u,a)&&this.tryInRepetitionRecovery(e,t,n,l)}const Ls=1024,Os=1280,_s=1536;function bs(e,t,n){return n|t|e}class Ps{constructor(e){var t;this.maxLookahead=null!==(t=null==e?void 0:e.maxLookahead)&&void 0!==t?t:ta.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(he(t)){const n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return Ie(e,(e=>us(e,e,Oi)))}validateEmptyOrAlternatives(e){return Ie(e,(e=>function(e,t){const n=new ds;return e.accept(n),Ie(n.alternations,(n=>Ie(Re(n.definition),((r,i)=>{const s=Ki([r],[],ti,1);return he(s)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:ra.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]}))))}(e,Oi)))}validateAmbiguousAlternationAlternatives(e,t){return Ie(e,(e=>fs(e,t,Oi)))}validateSomeNonEmptyLookaheadPath(e,t){return function(e,t,n){const r=[];return ee(e,(e=>{const i=new ps;e.accept(i);const s=i.allProductions;ee(s,(i=>{const s=Wi(i),a=i.maxLookahead||t,o=rs(i.idx,e,s,a)[0];if(he(D(o))){const t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:ra.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}}))})),r}(e,t,Oi)}buildLookaheadForAlternation(e){return function(e,t,n,r,i,s){const a=ns(e,t,n);return s(a,r,ss(a)?ni:ti,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Yi)}buildLookaheadForOptional(e){return function(e,t,n,r,i,s){const a=rs(e,t,i,n),o=ss(a)?ni:ti;return s(a[0],o,r)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Wi(e.prodType),qi)}}const Ms=new class extends mr{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)}};function Ds(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function Us(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Fs(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function Gs(e,t){const n=T(e),r=n.length;for(let i=0;i<r;i++){const r=e[n[i]],s=r.length;for(let e=0;e<s;e++){const n=r[e];void 0===n.tokenTypeIdx&&this[n.name](n.children,t)}}}function Bs(e,t){const n=function(){};Fs(n,e+"BaseSemantics");const r={visit:function(e,t){if(R(e)&&(e=e[0]),!te(e))return this[e.name](e.children,t)},validateVisitor:function(){const e=function(e,t){const n=function(e,t){const n=re(t,(t=>!1===U(e[t]))),r=se(n,(t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Ks.MISSING_METHOD,methodName:t})));return me(r)}(e,t);return n}(this,t);if(!he(e)){const t=se(e,(e=>e.msg));throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(n.prototype=r).constructor=n,n._RULE_NAMES=t,n}var Ks,js;(js=Ks||(Ks={}))[js.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",js[js.MISSING_METHOD=1]="MISSING_METHOD";const Vs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Vs);const Hs=!0,Ws=Math.pow(2,8)-1,zs=xi({name:"RECORDING_PHASE_TOKEN",pattern:pi.NA});si([zs]);const Ys=$i(zs,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(Ys);const qs={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function Xs(e,t,n,r=!1){Zs(n);const i=le(this.recordingProdStack),s=U(t)?t:t.DEF,a=new e({definition:[],idx:n});return r&&(a.separator=t.SEP),oe(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),s.call(this),i.definition.push(a),this.recordingProdStack.pop(),Vs}function Qs(e,t){Zs(t);const n=le(this.recordingProdStack),r=!1===R(e),i=!1===r?e:e.DEF,s=new dr({definition:[],idx:t,ignoreAmbiguities:r&&!0===e.IGNORE_AMBIGUITIES});oe(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD);const a=Fe(i,(e=>U(e.GATE)));return s.hasPredicates=a,n.definition.push(s),ee(i,(e=>{const t=new ar({definition:[]});s.definition.push(t),oe(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:oe(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()})),Vs}function Js(e){return 0===e?"":`${e}`}function Zs(e){if(e<0||e>Ws){const t=new Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${Ws+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}const ea=$i(Ni,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ea);const ta=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:wi,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),na=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ra,ia,sa;function aa(e=void 0){return function(){return e}}(ia=ra||(ra={}))[ia.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",ia[ia.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",ia[ia.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",ia[ia.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",ia[ia.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",ia[ia.LEFT_RECURSION=5]="LEFT_RECURSION",ia[ia.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",ia[ia.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",ia[ia.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",ia[ia.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",ia[ia.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",ia[ia.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",ia[ia.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",ia[ia.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class oa{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\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",(()=>{tr(this)})),this.TRACE_INIT("Grammar Recording",(()=>{try{this.enableRecording(),ee(this.definedRulesNames,(e=>{const t=this[e].originalGrammarAction;let n;this.TRACE_INIT(`${e} Rule`,(()=>{n=this.topLevelRuleRecord(e,t)})),this.gastProductionsCache[e]=n}))}finally{this.disableRecording()}}));let n=[];if(this.TRACE_INIT("Grammar Resolving",(()=>{n=ms({rules:q(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)})),this.TRACE_INIT("Grammar Validations",(()=>{if(he(n)&&!1===this.skipValidations){const n=(e={rules:q(this.gastProductionsCache),tokenTypes:q(this.tokensMap),errMsgProvider:Oi,grammarName:t},as((e=ce(e,{errMsgProvider:Oi})).rules,e.tokenTypes,e.errMsgProvider,e.grammarName)),r=function(e){const t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return se(t,(e=>Object.assign({type:ra.CUSTOM_LOOKAHEAD_VALIDATION},e)))}({lookaheadStrategy:this.lookaheadStrategy,rules:q(this.gastProductionsCache),tokenTypes:q(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(n,r)}var e})),he(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",(()=>{const e=function(e){const t={};return ee(e,(e=>{const n=new Ar(e).startWalking();pe(t,n)})),t}(q(this.gastProductionsCache));this.resyncFollows=e})),this.TRACE_INIT("ComputeLookaheadFunctions",(()=>{var e,t;null===(t=(e=this.lookaheadStrategy).initialize)||void 0===t||t.call(e,{rules:q(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(q(this.gastProductionsCache))}))),!oa.DEFER_DEFINITION_ERRORS_HANDLING&&!he(this.definitionErrors))throw e=se(this.definitionErrors,(e=>e.message)),new Error(`Parser Definition Errors detected:\n ${e.join("\n-------------------------------\n")}`)}))}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),oe(t,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=oe(t,"skipValidations")?t.skipValidations:ta.skipValidations}}oa.DEFER_DEFINITION_ERRORS_HANDLING=!1,sa=oa,[class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=oe(e,"recoveryEnabled")?e.recoveryEnabled:ta.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=ws)}getTokenToInsert(e){const t=$i(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){const i=this.findReSyncTokenType(),s=this.exportLexerState(),a=[];let o=!1;const c=this.LA(1);let l=this.LA(1);const u=()=>{const e=this.LA(0),t=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),n=new ks(t,c,this.LA(0));n.resyncedTokens=Re(a),this.SAVE_ERROR(n)};for(;!o;){if(this.tokenMatcher(l,r))return void u();if(n.call(this))return u(),void e.apply(this,t);this.tokenMatcher(l,i)?o=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,a))}this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(e,t,n){return!1!==n&&!this.tokenMatcher(this.LA(1),e)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t))}getFollowsForInRuleRecovery(e,t){const n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new Cs("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(he(t))return!1;const n=this.LA(1);return void 0!==ae(t,(e=>this.tokenMatcher(n,e)))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey();return Oe(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA(1),n=2;for(;;){const r=ae(e,(e=>Ci(t,e)));if(void 0!==r)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return Ns;const e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return se(e,((n,r)=>0===r?Ns:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])}))}flattenFollowSet(){const e=se(this.buildFullFollowKeyStack(),(e=>this.getFollowSetFromFollowKey(e)));return D(e)}getFollowSetFromFollowKey(e){if(e===Ns)return[Ni];const t=e.ruleName+e.idxInCallingRule+Er+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Ni)||t.push(e),t}reSyncTo(e){const t=[];let n=this.LA(1);for(;!1===this.tokenMatcher(n,e);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return Re(t)}attemptInRepetitionRecovery(e,t,n,r,i,s,a){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:de(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return se(this.RULE_STACK,(e=>this.shortRuleNameToFullName(e)))}},class{initLooksAhead(e){this.dynamicTokensEnabled=oe(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ta.dynamicTokensEnabled,this.maxLookahead=oe(e,"maxLookahead")?e.maxLookahead:ta.maxLookahead,this.lookaheadStrategy=oe(e,"lookaheadStrategy")?e.lookaheadStrategy:new Ps({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){ee(e,(e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,(()=>{const{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:a}=function(e){Ms.reset(),e.accept(Ms);const t=Ms.dslMethods;return Ms.reset(),t}(e);ee(t,(t=>{const n=0===t.idx?"":t.idx;this.TRACE_INIT(`${yr(t)}${n}`,(()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=bs(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)}))})),ee(n,(t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,yr(t))})),ee(r,(t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,yr(t))})),ee(i,(t=>{this.computeLookaheadFunc(e,t.idx,Ls,"RepetitionMandatory",t.maxLookahead,yr(t))})),ee(s,(t=>{this.computeLookaheadFunc(e,t.idx,_s,"RepetitionMandatoryWithSeparator",t.maxLookahead,yr(t))})),ee(a,(t=>{this.computeLookaheadFunc(e,t.idx,Os,"RepetitionWithSeparator",t.maxLookahead,yr(t))}))}))}))}computeLookaheadFunc(e,t,n,r,i,s){this.TRACE_INIT(`${s}${0===t?"":t}`,(()=>{const s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),a=bs(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(a,s)}))}getKeyForAutomaticLookahead(e,t){return bs(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=oe(e,"nodeLocationTracking")?e.nodeLocationTracking:ta.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Us,this.setNodeLocationFromNode=Us,this.cstPostRule=ie,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ds,this.setNodeLocationFromNode=Ds,this.cstPostRule=ie,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);this.setNodeLocationFromToken=ie,this.setNodeLocationFromNode=ie,this.cstPostRule=ie,this.setInitialNodeLocation=ie}else this.cstInvocationStateUpdate=ie,this.cstFinallyStateUpdate=ie,this.cstPostTerminal=ie,this.cstPostNonTerminal=ie,this.cstPostRule=ie}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),n=e.location;n.startOffset<=t.startOffset==1?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){const t=this.LA(0),n=e.location;n.startOffset<=t.startOffset==1?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];var r,i,s;i=t,s=e,void 0===(r=n).children[s]?r.children[s]=[i]:r.children[s].push(i),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];!function(e,t,n){void 0===e.children[t]?e.children[t]=[n]:e.children[t].push(n)}(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(te(this.baseCstVisitorConstructor)){const e=Bs(this.className,T(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(te(this.baseCstVisitorWithDefaultsConstructor)){const e=function(e,t,n){const r=function(){};Fs(r,e+"BaseSemanticsWithDefaults");const i=Object.create(n.prototype);return ee(t,(e=>{i[e]=Gs})),(r.prototype=i).constructor=r,r}(this.className,T(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{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)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)):ea}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ea: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{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=ni,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},oe(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(R(e)){if(he(e))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(R(e))this.tokensMap=ne(e,((e,t)=>(e[t.name]=t,e)),{});else if(oe(e,"modes")&&ke(D(q(e.modes)),li)){const t=Ge(D(q(e.modes)));this.tokensMap=ne(t,((e,t)=>(e[t.name]=t,e)),{})}else{if(!G(e))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=de(e)}this.tokensMap.EOF=Ni;const n=ke(oe(e,"modes")?D(q(e.modes)):q(e),(e=>he(e.categoryMatches)));this.tokenMatcher=n?ni:ti,si(q(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=oe(n,"resyncEnabled")?n.resyncEnabled:na.resyncEnabled,i=oe(n,"recoveryValueFunc")?n.recoveryValueFunc:na.recoveryValueFunc,s=this.ruleShortNameIdx<<12;let a;return this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=e,this.fullRuleNameToShort[e]=s,a=!0===this.outputCst?function(...n){try{this.ruleInvocationStateUpdate(s,e,this.subruleIdx),t.apply(this,n);const r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(a){return this.invokeRuleCatch(a,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(s,e,this.subruleIdx),t.apply(this,n)}catch(a){return this.invokeRuleCatch(a,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(a,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){const r=1===this.RULE_STACK.length,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Es(e)){const t=e;if(i){const r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(r)return this.moveToTerminatedState(),n(e);throw t}throw e}optionInternal(e,t){const n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof e){r=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else r=e;if(!0===i.call(this))return r.call(this)}atLeastOneInternal(e,t){const n=this.getKeyForAutomaticLookahead(Ls,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;if(!0!==i.call(this))throw this.raiseEarlyExitException(e,Vi.REPETITION_MANDATORY,t.ERR_MSG);{let e=this.doSingleRepetition(r);for(;!0===i.call(this)&&!0===e;)e=this.doSingleRepetition(r)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Ls,e,Fi)}atLeastOneSepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(_s,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(e,Vi.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);{r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Gi],t,_s,e,Gi)}}manyInternal(e,t){const n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;let s=!0;for(;!0===i.call(this)&&!0===s;)s=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,768,e,Di,s)}manySepFirstInternal(e,t){const n=this.getKeyForAutomaticLookahead(Os,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){const r=t.DEF,i=t.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){r.call(this);const t=()=>this.tokenMatcher(this.LA(1),i);for(;!0===this.tokenMatcher(this.LA(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Ui],t,Os,e,Ui)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,_s,e,i)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const n=this.getKeyForAutomaticLookahead(256,t),r=R(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(void 0!==i)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){const e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Is(t,e))}}subruleInternal(e,t,n){let r;try{const i=void 0!==n?n.ARGS:void 0;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:e.ruleName),r}catch(i){throw this.subruleInternalError(i,n,e.ruleName)}}subruleInternalError(e,t,n){throw Es(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{const t=this.LA(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(i){r=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r;const i=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new ks(r,t,i))}consumeInternalRecovery(e,t,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;{const i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(r){throw r.name===$s?n:r}}}saveRecogState(){const e=this.errors,t=de(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,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ni)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}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,n=na){if(Oe(this.definedRulesNames,e)){const t={message:Oi.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:ra.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);const r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=na){const r=function(e,t,n){const r=[];let i;return Oe(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:ra.INVALID_RULE_OVERRIDE,ruleName:e})),r}(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);const i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);const n=this.saveRecogState();try{return e.apply(this,t),!0}catch(r){if(Es(r))return!1;throw r}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return e=q(this.gastProductionsCache),se(e,pr);var e}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=oe(e,"errorMessageProvider")?e.errorMessageProvider:ta.errorMessageProvider}SAVE_ERROR(e){if(Es(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:de(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return de(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){const r=this.getCurrRuleFullName(),i=rs(e,this.getGAstProductions()[r],t,this.maxLookahead)[0],s=[];for(let o=1;o<=this.maxLookahead;o++)s.push(this.LA(o));const a=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:s,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new xs(a,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const n=this.getCurrRuleFullName(),r=ns(e,this.getGAstProductions()[n],this.maxLookahead),i=[];for(let o=1;o<=this.maxLookahead;o++)i.push(this.LA(o));const s=this.LA(0),a=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:s,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Ss(a,this.LA(1),s))}},class{initContentAssist(){}computeContentAssist(e,t){const n=this.gastProductionsCache[e];if(te(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Ki([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const t=Se(e.ruleStack),n=this.getGAstProductions()[t];return new Pi(n,e).startWalking()}},class{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(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},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 n=t>0?t:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}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 ea}topLevelRuleRecord(e,t){try{const n=new sr({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(n){if(!0!==n.KNOWN_RECORDER_ERROR)try{n.message=n.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(r){throw n}throw n}}optionInternalRecord(e,t){return Xs.call(this,or,e,t)}atLeastOneInternalRecord(e,t){Xs.call(this,cr,t,e)}atLeastOneSepFirstInternalRecord(e,t){Xs.call(this,lr,t,e,Hs)}manyInternalRecord(e,t){Xs.call(this,ur,t,e)}manySepFirstInternalRecord(e,t){Xs.call(this,hr,t,e,Hs)}orInternalRecord(e,t){return Qs.call(this,e,t)}subruleInternalRecord(e,t,n){if(Zs(t),!e||!1===oe(e,"ruleName")){const n=new Error(`<SUBRULE${Js(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=le(this.recordingProdStack),i=e.ruleName,s=new ir({idx:t,nonTerminalName:i,label:null==n?void 0:n.LABEL,referencedRule:void 0});return r.definition.push(s),this.outputCst?qs:Vs}consumeInternalRecord(e,t,n){if(Zs(t),!oi(e)){const n=new Error(`<CONSUME${Js(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=le(this.recordingProdStack),i=new fr({idx:t,terminalType:e,label:null==n?void 0:n.LABEL});return r.definition.push(i),Ys}},class{initPerformanceTracer(e){if(oe(e,"traceInitPerf")){const t=e.traceInitPerf,n="number"==typeof t;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ta.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${e}>`);const{time:r,value:i}=er(t),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}}].forEach((e=>{const t=e.prototype;Object.getOwnPropertyNames(t).forEach((n=>{if("constructor"===n)return;const r=Object.getOwnPropertyDescriptor(t,n);r&&(r.get||r.set)?Object.defineProperty(sa.prototype,n,r):sa.prototype[n]=e.prototype[n]}))}));class ca extends oa{constructor(e,t=ta){const n=de(t);n.outputCst=!1,super(e,n)}}function la(e,t,n){return`${e.name}_${t}_${n}`}class ua{constructor(e){this.target=e}isEpsilon(){return!1}}class ha extends ua{constructor(e,t){super(e),this.tokenType=t}}class da extends ua{constructor(e){super(e)}isEpsilon(){return!0}}class fa extends ua{constructor(e,t,n){super(e),this.rule=t,this.followState=n}isEpsilon(){return!0}}function pa(e){const t={decisionMap:{},decisionStates:[],ruleToStartState:new Map,ruleToStopState:new Map,states:[]};!function(e,t){const n=t.length;for(let r=0;r<n;r++){const n=t[r],i=Sa(e,n,void 0,{type:2}),s=Sa(e,n,void 0,{type:7});i.stop=s,e.ruleToStartState.set(n,i),e.ruleToStopState.set(n,s)}}(t,e);const n=e.length;for(let r=0;r<n;r++){const n=e[r],i=ga(t,n,n);void 0!==i&&Aa(t,n,i)}return t}function ma(e,t,n){return n instanceof fr?Ea(e,t,n.terminalType,n):n instanceof ir?function(e,t,n){const r=n.referencedRule,i=e.ruleToStartState.get(r),s=Sa(e,t,n,{type:1}),a=Sa(e,t,n,{type:1}),o=new fa(i,r,a);return Ia(s,o),{left:s,right:a}}(e,t,n):n instanceof dr?function(e,t,n){const r=Sa(e,t,n,{type:1});va(e,r);const i=se(n.definition,(n=>ma(e,t,n))),s=Ra(e,t,r,n,...i);return s}(e,t,n):n instanceof or?function(e,t,n){const r=Sa(e,t,n,{type:1});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return function(e,t,n,r){const i=r.left,s=r.right;return ka(i,s),e.decisionMap[la(t,"Option",n.idx)]=i,r}(e,t,n,i)}(e,t,n):n instanceof ur?function(e,t,n){const r=Sa(e,t,n,{type:5});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return Ta(e,t,n,i)}(e,t,n):n instanceof hr?function(e,t,n){const r=Sa(e,t,n,{type:5});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n)),s=Ea(e,t,n.separator,n);return Ta(e,t,n,i,s)}(e,t,n):n instanceof cr?function(e,t,n){const r=Sa(e,t,n,{type:4});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n));return ya(e,t,n,i)}(e,t,n):n instanceof lr?function(e,t,n){const r=Sa(e,t,n,{type:4});va(e,r);const i=Ra(e,t,r,n,ga(e,t,n)),s=Ea(e,t,n.separator,n);return ya(e,t,n,i,s)}(e,t,n):ga(e,t,n)}function ga(e,t,n){const r=re(se(n.definition,(n=>ma(e,t,n))),(e=>void 0!==e));return 1===r.length?r[0]:0===r.length?void 0:function(e,t){const n=t.length;for(let s=0;s<n-1;s++){const n=t[s];let r;1===n.left.transitions.length&&(r=n.left.transitions[0]);const i=r instanceof fa,a=r,o=t[s+1].left;1===n.left.type&&1===n.right.type&&void 0!==r&&(i&&a.followState===n.right||r.target===n.right)?(i?a.followState=o:r.target=o,xa(e,n.right)):ka(n.right,o)}const r=t[0],i=t[n-1];return{left:r.left,right:i.right}}(e,r)}function ya(e,t,n,r,i){const s=r.left,a=r.right,o=Sa(e,t,n,{type:11});va(e,o);const c=Sa(e,t,n,{type:12});return s.loopback=o,c.loopback=o,e.decisionMap[la(t,i?"RepetitionMandatoryWithSeparator":"RepetitionMandatory",n.idx)]=o,ka(a,o),void 0===i?(ka(o,s),ka(o,c)):(ka(o,c),ka(o,i.left),ka(i.right,s)),{left:s,right:c}}function Ta(e,t,n,r,i){const s=r.left,a=r.right,o=Sa(e,t,n,{type:10});va(e,o);const c=Sa(e,t,n,{type:12}),l=Sa(e,t,n,{type:9});return o.loopback=l,c.loopback=l,ka(o,s),ka(o,c),ka(a,l),void 0!==i?(ka(l,c),ka(l,i.left),ka(i.right,s)):ka(l,o),e.decisionMap[la(t,i?"RepetitionWithSeparator":"Repetition",n.idx)]=o,{left:o,right:c}}function va(e,t){return e.decisionStates.push(t),t.decision=e.decisionStates.length-1,t.decision}function Ra(e,t,n,r,...i){const s=Sa(e,t,r,{type:8,start:n});n.end=s;for(const o of i)void 0!==o?(ka(n,o.left),ka(o.right,s)):ka(n,s);const a={left:n,right:s};return e.decisionMap[la(t,function(e){if(e instanceof dr)return"Alternation";if(e instanceof or)return"Option";if(e instanceof ur)return"Repetition";if(e instanceof hr)return"RepetitionWithSeparator";if(e instanceof cr)return"RepetitionMandatory";if(e instanceof lr)return"RepetitionMandatoryWithSeparator";throw new Error("Invalid production type encountered")}(r),r.idx)]=n,a}function Ea(e,t,n,r){const i=Sa(e,t,r,{type:1}),s=Sa(e,t,r,{type:1});return Ia(i,new ha(s,n)),{left:i,right:s}}function Aa(e,t,n){const r=e.ruleToStartState.get(t);ka(r,n.left);const i=e.ruleToStopState.get(t);ka(n.right,i);return{left:r,right:i}}function ka(e,t){Ia(e,new da(t))}function Sa(e,t,n,r){const i=Object.assign({atn:e,production:n,epsilonOnlyTransitions:!1,rule:t,transitions:[],nextTokenWithinRule:[],stateNumber:e.states.length},r);return e.states.push(i),i}function Ia(e,t){0===e.transitions.length&&(e.epsilonOnlyTransitions=t.isEpsilon()),e.transitions.push(t)}function xa(e,t){e.states.splice(e.states.indexOf(t),1)}const Na={};class $a{constructor(){this.map={},this.configs=[]}get size(){return this.configs.length}finalize(){this.map={}}add(e){const t=Ca(e);t in this.map||(this.map[t]=this.configs.length,this.configs.push(e))}get elements(){return this.configs}get alts(){return se(this.configs,(e=>e.alt))}get key(){let e="";for(const t in this.map)e+=t+":";return e}}function Ca(e,t=!0){return`${t?`a${e.alt}`:""}s${e.state.stateNumber}:${e.stack.map((e=>e.stateNumber.toString())).join("_")}`}function wa(e,t){const n={};return r=>{const i=r.toString();let s=n[i];return void 0!==s||(s={atnStartState:e,decision:t,states:{}},n[i]=s),s}}class La{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 n=0;n<t;n++)e+=!0===this.predicates[n]?"1":"0";return e}}const Oa=new La;class _a extends Ps{constructor(e){var t;super(),this.logging=null!==(t=null==e?void 0:e.logging)&&void 0!==t?t:e=>console.log(e)}initialize(e){this.atn=pa(e.rules),this.dfas=function(e){const t=e.decisionStates.length,n=Array(t);for(let r=0;r<t;r++)n[r]=wa(e.decisionStates[r],r);return n}(this.atn)}validateAmbiguousAlternationAlternatives(){return[]}validateEmptyOrAlternatives(){return[]}buildLookaheadForAlternation(e){const{prodOccurrence:t,rule:n,hasPredicates:r,dynamicTokensEnabled:i}=e,s=this.dfas,a=this.logging,o=la(n,"Alternation",t),c=this.atn.decisionMap[o].decision,l=se(zi({maxLookahead:1,occurrence:t,prodType:"Alternation",rule:n}),(e=>se(e,(e=>e[0]))));if(ba(l,!1)&&!i){const e=ne(l,((e,t,n)=>(ee(t,(t=>{t&&(e[t.tokenTypeIdx]=n,ee(t.categoryMatches,(t=>{e[t]=n})))})),e)),{});return r?function(t){var n;const r=this.LA(1),i=e[r.tokenTypeIdx];if(void 0!==t&&void 0!==i){const e=null===(n=t[i])||void 0===n?void 0:n.GATE;if(void 0!==e&&!1===e.call(this))return}return i}:function(){const t=this.LA(1);return e[t.tokenTypeIdx]}}return r?function(e){const t=new La,n=void 0===e?0:e.length;for(let i=0;i<n;i++){const n=null==e?void 0:e[i].GATE;t.set(i,void 0===n||n.call(this))}const r=Pa.call(this,s,c,t,a);return"number"==typeof r?r:void 0}:function(){const e=Pa.call(this,s,c,Oa,a);return"number"==typeof e?e:void 0}}buildLookaheadForOptional(e){const{prodOccurrence:t,rule:n,prodType:r,dynamicTokensEnabled:i}=e,s=this.dfas,a=this.logging,o=la(n,r,t),c=this.atn.decisionMap[o].decision,l=se(zi({maxLookahead:1,occurrence:t,prodType:r,rule:n}),(e=>se(e,(e=>e[0]))));if(ba(l)&&l[0][0]&&!i){const e=l[0],t=D(e);if(1===t.length&&he(t[0].categoryMatches)){const e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{const e=ne(t,((e,t)=>(void 0!==t&&(e[t.tokenTypeIdx]=!0,ee(t.categoryMatches,(t=>{e[t]=!0}))),e)),{});return function(){const t=this.LA(1);return!0===e[t.tokenTypeIdx]}}}return function(){const e=Pa.call(this,s,c,Oa,a);return"object"!=typeof e&&0===e}}}function ba(e,t=!0){const n=new Set;for(const r of e){const e=new Set;for(const i of r){if(void 0===i){if(t)break;return!1}const r=[i.tokenTypeIdx].concat(i.categoryMatches);for(const t of r)if(n.has(t)){if(!e.has(t))return!1}else n.add(t),e.add(t)}}return!0}function Pa(e,t,n,r){const i=e[t](n);let s=i.start;if(void 0===s){s=ja(i,Ba(function(e){const t=new $a,n=e.transitions.length;for(let r=0;r<n;r++){Va({state:e.transitions[r].target,alt:r,stack:[]},t)}return t}(i.atnStartState))),i.start=s}return Ma.apply(this,[i,s,n,r])}function Ma(e,t,n,r){let i=t,s=1;const a=[];let o=this.LA(s++);for(;;){let t=(c=o,i.edges[c.tokenTypeIdx]);if(void 0===t&&(t=Da.apply(this,[e,i,o,s,n,r])),t===Na)return Fa(a,i,o);if(!0===t.isAcceptState)return t.prediction;i=t,a.push(o),o=this.LA(s++)}var c}function Da(e,t,n,r,i,s){const a=function(e,t,n){const r=new $a,i=[];for(const a of e.elements){if(!1===n.is(a.alt))continue;if(7===a.state.type){i.push(a);continue}const e=a.state.transitions.length;for(let n=0;n<e;n++){const e=Ga(a.state.transitions[n],t);void 0!==e&&r.add({state:e,alt:a.alt,stack:a.stack})}}let s;0===i.length&&1===r.size&&(s=r);if(void 0===s){s=new $a;for(const e of r.elements)Va(e,s)}if(i.length>0&&!function(e){for(const t of e.elements)if(7===t.state.type)return!0;return!1}(s))for(const a of i)s.add(a);return s}(t.configs,n,i);if(0===a.size)return Ka(e,t,n,Na),Na;let o=Ba(a);const c=function(e,t){let n;for(const r of e.elements)if(!0===t.is(r.alt))if(void 0===n)n=r.alt;else if(n!==r.alt)return;return n}(a,i);if(void 0!==c)o.isAcceptState=!0,o.prediction=c,o.configs.uniqueAlt=c;else if(function(e){if(function(e){for(const t of e.elements)if(7!==t.state.type)return!1;return!0}(e))return!0;const t=function(e){const t=new Map;for(const n of e){const e=Ca(n,!1);let r=t.get(e);void 0===r&&(r={},t.set(e,r)),r[n.alt]=!0}return t}(e.elements);return function(e){for(const t of Array.from(e.values()))if(Object.keys(t).length>1)return!0;return!1}(t)&&!function(e){for(const t of Array.from(e.values()))if(1===Object.keys(t).length)return!0;return!1}(t)}(a)){const t=ue(a.alts);o.isAcceptState=!0,o.prediction=t,o.configs.uniqueAlt=t,Ua.apply(this,[e,r,a.alts,s])}return o=Ka(e,t,n,o),o}function Ua(e,t,n,r){const i=[];for(let a=1;a<=t;a++)i.push(this.LA(a).tokenType);const s=e.atnStartState;r(function(e){const t=se(e.prefixPath,(e=>mi(e))).join(", "),n=0===e.production.idx?"":e.production.idx;let r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(", ")}> in <${function(e){if(e instanceof ir)return"SUBRULE";if(e instanceof or)return"OPTION";if(e instanceof dr)return"OR";if(e instanceof cr)return"AT_LEAST_ONE";if(e instanceof lr)return"AT_LEAST_ONE_SEP";if(e instanceof hr)return"MANY_SEP";if(e instanceof ur)return"MANY";if(e instanceof fr)return"CONSUME";throw Error("non exhaustive match")}(e.production)}${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\n`;return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r}({topLevelRule:s.rule,ambiguityIndices:n,production:s.production,prefixPath:i}))}function Fa(e,t,n){const r=Ie(t.configs.elements,(e=>e.state.transitions));var i,s;return{actualToken:n,possibleTokenTypes:(i=r.filter((e=>e instanceof ha)).map((e=>e.tokenType)),s=e=>e.tokenTypeIdx,i&&i.length?Z(i,z(s)):[]),tokenPath:e}}function Ga(e,t){if(e instanceof ha&&Ci(t,e.tokenType))return e.target}function Ba(e){return{configs:e,edges:{},isAcceptState:!1,prediction:-1}}function Ka(e,t,n,r){return r=ja(e,r),t.edges[n.tokenTypeIdx]=r,r}function ja(e,t){if(t===Na)return t;const n=t.configs.key,r=e.states[n];return void 0!==r?r:(t.configs.finalize(),e.states[n]=t,t)}function Va(e,t){const n=e.state;if(7===n.type){if(e.stack.length>0){const n=[...e.stack];Va({state:n.pop(),alt:e.alt,stack:n},t)}else t.add(e);return}n.epsilonOnlyTransitions||t.add(e);const r=n.transitions.length;for(let i=0;i<r;i++){const r=Ha(e,n.transitions[i]);void 0!==r&&Va(r,t)}}function Ha(e,t){if(t instanceof da)return{state:t.target,alt:e.alt,stack:e.stack};if(t instanceof fa){const n=[...e.stack,t.followState];return{state:t.target,alt:e.alt,stack:n}}}class Wa{constructor(){this.nodeStack=[]}get current(){return this.nodeStack[this.nodeStack.length-1]}buildRootNode(e){return this.rootNode=new Qa(e),this.rootNode.root=this.rootNode,this.nodeStack=[this.rootNode],this.rootNode}buildCompositeNode(e){const t=new qa;return t.grammarSource=e,t.root=this.rootNode,this.current.content.push(t),this.nodeStack.push(t),t}buildLeafNode(e,t){const n=new Ya(e.startOffset,e.image.length,at(e),e.tokenType,!1);return n.grammarSource=t,n.root=this.rootNode,this.current.content.push(n),n}removeNode(e){const t=e.container;if(t){const n=t.content.indexOf(e);n>=0&&t.content.splice(n,1)}}construct(e){const t=this.current;"string"==typeof e.$type&&(this.current.astNode=e),e.$cstNode=t;const n=this.nodeStack.pop();0===(null==n?void 0:n.content.length)&&this.removeNode(n)}addHiddenTokens(e){for(const t of e){const e=new Ya(t.startOffset,t.image.length,at(t),t.tokenType,!0);e.root=this.rootNode,this.addHiddenToken(this.rootNode,e)}}addHiddenToken(e,t){const{offset:n,end:r}=t;for(let i=0;i<e.content.length;i++){const s=e.content[i],{offset:a,end:o}=s;if(He(s)&&n>a&&r<o)return void this.addHiddenToken(s,t);if(r<=a)return void e.content.splice(i,0,t)}e.content.push(t)}}class za{get parent(){return this.container}get feature(){return this.grammarSource}get hidden(){return!1}get astNode(){var e,t;const n="string"==typeof(null===(e=this._astNode)||void 0===e?void 0:e.$type)?this._astNode:null===(t=this.container)||void 0===t?void 0:t.astNode;if(!n)throw new Error("This node has no associated AST element");return n}set astNode(e){this._astNode=e}get element(){return this.astNode}get text(){return this.root.fullText.substring(this.offset,this.end)}}class Ya extends za{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,n,r,i=!1){super(),this._hidden=i,this._offset=e,this._tokenType=r,this._length=t,this._range=n}}class qa extends za{constructor(){super(...arguments),this.content=new Xa(this)}get children(){return this.content}get offset(){var e,t;return null!==(t=null===(e=this.firstNonHiddenNode)||void 0===e?void 0:e.offset)&&void 0!==t?t:0}get length(){return this.end-this.offset}get end(){var e,t;return null!==(t=null===(e=this.lastNonHiddenNode)||void 0===e?void 0:e.end)&&void 0!==t?t:0}get range(){const e=this.firstNonHiddenNode,t=this.lastNonHiddenNode;if(e&&t){if(void 0===this._rangeCache){const{range:n}=e,{range:r}=t;this._rangeCache={start:n.start,end:r.end.line<n.start.line?n.start:r.end}}return this._rangeCache}return{start:B.create(0,0),end:B.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 Xa extends Array{constructor(e){super(),this.parent=e,Object.setPrototypeOf(this,Xa.prototype)}push(...e){return this.addParents(e),super.push(...e)}unshift(...e){return this.addParents(e),super.unshift(...e)}splice(e,t,...n){return this.addParents(n),super.splice(e,t,...n)}addParents(e){for(const t of e)t.container=this.parent}}class Qa extends qa{get text(){return this._text.substring(this.offset,this.end)}get fullText(){return this._text}constructor(e){super(),this._text="",this._text=null!=e?e:""}}const Ja=Symbol("Datatype");function Za(e){return e.$type===Ja}const eo=e=>e.endsWith("​")?e:e+"​";class to{constructor(e){this._unorderedGroups=new Map,this.lexer=e.parser.Lexer;const t=this.lexer.definition;this.wrapper=new oo(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 no extends to{get current(){return this.stack[this.stack.length-1]}constructor(e){super(e),this.nodeBuilder=new Wa,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 n=e.fragment?void 0:jn(e)?Ja:Wn(e),r=this.wrapper.DEFINE_RULE(eo(e.name),this.startImplementation(n,t).bind(this));return e.entry&&(this.mainRule=r),r}parse(e){this.nodeBuilder.buildRootNode(e);const t=this.lexer.tokenize(e);this.wrapper.input=t.tokens;const n=this.mainRule.call(this.wrapper,{});return this.nodeBuilder.addHiddenTokens(t.hidden),this.unorderedGroups.clear(),{value:n,lexerErrors:t.errors,parserErrors:this.wrapper.errors}}startImplementation(e,t){return n=>{if(!this.isRecording()){const t={$type:e};this.stack.push(t),e===Ja&&(t.value="")}let r;try{r=t(n)}catch(i){r=void 0}return this.isRecording()||void 0!==r||(r=this.construct()),r}}consume(e,t,n){const r=this.wrapper.wrapConsume(e,t);if(!this.isRecording()&&this.isValidToken(r)){const e=this.nodeBuilder.buildLeafNode(r,n),{assignment:t,isCrossRef:i}=this.getAssignment(n),s=this.current;if(t){const s=zt(n)?r.image:this.converter.convert(r.image,e);this.assign(t.operator,t.feature,s,e,i)}else if(Za(s)){let t=r.image;zt(n)||(t=this.converter.convert(t,e).toString()),s.value+=t}}}isValidToken(e){return!e.isInsertedInRecovery&&!isNaN(e.startOffset)&&"number"==typeof e.endOffset&&!isNaN(e.endOffset)}subrule(e,t,n,r){let i;this.isRecording()||(i=this.nodeBuilder.buildCompositeNode(n));const s=this.wrapper.wrapSubrule(e,t,r);!this.isRecording()&&i&&i.length>0&&this.performSubruleAssignment(s,n,i)}performSubruleAssignment(e,t,n){const{assignment:r,isCrossRef:i}=this.getAssignment(t);if(r)this.assign(r.operator,r.feature,e,n,i);else if(!r){const t=this.current;if(Za(t))t.value+=e.toString();else if("object"==typeof e&&e){const n=e.$type,r=this.assignWithoutOverride(e,t);n&&(r.$type=n);const i=r;this.stack.pop(),this.stack.push(i)}}}action(e,t){if(!this.isRecording()){let n=this.current;if(!n.$cstNode&&t.feature&&t.operator){n=this.construct(!1);const e=n.$cstNode.feature;this.nodeBuilder.buildCompositeNode(e)}const r={$type:e};this.stack.pop(),this.stack.push(r),t.feature&&t.operator&&this.assign(t.operator,t.feature,n,n.$cstNode,!1)}}construct(e=!0){if(this.isRecording())return;const t=this.current;return function(e){for(const[t,n]of Object.entries(e))t.startsWith("$")||(Array.isArray(n)?n.forEach(((n,r)=>{Be(n)&&(n.$container=e,n.$containerProperty=t,n.$containerIndex=r)})):Be(n)&&(n.$container=e,n.$containerProperty=t))}(t),this.nodeBuilder.construct(t),e&&this.stack.pop(),Za(t)?this.converter.convert(t.value,t.$cstNode):(function(e,t){const n=e.getTypeMetaData(t.$type),r=t;for(const i of n.properties)void 0!==i.defaultValue&&void 0===r[i.name]&&(r[i.name]=mn(i.defaultValue))}(this.astReflection,t),t)}getAssignment(e){if(!this.assignmentMap.has(e)){const t=cn(e,Ft);this.assignmentMap.set(e,{assignment:t,isCrossRef:!!t&&Kt(t.terminal)})}return this.assignmentMap.get(e)}assign(e,t,n,r,i){const s=this.current;let a;switch(a=i&&"string"==typeof n?this.linker.buildReference(s,t,r,n):n,e){case"=":s[t]=a;break;case"?=":s[t]=!0;break;case"+=":Array.isArray(s[t])||(s[t]=[]),s[t].push(a)}}assignWithoutOverride(e,t){for(const[n,r]of Object.entries(t)){const t=e[n];void 0===t?e[n]=r:Array.isArray(t)&&Array.isArray(r)&&(r.push(...t),e[n]=r)}return e}get definitionErrors(){return this.wrapper.definitionErrors}}class ro{buildMismatchTokenMessage(e){return wi.buildMismatchTokenMessage(e)}buildNotAllInputParsedMessage(e){return wi.buildNotAllInputParsedMessage(e)}buildNoViableAltMessage(e){return wi.buildNoViableAltMessage(e)}buildEarlyExitMessage(e){return wi.buildEarlyExitMessage(e)}}class io extends ro{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 so extends to{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 n=this.wrapper.DEFINE_RULE(eo(e.name),this.startImplementation(t).bind(this));return e.entry&&(this.mainRule=n),n}resetState(){this.elementStack=[],this.lastElementStack=[],this.nextTokenIndex=0,this.stackSize=0}startImplementation(e){return t=>{const n=this.keepStackSize();try{e(t)}finally{this.resetStackSize(n)}}}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,n){this.wrapper.wrapConsume(e,t),this.isRecording()||(this.lastElementStack=[...this.elementStack,n],this.nextTokenIndex=this.currIdx+1)}subrule(e,t,n,r){this.before(n),this.wrapper.wrapSubrule(e,t,r),this.after(n)}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 ao={recoveryEnabled:!0,nodeLocationTracking:"full",skipValidations:!0,errorMessageProvider:new io};class oo extends ca{constructor(e,t){const n=t&&"maxLookahead"in t;super(e,Object.assign(Object.assign(Object.assign({},ao),{lookaheadStrategy:n?new Ps({maxLookahead:t.maxLookahead}):new _a}),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,n){return this.subrule(e,t,{ARGS:[n]})}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 co(e,t,n){return function(e,t){const n=Mn(t,!1),r=Ze(t.rules).filter($t).filter((e=>n.has(e)));for(const i of r){const t=Object.assign(Object.assign({},e),{consume:1,optional:1,subrule:1,many:1,or:1});t.rules.set(i.name,e.parser.rule(i,lo(t,i.definition)))}}({parser:t,tokens:n,rules:new Map,ruleNames:new Map},e),t}function lo(e,t,n=!1){let r;if(zt(t))r=function(e,t){const n=e.consume++,r=e.tokens[t.value];if(!r)throw new Error("Could not find token for keyword: "+t.value);return()=>e.parser.consume(n,r,t)}(e,t);else if(Pt(t))r=function(e,t){const n=Wn(t);return()=>e.parser.action(n,t)}(e,t);else if(Ft(t))r=lo(e,t.terminal);else if(Kt(t))r=fo(e,t);else if(Qt(t))r=function(e,t){const n=t.rule.ref;if($t(n)){const r=e.subrule++,i=t.arguments.length>0?function(e,t){const n=t.map((e=>uo(e.value)));return t=>{const r={};for(let i=0;i<n.length;i++){const s=e.parameters[i],a=n[i];r[s.name]=a(t)}return r}}(n,t.arguments):()=>({});return s=>e.parser.subrule(r,mo(e,n),t,i(s))}if(Lt(n)){const r=e.consume++,i=go(e,n.name);return()=>e.parser.consume(r,i,t)}if(!n)throw new ht(t.$cstNode,`Undefined rule type: ${t.$type}`);dt()}(e,t);else if(Dt(t))r=function(e,t){if(1===t.elements.length)return lo(e,t.elements[0]);{const n=[];for(const i of t.elements){const t={ALT:lo(e,i,!0)},r=ho(i);r&&(t.GATE=uo(r)),n.push(t)}const r=e.or++;return t=>e.parser.alternatives(r,n.map((e=>{const n={ALT:()=>e.ALT(t)},r=e.GATE;return r&&(n.GATE=()=>r(t)),n})))}}(e,t);else if(nn(t))r=function(e,t){if(1===t.elements.length)return lo(e,t.elements[0]);const n=[];for(const o of t.elements){const t={ALT:lo(e,o,!0)},r=ho(o);r&&(t.GATE=uo(r)),n.push(t)}const r=e.or++,i=(e,t)=>`uGroup_${e}_${t.getRuleStack().join("-")}`,s=t=>e.parser.alternatives(r,n.map(((n,s)=>{const a={ALT:()=>!0},o=e.parser;a.ALT=()=>{if(n.ALT(t),!o.isRecording()){const e=i(r,o);o.unorderedGroups.get(e)||o.unorderedGroups.set(e,[]);const t=o.unorderedGroups.get(e);void 0===(null==t?void 0:t[s])&&(t[s]=!0)}};const c=n.GATE;return a.GATE=c?()=>c(t):()=>{const e=o.unorderedGroups.get(i(r,o));return!(null==e?void 0:e[s])},a}))),a=po(e,ho(t),s,"*");return t=>{a(t),e.parser.isRecording()||e.parser.unorderedGroups.delete(i(r,e.parser))}}(e,t);else if(Ht(t))r=function(e,t){const n=t.elements.map((t=>lo(e,t)));return e=>n.forEach((t=>t(e)))}(e,t);else{if(i=t,!on.isInstance(i,jt))throw new ht(t.$cstNode,`Unexpected element type: ${t.$type}`);{const n=e.consume++;r=()=>e.parser.consume(n,Ni,t)}}var i;return po(e,n?void 0:ho(t),r,t.cardinality)}function uo(e){if(t=e,on.isInstance(t,Rt)){const t=uo(e.left),n=uo(e.right);return e=>t(e)||n(e)}if(function(e){return on.isInstance(e,vt)}(e)){const t=uo(e.left),n=uo(e.right);return e=>t(e)&&n(e)}if(function(e){return on.isInstance(e,It)}(e)){const t=uo(e.value);return e=>!t(e)}if(function(e){return on.isInstance(e,xt)}(e)){const t=e.parameter.ref.name;return e=>void 0!==e&&!0===e[t]}if(function(e){return on.isInstance(e,Tt)}(e)){const t=Boolean(e.true);return()=>t}var t;dt()}function ho(e){if(Ht(e))return e.guardCondition}function fo(e,t,n=t.terminal){if(n){if(Qt(n)&&$t(n.rule.ref)){const r=e.subrule++;return i=>e.parser.subrule(r,mo(e,n.rule.ref),t,i)}if(Qt(n)&&Lt(n.rule.ref)){const r=e.consume++,i=go(e,n.rule.ref.name);return()=>e.parser.consume(r,i,t)}if(zt(n)){const r=e.consume++,i=go(e,n.value);return()=>e.parser.consume(r,i,t)}throw new Error("Could not build cross reference parser")}{if(!t.type.ref)throw new Error("Could not resolve reference to type: "+t.type.$refText);const n=Bn(t.type.ref),r=null==n?void 0:n.terminal;if(!r)throw new Error("Could not find name assignment for type: "+Wn(t.type.ref));return fo(e,t,r)}}function po(e,t,n,r){const i=t&&uo(t);if(!r){if(i){const t=e.or++;return r=>e.parser.alternatives(t,[{ALT:()=>n(r),GATE:()=>i(r)},{ALT:aa(),GATE:()=>!i(r)}])}return n}if("*"===r){const t=e.many++;return r=>e.parser.many(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}if("+"===r){const t=e.many++;if(i){const r=e.or++;return s=>e.parser.alternatives(r,[{ALT:()=>e.parser.atLeastOne(t,{DEF:()=>n(s)}),GATE:()=>i(s)},{ALT:aa(),GATE:()=>!i(s)}])}return r=>e.parser.atLeastOne(t,{DEF:()=>n(r)})}if("?"===r){const t=e.optional++;return r=>e.parser.optional(t,{DEF:()=>n(r),GATE:i?()=>i(r):void 0})}dt()}function mo(e,t){const n=function(e,t){if($t(t))return t.name;if(e.ruleNames.has(t))return e.ruleNames.get(t);{let n=t,r=n.$container,i=t.$type;for(;!$t(r);){if(Ht(r)||Dt(r)||nn(r)){i=r.elements.indexOf(n).toString()+":"+i}n=r,r=r.$container}return i=r.name+":"+i,e.ruleNames.set(t,i),i}}(e,t),r=e.rules.get(n);if(!r)throw new Error(`Rule "${n}" not found."`);return r}function go(e,t){const n=e.tokens[t];if(!n)throw new Error(`Token "${t}" not found."`);return n}function yo(e){const t=function(e){const t=e.Grammar,n=e.parser.Lexer,r=new no(e);return co(t,r,n.definition)}(e);return t.finalize(),t}class To{buildTokens(e,t){const n=Ze(Mn(e,!1)),r=this.buildTerminalTokens(n),i=this.buildKeywordTokens(n,r,t);return r.forEach((e=>{const t=e.PATTERN;"object"==typeof t&&t&&"test"in t&&_n(t)?i.unshift(e):i.push(e)})),i}buildTerminalTokens(e){return e.filter(Lt).filter((e=>!e.fragment)).map((e=>this.buildTerminalToken(e))).toArray()}buildTerminalToken(e){const t=zn(e),n=this.requiresCustomPattern(t)?this.regexPatternFunction(t):t,r={name:e.name,PATTERN:n,LINE_BREAKS:!0};return e.hidden&&(r.GROUP=_n(t)?pi.SKIPPED:"hidden"),r}requiresCustomPattern(e){return!!e.flags.includes("u")||!(!e.source.includes("?<=")&&!e.source.includes("?<!"))}regexPatternFunction(e){const t=new RegExp(e,e.flags+"y");return(e,n)=>{t.lastIndex=n;return t.exec(e)}}buildKeywordTokens(e,t,n){return e.filter($t).flatMap((e=>hn(e).filter(zt))).distinct((e=>e.value)).toArray().sort(((e,t)=>t.value.length-e.value.length)).map((e=>this.buildKeywordToken(e,t,Boolean(null==n?void 0:n.caseInsensitive))))}buildKeywordToken(e,t,n){return{name:e.value,PATTERN:this.buildKeywordPattern(e,n),LONGER_ALT:this.findLongerAlt(e,t)}}buildKeywordPattern(e,t){return t?new RegExp(function(e){return Array.prototype.map.call(e,(e=>/\w/.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:bn(e))).join("")}(e.value)):e.value}findLongerAlt(e,t){return t.reduce(((t,n)=>{const r=null==n?void 0:n.PATTERN;return(null==r?void 0:r.source)&&Pn("^"+r.source+"$",e.value)&&t.push(n),t}),[])}}class vo{convert(e,t){let n=t.grammarSource;if(Kt(n)&&(n=function(e){if(e.terminal)return e.terminal;if(e.type.ref){const t=Bn(e.type.ref);return null==t?void 0:t.terminal}}(n)),Qt(n)){const r=n.rule.ref;if(!r)throw new Error("This cst node was not parsed by a rule.");return this.runConverter(r,e,t)}return e}runConverter(e,t,n){var r;switch(e.name.toUpperCase()){case"INT":return Ro.convertInt(t);case"STRING":return Ro.convertString(t);case"ID":return Ro.convertID(t)}switch(null===(r=function(e){var t,n,r;return Lt(e)?null!==(n=null===(t=e.type)||void 0===t?void 0:t.name)&&void 0!==n?n:"string":jn(e)?e.name:null!==(r=Hn(e))&&void 0!==r?r:e.name}(e))||void 0===r?void 0:r.toLowerCase()){case"number":return Ro.convertNumber(t);case"boolean":return Ro.convertBoolean(t);case"bigint":return Ro.convertBigint(t);case"date":return Ro.convertDate(t);default:return t}}}var Ro;!function(e){function t(e){switch(e){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";case"0":return"\0";default:return e}}e.convertString=function(e){let n="";for(let r=1;r<e.length-1;r++){const i=e.charAt(r);if("\\"===i){n+=t(e.charAt(++r))}else n+=i}return n},e.convertID=function(e){return"^"===e.charAt(0)?e.substring(1):e},e.convertInt=function(e){return parseInt(e)},e.convertBigint=function(e){return BigInt(e)},e.convertDate=function(e){return new Date(e)},e.convertNumber=function(e){return Number(e)},e.convertBoolean=function(e){return"true"===e.toLowerCase()}}(Ro||(Ro={}));var Eo=K();let Ao=0;const ko=Symbol("OperationCancelled");function So(e){return e===ko}async function Io(e){if(e===Eo.CancellationToken.None)return;const t=Date.now();if(t-Ao>=10&&(Ao=t,await new Promise((e=>{"undefined"==typeof setImmediate?setTimeout(e,0):setImmediate(e)}))),e.isCancellationRequested)throw ko}class xo{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=t=>(e(t),this),this.reject=e=>(t(e),this)}))}}class No{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,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),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){for(const n of e)if(No.isIncremental(n)){const e=bo(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);const i=Math.max(e.start.line,0),s=Math.max(e.end.line,0);let a=this._lineOffsets;const o=Oo(n.text,!1,t);if(s-i===o.length)for(let n=0,l=o.length;n<l;n++)a[n+i+1]=o[n];else o.length<1e4?a.splice(i+1,s-i,...o):this._lineOffsets=a=a.slice(0,i+1).concat(o,a.slice(s+1));const c=n.text.length-(r-t);if(0!==c)for(let n=i+1+o.length,l=a.length;n<l;n++)a[n]=a[n]+c}else{if(!No.isFull(n))throw new Error("Unknown change event received");this._content=n.text,this._lineOffsets=void 0}this._version=t}getLineOffsets(){return void 0===this._lineOffsets&&(this._lineOffsets=Oo(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);const t=this.getLineOffsets();let n=0,r=t.length;if(0===r)return{line:0,character:e};for(;n<r;){const i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}const i=n-1;return{line:i,character:(e=this.ensureBeforeEOL(e,t[i]))-t[i]}}offsetAt(e){const t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;const n=t[e.line];if(e.character<=0)return n;const r=e.line+1<t.length?t[e.line+1]:this._content.length,i=Math.min(n+e.character,r);return this.ensureBeforeEOL(i,n)}ensureBeforeEOL(e,t){for(;e>t&&_o(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){const t=e;return null!=t&&"string"==typeof t.text&&void 0!==t.range&&(void 0===t.rangeLength||"number"==typeof t.rangeLength)}static isFull(e){const t=e;return null!=t&&"string"==typeof t.text&&void 0===t.range&&void 0===t.rangeLength}}var $o,Co,wo;function Lo(e,t){if(e.length<=1)return e;const n=e.length/2|0,r=e.slice(0,n),i=e.slice(n);Lo(r,t),Lo(i,t);let s=0,a=0,o=0;for(;s<r.length&&a<i.length;){const n=t(r[s],i[a]);e[o++]=n<=0?r[s++]:i[a++]}for(;s<r.length;)e[o++]=r[s++];for(;a<i.length;)e[o++]=i[a++];return e}function Oo(e,t,n=0){const r=t?[n]:[];for(let i=0;i<e.length;i++){const t=e.charCodeAt(i);_o(t)&&(13===t&&i+1<e.length&&10===e.charCodeAt(i+1)&&i++,r.push(n+i+1))}return r}function _o(e){return 13===e||10===e}function bo(e){const t=e.start,n=e.end;return t.line>n.line||t.line===n.line&&t.character>n.character?{start:n,end:t}:e}function Po(e){const t=bo(e.range);return t!==e.range?{newText:e.newText,range:t}:e}(Co=$o||($o={})).create=function(e,t,n,r){return new No(e,t,n,r)},Co.update=function(e,t,n){if(e instanceof No)return e.update(t,n),e;throw new Error("TextDocument.update: document must be created by TextDocument.create")},Co.applyEdits=function(e,t){const n=e.getText(),r=Lo(t.map(Po),((e,t)=>{const n=e.range.start.line-t.range.start.line;return 0===n?e.range.start.character-t.range.start.character:n}));let i=0;const s=[];for(const a of r){const t=e.offsetAt(a.range.start);if(t<i)throw new Error("Overlapping edit");t>i&&s.push(n.substring(i,t)),a.newText.length&&s.push(a.newText),i=e.offsetAt(a.range.end)}return s.push(n.substr(i)),s.join("")},(()=>{var e={470:e=>{function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var n,r="",i=0,s=-1,a=0,o=0;o<=e.length;++o){if(o<e.length)n=e.charCodeAt(o);else{if(47===n)break;n=47}if(47===n){if(s===o-1||1===a);else if(s!==o-1&&2===a){if(r.length<2||2!==i||46!==r.charCodeAt(r.length-1)||46!==r.charCodeAt(r.length-2))if(r.length>2){var c=r.lastIndexOf("/");if(c!==r.length-1){-1===c?(r="",i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf("/"),s=o,a=0;continue}}else if(2===r.length||1===r.length){r="",i=0,s=o,a=0;continue}t&&(r.length>0?r+="/..":r="..",i=2)}else r.length>0?r+="/"+e.slice(s+1,o):r=e.slice(s+1,o),i=o-s-1;s=o,a=0}else 46===n&&-1!==a?++a:a=-1}return r}var r={resolve:function(){for(var e,r="",i=!1,s=arguments.length-1;s>=-1&&!i;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=process.cwd()),a=e),t(a),0!==a.length&&(r=a+"/"+r,i=47===a.charCodeAt(0))}return r=n(r,!i),i?r.length>0?"/"+r:"/":r.length>0?r:"."},normalize:function(e){if(t(e),0===e.length)return".";var r=47===e.charCodeAt(0),i=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!r)).length||r||(e="."),e.length>0&&i&&(e+="/"),r?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,n=0;n<arguments.length;++n){var i=arguments[n];t(i),i.length>0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n)return"";if((e=r.resolve(e))===(n=r.resolve(n)))return"";for(var i=1;i<e.length&&47===e.charCodeAt(i);++i);for(var s=e.length,a=s-i,o=1;o<n.length&&47===n.charCodeAt(o);++o);for(var c=n.length-o,l=a<c?a:c,u=-1,h=0;h<=l;++h){if(h===l){if(c>l){if(47===n.charCodeAt(o+h))return n.slice(o+h+1);if(0===h)return n.slice(o+h)}else a>l&&(47===e.charCodeAt(i+h)?u=h:0===h&&(u=0));break}var d=e.charCodeAt(i+h);if(d!==n.charCodeAt(o+h))break;47===d&&(u=h)}var f="";for(h=i+u+1;h<=s;++h)h!==s&&47!==e.charCodeAt(h)||(0===f.length?f+="..":f+="/..");return f.length>0?f+n.slice(o+u):(o+=u,47===n.charCodeAt(o)&&++o,n.slice(o))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var n=e.charCodeAt(0),r=47===n,i=-1,s=!0,a=e.length-1;a>=1;--a)if(47===(n=e.charCodeAt(a))){if(!s){i=a;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,n){if(void 0!==n&&"string"!=typeof n)throw new TypeError('"ext" argument must be a string');t(e);var r,i=0,s=-1,a=!0;if(void 0!==n&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return"";var o=n.length-1,c=-1;for(r=e.length-1;r>=0;--r){var l=e.charCodeAt(r);if(47===l){if(!a){i=r+1;break}}else-1===c&&(a=!1,c=r+1),o>=0&&(l===n.charCodeAt(o)?-1==--o&&(s=r):(o=-1,s=c))}return i===s?s=c:-1===s&&(s=e.length),e.slice(i,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!a){i=r+1;break}}else-1===s&&(a=!1,s=r+1);return-1===s?"":e.slice(i,s)},extname:function(e){t(e);for(var n=-1,r=0,i=-1,s=!0,a=0,o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(47!==c)-1===i&&(s=!1,i=o+1),46===c?-1===n?n=o:1!==a&&(a=1):-1!==n&&(a=-1);else if(!s){r=o+1;break}}return-1===n||-1===i||0===a||1===a&&n===i-1&&n===r+1?"":e.slice(n,i)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return n=(t=e).dir||t.root,r=t.base||(t.name||"")+(t.ext||""),n?n===t.root?n+r:n+"/"+r:r;var t,n,r},parse:function(e){t(e);var n={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return n;var r,i=e.charCodeAt(0),s=47===i;s?(n.root="/",r=1):r=0;for(var a=-1,o=0,c=-1,l=!0,u=e.length-1,h=0;u>=r;--u)if(47!==(i=e.charCodeAt(u)))-1===c&&(l=!1,c=u+1),46===i?-1===a?a=u:1!==h&&(h=1):-1!==a&&(h=-1);else if(!l){o=u+1;break}return-1===a||-1===c||0===h||1===h&&a===c-1&&a===o+1?-1!==c&&(n.base=n.name=0===o&&s?e.slice(1,c):e.slice(o,c)):(0===o&&s?(n.name=e.slice(1,a),n.base=e.slice(1,c)):(n.name=e.slice(o,a),n.base=e.slice(o,c)),n.ext=e.slice(a,c)),o>0?n.dir=e.slice(0,o-1):s&&(n.dir="/"),n},sep:"/",delimiter:":",win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{let e;if(n.r(r),n.d(r,{URI:()=>u,Utils:()=>I}),"object"==typeof process)e="win32"===process.platform;else if("object"==typeof navigator){let t=navigator.userAgent;e=t.indexOf("Windows")>=0}const t=/^\w[\w\d+.-]*$/,i=/^\//,s=/^\/\//;function a(e,n){if(!e.scheme&&n)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!t.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!i.test(e.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(s.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}const o="",c="/",l=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class u{constructor(e,t,n,r,i,s=!1){f(this,"scheme"),f(this,"authority"),f(this,"path"),f(this,"query"),f(this,"fragment"),"object"==typeof e?(this.scheme=e.scheme||o,this.authority=e.authority||o,this.path=e.path||o,this.query=e.query||o,this.fragment=e.fragment||o):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t||o,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==c&&(t=c+t):t=c}return t}(this.scheme,n||o),this.query=r||o,this.fragment=i||o,a(this,s))}static isUri(e){return e instanceof u||!!e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"string"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}get fsPath(){return y(this)}with(e){if(!e)return this;let{scheme:t,authority:n,path:r,query:i,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=o),void 0===n?n=this.authority:null===n&&(n=o),void 0===r?r=this.path:null===r&&(r=o),void 0===i?i=this.query:null===i&&(i=o),void 0===s?s=this.fragment:null===s&&(s=o),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&s===this.fragment?this:new d(t,n,r,i,s)}static parse(e,t=!1){const n=l.exec(e);return n?new d(n[2]||o,E(n[4]||o),E(n[5]||o),E(n[7]||o),E(n[9]||o),t):new d(o,o,o,o,o)}static file(t){let n=o;if(e&&(t=t.replace(/\\/g,c)),t[0]===c&&t[1]===c){const e=t.indexOf(c,2);-1===e?(n=t.substring(2),t=c):(n=t.substring(2,e),t=t.substring(e)||c)}return new d("file",n,t,o,o)}static from(e){const t=new d(e.scheme,e.authority,e.path,e.query,e.fragment);return a(t,!0),t}toString(e=!1){return T(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof u)return e;{const t=new d(e);return t._formatted=e.external,t._fsPath=e._sep===h?e.fsPath:null,t}}return e}}const h=e?1:void 0;class d extends u{constructor(){super(...arguments),f(this,"_formatted",null),f(this,"_fsPath",null)}get fsPath(){return this._fsPath||(this._fsPath=y(this)),this._fsPath}toString(e=!1){return e?T(this,!0):(this._formatted||(this._formatted=T(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 p={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 m(e,t,n){let r,i=-1;for(let s=0;s<e.length;s++){const a=e.charCodeAt(s);if(a>=97&&a<=122||a>=65&&a<=90||a>=48&&a<=57||45===a||46===a||95===a||126===a||t&&47===a||n&&91===a||n&&93===a||n&&58===a)-1!==i&&(r+=encodeURIComponent(e.substring(i,s)),i=-1),void 0!==r&&(r+=e.charAt(s));else{void 0===r&&(r=e.substr(0,s));const t=p[a];void 0!==t?(-1!==i&&(r+=encodeURIComponent(e.substring(i,s)),i=-1),r+=t):-1===i&&(i=s)}}return-1!==i&&(r+=encodeURIComponent(e.substring(i))),void 0!==r?r:e}function g(e){let t;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);35===r||63===r?(void 0===t&&(t=e.substr(0,n)),t+=p[r]):void 0!==t&&(t+=e[n])}return void 0!==t?t:e}function y(t,n){let r;return r=t.authority&&t.path.length>1&&"file"===t.scheme?`//${t.authority}${t.path}`:47===t.path.charCodeAt(0)&&(t.path.charCodeAt(1)>=65&&t.path.charCodeAt(1)<=90||t.path.charCodeAt(1)>=97&&t.path.charCodeAt(1)<=122)&&58===t.path.charCodeAt(2)?t.path[1].toLowerCase()+t.path.substr(2):t.path,e&&(r=r.replace(/\//g,"\\")),r}function T(e,t){const n=t?g:m;let r="",{scheme:i,authority:s,path:a,query:o,fragment:l}=e;if(i&&(r+=i,r+=":"),(s||"file"===i)&&(r+=c,r+=c),s){let e=s.indexOf("@");if(-1!==e){const t=s.substr(0,e);s=s.substr(e+1),e=t.lastIndexOf(":"),-1===e?r+=n(t,!1,!1):(r+=n(t.substr(0,e),!1,!1),r+=":",r+=n(t.substr(e+1),!1,!0)),r+="@"}s=s.toLowerCase(),e=s.lastIndexOf(":"),-1===e?r+=n(s,!1,!0):(r+=n(s.substr(0,e),!1,!0),r+=s.substr(e))}if(a){if(a.length>=3&&47===a.charCodeAt(0)&&58===a.charCodeAt(2)){const e=a.charCodeAt(1);e>=65&&e<=90&&(a=`/${String.fromCharCode(e+32)}:${a.substr(3)}`)}else if(a.length>=2&&58===a.charCodeAt(1)){const e=a.charCodeAt(0);e>=65&&e<=90&&(a=`${String.fromCharCode(e+32)}:${a.substr(2)}`)}r+=n(a,!0,!1)}return o&&(r+="?",r+=n(o,!1,!1)),l&&(r+="#",r+=t?l:m(l,!1,!1)),r}function v(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+v(e.substr(3)):e}}const R=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function E(e){return e.match(R)?e.replace(R,(e=>v(e))):e}var A=n(470);const k=A.posix||A,S="/";var I,x;(x=I||(I={})).joinPath=function(e,...t){return e.with({path:k.join(e.path,...t)})},x.resolvePath=function(e,...t){let n=e.path,r=!1;n[0]!==S&&(n=S+n,r=!0);let i=k.resolve(n,...t);return r&&i[0]===S&&!e.authority&&(i=i.substring(1)),e.with({path:i})},x.dirname=function(e){if(0===e.path.length||e.path===S)return e;let t=k.dirname(e.path);return 1===t.length&&46===t.charCodeAt(0)&&(t=""),e.with({path:t})},x.basename=function(e){return k.basename(e.path)},x.extname=function(e){return k.extname(e.path)}})(),wo=r})();const{URI:Mo,Utils:Do}=wo;var Uo,Fo,Go,Bo,Ko,jo,Vo,Ho;(Fo=Uo||(Uo={})).basename=Do.basename,Fo.dirname=Do.dirname,Fo.extname=Do.extname,Fo.joinPath=Do.joinPath,Fo.resolvePath=Do.resolvePath,Fo.equals=function(e,t){return(null==e?void 0:e.toString())===(null==t?void 0:t.toString())},Fo.relative=function(e,t){const n="string"==typeof e?e:e.path,r="string"==typeof t?t:t.path,i=n.split("/").filter((e=>e.length>0)),s=r.split("/").filter((e=>e.length>0));let a=0;for(;a<i.length&&i[a]===s[a];a++);return"../".repeat(i.length-a)+s.slice(a).join("/")},(Bo=Go||(Go={}))[Bo.Changed=0]="Changed",Bo[Bo.Parsed=1]="Parsed",Bo[Bo.IndexedContent=2]="IndexedContent",Bo[Bo.ComputedScopes=3]="ComputedScopes",Bo[Bo.Linked=4]="Linked",Bo[Bo.IndexedReferences=5]="IndexedReferences",Bo[Bo.Validated=6]="Validated";class Wo{constructor(e){this.serviceRegistry=e.ServiceRegistry,this.textDocuments=e.workspace.TextDocuments,this.fileSystemProvider=e.workspace.FileSystemProvider}async fromUri(e,t=Eo.CancellationToken.None){const n=await this.fileSystemProvider.readFile(e);return this.createAsync(e,n,t)}fromTextDocument(e,t,n){return t=null!=t?t:Mo.parse(e.uri),n?this.createAsync(t,e,n):this.create(t,e)}fromString(e,t,n){return n?this.createAsync(t,e,n):this.create(t,e)}fromModel(e,t){return this.create(t,{$model:e})}create(e,t){if("string"==typeof t){const n=this.parse(e,t);return this.createLangiumDocument(n,e,void 0,t)}if("$model"in t){const n={value:t.$model,parserErrors:[],lexerErrors:[]};return this.createLangiumDocument(n,e)}{const n=this.parse(e,t.getText());return this.createLangiumDocument(n,e,t)}}async createAsync(e,t,n){if("string"==typeof t){const r=await this.parseAsync(e,t,n);return this.createLangiumDocument(r,e,void 0,t)}{const r=await this.parseAsync(e,t.getText(),n);return this.createLangiumDocument(r,e,t)}}createLangiumDocument(e,t,n,r){let i;if(n)i={parseResult:e,uri:t,state:Go.Parsed,references:[],textDocument:n};else{const n=this.createTextDocumentGetter(t,r);i={parseResult:e,uri:t,state:Go.Parsed,references:[],get textDocument(){return n()}}}return e.value.$document=i,i}async update(e,t){var n,r;const i=null===(n=e.parseResult.value.$cstNode)||void 0===n?void 0:n.root.fullText,s=null===(r=this.textDocuments)||void 0===r?void 0:r.get(e.uri.toString()),a=s?s.getText():await this.fileSystemProvider.readFile(e.uri);if(s)Object.defineProperty(e,"textDocument",{value:s});else{const t=this.createTextDocumentGetter(e.uri,a);Object.defineProperty(e,"textDocument",{get:t})}return i!==a&&(e.parseResult=await this.parseAsync(e.uri,a,t),e.parseResult.value.$document=e),e.state=Go.Parsed,e}parse(e,t){return this.serviceRegistry.getServices(e).parser.LangiumParser.parse(t)}parseAsync(e,t,n){return this.serviceRegistry.getServices(e).parser.AsyncParser.parse(t,n)}createTextDocumentGetter(e,t){const n=this.serviceRegistry;let r;return()=>null!=r?r:r=$o.create(e.toString(),n.getServices(e).LanguageMetaData.languageId,0,null!=t?t:"")}}class zo{constructor(e){this.documentMap=new Map,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory}get all(){return Ze(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 n=this.getDocument(e);return n||(n=await this.langiumDocumentFactory.fromUri(e,t),this.addDocument(n),n)}createDocument(e,t,n){if(n)return this.langiumDocumentFactory.fromString(t,e,n).then((e=>(this.addDocument(e),e)));{const n=this.langiumDocumentFactory.fromString(t,e);return this.addDocument(n),n}}hasDocument(e){return this.documentMap.has(e.toString())}invalidateDocument(e){const t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=Go.Changed,n.precomputedScopes=void 0,n.references=[],n.diagnostics=void 0),n}deleteDocument(e){const t=e.toString(),n=this.documentMap.get(t);return n&&(n.state=Go.Changed,this.documentMap.delete(t)),n}}class Yo{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=Eo.CancellationToken.None){for(const n of dn(e.parseResult.value))await Io(t),pn(n).forEach((t=>this.doLink(t,e)))}doLink(e,t){const n=e.reference;if(void 0===n._ref)try{const t=this.getCandidate(e);if(je(t))n._ref=t;else if(n._nodeDescription=t,this.langiumDocuments().hasDocument(t.documentUri)){const r=this.loadAstNode(t);n._ref=null!=r?r:this.createLinkingError(e,t)}}catch(r){n._ref=Object.assign(Object.assign({},e),{message:`An error occurred while resolving reference to '${n.$refText}': ${r}`})}t.references.push(n)}unlink(e){for(const t of e.references)delete t._ref,delete t._nodeDescription;e.references=[]}getCandidate(e){const t=this.scopeProvider.getScope(e).getElement(e.reference.$refText);return null!=t?t:this.createLinkingError(e)}buildReference(e,t,n,r){const i=this,s={$refNode:n,$refText:r,get ref(){var n,r;if(Be(this._ref))return this._ref;if("object"==typeof(r=this._nodeDescription)&&null!==r&&"string"==typeof r.name&&"string"==typeof r.type&&"string"==typeof r.path){const n=i.loadAstNode(this._nodeDescription);this._ref=null!=n?n:i.createLinkingError({reference:s,container:e,property:t},this._nodeDescription)}else if(void 0===this._ref){const r=i.getLinkedNode({reference:s,container:e,property:t});if(r.error&&ln(e).state<Go.ComputedScopes)return;this._ref=null!==(n=r.node)&&void 0!==n?n:r.error,this._nodeDescription=r.descr}return Be(this._ref)?this._ref:void 0},get $nodeDescription(){return this._nodeDescription},get error(){return je(this._ref)?this._ref:void 0}};return s}getLinkedNode(e){try{const t=this.getCandidate(e);if(je(t))return{error:t};const n=this.loadAstNode(t);return n?{node:n,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);return t?this.astNodeLocator.getAstNode(t.parseResult.value,e.path):void 0}createLinkingError(e,t){const n=ln(e.container);n.state<Go.ComputedScopes&&console.warn(`Attempted reference resolution before document reached ComputedScopes state (${n.uri}).`);const r=this.reflection.getReferenceType(e);return Object.assign(Object.assign({},e),{message:`Could not resolve reference to ${r} named '${e.reference.$refText}'.`,targetDescription:t})}}class qo{getName(e){if(function(e){return"string"==typeof e.name}(e))return e.name}getNameNode(e){return Un(e.$cstNode,"name")}}class Xo{constructor(e){this.nameProvider=e.references.NameProvider,this.index=e.shared.workspace.IndexManager,this.nodeLocator=e.workspace.AstNodeLocator}findDeclaration(e){if(e){const t=function(e){var t;const n=e.astNode;for(;n===(null===(t=e.container)||void 0===t?void 0:t.astNode);){const t=cn(e.grammarSource,Ft);if(t)return t;e=e.container}}(e),n=e.astNode;if(t&&n){const r=n[t.feature];if(Ke(r))return r.ref;if(Array.isArray(r))for(const t of r)if(Ke(t)&&t.$refNode&&t.$refNode.offset<=e.offset&&t.$refNode.end>=e.end)return t.ref}if(n){const t=this.nameProvider.getNameNode(n);if(t&&(t===e||function(e,t){for(;e.container;)if((e=e.container)===t)return!0;return!1}(e,t)))return n}}}findDeclarationNode(e){const t=this.findDeclaration(e);if(null==t?void 0:t.$cstNode){const e=this.nameProvider.getNameNode(t);return null!=e?e:t.$cstNode}}findReferences(e,t){const n=[];if(t.includeDeclaration){const t=this.getReferenceToSelf(e);t&&n.push(t)}let r=this.index.findAllReferences(e,this.nodeLocator.getAstNodePath(e));return t.documentUri&&(r=r.filter((e=>Uo.equals(e.sourceUri,t.documentUri)))),n.push(...r),Ze(n)}getReferenceToSelf(e){const t=this.nameProvider.getNameNode(e);if(t){const n=ln(e),r=this.nodeLocator.getAstNodePath(e);return{sourceUri:n.uri,sourcePath:r,targetUri:n.uri,targetPath:r,segment:ot(t),local:!0}}}}class Qo{constructor(e){if(this.map=new Map,e)for(const[t,n]of e)this.add(t,n)}get size(){return tt.sum(Ze(this.map.values()).map((e=>e.length)))}clear(){this.map.clear()}delete(e,t){if(void 0===t)return this.map.delete(e);{const n=this.map.get(e);if(n){const r=n.indexOf(t);if(r>=0)return 1===n.length?this.map.delete(e):n.splice(r,1),!0}return!1}}get(e){var t;return null!==(t=this.map.get(e))&&void 0!==t?t:[]}has(e,t){if(void 0===t)return this.map.has(e);{const n=this.map.get(e);return!!n&&n.indexOf(t)>=0}}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,n)=>t.forEach((t=>e(t,n,this)))))}[Symbol.iterator](){return this.entries().iterator()}entries(){return Ze(this.map.entries()).flatMap((([e,t])=>t.map((t=>[e,t]))))}keys(){return Ze(this.map.keys())}values(){return Ze(this.map.values()).flat()}entriesGroupedByKey(){return Ze(this.map.entries())}}class Jo{get size(){return this.map.size}constructor(e){if(this.map=new Map,this.inverse=new Map,e)for(const[t,n]of e)this.set(t,n)}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 void 0!==t&&(this.map.delete(e),this.inverse.delete(t),!0)}}class Zo{constructor(e){this.nameProvider=e.references.NameProvider,this.descriptions=e.workspace.AstNodeDescriptionProvider}async computeExports(e,t=Eo.CancellationToken.None){return this.computeExportsForNode(e.parseResult.value,e,void 0,t)}async computeExportsForNode(e,t,n=un,r=Eo.CancellationToken.None){const i=[];this.exportNode(e,i,t);for(const s of n(e))await Io(r),this.exportNode(s,i,t);return i}exportNode(e,t,n){const r=this.nameProvider.getName(e);r&&t.push(this.descriptions.createDescription(e,r,n))}async computeLocalScopes(e,t=Eo.CancellationToken.None){const n=e.parseResult.value,r=new Qo;for(const i of hn(n))await Io(t),this.processNode(i,e,r);return r}processNode(e,t,n){const r=e.$container;if(r){const i=this.nameProvider.getName(e);i&&n.add(r,this.descriptions.createDescription(e,i,t))}}}class ec{constructor(e,t,n){var r;this.elements=e,this.outerScope=t,this.caseInsensitive=null!==(r=null==n?void 0:n.caseInsensitive)&&void 0!==r&&r}getAllElements(){return this.outerScope?this.elements.concat(this.outerScope.getAllElements()):this.elements}getElement(e){const t=this.caseInsensitive?this.elements.find((t=>t.name.toLowerCase()===e.toLowerCase())):this.elements.find((t=>t.name===e));return t||(this.outerScope?this.outerScope.getElement(e):void 0)}}class tc{constructor(e,t,n){var r;this.elements=new Map,this.caseInsensitive=null!==(r=null==n?void 0:n.caseInsensitive)&&void 0!==r&&r;for(const i of e){const e=this.caseInsensitive?i.name.toLowerCase():i.name;this.elements.set(e,i)}this.outerScope=t}getElement(e){const t=this.caseInsensitive?e.toLowerCase():e,n=this.elements.get(t);return n||(this.outerScope?this.outerScope.getElement(e):void 0)}getAllElements(){let e=Ze(this.elements.values());return this.outerScope&&(e=e.concat(this.outerScope.getAllElements())),e}}class nc{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 rc extends nc{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 n=t();return this.cache.set(e,n),n}}delete(e){return this.throwIfDisposed(),this.cache.delete(e)}clear(){this.throwIfDisposed(),this.cache.clear()}}class ic extends nc{constructor(e){super(),this.cache=new Map,this.converter=null!=e?e:e=>e}has(e,t){return this.throwIfDisposed(),this.cacheForContext(e).has(t)}set(e,t,n){this.throwIfDisposed(),this.cacheForContext(e).set(t,n)}get(e,t,n){this.throwIfDisposed();const r=this.cacheForContext(e);if(r.has(t))return r.get(t);if(n){const e=n();return r.set(t,e),e}}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 n=this.cache.get(t);return n||(n=new Map,this.cache.set(t,n)),n}}class sc extends rc{constructor(e){super(),this.onDispose(e.workspace.DocumentBuilder.onUpdate((()=>{this.clear()})))}}class ac{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 sc(e.shared)}getScope(e){const t=[],n=this.reflection.getReferenceType(e),r=ln(e.container).precomputedScopes;if(r){let i=e.container;do{const e=r.get(i);e.length>0&&t.push(Ze(e).filter((e=>this.reflection.isSubtype(e.type,n)))),i=i.$container}while(i)}let i=this.getGlobalScope(n,e);for(let s=t.length-1;s>=0;s--)i=this.createScope(t[s],i);return i}createScope(e,t,n){return new ec(Ze(e),t,n)}createScopeForNodes(e,t,n){const r=Ze(e).map((e=>{const t=this.nameProvider.getName(e);if(t)return this.descriptions.createDescription(e,t)})).nonNullable();return new ec(r,t,n)}getGlobalScope(e,t){return this.globalScopeCache.get(e,(()=>new tc(this.indexManager.allElements(e))))}}function oc(e){return"object"==typeof e&&!!e&&("$ref"in e||"$error"in e)}class cc{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 n=null==t?void 0:t.replacer,r=(e,n)=>this.replacer(e,n,t),i=n?(e,t)=>n(e,t,r):r;try{return this.currentDocument=ln(e),JSON.stringify(e,i,null==t?void 0:t.space)}finally{this.currentDocument=void 0}}deserialize(e,t={}){const n=JSON.parse(e);return this.linkNode(n,n,t),n}replacer(e,t,{refText:n,sourceText:r,textRegions:i,comments:s,uriConverter:a}){var o,c,l,u;if(!this.ignoreProperties.has(e)){if(Ke(t)){const e=t.ref,r=n?t.$refText:void 0;if(e){const n=ln(e);let i="";this.currentDocument&&this.currentDocument!==n&&(i=a?a(n.uri,t):n.uri.toString());return{$ref:`${i}#${this.astNodeLocator.getAstNodePath(e)}`,$refText:r}}return{$error:null!==(c=null===(o=t.error)||void 0===o?void 0:o.message)&&void 0!==c?c:"Could not resolve reference",$refText:r}}if(Be(t)){let n;if(i&&(n=this.addAstNodeRegionWithAssignmentsTo(Object.assign({},t)),e&&!t.$document||!(null==n?void 0:n.$textRegion)||(n.$textRegion.documentURI=null===(l=this.currentDocument)||void 0===l?void 0:l.uri.toString())),r&&!e&&(null!=n||(n=Object.assign({},t)),n.$sourceText=null===(u=t.$cstNode)||void 0===u?void 0:u.text),s){null!=n||(n=Object.assign({},t));const e=this.commentProvider.getComment(t);e&&(n.$comment=e.replace(/\r/g,""))}return null!=n?n:t}return t}}addAstNodeRegionWithAssignmentsTo(e){const t=e=>({offset:e.offset,end:e.end,length:e.length,range:e.range});if(e.$cstNode){const n=(e.$textRegion=t(e.$cstNode)).assignments={};return Object.keys(e).filter((e=>!e.startsWith("$"))).forEach((r=>{const i=function(e,t){return e&&t?Fn(e,t,e.astNode,!0):[]}(e.$cstNode,r).map(t);0!==i.length&&(n[r]=i)})),e}}linkNode(e,t,n,r,i,s){for(const[o,c]of Object.entries(e))if(Array.isArray(c))for(let r=0;r<c.length;r++){const i=c[r];oc(i)?c[r]=this.reviveReference(e,o,t,i,n):Be(i)&&this.linkNode(i,t,n,e,o,r)}else oc(c)?e[o]=this.reviveReference(e,o,t,c,n):Be(c)&&this.linkNode(c,t,n,e,o);const a=e;a.$container=r,a.$containerProperty=i,a.$containerIndex=s}reviveReference(e,t,n,r,i){let s=r.$refText,a=r.$error;if(r.$ref){const e=this.getRefNode(n,r.$ref,i.uriConverter);if(Be(e))return s||(s=this.nameProvider.getName(e)),{$refText:null!=s?s:"",ref:e};a=e}if(a){const n={$refText:null!=s?s:""};return n.error={container:e,property:t,message:a,reference:n},n}}getRefNode(e,t,n){try{const r=t.indexOf("#");if(0===r){const n=this.astNodeLocator.getAstNode(e,t.substring(1));return n||"Could not resolve path: "+t}if(r<0){const e=n?n(t):Mo.parse(t),r=this.langiumDocuments.getDocument(e);return r?r.parseResult.value:"Could not find document for URI: "+t}const i=n?n(t.substring(0,r)):Mo.parse(t.substring(0,r)),s=this.langiumDocuments.getDocument(i);if(!s)return"Could not find document for URI: "+t;if(r===t.length-1)return s.parseResult.value;const a=this.astNodeLocator.getAstNode(s.parseResult.value,t.substring(r+1));return a||"Could not resolve URI: "+t}catch(r){return String(r)}}}class lc{register(e){if(this.singleton||this.map){if(!this.map&&(this.map={},this.singleton)){for(const e of this.singleton.LanguageMetaData.fileExtensions)this.map[e]=this.singleton;this.singleton=void 0}for(const t of e.LanguageMetaData.fileExtensions)void 0!==this.map[t]&&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}else this.singleton=e}getServices(e){if(void 0!==this.singleton)return this.singleton;if(void 0===this.map)throw new Error("The service registry is empty. Use `register` to register the services of a language.");const t=Uo.extname(e),n=this.map[t];if(!n)throw new Error(`The service registry contains no services for the extension '${t}'.`);return n}get all(){return void 0!==this.singleton?[this.singleton]:void 0!==this.map?Object.values(this.map):[]}}function uc(e){return{code:e}}(Ko||(Ko={})).all=["fast","slow","built-in"];class hc{constructor(e){this.entries=new Qo,this.reflection=e.shared.AstReflection}register(e,t=this,n="fast"){if("built-in"===n)throw new Error("The 'built-in' category is reserved for lexer, parser, and linker errors.");for(const[r,i]of Object.entries(e)){const e=i;if(Array.isArray(e))for(const i of e){const e={check:this.wrapValidationException(i,t),category:n};this.addEntry(r,e)}else if("function"==typeof e){const i={check:this.wrapValidationException(e,t),category:n};this.addEntry(r,i)}}}wrapValidationException(e,t){return async(n,r,i)=>{try{await e.call(t,n,r,i)}catch(s){if(So(s))throw s;console.error("An error occurred during validation:",s);const e=s instanceof Error?s.message:String(s);s instanceof Error&&s.stack&&console.error(s.stack),r("error","An error occurred during validation: "+e,{node:n})}}}addEntry(e,t){if("AstNode"!==e)for(const n of this.reflection.getAllSubTypes(e))this.entries.add(n,t);else this.entries.add("AstNode",t)}getChecks(e,t){let n=Ze(this.entries.get(e)).concat(this.entries.get("AstNode"));return t&&(n=n.filter((e=>t.includes(e.category)))),n.map((e=>e.check))}}class dc{constructor(e){this.validationRegistry=e.validation.ValidationRegistry,this.metadata=e.LanguageMetaData}async validateDocument(e,t={},n=Eo.CancellationToken.None){const r=e.parseResult,i=[];if(await Io(n),!t.categories||t.categories.includes("built-in")){if(this.processLexingErrors(r,i,t),t.stopAfterLexingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.LexingError})))return i;if(this.processParsingErrors(r,i,t),t.stopAfterParsingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.ParsingError})))return i;if(this.processLinkingErrors(e,i,t),t.stopAfterLinkingErrors&&i.some((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.code)===jo.LinkingError})))return i}try{i.push(...await this.validateAst(r.value,t,n))}catch(s){if(So(s))throw s;console.error("An error occurred during validation:",s)}return await Io(n),i}processLexingErrors(e,t,n){for(const r of e.lexerErrors){const e={severity:pc("error"),range:{start:{line:r.line-1,character:r.column-1},end:{line:r.line-1,character:r.column+r.length-1}},message:r.message,data:uc(jo.LexingError),source:this.getSource()};t.push(e)}}processParsingErrors(e,t,n){for(const r of e.parserErrors){let e;if(isNaN(r.token.startOffset)){if("previousToken"in r){const t=r.previousToken;if(isNaN(t.startOffset)){const t={line:0,character:0};e={start:t,end:t}}else{const n={line:t.endLine-1,character:t.endColumn};e={start:n,end:n}}}}else e=at(r.token);if(e){const n={severity:pc("error"),range:e,message:r.message,data:uc(jo.ParsingError),source:this.getSource()};t.push(n)}}}processLinkingErrors(e,t,n){for(const r of e.references){const e=r.error;if(e){const n={node:e.container,property:e.property,index:e.index,data:{code:jo.LinkingError,containerType:e.container.$type,property:e.property,refText:e.reference.$refText}};t.push(this.toDiagnostic("error",e.message,n))}}}async validateAst(e,t,n=Eo.CancellationToken.None){const r=[],i=(e,t,n)=>{r.push(this.toDiagnostic(e,t,n))};return await Promise.all(dn(e).map((async e=>{await Io(n);const r=this.validationRegistry.getChecks(e.$type,t.categories);for(const t of r)await t(e,i,n)}))),r}toDiagnostic(e,t,n){return{message:t,range:fc(n),severity:pc(e),code:n.code,codeDescription:n.codeDescription,tags:n.tags,relatedInformation:n.relatedInformation,data:n.data,source:this.getSource()}}getSource(){return this.metadata.languageId}}function fc(e){if(e.range)return e.range;let t;return"string"==typeof e.property?t=Un(e.node.$cstNode,e.property,e.index):"string"==typeof e.keyword&&(t=Gn(e.node.$cstNode,e.keyword,e.index)),null!=t||(t=e.node.$cstNode),t?t.range:{start:{line:0,character:0},end:{line:0,character:0}}}function pc(e){switch(e){case"error":return 1;case"warning":return 2;case"info":return 3;case"hint":return 4;default:throw new Error("Invalid diagnostic severity: "+e)}}(Vo=jo||(jo={})).LexingError="lexing-error",Vo.ParsingError="parsing-error",Vo.LinkingError="linking-error";class mc{constructor(e){this.astNodeLocator=e.workspace.AstNodeLocator,this.nameProvider=e.references.NameProvider}createDescription(e,t,n=ln(e)){null!=t||(t=this.nameProvider.getName(e));const r=this.astNodeLocator.getAstNodePath(e);if(!t)throw new Error(`Node at path ${r} has no name.`);let i;const s=()=>{var t;return null!=i?i:i=ot(null!==(t=this.nameProvider.getNameNode(e))&&void 0!==t?t:e.$cstNode)};return{node:e,name:t,get nameSegment(){return s()},selectionSegment:ot(e.$cstNode),type:e.$type,documentUri:n.uri,path:r}}}class gc{constructor(e){this.nodeLocator=e.workspace.AstNodeLocator}async createDescriptions(e,t=Eo.CancellationToken.None){const n=[],r=e.parseResult.value;for(const i of dn(r))await Io(t),pn(i).filter((e=>!je(e))).forEach((e=>{const t=this.createDescription(e);t&&n.push(t)}));return n}createDescription(e){const t=e.reference.$nodeDescription,n=e.reference.$refNode;if(!t||!n)return;const r=ln(e.container).uri;return{sourceUri:r,sourcePath:this.nodeLocator.getAstNodePath(e.container),targetUri:t.documentUri,targetPath:t.path,segment:ot(n),local:Uo.equals(t.documentUri,r)}}}class yc{constructor(){this.segmentSeparator="/",this.indexSeparator="@"}getAstNodePath(e){if(e.$container){const t=this.getAstNodePath(e.$container),n=this.getPathSegment(e);return t+this.segmentSeparator+n}return""}getPathSegment({$containerProperty:e,$containerIndex:t}){if(!e)throw new Error("Missing '$containerProperty' in AST node.");return void 0!==t?e+this.indexSeparator+t:e}getAstNode(e,t){return t.split(this.segmentSeparator).reduce(((e,t)=>{if(!e||0===t.length)return e;const n=t.indexOf(this.indexSeparator);if(n>0){const r=t.substring(0,n),i=parseInt(t.substring(n+1)),s=e[r];return null==s?void 0:s[i]}return e[t]}),e)}}class Tc{constructor(e){this._ready=new xo,this.settings={},this.workspaceConfig=!1,this.serviceRegistry=e.ServiceRegistry}get ready(){return this._ready.promise}initialize(e){var t,n;this.workspaceConfig=null!==(n=null===(t=e.capabilities.workspace)||void 0===t?void 0:t.configuration)&&void 0!==n&&n}async initialized(e){if(this.workspaceConfig){if(e.register){const t=this.serviceRegistry.all;e.register({section:t.map((e=>this.toSectionName(e.LanguageMetaData.languageId)))})}if(e.fetchConfiguration){const t=this.serviceRegistry.all.map((e=>({section:this.toSectionName(e.LanguageMetaData.languageId)}))),n=await e.fetchConfiguration(t);t.forEach(((e,t)=>{this.updateSectionConfiguration(e.section,n[t])}))}}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 n=this.toSectionName(e);if(this.settings[n])return this.settings[n][t]}toSectionName(e){return`${e}`}}(Ho||(Ho={})).create=function(e){return{dispose:async()=>await e()}};class vc{constructor(e){this.updateBuildOptions={validation:{categories:["built-in","fast"]}},this.updateListeners=[],this.buildPhaseListeners=new Qo,this.buildState=new Map,this.documentBuildWaiters=new Map,this.currentState=Go.Changed,this.langiumDocuments=e.workspace.LangiumDocuments,this.langiumDocumentFactory=e.workspace.LangiumDocumentFactory,this.indexManager=e.workspace.IndexManager,this.serviceRegistry=e.ServiceRegistry}async build(e,t={},n=Eo.CancellationToken.None){var r,i;for(const s of e){const e=s.uri.toString();if(s.state===Go.Validated){if("boolean"==typeof t.validation&&t.validation)s.state=Go.IndexedReferences,s.diagnostics=void 0,this.buildState.delete(e);else if("object"==typeof t.validation){const n=this.buildState.get(e),a=null===(r=null==n?void 0:n.result)||void 0===r?void 0:r.validationChecks;if(a){const r=(null!==(i=t.validation.categories)&&void 0!==i?i:Ko.all).filter((e=>!a.includes(e)));r.length>0&&(this.buildState.set(e,{completed:!1,options:{validation:Object.assign(Object.assign({},t.validation),{categories:r})},result:n.result}),s.state=Go.IndexedReferences)}}}else this.buildState.delete(e)}this.currentState=Go.Changed,await this.emitUpdate(e.map((e=>e.uri)),[]),await this.buildDocuments(e,t,n)}async update(e,t,n=Eo.CancellationToken.None){this.currentState=Go.Changed;for(const s of t)this.langiumDocuments.deleteDocument(s),this.buildState.delete(s.toString()),this.indexManager.remove(s);for(const s of e){if(!this.langiumDocuments.invalidateDocument(s)){const e=this.langiumDocumentFactory.fromModel({$type:"INVALID"},s);e.state=Go.Changed,this.langiumDocuments.addDocument(e)}this.buildState.delete(s.toString())}const r=Ze(e).concat(t).map((e=>e.toString())).toSet();this.langiumDocuments.all.filter((e=>!r.has(e.uri.toString())&&this.shouldRelink(e,r))).forEach((e=>{this.serviceRegistry.getServices(e.uri).references.Linker.unlink(e),e.state=Math.min(e.state,Go.ComputedScopes),e.diagnostics=void 0})),await this.emitUpdate(e,t),await Io(n);const i=this.langiumDocuments.all.filter((e=>{var t;return e.state<Go.Linked||!(null===(t=this.buildState.get(e.uri.toString()))||void 0===t?void 0:t.completed)})).toArray();await this.buildDocuments(i,this.updateBuildOptions,n)}async emitUpdate(e,t){await Promise.all(this.updateListeners.map((n=>n(e,t))))}shouldRelink(e,t){return!!e.references.some((e=>void 0!==e.error))||this.indexManager.isAffected(e,t)}onUpdate(e){return this.updateListeners.push(e),Ho.create((()=>{const t=this.updateListeners.indexOf(e);t>=0&&this.updateListeners.splice(t,1)}))}async buildDocuments(e,t,n){this.prepareBuild(e,t),await this.runCancelable(e,Go.Parsed,n,(e=>this.langiumDocumentFactory.update(e,n))),await this.runCancelable(e,Go.IndexedContent,n,(e=>this.indexManager.updateContent(e,n))),await this.runCancelable(e,Go.ComputedScopes,n,(async e=>{const t=this.serviceRegistry.getServices(e.uri).references.ScopeComputation;e.precomputedScopes=await t.computeLocalScopes(e,n)})),await this.runCancelable(e,Go.Linked,n,(e=>this.serviceRegistry.getServices(e.uri).references.Linker.link(e,n))),await this.runCancelable(e,Go.IndexedReferences,n,(e=>this.indexManager.updateReferences(e,n)));const r=e.filter((e=>this.shouldValidate(e)));await this.runCancelable(r,Go.Validated,n,(e=>this.validate(e,n)));for(const i of e){const e=this.buildState.get(i.uri.toString());e&&(e.completed=!0)}}prepareBuild(e,t){for(const n of e){const e=n.uri.toString(),r=this.buildState.get(e);r&&!r.completed||this.buildState.set(e,{completed:!1,options:t,result:null==r?void 0:r.result})}}async runCancelable(e,t,n,r){const i=e.filter((e=>e.state<t));for(const s of i)await Io(n),await r(s),s.state=t;await this.notifyBuildPhase(i,t,n),this.currentState=t}onBuildPhase(e,t){return this.buildPhaseListeners.add(e,t),Ho.create((()=>{this.buildPhaseListeners.delete(e,t)}))}waitUntil(e,t,n){let r;if(t&&"path"in t?r=t:n=t,null!=n||(n=Eo.CancellationToken.None),r){const t=this.langiumDocuments.getDocument(r);if(t&&t.state>e)return Promise.resolve(r)}return this.currentState>=e?Promise.resolve(void 0):n.isCancellationRequested?Promise.reject(ko):new Promise(((t,i)=>{const s=this.onBuildPhase(e,(()=>{if(s.dispose(),a.dispose(),r){const e=this.langiumDocuments.getDocument(r);t(null==e?void 0:e.uri)}else t(void 0)})),a=n.onCancellationRequested((()=>{s.dispose(),a.dispose(),i(ko)}))}))}async notifyBuildPhase(e,t,n){if(0===e.length)return;const r=this.buildPhaseListeners.get(t);for(const i of r)await Io(n),await i(e,n)}shouldValidate(e){return Boolean(this.getBuildOptions(e).validation)}async validate(e,t){var n,r;const i=this.serviceRegistry.getServices(e.uri).validation.DocumentValidator,s=this.getBuildOptions(e).validation,a="object"==typeof s?s:void 0,o=await i.validateDocument(e,a,t);e.diagnostics?e.diagnostics.push(...o):e.diagnostics=o;const c=this.buildState.get(e.uri.toString());if(c){null!==(n=c.result)&&void 0!==n||(c.result={});const e=null!==(r=null==a?void 0:a.categories)&&void 0!==r?r:Ko.all;c.result.validationChecks?c.result.validationChecks.push(...e):c.result.validationChecks=[...e]}}getBuildOptions(e){var t,n;return null!==(n=null===(t=this.buildState.get(e.uri.toString()))||void 0===t?void 0:t.options)&&void 0!==n?n:{}}}class Rc{constructor(e){this.symbolIndex=new Map,this.symbolByTypeIndex=new ic,this.referenceIndex=new Map,this.documents=e.workspace.LangiumDocuments,this.serviceRegistry=e.ServiceRegistry,this.astReflection=e.AstReflection}findAllReferences(e,t){const n=ln(e).uri,r=[];return this.referenceIndex.forEach((e=>{e.forEach((e=>{Uo.equals(e.targetUri,n)&&e.targetPath===t&&r.push(e)}))})),Ze(r)}allElements(e,t){let n=Ze(this.symbolIndex.keys());return t&&(n=n.filter((e=>!t||t.has(e)))),n.map((t=>this.getFileDescriptions(t,e))).flat()}getFileDescriptions(e,t){var n;if(!t)return null!==(n=this.symbolIndex.get(e))&&void 0!==n?n:[];return this.symbolByTypeIndex.get(e,t,(()=>{var n;return(null!==(n=this.symbolIndex.get(e))&&void 0!==n?n:[]).filter((e=>this.astReflection.isSubtype(e.type,t)))}))}remove(e){const t=e.toString();this.symbolIndex.delete(t),this.symbolByTypeIndex.clear(t),this.referenceIndex.delete(t)}async updateContent(e,t=Eo.CancellationToken.None){const n=this.serviceRegistry.getServices(e.uri),r=await n.references.ScopeComputation.computeExports(e,t),i=e.uri.toString();this.symbolIndex.set(i,r),this.symbolByTypeIndex.clear(i)}async updateReferences(e,t=Eo.CancellationToken.None){const n=this.serviceRegistry.getServices(e.uri),r=await n.workspace.ReferenceDescriptionProvider.createDescriptions(e,t);this.referenceIndex.set(e.uri.toString(),r)}isAffected(e,t){const n=this.referenceIndex.get(e.uri.toString());return!!n&&n.some((e=>!e.local&&t.has(e.targetUri.toString())))}}class Ec{constructor(e){this.initialBuildOptions={},this._ready=new xo,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=null!==(t=e.workspaceFolders)&&void 0!==t?t:void 0}initialized(e){return this.mutex.write((e=>{var t;return this.initializeWorkspace(null!==(t=this.folders)&&void 0!==t?t:[],e)}))}async initializeWorkspace(e,t=Eo.CancellationToken.None){const n=await this.performStartup(e);await Io(t),await this.documentBuilder.build(n,this.initialBuildOptions,t)}async performStartup(e){const t=this.serviceRegistry.all.flatMap((e=>e.LanguageMetaData.fileExtensions)),n=[],r=e=>{n.push(e),this.langiumDocuments.hasDocument(e.uri)||this.langiumDocuments.addDocument(e)};return await this.loadAdditionalDocuments(e,r),await Promise.all(e.map((e=>[e,this.getRootFolder(e)])).map((async e=>this.traverseFolder(...e,t,r)))),this._ready.resolve(),n}loadAdditionalDocuments(e,t){return Promise.resolve()}getRootFolder(e){return Mo.parse(e.uri)}async traverseFolder(e,t,n,r){const i=await this.fileSystemProvider.readDirectory(t);await Promise.all(i.map((async t=>{if(this.includeEntry(e,t,n))if(t.isDirectory)await this.traverseFolder(e,t.uri,n,r);else if(t.isFile){const e=await this.langiumDocuments.getOrCreateDocument(t.uri);r(e)}})))}includeEntry(e,t,n){const r=Uo.basename(t.uri);if(r.startsWith("."))return!1;if(t.isDirectory)return"node_modules"!==r&&"out"!==r;if(t.isFile){const e=Uo.extname(t.uri);return n.includes(e)}return!1}}class Ac{constructor(e){const t=e.parser.TokenBuilder.buildTokens(e.Grammar,{caseInsensitive:e.LanguageMetaData.caseInsensitive});this.tokenTypes=this.toTokenTypeDictionary(t);const n=Sc(t)?Object.values(t):t;this.chevrotainLexer=new pi(n,{positionTracking:"full"})}get definition(){return this.tokenTypes}tokenize(e){var t;const n=this.chevrotainLexer.tokenize(e);return{tokens:n.tokens,errors:n.errors,hidden:null!==(t=n.groups.hidden)&&void 0!==t?t:[]}}toTokenTypeDictionary(e){if(Sc(e))return e;const t=kc(e)?Object.values(e.modes).flat():e,n={};return t.forEach((e=>n[e.name]=e)),n}}function kc(e){return e&&"modes"in e&&"defaultMode"in e}function Sc(e){return!function(e){return Array.isArray(e)&&(0===e.length||"name"in e[0])}(e)&&!kc(e)}function Ic(e,t,n){let r,i;"string"==typeof e?(i=t,r=n):(i=e.range.start,r=t),i||(i=B.create(0,0));const s=function(e){var t,n,r;const i=[];let s=e.position.line,a=e.position.character;for(let o=0;o<e.lines.length;o++){const c=0===o,l=o===e.lines.length-1;let u=e.lines[o],h=0;if(c&&e.options.start){const n=null===(t=e.options.start)||void 0===t?void 0:t.exec(u);n&&(h=n.index+n[0].length)}else{const t=null===(n=e.options.line)||void 0===n?void 0:n.exec(u);t&&(h=t.index+t[0].length)}if(l){const t=null===(r=e.options.end)||void 0===r?void 0:r.exec(u);t&&(u=u.substring(0,t.index))}u=u.substring(0,_c(u));if(Oc(u,h)>=u.length){if(i.length>0){const e=B.create(s,a);i.push({type:"break",content:"",range:j.create(e,e)})}}else{Nc.lastIndex=h;const e=Nc.exec(u);if(e){const t=e[0],n=e[1],r=B.create(s,a+h),o=B.create(s,a+h+t.length);i.push({type:"tag",content:n,range:j.create(r,o)}),h+=t.length,h=Oc(u,h)}if(h<u.length){const e=u.substring(h),t=Array.from(e.matchAll($c));i.push(...Cc(t,e,s,a+h))}}s++,a=0}if(i.length>0&&"break"===i[i.length-1].type)return i.slice(0,-1);return i}({lines:xc(e),position:i,options:Fc(r)});return function(e){var t,n,r,i;const s=B.create(e.position.line,e.position.character);if(0===e.tokens.length)return new Bc([],j.create(s,s));const a=[];for(;e.index<e.tokens.length;){const t=bc(e,a[a.length-1]);t&&a.push(t)}const o=null!==(n=null===(t=a[0])||void 0===t?void 0:t.range.start)&&void 0!==n?n:s,c=null!==(i=null===(r=a[a.length-1])||void 0===r?void 0:r.range.end)&&void 0!==i?i:s;return new Bc(a,j.create(o,c))}({index:0,tokens:s,position:i})}function xc(e){let t="";t="string"==typeof e?e:e.text;return t.split(Cn)}const Nc=/\s*(@([\p{L}][\p{L}\p{N}]*)?)/uy,$c=/\{(@[\p{L}][\p{L}\p{N}]*)(\s*)([^\r\n}]+)?\}/gu;function Cc(e,t,n,r){const i=[];if(0===e.length){const e=B.create(n,r),s=B.create(n,r+t.length);i.push({type:"text",content:t,range:j.create(e,s)})}else{let s=0;for(const o of e){const e=o.index,a=t.substring(s,e);a.length>0&&i.push({type:"text",content:t.substring(s,e),range:j.create(B.create(n,s+r),B.create(n,e+r))});let c=a.length+1;const l=o[1];if(i.push({type:"inline-tag",content:l,range:j.create(B.create(n,s+c+r),B.create(n,s+c+l.length+r))}),c+=l.length,4===o.length){c+=o[2].length;const e=o[3];i.push({type:"text",content:e,range:j.create(B.create(n,s+c+r),B.create(n,s+c+e.length+r))})}else i.push({type:"text",content:"",range:j.create(B.create(n,s+c+r),B.create(n,s+c+r))});s=e+o[0].length}const a=t.substring(s);a.length>0&&i.push({type:"text",content:a,range:j.create(B.create(n,s+r),B.create(n,s+r+a.length))})}return i}const wc=/\S/,Lc=/\s*$/;function Oc(e,t){const n=e.substring(t).match(wc);return n?t+n.index:e.length}function _c(e){const t=e.match(Lc);if(t&&"number"==typeof t.index)return t.index}function bc(e,t){const n=e.tokens[e.index];return"tag"===n.type?Dc(e,!1):"text"===n.type||"inline-tag"===n.type?Pc(e):(function(e,t){if(t){const n=new Vc("",e.range);"inlines"in t?t.inlines.push(n):t.content.inlines.push(n)}}(n,t),void e.index++)}function Pc(e){let t=e.tokens[e.index];const n=t;let r=t;const i=[];for(;t&&"break"!==t.type&&"tag"!==t.type;)i.push(Mc(e)),r=t,t=e.tokens[e.index];return new jc(i,j.create(n.range.start,r.range.end))}function Mc(e){return"inline-tag"===e.tokens[e.index].type?Dc(e,!0):Uc(e)}function Dc(e,t){const n=e.tokens[e.index++],r=n.content.substring(1),i=e.tokens[e.index];if("text"===(null==i?void 0:i.type)){if(t){const i=Uc(e);return new Kc(r,new jc([i],i.range),t,j.create(n.range.start,i.range.end))}{const i=Pc(e);return new Kc(r,i,t,j.create(n.range.start,i.range.end))}}{const e=n.range;return new Kc(r,new jc([],e),t,e)}}function Uc(e){const t=e.tokens[e.index++];return new Vc(t.content,t.range)}function Fc(e){if(!e)return Fc({start:"/**",end:"*/",line:"*"});const{start:t,end:n,line:r}=e;return{start:Gc(t,!0),end:Gc(n,!1),line:Gc(r,!0)}}function Gc(e,t){if("string"==typeof e||"object"==typeof e){const n="string"==typeof e?bn(e):e.source;return t?new RegExp(`^\\s*${n}`):new RegExp(`\\s*${n}\\s*$`)}return e}class Bc{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(0===e.length)e=t.toString();else{const n=t.toString();e+=Hc(e)+n}return e.trim()}toMarkdown(e){let t="";for(const n of this.elements)if(0===t.length)t=n.toMarkdown(e);else{const r=n.toMarkdown(e);t+=Hc(t)+r}return t.trim()}}class Kc{constructor(e,t,n,r){this.name=e,this.content=t,this.inline=n,this.range=r}toString(){let e=`@${this.name}`;const t=this.content.toString();return 1===this.content.inlines.length?e=`${e} ${t}`:this.content.inlines.length>1&&(e=`${e}\n${t}`),this.inline?`{${e}}`:e}toMarkdown(e){var t,n;return null!==(n=null===(t=null==e?void 0:e.renderTag)||void 0===t?void 0:t.call(e,this))&&void 0!==n?n:this.toMarkdownDefault(e)}toMarkdownDefault(e){const t=this.content.toMarkdown(e);if(this.inline){const n=function(e,t,n){var r,i;if("linkplain"===e||"linkcode"===e||"link"===e){const s=t.indexOf(" ");let a=t;if(s>0){const e=Oc(t,s);a=t.substring(e),t=t.substring(0,s)}("linkcode"===e||"link"===e&&"code"===n.link)&&(a=`\`${a}\``);const o=null!==(i=null===(r=n.renderLink)||void 0===r?void 0:r.call(n,t,a))&&void 0!==i?i:function(e,t){try{return Mo.parse(e,!0),`[${t}](${e})`}catch(r){return e}}(t,a);return o}return}(this.name,t,null!=e?e:{});if("string"==typeof n)return n}let n="";"italic"===(null==e?void 0:e.tag)||void 0===(null==e?void 0:e.tag)?n="*":"bold"===(null==e?void 0:e.tag)?n="**":"bold-italic"===(null==e?void 0:e.tag)&&(n="***");let r=`${n}@${this.name}${n}`;return 1===this.content.inlines.length?r=`${r} — ${t}`:this.content.inlines.length>1&&(r=`${r}\n${t}`),this.inline?`{${r}}`:r}}class jc{constructor(e,t){this.inlines=e,this.range=t}toString(){let e="";for(let t=0;t<this.inlines.length;t++){const n=this.inlines[t],r=this.inlines[t+1];e+=n.toString(),r&&r.range.start.line>n.range.start.line&&(e+="\n")}return e}toMarkdown(e){let t="";for(let n=0;n<this.inlines.length;n++){const r=this.inlines[n],i=this.inlines[n+1];t+=r.toMarkdown(e),i&&i.range.start.line>r.range.start.line&&(t+="\n")}return t}}class Vc{constructor(e,t){this.text=e,this.range=t}toString(){return this.text}toMarkdown(){return this.text}}function Hc(e){return e.endsWith("\n")?"\n":"\n\n"}class Wc{constructor(e){this.indexManager=e.shared.workspace.IndexManager,this.commentProvider=e.documentation.CommentProvider}getDocumentation(e){const t=this.commentProvider.getComment(e);if(t&&function(e,t){const n=Fc(t),r=xc(e);if(0===r.length)return!1;const i=r[0],s=r[r.length-1],a=n.start,o=n.end;return Boolean(null==a?void 0:a.exec(i))&&Boolean(null==o?void 0:o.exec(s))}(t)){return Ic(t).toMarkdown({renderLink:(t,n)=>this.documentationLinkRenderer(e,t,n),renderTag:t=>this.documentationTagRenderer(e,t)})}}documentationLinkRenderer(e,t,n){var r;const i=null!==(r=this.findNameInPrecomputedScopes(e,t))&&void 0!==r?r:this.findNameInGlobalScope(e,t);if(i&&i.nameSegment){const e=i.nameSegment.range.start.line+1,t=i.nameSegment.range.start.character+1;return`[${n}](${i.documentUri.with({fragment:`L${e},${t}`}).toString()})`}}documentationTagRenderer(e,t){}findNameInPrecomputedScopes(e,t){const n=ln(e).precomputedScopes;if(!n)return;let r=e;do{const e=n.get(r).find((e=>e.name===t));if(e)return e;r=r.$container}while(r)}findNameInGlobalScope(e,t){return this.indexManager.allElements().find((e=>e.name===t))}}class zc{constructor(e){this.grammarConfig=()=>e.parser.GrammarConfig}getComment(e){var t;return function(e){return"string"==typeof e.$comment}(e)?e.$comment:null===(t=function(e,t){if(e){const n=function(e,t=!0){for(;e.container;){const n=e.container;let r=n.content.indexOf(e);for(;r>0;){r--;const e=n.content[r];if(t||!e.hidden)return e}e=n}}(e,!0);if(n&&ut(n,t))return n;if(ze(e))for(let r=e.content.findIndex((e=>!e.hidden))-1;r>=0;r--){const n=e.content[r];if(ut(n,t))return n}}}(e.$cstNode,this.grammarConfig().multilineCommentRules))||void 0===t?void 0:t.text}}V();class Yc{constructor(e){this.syncParser=e.parser.LangiumParser}parse(e){return Promise.resolve(this.syncParser.parse(e))}}class qc{constructor(){this.previousTokenSource=new Eo.CancellationTokenSource,this.writeQueue=[],this.readQueue=[],this.done=!0}write(e){this.cancelWrite();const t=new Eo.CancellationTokenSource;return this.previousTokenSource=t,this.enqueue(this.writeQueue,e,t.token)}read(e){return this.enqueue(this.readQueue,e)}enqueue(e,t,n){const r=new xo,i={action:t,deferred:r,cancellationToken:null!=n?n:Eo.CancellationToken.None};return e.push(i),this.performNextOperation(),r.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))return;e.push(...this.readQueue.splice(0,this.readQueue.length))}this.done=!1,await Promise.all(e.map((async({action:e,deferred:t,cancellationToken:n})=>{try{const r=await Promise.resolve().then((()=>e(n)));t.resolve(r)}catch(r){So(r)?t.resolve(void 0):t.reject(r)}}))),this.done=!0,this.performNextOperation()}cancelWrite(){this.previousTokenSource.cancel()}}class Xc{constructor(e){this.grammarElementIdMap=new Jo,this.tokenTypeIdMap=new Jo,this.grammar=e.Grammar,this.lexer=e.parser.Lexer,this.linker=e.references.Linker}dehydrate(e){return{lexerErrors:e.lexerErrors.map((e=>Object.assign({},e))),parserErrors:e.parserErrors.map((e=>Object.assign({},e))),value:this.dehydrateAstNode(e.value,this.createDehyrationContext(e.value))}}createDehyrationContext(e){const t=new Map,n=new Map;for(const r of dn(e))t.set(r,{});if(e.$cstNode)for(const r of st(e.$cstNode))n.set(r,{});return{astNodes:t,cstNodes:n}}dehydrateAstNode(e,t){const n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,void 0!==e.$cstNode&&(n.$cstNode=this.dehydrateCstNode(e.$cstNode,t));for(const[r,i]of Object.entries(e))if(!r.startsWith("$"))if(Array.isArray(i)){const e=[];n[r]=e;for(const n of i)Be(n)?e.push(this.dehydrateAstNode(n,t)):Ke(n)?e.push(this.dehydrateReference(n,t)):e.push(n)}else Be(i)?n[r]=this.dehydrateAstNode(i,t):Ke(i)?n[r]=this.dehydrateReference(i,t):void 0!==i&&(n[r]=i);return n}dehydrateReference(e,t){const n={};return n.$refText=e.$refText,e.$refNode&&(n.$refNode=t.cstNodes.get(e.$refNode)),n}dehydrateCstNode(e,t){const n=t.cstNodes.get(e);return ze(e)?n.fullText=e.fullText:n.grammarSource=this.getGrammarElementId(e.grammarSource),n.hidden=e.hidden,n.astNode=t.astNodes.get(e.astNode),He(e)?n.content=e.content.map((e=>this.dehydrateCstNode(e,t))):We(e)&&(n.tokenType=e.tokenType.name,n.offset=e.offset,n.length=e.length,n.startLine=e.range.start.line,n.startColumn=e.range.start.character,n.endLine=e.range.end.line,n.endColumn=e.range.end.character),n}hydrate(e){const t=e.value,n=this.createHydrationContext(t);return"$cstNode"in t&&this.hydrateCstNode(t.$cstNode,n),{lexerErrors:e.lexerErrors,parserErrors:e.parserErrors,value:this.hydrateAstNode(t,n)}}createHydrationContext(e){const t=new Map,n=new Map;for(const i of dn(e))t.set(i,{});let r;if(e.$cstNode)for(const i of st(e.$cstNode)){let e;"fullText"in i?(e=new Qa(i.fullText),r=e):"content"in i?e=new qa:"tokenType"in i&&(e=this.hydrateCstLeafNode(i)),e&&(n.set(i,e),e.root=r)}return{astNodes:t,cstNodes:n}}hydrateAstNode(e,t){const n=t.astNodes.get(e);n.$type=e.$type,n.$containerIndex=e.$containerIndex,n.$containerProperty=e.$containerProperty,e.$cstNode&&(n.$cstNode=t.cstNodes.get(e.$cstNode));for(const[r,i]of Object.entries(e))if(!r.startsWith("$"))if(Array.isArray(i)){const e=[];n[r]=e;for(const s of i)Be(s)?e.push(this.setParent(this.hydrateAstNode(s,t),n)):Ke(s)?e.push(this.hydrateReference(s,n,r,t)):e.push(s)}else Be(i)?n[r]=this.setParent(this.hydrateAstNode(i,t),n):Ke(i)?n[r]=this.hydrateReference(i,n,r,t):void 0!==i&&(n[r]=i);return n}setParent(e,t){return e.$container=t,e}hydrateReference(e,t,n,r){return this.linker.buildReference(t,n,r.cstNodes.get(e.$refNode),e.$refText)}hydrateCstNode(e,t,n=0){const r=t.cstNodes.get(e);if("number"==typeof e.grammarSource&&(r.grammarSource=this.getGrammarElement(e.grammarSource)),r.astNode=t.astNodes.get(e.astNode),He(r))for(const i of e.content){const e=this.hydrateCstNode(i,t,n++);r.content.push(e)}return r}hydrateCstLeafNode(e){const t=this.getTokenType(e.tokenType),n=e.offset,r=e.length,i=e.startLine,s=e.startColumn,a=e.endLine,o=e.endColumn,c=e.hidden;return new Ya(n,r,{start:{line:i,character:s},end:{line:a,character:o}},t,c)}getTokenType(e){return this.lexer.definition[e]}getGrammarElementId(e){return 0===this.grammarElementIdMap.size&&this.createGrammarElementIdMap(),this.grammarElementIdMap.get(e)}getGrammarElement(e){0===this.grammarElementIdMap.size&&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 n of dn(this.grammar))t=n,on.isInstance(t,yt)&&this.grammarElementIdMap.set(n,e++);var t}}function Qc(e){return{documentation:{CommentProvider:e=>new zc(e),DocumentationProvider:e=>new Wc(e)},parser:{AsyncParser:e=>new Yc(e),GrammarConfig:e=>function(e){const t=[],n=e.Grammar;for(const i of n.rules)Lt(i)&&(r=i).hidden&&!zn(r).test(" ")&&On(zn(i))&&t.push(i.name);var r;return{multilineCommentRules:t,nameRegexp:lt}}(e),LangiumParser:e=>yo(e),CompletionParser:e=>function(e){const t=e.Grammar,n=e.parser.Lexer,r=new so(e);return co(t,r,n.definition),r.finalize(),r}(e),ValueConverter:()=>new vo,TokenBuilder:()=>new To,Lexer:e=>new Ac(e),ParserErrorMessageProvider:()=>new io},workspace:{AstNodeLocator:()=>new yc,AstNodeDescriptionProvider:e=>new mc(e),ReferenceDescriptionProvider:e=>new gc(e)},references:{Linker:e=>new Yo(e),NameProvider:()=>new qo,ScopeProvider:e=>new ac(e),ScopeComputation:e=>new Zo(e),References:e=>new Xo(e)},serializer:{Hydrator:e=>new Xc(e),JsonSerializer:e=>new cc(e)},validation:{DocumentValidator:e=>new dc(e),ValidationRegistry:e=>new hc(e)},shared:()=>e.shared}}function Jc(e){return{ServiceRegistry:()=>new lc,workspace:{LangiumDocuments:e=>new zo(e),LangiumDocumentFactory:e=>new Wo(e),DocumentBuilder:e=>new vc(e),IndexManager:e=>new Rc(e),WorkspaceManager:e=>new Ec(e),FileSystemProvider:t=>e.fileSystemProvider(t),WorkspaceLock:()=>new qc,ConfigurationProvider:e=>new Tc(e)}}}var Zc;function el(e,t,n,r,i,s,a,o,c){return nl([e,t,n,r,i,s,a,o,c].reduce(sl,{}))}(Zc||(Zc={})).merge=(e,t)=>sl(sl({},e),t);const tl=Symbol("isProxy");function nl(e,t){const n=new Proxy({},{deleteProperty:()=>!1,get:(r,i)=>il(r,i,e,t||n),getOwnPropertyDescriptor:(r,i)=>(il(r,i,e,t||n),Object.getOwnPropertyDescriptor(r,i)),has:(t,n)=>n in e,ownKeys:()=>[...Reflect.ownKeys(e),tl]});return n[tl]=!0,n}const rl=Symbol();function il(e,t,n,r){if(t in e){if(e[t]instanceof Error)throw new Error("Construction failure. Please make sure that your dependencies are constructable.",{cause:e[t]});if(e[t]===rl)throw new Error('Cycle detected. Please make "'+String(t)+'" lazy. See https://langium.org/docs/configuration-services/#resolving-cyclic-dependencies');return e[t]}if(t in n){const s=n[t];e[t]=rl;try{e[t]="function"==typeof s?s(r):nl(s,r)}catch(i){throw e[t]=i instanceof Error?i:void 0,i}return e[t]}}function sl(e,t){if(t)for(const[n,r]of Object.entries(t))if(void 0!==r){const t=e[n];e[n]=null!==t&&null!==r&&"object"==typeof t&&"object"==typeof r?sl(t,r):r}return e}class al{readFile(){throw new Error("No file system is available.")}async readDirectory(){return[]}}const ol={fileSystemProvider:()=>new al},cl={Grammar:()=>{},LanguageMetaData:()=>({caseInsensitive:!1,fileExtensions:[".langium"],languageId:"langium"})},ll={AstReflection:()=>new an};function ul(e){var t;const n=function(){const e=el(Jc(ol),ll),t=el(Qc({shared:e}),cl);return e.ServiceRegistry.register(t),t}(),r=n.serializer.JsonSerializer.deserialize(e);return n.shared.workspace.LangiumDocumentFactory.fromModel(r,Mo.parse(`memory://${null!==(t=r.name)&&void 0!==t?t:"grammar"}.langium`)),r}var hl=Object.defineProperty,dl=(e,t)=>hl(e,"name",{value:t,configurable:!0});dl((function(e){return kl.isInstance(e,"Architecture")}),"isArchitecture");var fl="Branch";dl((function(e){return kl.isInstance(e,fl)}),"isBranch");var pl="Commit";dl((function(e){return kl.isInstance(e,pl)}),"isCommit");dl((function(e){return kl.isInstance(e,"Common")}),"isCommon");var ml="GitGraph";dl((function(e){return kl.isInstance(e,ml)}),"isGitGraph");dl((function(e){return kl.isInstance(e,"Info")}),"isInfo");var gl="Merge";dl((function(e){return kl.isInstance(e,gl)}),"isMerge");dl((function(e){return kl.isInstance(e,"Packet")}),"isPacket");dl((function(e){return kl.isInstance(e,"PacketBlock")}),"isPacketBlock");dl((function(e){return kl.isInstance(e,"Pie")}),"isPie");dl((function(e){return kl.isInstance(e,"PieSection")}),"isPieSection");var yl,Tl,vl,Rl,El,Al=(dl(e=class extends Ve{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 fl:case"Checkout":case"CherryPicking":case pl:case gl:return this.isSubtype("Statement",t);case"Direction":return this.isSubtype(ml,t);default:return!1}}getReferenceType(e){const t=`${e.container.$type}:${e.property}`;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:[]}}}},"MermaidAstReflection"),e),kl=new Al,Sl=dl((()=>yl??(yl=ul('{"$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"),Il=dl((()=>Tl??(Tl=ul('{"$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"),xl=dl((()=>vl??(vl=ul('{"$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"),Nl=dl((()=>Rl??(Rl=ul('{"$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"),$l=dl((()=>El??(El=ul('{"$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"),Cl={languageId:"info",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},wl={languageId:"packet",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Ll={languageId:"pie",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},Ol={languageId:"architecture",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},_l={languageId:"gitGraph",fileExtensions:[".mmd",".mermaid"],caseInsensitive:!1},bl={AstReflection:dl((()=>new Al),"AstReflection")},Pl={Grammar:dl((()=>Sl()),"Grammar"),LanguageMetaData:dl((()=>Cl),"LanguageMetaData"),parser:{}},Ml={Grammar:dl((()=>Il()),"Grammar"),LanguageMetaData:dl((()=>wl),"LanguageMetaData"),parser:{}},Dl={Grammar:dl((()=>xl()),"Grammar"),LanguageMetaData:dl((()=>Ll),"LanguageMetaData"),parser:{}},Ul={Grammar:dl((()=>Nl()),"Grammar"),LanguageMetaData:dl((()=>Ol),"LanguageMetaData"),parser:{}},Fl={Grammar:dl((()=>$l()),"Grammar"),LanguageMetaData:dl((()=>_l),"LanguageMetaData"),parser:{}},Gl={ACC_DESCR:/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,ACC_TITLE:/accTitle[\t ]*:([^\n\r]*)/,TITLE:/title([\t ][^\n\r]*|)/},Bl=(dl(t=class extends vo{runConverter(e,t,n){let r=this.runCommonConverter(e,t,n);return void 0===r&&(r=this.runCustomConverter(e,t,n)),void 0===r?super.runConverter(e,t,n):r}runCommonConverter(e,t,n){const r=Gl[e.name];if(void 0===r)return;const i=r.exec(t);return null!==i?void 0!==i[1]?i[1].trim().replace(/[\t ]{2,}/gm," "):void 0!==i[2]?i[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,"\n"):void 0:void 0}},"AbstractMermaidValueConverter"),t),Kl=(dl(n=class extends Bl{runCustomConverter(e,t,n){}},"CommonValueConverter"),n),jl=(dl(r=class extends To{constructor(e){super(),this.keywords=new Set(e)}buildKeywordTokens(e,t,n){const r=super.buildKeywordTokens(e,t,n);return r.forEach((e=>{this.keywords.has(e.name)&&void 0!==e.PATTERN&&(e.PATTERN=new RegExp(e.PATTERN.toString()+"(?:(?=%%)|(?!\\S))"))})),r}},"AbstractMermaidTokenBuilder"),r);dl(class extends jl{},"CommonTokenBuilder");var Vl=(dl(i=class extends jl{constructor(){super(["gitGraph"])}},"GitGraphTokenBuilder"),i),Hl={parser:{TokenBuilder:dl((()=>new Vl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function Wl(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Fl,Hl);return t.ServiceRegistry.register(n),{shared:t,GitGraph:n}}dl(Wl,"createGitGraphServices");var zl=(dl(s=class extends jl{constructor(){super(["info","showInfo"])}},"InfoTokenBuilder"),s),Yl={parser:{TokenBuilder:dl((()=>new zl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function ql(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Pl,Yl);return t.ServiceRegistry.register(n),{shared:t,Info:n}}dl(ql,"createInfoServices");var Xl=(dl(a=class extends jl{constructor(){super(["packet-beta"])}},"PacketTokenBuilder"),a),Ql={parser:{TokenBuilder:dl((()=>new Xl),"TokenBuilder"),ValueConverter:dl((()=>new Kl),"ValueConverter")}};function Jl(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Ml,Ql);return t.ServiceRegistry.register(n),{shared:t,Packet:n}}dl(Jl,"createPacketServices");var Zl=(dl(o=class extends jl{constructor(){super(["pie","showData"])}},"PieTokenBuilder"),o),eu=(dl(c=class extends Bl{runCustomConverter(e,t,n){if("PIE_SECTION_LABEL"===e.name)return t.replace(/"/g,"").trim()}},"PieValueConverter"),c),tu={parser:{TokenBuilder:dl((()=>new Zl),"TokenBuilder"),ValueConverter:dl((()=>new eu),"ValueConverter")}};function nu(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Dl,tu);return t.ServiceRegistry.register(n),{shared:t,Pie:n}}dl(nu,"createPieServices");var ru=(dl(l=class extends jl{constructor(){super(["architecture"])}},"ArchitectureTokenBuilder"),l),iu=(dl(u=class extends Bl{runCustomConverter(e,t,n){return"ARCH_ICON"===e.name?t.replace(/[()]/g,"").trim():"ARCH_TEXT_ICON"===e.name?t.replace(/["()]/g,""):"ARCH_TITLE"===e.name?t.replace(/[[\]]/g,"").trim():void 0}},"ArchitectureValueConverter"),u),su={parser:{TokenBuilder:dl((()=>new ru),"TokenBuilder"),ValueConverter:dl((()=>new iu),"ValueConverter")}};function au(e=ol){const t=el(Jc(e),bl),n=el(Qc({shared:t}),Ul,su);return t.ServiceRegistry.register(n),{shared:t,Architecture:n}}dl(au,"createArchitectureServices");var ou={},cu={info:dl((async()=>{const{createInfoServices:e}=await H((async()=>{const{createInfoServices:e}=await Promise.resolve().then((()=>hu));return{createInfoServices:e}}),void 0,import.meta.url),t=e().Info.parser.LangiumParser;ou.info=t}),"info"),packet:dl((async()=>{const{createPacketServices:e}=await H((async()=>{const{createPacketServices:e}=await Promise.resolve().then((()=>du));return{createPacketServices:e}}),void 0,import.meta.url),t=e().Packet.parser.LangiumParser;ou.packet=t}),"packet"),pie:dl((async()=>{const{createPieServices:e}=await H((async()=>{const{createPieServices:e}=await Promise.resolve().then((()=>fu));return{createPieServices:e}}),void 0,import.meta.url),t=e().Pie.parser.LangiumParser;ou.pie=t}),"pie"),architecture:dl((async()=>{const{createArchitectureServices:e}=await H((async()=>{const{createArchitectureServices:e}=await Promise.resolve().then((()=>pu));return{createArchitectureServices:e}}),void 0,import.meta.url),t=e().Architecture.parser.LangiumParser;ou.architecture=t}),"architecture"),gitGraph:dl((async()=>{const{createGitGraphServices:e}=await H((async()=>{const{createGitGraphServices:e}=await Promise.resolve().then((()=>mu));return{createGitGraphServices:e}}),void 0,import.meta.url),t=e().GitGraph.parser.LangiumParser;ou.gitGraph=t}),"gitGraph")};async function lu(e,t){const n=cu[e];if(!n)throw new Error(`Unknown diagram type: ${e}`);ou[e]||await n();const r=ou[e].parse(t);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new uu(r);return r.value}dl(lu,"parse");var uu=(dl(h=class extends Error{constructor(e){super(`Parsing failed: ${e.lexerErrors.map((e=>e.message)).join("\n")} ${e.parserErrors.map((e=>e.message)).join("\n")}`),this.result=e}},"MermaidParseError"),h);const hu=Object.freeze(Object.defineProperty({__proto__:null,InfoModule:Yl,createInfoServices:ql},Symbol.toStringTag,{value:"Module"})),du=Object.freeze(Object.defineProperty({__proto__:null,PacketModule:Ql,createPacketServices:Jl},Symbol.toStringTag,{value:"Module"})),fu=Object.freeze(Object.defineProperty({__proto__:null,PieModule:tu,createPieServices:nu},Symbol.toStringTag,{value:"Module"})),pu=Object.freeze(Object.defineProperty({__proto__:null,ArchitectureModule:su,createArchitectureServices:au},Symbol.toStringTag,{value:"Module"})),mu=Object.freeze(Object.defineProperty({__proto__:null,GitGraphModule:Hl,createGitGraphServices:Wl},Symbol.toStringTag,{value:"Module"}));export{lu as p};