@softistx/pulsarix-widget 0.9.1 → 0.10.1

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 (131) hide show
  1. package/README.md +39 -27
  2. package/dist/chunks/{abnfDiagram-XWFEHMT6.xef4vppv.js → abnfDiagram-XWFEHMT6.9n16jbeh.js} +1 -1
  3. package/dist/chunks/architecture-WOLXFQ4H.04w48nbq.js +1 -0
  4. package/dist/chunks/architectureDiagram-CSQXQB3N.3c7xm6kb.js +36 -0
  5. package/dist/chunks/{blockDiagram-BEDRHYPZ.wgdr8xfr.js → blockDiagram-BEDRHYPZ.b7d9kkgr.js} +11 -11
  6. package/dist/chunks/{c4Diagram-M2UUVUY5.t09pndbz.js → c4Diagram-M2UUVUY5.f883rrpb.js} +3 -3
  7. package/dist/chunks/{chat-markdown-CQ4fSIYN.cv3fprzq.js → chat-markdown-BSu4FB_l.ngsfz1hc.js} +29 -29
  8. package/dist/chunks/{classDiagram-v2-KXABOMEV.9yfjtevj.js → classDiagram-v2-KXABOMEV.6gcf0jbx.js} +8 -8
  9. package/dist/chunks/cose-bilkent-JH36ORCC.900yznpf.js +1 -0
  10. package/dist/chunks/cynefin-EF2NZ3EQ.jp3enwcw.js +1 -0
  11. package/dist/chunks/{cynefinDiagram-NJNITYFG.k6mhek0s.js → cynefinDiagram-NJNITYFG.7y6esx64.js} +1 -1
  12. package/dist/chunks/{dagre-KIHZ2IZ3.sqeg911s.js → dagre-KIHZ2IZ3.2xtjsjjb.js} +2 -2
  13. package/dist/chunks/{diagram-7YQZDPLS.k1qvmctj.js → diagram-7YQZDPLS.5a4btxfh.js} +2 -2
  14. package/dist/chunks/{diagram-QBROCOUO.v7fe7e4g.js → diagram-QBROCOUO.je55sz0f.js} +24 -24
  15. package/dist/chunks/{diagram-RJJCUUZO.12s15pm6.js → diagram-RJJCUUZO.19nj7yqv.js} +4 -4
  16. package/dist/chunks/{diagram-WERXNKYE.tmrcv4we.js → diagram-WERXNKYE.h15fxc8e.js} +2 -2
  17. package/dist/chunks/diagram-YHHI257C.rjb588jf.js +3 -0
  18. package/dist/chunks/{diagram-YR4HJLHV.nytxr7pa.js → diagram-YR4HJLHV.5cj602t4.js} +1 -1
  19. package/dist/chunks/{ebnfDiagram-N527522P.6eqw92nv.js → ebnfDiagram-N527522P.edah3bz7.js} +1 -1
  20. package/dist/chunks/editor-shortcuts-dialog-Cz3T8435.kb0b5cra.js +1 -0
  21. package/dist/chunks/editor.ywaw7sz9.js +4 -0
  22. package/dist/chunks/{elk-O5DQBFGD.a5rqryhg.js → elk-O5DQBFGD.qnxmxe5n.js} +13 -13
  23. package/dist/chunks/emoji-picker-00Bw2c2b.2985hrzf.js +4 -0
  24. package/dist/chunks/{erDiagram-K3K3BIDK.exfeddaa.js → erDiagram-K3K3BIDK.9wh4fsa9.js} +8 -8
  25. package/dist/chunks/eventmodeling-K75KTNOO.xt3yb4h8.js +1 -0
  26. package/dist/chunks/{flow-diagram-Byy7DBZZ.pf5vdbkn.js → flow-diagram-DGZOc1z1.1276ykn3.js} +6 -6
  27. package/dist/chunks/flowDiagram-Z6JWZHQI.3t1zqq9x.js +1 -0
  28. package/dist/chunks/{ganttDiagram-3PRQTZWP.0tjaeqjw.js → ganttDiagram-3PRQTZWP.4t4r8jy0.js} +5 -5
  29. package/dist/chunks/gitGraph-VSP46ZUC.v9e8d46n.js +1 -0
  30. package/dist/chunks/{gitGraphDiagram-VXDFKS5L.6vvbj88t.js → gitGraphDiagram-VXDFKS5L.x4pypqh9.js} +19 -19
  31. package/dist/chunks/{grid-E2QIVN74.frpdy6t3.js → grid-E2QIVN74.8njsnft0.js} +1 -1
  32. package/dist/chunks/illustration-BcaGDjvB.ahkxq9mz.js +1 -0
  33. package/dist/chunks/{index.sv013f1z.js → index.0tz15aew.js} +1 -1
  34. package/dist/chunks/{index.zjykrx6y.js → index.0yskyw4t.js} +4 -4
  35. package/dist/chunks/{index.0kv7tp87.js → index.10k18jx6.js} +2 -2
  36. package/dist/chunks/{index.93zpfh3k.js → index.28jrnjz5.js} +2 -2
  37. package/dist/chunks/{index.f6jhkm5c.js → index.2j6fty9j.js} +35 -35
  38. package/dist/chunks/index.3c95g5mh.js +2 -0
  39. package/dist/chunks/{index.d8b8y928.js → index.3y8baz7q.js} +10 -10
  40. package/dist/chunks/{index.7q6v461v.js → index.5n55ccv6.js} +2 -2
  41. package/dist/chunks/{index.yfbwd99n.js → index.5sj251kq.js} +106 -106
  42. package/dist/chunks/{index.3pn4wy4j.js → index.a7m06kba.js} +1 -1
  43. package/dist/chunks/{index.fv9af3wd.js → index.d57x7pg9.js} +6 -6
  44. package/dist/chunks/{index.mcyw2bze.js → index.f1bfv6bh.js} +1 -1
  45. package/dist/chunks/{index.xrg5yg8d.js → index.gzgeb5ax.js} +2 -2
  46. package/dist/chunks/{index.nrd5w1x0.js → index.mjp06b03.js} +2 -2
  47. package/dist/chunks/{index.a6rz456z.js → index.mtrj86e8.js} +2 -2
  48. package/dist/chunks/index.n53k66q8.js +2 -0
  49. package/dist/chunks/index.pg4f51t3.js +44 -0
  50. package/dist/chunks/index.q39061xn.js +2 -0
  51. package/dist/chunks/{index.pyz71tqx.js → index.tnx5y2zc.js} +2 -2
  52. package/dist/chunks/{index.nsckd1vt.js → index.yhmqh641.js} +2 -2
  53. package/dist/chunks/{index.kh3f3gw8.js → index.znt11tbm.js} +2 -2
  54. package/dist/chunks/info-OHQRW6UA.atpz16bq.js +1 -0
  55. package/dist/chunks/{infoDiagram-EZ3ZOAHP.qh2bwz3m.js → infoDiagram-EZ3ZOAHP.mq5603w2.js} +2 -2
  56. package/dist/chunks/{ishikawaDiagram-S3EKX5GW.w2v6vnwd.js → ishikawaDiagram-S3EKX5GW.sx08qj3j.js} +5 -5
  57. package/dist/chunks/{journeyDiagram-POQNLL5X.ftkfdsrw.js → journeyDiagram-POQNLL5X.c3e37ws5.js} +5 -5
  58. package/dist/chunks/{kanban-definition-BH5XI6FM.9scqhcx5.js → kanban-definition-BH5XI6FM.6b85jkvt.js} +7 -7
  59. package/dist/chunks/markup-color-chrome-ykGNUl8y.76asgnkk.js +1 -0
  60. package/dist/chunks/markup-custom-color-MM-HnrqY.de5f5c2g.js +1 -0
  61. package/dist/chunks/mention-list-6cR5VSPa.r7r4w0q8.js +1 -0
  62. package/dist/chunks/{mermaid.core.tnh468qk.js → mermaid.core.kh4z9f22.js} +7 -7
  63. package/dist/chunks/{mindmap-definition-WVAN44T4.gskntx1f.js → mindmap-definition-WVAN44T4.07nv313g.js} +6 -6
  64. package/dist/chunks/packet-JDAUHWVQ.dmnq0wwq.js +1 -0
  65. package/dist/chunks/panel.zcphrx3e.js +7 -0
  66. package/dist/chunks/{pegDiagram-D4NLKWP3.yb58dpky.js → pegDiagram-D4NLKWP3.2mqrk2xy.js} +1 -1
  67. package/dist/chunks/pie-XZMESJXO.0rpk8mwa.js +1 -0
  68. package/dist/chunks/pieDiagram-36ENHN4W.kx9bhkyj.js +39 -0
  69. package/dist/chunks/plated-illustration-pTqcYOQg.a24pxzgf.js +1 -0
  70. package/dist/chunks/{quadrantDiagram-ZQUDMS73.1a721ces.js → quadrantDiagram-ZQUDMS73.68vxq0vb.js} +4 -4
  71. package/dist/chunks/radar-ABXABTNO.xt7snfyy.js +1 -0
  72. package/dist/chunks/railroad-I3PHUGI6.bjssfxkf.js +1 -0
  73. package/dist/chunks/railroad-abnf-LNEFI6M7.mchc5mex.js +1 -0
  74. package/dist/chunks/railroad-ebnf-DWYD2UWJ.wz1e7a1n.js +1 -0
  75. package/dist/chunks/railroad-peg-JR7BVNR7.xg4e4nsz.js +1 -0
  76. package/dist/chunks/{railroadDiagram-JIZHGYPL.xpgkt1zp.js → railroadDiagram-JIZHGYPL.dnj3h1n0.js} +1 -1
  77. package/dist/chunks/{render-VIF2ZAQL.khtqjmgm.js → render-VIF2ZAQL.cawqkxpf.js} +1 -1
  78. package/dist/chunks/{requirementDiagram-AXW2TVFA.ms6anxwg.js → requirementDiagram-AXW2TVFA.5z51j1hn.js} +4 -4
  79. package/dist/chunks/{sankeyDiagram-FBCJTAIF.40yzed7d.js → sankeyDiagram-FBCJTAIF.0dqdm7yd.js} +6 -6
  80. package/dist/chunks/{sequenceDiagram-3LA2ROMG.z0h3shw2.js → sequenceDiagram-3LA2ROMG.0fpdfwg0.js} +11 -11
  81. package/dist/chunks/{sizeCapture-2Q2CQKSF.4dh5g271.js → sizeCapture-2Q2CQKSF.gverqc02.js} +1 -1
  82. package/dist/chunks/{stateDiagram-v2-ATKHQDJO.5ftcgs8s.js → stateDiagram-v2-ATKHQDJO.56dj904f.js} +8 -8
  83. package/dist/chunks/{swimlanes-YQL5WMAO.r6vmskrb.js → swimlanes-YQL5WMAO.frj4npw4.js} +1 -1
  84. package/dist/chunks/swimlanesDiagram-UCCPES4V.834hahmm.js +8 -0
  85. package/dist/chunks/{timeline-definition-7Z437IG3.eke70hfq.js → timeline-definition-7Z437IG3.v99ghwdb.js} +9 -9
  86. package/dist/chunks/treeView-D4JQ5SDB.tbqcaq5q.js +1 -0
  87. package/dist/chunks/treemap-SAJKECNS.jgfv37a0.js +1 -0
  88. package/dist/chunks/{usecaseDiagram-RDK6N6HP.d8p4tnc6.js → usecaseDiagram-RDK6N6HP.b6317ne8.js} +57 -57
  89. package/dist/chunks/{vennDiagram-SHRQU5PJ.4s46abxd.js → vennDiagram-SHRQU5PJ.adr331gc.js} +7 -7
  90. package/dist/chunks/wardley-7MLQ67FV.4653yv6a.js +1 -0
  91. package/dist/chunks/{wardleyDiagram-F3OXNVQS.mq49fny4.js → wardleyDiagram-F3OXNVQS.5tt3knhg.js} +4 -4
  92. package/dist/chunks/{xychartDiagram-GDYJKCDI.d7he0fxa.js → xychartDiagram-GDYJKCDI.dqs1thzc.js} +5 -5
  93. package/dist/index.js +48 -21
  94. package/dist/types/config.d.ts +1 -1
  95. package/dist/types/mount.d.ts +1 -1
  96. package/docs/integration.md +32 -26
  97. package/package.json +4 -4
  98. package/dist/chunks/architecture-WOLXFQ4H.pp4drcrh.js +0 -1
  99. package/dist/chunks/architectureDiagram-CSQXQB3N.0bddzt5e.js +0 -36
  100. package/dist/chunks/cose-bilkent-JH36ORCC.qam7r9b1.js +0 -1
  101. package/dist/chunks/cynefin-EF2NZ3EQ.wgr8qmb2.js +0 -1
  102. package/dist/chunks/diagram-YHHI257C.7735ve6v.js +0 -3
  103. package/dist/chunks/editor-shortcuts-dialog-VmvMTjnq.mm7ab69f.js +0 -1
  104. package/dist/chunks/editor.wb4jsrjy.js +0 -4
  105. package/dist/chunks/emoji-picker-bnO0yA8e.bymgjc9a.js +0 -4
  106. package/dist/chunks/eventmodeling-K75KTNOO.nkahp6zg.js +0 -1
  107. package/dist/chunks/flowDiagram-Z6JWZHQI.54yz6gfm.js +0 -1
  108. package/dist/chunks/gitGraph-VSP46ZUC.2a0am491.js +0 -1
  109. package/dist/chunks/illustration-BfueshiW.syv54ccw.js +0 -1
  110. package/dist/chunks/index.bs3ygyp2.js +0 -2
  111. package/dist/chunks/index.newjn1k4.js +0 -2
  112. package/dist/chunks/index.rn0vxns6.js +0 -44
  113. package/dist/chunks/index.yexf86bf.js +0 -2
  114. package/dist/chunks/info-OHQRW6UA.4824y3cd.js +0 -1
  115. package/dist/chunks/markup-color-chrome-ykGNUl8y.8cysjsfb.js +0 -1
  116. package/dist/chunks/markup-custom-color-CytmKw-R.d25j0pcj.js +0 -1
  117. package/dist/chunks/mention-list-5h2lZwEU.wffam6eb.js +0 -1
  118. package/dist/chunks/packet-JDAUHWVQ.w0pv2dxr.js +0 -1
  119. package/dist/chunks/panel.dq8vt40k.js +0 -7
  120. package/dist/chunks/pie-XZMESJXO.zq72f2fq.js +0 -1
  121. package/dist/chunks/pieDiagram-36ENHN4W.7pgn8ayz.js +0 -39
  122. package/dist/chunks/plated-illustration-VrnsTz7H.tcyq0sxa.js +0 -1
  123. package/dist/chunks/radar-ABXABTNO.288gs0b8.js +0 -1
  124. package/dist/chunks/railroad-I3PHUGI6.aadrd13j.js +0 -1
  125. package/dist/chunks/railroad-abnf-LNEFI6M7.6btgmncj.js +0 -1
  126. package/dist/chunks/railroad-ebnf-DWYD2UWJ.y44ppt8p.js +0 -1
  127. package/dist/chunks/railroad-peg-JR7BVNR7.328jgxkz.js +0 -1
  128. package/dist/chunks/swimlanesDiagram-UCCPES4V.exhrz16x.js +0 -8
  129. package/dist/chunks/treeView-D4JQ5SDB.xz61fh4x.js +0 -1
  130. package/dist/chunks/treemap-SAJKECNS.8gv7pmqr.js +0 -1
  131. package/dist/chunks/wardley-7MLQ67FV.6v9j3be8.js +0 -1
@@ -1,63 +1,63 @@
1
- import{e,n,F,k,q,A,L,R,I,M,D,O,u,m,ve,he,pe,Ct,z,Ao,Ae,_e}from"./index.yfbwd99n.js";import{Ee}from"./index.newjn1k4.js";import{ge}from"./index.pyz71tqx.js";function tt(t){if(console&&console.error)console.error(`Error: ${t}`)}function Tt(t){if(console&&console.warn)console.warn(`Warning: ${t}`)}function gt(t){let s=new Date().getTime(),i=t();return{time:new Date().getTime()-s,value:i}}function At(t){function s(){}s.prototype=t;let i=new s;function r(){return typeof i.bar}return r(),r(),t;(0,eval)(t)}function $r(t){if(Gr(t))return t.LABEL;else return t.name}function Gr(t){return typeof t.LABEL==="string"&&t.LABEL!==""}class Oe{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),this.definition.forEach((s)=>{s.accept(t)})}}class B extends Oe{constructor(t){super([]);this.idx=1,Object.assign(this,be(t))}set definition(t){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(t){t.visit(this)}}class fe extends Oe{constructor(t){super(t.definition);this.orgText="",Object.assign(this,be(t))}}class G extends Oe{constructor(t){super(t.definition);this.ignoreAmbiguities=!1,Object.assign(this,be(t))}}class W extends Oe{constructor(t){super(t.definition);this.idx=1,Object.assign(this,be(t))}}class Z extends Oe{constructor(t){super(t.definition);this.idx=1,Object.assign(this,be(t))}}class Q extends Oe{constructor(t){super(t.definition);this.idx=1,Object.assign(this,be(t))}}class P extends Oe{constructor(t){super(t.definition);this.idx=1,Object.assign(this,be(t))}}class Y extends Oe{constructor(t){super(t.definition);this.idx=1,Object.assign(this,be(t))}}class J extends Oe{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition);this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,be(t))}}class w{constructor(t){this.idx=1,Object.assign(this,be(t))}accept(t){t.visit(this)}}function Wt(t){return t.map(st)}function st(t){function s(i){return i.map(st)}if(t instanceof B){let i={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(typeof t.label==="string")i.label=t.label;return i}else if(t instanceof G)return{type:"Alternative",definition:s(t.definition)};else if(t instanceof W)return{type:"Option",idx:t.idx,definition:s(t.definition)};else if(t instanceof Z)return{type:"RepetitionMandatory",idx:t.idx,definition:s(t.definition)};else if(t instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:st(new w({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof Y)return{type:"RepetitionWithSeparator",idx:t.idx,separator:st(new w({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof P)return{type:"Repetition",idx:t.idx,definition:s(t.definition)};else if(t instanceof J)return{type:"Alternation",idx:t.idx,definition:s(t.definition)};else if(t instanceof w){let i={type:"Terminal",name:t.terminalType.name,label:$r(t.terminalType),idx:t.idx};if(typeof t.label==="string")i.terminalLabel=t.label;let r=t.terminalType.PATTERN;if(t.terminalType.PATTERN)i.pattern=r instanceof RegExp?r.source:r;return i}else if(t instanceof fe)return{type:"Rule",name:t.name,orgText:t.orgText,definition:s(t.definition)};else throw Error("non exhaustive match")}function be(t){return Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0))}class me{visit(t){let s=t;switch(s.constructor){case B:return this.visitNonTerminal(s);case G:return this.visitAlternative(s);case W:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case Y:return this.visitRepetitionWithSeparator(s);case P:return this.visitRepetition(s);case J:return this.visitAlternation(s);case w:return this.visitTerminal(s);case fe:return this.visitRule(s);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}}function vs(t){return t instanceof G||t instanceof W||t instanceof P||t instanceof Z||t instanceof Q||t instanceof Y||t instanceof w||t instanceof fe}function je(t,s=[]){if(t instanceof W||t instanceof P||t instanceof Y)return!0;if(t instanceof J)return t.definition.some((r)=>je(r,s));else if(t instanceof B&&s.includes(t))return!1;else if(t instanceof Oe){if(t instanceof B)s.push(t);return t.definition.every((r)=>je(r,s))}else return!1}function Ms(t){return t instanceof J}function Te(t){if(t instanceof B)return"SUBRULE";else if(t instanceof W)return"OPTION";else if(t instanceof J)return"OR";else if(t instanceof Z)return"AT_LEAST_ONE";else if(t instanceof Q)return"AT_LEAST_ONE_SEP";else if(t instanceof Y)return"MANY_SEP";else if(t instanceof P)return"MANY";else if(t instanceof w)return"CONSUME";else throw Error("non exhaustive match")}class $e{walk(t,s=[]){t.definition.forEach((i,r)=>{let a=t.definition.slice(r+1);if(i instanceof B)this.walkProdRef(i,a,s);else if(i instanceof w)this.walkTerminal(i,a,s);else if(i instanceof G)this.walkFlat(i,a,s);else if(i instanceof W)this.walkOption(i,a,s);else if(i instanceof Z)this.walkAtLeastOne(i,a,s);else if(i instanceof Q)this.walkAtLeastOneSep(i,a,s);else if(i instanceof Y)this.walkManySep(i,a,s);else if(i instanceof P)this.walkMany(i,a,s);else if(i instanceof J)this.walkOr(i,a,s);else throw Error("non exhaustive match")})}walkTerminal(t,s,i){}walkProdRef(t,s,i){}walkFlat(t,s,i){let r=s.concat(i);this.walk(t,r)}walkOption(t,s,i){let r=s.concat(i);this.walk(t,r)}walkAtLeastOne(t,s,i){let r=[new W({definition:t.definition})].concat(s,i);this.walk(t,r)}walkAtLeastOneSep(t,s,i){let r=Nn(t,s,i);this.walk(t,r)}walkMany(t,s,i){let r=[new W({definition:t.definition})].concat(s,i);this.walk(t,r)}walkManySep(t,s,i){let r=Nn(t,s,i);this.walk(t,r)}walkOr(t,s,i){let r=s.concat(i);t.definition.forEach((a)=>{let o=new G({definition:[a]});this.walk(o,r)})}}function Nn(t,s,i){return[new W({definition:[new w({terminalType:t.separator})].concat(t.definition)})].concat(s,i)}function Ke(t){if(t instanceof B)return Ke(t.referencedRule);else if(t instanceof w)return Kr(t);else if(vs(t))return Wr(t);else if(Ms(t))return jr(t);else throw Error("non exhaustive match")}function Wr(t){let s=[],i=t.definition,r=0,a=i.length>r,o,c=!0;while(a&&c)o=i[r],c=je(o),s=s.concat(Ke(o)),r=r+1,a=i.length>r;return[...new Set(s)]}function jr(t){let s=t.definition.map((i)=>Ke(i));return[...new Set(s.flat())]}function Kr(t){return[t.terminalType]}var jt="_~IN~_";class In extends $e{constructor(t){super();this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,s,i){}walkProdRef(t,s,i){let r=Vr(t.referencedRule,t.idx)+this.topProd.name,a=s.concat(i),o=new G({definition:a}),c=Ke(o);this.follows[r]=c}}function kn(t){let s={};return t.forEach((i)=>{let r=new In(i).startWalking();Object.assign(s,r)}),s}function Vr(t,s){return t.name+s+jt}function C(t){return t.charCodeAt(0)}function Kt(t,s){if(Array.isArray(t))t.forEach(function(i){s.push(i)});else s.push(t)}function nt(t,s){if(t[s]===!0)throw"duplicate flag "+s;let i=t[s];t[s]=!0}function Ve(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function St(){throw Error("Internal Error - Should never get here!")}function ws(t){return t.type==="Character"}var Rt=[];for(let t=C("0");t<=C("9");t++)Rt.push(t);var yt=[C("_")].concat(Rt);for(let t=C("a");t<=C("z");t++)yt.push(t);for(let t=C("A");t<=C("Z");t++)yt.push(t);var Us=[C(" "),C("\f"),C(`
2
- `),C("\r"),C("\t"),C("\v"),C("\t"),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C("\u2028"),C("\u2029"),C(" "),C(" "),C(" "),C("\uFEFF")];var zr=/[0-9a-fA-F]/,Vt=/[0-9]/,Hr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let s=this.disjunction();this.consumeChar("/");let i={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(i,"global");break;case"i":nt(i,"ignoreCase");break;case"m":nt(i,"multiLine");break;case"u":nt(i,"unicode");break;case"y":nt(i,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:i,value:s,loc:this.loc(0)}}disjunction(){let t=[],s=this.idx;t.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(s)}}alternative(){let t=[],s=this.idx;while(this.isTerm())t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ve(s);let i=this.disjunction();return this.consumeChar(")"),{type:s,value:i,loc:this.loc(t)}}return St()}quantifier(t=!1){let s=void 0,i=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let r=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:r,atMost:r};break;case",":let a;if(this.isDigit())a=this.integerIncludingZero(),s={atLeast:r,atMost:a};else s={atLeast:r,atMost:1/0};this.consumeChar("}");break}if(t===!0&&s===void 0)return;Ve(s);break}if(t===!0&&s===void 0)return;if(Ve(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(i),s}}atom(){let t,s=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}if(t===void 0&&this.isPatternCharacter())t=this.patternCharacter();if(Ve(t)){if(t.loc=this.loc(s),this.isQuantifier())t.quantifier=this.quantifier();return t}return St()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
3
- `),C("\r"),C("\u2028"),C("\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 t,s=!1;switch(this.popChar()){case"d":t=Rt;break;case"D":t=Rt,s=!0;break;case"s":t=Us;break;case"S":t=Us,s=!0;break;case"w":t=yt;break;case"W":t=yt,s=!0;break}if(Ve(t))return{type:"Set",value:t,complement:s};return St()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=C("\f");break;case"n":t=C(`
4
- `);break;case"r":t=C("\r");break;case"t":t=C("\t");break;case"v":t=C("\v");break}if(Ve(t))return{type:"Character",value:t};return St()}controlLetterEscapeAtom(){this.consumeChar("c");let t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:C("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let t=this.popChar();return{type:"Character",value:C(t)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
1
+ import{e,n,B,k,q,A,L,R,I,M,P,O,u,p,ge,de,fe,Tt,F,_o,Se,Ee}from"./index.5sj251kq.js";import{Ce}from"./index.3c95g5mh.js";import{pe}from"./index.tnx5y2zc.js";function tt(t){if(console&&console.error)console.error(`Error: ${t}`)}function gt(t){if(console&&console.warn)console.warn(`Warning: ${t}`)}function At(t){let s=new Date().getTime(),i=t();return{time:new Date().getTime()-s,value:i}}function St(t){function s(){}s.prototype=t;let i=new s;function r(){return typeof i.bar}return r(),r(),t;(0,eval)(t)}function $r(t){if(Gr(t))return t.LABEL;else return t.name}function Gr(t){return typeof t.LABEL==="string"&&t.LABEL!==""}class Le{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),this.definition.forEach((s)=>{s.accept(t)})}}class G extends Le{constructor(t){super([]);this.idx=1,Object.assign(this,xe(t))}set definition(t){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(t){t.visit(this)}}class me extends Le{constructor(t){super(t.definition);this.orgText="",Object.assign(this,xe(t))}}class W extends Le{constructor(t){super(t.definition);this.ignoreAmbiguities=!1,Object.assign(this,xe(t))}}class j extends Le{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class Z extends Le{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class Q extends Le{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class D extends Le{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class Y extends Le{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class J extends Le{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition);this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,xe(t))}}class w{constructor(t){this.idx=1,Object.assign(this,xe(t))}accept(t){t.visit(this)}}function Wt(t){return t.map(st)}function st(t){function s(i){return i.map(st)}if(t instanceof G){let i={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(typeof t.label==="string")i.label=t.label;return i}else if(t instanceof W)return{type:"Alternative",definition:s(t.definition)};else if(t instanceof j)return{type:"Option",idx:t.idx,definition:s(t.definition)};else if(t instanceof Z)return{type:"RepetitionMandatory",idx:t.idx,definition:s(t.definition)};else if(t instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:st(new w({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof Y)return{type:"RepetitionWithSeparator",idx:t.idx,separator:st(new w({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof D)return{type:"Repetition",idx:t.idx,definition:s(t.definition)};else if(t instanceof J)return{type:"Alternation",idx:t.idx,definition:s(t.definition)};else if(t instanceof w){let i={type:"Terminal",name:t.terminalType.name,label:$r(t.terminalType),idx:t.idx};if(typeof t.label==="string")i.terminalLabel=t.label;let r=t.terminalType.PATTERN;if(t.terminalType.PATTERN)i.pattern=r instanceof RegExp?r.source:r;return i}else if(t instanceof me)return{type:"Rule",name:t.name,orgText:t.orgText,definition:s(t.definition)};else throw Error("non exhaustive match")}function xe(t){return Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0))}class Te{visit(t){let s=t;switch(s.constructor){case G:return this.visitNonTerminal(s);case W:return this.visitAlternative(s);case j:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case Y:return this.visitRepetitionWithSeparator(s);case D:return this.visitRepetition(s);case J:return this.visitAlternation(s);case w:return this.visitTerminal(s);case me:return this.visitRule(s);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}}function vs(t){return t instanceof W||t instanceof j||t instanceof D||t instanceof Z||t instanceof Q||t instanceof Y||t instanceof w||t instanceof me}function je(t,s=[]){if(t instanceof j||t instanceof D||t instanceof Y)return!0;if(t instanceof J)return t.definition.some((r)=>je(r,s));else if(t instanceof G&&s.includes(t))return!1;else if(t instanceof Le){if(t instanceof G)s.push(t);return t.definition.every((r)=>je(r,s))}else return!1}function Ms(t){return t instanceof J}function Ae(t){if(t instanceof G)return"SUBRULE";else if(t instanceof j)return"OPTION";else if(t instanceof J)return"OR";else if(t instanceof Z)return"AT_LEAST_ONE";else if(t instanceof Q)return"AT_LEAST_ONE_SEP";else if(t instanceof Y)return"MANY_SEP";else if(t instanceof D)return"MANY";else if(t instanceof w)return"CONSUME";else throw Error("non exhaustive match")}class $e{walk(t,s=[]){t.definition.forEach((i,r)=>{let a=t.definition.slice(r+1);if(i instanceof G)this.walkProdRef(i,a,s);else if(i instanceof w)this.walkTerminal(i,a,s);else if(i instanceof W)this.walkFlat(i,a,s);else if(i instanceof j)this.walkOption(i,a,s);else if(i instanceof Z)this.walkAtLeastOne(i,a,s);else if(i instanceof Q)this.walkAtLeastOneSep(i,a,s);else if(i instanceof Y)this.walkManySep(i,a,s);else if(i instanceof D)this.walkMany(i,a,s);else if(i instanceof J)this.walkOr(i,a,s);else throw Error("non exhaustive match")})}walkTerminal(t,s,i){}walkProdRef(t,s,i){}walkFlat(t,s,i){let r=s.concat(i);this.walk(t,r)}walkOption(t,s,i){let r=s.concat(i);this.walk(t,r)}walkAtLeastOne(t,s,i){let r=[new j({definition:t.definition})].concat(s,i);this.walk(t,r)}walkAtLeastOneSep(t,s,i){let r=Nn(t,s,i);this.walk(t,r)}walkMany(t,s,i){let r=[new j({definition:t.definition})].concat(s,i);this.walk(t,r)}walkManySep(t,s,i){let r=Nn(t,s,i);this.walk(t,r)}walkOr(t,s,i){let r=s.concat(i);t.definition.forEach((a)=>{let o=new W({definition:[a]});this.walk(o,r)})}}function Nn(t,s,i){return[new j({definition:[new w({terminalType:t.separator})].concat(t.definition)})].concat(s,i)}function Ke(t){if(t instanceof G)return Ke(t.referencedRule);else if(t instanceof w)return Kr(t);else if(vs(t))return Wr(t);else if(Ms(t))return jr(t);else throw Error("non exhaustive match")}function Wr(t){let s=[],i=t.definition,r=0,a=i.length>r,o,c=!0;while(a&&c)o=i[r],c=je(o),s=s.concat(Ke(o)),r=r+1,a=i.length>r;return[...new Set(s)]}function jr(t){let s=t.definition.map((i)=>Ke(i));return[...new Set(s.flat())]}function Kr(t){return[t.terminalType]}var jt="_~IN~_";class In extends $e{constructor(t){super();this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,s,i){}walkProdRef(t,s,i){let r=Vr(t.referencedRule,t.idx)+this.topProd.name,a=s.concat(i),o=new W({definition:a}),c=Ke(o);this.follows[r]=c}}function kn(t){let s={};return t.forEach((i)=>{let r=new In(i).startWalking();Object.assign(s,r)}),s}function Vr(t,s){return t.name+s+jt}function C(t){return t.charCodeAt(0)}function Kt(t,s){if(Array.isArray(t))t.forEach(function(i){s.push(i)});else s.push(t)}function nt(t,s){if(t[s]===!0)throw"duplicate flag "+s;let i=t[s];t[s]=!0}function Ve(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function Rt(){throw Error("Internal Error - Should never get here!")}function ws(t){return t.type==="Character"}var yt=[];for(let t=C("0");t<=C("9");t++)yt.push(t);var Ot=[C("_")].concat(yt);for(let t=C("a");t<=C("z");t++)Ot.push(t);for(let t=C("A");t<=C("Z");t++)Ot.push(t);var Us=[C(" "),C("\f"),C(`
2
+ `),C("\r"),C("\t"),C("\v"),C("\t"),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C("\u2028"),C("\u2029"),C(" "),C(" "),C(" "),C("\uFEFF")];var zr=/[0-9a-fA-F]/,Vt=/[0-9]/,Hr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let s=this.disjunction();this.consumeChar("/");let i={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(i,"global");break;case"i":nt(i,"ignoreCase");break;case"m":nt(i,"multiLine");break;case"u":nt(i,"unicode");break;case"y":nt(i,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:i,value:s,loc:this.loc(0)}}disjunction(){let t=[],s=this.idx;t.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(s)}}alternative(){let t=[],s=this.idx;while(this.isTerm())t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ve(s);let i=this.disjunction();return this.consumeChar(")"),{type:s,value:i,loc:this.loc(t)}}return Rt()}quantifier(t=!1){let s=void 0,i=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let r=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:r,atMost:r};break;case",":let a;if(this.isDigit())a=this.integerIncludingZero(),s={atLeast:r,atMost:a};else s={atLeast:r,atMost:1/0};this.consumeChar("}");break}if(t===!0&&s===void 0)return;Ve(s);break}if(t===!0&&s===void 0)return;if(Ve(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(i),s}}atom(){let t,s=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}if(t===void 0&&this.isPatternCharacter())t=this.patternCharacter();if(Ve(t)){if(t.loc=this.loc(s),this.isQuantifier())t.quantifier=this.quantifier();return t}return Rt()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
3
+ `),C("\r"),C("\u2028"),C("\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 t,s=!1;switch(this.popChar()){case"d":t=yt;break;case"D":t=yt,s=!0;break;case"s":t=Us;break;case"S":t=Us,s=!0;break;case"w":t=Ot;break;case"W":t=Ot,s=!0;break}if(Ve(t))return{type:"Set",value:t,complement:s};return Rt()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=C("\f");break;case"n":t=C(`
4
+ `);break;case"r":t=C("\r");break;case"t":t=C("\t");break;case"v":t=C("\v");break}if(Ve(t))return{type:"Character",value:t};return Rt()}controlLetterEscapeAtom(){this.consumeChar("c");let t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:C("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let t=this.popChar();return{type:"Character",value:C(t)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
5
  `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let t=this.popChar();return{type:"Character",value:C(t)}}}characterClass(){let t=[],s=!1;if(this.consumeChar("["),this.peekChar(0)==="^")this.consumeChar("^"),s=!0;while(this.isClassAtom()){let i=this.classAtom(),r=i.type==="Character";if(ws(i)&&this.isRangeDash()){this.consumeChar("-");let a=this.classAtom(),o=a.type==="Character";if(ws(a)){if(a.value<i.value)throw Error("Range out of order in character class");t.push({from:i.value,to:a.value})}else Kt(i.value,t),t.push(C("-")),Kt(a.value,t)}else Kt(i.value,t)}return this.consumeChar("]"),{type:"Set",complement:s,value:t}}classAtom(){switch(this.peekChar()){case"]":case`
6
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:C("\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 t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++;break}let s=this.disjunction();this.consumeChar(")");let i={type:"Group",capturing:t,value:s};if(t)i.idx=this.groupIdx;return i}positiveInteger(){let t=this.popChar();if(Hr.test(t)===!1)throw Error("Expecting a positive integer");while(Vt.test(this.peekChar(0)))t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(Vt.test(t)===!1)throw Error("Expecting an integer");while(Vt.test(this.peekChar(0)))t+=this.popChar();return parseInt(t,10)}patternCharacter(){let t=this.popChar();switch(t){case`
7
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:C(t)}}}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 Vt.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){case"]":case`
8
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 t=this.saveState();try{return this.quantifier(!0)!==void 0}catch(s){return!1}finally{this.restoreState(t)}}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(t){let s="";for(let r=0;r<t;r++){let a=this.popChar();if(zr.test(a)===!1)throw Error("Expecting a HexDecimal digits");s+=a}return{type:"Character",value:parseInt(s,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){let t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(t!==void 0&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}}class ze{visitChildren(t){for(let s in t){let i=t[s];if(t.hasOwnProperty(s)){if(i.type!==void 0)this.visit(i);else if(Array.isArray(i))i.forEach((r)=>{this.visit(r)},this)}}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Lookbehind":this.visitLookbehind(t);break;case"NegativeLookbehind":this.visitNegativeLookbehind(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t);break}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitLookbehind(t){}visitNegativeLookbehind(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}}var Ht={},Xr=new zt;function He(t){let s=t.toString();if(Ht.hasOwnProperty(s))return Ht[s];else{let i=Xr.pattern(s);return Ht[s]=i,i}}function Cn(){Ht={}}var _n="Complement Sets are not supported for first char optimization",Ot=`Unable to use "first char" lexer optimizations:
10
- `;function xn(t,s=!1){try{let i=He(t);return Ps(i.value,{},i.flags.ignoreCase)}catch(i){if(i.message===_n){if(s)Tt(`${Ot} Unable to optimize: < ${t.toString()} >
9
+ `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let s="";for(let r=0;r<t;r++){let a=this.popChar();if(zr.test(a)===!1)throw Error("Expecting a HexDecimal digits");s+=a}return{type:"Character",value:parseInt(s,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){let t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(t!==void 0&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}}class ze{visitChildren(t){for(let s in t){let i=t[s];if(t.hasOwnProperty(s)){if(i.type!==void 0)this.visit(i);else if(Array.isArray(i))i.forEach((r)=>{this.visit(r)},this)}}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Lookbehind":this.visitLookbehind(t);break;case"NegativeLookbehind":this.visitNegativeLookbehind(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t);break}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitLookbehind(t){}visitNegativeLookbehind(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}}var Ht={},Xr=new zt;function He(t){let s=t.toString();if(Ht.hasOwnProperty(s))return Ht[s];else{let i=Xr.pattern(s);return Ht[s]=i,i}}function Cn(){Ht={}}var _n="Complement Sets are not supported for first char optimization",Lt=`Unable to use "first char" lexer optimizations:
10
+ `;function xn(t,s=!1){try{let i=He(t);return Ps(i.value,{},i.flags.ignoreCase)}catch(i){if(i.message===_n){if(s)gt(`${Lt} Unable to optimize: < ${t.toString()} >
11
11
  Complement Sets cannot be automatically optimized.
12
12
  This will disable the lexer's first char optimizations.
13
13
  See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`)}else{let r="";if(s)r=`
14
14
  This will disable the lexer's first char optimizations.
15
- See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`;tt(`${Ot}
15
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`;tt(`${Lt}
16
16
  Failed parsing: < ${t.toString()} >
17
17
  Using the @chevrotain/regexp-to-ast library
18
- Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Ps(t,s,i){switch(t.type){case"Disjunction":for(let a=0;a<t.value.length;a++)Ps(t.value[a],s,i);break;case"Alternative":let r=t.value;for(let a=0;a<r.length;a++){let o=r[a];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let c=o;switch(c.type){case"Character":Xt(c.value,s,i);break;case"Set":if(c.complement===!0)throw Error(_n);c.value.forEach((l)=>{if(typeof l==="number")Xt(l,s,i);else{let d=l;if(i===!0)for(let p=d.from;p<=d.to;p++)Xt(p,s,i);else{for(let p=d.from;p<=d.to&&p<it;p++)Xt(p,s,i);if(d.to>=it){let p=d.from>=it?d.from:it,f=d.to,T=xe(p),g=xe(f);for(let x=T;x<=g;x++)s[x]=x}}}});break;case"Group":Ps(c.value,s,i);break;default:throw Error("Non Exhaustive Match")}let h=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&Ds(c)===!1||c.type!=="Group"&&h===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Xt(t,s,i){let r=xe(t);if(s[r]=r,i===!0)Yr(t,s)}function Yr(t,s){let i=String.fromCharCode(t),r=i.toUpperCase();if(r!==i){let a=xe(r.charCodeAt(0));s[a]=a}else{let a=i.toLowerCase();if(a!==i){let o=xe(a.charCodeAt(0));s[o]=o}}}function bn(t,s){return t.value.find((i)=>{if(typeof i==="number")return s.includes(i);else{let r=i;return s.find((a)=>r.from<=a&&a<=r.to)!==void 0}})}function Ds(t){let s=t.quantifier;if(s&&s.atLeast===0)return!0;if(!t.value)return!1;return Array.isArray(t.value)?t.value.every(Ds):Ds(t.value)}class vn extends ze{constructor(t){super();this.targetCharCodes=t,this.found=!1}visitChildren(t){if(this.found===!0)return;switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return;case"Lookbehind":this.visitLookbehind(t);return;case"NegativeLookbehind":this.visitNegativeLookbehind(t);return}super.visitChildren(t)}visitCharacter(t){if(this.targetCharCodes.includes(t.value))this.found=!0}visitSet(t){if(t.complement){if(bn(t,this.targetCharCodes)===void 0)this.found=!0}else if(bn(t,this.targetCharCodes)!==void 0)this.found=!0}}function Yt(t,s){if(s instanceof RegExp){let i=He(s),r=new vn(t);return r.visit(i),r.found}else{for(let i of s){let r=i.charCodeAt(0);if(t.includes(r))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",qt="modes",Zt=0,Lt=1,Qt=2,es=3;function wn(t,s){s=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
19
- `],tracer:(y,E)=>E()},s);let i=s.tracer;i("initCharCodeToOptimizedIndexMap",()=>{ma()});let r;i("Reject Lexer.NA",()=>{r=t.filter((y)=>y[Xe]!==K.NA)});let a=!1,o;i("Transform Patterns",()=>{a=!1,o=r.map((y)=>{let E=y[Xe];if(E instanceof RegExp){let _=E.source;if(_.length===1&&_!=="^"&&_!=="$"&&_!=="."&&!E.ignoreCase)return _;else if(_.length===2&&_[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(_[1]))return _[1];else return Mn(E)}else if(typeof E==="function")return a=!0,{exec:E};else if(typeof E==="object")return a=!0,E;else if(typeof E==="string")if(E.length===1)return E;else{let _=E.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(_);return Mn(te)}else throw Error("non exhaustive match")})});let c,h,l,d,p;i("misc mapping",()=>{c=r.map((y)=>y.tokenTypeIdx),h=r.map((y)=>{let E=y.GROUP;if(E===K.SKIPPED)return;else if(typeof E==="string")return E;else if(E===void 0)return!1;else throw Error("non exhaustive match")}),l=r.map((y)=>{let E=y.LONGER_ALT;if(E)return Array.isArray(E)?E.map((te)=>r.indexOf(te)):[r.indexOf(E)]}),d=r.map((y)=>y.PUSH_MODE),p=r.map((y)=>Object.hasOwn(y,"POP_MODE"))});let f;i("Line Terminator Handling",()=>{let y=Gn(s.lineTerminatorCharacters);if(f=r.map((E)=>!1),s.positionTracking!=="onlyOffset")f=r.map((E)=>{if(Object.hasOwn(E,"LINE_BREAKS"))return!!E.LINE_BREAKS;else return $n(E,y)===!1&&Yt(y,E.PATTERN)})});let T,g,x,v;i("Misc Mapping #2",()=>{T=r.map(Fn),g=o.map(pa),x=r.reduce((y,E)=>{let _=E.GROUP;if(typeof _==="string"&&_!==K.SKIPPED)y[_]=[];return y},{}),v=o.map((y,E)=>{let _=h[E]===void 0&&l[E]===void 0?qr(r[E].PATTERN):void 0;return{pattern:o[E],asciiClass:_,longerAlt:l[E],canLineTerminator:f[E],matchType:_!==void 0?es:g[E]!==!1?Zt:T[E]?Lt:Qt,short:g[E],group:h[E],push:d[E],pop:p[E],tokenTypeIdx:c[E],tokenType:r[E]}})});let b=!0,N=[];if(!s.safeMode)i("First Char Optimization",()=>{N=r.reduce((y,E,_)=>{if(typeof E.PATTERN==="string"){let te=E.PATTERN.charCodeAt(0),oe=xe(te);Fs(y,oe,v[_])}else if(Array.isArray(E.START_CHARS_HINT)){let te;E.START_CHARS_HINT.forEach((oe)=>{let pt=typeof oe==="string"?oe.charCodeAt(0):oe,Me=xe(pt);if(te!==Me)te=Me,Fs(y,Me,v[_])})}else if(E.PATTERN instanceof RegExp)if(E.PATTERN.unicode){if(b=!1,s.ensureOptimizations)tt(`${Ot} Unable to analyze < ${E.PATTERN.toString()} > pattern.
18
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function Ps(t,s,i){switch(t.type){case"Disjunction":for(let a=0;a<t.value.length;a++)Ps(t.value[a],s,i);break;case"Alternative":let r=t.value;for(let a=0;a<r.length;a++){let o=r[a];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let c=o;switch(c.type){case"Character":Xt(c.value,s,i);break;case"Set":if(c.complement===!0)throw Error(_n);c.value.forEach((l)=>{if(typeof l==="number")Xt(l,s,i);else{let d=l;if(i===!0)for(let f=d.from;f<=d.to;f++)Xt(f,s,i);else{for(let f=d.from;f<=d.to&&f<it;f++)Xt(f,s,i);if(d.to>=it){let f=d.from>=it?d.from:it,m=d.to,T=ve(f),g=ve(m);for(let x=T;x<=g;x++)s[x]=x}}}});break;case"Group":Ps(c.value,s,i);break;default:throw Error("Non Exhaustive Match")}let h=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&Ds(c)===!1||c.type!=="Group"&&h===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Xt(t,s,i){let r=ve(t);if(s[r]=r,i===!0)Yr(t,s)}function Yr(t,s){let i=String.fromCharCode(t),r=i.toUpperCase();if(r!==i){let a=ve(r.charCodeAt(0));s[a]=a}else{let a=i.toLowerCase();if(a!==i){let o=ve(a.charCodeAt(0));s[o]=o}}}function bn(t,s){return t.value.find((i)=>{if(typeof i==="number")return s.includes(i);else{let r=i;return s.find((a)=>r.from<=a&&a<=r.to)!==void 0}})}function Ds(t){let s=t.quantifier;if(s&&s.atLeast===0)return!0;if(!t.value)return!1;return Array.isArray(t.value)?t.value.every(Ds):Ds(t.value)}class vn extends ze{constructor(t){super();this.targetCharCodes=t,this.found=!1}visitChildren(t){if(this.found===!0)return;switch(t.type){case"Lookahead":this.visitLookahead(t);return;case"NegativeLookahead":this.visitNegativeLookahead(t);return;case"Lookbehind":this.visitLookbehind(t);return;case"NegativeLookbehind":this.visitNegativeLookbehind(t);return}super.visitChildren(t)}visitCharacter(t){if(this.targetCharCodes.includes(t.value))this.found=!0}visitSet(t){if(t.complement){if(bn(t,this.targetCharCodes)===void 0)this.found=!0}else if(bn(t,this.targetCharCodes)!==void 0)this.found=!0}}function Yt(t,s){if(s instanceof RegExp){let i=He(s),r=new vn(t);return r.visit(i),r.found}else{for(let i of s){let r=i.charCodeAt(0);if(t.includes(r))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",qt="modes",Zt=0,Nt=1,Qt=2,es=3;function wn(t,s){s=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
19
+ `],tracer:(y,E)=>E()},s);let i=s.tracer;i("initCharCodeToOptimizedIndexMap",()=>{ma()});let r;i("Reject Lexer.NA",()=>{r=t.filter((y)=>y[Xe]!==V.NA)});let a=!1,o;i("Transform Patterns",()=>{a=!1,o=r.map((y)=>{let E=y[Xe];if(E instanceof RegExp){let _=E.source;if(_.length===1&&_!=="^"&&_!=="$"&&_!=="."&&!E.ignoreCase)return _;else if(_.length===2&&_[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(_[1]))return _[1];else return Mn(E)}else if(typeof E==="function")return a=!0,{exec:E};else if(typeof E==="object")return a=!0,E;else if(typeof E==="string")if(E.length===1)return E;else{let _=E.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(_);return Mn(te)}else throw Error("non exhaustive match")})});let c,h,l,d,f;i("misc mapping",()=>{c=r.map((y)=>y.tokenTypeIdx),h=r.map((y)=>{let E=y.GROUP;if(E===V.SKIPPED)return;else if(typeof E==="string")return E;else if(E===void 0)return!1;else throw Error("non exhaustive match")}),l=r.map((y)=>{let E=y.LONGER_ALT;if(E)return Array.isArray(E)?E.map((te)=>r.indexOf(te)):[r.indexOf(E)]}),d=r.map((y)=>y.PUSH_MODE),f=r.map((y)=>Object.hasOwn(y,"POP_MODE"))});let m;i("Line Terminator Handling",()=>{let y=Gn(s.lineTerminatorCharacters);if(m=r.map((E)=>!1),s.positionTracking!=="onlyOffset")m=r.map((E)=>{if(Object.hasOwn(E,"LINE_BREAKS"))return!!E.LINE_BREAKS;else return $n(E,y)===!1&&Yt(y,E.PATTERN)})});let T,g,x,v;i("Misc Mapping #2",()=>{T=r.map(Fn),g=o.map(pa),x=r.reduce((y,E)=>{let _=E.GROUP;if(typeof _==="string"&&_!==V.SKIPPED)y[_]=[];return y},{}),v=o.map((y,E)=>{let _=h[E]===void 0&&l[E]===void 0?qr(r[E].PATTERN):void 0;return{pattern:o[E],asciiClass:_,longerAlt:l[E],canLineTerminator:m[E],matchType:_!==void 0?es:g[E]!==!1?Zt:T[E]?Nt:Qt,short:g[E],group:h[E],push:d[E],pop:f[E],tokenTypeIdx:c[E],tokenType:r[E]}})});let b=!0,N=[];if(!s.safeMode)i("First Char Optimization",()=>{N=r.reduce((y,E,_)=>{if(typeof E.PATTERN==="string"){let te=E.PATTERN.charCodeAt(0),oe=ve(te);Fs(y,oe,v[_])}else if(Array.isArray(E.START_CHARS_HINT)){let te;E.START_CHARS_HINT.forEach((oe)=>{let pt=typeof oe==="string"?oe.charCodeAt(0):oe,Me=ve(pt);if(te!==Me)te=Me,Fs(y,Me,v[_])})}else if(E.PATTERN instanceof RegExp)if(E.PATTERN.unicode){if(b=!1,s.ensureOptimizations)tt(`${Lt} Unable to analyze < ${E.PATTERN.toString()} > pattern.
20
20
  The regexp unicode flag is not currently supported by the regexp-to-ast library.
21
21
  This will disable the lexer's first char optimizations.
22
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(E.PATTERN,s.ensureOptimizations);if(te.length===0)b=!1;te.forEach((oe)=>{Fs(y,oe,v[_])})}else{if(s.ensureOptimizations)tt(`${Ot} TokenType: <${E.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
22
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(E.PATTERN,s.ensureOptimizations);if(te.length===0)b=!1;te.forEach((oe)=>{Fs(y,oe,v[_])})}else{if(s.ensureOptimizations)tt(`${Lt} TokenType: <${E.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
23
23
  This will disable the lexer's first char optimizations.
24
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`);b=!1}return y},[])});return{emptyGroups:x,patternIdxToConfig:v,charCodeToPatternIdxToConfig:N,hasCustom:a,canBeOptimized:b}}function qr(t){var s,i;if(!(t instanceof RegExp)||t.flags!=="")return;let r;try{r=He(t)}catch(h){return}if(r.value.value.length!==1||r.value.value[0].value.length!==1)return;let a=r.value.value[0].value[0],o;while(a.type==="Group"){if(a.capturing||a.quantifier!==void 0&&o!==void 0||a.value.value.length!==1||a.value.value[0].value.length!==1)return;o=(s=a.quantifier)!==null&&s!==void 0?s:o,a=a.value.value[0].value[0]}if(a.type!=="Set"||a.complement||a.quantifier!==void 0&&o!==void 0)return;if(o=(i=a.quantifier)!==null&&i!==void 0?i:o,(o===null||o===void 0?void 0:o.atLeast)!==1||o.atMost!==1/0||!o.greedy)return;let c=new Uint8Array(128);for(let h of a.value){let l=typeof h==="number"?h:h.from,d=typeof h==="number"?h:h.to;if(l<0||d>=c.length)return;c.fill(1,l,d+1)}return c}function Un(t,s){let i=[],r=Zr(t);i=i.concat(r.errors);let a=Qr(r.valid),o=a.valid;return i=i.concat(a.errors),i=i.concat(Jr(o)),i=i.concat(oa(o)),i=i.concat(la(o,s)),i=i.concat(ca(o)),i}function Jr(t){let s=[],i=t.filter((r)=>r[Xe]instanceof RegExp);return s=s.concat(ta(i)),s=s.concat(ia(i)),s=s.concat(ra(i)),s=s.concat(aa(i)),s=s.concat(sa(i)),s}function Zr(t){let s=t.filter((a)=>!Object.hasOwn(a,Xe)),i=s.map((a)=>({message:"Token Type: ->"+a.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[a]})),r=t.filter((a)=>!s.includes(a));return{errors:i,valid:r}}function Qr(t){let s=t.filter((a)=>{let o=a[Xe];return!(o instanceof RegExp)&&typeof o!=="function"&&!Object.hasOwn(o,"exec")&&typeof o!=="string"}),i=s.map((a)=>({message:"Token Type: ->"+a.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:j.INVALID_PATTERN,tokenTypes:[a]})),r=t.filter((a)=>!s.includes(a));return{errors:i,valid:r}}var ea=/[^\\][$]/;function ta(t){class s extends ze{constructor(){super(...arguments);this.found=!1}visitEndAnchor(a){this.found=!0}}return t.filter((a)=>{let o=a.PATTERN;try{let c=He(o),h=new s;return h.visit(c),h.found}catch(c){return ea.test(o.source)}}).map((a)=>({message:`Unexpected RegExp Anchor Error:
24
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`);b=!1}return y},[])});return{emptyGroups:x,patternIdxToConfig:v,charCodeToPatternIdxToConfig:N,hasCustom:a,canBeOptimized:b}}function qr(t){var s,i;if(!(t instanceof RegExp)||t.flags!=="")return;let r;try{r=He(t)}catch(h){return}if(r.value.value.length!==1||r.value.value[0].value.length!==1)return;let a=r.value.value[0].value[0],o;while(a.type==="Group"){if(a.capturing||a.quantifier!==void 0&&o!==void 0||a.value.value.length!==1||a.value.value[0].value.length!==1)return;o=(s=a.quantifier)!==null&&s!==void 0?s:o,a=a.value.value[0].value[0]}if(a.type!=="Set"||a.complement||a.quantifier!==void 0&&o!==void 0)return;if(o=(i=a.quantifier)!==null&&i!==void 0?i:o,(o===null||o===void 0?void 0:o.atLeast)!==1||o.atMost!==1/0||!o.greedy)return;let c=new Uint8Array(128);for(let h of a.value){let l=typeof h==="number"?h:h.from,d=typeof h==="number"?h:h.to;if(l<0||d>=c.length)return;c.fill(1,l,d+1)}return c}function Un(t,s){let i=[],r=Zr(t);i=i.concat(r.errors);let a=Qr(r.valid),o=a.valid;return i=i.concat(a.errors),i=i.concat(Jr(o)),i=i.concat(oa(o)),i=i.concat(la(o,s)),i=i.concat(ca(o)),i}function Jr(t){let s=[],i=t.filter((r)=>r[Xe]instanceof RegExp);return s=s.concat(ta(i)),s=s.concat(ia(i)),s=s.concat(ra(i)),s=s.concat(aa(i)),s=s.concat(sa(i)),s}function Zr(t){let s=t.filter((a)=>!Object.hasOwn(a,Xe)),i=s.map((a)=>({message:"Token Type: ->"+a.name+"<- missing static 'PATTERN' property",type:K.MISSING_PATTERN,tokenTypes:[a]})),r=t.filter((a)=>!s.includes(a));return{errors:i,valid:r}}function Qr(t){let s=t.filter((a)=>{let o=a[Xe];return!(o instanceof RegExp)&&typeof o!=="function"&&!Object.hasOwn(o,"exec")&&typeof o!=="string"}),i=s.map((a)=>({message:"Token Type: ->"+a.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:K.INVALID_PATTERN,tokenTypes:[a]})),r=t.filter((a)=>!s.includes(a));return{errors:i,valid:r}}var ea=/[^\\][$]/;function ta(t){class s extends ze{constructor(){super(...arguments);this.found=!1}visitEndAnchor(a){this.found=!0}}return t.filter((a)=>{let o=a.PATTERN;try{let c=He(o),h=new s;return h.visit(c),h.found}catch(c){return ea.test(o.source)}}).map((a)=>({message:`Unexpected RegExp Anchor Error:
25
25
  Token Type: ->`+a.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
26
- See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[a]}))}function sa(t){return t.filter((r)=>r.PATTERN.test("")).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[r]}))}var na=/[^\\[][\^]|^\^/;function ia(t){class s extends ze{constructor(){super(...arguments);this.found=!1}visitStartAnchor(a){this.found=!0}}return t.filter((a)=>{let o=a.PATTERN;try{let c=He(o),h=new s;return h.visit(c),h.found}catch(c){return na.test(o.source)}}).map((a)=>({message:`Unexpected RegExp Anchor Error:
26
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.EOI_ANCHOR_FOUND,tokenTypes:[a]}))}function sa(t){return t.filter((r)=>r.PATTERN.test("")).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:K.EMPTY_MATCH_PATTERN,tokenTypes:[r]}))}var na=/[^\\[][\^]|^\^/;function ia(t){class s extends ze{constructor(){super(...arguments);this.found=!1}visitStartAnchor(a){this.found=!0}}return t.filter((a)=>{let o=a.PATTERN;try{let c=He(o),h=new s;return h.visit(c),h.found}catch(c){return na.test(o.source)}}).map((a)=>({message:`Unexpected RegExp Anchor Error:
27
27
  Token Type: ->`+a.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
28
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[a]}))}function ra(t){return t.filter((r)=>{let a=r[Xe];return a instanceof RegExp&&(a.multiline||a.global)}).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}))}function aa(t){let s=[],i=t.map((o)=>t.reduce((c,h)=>{if(o.PATTERN.source===h.PATTERN.source&&!s.includes(h)&&h.PATTERN!==K.NA)return s.push(h),c.push(h),c;return c},[]));return i=i.filter(Boolean),i.filter((o)=>o.length>1).map((o)=>{let c=o.map((l)=>l.name);return{message:`The same RegExp pattern ->${o[0].PATTERN}<-has been used in all of the following Token Types: ${c.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}function oa(t){return t.filter((r)=>{if(!Object.hasOwn(r,"GROUP"))return!1;let a=r.GROUP;return a!==K.SKIPPED&&a!==K.NA&&typeof a!=="string"}).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}))}function la(t,s){return t.filter((a)=>a.PUSH_MODE!==void 0&&!s.includes(a.PUSH_MODE)).map((a)=>({message:`Token Type: ->${a.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${a.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[a]}))}function ca(t){let s=[],i=t.reduce((r,a,o)=>{let c=a.PATTERN;if(c===K.NA)return r;if(typeof c==="string")r.push({str:c,idx:o,tokenType:a});else if(c instanceof RegExp&&ua(c))r.push({str:c.source,idx:o,tokenType:a});return r},[]);return t.forEach((r,a)=>{i.forEach(({str:o,idx:c,tokenType:h})=>{if(a<c&&ha(o,r.PATTERN)){let l=`Token: ->${h.name}<- can never be matched.
28
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:K.SOI_ANCHOR_FOUND,tokenTypes:[a]}))}function ra(t){return t.filter((r)=>{let a=r[Xe];return a instanceof RegExp&&(a.multiline||a.global)}).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:K.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}))}function aa(t){let s=[],i=t.map((o)=>t.reduce((c,h)=>{if(o.PATTERN.source===h.PATTERN.source&&!s.includes(h)&&h.PATTERN!==V.NA)return s.push(h),c.push(h),c;return c},[]));return i=i.filter(Boolean),i.filter((o)=>o.length>1).map((o)=>{let c=o.map((l)=>l.name);return{message:`The same RegExp pattern ->${o[0].PATTERN}<-has been used in all of the following Token Types: ${c.join(", ")} <-`,type:K.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}function oa(t){return t.filter((r)=>{if(!Object.hasOwn(r,"GROUP"))return!1;let a=r.GROUP;return a!==V.SKIPPED&&a!==V.NA&&typeof a!=="string"}).map((r)=>({message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:K.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}))}function la(t,s){return t.filter((a)=>a.PUSH_MODE!==void 0&&!s.includes(a.PUSH_MODE)).map((a)=>({message:`Token Type: ->${a.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${a.PUSH_MODE}<-which does not exist`,type:K.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[a]}))}function ca(t){let s=[],i=t.reduce((r,a,o)=>{let c=a.PATTERN;if(c===V.NA)return r;if(typeof c==="string")r.push({str:c,idx:o,tokenType:a});else if(c instanceof RegExp&&ua(c))r.push({str:c.source,idx:o,tokenType:a});return r},[]);return t.forEach((r,a)=>{i.forEach(({str:o,idx:c,tokenType:h})=>{if(a<c&&ha(o,r.PATTERN)){let l=`Token: ->${h.name}<- can never be matched.
29
29
  Because it appears AFTER the Token Type ->${r.name}<-in the lexer's definition.
30
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;s.push({message:l,type:j.UNREACHABLE_PATTERN,tokenTypes:[r,h]})}})}),s}function ha(t,s){if(s instanceof RegExp){if(da(s))return!1;let i=s.exec(t);return i!==null&&i.index===0}else if(typeof s==="function")return s(t,0,[],{});else if(Object.hasOwn(s,"exec"))return s.exec(t,0,[],{});else if(typeof s==="string")return s===t;else throw Error("non exhaustive match")}function ua(t){return[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find((i)=>t.source.indexOf(i)!==-1)===void 0}function da(t){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source)}function Mn(t){let s=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,s)}function Pn(t,s,i){let r=[];if(!Object.hasOwn(t,rt))r.push({message:"A MultiMode Lexer cannot be initialized without a <"+rt+`> property in its definition
31
- `,type:j.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE});if(!Object.hasOwn(t,qt))r.push({message:"A MultiMode Lexer cannot be initialized without a <"+qt+`> property in its definition
32
- `,type:j.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY});if(Object.hasOwn(t,qt)&&Object.hasOwn(t,rt)&&!Object.hasOwn(t.modes,t.defaultMode))r.push({message:`A MultiMode Lexer cannot be initialized with a ${rt}: <${t.defaultMode}>which does not exist
33
- `,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST});if(Object.hasOwn(t,qt))Object.keys(t.modes).forEach((a)=>{let o=t.modes[a];o.forEach((c,h)=>{if(c===void 0)r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${a}> at index: <${h}>
34
- `,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(Object.hasOwn(c,"LONGER_ALT"))(Array.isArray(c.LONGER_ALT)?c.LONGER_ALT:[c.LONGER_ALT]).forEach((d)=>{if(d!==void 0&&!o.includes(d))r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${d.name}> on token <${c.name}> outside of mode <${a}>
35
- `,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})});return r}function Dn(t,s,i){let r=[],a=!1,c=Object.values(t.modes||{}).flat().filter(Boolean).filter((l)=>l[Xe]!==K.NA),h=Gn(i);if(s)c.forEach((l)=>{let d=$n(l,h);if(d!==!1){let f={message:fa(l,d),type:d.issue,tokenType:l};r.push(f)}else if(Object.hasOwn(l,"LINE_BREAKS")){if(l.LINE_BREAKS===!0)a=!0}else if(Yt(h,l.PATTERN))a=!0});if(s&&!a)r.push({message:`Warning: No LINE_BREAKS Found.
30
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;s.push({message:l,type:K.UNREACHABLE_PATTERN,tokenTypes:[r,h]})}})}),s}function ha(t,s){if(s instanceof RegExp){if(da(s))return!1;let i=s.exec(t);return i!==null&&i.index===0}else if(typeof s==="function")return s(t,0,[],{});else if(Object.hasOwn(s,"exec"))return s.exec(t,0,[],{});else if(typeof s==="string")return s===t;else throw Error("non exhaustive match")}function ua(t){return[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find((i)=>t.source.indexOf(i)!==-1)===void 0}function da(t){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source)}function Mn(t){let s=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,s)}function Pn(t,s,i){let r=[];if(!Object.hasOwn(t,rt))r.push({message:"A MultiMode Lexer cannot be initialized without a <"+rt+`> property in its definition
31
+ `,type:K.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE});if(!Object.hasOwn(t,qt))r.push({message:"A MultiMode Lexer cannot be initialized without a <"+qt+`> property in its definition
32
+ `,type:K.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY});if(Object.hasOwn(t,qt)&&Object.hasOwn(t,rt)&&!Object.hasOwn(t.modes,t.defaultMode))r.push({message:`A MultiMode Lexer cannot be initialized with a ${rt}: <${t.defaultMode}>which does not exist
33
+ `,type:K.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST});if(Object.hasOwn(t,qt))Object.keys(t.modes).forEach((a)=>{let o=t.modes[a];o.forEach((c,h)=>{if(c===void 0)r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${a}> at index: <${h}>
34
+ `,type:K.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(Object.hasOwn(c,"LONGER_ALT"))(Array.isArray(c.LONGER_ALT)?c.LONGER_ALT:[c.LONGER_ALT]).forEach((d)=>{if(d!==void 0&&!o.includes(d))r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${d.name}> on token <${c.name}> outside of mode <${a}>
35
+ `,type:K.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})});return r}function Dn(t,s,i){let r=[],a=!1,c=Object.values(t.modes||{}).flat().filter(Boolean).filter((l)=>l[Xe]!==V.NA),h=Gn(i);if(s)c.forEach((l)=>{let d=$n(l,h);if(d!==!1){let m={message:fa(l,d),type:d.issue,tokenType:l};r.push(m)}else if(Object.hasOwn(l,"LINE_BREAKS")){if(l.LINE_BREAKS===!0)a=!0}else if(Yt(h,l.PATTERN))a=!0});if(s&&!a)r.push({message:`Warning: No LINE_BREAKS Found.
36
36
  This Lexer has been defined to track line and column information,
37
37
  But none of the Token Types can be identified as matching a line terminator.
38
38
  See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
39
- for details.`,type:j.NO_LINE_BREAKS_FLAGS});return r}function Fn(t){let s=t.PATTERN;if(s instanceof RegExp)return!1;else if(typeof s==="function")return!0;else if(Object.hasOwn(s,"exec"))return!0;else if(typeof s==="string")return!1;else throw Error("non exhaustive match")}function pa(t){if(typeof t==="string"&&t.length===1)return t.charCodeAt(0);else return!1}var Bn={test:function(t){let s=t.length;for(let i=this.lastIndex;i<s;i++){let r=t.charCodeAt(i);if(r===10)return this.lastIndex=i+1,!0;else if(r===13){if(t.charCodeAt(i+1)===10)this.lastIndex=i+2;else this.lastIndex=i+1;return!0}}return!1},lastIndex:0};function $n(t,s){if(Object.hasOwn(t,"LINE_BREAKS"))return!1;else if(t.PATTERN instanceof RegExp){try{Yt(s,t.PATTERN)}catch(i){return{issue:j.IDENTIFY_TERMINATOR,errMsg:i.message}}return!1}else if(typeof t.PATTERN==="string")return!1;else if(Fn(t))return{issue:j.CUSTOM_LINE_BREAK};else throw Error("non exhaustive match")}function fa(t,s){if(s.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
39
+ for details.`,type:K.NO_LINE_BREAKS_FLAGS});return r}function Fn(t){let s=t.PATTERN;if(s instanceof RegExp)return!1;else if(typeof s==="function")return!0;else if(Object.hasOwn(s,"exec"))return!0;else if(typeof s==="string")return!1;else throw Error("non exhaustive match")}function pa(t){if(typeof t==="string"&&t.length===1)return t.charCodeAt(0);else return!1}var Bn={test:function(t){let s=t.length;for(let i=this.lastIndex;i<s;i++){let r=t.charCodeAt(i);if(r===10)return this.lastIndex=i+1,!0;else if(r===13){if(t.charCodeAt(i+1)===10)this.lastIndex=i+2;else this.lastIndex=i+1;return!0}}return!1},lastIndex:0};function $n(t,s){if(Object.hasOwn(t,"LINE_BREAKS"))return!1;else if(t.PATTERN instanceof RegExp){try{Yt(s,t.PATTERN)}catch(i){return{issue:K.IDENTIFY_TERMINATOR,errMsg:i.message}}return!1}else if(typeof t.PATTERN==="string")return!1;else if(Fn(t))return{issue:K.CUSTOM_LINE_BREAK};else throw Error("non exhaustive match")}function fa(t,s){if(s.issue===K.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
40
40
  The problem is in the <${t.name}> Token Type
41
41
  Root cause: ${s.errMsg}.
42
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;else if(s.issue===j.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
42
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;else if(s.issue===K.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
43
43
  The problem is in the <${t.name}> Token Type
44
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;else throw Error("non exhaustive match")}function Gn(t){return t.map((i)=>{if(typeof i==="string")return i.charCodeAt(0);else return i})}function Fs(t,s,i){if(t[s]===void 0)t[s]=[i];else t[s].push(i)}var it=256,Jt=[];function xe(t){return t<it?t:Jt[t]}function ma(){if(Jt.length===0){Jt=Array(65536);for(let t=0;t<65536;t++)Jt[t]=t>255?255+~~(t/255):t}}function Ue(t,s){let i=t.tokenTypeIdx;if(i===s.tokenTypeIdx)return!0;else return s.isParent===!0&&s.categoryMatchesMap[i]===!0}function at(t,s){return t.tokenTypeIdx===s.tokenTypeIdx}var Wn=1,Kn={};function Pe(t){let s=Ea(t);Ta(s),Aa(s),ga(s),s.forEach((i)=>{i.isParent=i.categoryMatches.length>0})}function Ea(t){let s=[...t],i=t,r=!0;while(r){i=i.map((o)=>o.CATEGORIES).flat().filter(Boolean);let a=i.filter((o)=>!s.includes(o));if(s=s.concat(a),a.length===0)r=!1;else i=a}return s}function Ta(t){t.forEach((s)=>{if(!Bs(s))Kn[Wn]=s,s.tokenTypeIdx=Wn++;if(jn(s)&&!Array.isArray(s.CATEGORIES))s.CATEGORIES=[s.CATEGORIES];if(!jn(s))s.CATEGORIES=[];if(!Sa(s))s.categoryMatches=[];if(!Ra(s))s.categoryMatchesMap={}})}function ga(t){t.forEach((s)=>{s.categoryMatches=[],Object.keys(s.categoryMatchesMap).forEach((i)=>{s.categoryMatches.push(Kn[i].tokenTypeIdx)})})}function Aa(t){t.forEach((s)=>{Vn([],s)})}function Vn(t,s){t.forEach((i)=>{s.categoryMatchesMap[i.tokenTypeIdx]=!0}),s.CATEGORIES.forEach((i)=>{let r=t.concat(s);if(!r.includes(i))Vn(r,i)})}function Bs(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"tokenTypeIdx")}function jn(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"CATEGORIES")}function Sa(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"categoryMatches")}function Ra(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"categoryMatchesMap")}function zn(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"tokenTypeIdx")}var $s={buildUnableToPopLexerModeMessage(t){return`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(t,s,i,r,a,o){return`unexpected character: ->${t.charAt(s)}<- at offset: ${s}, skipped ${i} characters.`}};var j;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));var Nt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
45
- `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Nt);class K{constructor(t,s=Nt){if(this.lexerDefinition=t,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(r,a)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${o}--> <${r}>`);let{time:c,value:h}=gt(a),l=c>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)l(`${o}<-- <${r}> time: ${c}ms`);return this.traceInitIndent--,h}else return a()},typeof s==="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
46
- a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Nt,s);let i=this.config.traceInitPerf;if(i===!0)this.traceInitMaxIdent=1/0,this.traceInitPerf=!0;else if(typeof i==="number")this.traceInitMaxIdent=i,this.traceInitPerf=!0;this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let r,a=!0;if(this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Nt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Bn;else if(this.config.lineTerminatorCharacters===Nt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
44
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;else throw Error("non exhaustive match")}function Gn(t){return t.map((i)=>{if(typeof i==="string")return i.charCodeAt(0);else return i})}function Fs(t,s,i){if(t[s]===void 0)t[s]=[i];else t[s].push(i)}var it=256,Jt=[];function ve(t){return t<it?t:Jt[t]}function ma(){if(Jt.length===0){Jt=Array(65536);for(let t=0;t<65536;t++)Jt[t]=t>255?255+~~(t/255):t}}function Ue(t,s){let i=t.tokenTypeIdx;if(i===s.tokenTypeIdx)return!0;else return s.isParent===!0&&s.categoryMatchesMap[i]===!0}function at(t,s){return t.tokenTypeIdx===s.tokenTypeIdx}var Wn=1,Kn={};function Pe(t){let s=Ea(t);Ta(s),Aa(s),ga(s),s.forEach((i)=>{i.isParent=i.categoryMatches.length>0})}function Ea(t){let s=[...t],i=t,r=!0;while(r){i=i.map((o)=>o.CATEGORIES).flat().filter(Boolean);let a=i.filter((o)=>!s.includes(o));if(s=s.concat(a),a.length===0)r=!1;else i=a}return s}function Ta(t){t.forEach((s)=>{if(!Bs(s))Kn[Wn]=s,s.tokenTypeIdx=Wn++;if(jn(s)&&!Array.isArray(s.CATEGORIES))s.CATEGORIES=[s.CATEGORIES];if(!jn(s))s.CATEGORIES=[];if(!Sa(s))s.categoryMatches=[];if(!Ra(s))s.categoryMatchesMap={}})}function ga(t){t.forEach((s)=>{s.categoryMatches=[],Object.keys(s.categoryMatchesMap).forEach((i)=>{s.categoryMatches.push(Kn[i].tokenTypeIdx)})})}function Aa(t){t.forEach((s)=>{Vn([],s)})}function Vn(t,s){t.forEach((i)=>{s.categoryMatchesMap[i.tokenTypeIdx]=!0}),s.CATEGORIES.forEach((i)=>{let r=t.concat(s);if(!r.includes(i))Vn(r,i)})}function Bs(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"tokenTypeIdx")}function jn(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"CATEGORIES")}function Sa(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"categoryMatches")}function Ra(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"categoryMatchesMap")}function zn(t){return Object.hasOwn(t!==null&&t!==void 0?t:{},"tokenTypeIdx")}var $s={buildUnableToPopLexerModeMessage(t){return`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(t,s,i,r,a,o){return`unexpected character: ->${t.charAt(s)}<- at offset: ${s}, skipped ${i} characters.`}};var K;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(K||(K={}));var It={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
45
+ `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(It);class V{constructor(t,s=It){if(this.lexerDefinition=t,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(r,a)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${o}--> <${r}>`);let{time:c,value:h}=At(a),l=c>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)l(`${o}<-- <${r}> time: ${c}ms`);return this.traceInitIndent--,h}else return a()},typeof s==="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
46
+ a boolean 2nd argument is no longer supported`);this.config=Object.assign({},It,s);let i=this.config.traceInitPerf;if(i===!0)this.traceInitMaxIdent=1/0,this.traceInitPerf=!0;else if(typeof i==="number")this.traceInitMaxIdent=i,this.traceInitPerf=!0;this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let r,a=!0;if(this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===It.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Bn;else if(this.config.lineTerminatorCharacters===It.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
47
47
  For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(s.safeMode&&s.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');if(this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(t))r={modes:{defaultMode:[...t]},defaultMode:rt};else a=!1,r=Object.assign({},t)}),this.config.skipValidations===!1)this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Pn(r,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Dn(r,this.trackStartLines,this.config.lineTerminatorCharacters))});r.modes=r.modes?r.modes:{},Object.entries(r.modes).forEach(([c,h])=>{r.modes[c]=h.filter((l)=>l!==void 0)});let o=Object.keys(r.modes);if(Object.entries(r.modes).forEach(([c,h])=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1)this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Un(h,o))});if(this.lexerDefinitionErrors.length===0){Pe(h);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=wn(h,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:s.positionTracking,ensureOptimizations:s.ensureOptimizations,safeMode:s.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=r.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let h=this.lexerDefinitionErrors.map((l)=>l.message).join(`-----------------------
48
48
  `);throw Error(`Errors detected in definition of Lexer:
49
- `+h)}this.lexerDefinitionWarning.forEach((c)=>{Tt(c.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(a)this.handleModes=()=>{};if(this.trackStartLines===!1)this.computeNewColumn=(c)=>c;if(this.trackEndLines===!1)this.updateTokenEndLineColumnLocation=()=>{};if(/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}"`);if(this.hasCustom)this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom;else this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let c=Object.entries(this.canModeBeOptimized).reduce((h,[l,d])=>{if(d===!1)h.push(l);return h},[]);if(s.ensureOptimizations&&c.length>0)throw Error(`Lexer Modes: < ${c.join(", ")} > cannot be optimized.
49
+ `+h)}this.lexerDefinitionWarning.forEach((c)=>{gt(c.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(a)this.handleModes=()=>{};if(this.trackStartLines===!1)this.computeNewColumn=(c)=>c;if(this.trackEndLines===!1)this.updateTokenEndLineColumnLocation=()=>{};if(/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}"`);if(this.hasCustom)this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom;else this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let c=Object.entries(this.canModeBeOptimized).reduce((h,[l,d])=>{if(d===!1)h.push(l);return h},[]);if(s.ensureOptimizations&&c.length>0)throw Error(`Lexer Modes: < ${c.join(", ")} > cannot be optimized.
50
50
  Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
51
- Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{At(this)})})}tokenize(t,s=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let r=this.lexerDefinitionErrors.map((a)=>a.message).join(`-----------------------
51
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{St(this)})})}tokenize(t,s=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let r=this.lexerDefinitionErrors.map((a)=>a.message).join(`-----------------------
52
52
  `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
53
- `+r)}return this.tokenizeInternal(t,s)}tokenizeInternal(t,s){let i,r,a,o,c,h,l,d,p,f,T,g,x,v,b,N=t,y=N.length,E=0,_=0,te=this.hasCustom?0:Math.floor(t.length/10),oe=Array(te),pt=[],Me=this.trackStartLines?1:void 0,Ce=this.trackStartLines?1:void 0,et={};for(let se=0;se<this.cachedGroupKeys.length;se++)et[this.cachedGroupKeys[se]]=[];let Fr=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,Br=(se)=>{if(mt.length===1&&se.tokenType.PUSH_MODE===void 0){let ye=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(se);pt.push({offset:se.startOffset,line:se.startLine,column:se.startColumn,length:se.image.length,message:ye})}else{mt.pop();let ye=mt.at(-1);We=this.patternIdxToConfig[ye],ft=this.charCodeToPatternIdxToConfig[ye],Cs=We.length;let bs=this.canModeBeOptimized[ye]&&this.config.safeMode===!1;if(ft&&bs)Et=!0;else Et=!1}};function On(se){mt.push(se),ft=this.charCodeToPatternIdxToConfig[se],We=this.patternIdxToConfig[se],Cs=We.length;let ye=this.canModeBeOptimized[se]&&this.config.safeMode===!1;if(ft&&ye)Et=!0;else Et=!1}On.call(this,s);let Re,Ln=this.config.recoveryEnabled;while(E<y){h=null,p=-1;let se=N.charCodeAt(E),ye;if(Et){let re=xe(se),de=ft[re];ye=de!==void 0?de:yn}else ye=We;let bs=ye.length;for(i=0;i<bs;i++){Re=ye[i];let re=Re.pattern;switch(l=null,Re.matchType){case Zt:if(se===Re.short)p=1,h=re;break;case Lt:if(b=re.exec(N,E,oe,et),b!==null){if(h=b[0],p=h.length,b.payload!==void 0)l=b.payload}else h=null;break;case es:{let de=Re.asciiClass;if(de[se]!==1){re.lastIndex=0;break}let ce=E+1;while(de[N.charCodeAt(ce)]===1)ce++;p=ce-E,re.lastIndex=ce;break}case Qt:re.lastIndex=E,p=this.matchLength(re,t,E);break}if(p!==-1){if(c=Re.longerAlt,c!==void 0){h=t.substring(E,E+p);let de=c.length;for(a=0;a<de;a++){let ce=We[c[a]],we=ce.pattern;if(d=null,ce.matchType===Lt)if(b=we.exec(N,E,oe,et),b!==null){if(o=b[0],b.payload!==void 0)d=b.payload}else o=null;else we.lastIndex=E,o=this.match(we,t,E);if(o&&o.length>h.length){h=o,p=o.length,l=d,Re=ce;break}}}break}}if(p!==-1){if(f=Re.group,f!==void 0)if(h=h!==null?h:t.substring(E,E+p),T=Re.tokenTypeIdx,g=this.createTokenInstance(h,E,T,Re.tokenType,Me,Ce,p),this.handlePayload(g,l),f===!1)_=this.addToken(oe,_,g);else et[f].push(g);if(Fr===!0&&Re.canLineTerminator===!0){let re=0,de,ce;ks.lastIndex=0;do if(h=h!==null?h:t.substring(E,E+p),de=ks.test(h),de===!0)ce=ks.lastIndex-1,re++;while(de===!0);if(re!==0)Me=Me+re,Ce=p-ce,this.updateTokenEndLineColumnLocation(g,f,ce,re,Me,Ce,p);else Ce=this.computeNewColumn(Ce,p)}else Ce=this.computeNewColumn(Ce,p);E=E+p,this.handleModes(Re,Br,On,g)}else{let re=E,de=Me,ce=Ce,we=Ln===!1;while(we===!1&&E<y){E++;for(r=0;r<Cs;r++){let _s=We[r],xs=_s.pattern;switch(_s.matchType){case Zt:if(N.charCodeAt(E)===_s.short)we=!0;break;case Lt:we=xs.exec(N,E,oe,et)!==null;break;case es:case Qt:xs.lastIndex=E,we=xs.exec(t)!==null;break}if(we===!0)break}}if(x=E-re,Ce=this.computeNewColumn(Ce,x),v=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,re,x,de,ce,mt.at(-1)),pt.push({offset:re,line:de,column:ce,length:x,message:v}),Ln===!1)break}}if(!this.hasCustom)oe.length=_;return{tokens:oe,groups:et,errors:pt}}handleModes(t,s,i,r){if(t.pop===!0){let a=t.push;if(s(r),a!==void 0)i.call(this,a)}else if(t.push!==void 0)i.call(this,t.push)}updateTokenEndLineColumnLocation(t,s,i,r,a,o,c){let h,l;if(s!==void 0){if(h=i===c-1,l=h?-1:0,!(r===1&&h===!0))t.endLine=a+l,t.endColumn=o-1+-l}}computeNewColumn(t,s){return t+s}createOffsetOnlyToken(t,s,i,r){return{image:t,startOffset:s,tokenTypeIdx:i,tokenType:r}}createStartOnlyToken(t,s,i,r,a,o){return{image:t,startOffset:s,startLine:a,startColumn:o,tokenTypeIdx:i,tokenType:r}}createFullToken(t,s,i,r,a,o,c){return{image:t,startOffset:s,endOffset:s+c-1,startLine:a,endLine:a,startColumn:o,endColumn:o+c-1,tokenTypeIdx:i,tokenType:r}}addTokenUsingPush(t,s,i){return t.push(i),s}addTokenUsingMemberAccess(t,s,i){return t[s]=i,s++,s}handlePayloadNoCustom(t,s){}handlePayloadWithCustom(t,s){if(s!==null)t.payload=s}match(t,s,i){if(t.test(s)===!0)return s.substring(i,t.lastIndex);return null}matchLength(t,s,i){if(t.test(s)===!0)return t.lastIndex-i;return-1}}K.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.";K.NA=/NOT_APPLICABLE/;function Ye(t){if(Gs(t))return t.LABEL;else return t.name}function Gs(t){return typeof t.LABEL==="string"&&t.LABEL!==""}var ya="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function S(t){return Oa(t)}function Oa(t){let s=t.pattern,i={};if(i.name=t.name,s!==void 0)i.PATTERN=s;if(Object.hasOwn(t,ya))throw`The parent property is no longer supported.
54
- See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(t,Hn))i.CATEGORIES=t[Hn];if(Pe([i]),Object.hasOwn(t,Xn))i.LABEL=t[Xn];if(Object.hasOwn(t,Yn))i.GROUP=t[Yn];if(Object.hasOwn(t,Jn))i.POP_MODE=t[Jn];if(Object.hasOwn(t,qn))i.PUSH_MODE=t[qn];if(Object.hasOwn(t,Zn))i.LONGER_ALT=t[Zn];if(Object.hasOwn(t,Qn))i.LINE_BREAKS=t[Qn];if(Object.hasOwn(t,ei))i.START_CHARS_HINT=t[ei];return i}var Se=S({name:"EOF",pattern:K.NA});Pe([Se]);function qe(t,s,i,r,a,o,c,h){return{image:s,startOffset:i,endOffset:r,startLine:a,endLine:o,startColumn:c,endColumn:h,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function It(t,s){return Ue(t,s)}var ts={buildMismatchTokenMessage({expected:t,actual:s,previous:i,ruleName:r}){return`Expecting ${Gs(t)?`--> ${Ye(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${s.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:s}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:s,previous:i,customUserDescription:r,ruleName:a}){let h=`
53
+ `+r)}return this.tokenizeInternal(t,s)}tokenizeInternal(t,s){let i,r,a,o,c,h,l,d,f,m,T,g,x,v,b,N=t,y=N.length,E=0,_=0,te=this.hasCustom?0:Math.floor(t.length/10),oe=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let se=0;se<this.cachedGroupKeys.length;se++)et[this.cachedGroupKeys[se]]=[];let Fr=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,Br=(se)=>{if(mt.length===1&&se.tokenType.PUSH_MODE===void 0){let Oe=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(se);pt.push({offset:se.startOffset,line:se.startLine,column:se.startColumn,length:se.image.length,message:Oe})}else{mt.pop();let Oe=mt.at(-1);We=this.patternIdxToConfig[Oe],ft=this.charCodeToPatternIdxToConfig[Oe],Cs=We.length;let bs=this.canModeBeOptimized[Oe]&&this.config.safeMode===!1;if(ft&&bs)Et=!0;else Et=!1}};function On(se){mt.push(se),ft=this.charCodeToPatternIdxToConfig[se],We=this.patternIdxToConfig[se],Cs=We.length;let Oe=this.canModeBeOptimized[se]&&this.config.safeMode===!1;if(ft&&Oe)Et=!0;else Et=!1}On.call(this,s);let ye,Ln=this.config.recoveryEnabled;while(E<y){h=null,f=-1;let se=N.charCodeAt(E),Oe;if(Et){let re=ve(se),ue=ft[re];Oe=ue!==void 0?ue:yn}else Oe=We;let bs=Oe.length;for(i=0;i<bs;i++){ye=Oe[i];let re=ye.pattern;switch(l=null,ye.matchType){case Zt:if(se===ye.short)f=1,h=re;break;case Nt:if(b=re.exec(N,E,oe,et),b!==null){if(h=b[0],f=h.length,b.payload!==void 0)l=b.payload}else h=null;break;case es:{let ue=ye.asciiClass;if(ue[se]!==1){re.lastIndex=0;break}let ce=E+1;while(ue[N.charCodeAt(ce)]===1)ce++;f=ce-E,re.lastIndex=ce;break}case Qt:re.lastIndex=E,f=this.matchLength(re,t,E);break}if(f!==-1){if(c=ye.longerAlt,c!==void 0){h=t.substring(E,E+f);let ue=c.length;for(a=0;a<ue;a++){let ce=We[c[a]],we=ce.pattern;if(d=null,ce.matchType===Nt)if(b=we.exec(N,E,oe,et),b!==null){if(o=b[0],b.payload!==void 0)d=b.payload}else o=null;else we.lastIndex=E,o=this.match(we,t,E);if(o&&o.length>h.length){h=o,f=o.length,l=d,ye=ce;break}}}break}}if(f!==-1){if(m=ye.group,m!==void 0)if(h=h!==null?h:t.substring(E,E+f),T=ye.tokenTypeIdx,g=this.createTokenInstance(h,E,T,ye.tokenType,Me,_e,f),this.handlePayload(g,l),m===!1)_=this.addToken(oe,_,g);else et[m].push(g);if(Fr===!0&&ye.canLineTerminator===!0){let re=0,ue,ce;ks.lastIndex=0;do if(h=h!==null?h:t.substring(E,E+f),ue=ks.test(h),ue===!0)ce=ks.lastIndex-1,re++;while(ue===!0);if(re!==0)Me=Me+re,_e=f-ce,this.updateTokenEndLineColumnLocation(g,m,ce,re,Me,_e,f);else _e=this.computeNewColumn(_e,f)}else _e=this.computeNewColumn(_e,f);E=E+f,this.handleModes(ye,Br,On,g)}else{let re=E,ue=Me,ce=_e,we=Ln===!1;while(we===!1&&E<y){E++;for(r=0;r<Cs;r++){let _s=We[r],xs=_s.pattern;switch(_s.matchType){case Zt:if(N.charCodeAt(E)===_s.short)we=!0;break;case Nt:we=xs.exec(N,E,oe,et)!==null;break;case es:case Qt:xs.lastIndex=E,we=xs.exec(t)!==null;break}if(we===!0)break}}if(x=E-re,_e=this.computeNewColumn(_e,x),v=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,re,x,ue,ce,mt.at(-1)),pt.push({offset:re,line:ue,column:ce,length:x,message:v}),Ln===!1)break}}if(!this.hasCustom)oe.length=_;return{tokens:oe,groups:et,errors:pt}}handleModes(t,s,i,r){if(t.pop===!0){let a=t.push;if(s(r),a!==void 0)i.call(this,a)}else if(t.push!==void 0)i.call(this,t.push)}updateTokenEndLineColumnLocation(t,s,i,r,a,o,c){let h,l;if(s!==void 0){if(h=i===c-1,l=h?-1:0,!(r===1&&h===!0))t.endLine=a+l,t.endColumn=o-1+-l}}computeNewColumn(t,s){return t+s}createOffsetOnlyToken(t,s,i,r){return{image:t,startOffset:s,tokenTypeIdx:i,tokenType:r}}createStartOnlyToken(t,s,i,r,a,o){return{image:t,startOffset:s,startLine:a,startColumn:o,tokenTypeIdx:i,tokenType:r}}createFullToken(t,s,i,r,a,o,c){return{image:t,startOffset:s,endOffset:s+c-1,startLine:a,endLine:a,startColumn:o,endColumn:o+c-1,tokenTypeIdx:i,tokenType:r}}addTokenUsingPush(t,s,i){return t.push(i),s}addTokenUsingMemberAccess(t,s,i){return t[s]=i,s++,s}handlePayloadNoCustom(t,s){}handlePayloadWithCustom(t,s){if(s!==null)t.payload=s}match(t,s,i){if(t.test(s)===!0)return s.substring(i,t.lastIndex);return null}matchLength(t,s,i){if(t.test(s)===!0)return t.lastIndex-i;return-1}}V.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.";V.NA=/NOT_APPLICABLE/;function Ye(t){if(Gs(t))return t.LABEL;else return t.name}function Gs(t){return typeof t.LABEL==="string"&&t.LABEL!==""}var ya="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function S(t){return Oa(t)}function Oa(t){let s=t.pattern,i={};if(i.name=t.name,s!==void 0)i.PATTERN=s;if(Object.hasOwn(t,ya))throw`The parent property is no longer supported.
54
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(t,Hn))i.CATEGORIES=t[Hn];if(Pe([i]),Object.hasOwn(t,Xn))i.LABEL=t[Xn];if(Object.hasOwn(t,Yn))i.GROUP=t[Yn];if(Object.hasOwn(t,Jn))i.POP_MODE=t[Jn];if(Object.hasOwn(t,qn))i.PUSH_MODE=t[qn];if(Object.hasOwn(t,Zn))i.LONGER_ALT=t[Zn];if(Object.hasOwn(t,Qn))i.LINE_BREAKS=t[Qn];if(Object.hasOwn(t,ei))i.START_CHARS_HINT=t[ei];return i}var Re=S({name:"EOF",pattern:V.NA});Pe([Re]);function qe(t,s,i,r,a,o,c,h){return{image:s,startOffset:i,endOffset:r,startLine:a,endLine:o,startColumn:c,endColumn:h,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function kt(t,s){return Ue(t,s)}var ts={buildMismatchTokenMessage({expected:t,actual:s,previous:i,ruleName:r}){return`Expecting ${Gs(t)?`--> ${Ye(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${s.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:s}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:s,previous:i,customUserDescription:r,ruleName:a}){let h=`
55
55
  but found: '`+s[0].image+"'";if(r)return"Expecting: "+r+h;else return`Expecting: one of these possible Token sequences:
56
56
  ${t.reduce((T,g)=>T.concat(g),[]).map((T)=>`[${T.map((g)=>Ye(g)).join(", ")}]`).map((T,g)=>` ${g+1}. ${T}`).join(`
57
57
  `)}`+h},buildEarlyExitMessage({expectedIterationPaths:t,actual:s,customUserDescription:i,ruleName:r}){let c=`
58
58
  but found: '`+s[0].image+"'";if(i)return"Expecting: "+i+c;else return`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
59
- <${t.map((d)=>`[${d.map((p)=>Ye(p)).join(",")}]`).join(" ,")}>`+c}};Object.freeze(ts);var ti={buildRuleNotFoundError(t,s){return"Invalid grammar, reference to a rule which is not defined: ->"+s.nonTerminalName+`<-
60
- inside top level rule: ->`+t.name+"<-"}},Ie={buildDuplicateFoundError(t,s){function i(p){if(p instanceof w)return p.terminalType.name;else if(p instanceof B)return p.nonTerminalName;else return""}let r=t.name,a=s[0],o=a.idx,c=Te(a),h=i(a),l=o>0,d=`->${c}${l?o:""}<- ${h?`with argument: ->${h}<-`:""}
59
+ <${t.map((d)=>`[${d.map((f)=>Ye(f)).join(",")}]`).join(" ,")}>`+c}};Object.freeze(ts);var ti={buildRuleNotFoundError(t,s){return"Invalid grammar, reference to a rule which is not defined: ->"+s.nonTerminalName+`<-
60
+ inside top level rule: ->`+t.name+"<-"}},ke={buildDuplicateFoundError(t,s){function i(f){if(f instanceof w)return f.terminalType.name;else if(f instanceof G)return f.nonTerminalName;else return""}let r=t.name,a=s[0],o=a.idx,c=Ae(a),h=i(a),l=o>0,d=`->${c}${l?o:""}<- ${h?`with argument: ->${h}<-`:""}
61
61
  appears more than once (${s.length} times) in the top level rule: ->${r}<-.
62
62
  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
63
63
  `;return d=d.replace(/[ \t]+/g," "),d=d.replace(/\s\s+/g,`
@@ -74,7 +74,7 @@ For Further details.`},buildAlternationAmbiguityError(t){let s=t.alternation.idx
74
74
  Only the last alternative may be empty.
75
75
  `;else{let a=t.prefixPath.map((o)=>Ye(o)).join(", ");r+=`<${a}> may appears as a prefix path in all these alternatives.
76
76
  `}return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
77
- For Further details.`,r},buildEmptyRepetitionError(t){let s=Te(t.repetition);if(t.repetition.idx!==0)s+=t.repetition.idx;return`The repetition <${s}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
77
+ For Further details.`,r},buildEmptyRepetitionError(t){let s=Ae(t.repetition);if(t.repetition.idx!==0)s+=t.repetition.idx;return`The repetition <${s}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
78
78
  This could lead to an infinite loop.`},buildTokenNameError(t){return"deprecated"},buildEmptyAlternationError(t){return`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
79
79
  Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(t){return`An Alternation cannot have more than 256 alternatives:
80
80
  <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
@@ -83,46 +83,46 @@ rule: <${s}> can be invoked from itself (directly or indirectly)
83
83
  without consuming any Tokens. The grammar path that causes this is:
84
84
  ${r}
85
85
  To fix this refactor your grammar to remove the left recursion.
86
- see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let s;if(t.topLevelRule instanceof fe)s=t.topLevelRule.name;else s=t.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${t.grammarName}<-`}};function si(t,s){let i=new ni(t,s);return i.resolveRefs(),i.errors}class ni extends me{constructor(t,s){super();this.nameToTopRule=t,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((t)=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let s=this.nameToTopRule[t.nonTerminalName];if(!s){let i=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:i,type:ne.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}else t.referencedRule=s}}class ii extends $e{constructor(t,s){super();this.topProd=t,this.path=s,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=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,s=[]){if(!this.found)super.walk(t,s)}walkProdRef(t,s,i){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let r=s.concat(i);this.updateExpectedNext(),this.walk(t.referencedRule,r)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ii{constructor(t,s){super(t,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,s,i){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let r=s.concat(i),a=new G({definition:r});this.possibleTokTypes=Ke(a),this.found=!0}}}class kt extends $e{constructor(t,s){super();this.topRule=t,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends kt{walkMany(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkMany(t,s,i)}}class ss extends kt{walkManySep(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkManySep(t,s,i)}}class Ks extends kt{walkAtLeastOne(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkAtLeastOne(t,s,i)}}class ns extends kt{walkAtLeastOneSep(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkAtLeastOneSep(t,s,i)}}function is(t,s,i=[]){i=[...i];let r=[],a=0;function o(h){return h.concat(t.slice(a+1))}function c(h){let l=is(o(h),s,i);return r.concat(l)}while(i.length<s&&a<t.length){let h=t[a];if(h instanceof G)return c(h.definition);else if(h instanceof B)return c(h.definition);else if(h instanceof W)r=c(h.definition);else if(h instanceof Z){let l=h.definition.concat([new P({definition:h.definition})]);return c(l)}else if(h instanceof Q){let l=[new G({definition:h.definition}),new P({definition:[new w({terminalType:h.separator})].concat(h.definition)})];return c(l)}else if(h instanceof Y){let l=h.definition.concat([new P({definition:[new w({terminalType:h.separator})].concat(h.definition)})]);r=c(l)}else if(h instanceof P){let l=h.definition.concat([new P({definition:h.definition})]);r=c(l)}else if(h instanceof J)return h.definition.forEach((l)=>{if(l.definition.length!==0)r=c(l.definition)}),r;else if(h instanceof w)i.push(h.terminalType);else throw Error("non exhaustive match");a++}return r.push({partialPath:i,suffixDef:t.slice(a)}),r}function ri(t,s,i,r){let o=["EXIT_NONE_TERMINAL"],c="EXIT_ALTERNATIVE",h=!1,l=s.length,d=l-r-1,p=[],f=[];f.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});while(f.length!==0){let T=f.pop();if(T==="EXIT_ALTERNATIVE"){if(h&&f.at(-1).idx<=d)f.pop();continue}let{def:g,idx:x,ruleStack:v,occurrenceStack:b}=T;if(g.length===0)continue;let N=g[0];if(N==="EXIT_NONE_TERMINAL"){let y={idx:x,def:g.slice(1),ruleStack:v.slice(0,-1),occurrenceStack:b.slice(0,-1)};f.push(y)}else if(N instanceof w)if(x<l-1){let y=x+1,E=s[y];if(i(E,N.terminalType)){let _={idx:y,def:g.slice(1),ruleStack:v,occurrenceStack:b};f.push(_)}}else if(x===l-1)p.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:v,occurrenceStack:b}),h=!0;else throw Error("non exhaustive match");else if(N instanceof B){let y=[...v];y.push(N.nonTerminalName);let E=[...b];E.push(N.idx);let _={idx:x,def:N.definition.concat(o,g.slice(1)),ruleStack:y,occurrenceStack:E};f.push(_)}else if(N instanceof W){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};f.push(y),f.push("EXIT_ALTERNATIVE");let E={idx:x,def:N.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};f.push(E)}else if(N instanceof Z){let y=new P({definition:N.definition,idx:N.idx}),E=N.definition.concat([y],g.slice(1)),_={idx:x,def:E,ruleStack:v,occurrenceStack:b};f.push(_)}else if(N instanceof Q){let y=new w({terminalType:N.separator}),E=new P({definition:[y].concat(N.definition),idx:N.idx}),_=N.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};f.push(te)}else if(N instanceof Y){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};f.push(y),f.push("EXIT_ALTERNATIVE");let E=new w({terminalType:N.separator}),_=new P({definition:[E].concat(N.definition),idx:N.idx}),te=N.definition.concat([_],g.slice(1)),oe={idx:x,def:te,ruleStack:v,occurrenceStack:b};f.push(oe)}else if(N instanceof P){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};f.push(y),f.push("EXIT_ALTERNATIVE");let E=new P({definition:N.definition,idx:N.idx}),_=N.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};f.push(te)}else if(N instanceof J)for(let y=N.definition.length-1;y>=0;y--){let E=N.definition[y],_={idx:x,def:E.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};f.push(_),f.push("EXIT_ALTERNATIVE")}else if(N instanceof G)f.push({idx:x,def:N.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b});else if(N instanceof fe)f.push(La(N,x,v,b));else throw Error("non exhaustive match")}return p}function La(t,s,i,r){let a=[...i];a.push(t.name);let o=[...r];return o.push(1),{idx:s,def:t.definition,ruleStack:a,occurrenceStack:o}}var V;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(V||(V={}));function rs(t){if(t instanceof W||t==="Option")return V.OPTION;else if(t instanceof P||t==="Repetition")return V.REPETITION;else if(t instanceof Z||t==="RepetitionMandatory")return V.REPETITION_MANDATORY;else if(t instanceof Q||t==="RepetitionMandatoryWithSeparator")return V.REPETITION_MANDATORY_WITH_SEPARATOR;else if(t instanceof Y||t==="RepetitionWithSeparator")return V.REPETITION_WITH_SEPARATOR;else if(t instanceof J||t==="Alternation")return V.ALTERNATION;else throw Error("non exhaustive match")}function oi(t,s,i,r,a,o){let c=bt(t,s,i),h=fi(c)?at:Ue;return o(c,r,h,a)}function li(t,s,i,r,a,o){let c=_t(t,s,a,i),h=fi(c)?at:Ue;return o(c[0],h,r)}function ci(t,s,i,r){let a=t.length,o=t.every((c)=>c.every((h)=>h.length===1));if(s)return function(c){let h=c.map((l)=>l.GATE);for(let l=0;l<a;l++){let d=t[l],p=d.length,f=h[l];if(f!==void 0&&f.call(this)===!1)continue;e:for(let T=0;T<p;T++){let g=d[T],x=g.length;for(let v=0;v<x;v++){let b=this.LA_FAST(v+1);if(i(b,g[v])===!1)continue e}return l}}return};else if(o&&!r){let h=t.map((l)=>l.flat()).reduce((l,d,p)=>(d.forEach((f)=>{if(!(f.tokenTypeIdx in l))l[f.tokenTypeIdx]=p;f.categoryMatches.forEach((T)=>{if(!Object.hasOwn(l,T))l[T]=p})}),l),{});return function(){let l=this.LA_FAST(1);return h[l.tokenTypeIdx]}}else return function(){for(let c=0;c<a;c++){let h=t[c],l=h.length;e:for(let d=0;d<l;d++){let p=h[d],f=p.length;for(let T=0;T<f;T++){let g=this.LA_FAST(T+1);if(i(g,p[T])===!1)continue e}return c}}return}}function hi(t,s,i){let r=t.every((o)=>o.length===1),a=t.length;if(r&&!i){let o=t.flat();if(o.length===1&&o[0].categoryMatches.length===0){let h=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===h}}else{let c=o.reduce((h,l,d)=>(h[l.tokenTypeIdx]=!0,l.categoryMatches.forEach((p)=>{h[p]=!0}),h),[]);return function(){let h=this.LA_FAST(1);return c[h.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<a;o++){let c=t[o],h=c.length;for(let l=0;l<h;l++){let d=this.LA_FAST(l+1);if(s(d,c[l])===!1)continue e}return!0}return!1}}class ui extends $e{constructor(t,s,i){super();this.topProd=t,this.targetOccurrence=s,this.targetProdType=i}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,s,i,r){if(t.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=i.concat(r),!0;return!1}walkOption(t,s,i){if(!this.checkIsTarget(t,V.OPTION,s,i))super.walkOption(t,s,i)}walkAtLeastOne(t,s,i){if(!this.checkIsTarget(t,V.REPETITION_MANDATORY,s,i))super.walkOption(t,s,i)}walkAtLeastOneSep(t,s,i){if(!this.checkIsTarget(t,V.REPETITION_MANDATORY_WITH_SEPARATOR,s,i))super.walkOption(t,s,i)}walkMany(t,s,i){if(!this.checkIsTarget(t,V.REPETITION,s,i))super.walkOption(t,s,i)}walkManySep(t,s,i){if(!this.checkIsTarget(t,V.REPETITION_WITH_SEPARATOR,s,i))super.walkOption(t,s,i)}}class zs extends me{constructor(t,s,i){super();this.targetOccurrence=t,this.targetProdType=s,this.targetRef=i,this.result=[]}checkIsTarget(t,s){if(t.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||t===this.targetRef))this.result=t.definition}visitOption(t){this.checkIsTarget(t,V.OPTION)}visitRepetition(t){this.checkIsTarget(t,V.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,V.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,V.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,V.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,V.ALTERNATION)}}function ai(t){let s=Array(t);for(let i=0;i<t;i++)s[i]=[];return s}function Vs(t){let s=[""];for(let i=0;i<t.length;i++){let r=t[i],a=[];for(let o=0;o<s.length;o++){let c=s[o];a.push(c+"_"+r.tokenTypeIdx);for(let h=0;h<r.categoryMatches.length;h++){let l="_"+r.categoryMatches[h];a.push(c+l)}}s=a}return s}function Na(t,s,i){for(let r=0;r<t.length;r++){if(r===i)continue;let a=t[r];for(let o=0;o<s.length;o++){let c=s[o];if(a[c]===!0)return!1}}return!0}function di(t,s){let i=t.map((c)=>is([c],1)),r=ai(i.length),a=i.map((c)=>{let h={};return c.forEach((l)=>{Vs(l.partialPath).forEach((p)=>{h[p]=!0})}),h}),o=i;for(let c=1;c<=s;c++){let h=o;o=ai(h.length);for(let l=0;l<h.length;l++){let d=h[l];for(let p=0;p<d.length;p++){let f=d[p].partialPath,T=d[p].suffixDef,g=Vs(f);if(Na(a,g,l)||T.length===0||f.length===s){let v=r[l];if(as(v,f)===!1){v.push(f);for(let b=0;b<g.length;b++){let N=g[b];a[l][N]=!0}}}else{let v=is(T,c+1,f);o[l]=o[l].concat(v),v.forEach((b)=>{Vs(b.partialPath).forEach((y)=>{a[l][y]=!0})})}}}}return r}function bt(t,s,i,r){let a=new zs(t,V.ALTERNATION,r);return s.accept(a),di(a.result,i)}function _t(t,s,i,r){let a=new zs(t,i);s.accept(a);let o=a.result,h=new ui(s,t,i).startWalking(),l=new G({definition:o}),d=new G({definition:h});return di([l,d],r)}function as(t,s){e:for(let i=0;i<t.length;i++){let r=t[i];if(r.length!==s.length)continue;for(let a=0;a<r.length;a++){let o=s[a],c=r[a];if((o===c||c.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function pi(t,s){return t.length<s.length&&t.every((i,r)=>{let a=s[r];return i===a||a.categoryMatchesMap[i.tokenTypeIdx]})}function fi(t){return t.every((s)=>s.every((i)=>i.every((r)=>r.categoryMatches.length===0)))}function mi(t){return t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}).map((i)=>Object.assign({type:ne.CUSTOM_LOOKAHEAD_VALIDATION},i))}function Ei(t,s,i,r){let a=t.flatMap((l)=>Ia(l,i)),o=va(t,s,i),c=t.flatMap((l)=>ba(l,i)),h=t.flatMap((l)=>Ca(l,t,r,i));return a.concat(o,c,h)}function Ia(t,s){let i=new gi;t.accept(i);let r=i.allProductions,a=Object.groupBy(r,ka),o=Object.fromEntries(Object.entries(a).filter(([h,l])=>l.length>1));return Object.values(o).map((h)=>{let l=h[0],d=s.buildDuplicateFoundError(t,h),p=Te(l),f={message:d,type:ne.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:p,occurrence:l.idx},T=Ti(l);if(T)f.parameter=T;return f})}function ka(t){return`${Te(t)}_#_${t.idx}_#_${Ti(t)}`}function Ti(t){if(t instanceof w)return t.terminalType.name;else if(t instanceof B)return t.nonTerminalName;else return""}class gi extends me{constructor(){super(...arguments);this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function Ca(t,s,i,r){let a=[];if(s.reduce((c,h)=>{if(h.name===t.name)return c+1;return c},0)>1){let c=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:i});a.push({message:c,type:ne.DUPLICATE_RULE_NAME,ruleName:t.name})}return a}function Ai(t,s,i){let r=[],a;if(!s.includes(t))a=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${i}<-as it is not defined in any of the super grammars `,r.push({message:a,type:ne.INVALID_RULE_OVERRIDE,ruleName:t});return r}function Hs(t,s,i,r=[]){let a=[],o=os(s.definition);if(o.length===0)return[];else{let c=t.name;if(o.includes(t))a.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:ne.LEFT_RECURSION,ruleName:c});let l=r.concat([t]),p=o.filter((f)=>!l.includes(f)).flatMap((f)=>{let T=[...r];return T.push(f),Hs(t,f,i,T)});return a.concat(p)}}function os(t){let s=[];if(t.length===0)return s;let i=t[0];if(i instanceof B)s.push(i.referencedRule);else if(i instanceof G||i instanceof W||i instanceof Z||i instanceof Q||i instanceof Y||i instanceof P)s=s.concat(os(i.definition));else if(i instanceof J)s=i.definition.map((o)=>os(o.definition)).flat();else if(i instanceof w);else throw Error("non exhaustive match");let r=je(i),a=t.length>1;if(r&&a){let o=t.slice(1);return s.concat(os(o))}else return s}class ls extends me{constructor(){super(...arguments);this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function Si(t,s){let i=new ls;return t.accept(i),i.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((h,l)=>{if(ri([h],[],Ue,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:t,alternation:o,emptyChoiceIdx:l}),type:ne.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:o.idx,alternative:l+1}];else return[]}))}function Ri(t,s,i){let r=new ls;t.accept(r);let a=r.alternations;return a=a.filter((c)=>c.ignoreAmbiguities!==!0),a.flatMap((c)=>{let h=c.idx,l=c.maxLookahead||s,d=bt(h,t,l,c),p=_a(d,c,t,i),f=xa(d,c,t,i);return p.concat(f)})}class yi extends me{constructor(){super(...arguments);this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function ba(t,s){let i=new ls;return t.accept(i),i.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:t,alternation:o}),type:ne.TOO_MANY_ALTS,ruleName:t.name,occurrence:o.idx}];else return[]})}function Oi(t,s,i){let r=[];return t.forEach((a)=>{let o=new yi;a.accept(o),o.allProductions.forEach((h)=>{let l=rs(h),d=h.maxLookahead||s,p=h.idx;if(_t(p,a,l,d)[0].flat().length===0){let g=i.buildEmptyRepetitionError({topLevelRule:a,repetition:h});r.push({message:g,type:ne.NO_NON_EMPTY_LOOKAHEAD,ruleName:a.name})}})}),r}function _a(t,s,i,r){let a=[];return t.reduce((h,l,d)=>{if(s.definition[d].ignoreAmbiguities===!0)return h;return l.forEach((p)=>{let f=[d];if(t.forEach((T,g)=>{if(d!==g&&as(T,p)&&s.definition[g].ignoreAmbiguities!==!0)f.push(g)}),f.length>1&&!as(a,p))a.push(p),h.push({alts:f,path:p})}),h},[]).map((h)=>{let l=h.alts.map((p)=>p+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:i,alternation:s,ambiguityIndices:l,prefixPath:h.path}),type:ne.AMBIGUOUS_ALTS,ruleName:i.name,occurrence:s.idx,alternatives:h.alts}})}function xa(t,s,i,r){let a=t.reduce((c,h,l)=>{let d=h.map((p)=>({idx:l,path:p}));return c.concat(d)},[]);return a.flatMap((c)=>{if(s.definition[c.idx].ignoreAmbiguities===!0)return[];let{idx:l,path:d}=c;return a.filter((T)=>s.definition[T.idx].ignoreAmbiguities!==!0&&T.idx<l&&pi(T.path,d)).map((T)=>{let g=[T.idx+1,l+1],x=s.idx===0?"":s.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:i,alternation:s,ambiguityIndices:g,prefixPath:T.path}),type:ne.AMBIGUOUS_PREFIX_ALTS,ruleName:i.name,occurrence:x,alternatives:g}})})}function va(t,s,i){let r=[],a=s.map((o)=>o.name);return t.forEach((o)=>{let c=o.name;if(a.includes(c)){let h=i.buildNamespaceConflictError(o);r.push({message:h,type:ne.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:c})}}),r}function Li(t){let s=Object.assign({errMsgProvider:ti},t),i={};return t.rules.forEach((r)=>{i[r.name]=r}),si(i,s.errMsgProvider)}function Ni(t){var s;let i=(s=t.errMsgProvider)!==null&&s!==void 0?s:Ie;return Ei(t.rules,t.tokenTypes,i,t.grammarName)}var Ii=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(Ii);function Ge(t){return Ii.includes(t.name)}class xt extends Error{constructor(t,s){super(t);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="MismatchedTokenException"}}class cs extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="NoViableAltException"}}class hs extends xt{constructor(t,s){super(t,s);this.name="NotAllInputParsedException"}}class us extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class ki extends Error{constructor(t){super(t);this.name=Ys}}class qs{initRecoverable(t){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(t,"recoveryEnabled")?t.recoveryEnabled:ue.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=Ma}getTokenToInsert(t){let s=qe(t,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,s,i,r){let a=this.findReSyncTokenType(),o=this.exportLexerState(),c=[],h=!1,l=this.LA_FAST(1),d=this.LA_FAST(1),p=()=>{let f=this.LA(0),T=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:l,previous:f,ruleName:this.getCurrRuleFullName()}),g=new ot(T,l,this.LA(0));g.resyncedTokens=c.slice(0,-1),this.SAVE_ERROR(g)};while(!h)if(this.tokenMatcher(d,r)){p();return}else if(i.call(this)){p(),t.apply(this,s);return}else if(this.tokenMatcher(d,a))h=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,c);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(t,s,i){if(i===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),t))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,s)))return!1;return!0}getNextPossibleTokenTypes(t){let s=t.ruleStack[0],r=this.getGAstProductions()[s];return new Ws(r,t).startWalking()}getFollowsForInRuleRecovery(t,s){let i=this.getCurrentGrammarPath(t,s);return this.getNextPossibleTokenTypes(i)}tryInRuleRecovery(t,s){if(this.canRecoverWithSingleTokenInsertion(t,s))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let i=this.SKIP_TOKEN();return this.consumeToken(),i}throw new ki("sad sad panda")}canPerformInRuleRecovery(t,s){return this.canRecoverWithSingleTokenInsertion(t,s)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,s){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(s.length===0)return!1;let i=this.LA_FAST(1);return s.find((a)=>this.tokenMatcher(i,a))!==void 0}canRecoverWithSingleTokenDeletion(t){if(!this.canTokenTypeBeDeletedInRecovery(t))return!1;return this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(t)}findReSyncTokenType(){let t=this.flattenFollowSet(),s=this.LA_FAST(1),i=2;while(!0){let r=t.find((a)=>It(s,a));if(r!==void 0)return r;s=this.LA(i),i++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let t=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(i)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,i=this.RULE_STACK_IDX+1,r=Array(i);for(let a=0;a<i;a++)if(a===0)r[a]=Xs;else r[a]={ruleName:this.shortRuleNameToFullName(t[a]),idxInCallingRule:s[a],inRule:this.shortRuleNameToFullName(t[a-1])};return r}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(t){if(t===Xs)return[Se];let s=t.ruleName+t.idxInCallingRule+jt+t.inRule;return this.resyncFollows[s]}addToResyncTokens(t,s){if(!this.tokenMatcher(t,Se))s.push(t);return s}reSyncTo(t){let s=[],i=this.LA_FAST(1);while(this.tokenMatcher(i,t)===!1)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,s);return s.slice(0,-1)}attemptInRepetitionRecovery(t,s,i,r,a,o,c){}getCurrentGrammarPath(t,s){let i=this.getHumanReadableRuleStack(),r=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:i,occurrenceStack:r,lastTok:t,lastTokOccurrence:s}}getHumanReadableRuleStack(){let t=this.RULE_STACK_IDX+1,s=Array(t);for(let i=0;i<t;i++)s[i]=this.shortRuleNameToFullName(this.RULE_STACK[i]);return s}}function Ma(t,s,i,r,a,o,c){var h,l,d;let p=r|a,f=(h=(l=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&h!==void 0?h:l[d]=[],T=f[p];if(T===void 0){let b=this.getCurrRuleFullName(),N=this.getGAstProductions()[b];T=new o(N,a).startWalking(),f[p]=T}let g=T.token,x=T.occurrence,v=T.isEndOfRule;if(this.RULE_STACK_IDX===0&&v&&g===void 0)g=Se,x=1;if(g===void 0||x===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(g,x,c))this.tryInRepetitionRecovery(t,s,i,g)}var ds=256,ps=512,vt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(t){var s;this.maxLookahead=(s=t===null||t===void 0?void 0:t.maxLookahead)!==null&&s!==void 0?s:ue.maxLookahead}validate(t){let s=this.validateNoLeftRecursion(t.rules);if(s.length===0){let i=this.validateEmptyOrAlternatives(t.rules),r=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),a=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...s,...i,...r,...a]}return s}validateNoLeftRecursion(t){return t.flatMap((s)=>Hs(s,s,Ie))}validateEmptyOrAlternatives(t){return t.flatMap((s)=>Si(s,Ie))}validateAmbiguousAlternationAlternatives(t,s){return t.flatMap((i)=>Ri(i,s,Ie))}validateSomeNonEmptyLookaheadPath(t,s){return Oi(t,s,Ie)}buildLookaheadForAlternation(t){return oi(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,ci)}buildLookaheadForOptional(t){return li(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,rs(t.prodType),hi)}}class Js{initLooksAhead(t){this.dynamicTokensEnabled=Object.hasOwn(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:ue.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(t,"maxLookahead")?t.maxLookahead:ue.maxLookahead,this.lookaheadStrategy=Object.hasOwn(t,"lookaheadStrategy")?t.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(t){t.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:i,repetition:r,option:a,repetitionMandatory:o,repetitionMandatoryWithSeparator:c,repetitionWithSeparator:h}=wa(s);i.forEach((l)=>{let d=l.idx===0?"":l.idx;this.TRACE_INIT(`${Te(l)}${d}`,()=>{let p=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:s,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],ds|l.idx,p)})}),r.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,vt,"Repetition",l.maxLookahead,Te(l))}),a.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,ps,"Option",l.maxLookahead,Te(l))}),o.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,Mt,"RepetitionMandatory",l.maxLookahead,Te(l))}),c.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,lt,"RepetitionMandatoryWithSeparator",l.maxLookahead,Te(l))}),h.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,wt,"RepetitionWithSeparator",l.maxLookahead,Te(l))})})})}computeLookaheadFunc(t,s,i,r,a,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let c=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:t,maxLookahead:a||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r});this.setLaFuncCache(this.fullRuleNameToShort[t.name],i|s,c)})}setLaFuncCache(t,s,i){let r=this.lookAheadFuncsCache[t];if(r===void 0)r=[],this.lookAheadFuncsCache[t]=r;r[s]=i}}class Ci extends me{constructor(){super(...arguments);this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}}var ms=new Ci;function wa(t){ms.reset(),t.accept(ms);let s=ms.dslMethods;return ms.reset(),s}function Zs(t,s){if(t.startOffset===-1)t.startOffset=s.startOffset,t.endOffset=s.endOffset;else if(t.endOffset<s.endOffset===!0)t.endOffset=s.endOffset}function Qs(t,s){if(t.startOffset===-1)t.startOffset=s.startOffset,t.startColumn=s.startColumn,t.startLine=s.startLine,t.endOffset=s.endOffset,t.endColumn=s.endColumn,t.endLine=s.endLine;else if(t.endOffset<s.endOffset===!0)t.endOffset=s.endOffset,t.endColumn=s.endColumn,t.endLine=s.endLine}function bi(t,s,i){if(t.children[i]===void 0)t.children[i]=[s];else t.children[i].push(s)}function _i(t,s,i){if(t.children[s]===void 0)t.children[s]=[i];else t.children[s].push(i)}function en(t,s){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Ua(t,s){let i=Object.keys(t),r=i.length;for(let a=0;a<r;a++){let o=i[a],c=t[o],h=c.length;for(let l=0;l<h;l++){let d=c[l];if(d.tokenTypeIdx===void 0)this[d.name](d.children,s)}}}function xi(t,s){let i=function(){};en(i,t+"BaseSemantics");let r={visit:function(a,o){if(Array.isArray(a))a=a[0];if(a===void 0)return;return this[a.name](a.children,o)},validateVisitor:function(){let a=Pa(this,s);if(a.length!==0){let o=a.map((c)=>c.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
86
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let s;if(t.topLevelRule instanceof me)s=t.topLevelRule.name;else s=t.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${t.grammarName}<-`}};function si(t,s){let i=new ni(t,s);return i.resolveRefs(),i.errors}class ni extends Te{constructor(t,s){super();this.nameToTopRule=t,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((t)=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let s=this.nameToTopRule[t.nonTerminalName];if(!s){let i=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:i,type:ne.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}else t.referencedRule=s}}class ii extends $e{constructor(t,s){super();this.topProd=t,this.path=s,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=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,s=[]){if(!this.found)super.walk(t,s)}walkProdRef(t,s,i){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let r=s.concat(i);this.updateExpectedNext(),this.walk(t.referencedRule,r)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ii{constructor(t,s){super(t,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,s,i){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let r=s.concat(i),a=new W({definition:r});this.possibleTokTypes=Ke(a),this.found=!0}}}class Ct extends $e{constructor(t,s){super();this.topRule=t,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends Ct{walkMany(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkMany(t,s,i)}}class ss extends Ct{walkManySep(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkManySep(t,s,i)}}class Ks extends Ct{walkAtLeastOne(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkAtLeastOne(t,s,i)}}class ns extends Ct{walkAtLeastOneSep(t,s,i){if(t.idx===this.occurrence){let r=s.concat(i)[0];if(this.result.isEndOfRule=r===void 0,r instanceof w)this.result.token=r.terminalType,this.result.occurrence=r.idx}else super.walkAtLeastOneSep(t,s,i)}}function is(t,s,i=[]){i=[...i];let r=[],a=0;function o(h){return h.concat(t.slice(a+1))}function c(h){let l=is(o(h),s,i);return r.concat(l)}while(i.length<s&&a<t.length){let h=t[a];if(h instanceof W)return c(h.definition);else if(h instanceof G)return c(h.definition);else if(h instanceof j)r=c(h.definition);else if(h instanceof Z){let l=h.definition.concat([new D({definition:h.definition})]);return c(l)}else if(h instanceof Q){let l=[new W({definition:h.definition}),new D({definition:[new w({terminalType:h.separator})].concat(h.definition)})];return c(l)}else if(h instanceof Y){let l=h.definition.concat([new D({definition:[new w({terminalType:h.separator})].concat(h.definition)})]);r=c(l)}else if(h instanceof D){let l=h.definition.concat([new D({definition:h.definition})]);r=c(l)}else if(h instanceof J)return h.definition.forEach((l)=>{if(l.definition.length!==0)r=c(l.definition)}),r;else if(h instanceof w)i.push(h.terminalType);else throw Error("non exhaustive match");a++}return r.push({partialPath:i,suffixDef:t.slice(a)}),r}function ri(t,s,i,r){let o=["EXIT_NONE_TERMINAL"],c="EXIT_ALTERNATIVE",h=!1,l=s.length,d=l-r-1,f=[],m=[];m.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let T=m.pop();if(T==="EXIT_ALTERNATIVE"){if(h&&m.at(-1).idx<=d)m.pop();continue}let{def:g,idx:x,ruleStack:v,occurrenceStack:b}=T;if(g.length===0)continue;let N=g[0];if(N==="EXIT_NONE_TERMINAL"){let y={idx:x,def:g.slice(1),ruleStack:v.slice(0,-1),occurrenceStack:b.slice(0,-1)};m.push(y)}else if(N instanceof w)if(x<l-1){let y=x+1,E=s[y];if(i(E,N.terminalType)){let _={idx:y,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(_)}}else if(x===l-1)f.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:v,occurrenceStack:b}),h=!0;else throw Error("non exhaustive match");else if(N instanceof G){let y=[...v];y.push(N.nonTerminalName);let E=[...b];E.push(N.idx);let _={idx:x,def:N.definition.concat(o,g.slice(1)),ruleStack:y,occurrenceStack:E};m.push(_)}else if(N instanceof j){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(y),m.push("EXIT_ALTERNATIVE");let E={idx:x,def:N.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};m.push(E)}else if(N instanceof Z){let y=new D({definition:N.definition,idx:N.idx}),E=N.definition.concat([y],g.slice(1)),_={idx:x,def:E,ruleStack:v,occurrenceStack:b};m.push(_)}else if(N instanceof Q){let y=new w({terminalType:N.separator}),E=new D({definition:[y].concat(N.definition),idx:N.idx}),_=N.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};m.push(te)}else if(N instanceof Y){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(y),m.push("EXIT_ALTERNATIVE");let E=new w({terminalType:N.separator}),_=new D({definition:[E].concat(N.definition),idx:N.idx}),te=N.definition.concat([_],g.slice(1)),oe={idx:x,def:te,ruleStack:v,occurrenceStack:b};m.push(oe)}else if(N instanceof D){let y={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(y),m.push("EXIT_ALTERNATIVE");let E=new D({definition:N.definition,idx:N.idx}),_=N.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};m.push(te)}else if(N instanceof J)for(let y=N.definition.length-1;y>=0;y--){let E=N.definition[y],_={idx:x,def:E.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};m.push(_),m.push("EXIT_ALTERNATIVE")}else if(N instanceof W)m.push({idx:x,def:N.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b});else if(N instanceof me)m.push(La(N,x,v,b));else throw Error("non exhaustive match")}return f}function La(t,s,i,r){let a=[...i];a.push(t.name);let o=[...r];return o.push(1),{idx:s,def:t.definition,ruleStack:a,occurrenceStack:o}}var z;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(z||(z={}));function rs(t){if(t instanceof j||t==="Option")return z.OPTION;else if(t instanceof D||t==="Repetition")return z.REPETITION;else if(t instanceof Z||t==="RepetitionMandatory")return z.REPETITION_MANDATORY;else if(t instanceof Q||t==="RepetitionMandatoryWithSeparator")return z.REPETITION_MANDATORY_WITH_SEPARATOR;else if(t instanceof Y||t==="RepetitionWithSeparator")return z.REPETITION_WITH_SEPARATOR;else if(t instanceof J||t==="Alternation")return z.ALTERNATION;else throw Error("non exhaustive match")}function oi(t,s,i,r,a,o){let c=bt(t,s,i),h=fi(c)?at:Ue;return o(c,r,h,a)}function li(t,s,i,r,a,o){let c=_t(t,s,a,i),h=fi(c)?at:Ue;return o(c[0],h,r)}function ci(t,s,i,r){let a=t.length,o=t.every((c)=>c.every((h)=>h.length===1));if(s)return function(c){let h=c.map((l)=>l.GATE);for(let l=0;l<a;l++){let d=t[l],f=d.length,m=h[l];if(m!==void 0&&m.call(this)===!1)continue;e:for(let T=0;T<f;T++){let g=d[T],x=g.length;for(let v=0;v<x;v++){let b=this.LA_FAST(v+1);if(i(b,g[v])===!1)continue e}return l}}return};else if(o&&!r){let h=t.map((l)=>l.flat()).reduce((l,d,f)=>(d.forEach((m)=>{if(!(m.tokenTypeIdx in l))l[m.tokenTypeIdx]=f;m.categoryMatches.forEach((T)=>{if(!Object.hasOwn(l,T))l[T]=f})}),l),{});return function(){let l=this.LA_FAST(1);return h[l.tokenTypeIdx]}}else return function(){for(let c=0;c<a;c++){let h=t[c],l=h.length;e:for(let d=0;d<l;d++){let f=h[d],m=f.length;for(let T=0;T<m;T++){let g=this.LA_FAST(T+1);if(i(g,f[T])===!1)continue e}return c}}return}}function hi(t,s,i){let r=t.every((o)=>o.length===1),a=t.length;if(r&&!i){let o=t.flat();if(o.length===1&&o[0].categoryMatches.length===0){let h=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===h}}else{let c=o.reduce((h,l,d)=>(h[l.tokenTypeIdx]=!0,l.categoryMatches.forEach((f)=>{h[f]=!0}),h),[]);return function(){let h=this.LA_FAST(1);return c[h.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<a;o++){let c=t[o],h=c.length;for(let l=0;l<h;l++){let d=this.LA_FAST(l+1);if(s(d,c[l])===!1)continue e}return!0}return!1}}class ui extends $e{constructor(t,s,i){super();this.topProd=t,this.targetOccurrence=s,this.targetProdType=i}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,s,i,r){if(t.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=i.concat(r),!0;return!1}walkOption(t,s,i){if(!this.checkIsTarget(t,z.OPTION,s,i))super.walkOption(t,s,i)}walkAtLeastOne(t,s,i){if(!this.checkIsTarget(t,z.REPETITION_MANDATORY,s,i))super.walkOption(t,s,i)}walkAtLeastOneSep(t,s,i){if(!this.checkIsTarget(t,z.REPETITION_MANDATORY_WITH_SEPARATOR,s,i))super.walkOption(t,s,i)}walkMany(t,s,i){if(!this.checkIsTarget(t,z.REPETITION,s,i))super.walkOption(t,s,i)}walkManySep(t,s,i){if(!this.checkIsTarget(t,z.REPETITION_WITH_SEPARATOR,s,i))super.walkOption(t,s,i)}}class zs extends Te{constructor(t,s,i){super();this.targetOccurrence=t,this.targetProdType=s,this.targetRef=i,this.result=[]}checkIsTarget(t,s){if(t.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||t===this.targetRef))this.result=t.definition}visitOption(t){this.checkIsTarget(t,z.OPTION)}visitRepetition(t){this.checkIsTarget(t,z.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,z.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,z.ALTERNATION)}}function ai(t){let s=Array(t);for(let i=0;i<t;i++)s[i]=[];return s}function Vs(t){let s=[""];for(let i=0;i<t.length;i++){let r=t[i],a=[];for(let o=0;o<s.length;o++){let c=s[o];a.push(c+"_"+r.tokenTypeIdx);for(let h=0;h<r.categoryMatches.length;h++){let l="_"+r.categoryMatches[h];a.push(c+l)}}s=a}return s}function Na(t,s,i){for(let r=0;r<t.length;r++){if(r===i)continue;let a=t[r];for(let o=0;o<s.length;o++){let c=s[o];if(a[c]===!0)return!1}}return!0}function di(t,s){let i=t.map((c)=>is([c],1)),r=ai(i.length),a=i.map((c)=>{let h={};return c.forEach((l)=>{Vs(l.partialPath).forEach((f)=>{h[f]=!0})}),h}),o=i;for(let c=1;c<=s;c++){let h=o;o=ai(h.length);for(let l=0;l<h.length;l++){let d=h[l];for(let f=0;f<d.length;f++){let m=d[f].partialPath,T=d[f].suffixDef,g=Vs(m);if(Na(a,g,l)||T.length===0||m.length===s){let v=r[l];if(as(v,m)===!1){v.push(m);for(let b=0;b<g.length;b++){let N=g[b];a[l][N]=!0}}}else{let v=is(T,c+1,m);o[l]=o[l].concat(v),v.forEach((b)=>{Vs(b.partialPath).forEach((y)=>{a[l][y]=!0})})}}}}return r}function bt(t,s,i,r){let a=new zs(t,z.ALTERNATION,r);return s.accept(a),di(a.result,i)}function _t(t,s,i,r){let a=new zs(t,i);s.accept(a);let o=a.result,h=new ui(s,t,i).startWalking(),l=new W({definition:o}),d=new W({definition:h});return di([l,d],r)}function as(t,s){e:for(let i=0;i<t.length;i++){let r=t[i];if(r.length!==s.length)continue;for(let a=0;a<r.length;a++){let o=s[a],c=r[a];if((o===c||c.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function pi(t,s){return t.length<s.length&&t.every((i,r)=>{let a=s[r];return i===a||a.categoryMatchesMap[i.tokenTypeIdx]})}function fi(t){return t.every((s)=>s.every((i)=>i.every((r)=>r.categoryMatches.length===0)))}function mi(t){return t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}).map((i)=>Object.assign({type:ne.CUSTOM_LOOKAHEAD_VALIDATION},i))}function Ei(t,s,i,r){let a=t.flatMap((l)=>Ia(l,i)),o=va(t,s,i),c=t.flatMap((l)=>ba(l,i)),h=t.flatMap((l)=>Ca(l,t,r,i));return a.concat(o,c,h)}function Ia(t,s){let i=new gi;t.accept(i);let r=i.allProductions,a=Object.groupBy(r,ka),o=Object.fromEntries(Object.entries(a).filter(([h,l])=>l.length>1));return Object.values(o).map((h)=>{let l=h[0],d=s.buildDuplicateFoundError(t,h),f=Ae(l),m={message:d,type:ne.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:f,occurrence:l.idx},T=Ti(l);if(T)m.parameter=T;return m})}function ka(t){return`${Ae(t)}_#_${t.idx}_#_${Ti(t)}`}function Ti(t){if(t instanceof w)return t.terminalType.name;else if(t instanceof G)return t.nonTerminalName;else return""}class gi extends Te{constructor(){super(...arguments);this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function Ca(t,s,i,r){let a=[];if(s.reduce((c,h)=>{if(h.name===t.name)return c+1;return c},0)>1){let c=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:i});a.push({message:c,type:ne.DUPLICATE_RULE_NAME,ruleName:t.name})}return a}function Ai(t,s,i){let r=[],a;if(!s.includes(t))a=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${i}<-as it is not defined in any of the super grammars `,r.push({message:a,type:ne.INVALID_RULE_OVERRIDE,ruleName:t});return r}function Hs(t,s,i,r=[]){let a=[],o=os(s.definition);if(o.length===0)return[];else{let c=t.name;if(o.includes(t))a.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:ne.LEFT_RECURSION,ruleName:c});let l=r.concat([t]),f=o.filter((m)=>!l.includes(m)).flatMap((m)=>{let T=[...r];return T.push(m),Hs(t,m,i,T)});return a.concat(f)}}function os(t){let s=[];if(t.length===0)return s;let i=t[0];if(i instanceof G)s.push(i.referencedRule);else if(i instanceof W||i instanceof j||i instanceof Z||i instanceof Q||i instanceof Y||i instanceof D)s=s.concat(os(i.definition));else if(i instanceof J)s=i.definition.map((o)=>os(o.definition)).flat();else if(i instanceof w);else throw Error("non exhaustive match");let r=je(i),a=t.length>1;if(r&&a){let o=t.slice(1);return s.concat(os(o))}else return s}class ls extends Te{constructor(){super(...arguments);this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function Si(t,s){let i=new ls;return t.accept(i),i.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((h,l)=>{if(ri([h],[],Ue,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:t,alternation:o,emptyChoiceIdx:l}),type:ne.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:o.idx,alternative:l+1}];else return[]}))}function Ri(t,s,i){let r=new ls;t.accept(r);let a=r.alternations;return a=a.filter((c)=>c.ignoreAmbiguities!==!0),a.flatMap((c)=>{let h=c.idx,l=c.maxLookahead||s,d=bt(h,t,l,c),f=_a(d,c,t,i),m=xa(d,c,t,i);return f.concat(m)})}class yi extends Te{constructor(){super(...arguments);this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function ba(t,s){let i=new ls;return t.accept(i),i.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:t,alternation:o}),type:ne.TOO_MANY_ALTS,ruleName:t.name,occurrence:o.idx}];else return[]})}function Oi(t,s,i){let r=[];return t.forEach((a)=>{let o=new yi;a.accept(o),o.allProductions.forEach((h)=>{let l=rs(h),d=h.maxLookahead||s,f=h.idx;if(_t(f,a,l,d)[0].flat().length===0){let g=i.buildEmptyRepetitionError({topLevelRule:a,repetition:h});r.push({message:g,type:ne.NO_NON_EMPTY_LOOKAHEAD,ruleName:a.name})}})}),r}function _a(t,s,i,r){let a=[];return t.reduce((h,l,d)=>{if(s.definition[d].ignoreAmbiguities===!0)return h;return l.forEach((f)=>{let m=[d];if(t.forEach((T,g)=>{if(d!==g&&as(T,f)&&s.definition[g].ignoreAmbiguities!==!0)m.push(g)}),m.length>1&&!as(a,f))a.push(f),h.push({alts:m,path:f})}),h},[]).map((h)=>{let l=h.alts.map((f)=>f+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:i,alternation:s,ambiguityIndices:l,prefixPath:h.path}),type:ne.AMBIGUOUS_ALTS,ruleName:i.name,occurrence:s.idx,alternatives:h.alts}})}function xa(t,s,i,r){let a=t.reduce((c,h,l)=>{let d=h.map((f)=>({idx:l,path:f}));return c.concat(d)},[]);return a.flatMap((c)=>{if(s.definition[c.idx].ignoreAmbiguities===!0)return[];let{idx:l,path:d}=c;return a.filter((T)=>s.definition[T.idx].ignoreAmbiguities!==!0&&T.idx<l&&pi(T.path,d)).map((T)=>{let g=[T.idx+1,l+1],x=s.idx===0?"":s.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:i,alternation:s,ambiguityIndices:g,prefixPath:T.path}),type:ne.AMBIGUOUS_PREFIX_ALTS,ruleName:i.name,occurrence:x,alternatives:g}})})}function va(t,s,i){let r=[],a=s.map((o)=>o.name);return t.forEach((o)=>{let c=o.name;if(a.includes(c)){let h=i.buildNamespaceConflictError(o);r.push({message:h,type:ne.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:c})}}),r}function Li(t){let s=Object.assign({errMsgProvider:ti},t),i={};return t.rules.forEach((r)=>{i[r.name]=r}),si(i,s.errMsgProvider)}function Ni(t){var s;let i=(s=t.errMsgProvider)!==null&&s!==void 0?s:ke;return Ei(t.rules,t.tokenTypes,i,t.grammarName)}var Ii=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(Ii);function Ge(t){return Ii.includes(t.name)}class xt extends Error{constructor(t,s){super(t);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="MismatchedTokenException"}}class cs extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="NoViableAltException"}}class hs extends xt{constructor(t,s){super(t,s);this.name="NotAllInputParsedException"}}class us extends xt{constructor(t,s,i){super(t,s);this.previousToken=i,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class ki extends Error{constructor(t){super(t);this.name=Ys}}class qs{initRecoverable(t){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(t,"recoveryEnabled")?t.recoveryEnabled:he.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=Ma}getTokenToInsert(t){let s=qe(t,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,s,i,r){let a=this.findReSyncTokenType(),o=this.exportLexerState(),c=[],h=!1,l=this.LA_FAST(1),d=this.LA_FAST(1),f=()=>{let m=this.LA(0),T=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:l,previous:m,ruleName:this.getCurrRuleFullName()}),g=new ot(T,l,this.LA(0));g.resyncedTokens=c.slice(0,-1),this.SAVE_ERROR(g)};while(!h)if(this.tokenMatcher(d,r)){f();return}else if(i.call(this)){f(),t.apply(this,s);return}else if(this.tokenMatcher(d,a))h=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,c);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(t,s,i){if(i===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),t))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,s)))return!1;return!0}getNextPossibleTokenTypes(t){let s=t.ruleStack[0],r=this.getGAstProductions()[s];return new Ws(r,t).startWalking()}getFollowsForInRuleRecovery(t,s){let i=this.getCurrentGrammarPath(t,s);return this.getNextPossibleTokenTypes(i)}tryInRuleRecovery(t,s){if(this.canRecoverWithSingleTokenInsertion(t,s))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let i=this.SKIP_TOKEN();return this.consumeToken(),i}throw new ki("sad sad panda")}canPerformInRuleRecovery(t,s){return this.canRecoverWithSingleTokenInsertion(t,s)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,s){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(s.length===0)return!1;let i=this.LA_FAST(1);return s.find((a)=>this.tokenMatcher(i,a))!==void 0}canRecoverWithSingleTokenDeletion(t){if(!this.canTokenTypeBeDeletedInRecovery(t))return!1;return this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(t)}findReSyncTokenType(){let t=this.flattenFollowSet(),s=this.LA_FAST(1),i=2;while(!0){let r=t.find((a)=>kt(s,a));if(r!==void 0)return r;s=this.LA(i),i++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let t=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(i)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,i=this.RULE_STACK_IDX+1,r=Array(i);for(let a=0;a<i;a++)if(a===0)r[a]=Xs;else r[a]={ruleName:this.shortRuleNameToFullName(t[a]),idxInCallingRule:s[a],inRule:this.shortRuleNameToFullName(t[a-1])};return r}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(t){if(t===Xs)return[Re];let s=t.ruleName+t.idxInCallingRule+jt+t.inRule;return this.resyncFollows[s]}addToResyncTokens(t,s){if(!this.tokenMatcher(t,Re))s.push(t);return s}reSyncTo(t){let s=[],i=this.LA_FAST(1);while(this.tokenMatcher(i,t)===!1)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,s);return s.slice(0,-1)}attemptInRepetitionRecovery(t,s,i,r,a,o,c){}getCurrentGrammarPath(t,s){let i=this.getHumanReadableRuleStack(),r=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:i,occurrenceStack:r,lastTok:t,lastTokOccurrence:s}}getHumanReadableRuleStack(){let t=this.RULE_STACK_IDX+1,s=Array(t);for(let i=0;i<t;i++)s[i]=this.shortRuleNameToFullName(this.RULE_STACK[i]);return s}}function Ma(t,s,i,r,a,o,c){var h,l,d;let f=r|a,m=(h=(l=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&h!==void 0?h:l[d]=[],T=m[f];if(T===void 0){let b=this.getCurrRuleFullName(),N=this.getGAstProductions()[b];T=new o(N,a).startWalking(),m[f]=T}let g=T.token,x=T.occurrence,v=T.isEndOfRule;if(this.RULE_STACK_IDX===0&&v&&g===void 0)g=Re,x=1;if(g===void 0||x===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(g,x,c))this.tryInRepetitionRecovery(t,s,i,g)}var ds=256,ps=512,vt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(t){var s;this.maxLookahead=(s=t===null||t===void 0?void 0:t.maxLookahead)!==null&&s!==void 0?s:he.maxLookahead}validate(t){let s=this.validateNoLeftRecursion(t.rules);if(s.length===0){let i=this.validateEmptyOrAlternatives(t.rules),r=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),a=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...s,...i,...r,...a]}return s}validateNoLeftRecursion(t){return t.flatMap((s)=>Hs(s,s,ke))}validateEmptyOrAlternatives(t){return t.flatMap((s)=>Si(s,ke))}validateAmbiguousAlternationAlternatives(t,s){return t.flatMap((i)=>Ri(i,s,ke))}validateSomeNonEmptyLookaheadPath(t,s){return Oi(t,s,ke)}buildLookaheadForAlternation(t){return oi(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,ci)}buildLookaheadForOptional(t){return li(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,rs(t.prodType),hi)}}class Js{initLooksAhead(t){this.dynamicTokensEnabled=Object.hasOwn(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:he.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(t,"maxLookahead")?t.maxLookahead:he.maxLookahead,this.lookaheadStrategy=Object.hasOwn(t,"lookaheadStrategy")?t.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(t){t.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:i,repetition:r,option:a,repetitionMandatory:o,repetitionMandatoryWithSeparator:c,repetitionWithSeparator:h}=wa(s);i.forEach((l)=>{let d=l.idx===0?"":l.idx;this.TRACE_INIT(`${Ae(l)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:s,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],ds|l.idx,f)})}),r.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,vt,"Repetition",l.maxLookahead,Ae(l))}),a.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,ps,"Option",l.maxLookahead,Ae(l))}),o.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,Mt,"RepetitionMandatory",l.maxLookahead,Ae(l))}),c.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,lt,"RepetitionMandatoryWithSeparator",l.maxLookahead,Ae(l))}),h.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,wt,"RepetitionWithSeparator",l.maxLookahead,Ae(l))})})})}computeLookaheadFunc(t,s,i,r,a,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let c=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:t,maxLookahead:a||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r});this.setLaFuncCache(this.fullRuleNameToShort[t.name],i|s,c)})}setLaFuncCache(t,s,i){let r=this.lookAheadFuncsCache[t];if(r===void 0)r=[],this.lookAheadFuncsCache[t]=r;r[s]=i}}class Ci extends Te{constructor(){super(...arguments);this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}}var ms=new Ci;function wa(t){ms.reset(),t.accept(ms);let s=ms.dslMethods;return ms.reset(),s}function Zs(t,s){if(t.startOffset===-1)t.startOffset=s.startOffset,t.endOffset=s.endOffset;else if(t.endOffset<s.endOffset===!0)t.endOffset=s.endOffset}function Qs(t,s){if(t.startOffset===-1)t.startOffset=s.startOffset,t.startColumn=s.startColumn,t.startLine=s.startLine,t.endOffset=s.endOffset,t.endColumn=s.endColumn,t.endLine=s.endLine;else if(t.endOffset<s.endOffset===!0)t.endOffset=s.endOffset,t.endColumn=s.endColumn,t.endLine=s.endLine}function bi(t,s,i){if(t.children[i]===void 0)t.children[i]=[s];else t.children[i].push(s)}function _i(t,s,i){if(t.children[s]===void 0)t.children[s]=[i];else t.children[s].push(i)}function en(t,s){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Ua(t,s){let i=Object.keys(t),r=i.length;for(let a=0;a<r;a++){let o=i[a],c=t[o],h=c.length;for(let l=0;l<h;l++){let d=c[l];if(d.tokenTypeIdx===void 0)this[d.name](d.children,s)}}}function xi(t,s){let i=function(){};en(i,t+"BaseSemantics");let r={visit:function(a,o){if(Array.isArray(a))a=a[0];if(a===void 0)return;return this[a.name](a.children,o)},validateVisitor:function(){let a=Pa(this,s);if(a.length!==0){let o=a.map((c)=>c.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
87
87
  ${o.join(`
88
88
 
89
89
  `).replace(/\n/g,`
90
- `)}`)}}};return i.prototype=r,i.prototype.constructor=i,i._RULE_NAMES=s,i}function vi(t,s,i){let r=function(){};en(r,t+"BaseSemanticsWithDefaults");let a=Object.create(i.prototype);return s.forEach((o)=>{a[o]=Ua}),r.prototype=a,r.prototype.constructor=r,r}var tn;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(tn||(tn={}));function Pa(t,s){return Da(t,s)}function Da(t,s){return s.filter((a)=>typeof t[a]==="function"===!1).map((a)=>({msg:`Missing visitor method: <${a}> on ${t.constructor.name} CST Visitor.`,type:tn.MISSING_METHOD,methodName:a})).filter(Boolean)}class sn{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=Object.hasOwn(t,"nodeLocationTracking")?t.nodeLocationTracking:ue.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Qs,this.setNodeLocationFromNode=Qs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular;else if(/onlyOffset/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Zs,this.setNodeLocationFromNode=Zs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular;else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(t){let s=this.LA_FAST(1);t.location={startOffset:s.startOffset,startLine:s.startLine,startColumn:s.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(t){let s={name:t,children:Object.create(null)};this.setInitialNodeLocation(s),this.CST_STACK.push(s)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let s=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=s.startOffset===!0)i.endOffset=s.endOffset,i.endLine=s.endLine,i.endColumn=s.endColumn;else i.startOffset=-1,i.startLine=-1,i.startColumn=-1}cstPostRuleOnlyOffset(t){let s=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=s.startOffset===!0)i.endOffset=s.endOffset;else i.startOffset=-1}cstPostTerminal(t,s){let i=this.CST_STACK[this.CST_STACK.length-1];bi(i,s,t),this.setNodeLocationFromToken(i.location,s)}cstPostNonTerminal(t,s){let i=this.CST_STACK[this.CST_STACK.length-1];_i(i,s,t),this.setNodeLocationFromNode(i.location,t.location)}get currCSTNode(){let t=this;return t.CST_STACK[t.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let t=xi(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let t=vi(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class nn{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){if(this.currIdx<=this.tokVectorLength-2)return this.consumeToken(),this.LA_FAST(1);else return De}LA_FAST(t){let s=this.currIdx+t;return this.tokVector[s]}LA(t){let s=this.currIdx+t;if(s<0||this.tokVectorLength<=s)return De;else return this.tokVector[s]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class rn{ACTION(t){return t.call(this)}consume(t,s,i){return this.consumeInternal(s,t,i)}subrule(t,s,i){return this.subruleInternal(s,t,i)}option(t,s){return this.optionInternal(s,t)}or(t,s){return this.orInternal(s,t)}many(t,s){return this.manyInternal(t,s)}atLeastOne(t,s){return this.atLeastOneInternal(t,s)}CONSUME(t,s){return this.consumeInternal(t,0,s)}CONSUME1(t,s){return this.consumeInternal(t,1,s)}CONSUME2(t,s){return this.consumeInternal(t,2,s)}CONSUME3(t,s){return this.consumeInternal(t,3,s)}CONSUME4(t,s){return this.consumeInternal(t,4,s)}CONSUME5(t,s){return this.consumeInternal(t,5,s)}CONSUME6(t,s){return this.consumeInternal(t,6,s)}CONSUME7(t,s){return this.consumeInternal(t,7,s)}CONSUME8(t,s){return this.consumeInternal(t,8,s)}CONSUME9(t,s){return this.consumeInternal(t,9,s)}SUBRULE(t,s){return this.subruleInternal(t,0,s)}SUBRULE1(t,s){return this.subruleInternal(t,1,s)}SUBRULE2(t,s){return this.subruleInternal(t,2,s)}SUBRULE3(t,s){return this.subruleInternal(t,3,s)}SUBRULE4(t,s){return this.subruleInternal(t,4,s)}SUBRULE5(t,s){return this.subruleInternal(t,5,s)}SUBRULE6(t,s){return this.subruleInternal(t,6,s)}SUBRULE7(t,s){return this.subruleInternal(t,7,s)}SUBRULE8(t,s){return this.subruleInternal(t,8,s)}SUBRULE9(t,s){return this.subruleInternal(t,9,s)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,s,i=ct){if(this.definedRulesNames.includes(t)){let o={message:Ie.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:ne.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(o)}this.definedRulesNames.push(t);let r=this.defineRule(t,s,i);return this[t]=r,r}OVERRIDE_RULE(t,s,i=ct){let r=Ai(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let a=this.defineRule(t,s,i);return this[t]=a,a}BACKTRACK(t,s){var i;let r=(i=t.coreRule)!==null&&i!==void 0?i:t;return function(){this.isBackTrackingStack.push(1);let a=this.saveRecogState();try{return r.apply(this,s),!0}catch(o){if(Ge(o))return!1;else throw o}finally{this.reloadRecogState(a),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Wt(Object.values(this.gastProductionsCache))}}class an{initRecognizerEngine(t,s){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=at,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(s,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
90
+ `)}`)}}};return i.prototype=r,i.prototype.constructor=i,i._RULE_NAMES=s,i}function vi(t,s,i){let r=function(){};en(r,t+"BaseSemanticsWithDefaults");let a=Object.create(i.prototype);return s.forEach((o)=>{a[o]=Ua}),r.prototype=a,r.prototype.constructor=r,r}var tn;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(tn||(tn={}));function Pa(t,s){return Da(t,s)}function Da(t,s){return s.filter((a)=>typeof t[a]==="function"===!1).map((a)=>({msg:`Missing visitor method: <${a}> on ${t.constructor.name} CST Visitor.`,type:tn.MISSING_METHOD,methodName:a})).filter(Boolean)}class sn{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=Object.hasOwn(t,"nodeLocationTracking")?t.nodeLocationTracking:he.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Qs,this.setNodeLocationFromNode=Qs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular;else if(/onlyOffset/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Zs,this.setNodeLocationFromNode=Zs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular;else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(t){let s=this.LA_FAST(1);t.location={startOffset:s.startOffset,startLine:s.startLine,startColumn:s.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(t){let s={name:t,children:Object.create(null)};this.setInitialNodeLocation(s),this.CST_STACK.push(s)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let s=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=s.startOffset===!0)i.endOffset=s.endOffset,i.endLine=s.endLine,i.endColumn=s.endColumn;else i.startOffset=-1,i.startLine=-1,i.startColumn=-1}cstPostRuleOnlyOffset(t){let s=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=s.startOffset===!0)i.endOffset=s.endOffset;else i.startOffset=-1}cstPostTerminal(t,s){let i=this.CST_STACK[this.CST_STACK.length-1];bi(i,s,t),this.setNodeLocationFromToken(i.location,s)}cstPostNonTerminal(t,s){let i=this.CST_STACK[this.CST_STACK.length-1];_i(i,s,t),this.setNodeLocationFromNode(i.location,t.location)}get currCSTNode(){let t=this;return t.CST_STACK[t.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let t=xi(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let t=vi(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class nn{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){if(this.currIdx<=this.tokVectorLength-2)return this.consumeToken(),this.LA_FAST(1);else return De}LA_FAST(t){let s=this.currIdx+t;return this.tokVector[s]}LA(t){let s=this.currIdx+t;if(s<0||this.tokVectorLength<=s)return De;else return this.tokVector[s]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class rn{ACTION(t){return t.call(this)}consume(t,s,i){return this.consumeInternal(s,t,i)}subrule(t,s,i){return this.subruleInternal(s,t,i)}option(t,s){return this.optionInternal(s,t)}or(t,s){return this.orInternal(s,t)}many(t,s){return this.manyInternal(t,s)}atLeastOne(t,s){return this.atLeastOneInternal(t,s)}CONSUME(t,s){return this.consumeInternal(t,0,s)}CONSUME1(t,s){return this.consumeInternal(t,1,s)}CONSUME2(t,s){return this.consumeInternal(t,2,s)}CONSUME3(t,s){return this.consumeInternal(t,3,s)}CONSUME4(t,s){return this.consumeInternal(t,4,s)}CONSUME5(t,s){return this.consumeInternal(t,5,s)}CONSUME6(t,s){return this.consumeInternal(t,6,s)}CONSUME7(t,s){return this.consumeInternal(t,7,s)}CONSUME8(t,s){return this.consumeInternal(t,8,s)}CONSUME9(t,s){return this.consumeInternal(t,9,s)}SUBRULE(t,s){return this.subruleInternal(t,0,s)}SUBRULE1(t,s){return this.subruleInternal(t,1,s)}SUBRULE2(t,s){return this.subruleInternal(t,2,s)}SUBRULE3(t,s){return this.subruleInternal(t,3,s)}SUBRULE4(t,s){return this.subruleInternal(t,4,s)}SUBRULE5(t,s){return this.subruleInternal(t,5,s)}SUBRULE6(t,s){return this.subruleInternal(t,6,s)}SUBRULE7(t,s){return this.subruleInternal(t,7,s)}SUBRULE8(t,s){return this.subruleInternal(t,8,s)}SUBRULE9(t,s){return this.subruleInternal(t,9,s)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,s,i=ct){if(this.definedRulesNames.includes(t)){let o={message:ke.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:ne.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(o)}this.definedRulesNames.push(t);let r=this.defineRule(t,s,i);return this[t]=r,r}OVERRIDE_RULE(t,s,i=ct){let r=Ai(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let a=this.defineRule(t,s,i);return this[t]=a,a}BACKTRACK(t,s){var i;let r=(i=t.coreRule)!==null&&i!==void 0?i:t;return function(){this.isBackTrackingStack.push(1);let a=this.saveRecogState();try{return r.apply(this,s),!0}catch(o){if(Ge(o))return!1;else throw o}finally{this.reloadRecogState(a),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Wt(Object.values(this.gastProductionsCache))}}class an{initRecognizerEngine(t,s){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=at,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(s,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
91
91
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
92
92
  For Further details.`);if(Array.isArray(t)){if(t.length===0)throw Error(`A Token Vocabulary cannot be empty.
93
93
  Note that the first argument for the parser constructor
94
94
  is no longer a Token vector (since v4.0).`);if(typeof t[0].startOffset==="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
95
95
  See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
96
- For Further details.`)}if(Array.isArray(t))this.tokensMap=t.reduce((a,o)=>(a[o.name]=o,a),{});else if(Object.hasOwn(t,"modes")&&Object.values(t.modes).flat().every(zn)){let a=Object.values(t.modes).flat(),o=[...new Set(a)];this.tokensMap=o.reduce((c,h)=>(c[h.name]=h,c),{})}else if(typeof t==="object"&&t!==null)this.tokensMap=Object.assign({},t);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Se;let r=(Object.hasOwn(t,"modes")?Object.values(t.modes).flat():Object.values(t)).every((a)=>{var o;return((o=a.categoryMatches)===null||o===void 0?void 0:o.length)==0});this.tokenMatcher=r?at:Ue,Pe(Object.values(this.tokensMap))}defineRule(t,s,i){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
97
- Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=Object.hasOwn(i,"resyncEnabled")?i.resyncEnabled:ct.resyncEnabled,a=Object.hasOwn(i,"recoveryValueFunc")?i.recoveryValueFunc:ct.recoveryValueFunc,o=this.ruleShortNameIdx++;this.shortRuleNameToFull[o]=t,this.fullRuleNameToShort[t]=o;let c;if(this.outputCst===!0)c=function(...p){try{this.ruleInvocationStateUpdate(o,t,this.subruleIdx),s.apply(this,p);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,r,a)}finally{this.ruleFinallyStateUpdate()}};else c=function(...p){try{return this.ruleInvocationStateUpdate(o,t,this.subruleIdx),s.apply(this,p)}catch(f){return this.invokeRuleCatch(f,r,a)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...p){this.onBeforeParse(t);try{return c.apply(this,p)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:s,coreRule:c})}invokeRuleCatch(t,s,i){let r=this.RULE_STACK_IDX===0,a=s&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(t)){let o=t;if(a){let c=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(c))if(o.resyncedTokens=this.reSyncTo(c),this.outputCst){let h=this.CST_STACK[this.CST_STACK.length-1];return h.recoveredNode=!0,h}else return i(t);else{if(this.outputCst){let h=this.CST_STACK[this.CST_STACK.length-1];h.recoveredNode=!0,o.partialCstResult=h}throw o}}else if(r)return this.moveToTerminatedState(),i(t);else throw o}else throw t}optionInternal(t,s){let i=ps|s;return this.optionInternalLogic(t,s,i)}optionInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof t!=="function"){a=t.DEF;let o=t.GATE;if(o!==void 0){let c=r;r=()=>o.call(this)&&c.call(this)}}else a=t;if(r.call(this)===!0)return a.call(this);return}atLeastOneInternal(t,s){let i=Mt|t;return this.atLeastOneInternalLogic(t,s,i)}atLeastOneInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof s!=="function"){a=s.DEF;let o=s.GATE;if(o!==void 0){let c=r;r=()=>o.call(this)&&c.call(this)}}else a=s;if(r.call(this)===!0){let o=this.doSingleRepetition(a);while(r.call(this)===!0&&o===!0)o=this.doSingleRepetition(a)}else throw this.raiseEarlyExitException(t,V.REPETITION_MANDATORY,s.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,s],r,Mt,t,Ks)}atLeastOneSepFirstInternal(t,s){let i=lt|t;this.atLeastOneSepFirstInternalLogic(t,s,i)}atLeastOneSepFirstInternalLogic(t,s,i){let{DEF:r,SEP:a}=s;if(this.currRuleLookaheadFuncs[i].call(this)===!0){r.call(this);let c=()=>this.tokenMatcher(this.LA_FAST(1),a);while(this.tokenMatcher(this.LA_FAST(1),a)===!0)this.CONSUME(a),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,a,c,r,ns],c,lt,t,ns)}else throw this.raiseEarlyExitException(t,V.REPETITION_MANDATORY_WITH_SEPARATOR,s.ERR_MSG)}manyInternal(t,s){let i=vt|t;return this.manyInternalLogic(t,s,i)}manyInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof s!=="function"){a=s.DEF;let c=s.GATE;if(c!==void 0){let h=r;r=()=>c.call(this)&&h.call(this)}}else a=s;let o=!0;while(r.call(this)===!0&&o===!0)o=this.doSingleRepetition(a);this.attemptInRepetitionRecovery(this.manyInternal,[t,s],r,vt,t,js,o)}manySepFirstInternal(t,s){let i=wt|t;this.manySepFirstInternalLogic(t,s,i)}manySepFirstInternalLogic(t,s,i){let{DEF:r,SEP:a}=s;if(this.currRuleLookaheadFuncs[i].call(this)===!0){r.call(this);let c=()=>this.tokenMatcher(this.LA_FAST(1),a);while(this.tokenMatcher(this.LA_FAST(1),a)===!0)this.CONSUME(a),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,a,c,r,ss],c,wt,t,ss)}}repetitionSepSecondInternal(t,s,i,r,a){while(i())this.CONSUME(s),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,s,i,r,a],i,lt,t,a)}doSingleRepetition(t){let s=this.getLexerPosition();return t.call(this),this.getLexerPosition()>s}orInternal(t,s){let i=ds|s,r=Array.isArray(t)?t:t.DEF,o=this.currRuleLookaheadFuncs[i].call(this,r);if(o!==void 0)return r[o].ALT.call(this);this.raiseNoAltException(s,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName];this.cstFinallyStateUpdate()}subruleInternal(t,s,i){let r;try{let a=i!==void 0?i.ARGS:void 0;return this.subruleIdx=s,r=t.coreRule.apply(this,a),this.cstPostNonTerminal(r,i!==void 0&&i.LABEL!==void 0?i.LABEL:t.ruleName),r}catch(a){throw this.subruleInternalError(a,i,t.ruleName)}}subruleInternalError(t,s,i){if(Ge(t)&&t.partialCstResult!==void 0)this.cstPostNonTerminal(t.partialCstResult,s!==void 0&&s.LABEL!==void 0?s.LABEL:i),delete t.partialCstResult;throw t}consumeInternal(t,s,i){let r;try{let a=this.LA_FAST(1);if(this.tokenMatcher(a,t)===!0)this.consumeToken(),r=a;else this.consumeInternalError(t,a,i)}catch(a){r=this.consumeInternalRecovery(t,s,a)}return this.cstPostTerminal(i!==void 0&&i.LABEL!==void 0?i.LABEL:t.name,r),r}consumeInternalError(t,s,i){let r,a=this.LA(0);if(i!==void 0&&i.ERR_MSG)r=i.ERR_MSG;else r=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:s,previous:a,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ot(r,s,a))}consumeInternalRecovery(t,s,i){if(this.recoveryEnabled&&i.name==="MismatchedTokenException"&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(t,s);try{return this.tryInRuleRecovery(t,r)}catch(a){if(a.name===Ys)throw i;else throw a}}else throw i}saveRecogState(){let t=this.errors,s=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:s,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);let s=t.RULE_STACK;for(let i=0;i<s.length;i++)this.RULE_STACK[i]=s[i];if(this.RULE_STACK_IDX=s.length-1,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]}ruleInvocationStateUpdate(t,s,i){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=i,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[t],this.cstInvocationStateUpdate(s)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Se)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(t){for(let s=0;s<this.maxLookahead+1;s++)this.tokVector.push(De)}onAfterParse(t){if(this.isAtEndOfInput()===!1){let s=this.LA(1),i=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:s,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new hs(i,s))}while(this.tokVector.at(-1)===De)this.tokVector.pop()}}class on{initErrorHandler(t){this._errors=[],this.errorMessageProvider=Object.hasOwn(t,"errorMessageProvider")?t.errorMessageProvider:ue.errorMessageProvider}SAVE_ERROR(t){if(Ge(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(t),t;else throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(t){this._errors=t}raiseEarlyExitException(t,s,i){let r=this.getCurrRuleFullName(),a=this.getGAstProductions()[r],c=_t(t,a,s,this.maxLookahead)[0],h=[];for(let d=1;d<=this.maxLookahead;d++)h.push(this.LA(d));let l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:c,actual:h,previous:this.LA(0),customUserDescription:i,ruleName:r});throw this.SAVE_ERROR(new us(l,this.LA(1),this.LA(0)))}raiseNoAltException(t,s){let i=this.getCurrRuleFullName(),r=this.getGAstProductions()[i],a=bt(t,r,this.maxLookahead),o=[];for(let l=1;l<=this.maxLookahead;l++)o.push(this.LA(l));let c=this.LA(0),h=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:a,actual:o,previous:c,customUserDescription:s,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new cs(h,this.LA(1),c))}}var Ts={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ts);var Mi=!0,wi=255,Pi=S({name:"RECORDING_PHASE_TOKEN",pattern:K.NA});Pe([Pi]);var Di=qe(Pi,`This IToken indicates the Parser is in Recording Phase
96
+ For Further details.`)}if(Array.isArray(t))this.tokensMap=t.reduce((a,o)=>(a[o.name]=o,a),{});else if(Object.hasOwn(t,"modes")&&Object.values(t.modes).flat().every(zn)){let a=Object.values(t.modes).flat(),o=[...new Set(a)];this.tokensMap=o.reduce((c,h)=>(c[h.name]=h,c),{})}else if(typeof t==="object"&&t!==null)this.tokensMap=Object.assign({},t);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Re;let r=(Object.hasOwn(t,"modes")?Object.values(t.modes).flat():Object.values(t)).every((a)=>{var o;return((o=a.categoryMatches)===null||o===void 0?void 0:o.length)==0});this.tokenMatcher=r?at:Ue,Pe(Object.values(this.tokensMap))}defineRule(t,s,i){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
97
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=Object.hasOwn(i,"resyncEnabled")?i.resyncEnabled:ct.resyncEnabled,a=Object.hasOwn(i,"recoveryValueFunc")?i.recoveryValueFunc:ct.recoveryValueFunc,o=this.ruleShortNameIdx++;this.shortRuleNameToFull[o]=t,this.fullRuleNameToShort[t]=o;let c;if(this.outputCst===!0)c=function(...f){try{this.ruleInvocationStateUpdate(o,t,this.subruleIdx),s.apply(this,f);let m=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(m),m}catch(m){return this.invokeRuleCatch(m,r,a)}finally{this.ruleFinallyStateUpdate()}};else c=function(...f){try{return this.ruleInvocationStateUpdate(o,t,this.subruleIdx),s.apply(this,f)}catch(m){return this.invokeRuleCatch(m,r,a)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...f){this.onBeforeParse(t);try{return c.apply(this,f)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:s,coreRule:c})}invokeRuleCatch(t,s,i){let r=this.RULE_STACK_IDX===0,a=s&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(t)){let o=t;if(a){let c=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(c))if(o.resyncedTokens=this.reSyncTo(c),this.outputCst){let h=this.CST_STACK[this.CST_STACK.length-1];return h.recoveredNode=!0,h}else return i(t);else{if(this.outputCst){let h=this.CST_STACK[this.CST_STACK.length-1];h.recoveredNode=!0,o.partialCstResult=h}throw o}}else if(r)return this.moveToTerminatedState(),i(t);else throw o}else throw t}optionInternal(t,s){let i=ps|s;return this.optionInternalLogic(t,s,i)}optionInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof t!=="function"){a=t.DEF;let o=t.GATE;if(o!==void 0){let c=r;r=()=>o.call(this)&&c.call(this)}}else a=t;if(r.call(this)===!0)return a.call(this);return}atLeastOneInternal(t,s){let i=Mt|t;return this.atLeastOneInternalLogic(t,s,i)}atLeastOneInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof s!=="function"){a=s.DEF;let o=s.GATE;if(o!==void 0){let c=r;r=()=>o.call(this)&&c.call(this)}}else a=s;if(r.call(this)===!0){let o=this.doSingleRepetition(a);while(r.call(this)===!0&&o===!0)o=this.doSingleRepetition(a)}else throw this.raiseEarlyExitException(t,z.REPETITION_MANDATORY,s.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,s],r,Mt,t,Ks)}atLeastOneSepFirstInternal(t,s){let i=lt|t;this.atLeastOneSepFirstInternalLogic(t,s,i)}atLeastOneSepFirstInternalLogic(t,s,i){let{DEF:r,SEP:a}=s;if(this.currRuleLookaheadFuncs[i].call(this)===!0){r.call(this);let c=()=>this.tokenMatcher(this.LA_FAST(1),a);while(this.tokenMatcher(this.LA_FAST(1),a)===!0)this.CONSUME(a),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,a,c,r,ns],c,lt,t,ns)}else throw this.raiseEarlyExitException(t,z.REPETITION_MANDATORY_WITH_SEPARATOR,s.ERR_MSG)}manyInternal(t,s){let i=vt|t;return this.manyInternalLogic(t,s,i)}manyInternalLogic(t,s,i){let r=this.currRuleLookaheadFuncs[i],a;if(typeof s!=="function"){a=s.DEF;let c=s.GATE;if(c!==void 0){let h=r;r=()=>c.call(this)&&h.call(this)}}else a=s;let o=!0;while(r.call(this)===!0&&o===!0)o=this.doSingleRepetition(a);this.attemptInRepetitionRecovery(this.manyInternal,[t,s],r,vt,t,js,o)}manySepFirstInternal(t,s){let i=wt|t;this.manySepFirstInternalLogic(t,s,i)}manySepFirstInternalLogic(t,s,i){let{DEF:r,SEP:a}=s;if(this.currRuleLookaheadFuncs[i].call(this)===!0){r.call(this);let c=()=>this.tokenMatcher(this.LA_FAST(1),a);while(this.tokenMatcher(this.LA_FAST(1),a)===!0)this.CONSUME(a),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,a,c,r,ss],c,wt,t,ss)}}repetitionSepSecondInternal(t,s,i,r,a){while(i())this.CONSUME(s),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,s,i,r,a],i,lt,t,a)}doSingleRepetition(t){let s=this.getLexerPosition();return t.call(this),this.getLexerPosition()>s}orInternal(t,s){let i=ds|s,r=Array.isArray(t)?t:t.DEF,o=this.currRuleLookaheadFuncs[i].call(this,r);if(o!==void 0)return r[o].ALT.call(this);this.raiseNoAltException(s,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName];this.cstFinallyStateUpdate()}subruleInternal(t,s,i){let r;try{let a=i!==void 0?i.ARGS:void 0;return this.subruleIdx=s,r=t.coreRule.apply(this,a),this.cstPostNonTerminal(r,i!==void 0&&i.LABEL!==void 0?i.LABEL:t.ruleName),r}catch(a){throw this.subruleInternalError(a,i,t.ruleName)}}subruleInternalError(t,s,i){if(Ge(t)&&t.partialCstResult!==void 0)this.cstPostNonTerminal(t.partialCstResult,s!==void 0&&s.LABEL!==void 0?s.LABEL:i),delete t.partialCstResult;throw t}consumeInternal(t,s,i){let r;try{let a=this.LA_FAST(1);if(this.tokenMatcher(a,t)===!0)this.consumeToken(),r=a;else this.consumeInternalError(t,a,i)}catch(a){r=this.consumeInternalRecovery(t,s,a)}return this.cstPostTerminal(i!==void 0&&i.LABEL!==void 0?i.LABEL:t.name,r),r}consumeInternalError(t,s,i){let r,a=this.LA(0);if(i!==void 0&&i.ERR_MSG)r=i.ERR_MSG;else r=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:s,previous:a,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ot(r,s,a))}consumeInternalRecovery(t,s,i){if(this.recoveryEnabled&&i.name==="MismatchedTokenException"&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(t,s);try{return this.tryInRuleRecovery(t,r)}catch(a){if(a.name===Ys)throw i;else throw a}}else throw i}saveRecogState(){let t=this.errors,s=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:s,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);let s=t.RULE_STACK;for(let i=0;i<s.length;i++)this.RULE_STACK[i]=s[i];if(this.RULE_STACK_IDX=s.length-1,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]}ruleInvocationStateUpdate(t,s,i){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=i,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[t],this.cstInvocationStateUpdate(s)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Re)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(t){for(let s=0;s<this.maxLookahead+1;s++)this.tokVector.push(De)}onAfterParse(t){if(this.isAtEndOfInput()===!1){let s=this.LA(1),i=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:s,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new hs(i,s))}while(this.tokVector.at(-1)===De)this.tokVector.pop()}}class on{initErrorHandler(t){this._errors=[],this.errorMessageProvider=Object.hasOwn(t,"errorMessageProvider")?t.errorMessageProvider:he.errorMessageProvider}SAVE_ERROR(t){if(Ge(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(t),t;else throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(t){this._errors=t}raiseEarlyExitException(t,s,i){let r=this.getCurrRuleFullName(),a=this.getGAstProductions()[r],c=_t(t,a,s,this.maxLookahead)[0],h=[];for(let d=1;d<=this.maxLookahead;d++)h.push(this.LA(d));let l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:c,actual:h,previous:this.LA(0),customUserDescription:i,ruleName:r});throw this.SAVE_ERROR(new us(l,this.LA(1),this.LA(0)))}raiseNoAltException(t,s){let i=this.getCurrRuleFullName(),r=this.getGAstProductions()[i],a=bt(t,r,this.maxLookahead),o=[];for(let l=1;l<=this.maxLookahead;l++)o.push(this.LA(l));let c=this.LA(0),h=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:a,actual:o,previous:c,customUserDescription:s,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new cs(h,this.LA(1),c))}}var Ts={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ts);var Mi=!0,wi=255,Pi=S({name:"RECORDING_PHASE_TOKEN",pattern:V.NA});Pe([Pi]);var Di=qe(Pi,`This IToken indicates the Parser is in Recording Phase
98
98
  See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Di);var Fa={name:`This CSTNode indicates the Parser is in Recording Phase
99
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class ln{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let s=t>0?t:"";this[`CONSUME${s}`]=function(i,r){return this.consumeInternalRecord(i,t,r)},this[`SUBRULE${s}`]=function(i,r){return this.subruleInternalRecord(i,t,r)},this[`OPTION${s}`]=function(i){return this.optionInternalRecord(i,t)},this[`OR${s}`]=function(i){return this.orInternalRecord(i,t)},this[`MANY${s}`]=function(i){this.manyInternalRecord(t,i)},this[`MANY_SEP${s}`]=function(i){this.manySepFirstInternalRecord(t,i)},this[`AT_LEAST_ONE${s}`]=function(i){this.atLeastOneInternalRecord(t,i)},this[`AT_LEAST_ONE_SEP${s}`]=function(i){this.atLeastOneSepFirstInternalRecord(t,i)}}this.consume=function(t,s,i){return this.consumeInternalRecord(s,t,i)},this.subrule=function(t,s,i){return this.subruleInternalRecord(s,t,i)},this.option=function(t,s){return this.optionInternalRecord(s,t)},this.or=function(t,s){return this.orInternalRecord(s,t)},this.many=function(t,s){this.manyInternalRecord(t,s)},this.atLeastOne=function(t,s){this.atLeastOneInternalRecord(t,s)},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 t=this;for(let s=0;s<10;s++){let i=s>0?s:"";delete t[`CONSUME${i}`],delete t[`SUBRULE${i}`],delete t[`OPTION${i}`],delete t[`OR${i}`],delete t[`MANY${i}`],delete t[`MANY_SEP${i}`],delete t[`AT_LEAST_ONE${i}`],delete t[`AT_LEAST_ONE_SEP${i}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,s){return()=>!0}LA_RECORD(t){return De}topLevelRuleRecord(t,s){try{let i=new fe({definition:[],name:t});return i.name=t,this.recordingProdStack.push(i),s.call(this),this.recordingProdStack.pop(),i}catch(i){if(i.KNOWN_RECORDER_ERROR!==!0)try{i.message=i.message+`
99
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class ln{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let s=t>0?t:"";this[`CONSUME${s}`]=function(i,r){return this.consumeInternalRecord(i,t,r)},this[`SUBRULE${s}`]=function(i,r){return this.subruleInternalRecord(i,t,r)},this[`OPTION${s}`]=function(i){return this.optionInternalRecord(i,t)},this[`OR${s}`]=function(i){return this.orInternalRecord(i,t)},this[`MANY${s}`]=function(i){this.manyInternalRecord(t,i)},this[`MANY_SEP${s}`]=function(i){this.manySepFirstInternalRecord(t,i)},this[`AT_LEAST_ONE${s}`]=function(i){this.atLeastOneInternalRecord(t,i)},this[`AT_LEAST_ONE_SEP${s}`]=function(i){this.atLeastOneSepFirstInternalRecord(t,i)}}this.consume=function(t,s,i){return this.consumeInternalRecord(s,t,i)},this.subrule=function(t,s,i){return this.subruleInternalRecord(s,t,i)},this.option=function(t,s){return this.optionInternalRecord(s,t)},this.or=function(t,s){return this.orInternalRecord(s,t)},this.many=function(t,s){this.manyInternalRecord(t,s)},this.atLeastOne=function(t,s){this.atLeastOneInternalRecord(t,s)},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 t=this;for(let s=0;s<10;s++){let i=s>0?s:"";delete t[`CONSUME${i}`],delete t[`SUBRULE${i}`],delete t[`OPTION${i}`],delete t[`OR${i}`],delete t[`MANY${i}`],delete t[`MANY_SEP${i}`],delete t[`AT_LEAST_ONE${i}`],delete t[`AT_LEAST_ONE_SEP${i}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,s){return()=>!0}LA_RECORD(t){return De}topLevelRuleRecord(t,s){try{let i=new me({definition:[],name:t});return i.name=t,this.recordingProdStack.push(i),s.call(this),this.recordingProdStack.pop(),i}catch(i){if(i.KNOWN_RECORDER_ERROR!==!0)try{i.message=i.message+`
100
100
  This error was thrown during the "grammar recording phase" For more info see:
101
- https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(r){throw i}throw i}}optionInternalRecord(t,s){return Ut.call(this,W,t,s)}atLeastOneInternalRecord(t,s){Ut.call(this,Z,s,t)}atLeastOneSepFirstInternalRecord(t,s){Ut.call(this,Q,s,t,Mi)}manyInternalRecord(t,s){Ut.call(this,P,s,t)}manySepFirstInternalRecord(t,s){Ut.call(this,Y,s,t,Mi)}orInternalRecord(t,s){return Ba.call(this,t,s)}subruleInternalRecord(t,s,i){if(Es(s),!t||!Object.hasOwn(t,"ruleName")){let c=Error(`<SUBRULE${Ui(s)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
102
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw c.KNOWN_RECORDER_ERROR=!0,c}let r=this.recordingProdStack.at(-1),a=t.ruleName,o=new B({idx:s,nonTerminalName:a,label:i===null||i===void 0?void 0:i.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?Fa:Ts}consumeInternalRecord(t,s,i){if(Es(s),!Bs(t)){let o=Error(`<CONSUME${Ui(s)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
103
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let r=this.recordingProdStack.at(-1),a=new w({idx:s,terminalType:t,label:i===null||i===void 0?void 0:i.LABEL});return r.definition.push(a),Di}}function Ut(t,s,i,r=!1){Es(i);let a=this.recordingProdStack.at(-1),o=typeof s==="function"?s:s.DEF,c=new t({definition:[],idx:i});if(r)c.separator=s.SEP;if(Object.hasOwn(s,"MAX_LOOKAHEAD"))c.maxLookahead=s.MAX_LOOKAHEAD;return this.recordingProdStack.push(c),o.call(this),a.definition.push(c),this.recordingProdStack.pop(),Ts}function Ba(t,s){Es(s);let i=this.recordingProdStack.at(-1),r=Array.isArray(t)===!1,a=r===!1?t:t.DEF,o=new J({definition:[],idx:s,ignoreAmbiguities:r&&t.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(t,"MAX_LOOKAHEAD"))o.maxLookahead=t.MAX_LOOKAHEAD;let c=a.some((h)=>typeof h.GATE==="function");return o.hasPredicates=c,i.definition.push(o),a.forEach((h)=>{let l=new G({definition:[]});if(o.definition.push(l),Object.hasOwn(h,"IGNORE_AMBIGUITIES"))l.ignoreAmbiguities=h.IGNORE_AMBIGUITIES;else if(Object.hasOwn(h,"GATE"))l.ignoreAmbiguities=!0;this.recordingProdStack.push(l),h.ALT.call(this),this.recordingProdStack.pop()}),Ts}function Ui(t){return t===0?"":`${t}`}function Es(t){if(t<0||t>wi){let s=Error(`Invalid DSL Method idx value: <${t}>
104
- Idx value must be a none negative value smaller than ${wi+1}`);throw s.KNOWN_RECORDER_ERROR=!0,s}}class cn{initPerformanceTracer(t){if(Object.hasOwn(t,"traceInitPerf")){let s=t.traceInitPerf,i=typeof s==="number";this.traceInitMaxIdent=i?s:1/0,this.traceInitPerf=i?s>0:s}else this.traceInitMaxIdent=0,this.traceInitPerf=ue.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,s){if(this.traceInitPerf===!0){this.traceInitIndent++;let i=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${i}--> <${t}>`);let{time:r,value:a}=gt(s),o=r>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)o(`${i}<-- <${t}> time: ${r}ms`);return this.traceInitIndent--,a}else return s()}}function Fi(t,s){s.forEach((i)=>{let r=i.prototype;Object.getOwnPropertyNames(r).forEach((a)=>{if(a==="constructor")return;let o=Object.getOwnPropertyDescriptor(r,a);if(o&&(o.get||o.set))Object.defineProperty(t.prototype,a,o);else t.prototype[a]=i.prototype[a]})})}var De=qe(Se,"",-1,-1,-1,-1,-1,-1);Object.freeze(De);var ue=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ts,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ct=Object.freeze({recoveryValueFunc:()=>{return},resyncEnabled:!0}),ne;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ne||(ne={}));class Pt{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let s=this.className;this.TRACE_INIT("toFastProps",()=>{At(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach((r)=>{let o=this[r].originalGrammarAction,c;this.TRACE_INIT(`${r} Rule`,()=>{c=this.topLevelRuleRecord(r,o)}),this.gastProductionsCache[r]=c})}finally{this.disableRecording()}});let i=[];if(this.TRACE_INIT("Grammar Resolving",()=>{i=Li({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(i)}),this.TRACE_INIT("Grammar Validations",()=>{if(i.length===0&&this.skipValidations===!1){let r=Ni({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:Ie,grammarName:s}),a=mi({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:s});this.definitionErrors=this.definitionErrors.concat(r,a)}}),this.definitionErrors.length===0){if(this.recoveryEnabled)this.TRACE_INIT("computeAllProdsFollows",()=>{let r=kn(Object.values(this.gastProductionsCache));this.resyncFollows=r});this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var r,a;(a=(r=this.lookaheadStrategy).initialize)===null||a===void 0||a.call(r,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})}if(!Pt.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw t=this.definitionErrors.map((r)=>r.message),Error(`Parser Definition Errors detected:
101
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(r){throw i}throw i}}optionInternalRecord(t,s){return Ut.call(this,j,t,s)}atLeastOneInternalRecord(t,s){Ut.call(this,Z,s,t)}atLeastOneSepFirstInternalRecord(t,s){Ut.call(this,Q,s,t,Mi)}manyInternalRecord(t,s){Ut.call(this,D,s,t)}manySepFirstInternalRecord(t,s){Ut.call(this,Y,s,t,Mi)}orInternalRecord(t,s){return Ba.call(this,t,s)}subruleInternalRecord(t,s,i){if(Es(s),!t||!Object.hasOwn(t,"ruleName")){let c=Error(`<SUBRULE${Ui(s)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
102
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw c.KNOWN_RECORDER_ERROR=!0,c}let r=this.recordingProdStack.at(-1),a=t.ruleName,o=new G({idx:s,nonTerminalName:a,label:i===null||i===void 0?void 0:i.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?Fa:Ts}consumeInternalRecord(t,s,i){if(Es(s),!Bs(t)){let o=Error(`<CONSUME${Ui(s)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
103
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let r=this.recordingProdStack.at(-1),a=new w({idx:s,terminalType:t,label:i===null||i===void 0?void 0:i.LABEL});return r.definition.push(a),Di}}function Ut(t,s,i,r=!1){Es(i);let a=this.recordingProdStack.at(-1),o=typeof s==="function"?s:s.DEF,c=new t({definition:[],idx:i});if(r)c.separator=s.SEP;if(Object.hasOwn(s,"MAX_LOOKAHEAD"))c.maxLookahead=s.MAX_LOOKAHEAD;return this.recordingProdStack.push(c),o.call(this),a.definition.push(c),this.recordingProdStack.pop(),Ts}function Ba(t,s){Es(s);let i=this.recordingProdStack.at(-1),r=Array.isArray(t)===!1,a=r===!1?t:t.DEF,o=new J({definition:[],idx:s,ignoreAmbiguities:r&&t.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(t,"MAX_LOOKAHEAD"))o.maxLookahead=t.MAX_LOOKAHEAD;let c=a.some((h)=>typeof h.GATE==="function");return o.hasPredicates=c,i.definition.push(o),a.forEach((h)=>{let l=new W({definition:[]});if(o.definition.push(l),Object.hasOwn(h,"IGNORE_AMBIGUITIES"))l.ignoreAmbiguities=h.IGNORE_AMBIGUITIES;else if(Object.hasOwn(h,"GATE"))l.ignoreAmbiguities=!0;this.recordingProdStack.push(l),h.ALT.call(this),this.recordingProdStack.pop()}),Ts}function Ui(t){return t===0?"":`${t}`}function Es(t){if(t<0||t>wi){let s=Error(`Invalid DSL Method idx value: <${t}>
104
+ Idx value must be a none negative value smaller than ${wi+1}`);throw s.KNOWN_RECORDER_ERROR=!0,s}}class cn{initPerformanceTracer(t){if(Object.hasOwn(t,"traceInitPerf")){let s=t.traceInitPerf,i=typeof s==="number";this.traceInitMaxIdent=i?s:1/0,this.traceInitPerf=i?s>0:s}else this.traceInitMaxIdent=0,this.traceInitPerf=he.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,s){if(this.traceInitPerf===!0){this.traceInitIndent++;let i=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${i}--> <${t}>`);let{time:r,value:a}=At(s),o=r>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)o(`${i}<-- <${t}> time: ${r}ms`);return this.traceInitIndent--,a}else return s()}}function Fi(t,s){s.forEach((i)=>{let r=i.prototype;Object.getOwnPropertyNames(r).forEach((a)=>{if(a==="constructor")return;let o=Object.getOwnPropertyDescriptor(r,a);if(o&&(o.get||o.set))Object.defineProperty(t.prototype,a,o);else t.prototype[a]=i.prototype[a]})})}var De=qe(Re,"",-1,-1,-1,-1,-1,-1);Object.freeze(De);var he=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ts,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ct=Object.freeze({recoveryValueFunc:()=>{return},resyncEnabled:!0}),ne;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ne||(ne={}));class Pt{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let s=this.className;this.TRACE_INIT("toFastProps",()=>{St(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach((r)=>{let o=this[r].originalGrammarAction,c;this.TRACE_INIT(`${r} Rule`,()=>{c=this.topLevelRuleRecord(r,o)}),this.gastProductionsCache[r]=c})}finally{this.disableRecording()}});let i=[];if(this.TRACE_INIT("Grammar Resolving",()=>{i=Li({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(i)}),this.TRACE_INIT("Grammar Validations",()=>{if(i.length===0&&this.skipValidations===!1){let r=Ni({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:ke,grammarName:s}),a=mi({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:s});this.definitionErrors=this.definitionErrors.concat(r,a)}}),this.definitionErrors.length===0){if(this.recoveryEnabled)this.TRACE_INIT("computeAllProdsFollows",()=>{let r=kn(Object.values(this.gastProductionsCache));this.resyncFollows=r});this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var r,a;(a=(r=this.lookaheadStrategy).initialize)===null||a===void 0||a.call(r,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})}if(!Pt.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw t=this.definitionErrors.map((r)=>r.message),Error(`Parser Definition Errors detected:
105
105
  ${t.join(`
106
106
  -------------------------------
107
107
  `)}`)})}constructor(t,s){this.definitionErrors=[],this.selfAnalysisDone=!1;let i=this;if(i.initErrorHandler(s),i.initLexerAdapter(),i.initLooksAhead(s),i.initRecognizerEngine(t,s),i.initRecoverable(s),i.initTreeBuilder(s),i.initGastRecorder(s),i.initPerformanceTracer(s),Object.hasOwn(s,"ignoredIssues"))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
108
108
  Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
109
109
  See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
110
- For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:ue.skipValidations}}Pt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Fi(Pt,[qs,Js,sn,nn,an,rn,on,ln,cn]);class gs extends Pt{constructor(t,s=ue){let i=Object.assign({},s);i.outputCst=!0;super(t,i)}}var ut=e((t)=>t!==void 0&&t>=0,"isKnownLocation");function Hi(t,s){let i=t.lexer.tokenize(s);if(i.errors.length>0){let a=i.errors[0],o=ut(a.offset)?a.offset:s.length,c=o+(ut(a.length)?a.length:0);throw Error(`Error lexing ${t.diagramType} diagram: ${a.message} at line ${a.line??1}, column ${a.column??1} [${o},${c})`)}t.parser.input=i.tokens;let r=t.entry();if(t.parser.errors.length>0)throw Error(`Error parsing ${t.diagramType} diagram: ${t.parser.errors[0].message}`);t.visit(r)}e(Hi,"runChevrotainParse");var H={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ga="LR",Wa=F.usecase,Tn=e(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ga,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Wa)}),"createModel"),ja=e((t)=>{if(!(t.actors instanceof Map)||!(t.useCases instanceof Map)||!(t.systemBoundaries instanceof Map)||!Array.isArray(t.relationships)||!(t.notes instanceof Map)||!(t.jsonNodes instanceof Map)||!(t.classDefs instanceof Map)||!(t.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(t.direction)||!Number.isSafeInteger(t.relationshipCounter)||t.relationshipCounter<0||!Number.isSafeInteger(t.noteCounter)||t.noteCounter<0||typeof t.accTitle!=="string"||typeof t.accDescription!=="string"||!t.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),U=Tn(),Ka=e(()=>structuredClone(U.config),"getConfig"),Va=e(()=>U.ast,"getAST"),za=e((t)=>{let s=structuredClone(t);ja(s);let i=R(),r=M();try{L(s.accTitle),I(s.accDescription),U=s}catch(a){throw L(i),I(r),a}},"commit"),Ha=e(()=>{U=Tn(),A()},"clear"),Xa=e(()=>U.actors,"getActors"),Ya=e((t)=>U.actors.get(t),"getActor"),qa=e(()=>U.useCases,"getUseCases"),Ja=e((t)=>U.useCases.get(t),"getUseCase"),Za=e(()=>U.systemBoundaries,"getSystemBoundaries"),Qa=e((t)=>U.systemBoundaries.get(t),"getSystemBoundary"),eo=e(()=>U.relationships,"getRelationships"),to=e(()=>U.notes,"getNotes"),so=e((t)=>U.notes.get(t),"getNote"),no=e(()=>U.jsonNodes,"getJsonNodes"),io=e((t)=>U.jsonNodes.get(t),"getJsonNode"),ro=e(()=>U.classDefs,"getClassDefs"),ao=e((t)=>U.classDefs.get(t),"getClassDef"),Xi=e(()=>U.direction,"getDirection"),Je=e((t)=>{let s=new Map;for(let i of["default",...t]){let r=U.classDefs.get(i);if(!r)continue;for(let a of r.styles){let o=a.trim(),c=o.indexOf(":"),h=(c===-1?o:o.slice(0,c)).trim();if(h)s.set(h,o)}}return[...s.values()]},"getCompiledStyles"),oo=e((t)=>t.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Bi=e((t)=>typeof t==="string"?t:t===null?"null":String(t),"displayJsonScalar"),lo=e((t,s,i=(r)=>r)=>{let r=[],a=e((c,h,l)=>{r.push({key:i(c),accessibleKey:i(h),value:i(l)})},"append"),o=e((c,h,l)=>{if(Array.isArray(c)){if(c.length===0){a(h,h,"[]");return}if(c.every((p)=>p===null||["string","number","boolean"].includes(typeof p))){for(let[p,f]of c.entries())a(p===0?h:"",h,Bi(f));return}for(let[p,f]of c.entries())o(f,`${h}[${p}]`,`${l}/${p}`);return}if(c!==null&&typeof c==="object"){let d=c,p=s[l]??Object.keys(d);if(p.length===0){a(h,h,"{}");return}for(let f of p){let T=h?`${h}.${f}`:f;o(d[f],T,`${l}/${oo(f)}`)}return}a(h,h,Bi(c))},"visit");return o(t,"",""),r},"flattenJsonRows"),co=e((t)=>{switch(t.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),ho=e((t)=>{if(t.shape==="ellipse")return t.business?"usecaseBusiness":"usecaseEllipse";return t.shape},"useCaseShape"),uo=e((t)=>{switch(t){case H.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case H.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case H.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case H.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case H.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case H.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case H.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),po=e((t)=>{switch(t.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:`«${t.type}»`,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...uo(t.arrowType),pattern:"solid",...t.label?{label:t.label}:{},...t.labelType?{labelType:t.labelType}:{}}}},"relationshipVisuals"),fo=e((t)=>t.animate||t.animation?[`edge-animation-${t.animation??"fast"}`]:[],"animationClasses"),Dt=e((...t)=>t.filter((s)=>Boolean(s)).join(" "),"classNames"),mo=e(()=>{let t=u(),s={...U.config,...t.usecase},i=e((l)=>q(l,t),"sanitize"),r=e((l)=>i(U.actors.get(l)?.label??U.useCases.get(l)?.label??U.jsonNodes.get(l)?.id??U.notes.get(l)?.label??l),"endpointLabel"),a=[],o=[],c=0,h=0;for(let l of U.actors.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:co(l),isGroup:!1,padding:10,look:t.look,colorIndex:c++,cssClasses:Dt("default","usecase-actor",`usecase-actor-${l.type}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),actorType:l.type,business:l.business,...l.icon?{icon:l.icon}:{},...l.stereotype?{stereotype:i(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of U.useCases.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:ho(l),isGroup:!1,padding:l.shape==="ellipse"?20:10,look:t.look,colorIndex:c++,cssClasses:Dt("default","usecase-element",`usecase-${l.shape}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),business:l.business,...l.stereotype?{stereotype:i(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of U.notes.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:"note",isGroup:!1,padding:10,look:t.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:l.target,noteTargetLabel:i(U.actors.get(l.target)?.label??U.useCases.get(l.target)?.label??U.jsonNodes.get(l.target)?.id??l.target)});for(let l of U.jsonNodes.values())a.push({id:l.id,label:i(l.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:t.look,cssClasses:Dt("default","usecase-json-table",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),jsonRows:lo(l.value,l.propertyOrder,i)});for(let l of U.systemBoundaries.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:t.look,colorIndex:h++,cssClasses:Dt("default","system-boundary",`system-boundary-${l.type}`,...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),boundaryType:l.type});for(let l of U.relationships){let{label:d,...p}=po(l);o.push({id:l.id,start:l.source,end:l.target,source:l.source,target:l.target,sourceLabel:r(l.source),targetLabel:r(l.target),type:"edge",relationshipType:l.type,internal:!1,...p,...d!==void 0?{label:i(d)}:{},labelpos:"c",classes:Dt("default","relationship",`relationship-${l.type}`,...l.classes,...fo(l)),style:[...l.styles],cssCompiledStyles:Je(l.classes),animate:l.animate,...l.animation?{animation:l.animation}:{},look:t.look,thickness:"normal",minlen:l.minlen,isUserDefinedId:l.explicitId})}for(let l of U.notes.values())o.push({id:`${l.id}-edge`,start:l.id,end:l.target,source:l.id,target:l.target,type:"edge",relationshipType:"note",sourceLabel:r(l.id),targetLabel:r(l.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:t.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let l of a){if(l.wrappingWidth??=s.wrappingWidth,!l.isGroup&&!l.shape.startsWith("usecaseActor"))l.minWidth??=s.minNodeWidth;if(l.shape==="usecaseEllipse"||l.shape==="usecaseBusiness")l.spreadPorts=!0}return{nodes:a,edges:o,config:t,type:"usecase",layoutAlgorithm:"dagre",direction:Xi(),nodeSpacing:s.nodeSpacing,rankSpacing:s.rankSpacing,actorFontSize:s.actorFontSize,actorFontFamily:s.actorFontFamily,actorFontWeight:s.actorFontWeight,usecaseFontSize:s.usecaseFontSize,usecaseFontFamily:s.usecaseFontFamily,usecaseFontWeight:s.usecaseFontWeight,diagramPadding:s.diagramPadding,useMaxWidth:s.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ns={getConfig:Ka,createModel:Tn,commit:za,getAST:Va,clear:Ha,setDiagramTitle:D,getDiagramTitle:O,setAccTitle:L,getAccTitle:R,setAccDescription:I,getAccDescription:M,getActors:Xa,getActor:Ya,getUseCases:qa,getUseCase:Ja,getSystemBoundaries:Za,getSystemBoundary:Qa,getRelationships:eo,getNotes:to,getNote:so,getJsonNodes:no,getJsonNode:io,getClassDefs:ro,getClassDef:ao,getDirection:Xi,getData:mo};function Qe(t,s,i){let r=[i];return r.index=s,r.input=t,r}e(Qe,"customMatch");var Eo=e((t,s)=>{if(t[s]!=='"'||t[s+1]!=="`")return null;for(let i=s+2;i<t.length-1;i++)if(t[i]==="`"&&t[i+1]==='"')return Qe(t,s,t.slice(s,i+2));return null},"matchMarkdownString"),To=e((t,s)=>{if(t[s]!=="%"||t[s+1]!=="%")return null;for(let r=s-1;r>=0;r--){let a=t[r];if(a===`
110
+ For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:he.skipValidations}}Pt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Fi(Pt,[qs,Js,sn,nn,an,rn,on,ln,cn]);class gs extends Pt{constructor(t,s=he){let i=Object.assign({},s);i.outputCst=!0;super(t,i)}}var ut=e((t)=>t!==void 0&&t>=0,"isKnownLocation");function Hi(t,s){let i=t.lexer.tokenize(s);if(i.errors.length>0){let a=i.errors[0],o=ut(a.offset)?a.offset:s.length,c=o+(ut(a.length)?a.length:0);throw Error(`Error lexing ${t.diagramType} diagram: ${a.message} at line ${a.line??1}, column ${a.column??1} [${o},${c})`)}t.parser.input=i.tokens;let r=t.entry();if(t.parser.errors.length>0)throw Error(`Error parsing ${t.diagramType} diagram: ${t.parser.errors[0].message}`);t.visit(r)}e(Hi,"runChevrotainParse");var H={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ga="LR",Wa=B.usecase,Tn=e(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ga,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Wa)}),"createModel"),ja=e((t)=>{if(!(t.actors instanceof Map)||!(t.useCases instanceof Map)||!(t.systemBoundaries instanceof Map)||!Array.isArray(t.relationships)||!(t.notes instanceof Map)||!(t.jsonNodes instanceof Map)||!(t.classDefs instanceof Map)||!(t.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(t.direction)||!Number.isSafeInteger(t.relationshipCounter)||t.relationshipCounter<0||!Number.isSafeInteger(t.noteCounter)||t.noteCounter<0||typeof t.accTitle!=="string"||typeof t.accDescription!=="string"||!t.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),U=Tn(),Ka=e(()=>structuredClone(U.config),"getConfig"),Va=e(()=>U.ast,"getAST"),za=e((t)=>{let s=structuredClone(t);ja(s);let i=R(),r=M();try{L(s.accTitle),I(s.accDescription),U=s}catch(a){throw L(i),I(r),a}},"commit"),Ha=e(()=>{U=Tn(),A()},"clear"),Xa=e(()=>U.actors,"getActors"),Ya=e((t)=>U.actors.get(t),"getActor"),qa=e(()=>U.useCases,"getUseCases"),Ja=e((t)=>U.useCases.get(t),"getUseCase"),Za=e(()=>U.systemBoundaries,"getSystemBoundaries"),Qa=e((t)=>U.systemBoundaries.get(t),"getSystemBoundary"),eo=e(()=>U.relationships,"getRelationships"),to=e(()=>U.notes,"getNotes"),so=e((t)=>U.notes.get(t),"getNote"),no=e(()=>U.jsonNodes,"getJsonNodes"),io=e((t)=>U.jsonNodes.get(t),"getJsonNode"),ro=e(()=>U.classDefs,"getClassDefs"),ao=e((t)=>U.classDefs.get(t),"getClassDef"),Xi=e(()=>U.direction,"getDirection"),Je=e((t)=>{let s=new Map;for(let i of["default",...t]){let r=U.classDefs.get(i);if(!r)continue;for(let a of r.styles){let o=a.trim(),c=o.indexOf(":"),h=(c===-1?o:o.slice(0,c)).trim();if(h)s.set(h,o)}}return[...s.values()]},"getCompiledStyles"),oo=e((t)=>t.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Bi=e((t)=>typeof t==="string"?t:t===null?"null":String(t),"displayJsonScalar"),lo=e((t,s,i=(r)=>r)=>{let r=[],a=e((c,h,l)=>{r.push({key:i(c),accessibleKey:i(h),value:i(l)})},"append"),o=e((c,h,l)=>{if(Array.isArray(c)){if(c.length===0){a(h,h,"[]");return}if(c.every((f)=>f===null||["string","number","boolean"].includes(typeof f))){for(let[f,m]of c.entries())a(f===0?h:"",h,Bi(m));return}for(let[f,m]of c.entries())o(m,`${h}[${f}]`,`${l}/${f}`);return}if(c!==null&&typeof c==="object"){let d=c,f=s[l]??Object.keys(d);if(f.length===0){a(h,h,"{}");return}for(let m of f){let T=h?`${h}.${m}`:m;o(d[m],T,`${l}/${oo(m)}`)}return}a(h,h,Bi(c))},"visit");return o(t,"",""),r},"flattenJsonRows"),co=e((t)=>{switch(t.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),ho=e((t)=>{if(t.shape==="ellipse")return t.business?"usecaseBusiness":"usecaseEllipse";return t.shape},"useCaseShape"),uo=e((t)=>{switch(t){case H.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case H.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case H.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case H.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case H.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case H.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case H.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),po=e((t)=>{switch(t.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:`«${t.type}»`,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...uo(t.arrowType),pattern:"solid",...t.label?{label:t.label}:{},...t.labelType?{labelType:t.labelType}:{}}}},"relationshipVisuals"),fo=e((t)=>t.animate||t.animation?[`edge-animation-${t.animation??"fast"}`]:[],"animationClasses"),Dt=e((...t)=>t.filter((s)=>Boolean(s)).join(" "),"classNames"),mo=e(()=>{let t=u(),s={...U.config,...t.usecase},i=e((l)=>q(l,t),"sanitize"),r=e((l)=>i(U.actors.get(l)?.label??U.useCases.get(l)?.label??U.jsonNodes.get(l)?.id??U.notes.get(l)?.label??l),"endpointLabel"),a=[],o=[],c=0,h=0;for(let l of U.actors.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:co(l),isGroup:!1,padding:10,look:t.look,colorIndex:c++,cssClasses:Dt("default","usecase-actor",`usecase-actor-${l.type}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),actorType:l.type,business:l.business,...l.icon?{icon:l.icon}:{},...l.stereotype?{stereotype:i(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of U.useCases.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:ho(l),isGroup:!1,padding:l.shape==="ellipse"?20:10,look:t.look,colorIndex:c++,cssClasses:Dt("default","usecase-element",`usecase-${l.shape}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),business:l.business,...l.stereotype?{stereotype:i(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of U.notes.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:"note",isGroup:!1,padding:10,look:t.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:l.target,noteTargetLabel:i(U.actors.get(l.target)?.label??U.useCases.get(l.target)?.label??U.jsonNodes.get(l.target)?.id??l.target)});for(let l of U.jsonNodes.values())a.push({id:l.id,label:i(l.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:t.look,cssClasses:Dt("default","usecase-json-table",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),jsonRows:lo(l.value,l.propertyOrder,i)});for(let l of U.systemBoundaries.values())a.push({id:l.id,label:i(l.label),labelType:l.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:t.look,colorIndex:h++,cssClasses:Dt("default","system-boundary",`system-boundary-${l.type}`,...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),boundaryType:l.type});for(let l of U.relationships){let{label:d,...f}=po(l);o.push({id:l.id,start:l.source,end:l.target,source:l.source,target:l.target,sourceLabel:r(l.source),targetLabel:r(l.target),type:"edge",relationshipType:l.type,internal:!1,...f,...d!==void 0?{label:i(d)}:{},labelpos:"c",classes:Dt("default","relationship",`relationship-${l.type}`,...l.classes,...fo(l)),style:[...l.styles],cssCompiledStyles:Je(l.classes),animate:l.animate,...l.animation?{animation:l.animation}:{},look:t.look,thickness:"normal",minlen:l.minlen,isUserDefinedId:l.explicitId})}for(let l of U.notes.values())o.push({id:`${l.id}-edge`,start:l.id,end:l.target,source:l.id,target:l.target,type:"edge",relationshipType:"note",sourceLabel:r(l.id),targetLabel:r(l.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:t.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let l of a){if(l.wrappingWidth??=s.wrappingWidth,!l.isGroup&&!l.shape.startsWith("usecaseActor"))l.minWidth??=s.minNodeWidth;if(l.shape==="usecaseEllipse"||l.shape==="usecaseBusiness")l.spreadPorts=!0}return{nodes:a,edges:o,config:t,type:"usecase",layoutAlgorithm:"dagre",direction:Xi(),nodeSpacing:s.nodeSpacing,rankSpacing:s.rankSpacing,actorFontSize:s.actorFontSize,actorFontFamily:s.actorFontFamily,actorFontWeight:s.actorFontWeight,usecaseFontSize:s.usecaseFontSize,usecaseFontFamily:s.usecaseFontFamily,usecaseFontWeight:s.usecaseFontWeight,diagramPadding:s.diagramPadding,useMaxWidth:s.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ns={getConfig:Ka,createModel:Tn,commit:za,getAST:Va,clear:Ha,setDiagramTitle:P,getDiagramTitle:O,setAccTitle:L,getAccTitle:R,setAccDescription:I,getAccDescription:M,getActors:Xa,getActor:Ya,getUseCases:qa,getUseCase:Ja,getSystemBoundaries:Za,getSystemBoundary:Qa,getRelationships:eo,getNotes:to,getNote:so,getJsonNodes:no,getJsonNode:io,getClassDefs:ro,getClassDef:ao,getDirection:Xi,getData:mo};function Qe(t,s,i){let r=[i];return r.index=s,r.input=t,r}e(Qe,"customMatch");var Eo=e((t,s)=>{if(t[s]!=='"'||t[s+1]!=="`")return null;for(let i=s+2;i<t.length-1;i++)if(t[i]==="`"&&t[i+1]==='"')return Qe(t,s,t.slice(s,i+2));return null},"matchMarkdownString"),To=e((t,s)=>{if(t[s]!=="%"||t[s+1]!=="%")return null;for(let r=s-1;r>=0;r--){let a=t[r];if(a===`
111
111
  `||a==="\r")break;if(a!==" "&&a!=="\t")return null}let i=s+2;while(i<t.length&&t[i]!==`
112
112
  `&&t[i]!=="\r")i++;return Qe(t,s,t.slice(s,i))},"matchComment"),Yi=e((t,s)=>{for(let i=s-1;i>=0;i--){let r=t[i];if(r===`
113
- `||r==="\r")return!0;if(r!==" "&&r!=="\t")return!1}return!0},"isIndentedLineStart"),qi=e((t,s,i)=>{if(!Yi(t,s))return null;let r=i.exec(t.slice(s));return r?Qe(t,s,r[0]):null},"matchAccessibilityLine"),go=e((t,s)=>{if(!Yi(t,s))return null;let i=/^accDescr[\t ]*{/.exec(t.slice(s));if(!i)return null;let r=t.indexOf("}",s+i[0].length);return r===-1?null:Qe(t,s,t.slice(s,r+1))},"matchAccDescrBlock"),So=e((t,s)=>{if(t[s]!=="{")return null;let i=0,r=!1,a=!1;for(let o=s;o<t.length;o++){let c=t[o];if(r){if(a)a=!1;else if(c==="\\")a=!0;else if(c==='"')r=!1;continue}if(c==='"')r=!0;else if(c==="{")i++;else if(c==="}"&&--i===0)return Qe(t,s,t.slice(s,o+1))}return null},"matchJsonObject"),Ro=e((t,s)=>{let i=t.indexOf(">>",s);if(i===-1||/[\n\r]/.test(t.slice(s,i)))return null;let r=t.slice(s,i);return r.trim()?Qe(t,s,r):null},"matchStereotypeText"),ie=S({name:"LABEL_TEXT",pattern:K.NA}),dt=S({name:"WORD",pattern:K.NA,categories:ie}),gn=S({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:ie}),X=S({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),yo=S({name:"HWS",pattern:/[\t ]+/,group:K.SKIPPED}),Be=S({name:"MARKDOWN_STRING",pattern:Eo,start_chars_hint:['"'],line_breaks:!0}),Oo=S({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=S({name:"COMMENT",pattern:To,start_chars_hint:["%"],line_breaks:!1}),Fe=S({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Ji=S({name:"ACC_DESCR_BLOCK",pattern:go,start_chars_hint:["a"],line_breaks:!0}),Lo=/^accTitle[\t ]*:[^\n\r]*/,No=/^accDescr[\t ]*:[^\n\r]*/,Zi=S({name:"ACC_TITLE_LINE",pattern:e((t,s)=>qi(t,s,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Qi=S({name:"ACC_DESCR_LINE",pattern:e((t,s)=>qi(t,s,No),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=S({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=S({name:"JSON_OBJECT_LITERAL",pattern:So,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),tr=S({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=e((t,s)=>S({name:t,pattern:s,longer_alt:X,categories:dt}),"keyword"),sr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),nr=ee("SYSTEM_BOUNDARY",/systemBoundary/),ir=ee("END",/end/),rr=ee("DIRECTION",/direction/),ar=ee("TD",/TD/),or=ee("TB",/TB/),lr=ee("BT",/BT/),cr=ee("LR",/LR/),hr=ee("RL",/RL/),ur=ee("NOTE",/note/),dr=ee("FOR",/for/),Io=ee("JSON",/json/),pr=ee("CLASS_DEF",/classDef/),fr=ee("CLASS",/class/),mr=ee("STYLE",/style/),Er=ee("INCLUDE",/include/i),Tr=ee("EXTEND",/extend/i),gr=ee("TRUE",/true/),Ar=ee("FALSE",/false/),Sr=S({name:"GENERALIZATION",pattern:/--\|>/}),Rr=S({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),yr=S({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=S({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=S({name:"STEREOTYPE_TEXT",pattern:Ro,line_breaks:!1}),Or=S({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Lr=S({name:"CLASS_SEPARATOR",pattern:/:::/}),As=S({name:"FORWARD_SOLID",pattern:/--+>/}),Nr=S({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=S({name:"FORWARD_CIRCLE",pattern:/--o/}),Ir=S({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=S({name:"FORWARD_CROSS",pattern:/--x/}),kr=S({name:"BACKWARD_CROSS",pattern:/x--/}),Le=S({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=S({name:"METADATA_START",pattern:/@{/}),ys=S({name:"AT",pattern:/@/,categories:ie}),Cr=S({name:"LBRACE",pattern:/{/}),fn=S({name:"RBRACE",pattern:/}/}),Os=S({name:"LBRACKET",pattern:/\[/}),Ls=S({name:"RBRACKET",pattern:/]/}),Ft=S({name:"LPAREN",pattern:/\(/}),Bt=S({name:"RPAREN",pattern:/\)/}),ke=S({name:"COMMA",pattern:/,/,categories:ie}),$t=S({name:"COLON",pattern:/:/,categories:ie}),br=S({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:ie}),Ne=S({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=S({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:ie}),_r=S({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:ie}),xr=S({name:"DASH",pattern:/-/,categories:ie}),vr=S({name:"DOT",pattern:/\./,categories:ie}),Mr=S({name:"PERCENT",pattern:/%/,categories:ie}),wr=S({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:ie}),ko=S({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:ie}),Co=S({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:ie}),Ur=[ie,dt,yo,Be,Oo,un,Fe,Ji,Zi,Qi,er,sr,dn,nr,ir,rr,ar,or,lr,cr,hr,ur,dr,Io,pr,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Lr,As,Nr,Ss,Ir,Rs,kr,Le,pn,ys,Cr,fn,Os,Ls,Ft,Bt,ke,$t,br,Ne,mn,X,gn,_r,xr,vr,Mr,wr,ko,Co],bo={defaultMode:"defaultMode",modes:{defaultMode:[...Ur],jsonBody:[An,tr],stereotype:[Sn,Rn,Or]}},_o=[...Ur,An,tr,Sn,Rn,Or],xo=new K(bo),$i=e((t)=>It(t,ie)||t.tokenType===Ne||t.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{e(this,"UsecaseParser")}constructor(){super(_o,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(sr),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(Fe),"ALT")},{ALT:e(()=>this.CONSUME(Se),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Zi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:e(()=>this.CONSUME(Qi),"ALT")},{ALT:e(()=>this.CONSUME(Ji),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:e(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(ke),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(X),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(ke),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(X),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"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(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:e(()=>this.LA(1).tokenType===X&&this.LA(2).tokenType===ys,"GATE"),DEF:e(()=>{this.CONSUME(X),this.CONSUME(ys)},"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(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Nr),this.OPTION({GATE:e(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Le]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Le)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Le),this.OPTION({GATE:e(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Le,Ss,Rs]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:e(()=>this.CONSUME(As),"ALT")},{ALT:e(()=>this.CONSUME2(Le),"ALT")},{ALT:e(()=>this.CONSUME(Ss),"ALT")},{ALT:e(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:e(()=>this.hasLabeledRight([Le]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Le)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Le]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Le)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Rr),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME(Er),"ALT")},{ALT:e(()=>this.CONSUME(Tr),"ALT")}])},"ALT")},{ALT:e(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(ke)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:e(()=>this.CONSUME(X),"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME2(X),"ALT")},{ALT:e(()=>this.CONSUME2(Ne),"ALT")},{ALT:e(()=>this.CONSUME(gr),"ALT")},{ALT:e(()=>this.CONSUME(Ar),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:e(()=>{this.CONSUME(ke),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:e(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(ke)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(nr),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(ir),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(X),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"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(X),"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(ur),this.CONSUME(dr),this.CONSUME(X),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(yr),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Lr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(ke),this.CONSUME2(X)})}),this.RULE("jsonStatement",()=>{this.CONSUME(er),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(rr),this.OR([{ALT:e(()=>this.CONSUME(ar),"ALT")},{ALT:e(()=>this.CONSUME(or),"ALT")},{ALT:e(()=>this.CONSUME(lr),"ALT")},{ALT:e(()=>this.CONSUME(cr),"ALT")},{ALT:e(()=>this.CONSUME(hr),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(pr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(ke),this.CONSUME2(X)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(fr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(ke),this.CONSUME2(X)}),this.CONSUME3(X),this.MANY2(()=>{this.CONSUME2(ke),this.CONSUME4(X)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(mr),this.CONSUME(X),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(ke),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>{this.CONSUME(Le),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")},{ALT:e(()=>this.CONSUME(gn),"ALT")},{ALT:e(()=>this.CONSUME(br),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>this.CONSUME(_r),"ALT")},{ALT:e(()=>this.CONSUME(xr),"ALT")},{ALT:e(()=>this.CONSUME(vr),"ALT")},{ALT:e(()=>this.CONSUME(Mr),"ALT")},{ALT:e(()=>this.CONSUME(wr),"ALT")},{ALT:e(()=>this.CONSUME($t),"ALT")},{ALT:e(()=>this.CONSUME(Ft),"ALT")},{ALT:e(()=>this.CONSUME(Bt),"ALT")},{ALT:e(()=>this.CONSUME(Os),"ALT")},{ALT:e(()=>this.CONSUME(Ls),"ALT")},{ALT:e(()=>this.CONSUME(Cr),"ALT")},{ALT:e(()=>this.CONSUME(fn),"ALT")},{ALT:e(()=>this.CONSUME(ys),"ALT")},{ALT:e(()=>this.CONSUME(Le),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let t=this.LA(1).tokenType;return(t===X||t===Ne||t===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let t=this.LA(1).tokenType;return t!==Se&&t!==Fe&&t!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===X&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(t){if(!$i(this.LA(1)))return!1;for(let s=2;;s++){let i=this.LA(s);if(t.includes(i.tokenType))return!0;if(!$i(i))return!1}}},Gt=new Mo,Gi=class extends Error{constructor(t,s,i){super(`${t} (line ${s}, column ${i})`);this.line=s,this.column=i,this.name="UsecaseJsonError"}static{e(this,"UsecaseJsonError")}},En=e((t,s,i,r)=>{let a=i,o=r,c=Math.min(Math.max(s,0),t.length);for(let h=0;h<c;h++){let l=t[h];if(l==="\r")a++,o=1;else if(l===`
113
+ `||r==="\r")return!0;if(r!==" "&&r!=="\t")return!1}return!0},"isIndentedLineStart"),qi=e((t,s,i)=>{if(!Yi(t,s))return null;let r=i.exec(t.slice(s));return r?Qe(t,s,r[0]):null},"matchAccessibilityLine"),go=e((t,s)=>{if(!Yi(t,s))return null;let i=/^accDescr[\t ]*{/.exec(t.slice(s));if(!i)return null;let r=t.indexOf("}",s+i[0].length);return r===-1?null:Qe(t,s,t.slice(s,r+1))},"matchAccDescrBlock"),Ao=e((t,s)=>{if(t[s]!=="{")return null;let i=0,r=!1,a=!1;for(let o=s;o<t.length;o++){let c=t[o];if(r){if(a)a=!1;else if(c==="\\")a=!0;else if(c==='"')r=!1;continue}if(c==='"')r=!0;else if(c==="{")i++;else if(c==="}"&&--i===0)return Qe(t,s,t.slice(s,o+1))}return null},"matchJsonObject"),So=e((t,s)=>{let i=t.indexOf(">>",s);if(i===-1||/[\n\r]/.test(t.slice(s,i)))return null;let r=t.slice(s,i);return r.trim()?Qe(t,s,r):null},"matchStereotypeText"),ie=S({name:"LABEL_TEXT",pattern:V.NA}),dt=S({name:"WORD",pattern:V.NA,categories:ie}),gn=S({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:ie}),X=S({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),Ro=S({name:"HWS",pattern:/[\t ]+/,group:V.SKIPPED}),Be=S({name:"MARKDOWN_STRING",pattern:Eo,start_chars_hint:['"'],line_breaks:!0}),yo=S({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=S({name:"COMMENT",pattern:To,start_chars_hint:["%"],line_breaks:!1}),Fe=S({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Ji=S({name:"ACC_DESCR_BLOCK",pattern:go,start_chars_hint:["a"],line_breaks:!0}),Oo=/^accTitle[\t ]*:[^\n\r]*/,Lo=/^accDescr[\t ]*:[^\n\r]*/,Zi=S({name:"ACC_TITLE_LINE",pattern:e((t,s)=>qi(t,s,Oo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Qi=S({name:"ACC_DESCR_LINE",pattern:e((t,s)=>qi(t,s,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=S({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=S({name:"JSON_OBJECT_LITERAL",pattern:Ao,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),tr=S({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=e((t,s)=>S({name:t,pattern:s,longer_alt:X,categories:dt}),"keyword"),sr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),nr=ee("SYSTEM_BOUNDARY",/systemBoundary/),ir=ee("END",/end/),rr=ee("DIRECTION",/direction/),ar=ee("TD",/TD/),or=ee("TB",/TB/),lr=ee("BT",/BT/),cr=ee("LR",/LR/),hr=ee("RL",/RL/),ur=ee("NOTE",/note/),dr=ee("FOR",/for/),No=ee("JSON",/json/),pr=ee("CLASS_DEF",/classDef/),fr=ee("CLASS",/class/),mr=ee("STYLE",/style/),Er=ee("INCLUDE",/include/i),Tr=ee("EXTEND",/extend/i),gr=ee("TRUE",/true/),Ar=ee("FALSE",/false/),Sr=S({name:"GENERALIZATION",pattern:/--\|>/}),Rr=S({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),yr=S({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=S({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=S({name:"STEREOTYPE_TEXT",pattern:So,line_breaks:!1}),Or=S({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Lr=S({name:"CLASS_SEPARATOR",pattern:/:::/}),As=S({name:"FORWARD_SOLID",pattern:/--+>/}),Nr=S({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=S({name:"FORWARD_CIRCLE",pattern:/--o/}),Ir=S({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=S({name:"FORWARD_CROSS",pattern:/--x/}),kr=S({name:"BACKWARD_CROSS",pattern:/x--/}),Ne=S({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=S({name:"METADATA_START",pattern:/@{/}),ys=S({name:"AT",pattern:/@/,categories:ie}),Cr=S({name:"LBRACE",pattern:/{/}),fn=S({name:"RBRACE",pattern:/}/}),Os=S({name:"LBRACKET",pattern:/\[/}),Ls=S({name:"RBRACKET",pattern:/]/}),Ft=S({name:"LPAREN",pattern:/\(/}),Bt=S({name:"RPAREN",pattern:/\)/}),be=S({name:"COMMA",pattern:/,/,categories:ie}),$t=S({name:"COLON",pattern:/:/,categories:ie}),br=S({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:ie}),Ie=S({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=S({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:ie}),_r=S({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:ie}),xr=S({name:"DASH",pattern:/-/,categories:ie}),vr=S({name:"DOT",pattern:/\./,categories:ie}),Mr=S({name:"PERCENT",pattern:/%/,categories:ie}),wr=S({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:ie}),Io=S({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:ie}),ko=S({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:ie}),Ur=[ie,dt,Ro,Be,yo,un,Fe,Ji,Zi,Qi,er,sr,dn,nr,ir,rr,ar,or,lr,cr,hr,ur,dr,No,pr,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Lr,As,Nr,Ss,Ir,Rs,kr,Ne,pn,ys,Cr,fn,Os,Ls,Ft,Bt,be,$t,br,Ie,mn,X,gn,_r,xr,vr,Mr,wr,Io,ko],Co={defaultMode:"defaultMode",modes:{defaultMode:[...Ur],jsonBody:[An,tr],stereotype:[Sn,Rn,Or]}},bo=[...Ur,An,tr,Sn,Rn,Or],xo=new V(Co),$i=e((t)=>kt(t,ie)||t.tokenType===Ie||t.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{e(this,"UsecaseParser")}constructor(){super(bo,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(sr),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(Fe),"ALT")},{ALT:e(()=>this.CONSUME(Re),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Zi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:e(()=>this.CONSUME(Qi),"ALT")},{ALT:e(()=>this.CONSUME(Ji),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:e(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(be),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(X),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(be),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(X),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"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(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:e(()=>this.LA(1).tokenType===X&&this.LA(2).tokenType===ys,"GATE"),DEF:e(()=>{this.CONSUME(X),this.CONSUME(ys)},"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(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Nr),this.OPTION({GATE:e(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Ne]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ne)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Ne),this.OPTION({GATE:e(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Ne,Ss,Rs]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:e(()=>this.CONSUME(As),"ALT")},{ALT:e(()=>this.CONSUME2(Ne),"ALT")},{ALT:e(()=>this.CONSUME(Ss),"ALT")},{ALT:e(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ne]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ne)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ne]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ne)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Rr),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME(Er),"ALT")},{ALT:e(()=>this.CONSUME(Tr),"ALT")}])},"ALT")},{ALT:e(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(be)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:e(()=>this.CONSUME(X),"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME2(X),"ALT")},{ALT:e(()=>this.CONSUME2(Ie),"ALT")},{ALT:e(()=>this.CONSUME(gr),"ALT")},{ALT:e(()=>this.CONSUME(Ar),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:e(()=>{this.CONSUME(be),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:e(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(be)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(nr),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(ir),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(X),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"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(X),"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(ur),this.CONSUME(dr),this.CONSUME(X),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(yr),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Lr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(X)})}),this.RULE("jsonStatement",()=>{this.CONSUME(er),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(rr),this.OR([{ALT:e(()=>this.CONSUME(ar),"ALT")},{ALT:e(()=>this.CONSUME(or),"ALT")},{ALT:e(()=>this.CONSUME(lr),"ALT")},{ALT:e(()=>this.CONSUME(cr),"ALT")},{ALT:e(()=>this.CONSUME(hr),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(pr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(X)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(fr),this.CONSUME(X),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(X)}),this.CONSUME3(X),this.MANY2(()=>{this.CONSUME2(be),this.CONSUME4(X)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(mr),this.CONSUME(X),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>{this.CONSUME(Ne),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")},{ALT:e(()=>this.CONSUME(gn),"ALT")},{ALT:e(()=>this.CONSUME(br),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>this.CONSUME(_r),"ALT")},{ALT:e(()=>this.CONSUME(xr),"ALT")},{ALT:e(()=>this.CONSUME(vr),"ALT")},{ALT:e(()=>this.CONSUME(Mr),"ALT")},{ALT:e(()=>this.CONSUME(wr),"ALT")},{ALT:e(()=>this.CONSUME($t),"ALT")},{ALT:e(()=>this.CONSUME(Ft),"ALT")},{ALT:e(()=>this.CONSUME(Bt),"ALT")},{ALT:e(()=>this.CONSUME(Os),"ALT")},{ALT:e(()=>this.CONSUME(Ls),"ALT")},{ALT:e(()=>this.CONSUME(Cr),"ALT")},{ALT:e(()=>this.CONSUME(fn),"ALT")},{ALT:e(()=>this.CONSUME(ys),"ALT")},{ALT:e(()=>this.CONSUME(Ne),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let t=this.LA(1).tokenType;return(t===X||t===Ie||t===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let t=this.LA(1).tokenType;return t!==Re&&t!==Fe&&t!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===X&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(t){if(!$i(this.LA(1)))return!1;for(let s=2;;s++){let i=this.LA(s);if(t.includes(i.tokenType))return!0;if(!$i(i))return!1}}},Gt=new Mo,Gi=class extends Error{constructor(t,s,i){super(`${t} (line ${s}, column ${i})`);this.line=s,this.column=i,this.name="UsecaseJsonError"}static{e(this,"UsecaseJsonError")}},En=e((t,s,i,r)=>{let a=i,o=r,c=Math.min(Math.max(s,0),t.length);for(let h=0;h<c;h++){let l=t[h];if(l==="\r")a++,o=1;else if(l===`
114
114
  `){if(h===0||t[h-1]!=="\r")a++,o=1}else o++}return{line:a,column:o}},"locationAtOffset"),wo=e((t,s,i,r)=>{let a=/\bposition (\d+)\b/u.exec(t);if(a)return En(s,Number.parseInt(a[1],10),i,r);let o=/\bline (\d+) column (\d+)\b/u.exec(t);if(o){let c=Number.parseInt(o[1],10),h=Number.parseInt(o[2],10);return{line:i+c-1,column:c===1?r+h-1:h}}if(/unexpected end|end of json input/iu.test(t))return En(s,s.length,i,r);return},"locationFromErrorMessage"),ae=class extends Error{constructor(t){super("Invalid JSON token");this.offset=t}static{e(this,"JsonWalkError")}},Wi=class{constructor(t){this.text=t,this.offset=0,this.propertyOrder={}}static{e(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new ae(this.offset);return this.propertyOrder}collectValue(t){this.skipWhitespace();let s=this.text[this.offset];if(s==="{")this.collectObject(t);else if(s==="[")this.collectArray(t);else if(s==='"')this.readString(!1);else if(s==="t")this.consumeLiteral("true");else if(s==="f")this.consumeLiteral("false");else if(s==="n")this.consumeLiteral("null");else if(s==="-"||s>="0"&&s<="9")this.consumeNumber();else throw new ae(this.offset)}collectObject(t){this.offset++;let s=[],i=new Set;if(this.propertyOrder[t]=s,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}while(this.offset<this.text.length){if(this.text[this.offset]!=='"')throw new ae(this.offset);let r=this.readString(!0),a=`${t}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;if(i.has(r))this.deletePointerSubtree(a);else i.add(r),s.push(r);if(this.skipWhitespace(),this.text[this.offset]!==":")throw new ae(this.offset);if(this.offset++,this.collectValue(a),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new ae(this.offset);this.offset++,this.skipWhitespace()}throw new ae(this.offset)}collectArray(t){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let s=0;while(this.offset<this.text.length){if(this.collectValue(`${t}/${s}`),s++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new ae(this.offset);this.offset++,this.skipWhitespace()}throw new ae(this.offset)}readString(t){this.offset++;let s="";while(this.offset<this.text.length){let i=this.offset,r=this.text[this.offset++];if(r==='"')return s;if(r.charCodeAt(0)<32)throw new ae(i);if(r!=="\\"){if(t)s+=r;continue}let a=this.offset,o=this.text[this.offset++];switch(o){case'"':case"\\":case"/":if(t)s+=o;break;case"b":if(t)s+="\b";break;case"f":if(t)s+="\f";break;case"n":if(t)s+=`
115
115
  `;break;case"r":if(t)s+="\r";break;case"t":if(t)s+="\t";break;case"u":{let c=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(c))throw new ae(this.offset);if(t)s+=String.fromCharCode(Number.parseInt(c,16));this.offset+=4;break}default:throw new ae(a)}}throw new ae(this.offset)}consumeLiteral(t){let s=0;for(let i of t){if(this.text[this.offset+s]!==i)throw new ae(this.offset+s);s++}this.offset+=t.length}consumeNumber(){if(this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++;else throw new ae(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ae(this.offset);while(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++;if(this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ae(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}}skipWhitespace(){while(this.offset<this.text.length){let t=this.text[this.offset];if(t!==" "&&t!=="\t"&&t!==`
116
- `&&t!=="\r")return;this.offset++}}deletePointerSubtree(t){let s=`${t}/`;for(let i of Object.keys(this.propertyOrder))if(i===t||i.startsWith(s))delete this.propertyOrder[i]}};function Pr(t,s,i){let r;try{r=JSON.parse(t)}catch(a){let o=a instanceof Error?a.message:String(a),c=wo(o,t,s,i);if(!c){let h=0;try{new Wi(t).collect()}catch(l){if(l instanceof ae)h=l.offset}c=En(t,h,s,i)}throw new Gi(`Invalid JSON: ${o}`,c.line,c.column)}if(typeof r!=="object"||r===null||Array.isArray(r))throw new Gi("JSON value must have an object root",s,i);return{value:r,propertyOrder:new Wi(t).collect()}}e(Pr,"parseOrderedJsonObject");var Uo=e((t)=>({shape:t.type==="normal"?"actor":t.type==="hollow"?"actor-hollow":t.type==="awesome"?"actor-awesome":"actor-icon",...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"actor",actorType:t.type,business:t.business,labelType:t.labelType,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"actorNode"),Po=e((t)=>({shape:t.shape,...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"usecase",useCaseShape:t.shape,business:t.business,labelType:t.labelType,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"useCaseNode"),Do=e((t)=>({label:t.label,shape:"note",attrs:{kind:"note",target:t.target,labelType:t.labelType}}),"noteNode"),Fo=e((t)=>({label:t.id,shape:"json-table",...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"json",value:t.value,propertyOrder:t.propertyOrder,labelType:"text"}}),"jsonNode"),Bo=e((t)=>({id:t.id,source:t.source,target:t.target,...t.label?{label:t.label}:{},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{relationshipType:t.type,arrowType:t.arrowType,minlen:t.minlen,explicitId:t.explicitId,animate:t.animate,...t.animation?{animation:t.animation}:{},...t.labelType?{labelType:t.labelType}:{}}}),"relationshipEdge"),$o=e((t)=>({id:`${t.id}-edge`,source:t.id,target:t.target,attrs:{relationshipType:"note",arrowType:H.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Go=e((t,s,i,r)=>{let a={};for(let l of t.getActors().values())a[l.id]=Uo(l);for(let l of t.getUseCases().values())a[l.id]=Po(l);for(let l of t.getNotes().values())a[l.id]=Do(l);for(let l of t.getJsonNodes().values())a[l.id]=Fo(l);let o={};for(let l of t.getSystemBoundaries().values())o[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};let c={};for(let l of t.getClassDefs().values())c[l.id]={styles:[...l.styles]};let h=t.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:h==="TD"?"TB":h,span:i},...t.getAccTitle()?{accTitle:t.getAccTitle()}:{},...t.getAccDescription()?{accDescr:t.getAccDescription()}:{},nodes:a,edges:[...t.getRelationships().map(Bo),...[...t.getNotes().values()].map($o)],groups:o,classDefs:c,statements:r}},"buildUsecaseGraphAST"),le=e((t)=>`line ${t.line}, column ${t.column} [${t.span[0]},${t.span[1]})`,"locationText"),ji=e((t)=>t===void 0?"":` (label "${t}")`,"labelSuffix"),Ze=e((t)=>t.generated?t.label:void 0,"generatedFrom"),hn=e((t,s)=>{for(let i of s)if(!t.includes(i))t.push(i)},"pushUnique"),Wo=class{constructor(t){this.db=t,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=t.createModel()}static{e(this,"UsecaseModelBuilder")}reset(t){this.model=this.db.createModel(),this.source=t,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(t){this.elements.push(t)}addBoundary(t){this.boundaries.push(t)}addJson(t){this.jsonDrafts.push(t)}addRelationship(t){this.relationshipDrafts.push(t)}addNote(t){this.noteDrafts.push(t)}addMetadataAssignment(t,s,i,r){this.metadataAssignments.push({target:t,targetLocation:s,metadata:i,statement:r})}addClassDef(t,s){this.classDefinitions.push({ids:t,styles:s})}addClassAssignment(t,s){this.classAssignments.push({targets:t,classes:s})}addStyleAssignment(t,s,i){this.styleAssignments.push({target:t,location:s,styles:i})}setDirection(t){this.directions.push(t==="TD"?"TB":t)}setAccTitle(t){this.model.accTitle=t}setAccDescription(t){this.model.accDescription=t}setStatements(t){this.statements=t}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(t){let s=new Map,i=new Map,r=new Map,a=new Map;for(let l of this.relationshipDrafts)this.recordFirst(a,l.source.id,l.source.location.span[0]),this.recordFirst(a,l.target.id,l.target.location.span[0]);for(let l of this.elements)this.recordFirst(a,l.id,l.location.span[0]);for(let l of this.boundaries)this.recordFirst(a,l.id,l.location.span[0]);for(let l of this.jsonDrafts)this.recordFirst(a,l.id,l.location.span[0]);let o=[...this.elements.map((l)=>({offset:l.location.span[0],type:"element",value:l})),...this.boundaries.map((l)=>({offset:l.location.span[0],type:"boundary",value:l})),...this.jsonDrafts.map((l)=>({offset:l.location.span[0],type:"json",value:l})),...this.relationshipDrafts.filter((l)=>l.explicitId).map((l)=>({offset:l.explicitIdLocation.span[0],type:"edge",value:l}))].sort((l,d)=>l.offset-d.offset);for(let l of o)if(l.type==="element")this.collectElement(l.value,s,i);else if(l.type==="boundary")this.collectBoundary(l.value,s,r);else if(l.type==="json")this.registerUnique(s,l.value.id,"json",l.value.location,!1);else this.registerUnique(s,l.value.explicitId,"edge",l.value.explicitIdLocation,!1);this.materializeElements(i,a),this.materializeBoundaries(r,a),this.materializeJson(a);let c=this.materializeRelationships(s,i,a);this.reorderElements(i,a),this.applyMetadataAssignments(s,i,r,c),this.validateAndRefreshElements(i),this.refreshBoundaries(r,i),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,c),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([l,d])=>[l,d.kind]));let h=Go(this,this.source,t,this.statements);return this.model.ast=h,this.db.commit(this.model),h}collectElement(t,s,i){let r=s.get(t.id),a=Ze({generated:t.generated,label:t.label.text});if(r&&r.kind!==t.kind)this.conflict(`ID '${t.id}' is declared as both ${r.kind} and ${t.kind}`,t.location,r.location,a,Ze(r));if(r&&(r.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,r.location,a,Ze(r));let o=i.get(t.id);if(!o){let c={kind:t.kind,id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],...t.parentId?{parentId:t.parentId,parentLocation:t.parentLocation}:{},...t.shape?{shape:t.shape}:{},...t.stereotype?{stereotype:t.stereotype,stereotypeLocation:t.location}:{}};this.applyDeclarationMetadata(c,t.metadata),i.set(t.id,c),s.set(t.id,{kind:t.kind,location:t.location,generated:t.generated,label:t.label.text});return}if(o.label.text!==t.label.text||o.label.type!==t.label.type)this.conflict(`ID '${t.id}' has conflicting labels`,t.location,o.location);if(t.shape&&o.shape&&t.shape!==o.shape)this.conflict(`Use case '${t.id}' has conflicting shapes`,t.location,o.location);if(t.parentId&&o.parentId&&t.parentId!==o.parentId)this.conflict(`Element '${t.id}' belongs to more than one system boundary`,t.parentLocation??t.location,o.parentLocation??o.location);if(t.stereotype&&o.stereotype&&t.stereotype!==o.stereotype)this.conflict(`Element '${t.id}' has conflicting stereotypes`,t.location,o.stereotypeLocation??o.location);o.shape??=t.shape,o.parentId??=t.parentId,o.parentLocation??=t.parentLocation,o.stereotype??=t.stereotype,o.stereotypeLocation??=t.stereotype?t.location:void 0,hn(o.classes,t.classes),this.applyDeclarationMetadata(o,t.metadata)}collectBoundary(t,s,i){let r=s.get(t.id),a=Ze({generated:t.generated,label:t.label.text});if(r&&r.kind!=="boundary")this.conflict(`ID '${t.id}' is declared as both ${r.kind} and boundary`,t.location,r.location,a,Ze(r));if(r&&(r.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,r.location,a,Ze(r));let o=i.get(t.id);if(o){if(o.label.text!==t.label.text||o.label.type!==t.label.type)this.conflict(`Boundary '${t.id}' has conflicting titles`,t.location,o.location);hn(o.classes,t.classes);return}i.set(t.id,{id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],styles:[],members:[]}),s.set(t.id,{kind:"boundary",location:t.location,generated:t.generated,label:t.label.text})}materializeElements(t,s){for(let i of[...t.values()].sort((r,a)=>(s.get(r.id)??0)-(s.get(a.id)??0)))this.setElementModel(i)}materializeBoundaries(t,s){for(let i of[...t.values()].sort((r,a)=>(s.get(r.id)??0)-(s.get(a.id)??0)))this.model.systemBoundaries.set(i.id,{id:i.id,label:i.label.text,labelType:i.label.type,type:i.type??"rect",members:[],classes:[...i.classes],styles:[...i.styles]})}materializeJson(t){for(let s of[...this.jsonDrafts].sort((i,r)=>(t.get(i.id)??0)-(t.get(r.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(t,s,i){let r=new Map,a=0;for(let o of this.relationshipDrafts){let c=this.resolveEndpoint(o.source,t,s,i),h=this.resolveEndpoint(o.target,t,s,i);this.validateRelationship(o,c,h,t);let l=o.explicitId??`edge-${a++}`,d={id:l,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),r.set(l,{draft:o,relationship:d})}return this.model.relationshipCounter=a,r}resolveEndpoint(t,s,i,r){if(t.classesOnReference&&!t.declaration)throw Error(`Relationship endpoint '${t.id}' uses ::: without declaring the node at ${le(t.location)}`);let a=s.get(t.id);if(a)return a.kind;return i.set(t.id,{kind:"usecase",id:t.id,label:t.label,location:t.location,generated:t.generated,shape:"ellipse",classes:[]}),s.set(t.id,{kind:"usecase",location:t.location,generated:t.generated,label:t.label.text}),this.recordFirst(r,t.id,t.location.span[0]),"usecase"}reorderElements(t,s){let i=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let a of[...t.values()].sort((o,c)=>(s.get(o.id)??0)-(s.get(c.id)??0))){if(!i.has(a.id)&&!r.has(a.id))this.setElementModel(a);let o=i.get(a.id)??this.model.actors.get(a.id),c=r.get(a.id)??this.model.useCases.get(a.id);if(o)this.model.actors.set(a.id,o);else if(c)this.model.useCases.set(a.id,c)}}applyMetadataAssignments(t,s,i,r){for(let a of this.metadataAssignments){let o=t.get(a.target);if(!o){let c=this.inferMetadataKind(a.metadata);throw Error(`Metadata target '${a.target}' is unresolved${c?` (metadata implies ${c})`:""} at ${le(a.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(a.target),a.metadata);else if(o.kind==="boundary"){let c=i.get(a.target);for(let h of a.metadata.properties){if(h.key!=="type"||h.value!=="rect"&&h.value!=="package")this.invalidMetadata(a.target,o.kind,h);c.type=h.value}}else if(o.kind==="edge"){let c=r.get(a.target);if(!c)throw Error(`Metadata target '${a.target}' is not an explicit edge at ${le(a.targetLocation)}`);a.statement.kind="edgeMetadata",a.statement.edges=[{id:a.target,span:a.statement.span,idSpan:a.targetLocation.span,...a.statement.metadata?{metadata:a.statement.metadata}:{}}],delete a.statement.nodes;for(let h of a.metadata.properties)if(h.key==="animate"&&typeof h.value==="boolean")c.relationship.animate=h.value;else if(h.key==="animation"&&(h.value==="fast"||h.value==="slow"))c.relationship.animation=h.value,c.relationship.animate=!0;else this.invalidMetadata(a.target,o.kind,h)}else for(let c of a.metadata.properties)this.invalidMetadata(a.target,o.kind,c)}for(let{relationship:a}of r.values())if(a.animation)a.animate=!0}applyStandaloneElementMetadata(t,s){for(let i of s.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!0);else if(i.key==="business"&&typeof i.value==="boolean")t.business=i.value;else this.invalidMetadata(t.id,t.kind,i)}applyDeclarationMetadata(t,s){if(!s)return;for(let i of s.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!1);else if(i.key==="business"&&typeof i.value==="boolean"){if(t.business!==void 0&&t.business!==i.value)this.conflict(`Use case '${t.id}' has conflicting business metadata`,i.location,t.location);t.business=i.value}else this.invalidMetadata(t.id,t.kind,i)}applyActorProperty(t,s,i){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!i&&t.actorType!==void 0&&t.actorType!==s.value)this.conflict(`Actor '${t.id}' has conflicting type metadata`,s.location,t.location);t.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!i&&t.icon!==void 0&&t.icon!==s.value)this.conflict(`Actor '${t.id}' has conflicting icon metadata`,s.location,t.location);t.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!i&&t.business!==void 0&&t.business!==s.value)this.conflict(`Actor '${t.id}' has conflicting business metadata`,s.location,t.location);t.business=s.value}else this.invalidMetadata(t.id,t.kind,s)}validateAndRefreshElements(t){for(let s of t.values()){let i=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${le(s.location)}`);if(s.business&&(i==="icon"||i==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${le(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${le(s.location)}`);this.setElementModel(s)}}refreshBoundaries(t,s){for(let i of t.values())i.members.length=0;for(let i of[...this.elements].sort((r,a)=>r.location.span[0]-a.location.span[0])){if(!i.parentId)continue;let r=t.get(i.parentId);if(!r)throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${le(i.parentLocation??i.location)}`);if(!r.members.includes(i.id))r.members.push(i.id)}for(let i of s.values())if(i.parentId&&!t.has(i.parentId))throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${le(i.parentLocation??i.location)}`);for(let i of t.values()){let r=this.model.systemBoundaries.get(i.id);r.type=i.type??"rect",r.members=[...i.members],r.classes=[...i.classes],r.styles=[...i.styles]}}materializeNotes(t){let s=0;for(let i of this.noteDrafts){let r=t.get(i.target);if(!r)throw Error(`Note target '${i.target}' is unresolved at ${le(i.targetLocation)}`);if(r.kind!=="actor"&&r.kind!=="usecase")this.conflict(`Note target '${i.target}' must be an actor or use case, not ${r.kind}`,i.targetLocation,r.location);let a=`note-${s++}`;this.model.notes.set(a,{id:a,target:i.target,label:i.label.text,labelType:i.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let t of this.classDefinitions)for(let s of t.ids)this.model.classDefs.set(s,{id:s,styles:[...t.styles]})}applyClassesAndStyles(t,s){for(let i of this.classAssignments)for(let r of i.targets)hn(this.getStylable(r.id,t,s,r.location).classes,i.classes);for(let i of this.styleAssignments)this.getStylable(i.target,t,s,i.location).styles.push(...i.styles)}getStylable(t,s,i,r){let a=s.get(t)?.kind,o=a==="actor"?this.model.actors.get(t):a==="usecase"?this.model.useCases.get(t):a==="boundary"?this.model.systemBoundaries.get(t):a==="json"?this.model.jsonNodes.get(t):a==="edge"?i.get(t)?.relationship:void 0;if(!o)throw Error(`Class/style target '${t}' is unresolved or anonymous at ${le(r)}`);return o}validateRelationship(t,s,i,r){let a=e((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!a(s))this.conflict(`Relationship source '${t.source.id}' cannot be ${s}`,t.source.location,r.get(t.source.id).location);if(!a(i))this.conflict(`Relationship target '${t.target.id}' cannot be ${i}`,t.target.location,r.get(t.target.id).location);if((t.type==="include"||t.type==="extend")&&(s!=="usecase"||i!=="usecase"))throw Error(`${t.type} relationship requires use-case endpoints at ${le(t.location)}`);if(t.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==i))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${le(t.location)}`);if(t.type==="association"&&(s==="json"||i==="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 ${le(t.location)}`)}setElementModel(t){if(t.kind==="actor"){let s=t.icon?"icon":t.actorType??"normal";this.model.useCases.delete(t.id),this.model.actors.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,type:s,...t.icon?{icon:t.icon}:{},business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.actors.get(t.id)?.styles??[]})}else this.model.actors.delete(t.id),this.model.useCases.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,shape:t.shape??"ellipse",business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.useCases.get(t.id)?.styles??[]})}inferMetadataKind(t){let s=new Set(["actor","usecase","boundary","edge"]);for(let i of t.properties)if(i.key==="icon")s.clear(),s.add("actor");else if(i.key==="animate"||i.key==="animation")s.clear(),s.add("edge");else if(i.key==="type"){if(s.clear(),i.value==="rect"||i.value==="package")s.add("boundary");else if(i.value==="normal"||i.value==="hollow"||i.value==="awesome")s.add("actor")}else if(i.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(t,s,i){throw Error(`Metadata property '${i.key}' is invalid for ${s} '${t}' at ${le(i.location)}`)}registerUnique(t,s,i,r,a){let o=t.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${i})`,r,o.location,void 0,Ze(o));t.set(s,{kind:i,location:r,generated:a})}recordFirst(t,s,i){let r=t.get(s);if(r===void 0||i<r)t.set(s,i)}conflict(t,s,i,r,a){throw Error(`${t} at ${le(s)}${ji(r)}; previous declaration at ${le(i)}${ji(a)}`)}},jo=Gt.getBaseCstVisitorConstructor(),Ko=class extends jo{constructor(){super();this.builder=new Wo(Ns),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{e(this,"UsecaseVisitor")}build(t,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(t)}start(t){let s=this.tokens(t,"USECASE")[0],i=[];for(let r of this.nodes(t,"line"))i.push(this.visit(r));this.builder.setStatements(i),this.builder.finalize(this.tokenSpan(s))}line(t){let s=this.firstNode(t,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(t){return this.visit(this.firstNode(t,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(t){return}blankLine(t){return{kind:"blank",span:this.tokenSpan(this.tokens(t,"NEWLINE")[0])}}commentLine(t){return{kind:"comment",span:this.tokenSpan(this.tokens(t,"COMMENT")[0])}}accTitleStatement(t){let s=this.tokens(t,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(t){let s=this.tokens(t,"ACC_DESCR_LINE")[0],i=this.tokens(t,"ACC_DESCR_BLOCK")[0],r=s?s.image.slice(s.image.indexOf(":")+1).trim():i.image.slice(i.image.indexOf("{")+1,i.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(r),{kind:"accDescr",span:[0,0]}}actorStatement(t){let s=this.nodes(t,"actorItem"),i=s.map((l)=>this.visit(l)),r=this.nodes(t,"relationTail")[0],a=i.map((l,d)=>this.actorOccurrence(s[d],l,!0));for(let l of i)this.builder.addElement(this.actorDraft(l));if(!r)return{kind:"node",span:[0,0],nodes:a};let o=this.visit(r);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let c=this.relationshipDraft(i[0],o,this.nodeLocation(r));this.builder.addRelationship(c);let h=c.explicitId??`edge-${this.anonymousEdge++}`;return a.push(this.entityOccurrence(this.nodes(r.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:a,edges:[{id:h,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}actorItem(t){let s=this.visit(this.nodes(t,"actorName")[0]),i=this.nodes(t,"metadata")[0],r=this.nodes(t,"stereotype")[0],a=this.nodes(t,"classSuffix")[0],o=a?this.visit(a):{classes:[],spans:[]};return{...s,...i?{metadata:this.visit(i)}:{},...r?{stereotype:this.visit(r)}:{},classes:o.classes,classSpans:o.spans}}actorName(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0];if(s){let a=this.nodes(t,"nodeLabel")[0],o=a?this.visit(a):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let r=this.tokenLabel(i);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(i),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(t){let s=this.nodes(t,"actorItem"),i=s.map((r)=>this.visit(r));for(let r of i)this.builder.addElement(this.actorDraft(r));return{kind:"node",span:[0,0],nodes:i.map((r,a)=>this.actorOccurrence(s[a],r,!0))}}entityStatement(t){let s=this.nodes(t,"entityName"),i=this.visit(s[0]),r=this.nodes(t,"relationTail")[0];if(!r)return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],i,!0)]};if(i.explicitDeclaration)this.builder.addElement(this.entityDraft(i));let a=this.visit(r);if(a.target.explicitDeclaration)this.builder.addElement(this.entityDraft(a.target));let o={source:this.endpoint(i),target:this.endpoint(a.target),location:this.nodeLocation(r),...a.explicitId?{explicitId:a.explicitId,explicitIdLocation:a.explicitIdLocation}:{},...a.arrow};this.builder.addRelationship(o);let c=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],i,i.explicitDeclaration),this.entityOccurrence(this.nodes(r.children,"entityName")[0],a.target,a.target.explicitDeclaration)],edges:[{id:c,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],r=this.nodes(t,"nodeLabel")[0],a=this.nodes(t,"useCaseMetadata")[0],o=this.nodes(t,"stereotype")[0],c=this.nodes(t,"classSuffix")[0],h=c?this.visit(c):{classes:[],spans:[]};if(s){let d=r?this.visit(r):this.tokenLabel(s),p=r?this.tokens(t,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:d,location:this.tokenLocation(s),generated:!1,...p?{shape:p}:{},...a?{metadata:this.visit(a)}:{},...o?{stereotype:this.visit(o)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:Boolean(p||a||o)}}let l=this.tokenLabel(i);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(i),generated:!0,...a?{metadata:this.visit(a)}:{},...o?{stereotype:this.visit(o)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:Boolean(a||o)}}nodeLabel(t){let s=this.allTokens(t);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let i=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(i[0],i[1]),type:"text",span:i}}useCaseMetadata(t){return this.visit(this.nodes(t,"metadata")[0])}relationTail(t){let s=this.tokens(t,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},arrow:this.visit(this.nodes(t,"arrow")[0]),target:this.visit(this.nodes(t,"entityName")[0])}}arrow(t){return this.visit(this.firstNode(t,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(t){return this.nodeLabel(t)}semanticRelation(t){if(this.tokens(t,"GENERALIZATION").length)return{type:"generalization",arrowType:H.SOLID_ARROW,minlen:1};let s=this.tokens(t,"INCLUDE").length?"include":"extend",i=this.tokens(t,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:H.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(i)},minlen:1}}metadata(t){return{properties:this.nodes(t,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(t)}}metadataProperty(t){let s=this.allTokens(t).filter((c)=>c.tokenType.name!=="COLON"),i=s[0],r=s[1],a=r.tokenType.name==="TRUE"?!0:r.tokenType.name==="FALSE"?!1:this.decodePlain(r),o=[i.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(i),value:a,span:o,keySpan:this.contentSpan(i),valueSpan:this.contentSpan(r),location:this.tokenLocation(i)}}metadataSeparator(t){return}systemBoundaryStatement(t){let s=this.visit(this.nodes(t,"systemBoundaryName")[0]),i=this.nodes(t,"classSuffix")[0],r=i?this.visit(i):{classes:[],spans:[]};s.classes=r.classes,this.builder.addBoundary(s);let a=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(t,"systemBoundaryContent")[0],c=o?this.visit(o):[];this.parentBoundary=a;let h=this.tokens(t,"END")[0],l=this.nodes(t,"metadata")[0],d=l?this.visit(l):void 0,p={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(h),classSpans:r.spans,...d?{metadata:d.properties.map(({key:f,span:T,keySpan:g,valueSpan:x})=>({key:f,span:T,keySpan:g,valueSpan:x}))}:{},...c.length?{children:c}:{}};if(d)this.builder.addMetadataAssignment(s.id,s.location,d,p);return p}systemBoundaryName(t){let s=this.tokens(t,"IDENTIFIER")[0];if(s){let a=this.nodes(t,"nodeLabel")[0];return{id:s.image,label:a?this.visit(a):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],r=this.tokenLabel(i);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(i),generated:!0,classes:[]}}systemBoundaryContent(t){return[...this.nodes(t,"blankLine"),...this.nodes(t,"commentLine"),...this.nodes(t,"boundaryElement")].sort((i,r)=>(i.location?.startOffset??0)-(r.location?.startOffset??0)).map((i)=>this.wrap(i,this.visit(i)))}boundaryElement(t){let s=this.nodes(t,"actorDeclarationOnly")[0];if(s)return this.visit(s);let i=this.nodes(t,"entityName")[0],r=this.visit(i);return r.explicitDeclaration=!0,r.shape??="ellipse",this.builder.addElement(this.entityDraft(r)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(i,r,!0)]}}metadataAssignmentStatement(t){let s=this.visit(this.nodes(t,"metadataAssignmentTarget")[0]),i=this.visit(this.nodes(t,"metadata")[0]),r={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:i.properties.map(({key:a,span:o,keySpan:c,valueSpan:h})=>({key:a,span:o,keySpan:c,valueSpan:h}))};return this.builder.addMetadataAssignment(s.id,s.location,i,r),r}metadataAssignmentTarget(t){let s=this.allTokens(t)[0],i=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(i.text),location:this.tokenLocation(s)}}noteStatement(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:i,location:this.ctxLocation(t)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:i.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(t){let s=this.tokens(t,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(t){let s=this.tokens(t,"IDENTIFIER");return{classes:s.map((i)=>i.image),spans:s.map((i)=>this.tokenSpan(i))}}jsonStatement(t){let s=this.tokens(t,"JSON_DECLARATION_START")[0],i=this.tokens(t,"JSON_OBJECT_LITERAL")[0],r=/^json[\t ]+(\w+)/.exec(s.image),a=r[1],o=r[0].length-a.length,c={span:[s.startOffset+o,s.startOffset+o+a.length],line:s.startLine??1,column:(s.startColumn??1)+o},h=Pr(i.image,i.startLine??1,i.startColumn??1),l=this.nodes(t,"classSuffix")[0],d=l?this.visit(l):{classes:[],spans:[]},p={id:a,value:h.value,propertyOrder:h.propertyOrder,location:c,classes:d.classes};return this.builder.addJson(p),{kind:"json",span:[0,0],nodes:[{id:a,span:c.span,idSpan:c.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(t){let s=this.allTokens(t).find((i)=>["TD","TB","BT","RL","LR"].includes(i.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(t){let s=this.tokens(t,"IDENTIFIER"),i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addClassDef(s.map((r)=>r.image),i),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(t){let s=this.tokens(t,"IDENTIFIER"),i=1;for(;i<s.length;i++)if(!this.source.slice((s[i-1].endOffset??s[i-1].startOffset)+1,s[i].startOffset).includes(","))break;let r=s.slice(0,i).map((o)=>({id:o.image,location:this.tokenLocation(o)})),a=s.slice(i).map((o)=>o.image);return this.builder.addClassAssignment(r,a),{kind:"classAssign",span:[0,0],ref:a[0],refSpan:this.tokenSpan(s[i]),nodes:r.map(({id:o,location:c})=>({id:o,span:c.span,idSpan:c.span}))}}styleStatement(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),i),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(t){return this.nodes(t,"styleValue").map((s)=>this.visit(s))}styleValue(t){let s=this.allTokens(t),i=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(i[0],i[1]).replaceAll("\\,",",")}styleComponent(t){return this.allTokens(t).map((s)=>s.image).join("")}forwardSolidOperator(t){let s=this.tokens(t,"FORWARD_SOLID")[0];return{type:"association",arrowType:H.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(t){let s=this.tokens(t,"BACKWARD_SOLID")[0],i=this.nodes(t,"edgeLabel")[0],r=i?this.tokens(t,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:H.BACK_ARROW,minlen:this.solidMinlen(r),...i?{label:this.visit(i)}:{}}}markerlessSolidOperator(t){let s=this.nodes(t,"edgeLabel")[0],i=this.allTokens(t);if(!s)return{type:"association",arrowType:H.LINE_SOLID,minlen:this.solidMinlen(this.tokens(t,"MARKERLESS_SOLID")[0])};let r=i.at(-1),a=r.tokenType.name==="FORWARD_SOLID"?H.SOLID_ARROW:r.tokenType.name==="FORWARD_CIRCLE"?H.CIRCLE_ARROW:r.tokenType.name==="FORWARD_CROSS"?H.CROSS_ARROW:H.LINE_SOLID;return{type:"association",arrowType:a,label:this.visit(s),minlen:a===H.SOLID_ARROW||a===H.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(t){return{type:"association",arrowType:H.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(t){let s=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:H.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(t){return{type:"association",arrowType:H.CROSS_ARROW,minlen:1}}backwardCrossOperator(t){let s=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:H.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}actorDraft(t){return{id:t.id,kind:"actor",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}entityDraft(t){return{id:t.id,kind:"usecase",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.shape?{shape:t.shape}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}endpoint(t,s=t.explicitDeclaration??!0){return{id:t.id,label:t.label,location:t.location,generated:t.generated,declaration:s,classesOnReference:t.classes.length>0}}relationshipDraft(t,s,i){return{source:this.endpoint(t,!0),target:this.endpoint(s.target),location:i,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(t,s,i){return{id:s.id,span:this.nodeSpan(t),idSpan:s.location.span,labelSpan:s.label.span,...i?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:r,span:a,keySpan:o,valueSpan:c})=>({key:r,span:a,keySpan:o,valueSpan:c}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(t,s,i){return this.actorOccurrence(t,s,i)}wrap(t,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(t);for(let i of s.edges??[])i.span=s.span;return s}tokenLabel(t){let s=t.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",i=s==="markdown"?2:t.tokenType.name==="PLAIN_STRING"?1:0,r=this.tokenSpan(t,i);return{text:this.source.slice(r[0],r[1]),type:s,span:r}}decodePlain(t){return t.tokenType.name==="PLAIN_STRING"?t.image.slice(1,-1):t.image}contentSpan(t){return this.tokenSpan(t,t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(t){return t.replace(/\W/g,"_")}solidMinlen(t){return Math.max(1,(t.image.match(/-/g)?.length??2)-1)}nodeLocation(t){let s=this.allTokens(t.children)[0];return{span:this.nodeSpan(t),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(t){let s=this.allTokens(t).filter((a)=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),i=s[0],r=s.at(-1);return{span:[i.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:i.startLine??1,column:i.startColumn??1}}tokenLocation(t){let s=t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(t,s),line:t.startLine??1,column:(t.startColumn??1)+s}}nodeSpan(t){let s=this.allTokens(t.children).filter((a)=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),i=s[0],r=s.at(-1);if(!i||!r)throw Error("Usecase CST node has no source token");return[i.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(t,s=0){return[t.startOffset+s,Math.min(this.source.length,(t.endOffset??t.startOffset+t.image.length-1)+1-s)]}nodes(t,s){return(t[s]??[]).filter((i)=>("children"in i))}tokens(t,s){return(t[s]??[]).filter((i)=>("tokenTypeIdx"in i))}firstNode(t,...s){for(let i of s){let r=this.nodes(t,i)[0];if(r)return r}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(t){let s=[];for(let i of Object.values(t))for(let r of i)if("tokenTypeIdx"in r)s.push(r);else s.push(...this.allTokens(r.children));return s.sort((i,r)=>i.startOffset-r.startOffset)}},Vo=new Ko,zo={parse:e(async(t)=>{Ns.clear(),Gt.input=[];try{Hi({diagramType:"usecase",lexer:xo,parser:Gt,entry:e(()=>Gt.start(),"entry"),visit:e((s)=>Vo.build(s,t),"visit")},t)}catch(s){Ns.clear();let i=Gt.errors[0];if(i){let{token:r}=i,a=ut(r.startOffset)?r.startOffset:t.length,o=ut(r.endOffset)?r.endOffset+1:a,c=ut(r.startLine)?r.startLine:t.slice(0,a).split(/\r\n|\r|\n/).length,h=Math.max(t.lastIndexOf(`
117
- `,a-1),t.lastIndexOf("\r",a-1)),l=ut(r.startColumn)?r.startColumn:a-h,d=s instanceof Error?s.message:String(s);throw Error(`${d} at line ${c}, column ${l} [${a},${o})`)}throw s}},"parse")},Ho=["point","circle","cross","extension"],Dr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Ki=e((t,s)=>{let[i,r]=[t,s].map((a)=>a.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${i}-${r}`},"usecaseDomId"),Xo=e((t)=>`usecase-${t.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=e((t,s)=>{if(s!=="markdown")return t;return Ao(t).map((i)=>i.map((r)=>r.content).join(" ")).join(`
118
- `)},"getAccessibleLabel"),Yo=e((t)=>{let s=Is(t.label??t.id,t.labelType);if(Dr[t.shape]){let r=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",a=t.business?"business ":"",o=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${a}${r}actor ${s}${o}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${s}`;if(t.shape==="usecaseJsonTable"){let r=(t.jsonRows??[]).map((a)=>`${a.accessibleKey}: ${a.value}`).join("; ");return r?`${s}: ${r}`:s}let i=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${s}${i}`},"getUsecaseNodeAccessibleName"),qo=e((t)=>`${t.boundaryType} system boundary ${Is(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=e((t)=>{if(t.relationshipType==="note")return"";return`${t.relationshipType==="association"&&t.label?`association ${Is(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=e((t)=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Vi=e((t)=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=e((t,s)=>{t.diagramId=s,t.markers=[...Ho];for(let i of t.nodes){let r=i;if(r.domId=Xo(i.id),i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);if(i.stereotype)i.stereotype=ht(i.stereotype);if(!i.isGroup&&i.shape==="usecaseJsonTable")i.jsonRows=i.jsonRows?.map((a)=>({...a,key:ht(a.key),value:ht(a.value)}));if(!i.isGroup&&(i.shape==="usecaseEllipse"||i.shape==="rect")&&i.stereotype){let a=i.label??ht(i.id);i.label=`«${Vi(i.stereotype)}»<br/>${i.labelType==="text"?Vi(a):a}`,i.labelType="markdown",r.hasFoldedStereotype=!0,delete i.stereotype}}for(let i of t.edges)if(i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);return t},"prepareUsecaseLayoutData"),Qo=e((t,s,i)=>{for(let a of s.nodes){let o=typeof a.domId==="string"?a.domId:Ki(s.diagramId,a.id),c=t.select(`#${o}`),h=a.isGroup?"boundary":Dr[a.shape]?"actor":a.shape==="note"?"note":a.shape==="usecaseJsonTable"?"json":"usecase",l=i.nodes.get(a.id)??a.id;if(c.attr("data-usecase-id",a.id).attr("data-usecase-kind",h).attr("role","img").attr("aria-label",l),!a.isGroup&&(a.shape==="usecaseEllipse"||a.shape==="rect")&&"hasFoldedStereotype"in a&&a.hasFoldedStereotype===!0){let d=c.node(),p=d?.querySelector(".nodeLabel"),f=p?.querySelector("p")??p,T=f?.firstChild;if(f&&T?.nodeType===3){let g=f.ownerDocument.createElement("span");g.className="usecase-stereotype",f.insertBefore(g,T),g.appendChild(T)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let r=new Map(s.edges.map((a)=>[a.id,a]));t.selectAll('path[data-et="edge"]').each(function(){let a=r.get(this.getAttribute("data-id")??"");if(!a)return;let o=m(this);if(o.attr("id",Ki(s.diagramId,a.id)).attr("data-usecase-id",a.id).attr("data-usecase-kind",a.internal?"note-connector":"relationship"),a.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",i.edges.get(a.id)??a.id)})},"annotateUsecaseElements"),zi=e((t,s)=>{t.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=e(async(t,s,i,r)=>{n.info("Drawing usecase diagram (unified)",s);let{layout:a}=u(),o=r.db,c=o.getData(),h=new Map(c.nodes.map((f)=>[f.id,Is(f.label??f.id,f.labelType)])),l={nodes:new Map(c.nodes.map((f)=>[f.id,f.isGroup?qo(f):Yo(f.shape==="note"?{...f,noteTargetLabel:h.get(f.noteTarget??"")}:f)])),edges:new Map(c.edges.map((f)=>[f.id,Jo({...f,sourceLabel:h.get(f.source)??f.sourceLabel,targetLabel:h.get(f.target)??f.targetLabel})]))},d=Ee(s,c.config.securityLevel);c.layoutAlgorithm=_e(a),Zo(c,s),zi(d,c),await Ae(c,d),Qo(d,c,l);let p=c.diagramPadding;z.insertTitle(d,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),ge(d,p,"usecaseDiagram",c.useMaxWidth),zi(d,c)},"draw"),tl={draw:el},sl=e((t)=>({actorBkg:t.usecaseActorBkg??t.actorBkg??t.mainBkg,actorBorder:t.usecaseActorBorder??t.actorBorder??t.primaryColor,bkg:t.usecaseBkg??t.mainBkg,border:t.usecaseBorder??t.nodeBorder??t.primaryColor,boundaryBkg:t.usecaseBoundaryBkg??t.clusterBkg,boundaryBorder:t.usecaseBoundaryBorder??t.clusterBorder,includeLine:t.usecaseIncludeLine??t.lineColor,extendLine:t.usecaseExtendLine??t.lineColor}),"roleColors"),nl=e((t)=>{let{theme:s,bkgColorArray:i,borderColorArray:r}=t;if(!he(s,r))return"";let a=k().usecase?.colorScheme==="rotate",o=pe(t.look),c=o==="handDrawn",h=ve(i),l="";for(let d=0;d<Ct(r);d++){let p=r[d],f=h?`fill: ${i[d%i.length]};`:"",T=`[data-look="${o}"][data-color-id="color-${d}"]`;if(l+=`
116
+ `&&t!=="\r")return;this.offset++}}deletePointerSubtree(t){let s=`${t}/`;for(let i of Object.keys(this.propertyOrder))if(i===t||i.startsWith(s))delete this.propertyOrder[i]}};function Pr(t,s,i){let r;try{r=JSON.parse(t)}catch(a){let o=a instanceof Error?a.message:String(a),c=wo(o,t,s,i);if(!c){let h=0;try{new Wi(t).collect()}catch(l){if(l instanceof ae)h=l.offset}c=En(t,h,s,i)}throw new Gi(`Invalid JSON: ${o}`,c.line,c.column)}if(typeof r!=="object"||r===null||Array.isArray(r))throw new Gi("JSON value must have an object root",s,i);return{value:r,propertyOrder:new Wi(t).collect()}}e(Pr,"parseOrderedJsonObject");var Uo=e((t)=>({shape:t.type==="normal"?"actor":t.type==="hollow"?"actor-hollow":t.type==="awesome"?"actor-awesome":"actor-icon",...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"actor",actorType:t.type,business:t.business,labelType:t.labelType,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"actorNode"),Po=e((t)=>({shape:t.shape,...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"usecase",useCaseShape:t.shape,business:t.business,labelType:t.labelType,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"useCaseNode"),Do=e((t)=>({label:t.label,shape:"note",attrs:{kind:"note",target:t.target,labelType:t.labelType}}),"noteNode"),Fo=e((t)=>({label:t.id,shape:"json-table",...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"json",value:t.value,propertyOrder:t.propertyOrder,labelType:"text"}}),"jsonNode"),Bo=e((t)=>({id:t.id,source:t.source,target:t.target,...t.label?{label:t.label}:{},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{relationshipType:t.type,arrowType:t.arrowType,minlen:t.minlen,explicitId:t.explicitId,animate:t.animate,...t.animation?{animation:t.animation}:{},...t.labelType?{labelType:t.labelType}:{}}}),"relationshipEdge"),$o=e((t)=>({id:`${t.id}-edge`,source:t.id,target:t.target,attrs:{relationshipType:"note",arrowType:H.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Go=e((t,s,i,r)=>{let a={};for(let l of t.getActors().values())a[l.id]=Uo(l);for(let l of t.getUseCases().values())a[l.id]=Po(l);for(let l of t.getNotes().values())a[l.id]=Do(l);for(let l of t.getJsonNodes().values())a[l.id]=Fo(l);let o={};for(let l of t.getSystemBoundaries().values())o[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};let c={};for(let l of t.getClassDefs().values())c[l.id]={styles:[...l.styles]};let h=t.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:h==="TD"?"TB":h,span:i},...t.getAccTitle()?{accTitle:t.getAccTitle()}:{},...t.getAccDescription()?{accDescr:t.getAccDescription()}:{},nodes:a,edges:[...t.getRelationships().map(Bo),...[...t.getNotes().values()].map($o)],groups:o,classDefs:c,statements:r}},"buildUsecaseGraphAST"),le=e((t)=>`line ${t.line}, column ${t.column} [${t.span[0]},${t.span[1]})`,"locationText"),ji=e((t)=>t===void 0?"":` (label "${t}")`,"labelSuffix"),Ze=e((t)=>t.generated?t.label:void 0,"generatedFrom"),hn=e((t,s)=>{for(let i of s)if(!t.includes(i))t.push(i)},"pushUnique"),Wo=class{constructor(t){this.db=t,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=t.createModel()}static{e(this,"UsecaseModelBuilder")}reset(t){this.model=this.db.createModel(),this.source=t,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(t){this.elements.push(t)}addBoundary(t){this.boundaries.push(t)}addJson(t){this.jsonDrafts.push(t)}addRelationship(t){this.relationshipDrafts.push(t)}addNote(t){this.noteDrafts.push(t)}addMetadataAssignment(t,s,i,r){this.metadataAssignments.push({target:t,targetLocation:s,metadata:i,statement:r})}addClassDef(t,s){this.classDefinitions.push({ids:t,styles:s})}addClassAssignment(t,s){this.classAssignments.push({targets:t,classes:s})}addStyleAssignment(t,s,i){this.styleAssignments.push({target:t,location:s,styles:i})}setDirection(t){this.directions.push(t==="TD"?"TB":t)}setAccTitle(t){this.model.accTitle=t}setAccDescription(t){this.model.accDescription=t}setStatements(t){this.statements=t}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(t){let s=new Map,i=new Map,r=new Map,a=new Map;for(let l of this.relationshipDrafts)this.recordFirst(a,l.source.id,l.source.location.span[0]),this.recordFirst(a,l.target.id,l.target.location.span[0]);for(let l of this.elements)this.recordFirst(a,l.id,l.location.span[0]);for(let l of this.boundaries)this.recordFirst(a,l.id,l.location.span[0]);for(let l of this.jsonDrafts)this.recordFirst(a,l.id,l.location.span[0]);let o=[...this.elements.map((l)=>({offset:l.location.span[0],type:"element",value:l})),...this.boundaries.map((l)=>({offset:l.location.span[0],type:"boundary",value:l})),...this.jsonDrafts.map((l)=>({offset:l.location.span[0],type:"json",value:l})),...this.relationshipDrafts.filter((l)=>l.explicitId).map((l)=>({offset:l.explicitIdLocation.span[0],type:"edge",value:l}))].sort((l,d)=>l.offset-d.offset);for(let l of o)if(l.type==="element")this.collectElement(l.value,s,i);else if(l.type==="boundary")this.collectBoundary(l.value,s,r);else if(l.type==="json")this.registerUnique(s,l.value.id,"json",l.value.location,!1);else this.registerUnique(s,l.value.explicitId,"edge",l.value.explicitIdLocation,!1);this.materializeElements(i,a),this.materializeBoundaries(r,a),this.materializeJson(a);let c=this.materializeRelationships(s,i,a);this.reorderElements(i,a),this.applyMetadataAssignments(s,i,r,c),this.validateAndRefreshElements(i),this.refreshBoundaries(r,i),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,c),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([l,d])=>[l,d.kind]));let h=Go(this,this.source,t,this.statements);return this.model.ast=h,this.db.commit(this.model),h}collectElement(t,s,i){let r=s.get(t.id),a=Ze({generated:t.generated,label:t.label.text});if(r&&r.kind!==t.kind)this.conflict(`ID '${t.id}' is declared as both ${r.kind} and ${t.kind}`,t.location,r.location,a,Ze(r));if(r&&(r.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,r.location,a,Ze(r));let o=i.get(t.id);if(!o){let c={kind:t.kind,id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],...t.parentId?{parentId:t.parentId,parentLocation:t.parentLocation}:{},...t.shape?{shape:t.shape}:{},...t.stereotype?{stereotype:t.stereotype,stereotypeLocation:t.location}:{}};this.applyDeclarationMetadata(c,t.metadata),i.set(t.id,c),s.set(t.id,{kind:t.kind,location:t.location,generated:t.generated,label:t.label.text});return}if(o.label.text!==t.label.text||o.label.type!==t.label.type)this.conflict(`ID '${t.id}' has conflicting labels`,t.location,o.location);if(t.shape&&o.shape&&t.shape!==o.shape)this.conflict(`Use case '${t.id}' has conflicting shapes`,t.location,o.location);if(t.parentId&&o.parentId&&t.parentId!==o.parentId)this.conflict(`Element '${t.id}' belongs to more than one system boundary`,t.parentLocation??t.location,o.parentLocation??o.location);if(t.stereotype&&o.stereotype&&t.stereotype!==o.stereotype)this.conflict(`Element '${t.id}' has conflicting stereotypes`,t.location,o.stereotypeLocation??o.location);o.shape??=t.shape,o.parentId??=t.parentId,o.parentLocation??=t.parentLocation,o.stereotype??=t.stereotype,o.stereotypeLocation??=t.stereotype?t.location:void 0,hn(o.classes,t.classes),this.applyDeclarationMetadata(o,t.metadata)}collectBoundary(t,s,i){let r=s.get(t.id),a=Ze({generated:t.generated,label:t.label.text});if(r&&r.kind!=="boundary")this.conflict(`ID '${t.id}' is declared as both ${r.kind} and boundary`,t.location,r.location,a,Ze(r));if(r&&(r.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,r.location,a,Ze(r));let o=i.get(t.id);if(o){if(o.label.text!==t.label.text||o.label.type!==t.label.type)this.conflict(`Boundary '${t.id}' has conflicting titles`,t.location,o.location);hn(o.classes,t.classes);return}i.set(t.id,{id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],styles:[],members:[]}),s.set(t.id,{kind:"boundary",location:t.location,generated:t.generated,label:t.label.text})}materializeElements(t,s){for(let i of[...t.values()].sort((r,a)=>(s.get(r.id)??0)-(s.get(a.id)??0)))this.setElementModel(i)}materializeBoundaries(t,s){for(let i of[...t.values()].sort((r,a)=>(s.get(r.id)??0)-(s.get(a.id)??0)))this.model.systemBoundaries.set(i.id,{id:i.id,label:i.label.text,labelType:i.label.type,type:i.type??"rect",members:[],classes:[...i.classes],styles:[...i.styles]})}materializeJson(t){for(let s of[...this.jsonDrafts].sort((i,r)=>(t.get(i.id)??0)-(t.get(r.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(t,s,i){let r=new Map,a=0;for(let o of this.relationshipDrafts){let c=this.resolveEndpoint(o.source,t,s,i),h=this.resolveEndpoint(o.target,t,s,i);this.validateRelationship(o,c,h,t);let l=o.explicitId??`edge-${a++}`,d={id:l,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),r.set(l,{draft:o,relationship:d})}return this.model.relationshipCounter=a,r}resolveEndpoint(t,s,i,r){if(t.classesOnReference&&!t.declaration)throw Error(`Relationship endpoint '${t.id}' uses ::: without declaring the node at ${le(t.location)}`);let a=s.get(t.id);if(a)return a.kind;return i.set(t.id,{kind:"usecase",id:t.id,label:t.label,location:t.location,generated:t.generated,shape:"ellipse",classes:[]}),s.set(t.id,{kind:"usecase",location:t.location,generated:t.generated,label:t.label.text}),this.recordFirst(r,t.id,t.location.span[0]),"usecase"}reorderElements(t,s){let i=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let a of[...t.values()].sort((o,c)=>(s.get(o.id)??0)-(s.get(c.id)??0))){if(!i.has(a.id)&&!r.has(a.id))this.setElementModel(a);let o=i.get(a.id)??this.model.actors.get(a.id),c=r.get(a.id)??this.model.useCases.get(a.id);if(o)this.model.actors.set(a.id,o);else if(c)this.model.useCases.set(a.id,c)}}applyMetadataAssignments(t,s,i,r){for(let a of this.metadataAssignments){let o=t.get(a.target);if(!o){let c=this.inferMetadataKind(a.metadata);throw Error(`Metadata target '${a.target}' is unresolved${c?` (metadata implies ${c})`:""} at ${le(a.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(a.target),a.metadata);else if(o.kind==="boundary"){let c=i.get(a.target);for(let h of a.metadata.properties){if(h.key!=="type"||h.value!=="rect"&&h.value!=="package")this.invalidMetadata(a.target,o.kind,h);c.type=h.value}}else if(o.kind==="edge"){let c=r.get(a.target);if(!c)throw Error(`Metadata target '${a.target}' is not an explicit edge at ${le(a.targetLocation)}`);a.statement.kind="edgeMetadata",a.statement.edges=[{id:a.target,span:a.statement.span,idSpan:a.targetLocation.span,...a.statement.metadata?{metadata:a.statement.metadata}:{}}],delete a.statement.nodes;for(let h of a.metadata.properties)if(h.key==="animate"&&typeof h.value==="boolean")c.relationship.animate=h.value;else if(h.key==="animation"&&(h.value==="fast"||h.value==="slow"))c.relationship.animation=h.value,c.relationship.animate=!0;else this.invalidMetadata(a.target,o.kind,h)}else for(let c of a.metadata.properties)this.invalidMetadata(a.target,o.kind,c)}for(let{relationship:a}of r.values())if(a.animation)a.animate=!0}applyStandaloneElementMetadata(t,s){for(let i of s.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!0);else if(i.key==="business"&&typeof i.value==="boolean")t.business=i.value;else this.invalidMetadata(t.id,t.kind,i)}applyDeclarationMetadata(t,s){if(!s)return;for(let i of s.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!1);else if(i.key==="business"&&typeof i.value==="boolean"){if(t.business!==void 0&&t.business!==i.value)this.conflict(`Use case '${t.id}' has conflicting business metadata`,i.location,t.location);t.business=i.value}else this.invalidMetadata(t.id,t.kind,i)}applyActorProperty(t,s,i){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!i&&t.actorType!==void 0&&t.actorType!==s.value)this.conflict(`Actor '${t.id}' has conflicting type metadata`,s.location,t.location);t.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!i&&t.icon!==void 0&&t.icon!==s.value)this.conflict(`Actor '${t.id}' has conflicting icon metadata`,s.location,t.location);t.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!i&&t.business!==void 0&&t.business!==s.value)this.conflict(`Actor '${t.id}' has conflicting business metadata`,s.location,t.location);t.business=s.value}else this.invalidMetadata(t.id,t.kind,s)}validateAndRefreshElements(t){for(let s of t.values()){let i=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${le(s.location)}`);if(s.business&&(i==="icon"||i==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${le(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${le(s.location)}`);this.setElementModel(s)}}refreshBoundaries(t,s){for(let i of t.values())i.members.length=0;for(let i of[...this.elements].sort((r,a)=>r.location.span[0]-a.location.span[0])){if(!i.parentId)continue;let r=t.get(i.parentId);if(!r)throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${le(i.parentLocation??i.location)}`);if(!r.members.includes(i.id))r.members.push(i.id)}for(let i of s.values())if(i.parentId&&!t.has(i.parentId))throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${le(i.parentLocation??i.location)}`);for(let i of t.values()){let r=this.model.systemBoundaries.get(i.id);r.type=i.type??"rect",r.members=[...i.members],r.classes=[...i.classes],r.styles=[...i.styles]}}materializeNotes(t){let s=0;for(let i of this.noteDrafts){let r=t.get(i.target);if(!r)throw Error(`Note target '${i.target}' is unresolved at ${le(i.targetLocation)}`);if(r.kind!=="actor"&&r.kind!=="usecase")this.conflict(`Note target '${i.target}' must be an actor or use case, not ${r.kind}`,i.targetLocation,r.location);let a=`note-${s++}`;this.model.notes.set(a,{id:a,target:i.target,label:i.label.text,labelType:i.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let t of this.classDefinitions)for(let s of t.ids)this.model.classDefs.set(s,{id:s,styles:[...t.styles]})}applyClassesAndStyles(t,s){for(let i of this.classAssignments)for(let r of i.targets)hn(this.getStylable(r.id,t,s,r.location).classes,i.classes);for(let i of this.styleAssignments)this.getStylable(i.target,t,s,i.location).styles.push(...i.styles)}getStylable(t,s,i,r){let a=s.get(t)?.kind,o=a==="actor"?this.model.actors.get(t):a==="usecase"?this.model.useCases.get(t):a==="boundary"?this.model.systemBoundaries.get(t):a==="json"?this.model.jsonNodes.get(t):a==="edge"?i.get(t)?.relationship:void 0;if(!o)throw Error(`Class/style target '${t}' is unresolved or anonymous at ${le(r)}`);return o}validateRelationship(t,s,i,r){let a=e((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!a(s))this.conflict(`Relationship source '${t.source.id}' cannot be ${s}`,t.source.location,r.get(t.source.id).location);if(!a(i))this.conflict(`Relationship target '${t.target.id}' cannot be ${i}`,t.target.location,r.get(t.target.id).location);if((t.type==="include"||t.type==="extend")&&(s!=="usecase"||i!=="usecase"))throw Error(`${t.type} relationship requires use-case endpoints at ${le(t.location)}`);if(t.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==i))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${le(t.location)}`);if(t.type==="association"&&(s==="json"||i==="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 ${le(t.location)}`)}setElementModel(t){if(t.kind==="actor"){let s=t.icon?"icon":t.actorType??"normal";this.model.useCases.delete(t.id),this.model.actors.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,type:s,...t.icon?{icon:t.icon}:{},business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.actors.get(t.id)?.styles??[]})}else this.model.actors.delete(t.id),this.model.useCases.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,shape:t.shape??"ellipse",business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.useCases.get(t.id)?.styles??[]})}inferMetadataKind(t){let s=new Set(["actor","usecase","boundary","edge"]);for(let i of t.properties)if(i.key==="icon")s.clear(),s.add("actor");else if(i.key==="animate"||i.key==="animation")s.clear(),s.add("edge");else if(i.key==="type"){if(s.clear(),i.value==="rect"||i.value==="package")s.add("boundary");else if(i.value==="normal"||i.value==="hollow"||i.value==="awesome")s.add("actor")}else if(i.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(t,s,i){throw Error(`Metadata property '${i.key}' is invalid for ${s} '${t}' at ${le(i.location)}`)}registerUnique(t,s,i,r,a){let o=t.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${i})`,r,o.location,void 0,Ze(o));t.set(s,{kind:i,location:r,generated:a})}recordFirst(t,s,i){let r=t.get(s);if(r===void 0||i<r)t.set(s,i)}conflict(t,s,i,r,a){throw Error(`${t} at ${le(s)}${ji(r)}; previous declaration at ${le(i)}${ji(a)}`)}},jo=Gt.getBaseCstVisitorConstructor(),Ko=class extends jo{constructor(){super();this.builder=new Wo(Ns),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{e(this,"UsecaseVisitor")}build(t,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(t)}start(t){let s=this.tokens(t,"USECASE")[0],i=[];for(let r of this.nodes(t,"line"))i.push(this.visit(r));this.builder.setStatements(i),this.builder.finalize(this.tokenSpan(s))}line(t){let s=this.firstNode(t,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(t){return this.visit(this.firstNode(t,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(t){return}blankLine(t){return{kind:"blank",span:this.tokenSpan(this.tokens(t,"NEWLINE")[0])}}commentLine(t){return{kind:"comment",span:this.tokenSpan(this.tokens(t,"COMMENT")[0])}}accTitleStatement(t){let s=this.tokens(t,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(t){let s=this.tokens(t,"ACC_DESCR_LINE")[0],i=this.tokens(t,"ACC_DESCR_BLOCK")[0],r=s?s.image.slice(s.image.indexOf(":")+1).trim():i.image.slice(i.image.indexOf("{")+1,i.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(r),{kind:"accDescr",span:[0,0]}}actorStatement(t){let s=this.nodes(t,"actorItem"),i=s.map((l)=>this.visit(l)),r=this.nodes(t,"relationTail")[0],a=i.map((l,d)=>this.actorOccurrence(s[d],l,!0));for(let l of i)this.builder.addElement(this.actorDraft(l));if(!r)return{kind:"node",span:[0,0],nodes:a};let o=this.visit(r);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let c=this.relationshipDraft(i[0],o,this.nodeLocation(r));this.builder.addRelationship(c);let h=c.explicitId??`edge-${this.anonymousEdge++}`;return a.push(this.entityOccurrence(this.nodes(r.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:a,edges:[{id:h,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}actorItem(t){let s=this.visit(this.nodes(t,"actorName")[0]),i=this.nodes(t,"metadata")[0],r=this.nodes(t,"stereotype")[0],a=this.nodes(t,"classSuffix")[0],o=a?this.visit(a):{classes:[],spans:[]};return{...s,...i?{metadata:this.visit(i)}:{},...r?{stereotype:this.visit(r)}:{},classes:o.classes,classSpans:o.spans}}actorName(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0];if(s){let a=this.nodes(t,"nodeLabel")[0],o=a?this.visit(a):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let r=this.tokenLabel(i);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(i),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(t){let s=this.nodes(t,"actorItem"),i=s.map((r)=>this.visit(r));for(let r of i)this.builder.addElement(this.actorDraft(r));return{kind:"node",span:[0,0],nodes:i.map((r,a)=>this.actorOccurrence(s[a],r,!0))}}entityStatement(t){let s=this.nodes(t,"entityName"),i=this.visit(s[0]),r=this.nodes(t,"relationTail")[0];if(!r)return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],i,!0)]};if(i.explicitDeclaration)this.builder.addElement(this.entityDraft(i));let a=this.visit(r);if(a.target.explicitDeclaration)this.builder.addElement(this.entityDraft(a.target));let o={source:this.endpoint(i),target:this.endpoint(a.target),location:this.nodeLocation(r),...a.explicitId?{explicitId:a.explicitId,explicitIdLocation:a.explicitIdLocation}:{},...a.arrow};this.builder.addRelationship(o);let c=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],i,i.explicitDeclaration),this.entityOccurrence(this.nodes(r.children,"entityName")[0],a.target,a.target.explicitDeclaration)],edges:[{id:c,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],r=this.nodes(t,"nodeLabel")[0],a=this.nodes(t,"useCaseMetadata")[0],o=this.nodes(t,"stereotype")[0],c=this.nodes(t,"classSuffix")[0],h=c?this.visit(c):{classes:[],spans:[]};if(s){let d=r?this.visit(r):this.tokenLabel(s),f=r?this.tokens(t,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:d,location:this.tokenLocation(s),generated:!1,...f?{shape:f}:{},...a?{metadata:this.visit(a)}:{},...o?{stereotype:this.visit(o)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:Boolean(f||a||o)}}let l=this.tokenLabel(i);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(i),generated:!0,...a?{metadata:this.visit(a)}:{},...o?{stereotype:this.visit(o)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:Boolean(a||o)}}nodeLabel(t){let s=this.allTokens(t);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let i=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(i[0],i[1]),type:"text",span:i}}useCaseMetadata(t){return this.visit(this.nodes(t,"metadata")[0])}relationTail(t){let s=this.tokens(t,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},arrow:this.visit(this.nodes(t,"arrow")[0]),target:this.visit(this.nodes(t,"entityName")[0])}}arrow(t){return this.visit(this.firstNode(t,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(t){return this.nodeLabel(t)}semanticRelation(t){if(this.tokens(t,"GENERALIZATION").length)return{type:"generalization",arrowType:H.SOLID_ARROW,minlen:1};let s=this.tokens(t,"INCLUDE").length?"include":"extend",i=this.tokens(t,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:H.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(i)},minlen:1}}metadata(t){return{properties:this.nodes(t,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(t)}}metadataProperty(t){let s=this.allTokens(t).filter((c)=>c.tokenType.name!=="COLON"),i=s[0],r=s[1],a=r.tokenType.name==="TRUE"?!0:r.tokenType.name==="FALSE"?!1:this.decodePlain(r),o=[i.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(i),value:a,span:o,keySpan:this.contentSpan(i),valueSpan:this.contentSpan(r),location:this.tokenLocation(i)}}metadataSeparator(t){return}systemBoundaryStatement(t){let s=this.visit(this.nodes(t,"systemBoundaryName")[0]),i=this.nodes(t,"classSuffix")[0],r=i?this.visit(i):{classes:[],spans:[]};s.classes=r.classes,this.builder.addBoundary(s);let a=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(t,"systemBoundaryContent")[0],c=o?this.visit(o):[];this.parentBoundary=a;let h=this.tokens(t,"END")[0],l=this.nodes(t,"metadata")[0],d=l?this.visit(l):void 0,f={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(h),classSpans:r.spans,...d?{metadata:d.properties.map(({key:m,span:T,keySpan:g,valueSpan:x})=>({key:m,span:T,keySpan:g,valueSpan:x}))}:{},...c.length?{children:c}:{}};if(d)this.builder.addMetadataAssignment(s.id,s.location,d,f);return f}systemBoundaryName(t){let s=this.tokens(t,"IDENTIFIER")[0];if(s){let a=this.nodes(t,"nodeLabel")[0];return{id:s.image,label:a?this.visit(a):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],r=this.tokenLabel(i);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(i),generated:!0,classes:[]}}systemBoundaryContent(t){return[...this.nodes(t,"blankLine"),...this.nodes(t,"commentLine"),...this.nodes(t,"boundaryElement")].sort((i,r)=>(i.location?.startOffset??0)-(r.location?.startOffset??0)).map((i)=>this.wrap(i,this.visit(i)))}boundaryElement(t){let s=this.nodes(t,"actorDeclarationOnly")[0];if(s)return this.visit(s);let i=this.nodes(t,"entityName")[0],r=this.visit(i);return r.explicitDeclaration=!0,r.shape??="ellipse",this.builder.addElement(this.entityDraft(r)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(i,r,!0)]}}metadataAssignmentStatement(t){let s=this.visit(this.nodes(t,"metadataAssignmentTarget")[0]),i=this.visit(this.nodes(t,"metadata")[0]),r={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:i.properties.map(({key:a,span:o,keySpan:c,valueSpan:h})=>({key:a,span:o,keySpan:c,valueSpan:h}))};return this.builder.addMetadataAssignment(s.id,s.location,i,r),r}metadataAssignmentTarget(t){let s=this.allTokens(t)[0],i=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(i.text),location:this.tokenLocation(s)}}noteStatement(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:i,location:this.ctxLocation(t)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:i.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(t){let s=this.tokens(t,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(t){let s=this.tokens(t,"IDENTIFIER");return{classes:s.map((i)=>i.image),spans:s.map((i)=>this.tokenSpan(i))}}jsonStatement(t){let s=this.tokens(t,"JSON_DECLARATION_START")[0],i=this.tokens(t,"JSON_OBJECT_LITERAL")[0],r=/^json[\t ]+(\w+)/.exec(s.image),a=r[1],o=r[0].length-a.length,c={span:[s.startOffset+o,s.startOffset+o+a.length],line:s.startLine??1,column:(s.startColumn??1)+o},h=Pr(i.image,i.startLine??1,i.startColumn??1),l=this.nodes(t,"classSuffix")[0],d=l?this.visit(l):{classes:[],spans:[]},f={id:a,value:h.value,propertyOrder:h.propertyOrder,location:c,classes:d.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:a,span:c.span,idSpan:c.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(t){let s=this.allTokens(t).find((i)=>["TD","TB","BT","RL","LR"].includes(i.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(t){let s=this.tokens(t,"IDENTIFIER"),i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addClassDef(s.map((r)=>r.image),i),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(t){let s=this.tokens(t,"IDENTIFIER"),i=1;for(;i<s.length;i++)if(!this.source.slice((s[i-1].endOffset??s[i-1].startOffset)+1,s[i].startOffset).includes(","))break;let r=s.slice(0,i).map((o)=>({id:o.image,location:this.tokenLocation(o)})),a=s.slice(i).map((o)=>o.image);return this.builder.addClassAssignment(r,a),{kind:"classAssign",span:[0,0],ref:a[0],refSpan:this.tokenSpan(s[i]),nodes:r.map(({id:o,location:c})=>({id:o,span:c.span,idSpan:c.span}))}}styleStatement(t){let s=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),i),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(t){return this.nodes(t,"styleValue").map((s)=>this.visit(s))}styleValue(t){let s=this.allTokens(t),i=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(i[0],i[1]).replaceAll("\\,",",")}styleComponent(t){return this.allTokens(t).map((s)=>s.image).join("")}forwardSolidOperator(t){let s=this.tokens(t,"FORWARD_SOLID")[0];return{type:"association",arrowType:H.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(t){let s=this.tokens(t,"BACKWARD_SOLID")[0],i=this.nodes(t,"edgeLabel")[0],r=i?this.tokens(t,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:H.BACK_ARROW,minlen:this.solidMinlen(r),...i?{label:this.visit(i)}:{}}}markerlessSolidOperator(t){let s=this.nodes(t,"edgeLabel")[0],i=this.allTokens(t);if(!s)return{type:"association",arrowType:H.LINE_SOLID,minlen:this.solidMinlen(this.tokens(t,"MARKERLESS_SOLID")[0])};let r=i.at(-1),a=r.tokenType.name==="FORWARD_SOLID"?H.SOLID_ARROW:r.tokenType.name==="FORWARD_CIRCLE"?H.CIRCLE_ARROW:r.tokenType.name==="FORWARD_CROSS"?H.CROSS_ARROW:H.LINE_SOLID;return{type:"association",arrowType:a,label:this.visit(s),minlen:a===H.SOLID_ARROW||a===H.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(t){return{type:"association",arrowType:H.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(t){let s=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:H.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(t){return{type:"association",arrowType:H.CROSS_ARROW,minlen:1}}backwardCrossOperator(t){let s=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:H.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}actorDraft(t){return{id:t.id,kind:"actor",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}entityDraft(t){return{id:t.id,kind:"usecase",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.shape?{shape:t.shape}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}endpoint(t,s=t.explicitDeclaration??!0){return{id:t.id,label:t.label,location:t.location,generated:t.generated,declaration:s,classesOnReference:t.classes.length>0}}relationshipDraft(t,s,i){return{source:this.endpoint(t,!0),target:this.endpoint(s.target),location:i,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(t,s,i){return{id:s.id,span:this.nodeSpan(t),idSpan:s.location.span,labelSpan:s.label.span,...i?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:r,span:a,keySpan:o,valueSpan:c})=>({key:r,span:a,keySpan:o,valueSpan:c}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(t,s,i){return this.actorOccurrence(t,s,i)}wrap(t,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(t);for(let i of s.edges??[])i.span=s.span;return s}tokenLabel(t){let s=t.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",i=s==="markdown"?2:t.tokenType.name==="PLAIN_STRING"?1:0,r=this.tokenSpan(t,i);return{text:this.source.slice(r[0],r[1]),type:s,span:r}}decodePlain(t){return t.tokenType.name==="PLAIN_STRING"?t.image.slice(1,-1):t.image}contentSpan(t){return this.tokenSpan(t,t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(t){return t.replace(/\W/g,"_")}solidMinlen(t){return Math.max(1,(t.image.match(/-/g)?.length??2)-1)}nodeLocation(t){let s=this.allTokens(t.children)[0];return{span:this.nodeSpan(t),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(t){let s=this.allTokens(t).filter((a)=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),i=s[0],r=s.at(-1);return{span:[i.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:i.startLine??1,column:i.startColumn??1}}tokenLocation(t){let s=t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(t,s),line:t.startLine??1,column:(t.startColumn??1)+s}}nodeSpan(t){let s=this.allTokens(t.children).filter((a)=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),i=s[0],r=s.at(-1);if(!i||!r)throw Error("Usecase CST node has no source token");return[i.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(t,s=0){return[t.startOffset+s,Math.min(this.source.length,(t.endOffset??t.startOffset+t.image.length-1)+1-s)]}nodes(t,s){return(t[s]??[]).filter((i)=>("children"in i))}tokens(t,s){return(t[s]??[]).filter((i)=>("tokenTypeIdx"in i))}firstNode(t,...s){for(let i of s){let r=this.nodes(t,i)[0];if(r)return r}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(t){let s=[];for(let i of Object.values(t))for(let r of i)if("tokenTypeIdx"in r)s.push(r);else s.push(...this.allTokens(r.children));return s.sort((i,r)=>i.startOffset-r.startOffset)}},Vo=new Ko,zo={parse:e(async(t)=>{Ns.clear(),Gt.input=[];try{Hi({diagramType:"usecase",lexer:xo,parser:Gt,entry:e(()=>Gt.start(),"entry"),visit:e((s)=>Vo.build(s,t),"visit")},t)}catch(s){Ns.clear();let i=Gt.errors[0];if(i){let{token:r}=i,a=ut(r.startOffset)?r.startOffset:t.length,o=ut(r.endOffset)?r.endOffset+1:a,c=ut(r.startLine)?r.startLine:t.slice(0,a).split(/\r\n|\r|\n/).length,h=Math.max(t.lastIndexOf(`
117
+ `,a-1),t.lastIndexOf("\r",a-1)),l=ut(r.startColumn)?r.startColumn:a-h,d=s instanceof Error?s.message:String(s);throw Error(`${d} at line ${c}, column ${l} [${a},${o})`)}throw s}},"parse")},Ho=["point","circle","cross","extension"],Dr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Ki=e((t,s)=>{let[i,r]=[t,s].map((a)=>a.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${i}-${r}`},"usecaseDomId"),Xo=e((t)=>`usecase-${t.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=e((t,s)=>{if(s!=="markdown")return t;return _o(t).map((i)=>i.map((r)=>r.content).join(" ")).join(`
118
+ `)},"getAccessibleLabel"),Yo=e((t)=>{let s=Is(t.label??t.id,t.labelType);if(Dr[t.shape]){let r=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",a=t.business?"business ":"",o=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${a}${r}actor ${s}${o}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${s}`;if(t.shape==="usecaseJsonTable"){let r=(t.jsonRows??[]).map((a)=>`${a.accessibleKey}: ${a.value}`).join("; ");return r?`${s}: ${r}`:s}let i=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${s}${i}`},"getUsecaseNodeAccessibleName"),qo=e((t)=>`${t.boundaryType} system boundary ${Is(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=e((t)=>{if(t.relationshipType==="note")return"";return`${t.relationshipType==="association"&&t.label?`association ${Is(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=e((t)=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Vi=e((t)=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=e((t,s)=>{t.diagramId=s,t.markers=[...Ho];for(let i of t.nodes){let r=i;if(r.domId=Xo(i.id),i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);if(i.stereotype)i.stereotype=ht(i.stereotype);if(!i.isGroup&&i.shape==="usecaseJsonTable")i.jsonRows=i.jsonRows?.map((a)=>({...a,key:ht(a.key),value:ht(a.value)}));if(!i.isGroup&&(i.shape==="usecaseEllipse"||i.shape==="rect")&&i.stereotype){let a=i.label??ht(i.id);i.label=`«${Vi(i.stereotype)}»<br/>${i.labelType==="text"?Vi(a):a}`,i.labelType="markdown",r.hasFoldedStereotype=!0,delete i.stereotype}}for(let i of t.edges)if(i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);return t},"prepareUsecaseLayoutData"),Qo=e((t,s,i)=>{for(let a of s.nodes){let o=typeof a.domId==="string"?a.domId:Ki(s.diagramId,a.id),c=t.select(`#${o}`),h=a.isGroup?"boundary":Dr[a.shape]?"actor":a.shape==="note"?"note":a.shape==="usecaseJsonTable"?"json":"usecase",l=i.nodes.get(a.id)??a.id;if(c.attr("data-usecase-id",a.id).attr("data-usecase-kind",h).attr("role","img").attr("aria-label",l),!a.isGroup&&(a.shape==="usecaseEllipse"||a.shape==="rect")&&"hasFoldedStereotype"in a&&a.hasFoldedStereotype===!0){let d=c.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,T=m?.firstChild;if(m&&T?.nodeType===3){let g=m.ownerDocument.createElement("span");g.className="usecase-stereotype",m.insertBefore(g,T),g.appendChild(T)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let r=new Map(s.edges.map((a)=>[a.id,a]));t.selectAll('path[data-et="edge"]').each(function(){let a=r.get(this.getAttribute("data-id")??"");if(!a)return;let o=p(this);if(o.attr("id",Ki(s.diagramId,a.id)).attr("data-usecase-id",a.id).attr("data-usecase-kind",a.internal?"note-connector":"relationship"),a.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",i.edges.get(a.id)??a.id)})},"annotateUsecaseElements"),zi=e((t,s)=>{t.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=e(async(t,s,i,r)=>{n.info("Drawing usecase diagram (unified)",s);let{layout:a}=u(),o=r.db,c=o.getData(),h=new Map(c.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),l={nodes:new Map(c.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:h.get(m.noteTarget??"")}:m)])),edges:new Map(c.edges.map((m)=>[m.id,Jo({...m,sourceLabel:h.get(m.source)??m.sourceLabel,targetLabel:h.get(m.target)??m.targetLabel})]))},d=Ce(s,c.config.securityLevel);c.layoutAlgorithm=Ee(a),Zo(c,s),zi(d,c),await Se(c,d),Qo(d,c,l);let f=c.diagramPadding;F.insertTitle(d,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),pe(d,f,"usecaseDiagram",c.useMaxWidth),zi(d,c)},"draw"),tl={draw:el},sl=e((t)=>({actorBkg:t.usecaseActorBkg??t.actorBkg??t.mainBkg,actorBorder:t.usecaseActorBorder??t.actorBorder??t.primaryColor,bkg:t.usecaseBkg??t.mainBkg,border:t.usecaseBorder??t.nodeBorder??t.primaryColor,boundaryBkg:t.usecaseBoundaryBkg??t.clusterBkg,boundaryBorder:t.usecaseBoundaryBorder??t.clusterBorder,includeLine:t.usecaseIncludeLine??t.lineColor,extendLine:t.usecaseExtendLine??t.lineColor}),"roleColors"),nl=e((t)=>{let{theme:s,bkgColorArray:i,borderColorArray:r}=t;if(!de(s,r))return"";let a=k().usecase?.colorScheme==="rotate",o=fe(t.look),c=o==="handDrawn",h=ge(i),l="";for(let d=0;d<Tt(r);d++){let f=r[d],m=h?`fill: ${i[d%i.length]};`:"",T=`[data-look="${o}"][data-color-id="color-${d}"]`;if(l+=`
119
119
 
120
120
  & ${T}.system-boundary rect.boundary-body,
121
121
  & ${T}.system-boundary rect.boundary-tab,
122
122
  & ${T}.system-boundary .boundary-body path,
123
123
  & ${T}.system-boundary .boundary-tab path {
124
- stroke: ${p};
125
- ${f}
124
+ stroke: ${f};
125
+ ${m}
126
126
  }
127
127
  `,!a)continue;l+=`
128
128
 
@@ -137,15 +137,15 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
137
137
  theme's uniform colours, exactly as handDrawn flowchart nodes do. */
138
138
  & ${T}.usecase-element ellipse,
139
139
  & ${T}.usecase-element rect {
140
- stroke: ${p};
141
- ${f}
140
+ stroke: ${f};
141
+ ${m}
142
142
  }
143
143
 
144
144
  /* The business marker is a single classed path, so it can be reached safely by name --
145
145
  without it the marker keeps the uniform border beside a palette-coloured body. No
146
146
  \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
147
147
  & ${T}.usecase-element .usecase-business-marker {
148
- stroke: ${p};
148
+ stroke: ${f};
149
149
  }
150
150
 
151
151
  /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
@@ -156,8 +156,8 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
156
156
  & ${T}.usecase-actor .usecase-actor-hollow,
157
157
  & ${T}.usecase-actor .usecase-actor-awesome,
158
158
  & ${T}.usecase-actor .usecase-actor-icon {
159
- stroke: ${p};
160
- ${f}
159
+ stroke: ${f};
160
+ ${m}
161
161
  }
162
162
  ${c?"":`
163
163
  /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
@@ -171,10 +171,10 @@ ${c?"":`
171
171
  \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
172
172
  & ${T}.usecase-actor .usecase-actor-glyph path,
173
173
  & ${T}.usecase-actor .usecase-actor-glyph circle {
174
- stroke: ${p};
174
+ stroke: ${f};
175
175
  }
176
176
  `}
177
- `}return l},"genColor");var il=e((t)=>{let s=sl(t),i=pe(t.look)==="handDrawn";return`
177
+ `}return l},"genColor");var il=e((t)=>{let s=sl(t),i=fe(t.look)==="handDrawn";return`
178
178
  ${nl(t)}
179
179
  & .usecase-actor {
180
180
  color: ${t.actorTextColor??t.primaryTextColor};
@@ -235,15 +235,15 @@ ${i?"":`
235
235
  tie with it -- on a tie the later stylesheet would win, which is how neo took this in
236
236
  the first place. Skipped under handDrawn, where roughjs draws paths and neither element
237
237
  exists. */
238
- & [data-look="${pe(t.look)}"].node.usecase-element ellipse,
239
- & [data-look="${pe(t.look)}"].node.usecase-element rect {
238
+ & [data-look="${fe(t.look)}"].node.usecase-element ellipse,
239
+ & [data-look="${fe(t.look)}"].node.usecase-element rect {
240
240
  fill: ${s.bkg};
241
241
  stroke: ${s.border};
242
242
  }
243
243
 
244
244
  /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
245
245
  way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
246
- & [data-look="${pe(t.look)}"].node.usecase-element .usecase-business-marker {
246
+ & [data-look="${fe(t.look)}"].node.usecase-element .usecase-business-marker {
247
247
  stroke: ${s.border};
248
248
  }
249
249
  `}