project-athena 0.1.0

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +247 -0
  3. package/dist/cli.js +8614 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/web/assets/Editor-DmFaONG7.js +39 -0
  6. package/dist/web/assets/_basePickBy-QJXUw_pr.js +1 -0
  7. package/dist/web/assets/_baseUniq-DR4vVjyC.js +1 -0
  8. package/dist/web/assets/abnfDiagram-O67JEVCF-BEaDGLKl.js +1 -0
  9. package/dist/web/assets/arc-DgcGdgmL.js +1 -0
  10. package/dist/web/assets/architecture-7GRP2DOG-CHNxu4zI.js +1 -0
  11. package/dist/web/assets/architectureDiagram-NJMV4G6O-Cr_YqU4C.js +36 -0
  12. package/dist/web/assets/array-BifhSqXX.js +1 -0
  13. package/dist/web/assets/blockDiagram-BEXU5L5S-NA64lNxM.js +140 -0
  14. package/dist/web/assets/c4Diagram-YGBWAQC7-C9OZTI8T.js +38 -0
  15. package/dist/web/assets/channel-D_T5GGJX.js +1 -0
  16. package/dist/web/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  17. package/dist/web/assets/chunk-3FUC2YCW-PivwegVV.js +2 -0
  18. package/dist/web/assets/chunk-5DYCD2WN-DH_dVKgx.js +1 -0
  19. package/dist/web/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  20. package/dist/web/assets/chunk-742MDFTN-DTR6iTOw.js +1 -0
  21. package/dist/web/assets/chunk-7INBJB4K-XeJOzIDQ.js +62 -0
  22. package/dist/web/assets/chunk-7M6MHVWA-Bn-cXg0l.js +213 -0
  23. package/dist/web/assets/chunk-7PRAP22T-CPe5zfLc.js +1 -0
  24. package/dist/web/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  25. package/dist/web/assets/chunk-FOHPRMQF-DzxwRta7.js +161 -0
  26. package/dist/web/assets/chunk-GTNCS2PH-DSn-mpqy.js +88 -0
  27. package/dist/web/assets/chunk-GWA4HPMP-DE4DJkth.js +1 -0
  28. package/dist/web/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  29. package/dist/web/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  30. package/dist/web/assets/chunk-MBY4JIJT-9uaOqseW.js +72 -0
  31. package/dist/web/assets/chunk-NETBCI7D-bxqe7jPe.js +1 -0
  32. package/dist/web/assets/chunk-O7XYJQB3-CjZQSnt8.js +126 -0
  33. package/dist/web/assets/chunk-UA2S7LBM-BfYbPxwY.js +1 -0
  34. package/dist/web/assets/chunk-WEXAMYUT-CT8bG5L7.js +1 -0
  35. package/dist/web/assets/chunk-XXDRQBXY-BvKO0v-W.js +1 -0
  36. package/dist/web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  37. package/dist/web/assets/chunk-Z7XXMR3K-CHWuLoFG.js +10 -0
  38. package/dist/web/assets/chunk-ZIGJFQKS-C6SOqBs6.js +2 -0
  39. package/dist/web/assets/classDiagram-v2-NBCMYWYE-CrSxkUNF.js +217 -0
  40. package/dist/web/assets/cose-bilkent-JH36ORCC-COXSdE6a.js +1 -0
  41. package/dist/web/assets/cynefin-OW5HDTMX-CMbTYwga.js +1 -0
  42. package/dist/web/assets/cynefinDiagram-VND7K2PF-B8wb03CF.js +62 -0
  43. package/dist/web/assets/cytoscape.esm-Yq6u8L66.js +321 -0
  44. package/dist/web/assets/dagre-6A5THRUB-Bz-BHtjW.js +4 -0
  45. package/dist/web/assets/defaultLocale-BFoDCU3G.js +1 -0
  46. package/dist/web/assets/diagram-22UHCM2B-C9M-mcex.js +200 -0
  47. package/dist/web/assets/diagram-3UASUU5V-q18RgATq.js +24 -0
  48. package/dist/web/assets/diagram-ATOU4E4O-zywdDXPc.js +3 -0
  49. package/dist/web/assets/diagram-CDSNMT55-BGMdofKO.js +30 -0
  50. package/dist/web/assets/diagram-MLGK6HIB-BdT0J6Xl.js +24 -0
  51. package/dist/web/assets/diagram-MPIPVDR6-BXdFmdOp.js +41 -0
  52. package/dist/web/assets/dist-B_J_HbC0.js +1 -0
  53. package/dist/web/assets/ebnfDiagram-ZINNZB2B-B7Mz8zd0.js +1 -0
  54. package/dist/web/assets/elk-276RUBZZ-CQ4lVw-r.js +27 -0
  55. package/dist/web/assets/erDiagram-OPXOYQCR-DmmZBLvC.js +99 -0
  56. package/dist/web/assets/eventmodeling-NTZA5JFV-BgPhBkRf.js +1 -0
  57. package/dist/web/assets/flowDiagram-KWPJA3E3-C3wNriu7.js +1 -0
  58. package/dist/web/assets/ganttDiagram-FUAMR5RP-B0egPzgH.js +292 -0
  59. package/dist/web/assets/gitGraph-4MIJSDKK-BdShI4JY.js +1 -0
  60. package/dist/web/assets/gitGraphDiagram-X574FWY7-jwG6nUmP.js +106 -0
  61. package/dist/web/assets/graphlib-C9Tl7QrK.js +1 -0
  62. package/dist/web/assets/index-BSiW3yI1.js +45 -0
  63. package/dist/web/assets/index-DKE3ojTe.css +1 -0
  64. package/dist/web/assets/info-A6RAGUB7-Hm3KO-lX.js +1 -0
  65. package/dist/web/assets/infoDiagram-VRGFBTTK-CdcggvNW.js +2 -0
  66. package/dist/web/assets/init-C-OQMol4.js +1 -0
  67. package/dist/web/assets/ishikawaDiagram-OU5B5YK6-C8x3tV6X.js +70 -0
  68. package/dist/web/assets/journeyDiagram-ZHPQQLJL-CLXIkiwl.js +139 -0
  69. package/dist/web/assets/kanban-definition-PNTS6WVX-P94klDAy.js +89 -0
  70. package/dist/web/assets/katex-ZlcWpGUi.js +257 -0
  71. package/dist/web/assets/line-DtGZCXZs.js +1 -0
  72. package/dist/web/assets/linear-BUnzfXgk.js +1 -0
  73. package/dist/web/assets/mermaid-parser.core-Du2mcMMx.js +7 -0
  74. package/dist/web/assets/mermaid.core-B4zgSyXF.js +44 -0
  75. package/dist/web/assets/mindmap-definition-NLK3R4M7-C0EF7lWr.js +96 -0
  76. package/dist/web/assets/ordinal-BDEzSJ7C.js +1 -0
  77. package/dist/web/assets/packet-AYTQ26CC-SJ1tKR5t.js +1 -0
  78. package/dist/web/assets/path-fybaL0A-.js +1 -0
  79. package/dist/web/assets/pegDiagram-GJSIUBJH-Dek_S7Z0.js +1 -0
  80. package/dist/web/assets/pie-WAS4IAKB-C0wgWLu4.js +1 -0
  81. package/dist/web/assets/pieDiagram-5QR66LMP-Dy1jV_P-.js +39 -0
  82. package/dist/web/assets/quadrantDiagram-O4NWA36T-Df6Jl4OG.js +7 -0
  83. package/dist/web/assets/radar-RG4KPBEZ-BCtk017a.js +1 -0
  84. package/dist/web/assets/railroad-74A4TZTK-_ZAooQok.js +1 -0
  85. package/dist/web/assets/railroad-abnf-HS5TGJTU-Bacbbg7g.js +1 -0
  86. package/dist/web/assets/railroad-ebnf-LZEXJU2U-Cb23oOsU.js +1 -0
  87. package/dist/web/assets/railroad-peg-WCYAUIDC-EPh5LyCw.js +1 -0
  88. package/dist/web/assets/railroadDiagram-XR7U4H2S-DNraioKj.js +1 -0
  89. package/dist/web/assets/requirementDiagram-PLB6GJNP-C09s8xl6.js +84 -0
  90. package/dist/web/assets/rolldown-runtime-Dd_uD5pT.js +1 -0
  91. package/dist/web/assets/rough.esm-Dy-Kn_BL.js +1 -0
  92. package/dist/web/assets/sankeyDiagram-IPEJSGJF-cwVwdash.js +40 -0
  93. package/dist/web/assets/sequenceDiagram-PO4LG4MO-Uz6m2m-d.js +169 -0
  94. package/dist/web/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  95. package/dist/web/assets/src-oBChb5qS.js +1 -0
  96. package/dist/web/assets/stateDiagram-v2-GCMORJYK-DASY_MN7.js +291 -0
  97. package/dist/web/assets/swimlanes-2SLR337P-DjbxDj0Z.js +1 -0
  98. package/dist/web/assets/swimlanesDiagram-TC7HE7FX-Bv90z5my.js +8 -0
  99. package/dist/web/assets/timeline-definition-EJHVYXUP-Dffxj5AG.js +120 -0
  100. package/dist/web/assets/treeView-Q6P3EWNA-CXAvuG6A.js +1 -0
  101. package/dist/web/assets/treemap-WGGIJYW6-D_BSE2GX.js +1 -0
  102. package/dist/web/assets/usecaseDiagram-POWQR4AR-CKcfbpDB.js +328 -0
  103. package/dist/web/assets/vennDiagram-UO4OBE2U-DkJknm_I.js +34 -0
  104. package/dist/web/assets/wardley-WFR3VGLG-Drx6WB-t.js +1 -0
  105. package/dist/web/assets/wardleyDiagram-VNRHLVJA-fdjd5am3.js +78 -0
  106. package/dist/web/assets/xychartDiagram-PMCCYNJV-DCWTWMv0.js +7 -0
  107. package/dist/web/favicon.svg +1 -0
  108. package/dist/web/index.html +17 -0
  109. package/package.json +77 -0
@@ -0,0 +1,328 @@
1
+ import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as t,p as n}from"./src-oBChb5qS.js";import{H as r,U as i,a,b as o,f as s,q as c,v as l,w as u,x as d,y as f,z as p}from"./chunk-O7XYJQB3-CjZQSnt8.js";import{g as m}from"./chunk-ZIGJFQKS-C6SOqBs6.js";import"./chunk-742MDFTN-DTR6iTOw.js";import{i as h}from"./chunk-MBY4JIJT-9uaOqseW.js";import"./chunk-7PRAP22T-CPe5zfLc.js";import{a as g,i as ee,o as te,r as _}from"./chunk-J5ZVWO5B-oDCd-gWO.js";import"./chunk-7INBJB4K-XeJOzIDQ.js";import"./chunk-5DYCD2WN-DH_dVKgx.js";import"./chunk-Z7XXMR3K-CHWuLoFG.js";import{A as ne,G as re,H as ie,I as ae,K as oe,O as se,Q as ce,V as le,Z as ue,a as v,at as y,b as de,c as b,ct as x,d as fe,dt as pe,f as me,ft as S,h as he,i as C,it as w,lt as ge,n as T,o as E,ot as _e,q as ve,r as ye,s as be,st as xe,t as Se,u as Ce,x as we,y as Te}from"./_baseUniq-DR4vVjyC.js";import{C as Ee,_ as De,b as Oe,c as ke,f as Ae,h as je,i as D,l as Me,n as O,o as Ne,r as k,s as Pe,t as Fe,v as Ie,x as Le,y as Re}from"./_basePickBy-QJXUw_pr.js";import{t as ze}from"./chunk-XXDRQBXY-BvKO0v-W.js";import{t as Be}from"./chunk-WEXAMYUT-CT8bG5L7.js";import"./chunk-UA2S7LBM-BfYbPxwY.js";import{i as Ve,r as He}from"./mermaid.core-B4zgSyXF.js";var Ue=Object.prototype.hasOwnProperty,A=De(function(e,t){if(re(t)||oe(t)){Re(t,ae(t),e);return}for(var n in t)Ue.call(t,n)&&Oe(e,n,t[n])});function We(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}var Ge=4;function j(e){return Me(e,Ge)}function Ke(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}function qe(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Je(e,t,n,r){return me(e,function(e,i,a){t(r,e,n(e),a)}),r}function Ye(e,t){return function(n,r){var i=x(n)?qe:Je,a=t?t():{};return i(n,e,he(r,2),a)}}var Xe=200;function Ze(e,t,n,r){var i=-1,a=ue,o=!0,s=e.length,c=[],l=t.length;if(!s)return c;n&&(t=ge(t,ie(n))),r?(a=Ce,o=!1):t.length>=Xe&&(a=Te,o=!1,t=new we(t));outer:for(;++i<s;){var u=e[i],d=n==null?u:n(u);if(u=r||u!==0?u:0,o&&d===d){for(var f=l;f--;)if(t[f]===d)continue outer;c.push(u)}else a(t,d,r)||c.push(u)}return c}var Qe=ve(function(e,t){return fe(e)?Ze(e,ne(t,1,fe,!0)):[]});function M(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:Ee(t),We(e,t<0?0:t,r)):[]}function $e(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:Ee(t),t=r-t,We(e,0,t<0?0:t)):[]}function et(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function tt(e,t){var n=!0;return me(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function nt(e,t,n){var r=x(e)?et:tt;return n&&Ie(e,t,n)&&(t=void 0),r(e,he(t,3))}function rt(e){return e&&e.length?e[0]:void 0}function N(e,t){return ne(D(e,t),1)}var it=Object.prototype.hasOwnProperty,at=Ye(function(e,t,n){it.call(e,n)?e[n].push(t):Le(e,n,[t])}),ot=Math.max;function P(e,t,n,r){e=oe(e)?e:v(e),n=n&&!r?Ee(n):0;var i=e.length;return n<0&&(n=ot(i+n,0)),O(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&ce(e,t,n)>-1}var st=Math.max;function ct(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:Ee(n);return i<0&&(i=st(r+i,0)),ce(e,t,i)}var lt=`[object RegExp]`;function ut(e){return pe(e)&&S(e)==lt}var dt=le&&le.isRegExp,ft=dt?ie(dt):ut,pt=`Expected a function`;function mt(e){if(typeof e!=`function`)throw TypeError(pt);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)}}function ht(e,t){if(e==null)return{};var n=ge(Ae(e),function(e){return[e]});return t=he(t),Fe(e,n,function(e,n){return t(e,n[0])})}function gt(e,t){return(x(e)?se:be)(e,mt(he(t,3)))}function _t(e,t){var n;return me(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function vt(e,t,n){var r=x(e)?de:_t;return n&&Ie(e,t,n)&&(t=void 0),r(e,he(t,3))}function yt(e){return e&&e.length?Se(e):[]}function bt(e){console&&console.error&&console.error(`Error: ${e}`)}function xt(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function St(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function Ct(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}function wt(e){return Tt(e)?e.LABEL:e.name}function Tt(e){return O(e.LABEL)&&e.LABEL!==``}var Et=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),b(this.definition,t=>{t.accept(e)})}},F=class extends Et{constructor(e){super([]),this.idx=1,A(this,ht(e,e=>e!==void 0))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},Dt=class extends Et{constructor(e){super(e.definition),this.orgText=``,A(this,ht(e,e=>e!==void 0))}},I=class extends Et{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,A(this,ht(e,e=>e!==void 0))}},L=class extends Et{constructor(e){super(e.definition),this.idx=1,A(this,ht(e,e=>e!==void 0))}},Ot=class extends Et{constructor(e){super(e.definition),this.idx=1,A(this,ht(e,e=>e!==void 0))}},kt=class extends Et{constructor(e){super(e.definition),this.idx=1,A(this,ht(e,e=>e!==void 0))}},R=class extends Et{constructor(e){super(e.definition),this.idx=1,A(this,ht(e,e=>e!==void 0))}},At=class extends Et{constructor(e){super(e.definition),this.idx=1,A(this,ht(e,e=>e!==void 0))}},jt=class extends Et{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,A(this,ht(e,e=>e!==void 0))}},z=class{constructor(e){this.idx=1,A(this,ht(e,e=>e!==void 0))}accept(e){e.visit(this)}};function Mt(e){return D(e,Nt)}function Nt(e){function t(e){return D(e,Nt)}if(e instanceof F){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return O(e.label)&&(t.label=e.label),t}if(e instanceof I)return{type:`Alternative`,definition:t(e.definition)};if(e instanceof L)return{type:`Option`,idx:e.idx,definition:t(e.definition)};if(e instanceof Ot)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};if(e instanceof kt)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:Nt(new z({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof At)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:Nt(new z({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof R)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};if(e instanceof jt)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};if(e instanceof z){let t={type:`Terminal`,name:e.terminalType.name,label:wt(e.terminalType),idx:e.idx};O(e.label)&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=ft(n)?n.source:n),t}if(e instanceof Dt)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error(`non exhaustive match`)}var Pt=class{visit(e){let t=e;switch(t.constructor){case F:return this.visitNonTerminal(t);case I:return this.visitAlternative(t);case L:return this.visitOption(t);case Ot:return this.visitRepetitionMandatory(t);case kt:return this.visitRepetitionMandatoryWithSeparator(t);case At:return this.visitRepetitionWithSeparator(t);case R:return this.visitRepetition(t);case jt:return this.visitAlternation(t);case z:return this.visitTerminal(t);case Dt: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 Ft(e){return e instanceof I||e instanceof L||e instanceof R||e instanceof Ot||e instanceof kt||e instanceof At||e instanceof z||e instanceof Dt}function It(e,t=[]){return e instanceof L||e instanceof R||e instanceof At?!0:e instanceof jt?vt(e.definition,e=>It(e,t)):e instanceof F&&P(t,e)?!1:e instanceof Et&&(e instanceof F&&t.push(e),nt(e.definition,e=>It(e,t)))}function Lt(e){return e instanceof jt}function Rt(e){if(e instanceof F)return`SUBRULE`;if(e instanceof L)return`OPTION`;if(e instanceof jt)return`OR`;if(e instanceof Ot)return`AT_LEAST_ONE`;if(e instanceof kt)return`AT_LEAST_ONE_SEP`;if(e instanceof At)return`MANY_SEP`;if(e instanceof R)return`MANY`;if(e instanceof z)return`CONSUME`;throw Error(`non exhaustive match`)}var zt=class{walk(e,t=[]){b(e.definition,(n,r)=>{let i=M(e.definition,r+1);if(n instanceof F)this.walkProdRef(n,i,t);else if(n instanceof z)this.walkTerminal(n,i,t);else if(n instanceof I)this.walkFlat(n,i,t);else if(n instanceof L)this.walkOption(n,i,t);else if(n instanceof Ot)this.walkAtLeastOne(n,i,t);else if(n instanceof kt)this.walkAtLeastOneSep(n,i,t);else if(n instanceof At)this.walkManySep(n,i,t);else if(n instanceof R)this.walkMany(n,i,t);else if(n instanceof jt)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new L({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=Bt(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new L({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=Bt(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);b(e.definition,e=>{let t=new I({definition:[e]});this.walk(t,r)})}};function Bt(e,t,n){return[new L({definition:[new z({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function Vt(e){if(e instanceof F)return Vt(e.referencedRule);if(e instanceof z)return Wt(e);if(Ft(e))return Ht(e);if(Lt(e))return Ut(e);throw Error(`non exhaustive match`)}function Ht(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=It(a),t=t.concat(Vt(a)),r+=1,i=n.length>r;return yt(t)}function Ut(e){let t=D(e.definition,e=>Vt(e));return yt(je(t))}function Wt(e){return[e.terminalType]}var Gt=`_~IN~_`,Kt=class extends zt{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=Jt(e.referencedRule,e.idx)+this.topProd.name,i=Vt(new I({definition:t.concat(n)}));this.follows[r]=i}};function qt(e){let t={};return b(e,e=>{let n=new Kt(e).startWalking();A(t,n)}),t}function Jt(e,t){return e.name+t+Gt}function B(e){return e.charCodeAt(0)}function Yt(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function Xt(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function Zt(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function Qt(){throw Error(`Internal Error - Should never get here!`)}function $t(e){return e.type===`Character`}var en=[];for(let e=B(`0`);e<=B(`9`);e++)en.push(e);var tn=[B(`_`)].concat(en);for(let e=B(`a`);e<=B(`z`);e++)tn.push(e);for(let e=B(`A`);e<=B(`Z`);e++)tn.push(e);var nn=[B(` `),B(`\f`),B(`
2
+ `),B(`\r`),B(` `),B(`\v`),B(` `),B(`\xA0`),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(` `),B(`\u2028`),B(`\u2029`),B(` `),B(` `),B(` `),B(``)],rn=/[0-9a-fA-F]/,an=/[0-9]/,on=/[1-9]/,sn=class{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(`/`);let t=this.disjunction();this.consumeChar(`/`);let 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`:Xt(n,`global`);break;case`i`:Xt(n,`ignoreCase`);break;case`m`:Xt(n,`multiLine`);break;case`u`:Xt(n,`unicode`);break;case`y`:Xt(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(){let 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(){let 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(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}}Zt(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return Qt()}quantifier(e=!1){let t,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`{`:let 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(e===!0&&t===void 0)return;Zt(t)}if((e!==!0||t!==void 0)&&Zt(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,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()}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Zt(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Qt()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[B(`
3
+ `),B(`\r`),B(`\u2028`),B(`\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=nn;break;case`S`:e=nn,t=!0;break;case`w`:e=tn;break;case`W`:e=tn,t=!0}return Zt(e)?{type:`Set`,value:e,complement:t}:Qt()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=B(`\f`);break;case`n`:e=B(`
4
+ `);break;case`r`:e=B(`\r`);break;case`t`:e=B(` `);break;case`v`:e=B(`\v`)}return Zt(e)?{type:`Character`,value:e}:Qt()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:B(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:B(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:B(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,$t(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,$t(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else Yt(t.value,e),e.push(B(`-`)),Yt(n.value,e)}else Yt(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){case`]`:case`
6
+ `: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:B(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(on.test(e)===!1)throw Error(`Expecting a positive integer`);for(;an.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(an.test(e)===!1)throw Error(`Expecting an integer`);for(;an.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
7
+ `: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:B(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 an.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
8
+ `: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)===`!`||this.peekChar(2)===`<`&&(this.peekChar(3)===`=`||this.peekChar(3)===`!`));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
9
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(rn.test(e)===!1)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(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},cn=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}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`Lookbehind`:this.visitLookbehind(e);break;case`NegativeLookbehind`:this.visitNegativeLookbehind(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){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},ln={},un=new sn;function dn(e){let t=e.toString();if(ln.hasOwnProperty(t))return ln[t];{let e=un.pattern(t);return ln[t]=e,e}}function fn(){ln={}}var pn=`Complement Sets are not supported for first char optimization`,mn=`Unable to use "first char" lexer optimizations:
10
+ `;function hn(e,t=!1){try{let t=dn(e);return gn(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===pn)t&&xt(`${mn}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
11
+ This will disable the lexer's first char optimizations.
12
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
13
+ This will disable the lexer's first char optimizations.
14
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),bt(`${mn}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function gn(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)gn(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`Lookbehind`:case`NegativeLookbehind`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:_n(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(pn);b(a.value,e=>{if(typeof e==`number`)_n(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)_n(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)_n(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=tr(e),a=tr(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:gn(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&bn(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return v(t)}function _n(e,t,n){let r=tr(e);t[r]=r,n===!0&&vn(e,t)}function vn(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=tr(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=tr(e.charCodeAt(0));t[n]=n}}}function yn(e,t){return Ne(e.value,e=>{if(typeof e==`number`)return P(t,e);{let n=e;return Ne(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function bn(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?x(e.value)?nt(e.value,bn):bn(e.value):!1}var xn=class extends cn{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return;case`Lookbehind`:this.visitLookbehind(e);return;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){P(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?yn(e,this.targetCharCodes)===void 0&&(this.found=!0):yn(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Sn(e,t){if(t instanceof RegExp){let n=dn(t),r=new xn(e);return r.visit(n),r.found}return Ne(t,t=>P(e,t.charCodeAt(0)))!==void 0}var Cn=`PATTERN`,wn=`defaultMode`;function Tn(e,t){t=ke(t,{debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
15
+ `],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{nr()});let r;n(`Reject Lexer.NA`,()=>{r=gt(e,e=>e[Cn]===H.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=D(r,e=>{let t=e[Cn];if(ft(t)){let e=t.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!t.ignoreCase?e:e.length===2&&e[0]===`\\`&&!P([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:Un(t)}if(y(t))return i=!0,{exec:t};if(typeof t==`object`)return i=!0,t;if(typeof t==`string`){if(t.length===1)return t;{let e=t.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`);return Un(new RegExp(e))}}throw Error(`non exhaustive match`)})});let o,s,c,l,u;n(`misc mapping`,()=>{o=D(r,e=>e.tokenTypeIdx),s=D(r,e=>{let t=e.GROUP;if(t!==H.SKIPPED){if(O(t))return t;if(ye(t))return!1;throw Error(`non exhaustive match`)}}),c=D(r,e=>{let t=e.LONGER_ALT;if(t)return x(t)?D(t,e=>ct(r,e)):[ct(r,t)]}),l=D(r,e=>e.PUSH_MODE),u=D(r,e=>k(e,`POP_MODE`))});let d;n(`Line Terminator Handling`,()=>{let e=Qn(t.lineTerminatorCharacters);d=D(r,e=>!1),t.positionTracking!==`onlyOffset`&&(d=D(r,t=>k(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:Xn(t,e)===!1&&Sn(e,t.PATTERN)))});let f,p,m,h;n(`Misc Mapping #2`,()=>{f=D(r,qn),p=D(a,Jn),m=T(r,(e,t)=>{let n=t.GROUP;return O(n)&&n!==H.SKIPPED&&(e[n]=[]),e},{}),h=D(a,(e,t)=>({pattern:a[t],longerAlt:c[t],canLineTerminator:d[t],isCustom:f[t],short:p[t],group:s[t],push:l[t],pop:u[t],tokenTypeIdx:o[t],tokenType:r[t]}))});let g=!0,ee=[];return t.safeMode||n(`First Char Optimization`,()=>{ee=T(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)$n(e,tr(n.PATTERN.charCodeAt(0)),h[r]);else if(x(n.START_CHARS_HINT)){let t;b(n.START_CHARS_HINT,n=>{let i=tr(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,$n(e,i,h[r]))})}else if(ft(n.PATTERN)){if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&bt(`${mn}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
16
+ This will disable the lexer's first char optimizations.
17
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=hn(n.PATTERN,t.ensureOptimizations);C(i)&&(g=!1),b(i,t=>{$n(e,t,h[r])})}}else t.ensureOptimizations&&bt(`${mn}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
18
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e},[])}),{emptyGroups:m,patternIdxToConfig:h,charCodeToPatternIdxToConfig:ee,hasCustom:i,canBeOptimized:g}}function En(e,t){let n=[],r=On(e);n=n.concat(r.errors);let i=kn(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(Dn(a)),n=n.concat(Ln(a)),n=n.concat(Rn(a,t)),n=n.concat(zn(a)),n}function Dn(e){let t=[],n=E(e,e=>ft(e[Cn]));return t=t.concat(jn(n)),t=t.concat(Pn(n)),t=t.concat(Fn(n)),t=t.concat(In(n)),t=t.concat(Mn(n)),t}function On(e){let t=E(e,e=>!k(e,Cn));return{errors:D(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:V.MISSING_PATTERN,tokenTypes:[e]})),valid:Qe(e,t)}}function kn(e){let t=E(e,e=>{let t=e[Cn];return!ft(t)&&!y(t)&&!k(t,`exec`)&&!O(t)});return{errors:D(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:V.INVALID_PATTERN,tokenTypes:[e]})),valid:Qe(e,t)}}var An=/[^\\][$]/;function jn(e){class t extends cn{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}let n=E(e,e=>{let n=e.PATTERN;try{let e=dn(n),r=new t;return r.visit(e),r.found}catch{return An.test(n.source)}});return D(n,e=>({message:`Unexpected RegExp Anchor Error:
19
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
20
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function Mn(e){let t=E(e,e=>e.PATTERN.test(``));return D(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:V.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}var Nn=/[^\\[][\^]|^\^/;function Pn(e){class t extends cn{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}let n=E(e,e=>{let n=e.PATTERN;try{let e=dn(n),r=new t;return r.visit(e),r.found}catch{return Nn.test(n.source)}});return D(n,e=>({message:`Unexpected RegExp Anchor Error:
21
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
22
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function Fn(e){let t=E(e,e=>{let t=e[Cn];return t instanceof RegExp&&(t.multiline||t.global)});return D(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:V.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function In(e){let t=[],n=D(e,n=>T(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!P(t,r)&&r.PATTERN!==H.NA?(t.push(r),e.push(r),e):e,[]));n=Ke(n);let r=E(n,e=>e.length>1);return D(r,e=>{let t=D(e,e=>e.name);return{message:`The same RegExp pattern ->${rt(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:V.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function Ln(e){let t=E(e,e=>{if(!k(e,`GROUP`))return!1;let t=e.GROUP;return t!==H.SKIPPED&&t!==H.NA&&!O(t)});return D(t,e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:V.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function Rn(e,t){let n=E(e,e=>e.PUSH_MODE!==void 0&&!P(t,e.PUSH_MODE));return D(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:V.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function zn(e){let t=[],n=T(e,(e,t,n)=>{let r=t.PATTERN;return r===H.NA||(O(r)?e.push({str:r,idx:n,tokenType:t}):ft(r)&&Vn(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return b(e,(e,r)=>{b(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&Bn(n,e.PATTERN)){let n=`Token: ->${a.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:V.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function Bn(e,t){if(ft(t)){if(Hn(t))return!1;let n=t.exec(e);return n!==null&&n.index===0}if(y(t))return t(e,0,[],{});if(k(t,`exec`))return t.exec(e,0,[],{});if(typeof t==`string`)return t===e;throw Error(`non exhaustive match`)}function Vn(e){return Ne([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function Hn(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}function Un(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function Wn(e,t,n){let r=[];return k(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition
23
+ `,type:V.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),k(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
24
+ `,type:V.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),k(e,`modes`)&&k(e,`defaultMode`)&&!k(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${wn}: <${e.defaultMode}>which does not exist\n`,type:V.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),k(e,`modes`)&&b(e.modes,(e,t)=>{b(e,(n,i)=>{if(ye(n))r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:V.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(k(n,`LONGER_ALT`)){let i=x(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT];b(i,i=>{!ye(i)&&!P(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:V.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),r}function Gn(e,t,n){let r=[],i=!1,a=gt(Ke(je(v(e.modes))),e=>e[Cn]===H.NA),o=Qn(n);return t&&b(a,e=>{let t=Xn(e,o);if(t!==!1){let n={message:Zn(e,t),type:t.issue,tokenType:e};r.push(n)}else k(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):Sn(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
25
+ This Lexer has been defined to track line and column information,
26
+ But none of the Token Types can be identified as matching a line terminator.
27
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
28
+ for details.`,type:V.NO_LINE_BREAKS_FLAGS}),r}function Kn(e){let t={},n=ae(e);return b(n,n=>{let r=e[n];if(x(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function qn(e){let t=e.PATTERN;if(ft(t))return!1;if(y(t)||k(t,`exec`))return!0;if(O(t))return!1;throw Error(`non exhaustive match`)}function Jn(e){return O(e)&&e.length===1?e.charCodeAt(0):!1}var Yn={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return this.lastIndex=e.charCodeAt(n+1)===10?n+2:n+1,!0}return!1},lastIndex:0};function Xn(e,t){if(k(e,`LINE_BREAKS`))return!1;if(ft(e.PATTERN)){try{Sn(t,e.PATTERN)}catch(e){return{issue:V.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(O(e.PATTERN))return!1;if(qn(e))return{issue:V.CUSTOM_LINE_BREAK};throw Error(`non exhaustive match`)}function Zn(e,t){if(t.issue===V.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
29
+ \tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===V.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
30
+ \tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function Qn(e){return D(e,e=>O(e)?e.charCodeAt(0):e)}function $n(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}var er=[];function tr(e){return e<256?e:er[e]}function nr(){if(C(er)){er=Array(65536);for(let e=0;e<65536;e++)er[e]=e>255?255+~~(e/255):e}}function rr(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx||t.isParent===!0&&t.categoryMatchesMap[n]===!0}function ir(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var ar=1,or={};function sr(e){let t=cr(e);lr(t),dr(t),ur(t),b(t,e=>{e.isParent=e.categoryMatches.length>0})}function cr(e){let t=j(e),n=e,r=!0;for(;r;){n=Ke(je(D(n,e=>e.CATEGORIES)));let e=Qe(n,t);t=t.concat(e),C(e)?r=!1:n=e}return t}function lr(e){b(e,e=>{pr(e)||(or[ar]=e,e.tokenTypeIdx=ar++),mr(e)&&!x(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),mr(e)||(e.CATEGORIES=[]),hr(e)||(e.categoryMatches=[]),gr(e)||(e.categoryMatchesMap={})})}function ur(e){b(e,e=>{e.categoryMatches=[],b(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(or[n].tokenTypeIdx)})})}function dr(e){b(e,e=>{fr([],e)})}function fr(e,t){b(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),b(t.CATEGORIES,n=>{let r=e.concat(t);P(r,n)||fr(r,n)})}function pr(e){return k(e,`tokenTypeIdx`)}function mr(e){return k(e,`CATEGORIES`)}function hr(e){return k(e,`categoryMatches`)}function gr(e){return k(e,`categoryMatchesMap`)}function _r(e){return k(e,`tokenTypeIdx`)}var vr={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i,a){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}},V;(function(e){e[e.MISSING_PATTERN=0]=`MISSING_PATTERN`,e[e.INVALID_PATTERN=1]=`INVALID_PATTERN`,e[e.EOI_ANCHOR_FOUND=2]=`EOI_ANCHOR_FOUND`,e[e.UNSUPPORTED_FLAGS_FOUND=3]=`UNSUPPORTED_FLAGS_FOUND`,e[e.DUPLICATE_PATTERNS_FOUND=4]=`DUPLICATE_PATTERNS_FOUND`,e[e.INVALID_GROUP_TYPE_FOUND=5]=`INVALID_GROUP_TYPE_FOUND`,e[e.PUSH_MODE_DOES_NOT_EXIST=6]=`PUSH_MODE_DOES_NOT_EXIST`,e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]=`MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE`,e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]=`MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY`,e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]=`MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST`,e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]=`LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED`,e[e.SOI_ANCHOR_FOUND=11]=`SOI_ANCHOR_FOUND`,e[e.EMPTY_MATCH_PATTERN=12]=`EMPTY_MATCH_PATTERN`,e[e.NO_LINE_BREAKS_FLAGS=13]=`NO_LINE_BREAKS_FLAGS`,e[e.UNREACHABLE_PATTERN=14]=`UNREACHABLE_PATTERN`,e[e.IDENTIFY_TERMINATOR=15]=`IDENTIFY_TERMINATOR`,e[e.CUSTOM_LINE_BREAK=16]=`CUSTOM_LINE_BREAK`,e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]=`MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE`})(V||={});var yr={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
31
+ `,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:vr,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(yr);var H=class{constructor(e,t=yr){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(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=St(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
32
+ a boolean 2nd argument is no longer supported`);this.config=A({},yr,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(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===yr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Yn;else if(this.config.lineTerminatorCharacters===yr.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
33
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),x(e)?n={modes:{defaultMode:j(e)},defaultMode:wn}:(r=!1,n=j(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Wn(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Gn(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},b(n.modes,(e,t)=>{n.modes[t]=gt(e,e=>ye(e))});let i=ae(n.modes);if(b(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(En(e,i))}),C(this.lexerDefinitionErrors)){sr(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=Tn(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=A({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!C(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=D(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
34
+ `);throw Error(`Errors detected in definition of Lexer:
35
+ `+e)}b(this.lexerDefinitionWarning,e=>{xt(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(r&&(this.handleModes=w),this.trackStartLines===!1&&(this.computeNewColumn=_e),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=w),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=T(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!C(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
36
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{fn()}),this.TRACE_INIT(`toFastProperties`,()=>{Ct(this)})})}tokenize(e,t=this.defaultMode){if(!C(this.lexerDefinitionErrors)){let e=D(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
37
+ `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
38
+ `+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee=e,te=ee.length,_=0,ne=0,re=this.hasCustom?0:Math.floor(e.length/10),ie=Array(re),ae=[],oe=this.trackStartLines?1:void 0,se=this.trackStartLines?1:void 0,ce=Kn(this.emptyGroups),le=this.trackStartLines,ue=this.config.lineTerminatorsPattern,v=0,y=[],de=[],b=[],x=[];Object.freeze(x);let fe=!1,pe=e=>{if(b.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);ae.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{b.pop();let e=Pe(b);y=this.patternIdxToConfig[e],de=this.charCodeToPatternIdxToConfig[e],v=y.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;fe=!!(de&&t)}};function me(e){b.push(e),de=this.charCodeToPatternIdxToConfig[e],y=this.patternIdxToConfig[e],v=y.length,v=y.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;fe=!!(de&&t)}me.call(this,t);let S,he=this.config.recoveryEnabled;for(;_<te;){s=null,u=-1;let t=ee.charCodeAt(_),re;if(fe){let e=tr(t),n=de[e];re=n===void 0?x:n}else re=y;let C=re.length;for(n=0;n<C;n++){S=re[n];let r=S.pattern;c=null;let d=S.short;if(d===!1?S.isCustom===!0?(g=r.exec(ee,_,ie,ce),g===null?s=null:(s=g[0],u=s.length,g.payload!==void 0&&(c=g.payload))):(r.lastIndex=_,u=this.matchLength(r,e,_)):t===d&&(u=1,s=r),u!==-1){if(o=S.longerAlt,o!==void 0){s=e.substring(_,_+u);let t=o.length;for(i=0;i<t;i++){let t=y[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(ee,_,ie,ce),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(n.lastIndex=_,a=this.match(n,e,_)),a&&a.length>s.length){s=a,u=a.length,c=l,S=t;break}}}break}}if(u!==-1){if(d=S.group,d!==void 0&&(s=s===null?e.substring(_,_+u):s,f=S.tokenTypeIdx,p=this.createTokenInstance(s,_,f,S.tokenType,oe,se,u),this.handlePayload(p,c),d===!1?ne=this.addToken(ie,ne,p):ce[d].push(p)),le===!0&&S.canLineTerminator===!0){let t=0,n,r;ue.lastIndex=0;do s=s===null?e.substring(_,_+u):s,n=ue.test(s),n===!0&&(r=ue.lastIndex-1,t++);while(n===!0);t===0?se=this.computeNewColumn(se,u):(oe+=t,se=u-r,this.updateTokenEndLineColumnLocation(p,d,r,t,oe,se,u))}else se=this.computeNewColumn(se,u);_+=u,this.handleModes(S,pe,me,p)}else{let t=_,n=oe,i=se,a=he===!1;for(;a===!1&&_<te;)for(_++,r=0;r<v;r++){let t=y[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(ee,_,ie,ce)!==null:(n.lastIndex=_,a=n.exec(e)!==null):ee.charCodeAt(_)===i&&(a=!0),a===!0)break}if(m=_-t,se=this.computeNewColumn(se,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(ee,t,m,n,i,Pe(b)),ae.push({offset:t,line:n,column:i,length:m,message:h}),he===!1)break}}return this.hasCustom||(ie.length=ne),{tokens:ie,groups:ce,errors:ae}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,(r!==1||s!==!0)&&(e.endLine=i+c,e.endColumn=a-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,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchLength(e,t,n){return e.test(t)===!0?e.lastIndex-n:-1}};H.SKIPPED=`This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.`,H.NA=/NOT_APPLICABLE/;function br(e){return xr(e)?e.LABEL:e.name}function xr(e){return O(e.LABEL)&&e.LABEL!==``}var Sr=`parent`,Cr=`categories`,wr=`label`,Tr=`group`,Er=`push_mode`,Dr=`pop_mode`,Or=`longer_alt`,kr=`line_breaks`,Ar=`start_chars_hint`;function U(e){return jr(e)}function jr(e){let t=e.pattern,n={};if(n.name=e.name,ye(t)||(n.PATTERN=t),k(e,Sr))throw`The parent property is no longer supported.
39
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return k(e,Cr)&&(n.CATEGORIES=e[Cr]),sr([n]),k(e,wr)&&(n.LABEL=e[wr]),k(e,Tr)&&(n.GROUP=e[Tr]),k(e,Dr)&&(n.POP_MODE=e[Dr]),k(e,Er)&&(n.PUSH_MODE=e[Er]),k(e,Or)&&(n.LONGER_ALT=e[Or]),k(e,kr)&&(n.LINE_BREAKS=e[kr]),k(e,Ar)&&(n.START_CHARS_HINT=e[Ar]),n}var Mr=U({name:`EOF`,pattern:H.NA});sr([Mr]);function Nr(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function Pr(e,t){return rr(e,t)}var Fr={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${xr(e)?`--> ${br(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
40
+ but found: '`+rt(t).image+`'`;if(r)return`Expecting: `+r+a;{let t=T(e,(e,t)=>e.concat(t),[]),n=D(t,e=>`[${D(e,e=>br(e)).join(`, `)}]`);return`Expecting: one of these possible Token sequences:\n${D(n,(e,t)=>` ${t+1}. ${e}`).join(`
41
+ `)}`+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
42
+ but found: '`+rt(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${D(e,e=>`[${D(e,e=>br(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(Fr);var Ir={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
43
+ inside top level rule: ->`+e.name+`<-`}},Lr={buildDuplicateFoundError(e,t){function n(e){return e instanceof z?e.terminalType.name:e instanceof F?e.nonTerminalName:``}let r=e.name,i=rt(t),a=i.idx,o=Rt(i),s=n(i),c=`->${o}${a>0?a:``}<- ${s?`with argument: ->${s}<-`:``}
44
+ appears more than once (${t.length} times) in the top level rule: ->${r}<-.
45
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
46
+ `;return c=c.replace(/[ \t]+/g,` `),c=c.replace(/\s\s+/g,`
47
+ `),c},buildNamespaceConflictError(e){return`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){let t=D(e.prefixPath,e=>br(e)).join(`, `),n=e.alternation.idx===0?``: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){let t=e.alternation.idx===0?``:e.alternation.idx,n=e.prefixPath.length===0,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;if(n)r+=`These alternatives are all empty (match no tokens), making them indistinguishable.
48
+ Only the last alternative may be empty.
49
+ `;else{let t=D(e.prefixPath,e=>br(e)).join(`, `);r+=`<${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
50
+ For Further details.`,r},buildEmptyRepetitionError(e){let t=Rt(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`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){return`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){let 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} --> ${D(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof Dt?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function Rr(e,t){let n=new zr(e,t);return n.resolveRefs(),n.errors}var zr=class extends Pt{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){b(v(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:G.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},Br=class extends zt{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=j(this.path.ruleStack).reverse(),this.occurrenceStack=j(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){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){C(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},Vr=class extends Br{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){let e=new I({definition:t.concat(n)});this.possibleTokTypes=Vt(e),this.found=!0}}},Hr=class extends zt{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}},Ur=class extends Hr{walkMany(e,t,n){if(e.idx===this.occurrence){let e=rt(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof z&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},Wr=class extends Hr{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=rt(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof z&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},Gr=class extends Hr{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=rt(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof z&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},Kr=class extends Hr{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=rt(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof z&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function qr(e,t,n=[]){n=j(n);let r=[],i=0;function a(t){return t.concat(M(e,i+1))}function o(e){let i=qr(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof I||t instanceof F)return o(t.definition);if(t instanceof L)r=o(t.definition);else if(t instanceof Ot)return o(t.definition.concat([new R({definition:t.definition})]));else if(t instanceof kt)return o([new I({definition:t.definition}),new R({definition:[new z({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof At)r=o(t.definition.concat([new R({definition:[new z({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof R)r=o(t.definition.concat([new R({definition:t.definition})]));else if(t instanceof jt)return b(t.definition,e=>{C(e.definition)===!1&&(r=o(e.definition))}),r;else if(t instanceof z)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:M(e,i)}),r}function Jr(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!C(d);){let e=d.pop();if(e===o){s&&Pe(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(C(r))continue;let h=r[0];if(h===i){let e={idx:f,def:M(r),ruleStack:$e(p),occurrenceStack:$e(m)};d.push(e)}else if(h instanceof z){if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:M(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`)}else if(h instanceof F){let e=j(p);e.push(h.nonTerminalName);let t=j(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,M(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof L){let e={idx:f,def:M(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(M(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof Ot){let e=new R({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],M(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof kt){let e=new R({definition:[new z({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],M(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof At){let e={idx:f,def:M(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new R({definition:[new z({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],M(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof R){let e={idx:f,def:M(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new R({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],M(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof jt)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(M(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof I)d.push({idx:f,def:h.definition.concat(M(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof Dt)d.push(Yr(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function Yr(e,t,n,r){let i=j(n);i.push(e.name);let a=j(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var W;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(W||={});function Xr(e){if(e instanceof L||e===`Option`)return W.OPTION;if(e instanceof R||e===`Repetition`)return W.REPETITION;if(e instanceof Ot||e===`RepetitionMandatory`)return W.REPETITION_MANDATORY;if(e instanceof kt||e===`RepetitionMandatoryWithSeparator`)return W.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof At||e===`RepetitionWithSeparator`)return W.REPETITION_WITH_SEPARATOR;if(e instanceof jt||e===`Alternation`)return W.ALTERNATION;throw Error(`non exhaustive match`)}function Zr(e,t,n,r,i,a){let o=si(e,t,n);return a(o,r,di(o)?ir:rr,i)}function Qr(e,t,n,r,i,a){let o=ci(e,t,i,n),s=di(o)?ir:rr;return a(o[0],s,r)}function $r(e,t,n,r){let i=e.length,a=nt(e,e=>nt(e,e=>e.length===1));if(t)return function(t){let r=D(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(o===void 0||o.call(this)!==!1)nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=D(e,e=>je(e)),n=T(t,(e,t,n)=>(b(t,t=>{k(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),b(t.categoryMatches,t=>{k(e,t)||(e[t]=n)})}),e),{});return function(){let e=this.LA(1);return n[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function ei(e,t,n){let r=nt(e,e=>e.length===1),i=e.length;if(r&&!n){let t=je(e);if(t.length===1&&C(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{let e=T(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,b(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){let t=this.LA(1);return e[t.tokenTypeIdx]===!0}}}return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var ti=class extends zt{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,W.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,W.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,W.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,W.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,W.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},ni=class extends Pt{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&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,W.OPTION)}visitRepetition(e){this.checkIsTarget(e,W.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,W.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,W.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,W.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,W.ALTERNATION)}};function ri(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function ii(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function ai(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function oi(e,t){let n=D(e,e=>qr([e],1)),r=ri(n.length),i=D(n,e=>{let t={};return b(e,e=>{let n=ii(e.partialPath);b(n,e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=ri(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=ii(c);if(ai(i,u,o)||C(l)||c.length===t){let e=r[o];if(li(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=qr(l,e+1,c);a[o]=a[o].concat(t),b(t,e=>{let t=ii(e.partialPath);b(t,e=>{i[o][e]=!0})})}}}}return r}function si(e,t,n,r){let i=new ni(e,W.ALTERNATION,r);return t.accept(i),oi(i.result,n)}function ci(e,t,n,r){let i=new ni(e,n);t.accept(i);let a=i.result,o=new ti(t,e,n).startWalking();return oi([new I({definition:a}),new I({definition:o})],r)}function li(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(n!==i&&i.categoryMatchesMap[n.tokenTypeIdx]===void 0)continue compareOtherPath}return!0}}return!1}function ui(e,t){return e.length<t.length&&nt(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function di(e){return nt(e,e=>nt(e,e=>nt(e,e=>C(e.categoryMatches))))}function fi(e){let t=e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName});return D(t,e=>Object.assign({type:G.CUSTOM_LOOKAHEAD_VALIDATION},e))}function pi(e,t,n,r){let i=N(e,e=>mi(e,n)),a=Ai(e,t,n),o=N(e,e=>Ei(e,n)),s=N(e,t=>vi(t,e,r,n));return i.concat(a,o,s)}function mi(e,t){let n=new _i;e.accept(n);let r=n.allProductions,i=ht(at(r,hi),e=>e.length>1);return D(v(i),n=>{let r=rt(n),i=t.buildDuplicateFoundError(e,n),a=Rt(r),o={message:i,type:G.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=gi(r);return s&&(o.parameter=s),o})}function hi(e){return`${Rt(e)}_#_${e.idx}_#_${gi(e)}`}function gi(e){return e instanceof z?e.terminalType.name:e instanceof F?e.nonTerminalName:``}var _i=class extends Pt{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 vi(e,t,n,r){let i=[];if(T(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:G.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function yi(e,t,n){let r=[],i;return P(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:G.INVALID_RULE_OVERRIDE,ruleName:e})),r}function bi(e,t,n,r=[]){let i=[],a=xi(t.definition);if(C(a))return[];{let t=e.name;P(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:G.LEFT_RECURSION,ruleName:t});let o=N(Qe(a,r.concat([e])),t=>{let i=j(r);return i.push(t),bi(e,t,n,i)});return i.concat(o)}}function xi(e){let t=[];if(C(e))return t;let n=rt(e);if(n instanceof F)t.push(n.referencedRule);else if(n instanceof I||n instanceof L||n instanceof Ot||n instanceof kt||n instanceof At||n instanceof R)t=t.concat(xi(n.definition));else if(n instanceof jt)t=je(D(n.definition,e=>xi(e.definition)));else if(!(n instanceof z))throw Error(`non exhaustive match`);let r=It(n),i=e.length>1;if(r&&i){let n=M(e);return t.concat(xi(n))}return t}var Si=class extends Pt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Ci(e,t){let n=new Si;e.accept(n);let r=n.alternations;return N(r,n=>N($e(n.definition),(r,i)=>{let a=Jr([r],[],rr,1);return C(a)?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:G.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]}))}function wi(e,t,n){let r=new Si;e.accept(r);let i=r.alternations;return i=gt(i,e=>e.ignoreAmbiguities===!0),N(i,r=>{let i=r.idx,a=si(i,e,r.maxLookahead||t,r),o=Oi(a,r,e,n),s=ki(a,r,e,n);return o.concat(s)})}var Ti=class extends Pt{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 Ei(e,t){let n=new Si;e.accept(n);let r=n.alternations;return N(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:G.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function Di(e,t,n){let r=[];return b(e,e=>{let i=new Ti;e.accept(i);let a=i.allProductions;b(a,i=>{let a=Xr(i),o=i.maxLookahead||t,s=i.idx,c=ci(s,e,a,o)[0];if(C(je(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:G.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function Oi(e,t,n,r){let i=[],a=T(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||b(r,r=>{let o=[a];b(e,(e,n)=>{a!==n&&li(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!li(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]);return D(a,e=>{let i=D(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:G.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function ki(e,t,n,r){let i=T(e,(e,t,n)=>{let r=D(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return Ke(N(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,o=e.path,s=E(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&ui(e.path,o));return D(s,e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:G.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function Ai(e,t,n){let r=[],i=D(t,e=>e.name);return b(e,e=>{let t=e.name;if(P(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:G.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function ji(e){let t=ke(e,{errMsgProvider:Ir}),n={};return b(e.rules,e=>{n[e.name]=e}),Rr(n,t.errMsgProvider)}function Mi(e){return e=ke(e,{errMsgProvider:Lr}),pi(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var Ni=`MismatchedTokenException`,Pi=`NoViableAltException`,Fi=`EarlyExitException`,Ii=`NotAllInputParsedException`,Li=[Ni,Pi,Fi,Ii];Object.freeze(Li);function Ri(e){return P(Li,e.name)}var zi=class 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)}},Bi=class extends zi{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ni}},Vi=class extends zi{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Pi}},Hi=class extends zi{constructor(e,t){super(e,t),this.name=Ii}},Ui=class extends zi{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Fi}},Wi={},Gi=`InRuleRecoveryException`,Ki=class extends Error{constructor(e){super(e),this.name=Gi}},qi=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=k(e,`recoveryEnabled`)?e.recoveryEnabled:Fa.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Ji)}getTokenToInsert(e){let t=Nr(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){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),u=()=>{let e=this.LA(0),t=new Bi(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=$e(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let 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)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new Ki(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||C(t))return!1;let n=this.LA(1);return Ne(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return P(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=Ne(e,e=>Pr(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Wi;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return D(e,(n,r)=>r===0?Wi:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){let e=D(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e));return je(e)}getFollowSetFromFollowKey(e){if(e===Wi)return[Mr];let t=e.ruleName+e.idxInCallingRule+Gt+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Mr)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return $e(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:j(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return D(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function Ji(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=Mr,u=1),l!==void 0&&u!==void 0&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}var Yi=1024,Xi=1280,Zi=1536;function Qi(e,t,n){return n|t|e}var $i=class{constructor(e){this.maxLookahead=e?.maxLookahead??Fa.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(C(t)){let 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 N(e,e=>bi(e,e,Lr))}validateEmptyOrAlternatives(e){return N(e,e=>Ci(e,Lr))}validateAmbiguousAlternationAlternatives(e,t){return N(e,e=>wi(e,t,Lr))}validateSomeNonEmptyLookaheadPath(e,t){return Di(e,t,Lr)}buildLookaheadForAlternation(e){return Zr(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,$r)}buildLookaheadForOptional(e){return Qr(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Xr(e.prodType),ei)}},ea=class{initLooksAhead(e){this.dynamicTokensEnabled=k(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:Fa.dynamicTokensEnabled,this.maxLookahead=k(e,`maxLookahead`)?e.maxLookahead:Fa.maxLookahead,this.lookaheadStrategy=k(e,`lookaheadStrategy`)?e.lookaheadStrategy:new $i({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){b(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=na(e);b(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${Rt(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=Qi(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),b(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,Rt(t))}),b(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,Rt(t))}),b(i,t=>{this.computeLookaheadFunc(e,t.idx,Yi,`RepetitionMandatory`,t.maxLookahead,Rt(t))}),b(a,t=>{this.computeLookaheadFunc(e,t.idx,Zi,`RepetitionMandatoryWithSeparator`,t.maxLookahead,Rt(t))}),b(o,t=>{this.computeLookaheadFunc(e,t.idx,Xi,`RepetitionWithSeparator`,t.maxLookahead,Rt(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=Qi(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return Qi(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},ta=new class extends Pt{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 na(e){ta.reset(),e.accept(ta);let t=ta.dslMethods;return ta.reset(),t}function ra(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function ia(e,t){isNaN(e.startOffset)===!0?(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&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function aa(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function oa(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}var sa=`name`;function ca(e,t){Object.defineProperty(e,sa,{enumerable:!1,configurable:!0,writable:!1,value:t})}function la(e,t){let n=ae(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function ua(e,t){let n=function(){};return ca(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(x(e)&&(e=e[0]),!ye(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=pa(this,t);if(!C(e)){let t=D(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
51
+
52
+ `).replace(/\n/g,`
53
+ `)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function da(e,t,n){let r=function(){};ca(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return b(t,e=>{i[e]=la}),r.prototype=i,r.prototype.constructor=r,r}var fa;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(fa||={});function pa(e,t){return ma(e,t)}function ma(e,t){let n=E(t,t=>y(e[t])===!1);return Ke(D(n,t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:fa.MISSING_METHOD,methodName:t})))}var ha=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=k(e,`nodeLocationTracking`)?e.nodeLocationTracking:Fa.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=w,this.cstFinallyStateUpdate=w,this.cstPostTerminal=w,this.cstPostNonTerminal=w,this.cstPostRule=w;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=ia,this.setNodeLocationFromNode=ia,this.cstPostRule=w,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=ra,this.setNodeLocationFromNode=ra,this.cstPostRule=w,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=w,this.setNodeLocationFromNode=w,this.cstPostRule=w,this.setInitialNodeLocation=w;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];aa(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];oa(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(ye(this.baseCstVisitorConstructor)){let e=ua(this.className,ae(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(ye(this.baseCstVisitorWithDefaultsConstructor)){let e=da(this.className,ae(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},ga=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):Pa}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Pa: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()}},_a=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=Ia){if(P(this.definedRulesNames,e)){let t={message:Lr.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:G.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=Ia){let r=yi(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(Ri(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Mt(v(this.gastProductionsCache))}},va=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=ir,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},k(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
54
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
55
+ For Further details.`);if(x(e)){if(C(e))throw Error(`A Token Vocabulary cannot be empty.
56
+ Note that the first argument for the parser constructor
57
+ is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
58
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
59
+ For Further details.`)}if(x(e))this.tokensMap=T(e,(e,t)=>(e[t.name]=t,e),{});else if(k(e,`modes`)&&nt(je(v(e.modes)),_r)){let t=yt(je(v(e.modes)));this.tokensMap=T(t,(e,t)=>(e[t.name]=t,e),{})}else if(xe(e))this.tokensMap=j(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=Mr;let n=nt(k(e,`modes`)?je(v(e.modes)):v(e),e=>C(e.categoryMatches));this.tokenMatcher=n?ir:rr,sr(v(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.`);let r=k(n,`resyncEnabled`)?n.resyncEnabled:Ia.resyncEnabled,i=k(n,`recoveryValueFunc`)?n.recoveryValueFunc:Ia.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Ri(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){let 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){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof e!=`function`){i=e.DEF;let t=e.GATE;if(t!==void 0){let e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(Yi,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;if(r.call(this)===!0){let e=this.doSingleRepetition(i);for(;r.call(this)===!0&&e===!0;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,W.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,Yi,e,Gr)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Zi,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Kr],t,Zi,e,Kr)}else throw this.raiseEarlyExitException(e,W.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,Ur,a)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Xi,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Wr],t,Xi,e,Wr)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Zi,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=x(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)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(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Hi(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw Ri(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Bi(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}throw n}saveRecogState(){let e=this.errors,t=j(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 this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Mr)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},ya=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=k(e,`errorMessageProvider`)?e.errorMessageProvider:Fa.errorMessageProvider}SAVE_ERROR(e){if(Ri(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:j(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return j(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=ci(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new Ui(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=si(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Vi(s,this.LA(1),o))}},ba=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(ye(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return Jr([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=rt(e.ruleStack),n=this.getGAstProductions()[t];return new Vr(n,e).startWalking()}},xa={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(xa);var Sa=!0,Ca=255,wa=U({name:`RECORDING_PHASE_TOKEN`,pattern:H.NA});sr([wa]);var Ta=Nr(wa,`This IToken indicates the Parser is in Recording Phase
60
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Ta);var Ea={name:`This CSTNode indicates the Parser is in Recording Phase
61
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Da=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++){let 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`,()=>{let e=this;for(let t=0;t<10;t++){let 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 Pa}topLevelRuleRecord(e,t){try{let n=new Dt({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
62
+ This error was thrown during the "grammar recording phase" For more info see:
63
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return Oa.call(this,L,e,t)}atLeastOneInternalRecord(e,t){Oa.call(this,Ot,t,e)}atLeastOneSepFirstInternalRecord(e,t){Oa.call(this,kt,t,e,Sa)}manyInternalRecord(e,t){Oa.call(this,R,t,e)}manySepFirstInternalRecord(e,t){Oa.call(this,At,t,e,Sa)}orInternalRecord(e,t){return ka.call(this,e,t)}subruleInternalRecord(e,t,n){if(ja(t),!e||k(e,`ruleName`)===!1){let n=Error(`<SUBRULE${Aa(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}let r=Pe(this.recordingProdStack),i=e.ruleName,a=new F({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?Ea:xa}consumeInternalRecord(e,t,n){if(ja(t),!pr(e)){let n=Error(`<CONSUME${Aa(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}let r=Pe(this.recordingProdStack),i=new z({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Ta}};function Oa(e,t,n,r=!1){ja(n);let i=Pe(this.recordingProdStack),a=y(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),k(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),xa}function ka(e,t){ja(t);let n=Pe(this.recordingProdStack),r=x(e)===!1,i=r===!1?e:e.DEF,a=new jt({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return k(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=vt(i,e=>y(e.GATE)),n.definition.push(a),b(i,e=>{let t=new I({definition:[]});a.definition.push(t),k(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:k(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),xa}function Aa(e){return e===0?``:`${e}`}function ja(e){if(e<0||e>Ca){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${Ca+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var Ma=class{initPerformanceTracer(e){if(k(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=Fa.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=St(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}};function Na(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}var Pa=Nr(Mr,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Pa);var Fa=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Fr,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),Ia=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0}),G;(function(e){e[e.INVALID_RULE_NAME=0]=`INVALID_RULE_NAME`,e[e.DUPLICATE_RULE_NAME=1]=`DUPLICATE_RULE_NAME`,e[e.INVALID_RULE_OVERRIDE=2]=`INVALID_RULE_OVERRIDE`,e[e.DUPLICATE_PRODUCTIONS=3]=`DUPLICATE_PRODUCTIONS`,e[e.UNRESOLVED_SUBRULE_REF=4]=`UNRESOLVED_SUBRULE_REF`,e[e.LEFT_RECURSION=5]=`LEFT_RECURSION`,e[e.NONE_LAST_EMPTY_ALT=6]=`NONE_LAST_EMPTY_ALT`,e[e.AMBIGUOUS_ALTS=7]=`AMBIGUOUS_ALTS`,e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]=`CONFLICT_TOKENS_RULES_NAMESPACE`,e[e.INVALID_TOKEN_NAME=9]=`INVALID_TOKEN_NAME`,e[e.NO_NON_EMPTY_LOOKAHEAD=10]=`NO_NON_EMPTY_LOOKAHEAD`,e[e.AMBIGUOUS_PREFIX_ALTS=11]=`AMBIGUOUS_PREFIX_ALTS`,e[e.TOO_MANY_ALTS=12]=`TOO_MANY_ALTS`,e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]=`CUSTOM_LOOKAHEAD_VALIDATION`})(G||={});var La=class e{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let t;this.selfAnalysisDone=!0;let n=this.className;this.TRACE_INIT(`toFastProps`,()=>{Ct(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),b(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{r=ji({rules:v(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(C(r)&&this.skipValidations===!1){let e=Mi({rules:v(this.gastProductionsCache),tokenTypes:v(this.tokensMap),errMsgProvider:Lr,grammarName:n}),t=fi({lookaheadStrategy:this.lookaheadStrategy,rules:v(this.gastProductionsCache),tokenTypes:v(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),C(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=qt(v(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:v(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(v(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!C(this.definitionErrors))throw t=D(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${t.join(`
64
+ -------------------------------
65
+ `)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let 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),k(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
66
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
67
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
68
+ For further details.`);this.skipValidations=k(t,`skipValidations`)?t.skipValidations:Fa.skipValidations}};La.DEFER_DEFINITION_ERRORS_HANDLING=!1,Na(La,[qi,ea,ha,ga,va,_a,ya,ba,Da,Ma]);var Ra=class extends La{constructor(e,t=Fa){let n=j(t);n.outputCst=!0,super(e,n)}};function za(e,t){let n=e.lexer.tokenize(t);if(n.errors.length>0){let r=n.errors[0],i=Number.isFinite(r.offset)?r.offset:t.length,a=i+(Number.isFinite(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${i},${a})`)}e.parser.input=n.tokens;let r=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(r)}e(za,`runChevrotainParse`);var K={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ba=`LR`,Va=s.usecase,Ha=e(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ba,relationshipCounter:0,noteCounter:0,accTitle:``,accDescription:``,ast:void 0,config:structuredClone(Va)}),`createModel`),Ua=e(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||![`TB`,`TD`,`BT`,`RL`,`LR`].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||typeof e.accTitle!=`string`||typeof e.accDescription!=`string`||!e.config)throw Error(`Cannot commit an incomplete usecase model`)},`assertCompleteModel`),q=Ha(),Wa=e(()=>structuredClone(q.config),`getConfig`),Ga=e(()=>q.ast,`getAST`),Ka=e(e=>{let t=structuredClone(e);Ua(t);let n=f(),a=l();try{i(t.accTitle),r(t.accDescription),q=t}catch(e){throw i(n),r(a),e}},`commit`),qa=e(()=>{q=Ha(),a()},`clear`),Ja=e(()=>q.actors,`getActors`),Ya=e(e=>q.actors.get(e),`getActor`),Xa=e(()=>q.useCases,`getUseCases`),Za=e(e=>q.useCases.get(e),`getUseCase`),Qa=e(()=>q.systemBoundaries,`getSystemBoundaries`),$a=e(e=>q.systemBoundaries.get(e),`getSystemBoundary`),eo=e(()=>q.relationships,`getRelationships`),to=e(()=>q.notes,`getNotes`),no=e(e=>q.notes.get(e),`getNote`),ro=e(()=>q.jsonNodes,`getJsonNodes`),io=e(e=>q.jsonNodes.get(e),`getJsonNode`),ao=e(()=>q.classDefs,`getClassDefs`),oo=e(e=>q.classDefs.get(e),`getClassDef`),so=e(()=>q.direction,`getDirection`),co=e(e=>{let t=new Map;for(let n of[`default`,...e]){let e=q.classDefs.get(n);if(e)for(let n of e.styles){let e=n.trim(),r=e.indexOf(`:`),i=(r===-1?e:e.slice(0,r)).trim();i&&t.set(i,e)}}return[...t.values()]},`getCompiledStyles`),lo=e(e=>e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`),`escapeJsonPointerPart`),uo=e(e=>typeof e==`string`?e:e===null?`null`:String(e),`displayJsonScalar`),fo=e((t,n,r=e=>e)=>{let i=[],a=e((e,t,n)=>{i.push({key:r(e),accessibleKey:r(t),value:r(n)})},`append`),o=e((e,t,r)=>{if(Array.isArray(e)){if(e.length===0){a(t,t,`[]`);return}if(e.every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))){for(let[n,r]of e.entries())a(n===0?t:``,t,uo(r));return}for(let[n,i]of e.entries())o(i,`${t}[${n}]`,`${r}/${n}`);return}if(typeof e==`object`&&e){let i=e,s=n[r]??Object.keys(i);if(s.length===0){a(t,t,`{}`);return}for(let e of s){let n=t?`${t}.${e}`:e;o(i[e],n,`${r}/${lo(e)}`)}return}a(t,t,uo(e))},`visit`);return o(t,``,``),i},`flattenJsonRows`),po=e(e=>{switch(e.type){case`hollow`:return`usecaseActorHollow`;case`awesome`:return`usecaseActorAwesome`;case`icon`:return`usecaseActorIcon`;case`normal`:return`usecaseActor`}},`actorShape`),mo=e(e=>e.shape===`ellipse`?e.business?`usecaseBusiness`:`usecaseEllipse`:e.shape,`useCaseShape`),ho=e(e=>{switch(e){case K.SOLID_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_point`};case K.BACK_ARROW:return{arrowTypeStart:`arrow_point`,arrowTypeEnd:`none`};case K.CIRCLE_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_circle`};case K.CROSS_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_cross`};case K.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:`arrow_circle`,arrowTypeEnd:`none`};case K.CROSS_ARROW_REVERSED:return{arrowTypeStart:`arrow_cross`,arrowTypeEnd:`none`};case K.LINE_SOLID:return{arrowTypeStart:`none`,arrowTypeEnd:`none`}}},`associationMarkers`),go=e(e=>{switch(e.type){case`include`:case`extend`:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_point`,pattern:`dotted`,label:e.type,labelType:`text`};case`generalization`:return{arrowTypeStart:`none`,arrowTypeEnd:`extension`,pattern:`solid`};case`association`:return{...ho(e.arrowType),pattern:`solid`,...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},`relationshipVisuals`),_o=e(e=>e.animate||e.animation?[`edge-animation-${e.animation??`fast`}`]:[],`animationClasses`),vo=e((...e)=>e.filter(e=>!!e).join(` `),`classNames`),yo={getConfig:Wa,createModel:Ha,commit:Ka,getAST:Ga,clear:qa,setDiagramTitle:c,getDiagramTitle:u,setAccTitle:i,getAccTitle:f,setAccDescription:r,getAccDescription:l,getActors:Ja,getActor:Ya,getUseCases:Xa,getUseCase:Za,getSystemBoundaries:Qa,getSystemBoundary:$a,getRelationships:eo,getNotes:to,getNote:no,getJsonNodes:ro,getJsonNode:io,getClassDefs:ao,getClassDef:oo,getDirection:so,getData:e(()=>{let t=d(),n={...q.config,...t.usecase},r=e(e=>p(e,t),`sanitize`),i=e(e=>r(q.actors.get(e)?.label??q.useCases.get(e)?.label??q.jsonNodes.get(e)?.id??q.notes.get(e)?.label??e),`endpointLabel`),a=[],o=[],s=0,c=0;for(let e of q.actors.values())a.push({id:e.id,label:r(e.label),labelType:e.labelType,shape:po(e),isGroup:!1,padding:10,look:t.look,colorIndex:s++,cssClasses:vo(`default`,`usecase-actor`,`usecase-actor-${e.type}`,e.business&&`usecase-business`,...e.classes),cssStyles:[...e.styles],cssCompiledStyles:co(e.classes),actorType:e.type,business:e.business,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:r(e.stereotype)}:{},...e.parentId?{parentId:e.parentId}:{}});for(let e of q.useCases.values())a.push({id:e.id,label:r(e.label),labelType:e.labelType,shape:mo(e),isGroup:!1,padding:e.shape===`ellipse`?20:10,look:t.look,colorIndex:s++,cssClasses:vo(`default`,`usecase-element`,`usecase-${e.shape}`,e.business&&`usecase-business`,...e.classes),cssStyles:[...e.styles],cssCompiledStyles:co(e.classes),business:e.business,...e.stereotype?{stereotype:r(e.stereotype)}:{},...e.parentId?{parentId:e.parentId}:{}});for(let e of q.notes.values())a.push({id:e.id,label:r(e.label),labelType:e.labelType,shape:`note`,isGroup:!1,padding:10,look:t.look,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:co([]),noteTarget:e.target,noteTargetLabel:r(q.actors.get(e.target)?.label??q.useCases.get(e.target)?.label??q.jsonNodes.get(e.target)?.id??e.target)});for(let e of q.jsonNodes.values())a.push({id:e.id,label:r(e.id),labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,look:t.look,cssClasses:vo(`default`,`usecase-json-table`,...e.classes),cssStyles:[...e.styles],cssCompiledStyles:co(e.classes),jsonRows:fo(e.value,e.propertyOrder,r)});for(let e of q.systemBoundaries.values())a.push({id:e.id,label:r(e.label),labelType:e.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,look:t.look,colorIndex:c++,cssClasses:vo(`default`,`system-boundary`,`system-boundary-${e.type}`,...e.classes),cssStyles:[...e.styles],cssCompiledStyles:co(e.classes),boundaryType:e.type});for(let e of q.relationships){let{label:n,...a}=go(e);o.push({id:e.id,start:e.source,end:e.target,source:e.source,target:e.target,sourceLabel:i(e.source),targetLabel:i(e.target),type:`edge`,relationshipType:e.type,internal:!1,...a,...n===void 0?{}:{label:r(n)},labelpos:`c`,classes:vo(`default`,`relationship`,`relationship-${e.type}`,...e.classes,..._o(e)),style:[...e.styles],cssCompiledStyles:co(e.classes),animate:e.animate,...e.animation?{animation:e.animation}:{},look:t.look,thickness:`normal`,minlen:e.minlen,isUserDefinedId:e.explicitId})}for(let e of q.notes.values())o.push({id:`${e.id}-edge`,start:e.id,end:e.target,source:e.id,target:e.target,type:`edge`,relationshipType:`note`,sourceLabel:i(e.id),targetLabel:i(e.target),internal:!0,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,labelpos:`c`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:co([]),animate:!1,look:t.look,thickness:`normal`,minlen:1,isUserDefinedId:!1});for(let e of a)e.wrappingWidth??=n.wrappingWidth,!e.isGroup&&!e.shape.startsWith(`usecaseActor`)&&(e.minWidth??=n.minNodeWidth),(e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`)&&(e.spreadPorts=!0);return{nodes:a,edges:o,config:t,type:`usecase`,layoutAlgorithm:`dagre`,direction:so(),nodeSpacing:n.nodeSpacing,rankSpacing:n.rankSpacing,actorFontSize:n.actorFontSize,actorFontFamily:n.actorFontFamily,actorFontWeight:n.actorFontWeight,usecaseFontSize:n.usecaseFontSize,usecaseFontFamily:n.usecaseFontFamily,usecaseFontWeight:n.usecaseFontWeight,diagramPadding:n.diagramPadding,useMaxWidth:n.useMaxWidth,markers:[`point`,`circle`,`cross`,`extension`]}},`getData`)};function bo(e,t,n){let r=[n];return r.index=t,r.input=e,r}e(bo,`customMatch`);var xo=e((e,t)=>{if(e[t]!==`"`||e[t+1]!=="`")return null;for(let n=t+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]===`"`)return bo(e,t,e.slice(t,n+2));return null},`matchMarkdownString`),So=e((e,t)=>{if(e[t]!==`%`||e[t+1]!==`%`)return null;for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
69
+ `||t===`\r`)break;if(t!==` `&&t!==` `)return null}let n=t+2;for(;n<e.length&&e[n]!==`
70
+ `&&e[n]!==`\r`;)n++;return bo(e,t,e.slice(t,n))},`matchComment`),Co=e((e,t)=>{for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
71
+ `||t===`\r`)return!0;if(t!==` `&&t!==` `)return!1}return!0},`isIndentedLineStart`),wo=e((e,t,n)=>{if(!Co(e,t))return null;let r=n.exec(e.slice(t));return r?bo(e,t,r[0]):null},`matchAccessibilityLine`),To=e((e,t)=>{if(!Co(e,t))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(t));if(!n)return null;let r=e.indexOf(`}`,t+n[0].length);return r===-1?null:bo(e,t,e.slice(t,r+1))},`matchAccDescrBlock`),Eo=e((e,t)=>{if(e[t]!==`{`)return null;let n=0,r=!1,i=!1;for(let a=t;a<e.length;a++){let o=e[a];if(r){i?i=!1:o===`\\`?i=!0:o===`"`&&(r=!1);continue}if(o===`"`)r=!0;else if(o===`{`)n++;else if(o===`}`&&--n===0)return bo(e,t,e.slice(t,a+1))}return null},`matchJsonObject`),Do=e((e,t)=>{let n=e.indexOf(`>>`,t);if(n===-1||/[\n\r]/.test(e.slice(t,n)))return null;let r=e.slice(t,n);return r.trim()?bo(e,t,r):null},`matchStereotypeText`),J=U({name:`LABEL_TEXT`,pattern:H.NA}),Oo=U({name:`WORD`,pattern:H.NA,categories:J}),ko=U({name:`NUMBER`,pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:J}),Y=U({name:`IDENTIFIER`,pattern:/\w+/,longer_alt:ko,categories:Oo}),Ao=U({name:`HWS`,pattern:/[\t ]+/,group:H.SKIPPED}),jo=U({name:`MARKDOWN_STRING`,pattern:xo,start_chars_hint:[`"`],line_breaks:!0}),Mo=U({name:`UNCLOSED_MARKDOWN_STRING`,pattern:/"`[^]*/,line_breaks:!0}),No=U({name:`COMMENT`,pattern:So,start_chars_hint:[`%`],line_breaks:!1}),Po=U({name:`NEWLINE`,pattern:/\r\n|\n|\r/,line_breaks:!0}),Fo=U({name:`ACC_DESCR_BLOCK`,pattern:To,start_chars_hint:[`a`],line_breaks:!0}),Io=/^accTitle[\t ]*:[^\n\r]*/,Lo=/^accDescr[\t ]*:[^\n\r]*/,Ro=U({name:`ACC_TITLE_LINE`,pattern:e((e,t)=>wo(e,t,Io),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),zo=U({name:`ACC_DESCR_LINE`,pattern:e((e,t)=>wo(e,t,Lo),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),Bo=U({name:`JSON_DECLARATION_START`,pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:`jsonBody`}),Vo=U({name:`JSON_OBJECT_LITERAL`,pattern:Eo,start_chars_hint:[`{`],line_breaks:!0,pop_mode:!0}),Ho=U({name:`UNCLOSED_JSON_OBJECT_LITERAL`,pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),X=e((e,t)=>U({name:e,pattern:t,longer_alt:Y,categories:Oo}),`keyword`),Uo=X(`USECASE`,/usecase-beta/),Wo=X(`ACTOR`,/actor/),Go=X(`SYSTEM_BOUNDARY`,/systemBoundary/),Ko=X(`END`,/end/),qo=X(`DIRECTION`,/direction/),Jo=X(`TD`,/TD/),Yo=X(`TB`,/TB/),Xo=X(`BT`,/BT/),Zo=X(`LR`,/LR/),Qo=X(`RL`,/RL/),$o=X(`NOTE`,/note/),es=X(`FOR`,/for/),ts=X(`JSON`,/json/),ns=X(`CLASS_DEF`,/classDef/),rs=X(`CLASS`,/class/),is=X(`STYLE`,/style/),as=X(`INCLUDE`,/include/i),os=X(`EXTEND`,/extend/i),ss=X(`TRUE`,/true/),cs=X(`FALSE`,/false/),ls=U({name:`GENERALIZATION`,pattern:/--\|>/}),us=U({name:`DEPENDENCY_ARROW`,pattern:/\.\.>/}),ds=U({name:`STEREOTYPE_START`,pattern:/<</,push_mode:`stereotype`}),fs=U({name:`STEREOTYPE_END`,pattern:/>>/,pop_mode:!0}),ps=U({name:`STEREOTYPE_TEXT`,pattern:Do,line_breaks:!1}),ms=U({name:`UNCLOSED_STEREOTYPE_TEXT`,pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),hs=U({name:`CLASS_SEPARATOR`,pattern:/:::/}),gs=U({name:`FORWARD_SOLID`,pattern:/--+>/}),_s=U({name:`BACKWARD_SOLID`,pattern:/<--+/}),vs=U({name:`FORWARD_CIRCLE`,pattern:/--o/}),ys=U({name:`BACKWARD_CIRCLE`,pattern:/o--/}),bs=U({name:`FORWARD_CROSS`,pattern:/--x/}),xs=U({name:`BACKWARD_CROSS`,pattern:/x--/}),Z=U({name:`MARKERLESS_SOLID`,pattern:/--+/}),Ss=U({name:`METADATA_START`,pattern:/@{/}),Cs=U({name:`AT`,pattern:/@/,categories:J}),ws=U({name:`LBRACE`,pattern:/{/}),Ts=U({name:`RBRACE`,pattern:/}/}),Es=U({name:`LBRACKET`,pattern:/\[/}),Ds=U({name:`RBRACKET`,pattern:/]/}),Os=U({name:`LPAREN`,pattern:/\(/}),ks=U({name:`RPAREN`,pattern:/\)/}),As=U({name:`COMMA`,pattern:/,/,categories:J}),js=U({name:`COLON`,pattern:/:/,categories:J}),Ms=U({name:`HASH_COLOR`,pattern:/#[\dA-Fa-f]+/,categories:J}),Ns=U({name:`PLAIN_STRING`,pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),Ps=U({name:`CSS_IDENTIFIER`,pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:J}),Fs=U({name:`CSS_ESCAPED_COMMA`,pattern:/\\,/,categories:J}),Is=U({name:`DASH`,pattern:/-/,categories:J}),Ls=U({name:`DOT`,pattern:/\./,categories:J}),Rs=U({name:`PERCENT`,pattern:/%/,categories:J}),zs=U({name:`CSS_PUNCTUATION`,pattern:/[!#$&*+/=?^_|~]/,categories:J}),Bs=[J,Oo,Ao,jo,Mo,No,Po,Fo,Ro,zo,Bo,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,hs,gs,_s,vs,ys,bs,xs,Z,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Y,ko,Fs,Is,Ls,Rs,zs,U({name:`LABEL_PUNCTUATION`,pattern:/[;<>\\`]/,categories:J}),U({name:`LABEL_SYMBOL`,pattern:/[^\t\n\r !-~]+/,categories:J})],Vs={defaultMode:`defaultMode`,modes:{defaultMode:[...Bs],jsonBody:[Vo,Ho],stereotype:[fs,ps,ms]}},Hs=[...Bs,Vo,Ho,fs,ps,ms],Us=new H(Vs),Ws=e(e=>Pr(e,J)||e.tokenType===Ns||e.tokenType===jo,`isLabelToken`),Gs={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Ks=new class extends Ra{static{e(this,`UsecaseParser`)}constructor(){super(Hs,{nodeLocationTracking:`full`}),this.RULE(`start`,()=>{this.CONSUME(Uo),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE(`line`,()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:e(()=>this.SUBRULE(this.commentLine),`ALT`)},{GATE:e(()=>this.isStatementStart(),`GATE`),ALT:e(()=>this.SUBRULE(this.statement),`ALT`)}])}),this.RULE(`statement`,()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.accTitleStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.accDescrStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.directionStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.actorStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.systemBoundaryStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.noteStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.jsonStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.classDefStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.classStatement),`ALT`)},{ALT:e(()=>this.SUBRULE(this.styleStatement),`ALT`)},{GATE:e(()=>this.isMetadataAssignment(),`GATE`),ALT:e(()=>this.SUBRULE(this.metadataAssignmentStatement),`ALT`)},{GATE:e(()=>!this.isForbiddenPlantUmlStatement(),`GATE`),ALT:e(()=>this.SUBRULE(this.entityStatement),`ALT`)}])}),this.RULE(`lineEnd`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Po),`ALT`)},{ALT:e(()=>this.CONSUME(Mr),`ALT`)}])}),this.RULE(`blankLine`,()=>{this.CONSUME(Po)}),this.RULE(`commentLine`,()=>{this.CONSUME(No),this.SUBRULE(this.lineEnd)}),this.RULE(`accTitleStatement`,()=>{this.CONSUME(Ro),this.SUBRULE(this.lineEnd)}),this.RULE(`accDescrStatement`,()=>{this.OR([{ALT:e(()=>this.CONSUME(zo),`ALT`)},{ALT:e(()=>this.CONSUME(Fo),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`actorStatement`,()=>{this.CONSUME(Wo),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:e(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(As),this.SUBRULE2(this.actorItem)}),`ALT`)},{ALT:e(()=>this.SUBRULE(this.relationTail),`ALT`)}])}),this.SUBRULE(this.lineEnd)}),this.RULE(`actorItem`,()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE(`actorName`,()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Os),this.SUBRULE(this.nodeLabel),this.CONSUME(ks)})},`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)}])}),this.RULE(`actorDeclarationOnly`,()=>{this.CONSUME(Wo),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(As),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE(`entityStatement`,()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE(`entityName`,()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE(this.nodeLabel),this.CONSUME(ks)},`ALT`)},{ALT:e(()=>{this.CONSUME(Es),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ds)},`ALT`)}])})},`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE(`nodeLabel`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(J)),`ALT`)}])}),this.RULE(`useCaseMetadata`,()=>{this.SUBRULE(this.metadata)}),this.RULE(`relationTail`,()=>{this.OPTION({GATE:e(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===Cs,`GATE`),DEF:e(()=>{this.CONSUME(Y),this.CONSUME(Cs)},`DEF`)}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE(`arrow`,()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.semanticRelation),`ALT`)},{ALT:e(()=>this.SUBRULE(this.forwardSolidOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.backwardSolidOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.markerlessSolidOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.forwardCircleOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.backwardCircleOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.forwardCrossOperator),`ALT`)},{ALT:e(()=>this.SUBRULE(this.backwardCrossOperator),`ALT`)}])}),this.RULE(`forwardSolidOperator`,()=>{this.CONSUME(gs)}),this.RULE(`backwardSolidOperator`,()=>{this.CONSUME(_s),this.OPTION({GATE:e(()=>this.LA(0).image===`<--`&&this.hasLabeledRight([Z]),`GATE`),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Z)},`DEF`)})}),this.RULE(`markerlessSolidOperator`,()=>{this.CONSUME(Z),this.OPTION({GATE:e(()=>this.LA(0).image===`--`&&this.hasLabeledRight([gs,Z,vs,bs]),`GATE`),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:e(()=>this.CONSUME(gs),`ALT`)},{ALT:e(()=>this.CONSUME2(Z),`ALT`)},{ALT:e(()=>this.CONSUME(vs),`ALT`)},{ALT:e(()=>this.CONSUME(bs),`ALT`)}])},`DEF`)})}),this.RULE(`forwardCircleOperator`,()=>{this.CONSUME(vs)}),this.RULE(`backwardCircleOperator`,()=>{this.CONSUME(ys),this.OPTION({GATE:e(()=>this.hasLabeledRight([Z]),`GATE`),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Z)},`DEF`)})}),this.RULE(`forwardCrossOperator`,()=>{this.CONSUME(bs)}),this.RULE(`backwardCrossOperator`,()=>{this.CONSUME(xs),this.OPTION({GATE:e(()=>this.hasLabeledRight([Z]),`GATE`),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Z)},`DEF`)})}),this.RULE(`edgeLabel`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(J)),`ALT`)}])}),this.RULE(`semanticRelation`,()=>{this.OR([{ALT:e(()=>{this.CONSUME(us),this.CONSUME(js),this.OR2([{ALT:e(()=>this.CONSUME(as),`ALT`)},{ALT:e(()=>this.CONSUME(os),`ALT`)}])},`ALT`)},{ALT:e(()=>this.CONSUME(ls),`ALT`)}])}),this.RULE(`metadata`,()=>{this.CONSUME(Ss),this.MANY(()=>this.CONSUME(Po)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(As)),this.MANY3(()=>this.CONSUME2(Po))}),this.CONSUME(Ts)}),this.RULE(`metadataProperty`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)}]),this.CONSUME(js),this.OR2([{ALT:e(()=>this.CONSUME2(Y),`ALT`)},{ALT:e(()=>this.CONSUME2(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(ss),`ALT`)},{ALT:e(()=>this.CONSUME(cs),`ALT`)}])}),this.RULE(`metadataSeparator`,()=>{this.OR([{ALT:e(()=>{this.CONSUME(As),this.MANY(()=>this.CONSUME(Po))},`ALT`)},{ALT:e(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Po)),this.OPTION(()=>this.CONSUME2(As)),this.MANY2(()=>this.CONSUME3(Po))},`ALT`)}])}),this.RULE(`systemBoundaryStatement`,()=>{this.CONSUME(Go),this.SUBRULE(this.systemBoundaryName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd),this.SUBRULE(this.systemBoundaryContent),this.CONSUME(Ko),this.SUBRULE2(this.lineEnd)}),this.RULE(`systemBoundaryName`,()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE(this.nodeLabel),this.CONSUME(ks)},`ALT`)},{ALT:e(()=>{this.CONSUME(Es),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ds)},`ALT`)}])})},`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)}])}),this.RULE(`systemBoundaryContent`,()=>{this.MANY(()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:e(()=>this.SUBRULE(this.commentLine),`ALT`)},{ALT:e(()=>this.SUBRULE(this.boundaryElement),`ALT`)}])})}),this.RULE(`boundaryElement`,()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.actorDeclarationOnly),`ALT`)},{ALT:e(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},`ALT`)}])}),this.RULE(`metadataAssignmentStatement`,()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE(`metadataAssignmentTarget`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(jo),`ALT`)}])}),this.RULE(`noteStatement`,()=>{this.CONSUME($o),this.CONSUME(es),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE(`stereotype`,()=>{this.CONSUME(ds),this.CONSUME(ps),this.CONSUME(fs)}),this.RULE(`classSuffix`,()=>{this.CONSUME(hs),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(As),this.CONSUME2(Y)})}),this.RULE(`jsonStatement`,()=>{this.CONSUME(Bo),this.CONSUME(Vo),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE(`directionStatement`,()=>{this.CONSUME(qo),this.OR([{ALT:e(()=>this.CONSUME(Jo),`ALT`)},{ALT:e(()=>this.CONSUME(Yo),`ALT`)},{ALT:e(()=>this.CONSUME(Xo),`ALT`)},{ALT:e(()=>this.CONSUME(Zo),`ALT`)},{ALT:e(()=>this.CONSUME(Qo),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`classDefStatement`,()=>{this.CONSUME(ns),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(As),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`classStatement`,()=>{this.CONSUME(rs),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(As),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(As),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE(`styleStatement`,()=>{this.CONSUME(is),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`styles`,()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(As),this.SUBRULE2(this.styleValue)})}),this.RULE(`styleValue`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Oo),`ALT`)},{ALT:e(()=>this.CONSUME(Ps),`ALT`)},{ALT:e(()=>{this.CONSUME(Z),this.CONSUME2(Oo)},`ALT`)}]),this.CONSUME(js),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE(`styleComponent`,()=>{this.OR([{ALT:e(()=>this.CONSUME(Oo),`ALT`)},{ALT:e(()=>this.CONSUME(Ns),`ALT`)},{ALT:e(()=>this.CONSUME(ko),`ALT`)},{ALT:e(()=>this.CONSUME(Ms),`ALT`)},{ALT:e(()=>this.CONSUME(Ps),`ALT`)},{ALT:e(()=>this.CONSUME(Fs),`ALT`)},{ALT:e(()=>this.CONSUME(Is),`ALT`)},{ALT:e(()=>this.CONSUME(Ls),`ALT`)},{ALT:e(()=>this.CONSUME(Rs),`ALT`)},{ALT:e(()=>this.CONSUME(zs),`ALT`)},{ALT:e(()=>this.CONSUME(js),`ALT`)},{ALT:e(()=>this.CONSUME(Os),`ALT`)},{ALT:e(()=>this.CONSUME(ks),`ALT`)},{ALT:e(()=>this.CONSUME(Es),`ALT`)},{ALT:e(()=>this.CONSUME(Ds),`ALT`)},{ALT:e(()=>this.CONSUME(ws),`ALT`)},{ALT:e(()=>this.CONSUME(Ts),`ALT`)},{ALT:e(()=>this.CONSUME(Cs),`ALT`)},{ALT:e(()=>this.CONSUME(Z),`ALT`)}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===Y||e===Ns||e===jo)&&this.LA(2).tokenType===Ss}isStatementStart(){let e=this.LA(1).tokenType;return e!==Mr&&e!==Po&&e!==No}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&Gs[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Ws(this.LA(1)))return!1;for(let t=2;;t++){let n=this.LA(t);if(e.includes(n.tokenType))return!0;if(!Ws(n))return!1}}},qs=class extends Error{constructor(e,t,n){super(`${e} (line ${t}, column ${n})`),this.line=t,this.column=n,this.name=`UsecaseJsonError`}static{e(this,`UsecaseJsonError`)}},Js=e((e,t,n,r)=>{let i=n,a=r,o=Math.min(Math.max(t,0),e.length);for(let t=0;t<o;t++){let n=e[t];n===`\r`?(i++,a=1):n===`
72
+ `?(t===0||e[t-1]!==`\r`)&&(i++,a=1):a++}return{line:i,column:a}},`locationAtOffset`),Ys=e((e,t,n,r)=>{let i=/\bposition (\d+)\b/u.exec(e);if(i)return Js(t,Number.parseInt(i[1],10),n,r);let a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){let e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:n+e-1,column:e===1?r+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return Js(t,t.length,n,r)},`locationFromErrorMessage`),Q=class extends Error{constructor(e){super(`Invalid JSON token`),this.offset=e}static{e(this,`JsonWalkError`)}},Xs=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{e(this,`PropertyOrderCollector`)}collect(){if(this.skipWhitespace(),this.collectValue(``),this.skipWhitespace(),this.offset!==this.text.length)throw new Q(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if(t===`{`)this.collectObject(e);else if(t===`[`)this.collectArray(e);else if(t===`"`)this.readString(!1);else if(t===`t`)this.consumeLiteral(`true`);else if(t===`f`)this.consumeLiteral(`false`);else if(t===`n`)this.consumeLiteral(`null`);else if(t===`-`||t>=`0`&&t<=`9`)this.consumeNumber();else throw new Q(this.offset)}collectObject(e){this.offset++;let t=[],n=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),this.text[this.offset]===`}`){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!==`"`)throw new Q(this.offset);let r=this.readString(!0),i=`${e}/${r.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`;if(n.has(r)?this.deletePointerSubtree(i):(n.add(r),t.push(r)),this.skipWhitespace(),this.text[this.offset]!==`:`)throw new Q(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),this.text[this.offset]===`}`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}readString(e){this.offset++;let t=``;for(;this.offset<this.text.length;){let n=this.offset,r=this.text[this.offset++];if(r===`"`)return t;if(r.charCodeAt(0)<32)throw new Q(n);if(r!==`\\`){e&&(t+=r);continue}let i=this.offset,a=this.text[this.offset++];switch(a){case`"`:case`\\`:case`/`:e&&(t+=a);break;case`b`:e&&(t+=`\b`);break;case`f`:e&&(t+=`\f`);break;case`n`:e&&(t+=`
73
+ `);break;case`r`:e&&(t+=`\r`);break;case`t`:e&&(t+=` `);break;case`u`:{let n=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(n))throw new Q(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(n,16))),this.offset+=4;break}default:throw new Q(i)}}throw new Q(this.offset)}consumeLiteral(e){let t=0;for(let n of e){if(this.text[this.offset+t]!==n)throw new Q(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]===`-`&&this.offset++,this.text[this.offset]===`0`)this.offset++;else if(this.text[this.offset]>=`1`&&this.text[this.offset]<=`9`)for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++;else throw new Q(this.offset);if(this.text[this.offset]===`.`){if(this.offset++,this.text[this.offset]<`0`||this.text[this.offset]>`9`)throw new Q(this.offset);for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++}if(this.text[this.offset]===`e`||this.text[this.offset]===`E`){if(this.offset++,(this.text[this.offset]===`+`||this.text[this.offset]===`-`)&&this.offset++,this.text[this.offset]<`0`||this.text[this.offset]>`9`)throw new Q(this.offset);for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(e!==` `&&e!==` `&&e!==`
74
+ `&&e!==`\r`)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let n of Object.keys(this.propertyOrder))(n===e||n.startsWith(t))&&delete this.propertyOrder[n]}};function Zs(e,t,n){let r;try{r=JSON.parse(e)}catch(r){let i=r instanceof Error?r.message:String(r),a=Ys(i,e,t,n);if(!a){let r=0;try{new Xs(e).collect()}catch(e){e instanceof Q&&(r=e.offset)}a=Js(e,r,t,n)}throw new qs(`Invalid JSON: ${i}`,a.line,a.column)}if(typeof r!=`object`||!r||Array.isArray(r))throw new qs(`JSON value must have an object root`,t,n);return{value:r,propertyOrder:new Xs(e).collect()}}e(Zs,`parseOrderedJsonObject`);var Qs=e(e=>({shape:e.type===`normal`?`actor`:e.type===`hollow`?`actor-hollow`:e.type===`awesome`?`actor-awesome`:`actor-icon`,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`actor`,actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),`actorNode`),$s=e(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`usecase`,useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),`useCaseNode`),ec=e(e=>({label:e.label,shape:`note`,attrs:{kind:`note`,target:e.target,labelType:e.labelType}}),`noteNode`),tc=e(e=>({label:e.id,shape:`json-table`,...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`json`,value:e.value,propertyOrder:e.propertyOrder,labelType:`text`}}),`jsonNode`),nc=e(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),`relationshipEdge`),rc=e(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:`note`,arrowType:K.LINE_SOLID,pattern:`dotted`,minlen:1,explicitId:!1,animate:!1,internal:!0}}),`noteEdge`),ic=e((e,t,n,r)=>{let i={};for(let t of e.getActors().values())i[t.id]=Qs(t);for(let t of e.getUseCases().values())i[t.id]=$s(t);for(let t of e.getNotes().values())i[t.id]=ec(t);for(let t of e.getJsonNodes().values())i[t.id]=tc(t);let a={};for(let t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:`systemBoundary`,boundaryType:t.type,labelType:t.labelType}};let o={};for(let t of e.getClassDefs().values())o[t.id]={styles:[...t.styles]};let s=e.getDirection();return{version:1,diagramType:`usecase`,source:t,header:{keyword:`usecase`,direction:s===`TD`?`TB`:s,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:i,edges:[...e.getRelationships().map(nc),...[...e.getNotes().values()].map(rc)],groups:a,classDefs:o,statements:r}},`buildUsecaseGraphAST`),$=e(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,`locationText`),ac=e(e=>e===void 0?``:` (label "${e}")`,`labelSuffix`),oc=e(e=>e.generated?e.label:void 0,`generatedFrom`),sc=e((e,t)=>{for(let n of t)e.includes(n)||e.push(n)},`pushUnique`),cc=class{constructor(e){this.db=e,this.source=``,this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{e(this,`UsecaseModelBuilder`)}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,n,r){this.metadataAssignments.push({target:e,targetLocation:t,metadata:n,statement:r})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,n){this.styleAssignments.push({target:e,location:t,styles:n})}setDirection(e){this.directions.push(e===`TD`?`TB`:e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let e of this.relationshipDrafts)this.recordFirst(i,e.source.id,e.source.location.span[0]),this.recordFirst(i,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(i,e.id,e.location.span[0]);let a=[...this.elements.map(e=>({offset:e.location.span[0],type:`element`,value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:`boundary`,value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:`json`,value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:`edge`,value:e}))].sort((e,t)=>e.offset-t.offset);for(let e of a)e.type===`element`?this.collectElement(e.value,t,n):e.type===`boundary`?this.collectBoundary(e.value,t,r):e.type===`json`?this.registerUnique(t,e.value.id,`json`,e.value.location,!1):this.registerUnique(t,e.value.explicitId,`edge`,e.value.explicitIdLocation,!1);this.materializeElements(n,i),this.materializeBoundaries(r,i),this.materializeJson(i);let o=this.materializeRelationships(t,n,i);this.reorderElements(n,i),this.applyMetadataAssignments(t,n,r,o),this.validateAndRefreshElements(n),this.refreshBoundaries(r,n),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,o),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let s=ic(this,this.source,e,this.statements);return this.model.ast=s,this.db.commit(this.model),s}collectElement(e,t,n){let r=t.get(e.id),i=oc({generated:e.generated,label:e.label.text});r&&r.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and ${e.kind}`,e.location,r.location,i,oc(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,oc(r));let a=n.get(e.id);if(!a){let r={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(r,e.metadata),n.set(e.id,r),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,sc(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,t,n){let r=t.get(e.id),i=oc({generated:e.generated,label:e.label.text});r&&r.kind!==`boundary`&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and boundary`,e.location,r.location,i,oc(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,oc(r));let a=n.get(e.id);if(a){(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),sc(a.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:`boundary`,location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.setElementModel(n)}materializeBoundaries(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??`rect`,members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,n)=>(e.get(t.id)??0)-(e.get(n.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,n){let r=new Map,i=0;for(let a of this.relationshipDrafts){let o=this.resolveEndpoint(a.source,e,t,n),s=this.resolveEndpoint(a.target,e,t,n);this.validateRelationship(a,o,s,e);let c=a.explicitId??`edge-${i++}`,l={id:c,explicitId:!!a.explicitId,source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(l),r.set(c,{draft:a,relationship:l})}return this.model.relationshipCounter=i,r}resolveEndpoint(e,t,n,r){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${$(e.location)}`);let i=t.get(e.id);return i?i.kind:(n.set(e.id,{kind:`usecase`,id:e.id,label:e.label,location:e.location,generated:e.generated,shape:`ellipse`,classes:[]}),t.set(e.id,{kind:`usecase`,location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(r,e.id,e.location.span[0]),`usecase`)}reorderElements(e,t){let n=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let i of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0))){!n.has(i.id)&&!r.has(i.id)&&this.setElementModel(i);let e=n.get(i.id)??this.model.actors.get(i.id),t=r.get(i.id)??this.model.useCases.get(i.id);e?this.model.actors.set(i.id,e):t&&this.model.useCases.set(i.id,t)}}applyMetadataAssignments(e,t,n,r){for(let i of this.metadataAssignments){let a=e.get(i.target);if(!a){let e=this.inferMetadataKind(i.metadata);throw Error(`Metadata target '${i.target}' is unresolved${e?` (metadata implies ${e})`:``} at ${$(i.targetLocation)}`)}if(a.kind===`actor`||a.kind===`usecase`)this.applyStandaloneElementMetadata(t.get(i.target),i.metadata);else if(a.kind===`boundary`){let e=n.get(i.target);for(let t of i.metadata.properties)(t.key!==`type`||t.value!==`rect`&&t.value!==`package`)&&this.invalidMetadata(i.target,a.kind,t),e.type=t.value}else if(a.kind===`edge`){let e=r.get(i.target);if(!e)throw Error(`Metadata target '${i.target}' is not an explicit edge at ${$(i.targetLocation)}`);i.statement.kind=`edgeMetadata`,i.statement.edges=[{id:i.target,span:i.statement.span,idSpan:i.targetLocation.span,...i.statement.metadata?{metadata:i.statement.metadata}:{}}],delete i.statement.nodes;for(let t of i.metadata.properties)t.key===`animate`&&typeof t.value==`boolean`?e.relationship.animate=t.value:t.key===`animation`&&(t.value===`fast`||t.value===`slow`)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(i.target,a.kind,t)}else for(let e of i.metadata.properties)this.invalidMetadata(i.target,a.kind,e)}for(let{relationship:e}of r.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!0):n.key===`business`&&typeof n.value==`boolean`?e.business=n.value:this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,t){if(t)for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!1):n.key===`business`&&typeof n.value==`boolean`?(e.business!==void 0&&e.business!==n.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,t,n){t.key===`type`&&(t.value===`normal`||t.value===`hollow`||t.value===`awesome`)?(!n&&e.actorType!==void 0&&e.actorType!==t.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):t.key===`icon`&&typeof t.value==`string`?(!n&&e.icon!==void 0&&e.icon!==t.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):t.key===`business`&&typeof t.value==`boolean`?(!n&&e.business!==void 0&&e.business!==t.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?`icon`:t.actorType??`normal`;if(t.kind===`actor`){if(t.icon&&t.actorType&&t.actorType!==`normal`)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${$(t.location)}`);if(t.business&&(e===`icon`||e===`awesome`))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${$(t.location)}`)}else if((t.shape??`ellipse`)===`rect`&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${$(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let n=e.get(t.parentId);if(!n)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${$(t.parentLocation??t.location)}`);n.members.includes(t.id)||n.members.push(t.id)}for(let n of t.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${$(n.parentLocation??n.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??`rect`,e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let n of this.noteDrafts){let r=e.get(n.target);if(!r)throw Error(`Note target '${n.target}' is unresolved at ${$(n.targetLocation)}`);r.kind!==`actor`&&r.kind!==`usecase`&&this.conflict(`Note target '${n.target}' must be an actor or use case, not ${r.kind}`,n.targetLocation,r.location);let i=`note-${t++}`;this.model.notes.set(i,{id:i,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let n of this.classAssignments)for(let r of n.targets)sc(this.getStylable(r.id,e,t,r.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,t,n.location).styles.push(...n.styles)}getStylable(e,t,n,r){let i=t.get(e)?.kind,a=i===`actor`?this.model.actors.get(e):i===`usecase`?this.model.useCases.get(e):i===`boundary`?this.model.systemBoundaries.get(e):i===`json`?this.model.jsonNodes.get(e):i===`edge`?n.get(e)?.relationship:void 0;if(!a)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${$(r)}`);return a}validateRelationship(t,n,r,i){let a=e(e=>e===`actor`||e===`usecase`||e===`json`,`allowed`);if(a(n)||this.conflict(`Relationship source '${t.source.id}' cannot be ${n}`,t.source.location,i.get(t.source.id).location),a(r)||this.conflict(`Relationship target '${t.target.id}' cannot be ${r}`,t.target.location,i.get(t.target.id).location),(t.type===`include`||t.type===`extend`)&&(n!==`usecase`||r!==`usecase`))throw Error(`${t.type} relationship requires use-case endpoints at ${$(t.location)}`);if(t.type===`generalization`&&(n!==`actor`&&n!==`usecase`||n!==r))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${$(t.location)}`);if(t.type===`association`&&(n===`json`||r===`json`)&&![0,1,2].includes(t.arrowType))throw Error(`JSON relationship '${t.source.id}' to '${t.target.id}' permits only point, reversed-point, or markerless solid association at ${$(t.location)}`)}setElementModel(e){if(e.kind===`actor`){let t=e.icon?`icon`:e.actorType??`normal`;this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??`ellipse`,business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let n of e.properties)if(n.key===`icon`)t.clear(),t.add(`actor`);else if(n.key===`animate`||n.key===`animation`)t.clear(),t.add(`edge`);else if(n.key===`type`)t.clear(),n.value===`rect`||n.value===`package`?t.add(`boundary`):(n.value===`normal`||n.value===`hollow`||n.value===`awesome`)&&t.add(`actor`);else if(n.key===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}invalidMetadata(e,t,n){throw Error(`Metadata property '${n.key}' is invalid for ${t} '${e}' at ${$(n.location)}`)}registerUnique(e,t,n,r,i){let a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${n})`,r,a.location,void 0,oc(a)),e.set(t,{kind:n,location:r,generated:i})}recordFirst(e,t,n){let r=e.get(t);(r===void 0||n<r)&&e.set(t,n)}conflict(e,t,n,r,i){throw Error(`${e} at ${$(t)}${ac(r)}; previous declaration at ${$(n)}${ac(i)}`)}},lc=Ks.getBaseCstVisitorConstructor(),uc=new class extends lc{constructor(){super(),this.builder=new cc(yo),this.source=``,this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{e(this,`UsecaseVisitor`)}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,`USECASE`)[0],n=[];for(let t of this.nodes(e,`line`))n.push(this.visit(t));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,`blankLine`,`commentLine`,`statement`);return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,`accTitleStatement`,`accDescrStatement`,`directionStatement`,`actorStatement`,`systemBoundaryStatement`,`noteStatement`,`jsonStatement`,`classDefStatement`,`classStatement`,`styleStatement`,`metadataAssignmentStatement`,`entityStatement`))}lineEnd(e){}blankLine(e){return{kind:`blank`,span:this.tokenSpan(this.tokens(e,`NEWLINE`)[0])}}commentLine(e){return{kind:`comment`,span:this.tokenSpan(this.tokens(e,`COMMENT`)[0])}}accTitleStatement(e){let t=this.tokens(e,`ACC_TITLE_LINE`)[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(`:`)+1).trim()),{kind:`accTitle`,span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,`ACC_DESCR_LINE`)[0],n=this.tokens(e,`ACC_DESCR_BLOCK`)[0],r=t?t.image.slice(t.image.indexOf(`:`)+1).trim():n.image.slice(n.image.indexOf(`{`)+1,n.image.lastIndexOf(`}`)).trim();return this.builder.setAccDescription(r),{kind:`accDescr`,span:[0,0]}}actorStatement(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e)),r=this.nodes(e,`relationTail`)[0],i=n.map((e,n)=>this.actorOccurrence(t[n],e,!0));for(let e of n)this.builder.addElement(this.actorDraft(e));if(!r)return{kind:`node`,span:[0,0],nodes:i};let a=this.visit(r);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));let o=this.relationshipDraft(n[0],a,this.nodeLocation(r));this.builder.addRelationship(o);let s=o.explicitId??`edge-${this.anonymousEdge++}`;return i.push(this.entityOccurrence(this.nodes(r.children,`entityName`)[0],a.target,a.target.explicitDeclaration)),{kind:`edge`,span:[0,0],nodes:i,edges:[{id:s,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,`actorName`)[0]),n=this.nodes(e,`metadata`)[0],r=this.nodes(e,`stereotype`)[0],i=this.nodes(e,`classSuffix`)[0],a=i?this.visit(i):{classes:[],spans:[]};return{...t,...n?{metadata:this.visit(n)}:{},...r?{stereotype:this.visit(r)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0],r=n?this.visit(n):this.tokenLabel(t);return{id:t.image,label:r,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e));for(let e of n)this.builder.addElement(this.actorDraft(e));return{kind:`node`,span:[0,0],nodes:n.map((e,n)=>this.actorOccurrence(t[n],e,!0))}}entityStatement(e){let t=this.nodes(e,`entityName`),n=this.visit(t[0]),r=this.nodes(e,`relationTail`)[0];if(!r)return n.explicitDeclaration=!0,n.shape??=`ellipse`,this.builder.addElement(this.entityDraft(n)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,!0)]};n.explicitDeclaration&&this.builder.addElement(this.entityDraft(n));let i=this.visit(r);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));let a={source:this.endpoint(n),target:this.endpoint(i.target),location:this.nodeLocation(r),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(a);let o=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:`edge`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(r.children,`entityName`)[0],i.target,i.target.explicitDeclaration)],edges:[{id:o,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0],r=this.nodes(e,`nodeLabel`)[0],i=this.nodes(e,`useCaseMetadata`)[0],a=this.nodes(e,`stereotype`)[0],o=this.nodes(e,`classSuffix`)[0],s=o?this.visit(o):{classes:[],spans:[]};if(t){let n=r?this.visit(r):this.tokenLabel(t),o=r?this.tokens(e,`LBRACKET`).length?`rect`:`ellipse`:void 0;return{id:t.image,label:n,location:this.tokenLocation(t),generated:!1,...o?{shape:o}:{},...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(o||i||a)}}let c=this.tokenLabel(n);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(n),generated:!0,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(i||a)}}nodeLabel(e){let t=this.allTokens(e);if(t.length===1&&(t[0].tokenType.name===`PLAIN_STRING`||t[0].tokenType.name===`MARKDOWN_STRING`))return this.tokenLabel(t[0]);let n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:`text`,span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,`metadata`)[0])}relationTail(e){let t=this.tokens(e,`IDENTIFIER`)[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,`arrow`)[0]),target:this.visit(this.nodes(e,`entityName`)[0])}}arrow(e){return this.visit(this.firstNode(e,`semanticRelation`,`forwardSolidOperator`,`backwardSolidOperator`,`markerlessSolidOperator`,`forwardCircleOperator`,`backwardCircleOperator`,`forwardCrossOperator`,`backwardCrossOperator`))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,`GENERALIZATION`).length)return{type:`generalization`,arrowType:K.SOLID_ARROW,minlen:1};let t=this.tokens(e,`INCLUDE`).length?`include`:`extend`,n=this.tokens(e,t===`include`?`INCLUDE`:`EXTEND`)[0];return{type:t,arrowType:K.SOLID_ARROW,label:{text:t,type:`text`,span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,`metadataProperty`).map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`COLON`),n=t[0],r=t[1],i=r.tokenType.name===`TRUE`||r.tokenType.name!==`FALSE`&&this.decodePlain(r),a=[n.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(n),value:i,span:a,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(r),location:this.tokenLocation(n)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,`systemBoundaryName`)[0]),n=this.nodes(e,`classSuffix`)[0],r=n?this.visit(n):{classes:[],spans:[]};t.classes=r.classes,this.builder.addBoundary(t);let i=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let a=this.nodes(e,`systemBoundaryContent`)[0],o=a?this.visit(a):[];this.parentBoundary=i;let s=this.tokens(e,`END`)[0],c=this.nodes(e,`metadata`)[0],l=c?this.visit(c):void 0,u={kind:`group`,span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(s),classSpans:r.spans,...l?{metadata:l.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...o.length?{children:o}:{}};return l&&this.builder.addMetadataAssignment(t.id,t.location,l,u),u}systemBoundaryName(e){let t=this.tokens(e,`IDENTIFIER`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0];return{id:t.image,label:n?this.visit(n):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0],r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,`blankLine`),...this.nodes(e,`commentLine`),...this.nodes(e,`boundaryElement`)].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,`actorDeclarationOnly`)[0];if(t)return this.visit(t);let n=this.nodes(e,`entityName`)[0],r=this.visit(n);return r.explicitDeclaration=!0,r.shape??=`ellipse`,this.builder.addElement(this.entityDraft(r)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(n,r,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,`metadataAssignmentTarget`)[0]),n=this.visit(this.nodes(e,`metadata`)[0]),r={kind:`metadata`,span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:n.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))};return this.builder.addMetadataAssignment(t.id,t.location,n,r),r}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],n=this.tokenLabel(t);return{id:t.tokenType.name===`IDENTIFIER`?t.image:this.generateId(n.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`nodeLabel`)[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:n,location:this.ctxLocation(e)}),{kind:`note`,span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,`STEREOTYPE_TEXT`)[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,`IDENTIFIER`);return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,`JSON_DECLARATION_START`)[0],n=this.tokens(e,`JSON_OBJECT_LITERAL`)[0],r=/^json[\t ]+(\w+)/.exec(t.image),i=r[1],a=r[0].length-i.length,o={span:[t.startOffset+a,t.startOffset+a+i.length],line:t.startLine??1,column:(t.startColumn??1)+a},s=Zs(n.image,n.startLine??1,n.startColumn??1),c=this.nodes(e,`classSuffix`)[0],l=c?this.visit(c):{classes:[],spans:[]},u={id:i,value:s.value,propertyOrder:s.propertyOrder,location:o,classes:l.classes};return this.builder.addJson(u),{kind:`json`,span:[0,0],nodes:[{id:i,span:o.span,idSpan:o.span,defines:!0,classSpans:l.spans}],classSpans:l.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>[`TD`,`TB`,`BT`,`RL`,`LR`].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:`direction`,span:[0,0]}}classDefStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addClassDef(t.map(e=>e.image),n),{kind:`classDef`,span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=1;for(;n<t.length&&this.source.slice((t[n-1].endOffset??t[n-1].startOffset)+1,t[n].startOffset).includes(`,`);n++);let r=t.slice(0,n).map(e=>({id:e.image,location:this.tokenLocation(e)})),i=t.slice(n).map(e=>e.image);return this.builder.addClassAssignment(r,i),{kind:`classAssign`,span:[0,0],ref:i[0],refSpan:this.tokenSpan(t[n]),nodes:r.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),n),{kind:`style`,span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,`styleValue`).map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll(`\\,`,`,`)}styleComponent(e){return this.allTokens(e).map(e=>e.image).join(``)}forwardSolidOperator(e){let t=this.tokens(e,`FORWARD_SOLID`)[0];return{type:`association`,arrowType:K.SOLID_ARROW,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,`BACKWARD_SOLID`)[0],n=this.nodes(e,`edgeLabel`)[0],r=n?this.tokens(e,`MARKERLESS_SOLID`).at(-1):t;return{type:`association`,arrowType:K.BACK_ARROW,minlen:this.solidMinlen(r),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,`edgeLabel`)[0],n=this.allTokens(e);if(!t)return{type:`association`,arrowType:K.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,`MARKERLESS_SOLID`)[0])};let r=n.at(-1),i=r.tokenType.name===`FORWARD_SOLID`?K.SOLID_ARROW:r.tokenType.name===`FORWARD_CIRCLE`?K.CIRCLE_ARROW:r.tokenType.name===`FORWARD_CROSS`?K.CROSS_ARROW:K.LINE_SOLID;return{type:`association`,arrowType:i,label:this.visit(t),minlen:i===K.SOLID_ARROW||i===K.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(e){return{type:`association`,arrowType:K.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:K.CIRCLE_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:`association`,arrowType:K.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:K.CROSS_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:`actor`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:`usecase`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,n){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:n,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,n){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...n?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,n){return this.actorOccurrence(e,t,n)}wrap(e,t){if(t.kind===`blank`||t.kind===`comment`)return t;t.span=this.nodeSpan(e);for(let e of t.edges??[])e.span=t.span;return t}tokenLabel(e){let t=e.tokenType.name===`MARKDOWN_STRING`?`markdown`:`text`,n=t===`markdown`?2:+(e.tokenType.name===`PLAIN_STRING`),r=this.tokenSpan(e,n);return{text:this.source.slice(r[0],r[1]),type:t,span:r}}decodePlain(e){return e.tokenType.name===`PLAIN_STRING`?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name===`PLAIN_STRING`?1:e.tokenType.name===`MARKDOWN_STRING`?2:0)}generateId(e){return e.replace(/\W/g,`_`)}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let t=e.tokenType.name===`PLAIN_STRING`?1:e.tokenType.name===`MARKDOWN_STRING`?2:0;return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);if(!n||!r)throw Error(`Usecase CST node has no source token`);return[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>`children`in e)}tokens(e,t){return(e[t]??[]).filter(e=>`tokenTypeIdx`in e)}firstNode(e,...t){for(let n of t){let t=this.nodes(e,n)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(`, `)}`)}allTokens(e){let t=[];for(let n of Object.values(e))for(let e of n)`tokenTypeIdx`in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},dc={parse:e(async t=>{yo.clear(),Ks.input=[];try{za({diagramType:`usecase`,lexer:Us,parser:Ks,entry:e(()=>Ks.start(),`entry`),visit:e(e=>uc.build(e,t),`visit`)},t)}catch(e){yo.clear();let n=Ks.errors[0];if(n){let{token:r}=n,i=Number.isFinite(r.startOffset)?r.startOffset:t.length,a=typeof r.endOffset==`number`&&Number.isFinite(r.endOffset)?r.endOffset+1:i,o=r.startLine??t.slice(0,i).split(/\r\n|\r|\n/).length,s=Math.max(t.lastIndexOf(`
75
+ `,i-1),t.lastIndexOf(`\r`,i-1)),c=r.startColumn??i-s,l=e instanceof Error?e.message:String(e);throw Error(`${l} at line ${o}, column ${c} [${i},${a})`)}throw e}},`parse`)},fc=[`point`,`circle`,`cross`,`extension`],pc={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},mc=e((e,t)=>{let[n,r]=[e,t].map(e=>e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`);return`usecase-${n}-${r}`},`usecaseDomId`),hc=e(e=>`usecase-${e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`}`,`usecaseNodeDomId`),gc=e((e,t)=>t===`markdown`?h(e).map(e=>e.map(e=>e.content).join(` `)).join(`
76
+ `):e,`getAccessibleLabel`),_c=e(e=>{let t=gc(e.label??e.id,e.labelType);if(pc[e.shape]){let n=e.actorType&&e.actorType!==`normal`?`${e.actorType} `:``;return`${e.business?`business `:``}${n}actor ${t}${e.stereotype?`, stereotype ${e.stereotype}`:``}`}if(e.shape===`note`)return`Note for ${e.noteTargetLabel??e.noteTarget??``}: ${t}`;if(e.shape===`usecaseJsonTable`){let n=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join(`; `);return n?`${t}: ${n}`:t}let n=e.stereotype?`, stereotype ${e.stereotype}`:``;return`${e.business?`business `:``}use case ${t}${n}`},`getUsecaseNodeAccessibleName`),vc=e(e=>`${e.boundaryType} system boundary ${gc(e.label??e.id,e.labelType)}`,`getUsecaseBoundaryAccessibleName`),yc=e(e=>e.relationshipType===`note`?``:`${e.relationshipType===`association`&&e.label?`association ${gc(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`,`getUsecaseEdgeAccessibleName`),bc=e(e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),`escapePlainLabel`),xc=e(e=>e.replace(/([*[\\\]_`])/g,`\\$1`),`escapeMarkdownMarkers`),Sc=e((e,t)=>{e.diagramId=t,e.markers=[...fc];for(let t of e.nodes){let e=t;if(e.domId=hc(t.id),t.label!==void 0&&t.labelType===`text`&&(t.label=bc(t.label)),t.stereotype&&=bc(t.stereotype),!t.isGroup&&t.shape===`usecaseJsonTable`&&(t.jsonRows=t.jsonRows?.map(e=>({...e,key:bc(e.key),value:bc(e.value)}))),!t.isGroup&&(t.shape===`usecaseEllipse`||t.shape===`rect`)&&t.stereotype){let n=t.label??bc(t.id);t.label=`\xAB${xc(t.stereotype)}\xBB<br/>${t.labelType===`text`?xc(n):n}`,t.labelType=`markdown`,e.hasFoldedStereotype=!0,delete t.stereotype}}for(let t of e.edges)t.label!==void 0&&t.labelType===`text`&&(t.label=bc(t.label));return e},`prepareUsecaseLayoutData`),Cc=e((e,t,r)=>{for(let n of t.nodes){let i=typeof n.domId==`string`?n.domId:mc(t.diagramId,n.id),a=e.select(`#${i}`),o=n.isGroup?`boundary`:pc[n.shape]?`actor`:n.shape===`note`?`note`:n.shape===`usecaseJsonTable`?`json`:`usecase`,s=r.nodes.get(n.id)??n.id;if(a.attr(`data-usecase-id`,n.id).attr(`data-usecase-kind`,o).attr(`role`,`img`).attr(`aria-label`,s),!n.isGroup&&(n.shape===`usecaseEllipse`||n.shape===`rect`)&&`hasFoldedStereotype`in n&&n.hasFoldedStereotype===!0){let e=a.node(),t=e?.querySelector(`.nodeLabel`),n=t?.querySelector(`p`)??t,r=n?.firstChild;if(n&&r?.nodeType===3){let e=n.ownerDocument.createElement(`span`);e.className=`usecase-stereotype`,n.insertBefore(e,r),e.appendChild(r)}else e?.querySelector(`.label tspan tspan, .label tspan`)?.classList.add(`usecase-stereotype`)}}let i=new Map(t.edges.map(e=>[e.id,e]));e.selectAll(`path[data-et="edge"]`).each(function(){let e=i.get(this.getAttribute(`data-id`)??``);if(!e)return;let a=n(this);a.attr(`id`,mc(t.diagramId,e.id)).attr(`data-usecase-id`,e.id).attr(`data-usecase-kind`,e.internal?`note-connector`:`relationship`),e.internal?a.attr(`aria-hidden`,`true`):a.attr(`role`,`img`).attr(`aria-label`,r.edges.get(e.id)??e.id)})},`annotateUsecaseElements`),wc=e((e,t)=>{e.style(`--mermaid-usecase-actor-font-size`,`${t.actorFontSize}px`).style(`--mermaid-usecase-actor-font-family`,t.actorFontFamily).style(`--mermaid-usecase-actor-font-weight`,t.actorFontWeight).style(`--mermaid-usecase-font-size`,`${t.usecaseFontSize}px`).style(`--mermaid-usecase-font-family`,t.usecaseFontFamily).style(`--mermaid-usecase-font-weight`,t.usecaseFontWeight)},`applyUsecaseFonts`),Tc={draw:e(async(e,n,r,i)=>{t.info(`Drawing usecase diagram (unified)`,n);let{layout:a}=d(),o=i.db,s=o.getData(),c=new Map(s.nodes.map(e=>[e.id,gc(e.label??e.id,e.labelType)])),l={nodes:new Map(s.nodes.map(e=>[e.id,e.isGroup?vc(e):_c(e.shape===`note`?{...e,noteTargetLabel:c.get(e.noteTarget??``)}:e)])),edges:new Map(s.edges.map(e=>[e.id,yc({...e,sourceLabel:c.get(e.source)??e.sourceLabel,targetLabel:c.get(e.target)??e.targetLabel})]))},u=ze(n,s.config.securityLevel);s.layoutAlgorithm=He(a),Sc(s,n),wc(u,s),await Ve(s,u),Cc(u,s,l);let f=s.diagramPadding;m.insertTitle(u,`usecaseDiagramTitleText`,0,o.getDiagramTitle?.()??``),Be(u,f,`usecaseDiagram`,s.useMaxWidth),wc(u,s)},`draw`)},Ec=e(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),`roleColors`),Dc=e(e=>{let{theme:t,bkgColorArray:n,borderColorArray:r}=e;if(!ee(t,r))return``;let i=o().usecase?.colorScheme===`rotate`,a=te(e.look),s=a===`handDrawn`,c=_(n),l=``;for(let e=0;e<g(r);e++){let t=r[e],o=c?`fill: ${n[e%n.length]};`:``,u=`[data-look="${a}"][data-color-id="color-${e}"]`;l+=`
77
+
78
+ & ${u}.system-boundary rect.boundary-body,
79
+ & ${u}.system-boundary rect.boundary-tab,
80
+ & ${u}.system-boundary .boundary-body path,
81
+ & ${u}.system-boundary .boundary-tab path {
82
+ stroke: ${t};
83
+ ${o}
84
+ }
85
+ `,i&&(l+=`
86
+
87
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
88
+ the business variant.
89
+
90
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
91
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
92
+ fill stroked in the background colour, with no class to tell them apart. Stroking
93
+ both repaints the fill lines as border colour and the shape collapses into a solid
94
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
95
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
96
+ & ${u}.usecase-element ellipse,
97
+ & ${u}.usecase-element rect {
98
+ stroke: ${t};
99
+ ${o}
100
+ }
101
+
102
+ /* The business marker is a single classed path, so it can be reached safely by name --
103
+ without it the marker keeps the uniform border beside a palette-coloured body. No
104
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
105
+ & ${u}.usecase-element .usecase-business-marker {
106
+ stroke: ${t};
107
+ }
108
+
109
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
110
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
111
+ winning and a hollow actor stays hollow. Same reason as above for not descending
112
+ into the handDrawn paths. */
113
+ & ${u}.usecase-actor .usecase-actor-shape,
114
+ & ${u}.usecase-actor .usecase-actor-hollow,
115
+ & ${u}.usecase-actor .usecase-actor-awesome,
116
+ & ${u}.usecase-actor .usecase-actor-icon {
117
+ stroke: ${t};
118
+ ${o}
119
+ }
120
+ ${s?``:`
121
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
122
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
123
+ and a value set directly on the child always beats one inherited from the parent,
124
+ whatever the parent rule's specificity. So name the children too.
125
+
126
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
127
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
128
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
129
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
130
+ & ${u}.usecase-actor .usecase-actor-glyph path,
131
+ & ${u}.usecase-actor .usecase-actor-glyph circle {
132
+ stroke: ${t};
133
+ }
134
+ `}
135
+ `)}return l},`genColor`),Oc={parser:dc,db:yo,renderer:Tc,styles:e(e=>{let t=Ec(e),n=te(e.look)===`handDrawn`;return`
136
+ ${Dc(e)}
137
+ & .usecase-actor {
138
+ color: ${e.actorTextColor??e.primaryTextColor};
139
+ }
140
+
141
+ & .usecase-actor-shape,
142
+ & .usecase-actor-hollow,
143
+ & .usecase-actor-awesome,
144
+ & .usecase-actor-icon {
145
+ fill: ${t.actorBkg};
146
+ stroke: ${t.actorBorder};
147
+ stroke-width: 2px;
148
+ }
149
+ ${n?``:`
150
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
151
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
152
+ the glyph's own paths, and a value set directly on a child always beats one inherited
153
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
154
+ without this every actor renders in the node border colour rather than the actor
155
+ colour the rule above asks for.
156
+
157
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
158
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
159
+ depend on which stylesheet is concatenated last.
160
+
161
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
162
+ & .node.usecase-actor .usecase-actor-glyph path,
163
+ & .node.usecase-actor .usecase-actor-glyph circle {
164
+ stroke: ${t.actorBorder};
165
+ }
166
+ `}
167
+ & .usecase-actor .nodeLabel,
168
+ & .actor-label {
169
+ color: ${e.actorTextColor??e.primaryTextColor};
170
+ fill: ${e.actorTextColor??e.primaryTextColor};
171
+ font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
172
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
173
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
174
+ }
175
+
176
+ & .usecase-element ellipse,
177
+ & .usecase-element rect,
178
+ & .usecase-business ellipse,
179
+ & .usecase-business rect {
180
+ fill: ${t.bkg};
181
+ stroke: ${t.border};
182
+ stroke-width: 2px;
183
+ }
184
+ ${n?``:`
185
+ /* The same interception the actor glyph hits, one element down: neo ships
186
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
187
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
188
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
189
+ equivalent neo rule and is already correct; restating it here costs nothing and means
190
+ the two forms cannot drift apart again.
191
+
192
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
193
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
194
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
195
+ exists. */
196
+ & [data-look="${te(e.look)}"].node.usecase-element ellipse,
197
+ & [data-look="${te(e.look)}"].node.usecase-element rect {
198
+ fill: ${t.bkg};
199
+ stroke: ${t.border};
200
+ }
201
+
202
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
203
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
204
+ & [data-look="${te(e.look)}"].node.usecase-element .usecase-business-marker {
205
+ stroke: ${t.border};
206
+ }
207
+ `}
208
+ & .usecase-element .nodeLabel,
209
+ & .usecase-label {
210
+ color: ${e.primaryTextColor};
211
+ fill: ${e.primaryTextColor};
212
+ font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
213
+ font-size: var(--mermaid-usecase-font-size, 12px);
214
+ font-weight: var(--mermaid-usecase-font-weight, normal);
215
+ }
216
+
217
+ & .usecase-stereotype,
218
+ & .usecase-business-marker {
219
+ color: ${e.primaryTextColor};
220
+ fill: ${e.primaryTextColor};
221
+ stroke: ${t.border};
222
+ }
223
+
224
+ & .system-boundary rect.boundary-body,
225
+ & .system-boundary rect.boundary-tab,
226
+ & .system-boundary-package-tab {
227
+ fill: ${t.boundaryBkg};
228
+ stroke: ${t.boundaryBorder};
229
+ stroke-width: 1px;
230
+ }
231
+
232
+ & .system-boundary-title text {
233
+ fill: ${e.titleColor??e.primaryTextColor};
234
+ }
235
+
236
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
237
+ 'color' on the span, and that has to stay inheritable by its children. */
238
+ & .system-boundary-title span {
239
+ color: ${e.titleColor??e.primaryTextColor};
240
+ }
241
+
242
+ & .usecase-note {
243
+ fill: ${e.noteBkgColor};
244
+ stroke: ${e.noteBorderColor};
245
+ color: ${e.noteTextColor};
246
+ }
247
+
248
+ & .usecase-note .nodeLabel {
249
+ color: ${e.noteTextColor};
250
+ fill: ${e.noteTextColor};
251
+ }
252
+
253
+ & .usecase-json-table,
254
+ & .usecase-json-table rect,
255
+ & .usecase-json-cell {
256
+ fill: ${e.mainBkg};
257
+ stroke: ${e.nodeBorder??e.primaryColor};
258
+ }
259
+
260
+ & .usecase-json-title,
261
+ & .usecase-json-key,
262
+ & .usecase-json-value {
263
+ color: ${e.primaryTextColor};
264
+ fill: ${e.primaryTextColor};
265
+ }
266
+
267
+ & .relationship {
268
+ fill: none;
269
+ stroke: ${e.lineColor};
270
+ }
271
+
272
+ & .relationship-include,
273
+ & .relationship-extend,
274
+ & .relationship-note {
275
+ stroke-dasharray: 3;
276
+ }
277
+
278
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
279
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
280
+ & .relationship-include {
281
+ stroke: ${t.includeLine};
282
+ }
283
+
284
+ & .relationship-extend {
285
+ stroke: ${t.extendLine};
286
+ }
287
+
288
+ & .relationship.edge-animation-fast,
289
+ & .relationship.edge-animation-slow {
290
+ stroke-linecap: round;
291
+ }
292
+
293
+ & .edgeLabel,
294
+ & .edgeLabel p {
295
+ background-color: ${e.edgeLabelBackground};
296
+ }
297
+
298
+ & .labelBkg {
299
+ background-color: ${e.edgeLabelBackground};
300
+ padding: 0 2px;
301
+ }
302
+
303
+ & .edgeLabel .label rect {
304
+ fill: ${e.edgeLabelBackground};
305
+ }
306
+
307
+ & .relationship-label,
308
+ & .edgeLabel {
309
+ color: ${e.primaryTextColor};
310
+ fill: ${e.primaryTextColor};
311
+ font-family: ${e.fontFamily};
312
+ font-size: 10px;
313
+ font-weight: normal;
314
+ }
315
+
316
+ & .marker,
317
+ & .marker.point,
318
+ & .marker.circle,
319
+ & .marker.cross {
320
+ fill: ${e.lineColor};
321
+ stroke: ${e.lineColor};
322
+ }
323
+
324
+ & .marker.extension {
325
+ fill: ${e.mainBkg};
326
+ stroke: ${e.lineColor};
327
+ }
328
+ `},`getStyles`)};export{Oc as diagram};