filecat 7.7.4 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/build/dist/1045.0e4bdc838c37771a7f50.js +1 -0
  2. package/build/dist/1075.40103ec059c6b23b056e.js +1 -0
  3. package/build/dist/1128.b80776fbdbdda36034c3.js +1 -0
  4. package/build/dist/1388.1dcf844b452e3aae3dc0.js +1 -0
  5. package/build/dist/1417.7e511043474084a2a65b.js +1 -0
  6. package/build/dist/1671.fb137d27b5763953487e.js +1 -0
  7. package/build/dist/{6887.93191dae462af3692775.js → 1738.b8ab2bd79df131e60051.js} +1 -1
  8. package/build/dist/1802.e43e833638f6ba8e22d7.js +1 -0
  9. package/build/dist/1964.bd3d684b50aa5191b413.js +1 -0
  10. package/build/dist/200.bb7f6ce5543bd7ff6d97.js +1 -0
  11. package/build/dist/2105.e4ba1c1d506b3fe14e8e.js +1 -0
  12. package/build/dist/2122.bc10dcdbbfc38e0ef883.js +1 -0
  13. package/build/dist/{3457.18b45379d8bcf7f5f3b5.js → 2180.df641ebaead77c4ada71.js} +1 -1
  14. package/build/dist/2300.9e1baa1c0368abe53d96.js +2 -0
  15. package/build/dist/2479.dcc88b3370f0f1d66e02.js +1 -0
  16. package/build/dist/2572.8fdddfebb4da2f29dbd8.js +1 -0
  17. package/build/dist/2674.7fd28dae86ccdb247851.js +1 -0
  18. package/build/dist/{1001.44a1a25c7d6d3f294bf3.js → 2822.9417e764a14f8f5f57dc.js} +1 -1
  19. package/build/dist/2994.c492be0d907fa468a9be.js +1 -0
  20. package/build/dist/{3140.b078ec311f99170b7f4c.js → 3140.794a212da633caf38b3a.js} +2 -2
  21. package/build/dist/3230.7798ab546facfa058b34.js +1 -0
  22. package/build/dist/3283.9386fc7f67aef46604fb.js +1 -0
  23. package/build/dist/{3299.9bd4cf5d1679479639a8.js → 3299.f37767d30b6999df4014.js} +1 -1
  24. package/build/dist/3300.b8a3bc571293a6280ed8.js +1 -0
  25. package/build/dist/{3402.d412940350051a52d7ac.js → 3402.b6dc28d2f9bace7cde85.js} +1 -1
  26. package/build/dist/3509.cbcb309fbf49db53229f.js +1 -0
  27. package/build/dist/{3727.b8d9cbae9de47bf8d49b.js → 3510.b975b8bfdee5e8518215.js} +1 -1
  28. package/build/dist/{587.c75ed69a8373139346f9.js → 3566.ba323afadcf41fad2fa7.js} +1 -1
  29. package/build/dist/3608.aff9429024b740ac5cd0.js +1 -0
  30. package/build/dist/3990.5e16453f57b90b01d539.js +1 -0
  31. package/build/dist/4004.5d68418ad5c2321cb11f.js +1 -0
  32. package/build/dist/4061.c0eb5824eeb6a59fa827.js +1 -0
  33. package/build/dist/4220.b65b40382726a69ba0bc.js +1 -0
  34. package/build/dist/{3883.70d42c3a335d6833f07e.js → 4376.b022a792fb34fbe50398.js} +1 -1
  35. package/build/dist/4469.536491f90535e831ce3e.js +1 -0
  36. package/build/dist/453.8877eb10f13258c290bc.js +1 -0
  37. package/build/dist/4560.8ef2e4b60cc86d019dd6.js +1 -0
  38. package/build/dist/4735.838cd0f656bbf7d99ff6.js +1 -0
  39. package/build/dist/4772.9b95c402a4def0f576e3.js +1 -0
  40. package/build/dist/{4903.407cafe944a297471f5a.js → 4903.b5451ed0802b3f7c07b2.js} +1 -1
  41. package/build/dist/4985.44cb7d829ca477e368b8.js +1 -0
  42. package/build/dist/5516.645e4a900df9bdc1806c.js +1 -0
  43. package/build/dist/5526.6b4867751becda056ed8.js +1 -0
  44. package/build/dist/5617.8efc3b1d218f80df9b39.js +1 -0
  45. package/build/dist/5744.e9f1efb88a617b05b709.js +1 -0
  46. package/build/dist/583.cef46d6b21c6fa6454cf.js +1 -0
  47. package/build/dist/6010.5400c344149450c83284.js +1 -0
  48. package/build/dist/6089.6d5d19a327284ff3b11c.js +1 -0
  49. package/build/dist/6164.7dae9989dd129479f952.js +1 -0
  50. package/build/dist/6284.10deb80685728f50aa45.js +1 -0
  51. package/build/dist/629.b75b024aacc43e0d69cf.js +1 -0
  52. package/build/dist/6344.291e5dadc74e62739774.js +1 -0
  53. package/build/dist/6492.3ee4060598de873d8e8f.js +1 -0
  54. package/build/dist/6571.b381c44055704e3ba649.js +1 -0
  55. package/build/dist/6731.6763296ce5ae210bc0fe.js +1 -0
  56. package/build/dist/6759.f88b50c41207cb8345d1.js +1 -0
  57. package/build/dist/{4951.88718d978aea2dd40006.js → 6789.34921a30c8a81f0a6407.js} +1 -1
  58. package/build/dist/6800.ee99fd0a88b6acbaaf2c.js +1 -0
  59. package/build/dist/6803.fe4297b1e51c3bfc7f50.js +1 -0
  60. package/build/dist/{313.d51fc773856f078487ad.js → 6806.9ebf089eba60f3b8e946.js} +1 -1
  61. package/build/dist/7038.4e4fc8e405c56d3080e2.js +1 -0
  62. package/build/dist/7310.bf944d03f24fcf109680.js +1 -0
  63. package/build/dist/{359.1b95bd6368196ccaa731.js → 7430.25bf8437ad8f7c1fd36f.js} +1 -1
  64. package/build/dist/7483.5e26ada69b33418c31a8.js +1 -0
  65. package/build/dist/{4087.4796ff56340985c35542.js → 7486.fe0b5f867c08b40a3360.js} +1 -1
  66. package/build/dist/7567.09e1b34ad9bd3e463eb4.js +1 -0
  67. package/build/dist/7834.7a593dcb80ca09f58586.js +1 -0
  68. package/build/dist/784.48a3b71205680f427109.js +1 -0
  69. package/build/dist/7943.19d2de387eeb7f513d8e.js +1 -0
  70. package/build/dist/8014.28b5cf8c3787dc829aa4.js +1 -0
  71. package/build/dist/8079.f6f2be43e5d933ae1f6f.js +1 -0
  72. package/build/dist/{8302.c1c381630b4ec76bf8ab.js → 8302.5ae5bfe8baa0084204bb.js} +1 -1
  73. package/build/dist/8677.860320b7f36947e57d11.js +1 -0
  74. package/build/dist/8727.3628c746061aed7a4077.js +1 -0
  75. package/build/dist/8781.58f0c51870d3dd2689d7.js +1 -0
  76. package/build/dist/9299.6c06dad1abe098b61766.js +1 -0
  77. package/build/dist/9324.ef229da9b943484298ba.js +1 -0
  78. package/build/dist/9364.d2570d78afc50fe1b23e.js +1 -0
  79. package/build/dist/9463.2629a7daf4c2865b9b96.js +1 -0
  80. package/build/dist/index.html +1 -1
  81. package/build/dist/main.3a12152528aff6ae213a.js +2 -0
  82. package/build/main.js +1 -1
  83. package/package.json +4 -5
  84. package/build/dist/1075.3ef2e1902e9f7e9e37b1.js +0 -1
  85. package/build/dist/1312.199a506fb836a2412255.js +0 -1
  86. package/build/dist/136.e3bb3c50051edb17454d.js +0 -1
  87. package/build/dist/1478.c58a43bb24820a13eaed.js +0 -1
  88. package/build/dist/1491.901cce0168c42ad319fa.js +0 -1
  89. package/build/dist/1566.4f405afd26063b55129c.js +0 -1
  90. package/build/dist/161.98f6c2a50bf3824a6efb.js +0 -1
  91. package/build/dist/1654.a21a099e2749ef167ea9.js +0 -1
  92. package/build/dist/1875.46dd3a6cc071d45a32f1.js +0 -1
  93. package/build/dist/1883.14c90bbe93fe206906f0.js +0 -1
  94. package/build/dist/1924.c7bd2a2aa0e9bc78c9ba.js +0 -1
  95. package/build/dist/2000.f55ddba9e6313243f028.js +0 -1
  96. package/build/dist/2101.d4efa6a2c1e9169d9225.js +0 -1
  97. package/build/dist/2180.60fe32ab12c2fa1570a4.js +0 -1
  98. package/build/dist/2191.4c4f2fd5127168a81877.js +0 -1
  99. package/build/dist/2213.ceffb8fd7be66b35d079.js +0 -1
  100. package/build/dist/2463.6e530d1e9b5c58dba166.js +0 -1
  101. package/build/dist/2623.8b1e5e391dd4e05fc119.js +0 -1
  102. package/build/dist/2674.3713c09449bdd57b1066.js +0 -1
  103. package/build/dist/2894.8395ec5e280cc6b6c4dc.js +0 -1
  104. package/build/dist/3042.f490cfa4208208262398.js +0 -1
  105. package/build/dist/3096.d0b2c77a23418c545c01.js +0 -1
  106. package/build/dist/311.da79ace98b69a635c41c.js +0 -1
  107. package/build/dist/3166.088cf4a0356c3a6e30a0.js +0 -1
  108. package/build/dist/3357.4f1bf81ecc3c11a3f813.js +0 -1
  109. package/build/dist/3475.d10d21b637761d7d886d.js +0 -1
  110. package/build/dist/3708.04401b24d95214d641e5.js +0 -1
  111. package/build/dist/3752.01fc1f14b29f340e41fd.js +0 -1
  112. package/build/dist/3871.7a387a9dc21883d08423.js +0 -1
  113. package/build/dist/3994.19fb81947d65fc81b0a2.js +0 -1
  114. package/build/dist/4012.b516fdc981e55be2ebb2.js +0 -1
  115. package/build/dist/4122.9ea6b5dd8dc9d2265825.js +0 -1
  116. package/build/dist/4141.06960673a6a484e7b88d.js +0 -1
  117. package/build/dist/4190.ff72264b4f07f6542d33.js +0 -1
  118. package/build/dist/4239.1b49d7c26192fb637d57.js +0 -1
  119. package/build/dist/4288.8dc8f5d962720e084952.js +0 -1
  120. package/build/dist/434.04cdc2a05316f92d1d38.js +0 -1
  121. package/build/dist/4376.f3c60897f70dd4e33d2f.js +0 -1
  122. package/build/dist/4472.9e708dd3e1c9db7d7396.js +0 -1
  123. package/build/dist/4473.b42b37616f13be64199b.js +0 -1
  124. package/build/dist/449.3fd75e05da22fe1c5ecc.js +0 -1
  125. package/build/dist/452.4974390f4f4d991216e5.js +0 -1
  126. package/build/dist/4547.36b5848220c04c47bc80.js +0 -1
  127. package/build/dist/4605.ef0f4204b3bf3a18efa6.js +0 -1
  128. package/build/dist/4804.fbd0ffcf57d9dffc15b7.js +0 -1
  129. package/build/dist/482.0c7512372a1fbf61d704.js +0 -1
  130. package/build/dist/4963.22d7db9b376a42d3f00b.js +0 -1
  131. package/build/dist/5097.a0de16bf7b90a8b1157d.js +0 -1
  132. package/build/dist/5123.d9ed79af478b5cc4f1b2.js +0 -1
  133. package/build/dist/5332.8b6e85d8764e907a01d5.js +0 -1
  134. package/build/dist/536.660d866952b46ba53180.js +0 -1
  135. package/build/dist/548.d3d912d0c0c7e835e1dc.js +0 -1
  136. package/build/dist/5516.cc92dfbf06ddcd133dbc.js +0 -1
  137. package/build/dist/5590.585778da623ec71f7722.js +0 -1
  138. package/build/dist/5616.14df0fe505c4dadf4042.js +0 -1
  139. package/build/dist/5695.95dc69f3b02812eb9e93.js +0 -1
  140. package/build/dist/5697.6ac62f99ca19a979f1eb.js +0 -1
  141. package/build/dist/5741.237d817efc942de875e5.js +0 -1
  142. package/build/dist/5849.d26365d4b19533db6fd6.js +0 -1
  143. package/build/dist/5902.3969a79465383ff4bbb4.js +0 -1
  144. package/build/dist/5942.981e03467a3b2c653ab8.js +0 -1
  145. package/build/dist/6010.2da6f8c2fce5292557cb.js +0 -1
  146. package/build/dist/6029.63e4beb66df7afc65a90.js +0 -1
  147. package/build/dist/6054.f91307b52046172fc5f8.js +0 -1
  148. package/build/dist/6089.0863a6a09be2b97e84e1.js +0 -1
  149. package/build/dist/6095.d845e356a4db8a241cdb.js +0 -1
  150. package/build/dist/6114.ca67e88c701691b3bb1e.js +0 -1
  151. package/build/dist/612.74d77e32957a5c6eb197.js +0 -1
  152. package/build/dist/625.d9e531476b3306e0b837.js +0 -1
  153. package/build/dist/6318.66541f9cef18d14ea3ea.js +0 -1
  154. package/build/dist/6455.5c950f6eb61015409eb6.js +0 -1
  155. package/build/dist/6527.436d2d5d81376e6a54ae.js +0 -1
  156. package/build/dist/6530.2f1b283a902603262048.js +0 -1
  157. package/build/dist/6610.b92f337fcc1b347350fb.js +0 -1
  158. package/build/dist/6926.2786af754adcdabfbede.js +0 -1
  159. package/build/dist/697.62f8b1ec6d2cd40ed316.js +0 -1
  160. package/build/dist/70.be2f9130c93c4175d12f.js +0 -1
  161. package/build/dist/7081.9e1e196fecfcccb4bfb9.js +0 -1
  162. package/build/dist/7128.3573ab2a5f28b79ba89e.js +0 -1
  163. package/build/dist/7163.ad09accaa87e565b8dc0.js +0 -1
  164. package/build/dist/72.a1d87dabb7f0615b3a21.js +0 -1
  165. package/build/dist/7229.50a1700104d1e4732735.js +0 -1
  166. package/build/dist/7332.d024ae75a3da2f7674a1.js +0 -1
  167. package/build/dist/7509.370c49d7ff43e289190c.js +0 -1
  168. package/build/dist/7514.dbf525bade6ffbd70af6.js +0 -2
  169. package/build/dist/7557.7d62939c56391a647067.js +0 -1
  170. package/build/dist/7588.2d840229f62de92b22e5.js +0 -1
  171. package/build/dist/7632.5660653552f755580adc.js +0 -1
  172. package/build/dist/7639.b3c6382de2fde652a40b.js +0 -1
  173. package/build/dist/779.91614fabf5c9eb3aafa0.js +0 -1
  174. package/build/dist/7810.979796e8a3aad6d4d72f.js +0 -1
  175. package/build/dist/7897.8b8070d6abe5c2327168.js +0 -1
  176. package/build/dist/7941.dbef0b0f412899800b13.js +0 -1
  177. package/build/dist/7953.5cd280effe2e967ea490.js +0 -1
  178. package/build/dist/7954.efecc100b407af204add.js +0 -1
  179. package/build/dist/7959.e31a21f28ff463d9d5e9.js +0 -1
  180. package/build/dist/8034.301f1099c4a7ce6c2829.js +0 -1
  181. package/build/dist/8080.e1c9af30bdd818b08c6e.js +0 -1
  182. package/build/dist/8087.6452b67614a0855535a4.js +0 -1
  183. package/build/dist/8140.bbccc589b007f9d410d1.js +0 -1
  184. package/build/dist/8162.e47cccbe327b26a2ea6f.js +0 -1
  185. package/build/dist/8322.56c8f4b4ad93b1a866c8.js +0 -1
  186. package/build/dist/8376.01a9f23ba06a78922364.js +0 -1
  187. package/build/dist/8433.e54d57e2cc9408e5e411.js +0 -1
  188. package/build/dist/8460.25f0859cb2266f764113.js +0 -1
  189. package/build/dist/8524.7945bff0063dc5c5903d.js +0 -1
  190. package/build/dist/8782.a5498372f1eb6bab41b7.js +0 -1
  191. package/build/dist/8953.23fe6fe13b28168428d3.js +0 -1
  192. package/build/dist/8964.bdf168262ab40956654a.js +0 -1
  193. package/build/dist/9003.69a0d15e722e1ed455b0.js +0 -1
  194. package/build/dist/9299.c2699815e5339e4045f8.js +0 -1
  195. package/build/dist/9385.2b1afe7b55d4c16f97ad.js +0 -1
  196. package/build/dist/9428.3176bab8f5780f060d51.js +0 -1
  197. package/build/dist/9456.506d55e351dec4f45566.js +0 -1
  198. package/build/dist/9465.8ff5871fb708cf7c1021.js +0 -1
  199. package/build/dist/9500.95d19d78b580734ec35e.js +0 -1
  200. package/build/dist/9512.03215278f26dc63c056d.js +0 -1
  201. package/build/dist/9614.cfdbe03d8e2960b0a53a.js +0 -1
  202. package/build/dist/9651.6bf3e34362f10c1aa35d.js +0 -1
  203. package/build/dist/9788.4a1c2f3626e532d3b44c.js +0 -1
  204. package/build/dist/9943.b62436bd9d0730c715a9.js +0 -1
  205. package/build/dist/9967.216bc8d26440bcbaf785.js +0 -1
  206. package/build/dist/9970.aa60aa700a790ba226f0.js +0 -1
  207. package/build/dist/main.7a6fed9f5f814a194409.js +0 -2
  208. /package/build/dist/{7514.dbf525bade6ffbd70af6.js.LICENSE.txt → 2300.9e1baa1c0368abe53d96.js.LICENSE.txt} +0 -0
  209. /package/build/dist/{3140.b078ec311f99170b7f4c.js.LICENSE.txt → 3140.794a212da633caf38b3a.js.LICENSE.txt} +0 -0
  210. /package/build/dist/{main.7a6fed9f5f814a194409.js.LICENSE.txt → main.3a12152528aff6ae213a.js.LICENSE.txt} +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5695],{92892(e,t,s){s.d(t,{P:()=>r});var n=s(89983),i=s(31293),a=s(86827),r=(0,a.K)((e,t,s,a)=>{e.attr("class",s);const{width:r,height:l,x:h,y:d}=o(e,t);(0,n.a$)(e,l,r,a);const u=c(h,d,r,l,t);e.attr("viewBox",u),i.R.debug(`viewBox configured: ${u} with padding: ${t}`)},"setupViewPortForSVG"),o=(0,a.K)((e,t)=>{const s=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:s.width+2*t,height:s.height+2*t,x:s.x,y:s.y}},"calculateDimensionsWithPadding"),c=(0,a.K)((e,t,s,n,i)=>`${e-i} ${t-i} ${s} ${n}`,"createViewBox")},96755(e,t,s){s.d(t,{A:()=>a});var n=s(86827),i=s(51444),a=(0,n.K)((e,t)=>{let s;"sandbox"===t&&(s=(0,i.Ltv)("#i"+e));return("sandbox"===t?(0,i.Ltv)(s.nodes()[0].contentDocument.body):(0,i.Ltv)("body")).select(`[id="${e}"]`)},"getDiagramElement")},45695(e,t,s){s.d(t,{diagram:()=>Ua});var n=s(96755),i=s(92892),a=s(56714),r=(s(43247),s(99257),s(24832),s(36870),s(84076),s(36155),s(57588)),o=(s(54912),s(92941)),c=s(51255),l=s(89983),h=s(31293),d=s(86827);function u(e){function t(){}t.prototype=e;const s=new t;function n(){return typeof s.bar}return n(),n(),e}class p{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}}class f extends p{constructor(e){super([]),this.idx=1,Object.assign(this,k(e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class m extends p{constructor(e){super(e.definition),this.orgText="",Object.assign(this,k(e))}}class T extends p{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,k(e))}}class E extends p{constructor(e){super(e.definition),this.idx=1,Object.assign(this,k(e))}}class g extends p{constructor(e){super(e.definition),this.idx=1,Object.assign(this,k(e))}}class y extends p{constructor(e){super(e.definition),this.idx=1,Object.assign(this,k(e))}}class A extends p{constructor(e){super(e.definition),this.idx=1,Object.assign(this,k(e))}}class S extends p{constructor(e){super(e.definition),this.idx=1,Object.assign(this,k(e))}}class L extends p{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,k(e))}}class O{constructor(e){this.idx=1,Object.assign(this,k(e))}accept(e){e.visit(this)}}function R(e){function t(e){return e.map(R)}if(e instanceof f){const t={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};return"string"==typeof e.label&&(t.label=e.label),t}if(e instanceof T)return{type:"Alternative",definition:t(e.definition)};if(e instanceof E)return{type:"Option",idx:e.idx,definition:t(e.definition)};if(e instanceof g)return{type:"RepetitionMandatory",idx:e.idx,definition:t(e.definition)};if(e instanceof y)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:R(new O({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof S)return{type:"RepetitionWithSeparator",idx:e.idx,separator:R(new O({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof A)return{type:"Repetition",idx:e.idx,definition:t(e.definition)};if(e instanceof L)return{type:"Alternation",idx:e.idx,definition:t(e.definition)};if(e instanceof O){const t={type:"Terminal",name:e.terminalType.name,label:(s=e.terminalType,"string"==typeof(n=s).LABEL&&""!==n.LABEL?s.LABEL:s.name),idx:e.idx};"string"==typeof e.label&&(t.terminalLabel=e.label);const i=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=i instanceof RegExp?i.source:i),t}if(e instanceof m)return{type:"Rule",name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error("non exhaustive match");var s,n}function k(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}class N{visit(e){const t=e;switch(t.constructor){case f:return this.visitNonTerminal(t);case T:return this.visitAlternative(t);case E:return this.visitOption(t);case g:return this.visitRepetitionMandatory(t);case y:return this.visitRepetitionMandatoryWithSeparator(t);case S:return this.visitRepetitionWithSeparator(t);case A:return this.visitRepetition(t);case L:return this.visitAlternation(t);case O:return this.visitTerminal(t);case m:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function I(e,t=[]){return!!(e instanceof E||e instanceof A||e instanceof S)||(e instanceof L?e.definition.some(e=>I(e,t)):!(e instanceof f&&t.includes(e))&&(e instanceof p&&(e instanceof f&&t.push(e),e.definition.every(e=>I(e,t)))))}function b(e){if(e instanceof f)return"SUBRULE";if(e instanceof E)return"OPTION";if(e instanceof L)return"OR";if(e instanceof g)return"AT_LEAST_ONE";if(e instanceof y)return"AT_LEAST_ONE_SEP";if(e instanceof S)return"MANY_SEP";if(e instanceof A)return"MANY";if(e instanceof O)return"CONSUME";throw Error("non exhaustive match")}class C{walk(e,t=[]){e.definition.forEach((s,n)=>{const i=e.definition.slice(n+1);if(s instanceof f)this.walkProdRef(s,i,t);else if(s instanceof O)this.walkTerminal(s,i,t);else if(s instanceof T)this.walkFlat(s,i,t);else if(s instanceof E)this.walkOption(s,i,t);else if(s instanceof g)this.walkAtLeastOne(s,i,t);else if(s instanceof y)this.walkAtLeastOneSep(s,i,t);else if(s instanceof S)this.walkManySep(s,i,t);else if(s instanceof A)this.walkMany(s,i,t);else{if(!(s instanceof L))throw Error("non exhaustive match");this.walkOr(s,i,t)}})}walkTerminal(e,t,s){}walkProdRef(e,t,s){}walkFlat(e,t,s){const n=t.concat(s);this.walk(e,n)}walkOption(e,t,s){const n=t.concat(s);this.walk(e,n)}walkAtLeastOne(e,t,s){const n=[new E({definition:e.definition})].concat(t,s);this.walk(e,n)}walkAtLeastOneSep(e,t,s){const n=v(e,t,s);this.walk(e,n)}walkMany(e,t,s){const n=[new E({definition:e.definition})].concat(t,s);this.walk(e,n)}walkManySep(e,t,s){const n=v(e,t,s);this.walk(e,n)}walkOr(e,t,s){const n=t.concat(s);e.definition.forEach(e=>{const t=new T({definition:[e]});this.walk(t,n)})}}function v(e,t,s){return[new E({definition:[new O({terminalType:e.separator})].concat(e.definition)})].concat(t,s)}function _(e){if(e instanceof f)return _(e.referencedRule);if(e instanceof O)return[e.terminalType];if(function(e){return e instanceof T||e instanceof E||e instanceof A||e instanceof g||e instanceof y||e instanceof S||e instanceof O||e instanceof m}(e))return function(e){let t=[];const s=e.definition;let n,i=0,a=s.length>i,r=!0;for(;a&&r;)n=s[i],r=I(n),t=t.concat(_(n)),i+=1,a=s.length>i;return[...new Set(t)]}(e);if(function(e){return e instanceof L}(e))return function(e){const t=e.definition.map(e=>_(e));return[...new Set(t.flat())]}(e);throw Error("non exhaustive match")}const x="_~IN~_";class w extends C{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,s){}walkProdRef(e,t,s){const n=(i=e.referencedRule,a=e.idx,i.name+a+x+this.topProd.name);var i,a;const r=t.concat(s),o=_(new T({definition:r}));this.follows[n]=o}}function U(e){return e.charCodeAt(0)}function M(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function P(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t];e[t]=!0}function D(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function K(){throw Error("Internal Error - Should never get here!")}function $(e){return"Character"===e.type}const B=[];for(let e=U("0");e<=U("9");e++)B.push(e);const F=[U("_")].concat(B);for(let e=U("a");e<=U("z");e++)F.push(e);for(let e=U("A");e<=U("Z");e++)F.push(e);const j=[U(" "),U("\f"),U("\n"),U("\r"),U("\t"),U("\v"),U("\t"),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U(" "),U("\u2028"),U("\u2029"),U(" "),U(" "),U(" "),U("\ufeff")],G=/[0-9a-fA-F]/,W=/[0-9]/,V=/[1-9]/;class z{visitChildren(e){for(const t in e){const s=e[t];e.hasOwnProperty(t)&&(void 0!==s.type?this.visit(s):Array.isArray(s)&&s.forEach(e=>{this.visit(e)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}function H(e){console&&console.error&&console.error(`Error: ${e}`)}function Y(e){console&&console.warn&&console.warn(`Warning: ${e}`)}let X={};const J=new class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");const t=this.disjunction();this.consumeChar("/");const s={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":P(s,"global");break;case"i":P(s,"ignoreCase");break;case"m":P(s,"multiLine");break;case"u":P(s,"unicode");break;case"y":P(s,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:s,value:t,loc:this.loc(0)}}disjunction(){const e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){const e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}}D(t);const s=this.disjunction();return this.consumeChar(")"),{type:t,value:s,loc:this.loc(e)}}return K()}quantifier(e=!1){let t;const s=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":const s=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:s,atMost:s};break;case",":let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:s,atMost:e}):t={atLeast:s,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;D(t)}if(!0!==e||void 0!==t)return D(t)?("?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(s),t):void 0}atom(){let e;const t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),D(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):K()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[U("\n"),U("\r"),U("\u2028"),U("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=B;break;case"D":e=B,t=!0;break;case"s":e=j;break;case"S":e=j,t=!0;break;case"w":e=F;break;case"W":e=F,t=!0}return D(e)?{type:"Set",value:e,complement:t}:K()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=U("\f");break;case"n":e=U("\n");break;case"r":e=U("\r");break;case"t":e=U("\t");break;case"v":e=U("\v")}return D(e)?{type:"Character",value:e}:K()}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:U("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:U(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:U(this.popChar())}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const t=this.classAtom();t.type;if($(t)&&this.isRangeDash()){this.consumeChar("-");const s=this.classAtom();s.type;if($(s)){if(s.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:s.value})}else M(t.value,e),e.push(U("-")),M(s.value,e)}else M(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:U("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),e=!1;else this.groupIdx++;const t=this.disjunction();this.consumeChar(")");const s={type:"Group",capturing:e,value:t};return e&&(s.idx=this.groupIdx),s}positiveInteger(){let e=this.popChar();if(!1===V.test(e))throw Error("Expecting a positive integer");for(;W.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===W.test(e))throw Error("Expecting an integer");for(;W.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:U(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return"-"===this.peekChar()&&this.isClassAtom(1)}isDigit(){return W.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2)||"<"===this.peekChar(2)&&("="===this.peekChar(3)||"!"===this.peekChar(3)));default:return!1}}isQuantifier(){const e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let s=0;s<e;s++){const e=this.popChar();if(!1===G.test(e))throw Error("Expecting a HexDecimal digits");t+=e}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};function q(e){const t=e.toString();if(X.hasOwnProperty(t))return X[t];{const e=J.pattern(t);return X[t]=e,e}}const Z="Complement Sets are not supported for first char optimization",Q='Unable to use "first char" lexer optimizations:\n';function ee(e,t=!1){try{const t=q(e);return te(t.value,{},t.flags.ignoreCase)}catch(s){if(s.message===Z)t&&Y(`${Q}\tUnable to optimize: < ${e.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let s="";t&&(s="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),H(`${Q}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+s)}}return[]}function te(e,t,s){switch(e.type){case"Disjunction":for(let n=0;n<e.value.length;n++)te(e.value[n],t,s);break;case"Alternative":const n=e.value;for(let e=0;e<n.length;e++){const i=n[e];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const a=i;switch(a.type){case"Character":se(a.value,t,s);break;case"Set":if(!0===a.complement)throw Error(Z);a.value.forEach(e=>{if("number"==typeof e)se(e,t,s);else{const n=e;if(!0===s)for(let e=n.from;e<=n.to;e++)se(e,t,s);else{for(let e=n.from;e<=n.to&&e<Le;e++)se(e,t,s);if(n.to>=Le){const e=n.from>=Le?n.from:Le,s=n.to,i=Re(e),a=Re(s);for(let e=i;e<=a;e++)t[e]=e}}}});break;case"Group":te(a.value,t,s);break;default:throw Error("Non Exhaustive Match")}const r=void 0!==a.quantifier&&0===a.quantifier.atLeast;if("Group"===a.type&&!1===ie(a)||"Group"!==a.type&&!1===r)break}break;default:throw Error("non exhaustive match!")}return Object.values(t)}function se(e,t,s){const n=Re(e);t[n]=n,!0===s&&function(e,t){const s=String.fromCharCode(e),n=s.toUpperCase();if(n!==s){const e=Re(n.charCodeAt(0));t[e]=e}else{const e=s.toLowerCase();if(e!==s){const s=Re(e.charCodeAt(0));t[s]=s}}}(e,t)}function ne(e,t){return e.value.find(e=>{if("number"==typeof e)return t.includes(e);{const s=e;return void 0!==t.find(e=>s.from<=e&&e<=s.to)}})}function ie(e){const t=e.quantifier;return!(!t||0!==t.atLeast)||!!e.value&&(Array.isArray(e.value)?e.value.every(ie):ie(e.value))}class ae extends z{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e);case"Lookbehind":return void this.visitLookbehind(e);case"NegativeLookbehind":return void this.visitNegativeLookbehind(e)}super.visitChildren(e)}}visitCharacter(e){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===ne(e,this.targetCharCodes)&&(this.found=!0):void 0!==ne(e,this.targetCharCodes)&&(this.found=!0)}}function re(e,t){if(t instanceof RegExp){const s=q(t),n=new ae(e);return n.visit(s),n.found}for(const s of t){const t=s.charCodeAt(0);if(e.includes(t))return!0}return!1}const oe="PATTERN",ce="defaultMode",le="modes";function he(e,t){const s=(t=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()},t)).tracer;let n;s("initCharCodeToOptimizedIndexMap",()=>{!function(){if(0===Oe.length){Oe=new Array(65536);for(let e=0;e<65536;e++)Oe[e]=e>255?255+~~(e/255):e}}()}),s("Reject Lexer.NA",()=>{n=e.filter(e=>e[oe]!==Ke.NA)});let i,a,r,o,c,l,h,d,u,p,f,m=!1;s("Transform Patterns",()=>{m=!1,i=n.map(e=>{const t=e[oe];if(t instanceof RegExp){const e=t.source;return 1!==e.length||"^"===e||"$"===e||"."===e||t.ignoreCase?2!==e.length||"\\"!==e[0]||["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(e[1])?fe(t):e[1]:e}if("function"==typeof t)return m=!0,{exec:t};if("object"==typeof t)return m=!0,t;if("string"==typeof t){if(1===t.length)return t;{const e=t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&");return fe(new RegExp(e))}}throw Error("non exhaustive match")})}),s("misc mapping",()=>{a=n.map(e=>e.tokenTypeIdx),r=n.map(e=>{const t=e.GROUP;if(t!==Ke.SKIPPED){if("string"==typeof t)return t;if(void 0===t)return!1;throw Error("non exhaustive match")}}),o=n.map(e=>{const t=e.LONGER_ALT;if(t){return Array.isArray(t)?t.map(e=>n.indexOf(e)):[n.indexOf(t)]}}),c=n.map(e=>e.PUSH_MODE),l=n.map(e=>Object.hasOwn(e,"POP_MODE"))}),s("Line Terminator Handling",()=>{const e=Ae(t.lineTerminatorCharacters);h=n.map(e=>!1),"onlyOffset"!==t.positionTracking&&(h=n.map(t=>Object.hasOwn(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===ye(t,e)&&re(e,t.PATTERN)))}),s("Misc Mapping #2",()=>{d=n.map(Te),u=i.map(Ee),p=n.reduce((e,t)=>{const s=t.GROUP;return"string"==typeof s&&s!==Ke.SKIPPED&&(e[s]=[]),e},{}),f=i.map((e,t)=>{const s=void 0===r[t]&&void 0===o[t]?function(e){var t,s;if(!(e instanceof RegExp)||""!==e.flags)return;let n;try{n=q(e)}catch(e){return}if(1!==n.value.value.length||1!==n.value.value[0].value.length)return;let i,a=n.value.value[0].value[0];for(;"Group"===a.type;){if(a.capturing||void 0!==a.quantifier&&void 0!==i||1!==a.value.value.length||1!==a.value.value[0].value.length)return;i=null!==(t=a.quantifier)&&void 0!==t?t:i,a=a.value.value[0].value[0]}if("Set"!==a.type||a.complement||void 0!==a.quantifier&&void 0!==i)return;if(i=null!==(s=a.quantifier)&&void 0!==s?s:i,1!==(null==i?void 0:i.atLeast)||i.atMost!==1/0||!i.greedy)return;const r=new Uint8Array(128);for(const e of a.value){const t="number"==typeof e?e:e.from,s="number"==typeof e?e:e.to;if(t<0||s>=r.length)return;r.fill(1,t,s+1)}return r}(n[t].PATTERN):void 0;return{pattern:i[t],asciiClass:s,longerAlt:o[t],canLineTerminator:h[t],matchType:void 0!==s?3:!1!==u[t]?0:d[t]?1:2,short:u[t],group:r[t],push:c[t],pop:l[t],tokenTypeIdx:a[t],tokenType:n[t]}})});let T=!0,E=[];return t.safeMode||s("First Char Optimization",()=>{E=n.reduce((e,s,n)=>{if("string"==typeof s.PATTERN){const t=Re(s.PATTERN.charCodeAt(0));Se(e,t,f[n])}else if(Array.isArray(s.START_CHARS_HINT)){let t;s.START_CHARS_HINT.forEach(s=>{const i=Re("string"==typeof s?s.charCodeAt(0):s);t!==i&&(t=i,Se(e,i,f[n]))})}else if(s.PATTERN instanceof RegExp)if(s.PATTERN.unicode)T=!1,t.ensureOptimizations&&H(`${Q}\tUnable to analyze < ${s.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const i=ee(s.PATTERN,t.ensureOptimizations);0===i.length&&(T=!1),i.forEach(t=>{Se(e,t,f[n])})}else t.ensureOptimizations&&H(`${Q}\tTokenType: <${s.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),T=!1;return e},[])}),{emptyGroups:p,patternIdxToConfig:f,charCodeToPatternIdxToConfig:E,hasCustom:m,canBeOptimized:T}}function de(e,t){let s=[];const n=function(e){const t=e.filter(e=>!Object.hasOwn(e,oe)),s=t.map(e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:Pe.MISSING_PATTERN,tokenTypes:[e]})),n=e.filter(e=>!t.includes(e));return{errors:s,valid:n}}(e);s=s.concat(n.errors);const i=function(e){const t=e.filter(e=>{const t=e[oe];return!(t instanceof RegExp||"function"==typeof t||Object.hasOwn(t,"exec")||"string"==typeof t)}),s=t.map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:Pe.INVALID_PATTERN,tokenTypes:[e]})),n=e.filter(e=>!t.includes(e));return{errors:s,valid:n}}(n.valid),a=i.valid;return s=s.concat(i.errors),s=s.concat(function(e){let t=[];const s=e.filter(e=>e[oe]instanceof RegExp);return t=t.concat(function(e){class t extends z{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}const s=e.filter(e=>{const s=e.PATTERN;try{const e=q(s),n=new t;return n.visit(e),n.found}catch(e){return ue.test(s.source)}}),n=s.map(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Pe.EOI_ANCHOR_FOUND,tokenTypes:[e]}));return n}(s)),t=t.concat(function(e){class t extends z{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}const s=e.filter(e=>{const s=e.PATTERN;try{const e=q(s),n=new t;return n.visit(e),n.found}catch(e){return pe.test(s.source)}}),n=s.map(e=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Pe.SOI_ANCHOR_FOUND,tokenTypes:[e]}));return n}(s)),t=t.concat(function(e){const t=e.filter(e=>{const t=e[oe];return t instanceof RegExp&&(t.multiline||t.global)}),s=t.map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:Pe.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}));return s}(s)),t=t.concat(function(e){const t=[];let s=e.map(s=>e.reduce((e,n)=>(s.PATTERN.source!==n.PATTERN.source||t.includes(n)||n.PATTERN===Ke.NA||(t.push(n),e.push(n)),e),[]));s=s.filter(Boolean);const n=s.filter(e=>e.length>1).map(e=>{const t=e.map(e=>e.name);return{message:`The same RegExp pattern ->${e[0].PATTERN}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:Pe.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}});return n}(s)),t=t.concat(function(e){const t=e.filter(e=>e.PATTERN.test("")),s=t.map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:Pe.EMPTY_MATCH_PATTERN,tokenTypes:[e]}));return s}(s)),t}(a)),s=s.concat(function(e){const t=e.filter(e=>{if(!Object.hasOwn(e,"GROUP"))return!1;const t=e.GROUP;return t!==Ke.SKIPPED&&t!==Ke.NA&&!("string"==typeof t)}),s=t.map(e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:Pe.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}));return s}(a)),s=s.concat(function(e,t){const s=e.filter(e=>void 0!==e.PUSH_MODE&&!t.includes(e.PUSH_MODE)),n=s.map(e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:Pe.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}));return n}(a,t)),s=s.concat(function(e){const t=[],s=e.reduce((e,t,s)=>{const n=t.PATTERN;return n===Ke.NA||("string"==typeof n?e.push({str:n,idx:s,tokenType:t}):n instanceof RegExp&&(i=n,void 0===[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find(e=>-1!==i.source.indexOf(e)))&&e.push({str:n.source,idx:s,tokenType:t})),e;var i},[]);return e.forEach((e,n)=>{s.forEach(({str:s,idx:i,tokenType:a})=>{if(n<i&&function(e,t){if(t instanceof RegExp){if(/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source))return!1;const s=t.exec(e);return null!==s&&0===s.index}if("function"==typeof t)return t(e,0,[],{});if(Object.hasOwn(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(s,e.PATTERN)){const s=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:s,type:Pe.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}(a)),s}const ue=/[^\\][$]/;const pe=/[^\\[][\^]|^\^/;function fe(e){const t=e.ignoreCase?"iy":"y";return new RegExp(`${e.source}`,t)}function me(e,t,s){const n=[];let i=!1;const a=Object.values(e.modes||{}).flat().filter(Boolean).filter(e=>e[oe]!==Ke.NA),r=Ae(s);return t&&a.forEach(e=>{const t=ye(e,r);if(!1!==t){const s=function(e,t){if(t.issue===Pe.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===Pe.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${e.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),i={message:s,type:t.issue,tokenType:e};n.push(i)}else Object.hasOwn(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(i=!0):re(r,e.PATTERN)&&(i=!0)}),t&&!i&&n.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:Pe.NO_LINE_BREAKS_FLAGS}),n}function Te(e){const t=e.PATTERN;if(t instanceof RegExp)return!1;if("function"==typeof t)return!0;if(Object.hasOwn(t,"exec"))return!0;if("string"==typeof t)return!1;throw Error("non exhaustive match")}function Ee(e){return"string"==typeof e&&1===e.length&&e.charCodeAt(0)}const ge={test:function(e){const t=e.length;for(let s=this.lastIndex;s<t;s++){const t=e.charCodeAt(s);if(10===t)return this.lastIndex=s+1,!0;if(13===t)return 10===e.charCodeAt(s+1)?this.lastIndex=s+2:this.lastIndex=s+1,!0}return!1},lastIndex:0};function ye(e,t){if(Object.hasOwn(e,"LINE_BREAKS"))return!1;if(e.PATTERN instanceof RegExp){try{re(t,e.PATTERN)}catch(e){return{issue:Pe.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if("string"==typeof e.PATTERN)return!1;if(Te(e))return{issue:Pe.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function Ae(e){return e.map(e=>"string"==typeof e?e.charCodeAt(0):e)}function Se(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}const Le=256;let Oe=[];function Re(e){return e<Le?e:Oe[e]}function ke(e){const t=(new Date).getTime(),s=e();return{time:(new Date).getTime()-t,value:s}}function Ne(e,t){const s=e.tokenTypeIdx;return s===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[s]}function Ie(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let be=1;const Ce={};function ve(e){const t=function(e){let t=[...e],s=e,n=!0;for(;n;){s=s.map(e=>e.CATEGORIES).flat().filter(Boolean);const e=s.filter(e=>!t.includes(e));t=t.concat(e),0===e.length?n=!1:s=e}return t}(e);!function(e){e.forEach(e=>{var t;xe(e)||(Ce[be]=e,e.tokenTypeIdx=be++),we(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),we(e)||(e.CATEGORIES=[]),t=e,Object.hasOwn(null!=t?t:{},"categoryMatches")||(e.categoryMatches=[]),function(e){return Object.hasOwn(null!=e?e:{},"categoryMatchesMap")}(e)||(e.categoryMatchesMap={})})}(t),function(e){e.forEach(e=>{_e([],e)})}(t),function(e){e.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(Ce[t].tokenTypeIdx)})})}(t),t.forEach(e=>{e.isParent=e.categoryMatches.length>0})}function _e(e,t){e.forEach(e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),t.CATEGORIES.forEach(s=>{const n=e.concat(t);n.includes(s)||_e(n,s)})}function xe(e){return Object.hasOwn(null!=e?e:{},"tokenTypeIdx")}function we(e){return Object.hasOwn(null!=e?e:{},"CATEGORIES")}function Ue(e){return Object.hasOwn(null!=e?e:{},"tokenTypeIdx")}const Me={buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,s,n,i,a)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${s} characters.`};var Pe;!function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"}(Pe||(Pe={}));const De={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Me,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(De);class Ke{constructor(e,t=De){if(this.lexerDefinition=e,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=(e,t)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const s=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--\x3e <${e}>`);const{time:n,value:i}=ke(t),a=n>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${n}ms`),this.traceInitIndent--,i}return t()},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=Object.assign({},De,t);const s=this.config.traceInitPerf;!0===s?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof s&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let s,n=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===De.lineTerminatorsPattern)this.config.lineTerminatorsPattern=ge;else if(this.config.lineTerminatorCharacters===De.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?s={modes:{defaultMode:[...e]},defaultMode:ce}:(n=!1,s=Object.assign({},e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e){const t=[];return Object.hasOwn(e,ce)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+ce+"> property in its definition\n",type:Pe.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(e,le)||t.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:Pe.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(e,le)&&Object.hasOwn(e,ce)&&!Object.hasOwn(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${ce}: <${e.defaultMode}>which does not exist\n`,type:Pe.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(e,le)&&Object.keys(e.modes).forEach(s=>{const n=e.modes[s];n.forEach((e,i)=>{void 0===e?t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${i}>\n`,type:Pe.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(e,"LONGER_ALT")&&(Array.isArray(e.LONGER_ALT)?e.LONGER_ALT:[e.LONGER_ALT]).forEach(i=>{void 0===i||n.includes(i)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${e.name}> outside of mode <${s}>\n`,type:Pe.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),t}(s,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(me(s,this.trackStartLines,this.config.lineTerminatorCharacters))})),s.modes=s.modes?s.modes:{},Object.entries(s.modes).forEach(([e,t])=>{s.modes[e]=t.filter(e=>void 0!==e)});const i=Object.keys(s.modes);if(Object.entries(s.modes).forEach(([e,s])=>{this.TRACE_INIT(`Mode: <${e}> processing`,()=>{if(this.modes.push(e),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(de(s,i))}),0===this.lexerDefinitionErrors.length){let n;ve(s),this.TRACE_INIT("analyzeTokenTypes",()=>{n=he(s,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[e]=n.patternIdxToConfig,this.charCodeToPatternIdxToConfig[e]=n.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,n.emptyGroups),this.hasCustom=n.hasCustom||this.hasCustom,this.canModeBeOptimized[e]=n.canBeOptimized}})}),this.defaultMode=s.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){const e=this.lexerDefinitionErrors.map(e=>e.message).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+e)}this.lexerDefinitionWarning.forEach(e=>{Y(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(n&&(this.handleModes=()=>{}),!1===this.trackStartLines&&(this.computeNewColumn=e=>e),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else{if(!/onlyOffset/i.test(this.config.positionTracking))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const e=Object.entries(this.canModeBeOptimized).reduce((e,[t,s])=>(!1===s&&e.push(t),e),[]);if(t.ensureOptimizations&&e.length>0)throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{X={}}),this.TRACE_INIT("toFastProperties",()=>{u(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0){const e=this.lexerDefinitionErrors.map(e=>e.message).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let s,n,i,a,r,o,c,l,h,d,u,p,f,m,T;const E=e,g=E.length;let y=0,A=0;const S=this.hasCustom?0:Math.floor(e.length/10),L=new Array(S),O=[];let R=this.trackStartLines?1:void 0,k=this.trackStartLines?1:void 0;const N={};for(let e=0;e<this.cachedGroupKeys.length;e++)N[this.cachedGroupKeys[e]]=[];const I=this.trackStartLines,b=this.config.lineTerminatorsPattern;let C=0,v=[],_=[];const x=[],w=[];Object.freeze(w);let U=!1;const M=e=>{if(1===x.length&&void 0===e.tokenType.PUSH_MODE){const t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);O.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{x.pop();const e=x.at(-1);v=this.patternIdxToConfig[e],_=this.charCodeToPatternIdxToConfig[e],C=v.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;U=!(!_||!t)}};function P(e){x.push(e),_=this.charCodeToPatternIdxToConfig[e],v=this.patternIdxToConfig[e],C=v.length;const t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;U=!(!_||!t)}let D;P.call(this,t);const K=this.config.recoveryEnabled;for(;y<g;){o=null,h=-1;const t=E.charCodeAt(y);let S;if(U){const e=Re(t),s=_[e];S=void 0!==s?s:w}else S=v;const $=S.length;for(s=0;s<$;s++){D=S[s];const n=D.pattern;switch(c=null,D.matchType){case 0:t===D.short&&(h=1,o=n);break;case 1:T=n.exec(E,y,L,N),null!==T?(o=T[0],h=o.length,void 0!==T.payload&&(c=T.payload)):o=null;break;case 3:{const e=D.asciiClass;if(1!==e[t]){n.lastIndex=0;break}let s=y+1;for(;1===e[E.charCodeAt(s)];)s++;h=s-y,n.lastIndex=s;break}case 2:n.lastIndex=y,h=this.matchLength(n,e,y)}if(-1!==h){if(r=D.longerAlt,void 0!==r){o=e.substring(y,y+h);const t=r.length;for(i=0;i<t;i++){const t=v[r[i]],s=t.pattern;if(l=null,1===t.matchType?(T=s.exec(E,y,L,N),null!==T?(a=T[0],void 0!==T.payload&&(l=T.payload)):a=null):(s.lastIndex=y,a=this.match(s,e,y)),a&&a.length>o.length){o=a,h=a.length,c=l,D=t;break}}}break}}if(-1!==h){if(d=D.group,void 0!==d&&(o=null!==o?o:e.substring(y,y+h),u=D.tokenTypeIdx,p=this.createTokenInstance(o,y,u,D.tokenType,R,k,h),this.handlePayload(p,c),!1===d?A=this.addToken(L,A,p):N[d].push(p)),!0===I&&!0===D.canLineTerminator){let t,s,n=0;b.lastIndex=0;do{o=null!==o?o:e.substring(y,y+h),t=b.test(o),!0===t&&(s=b.lastIndex-1,n++)}while(!0===t);0!==n?(R+=n,k=h-s,this.updateTokenEndLineColumnLocation(p,d,s,n,R,k,h)):k=this.computeNewColumn(k,h)}else k=this.computeNewColumn(k,h);y+=h,this.handleModes(D,M,P,p)}else{const t=y,s=R,i=k;let a=!1===K;for(;!1===a&&y<g;)for(y++,n=0;n<C;n++){const t=v[n],s=t.pattern;switch(t.matchType){case 0:E.charCodeAt(y)===t.short&&(a=!0);break;case 1:a=null!==s.exec(E,y,L,N);break;case 3:case 2:s.lastIndex=y,a=null!==s.exec(e)}if(!0===a)break}if(f=y-t,k=this.computeNewColumn(k,f),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,t,f,s,i,x.at(-1)),O.push({offset:t,line:s,column:i,length:f,message:m}),!1===K)break}}return this.hasCustom||(L.length=A),{tokens:L,groups:N,errors:O}}handleModes(e,t,s,n){if(!0===e.pop){const i=e.push;t(n),void 0!==i&&s.call(this,i)}else void 0!==e.push&&s.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,s,n,i,a,r){let o,c;void 0!==t&&(o=s===r-1,c=o?-1:0,1===n&&!0===o||(e.endLine=i+c,e.endColumn=a-1-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,s,n){return{image:e,startOffset:t,tokenTypeIdx:s,tokenType:n}}createStartOnlyToken(e,t,s,n,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:s,tokenType:n}}createFullToken(e,t,s,n,i,a,r){return{image:e,startOffset:t,endOffset:t+r-1,startLine:i,endLine:i,startColumn:a,endColumn:a+r-1,tokenTypeIdx:s,tokenType:n}}addTokenUsingPush(e,t,s){return e.push(s),t}addTokenUsingMemberAccess(e,t,s){return e[t]=s,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}match(e,t,s){return!0===e.test(t)?t.substring(s,e.lastIndex):null}matchLength(e,t,s){return!0===e.test(t)?e.lastIndex-s:-1}}function $e(e){return Be(e)?e.LABEL:e.name}function Be(e){return"string"==typeof e.LABEL&&""!==e.LABEL}Ke.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.",Ke.NA=/NOT_APPLICABLE/;const Fe="parent",je="categories",Ge="label",We="group",Ve="push_mode",ze="pop_mode",He="longer_alt",Ye="line_breaks",Xe="start_chars_hint";function Je(e){return function(e){const t=e.pattern,s={};s.name=e.name,void 0!==t&&(s.PATTERN=t);if(Object.hasOwn(e,Fe))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";Object.hasOwn(e,je)&&(s.CATEGORIES=e[je]);ve([s]),Object.hasOwn(e,Ge)&&(s.LABEL=e[Ge]);Object.hasOwn(e,We)&&(s.GROUP=e[We]);Object.hasOwn(e,ze)&&(s.POP_MODE=e[ze]);Object.hasOwn(e,Ve)&&(s.PUSH_MODE=e[Ve]);Object.hasOwn(e,He)&&(s.LONGER_ALT=e[He]);Object.hasOwn(e,Ye)&&(s.LINE_BREAKS=e[Ye]);Object.hasOwn(e,Xe)&&(s.START_CHARS_HINT=e[Xe]);return s}(e)}const qe=Je({name:"EOF",pattern:Ke.NA});function Ze(e,t,s,n,i,a,r,o){return{image:t,startOffset:s,endOffset:n,startLine:i,endLine:a,startColumn:r,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function Qe(e,t){return Ne(e,t)}ve([qe]);const et={buildMismatchTokenMessage:({expected:e,actual:t,previous:s,ruleName:n})=>`Expecting ${Be(e)?`--\x3e ${$e(e)} <--`:`token of type --\x3e ${e.name} <--`} but found --\x3e '${t.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:s,customUserDescription:n,ruleName:i}){const a="Expecting: ",r="\nbut found: '"+t[0].image+"'";if(n)return a+n+r;return a+`one of these possible Token sequences:\n${e.reduce((e,t)=>e.concat(t),[]).map(e=>`[${e.map(e=>$e(e)).join(", ")}]`).map((e,t)=>` ${t+1}. ${e}`).join("\n")}`+r},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:s,ruleName:n}){const i="Expecting: ",a="\nbut found: '"+t[0].image+"'";if(s)return i+s+a;return i+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${e.map(e=>`[${e.map(e=>$e(e)).join(",")}]`).join(" ,")}>`+a}};Object.freeze(et);const tt={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},st={buildDuplicateFoundError(e,t){const s=e.name,n=t[0],i=n.idx,a=b(n),r=(o=n)instanceof O?o.terminalType.name:o instanceof f?o.nonTerminalName:"";var o;let c=`->${a}${i>0?i:""}<- ${r?`with argument: ->${r}<-`:""}\n appears more than once (${t.length} times) in the top level rule: ->${s}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){const t=e.prefixPath.map(e=>$e(e)).join(", "),s=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${s}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){const t=0===e.alternation.idx?"":e.alternation.idx,s=0===e.prefixPath.length;let n=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;if(s)n+="These alternatives are all empty (match no tokens), making them indistinguishable.\nOnly the last alternative may be empty.\n";else{n+=`<${e.prefixPath.map(e=>$e(e)).join(", ")}> may appears as a prefix path in all these alternatives.\n`}return n+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",n},buildEmptyRepetitionError(e){let t=b(e.repetition);0!==e.repetition.idx&&(t+=e.repetition.idx);return`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){const t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --\x3e ${e.leftRecursionPath.map(e=>e.name).concat([t]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;t=e.topLevelRule instanceof m?e.topLevelRule.name:e.topLevelRule;return`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class nt extends N{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:Ls.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class it extends C{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...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(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,s){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const n=t.concat(s);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){0===this.ruleStack.length?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class at extends it{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,s){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const e=t.concat(s),n=new T({definition:e});this.possibleTokTypes=_(n),this.found=!0}}}class rt extends C{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class ot extends rt{walkMany(e,t,s){if(e.idx===this.occurrence){const e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,s)}}class ct extends rt{walkManySep(e,t,s){if(e.idx===this.occurrence){const e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,s)}}class lt extends rt{walkAtLeastOne(e,t,s){if(e.idx===this.occurrence){const e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,s)}}class ht extends rt{walkAtLeastOneSep(e,t,s){if(e.idx===this.occurrence){const e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof O&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,s)}}function dt(e,t,s=[]){s=[...s];let n=[],i=0;function a(a){const r=dt(a.concat(e.slice(i+1)),t,s);return n.concat(r)}for(;s.length<t&&i<e.length;){const t=e[i];if(t instanceof T)return a(t.definition);if(t instanceof f)return a(t.definition);if(t instanceof E)n=a(t.definition);else{if(t instanceof g){return a(t.definition.concat([new A({definition:t.definition})]))}if(t instanceof y){return a([new T({definition:t.definition}),new A({definition:[new O({terminalType:t.separator})].concat(t.definition)})])}if(t instanceof S){const e=t.definition.concat([new A({definition:[new O({terminalType:t.separator})].concat(t.definition)})]);n=a(e)}else if(t instanceof A){const e=t.definition.concat([new A({definition:t.definition})]);n=a(e)}else{if(t instanceof L)return t.definition.forEach(e=>{0!==e.definition.length&&(n=a(e.definition))}),n;if(!(t instanceof O))throw Error("non exhaustive match");s.push(t.terminalType)}}i++}return n.push({partialPath:s,suffixDef:e.slice(i)}),n}function ut(e,t,s,n){const i=[...s];i.push(e.name);const a=[...n];return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var pt;function ft(e){if(e instanceof E||"Option"===e)return pt.OPTION;if(e instanceof A||"Repetition"===e)return pt.REPETITION;if(e instanceof g||"RepetitionMandatory"===e)return pt.REPETITION_MANDATORY;if(e instanceof y||"RepetitionMandatoryWithSeparator"===e)return pt.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof S||"RepetitionWithSeparator"===e)return pt.REPETITION_WITH_SEPARATOR;if(e instanceof L||"Alternation"===e)return pt.ALTERNATION;throw Error("non exhaustive match")}function mt(e,t,s,n){const i=e.length,a=e.every(e=>e.every(e=>1===e.length));if(t)return function(t){const n=t.map(e=>e.GATE);for(let t=0;t<i;t++){const i=e[t],a=i.length,r=n[t];if(void 0===r||!1!==r.call(this))e:for(let e=0;e<a;e++){const n=i[e],a=n.length;for(let e=0;e<a;e++){const t=this.LA_FAST(e+1);if(!1===s(t,n[e]))continue e}return t}}};if(a&&!n){const t=e.map(e=>e.flat()).reduce((e,t,s)=>(t.forEach(t=>{t.tokenTypeIdx in e||(e[t.tokenTypeIdx]=s),t.categoryMatches.forEach(t=>{Object.hasOwn(e,t)||(e[t]=s)})}),e),{});return function(){const e=this.LA_FAST(1);return t[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){const n=e[t],i=n.length;e:for(let e=0;e<i;e++){const i=n[e],a=i.length;for(let e=0;e<a;e++){const t=this.LA_FAST(e+1);if(!1===s(t,i[e]))continue e}return t}}}}function Tt(e,t,s){const n=e.every(e=>1===e.length),i=e.length;if(n&&!s){const t=e.flat();if(1===t.length&&0===t[0].categoryMatches.length){const e=t[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===e}}{const e=t.reduce((e,t,s)=>(e[t.tokenTypeIdx]=!0,t.categoryMatches.forEach(t=>{e[t]=!0}),e),[]);return function(){const t=this.LA_FAST(1);return!0===e[t.tokenTypeIdx]}}}return function(){e:for(let s=0;s<i;s++){const n=e[s],i=n.length;for(let e=0;e<i;e++){const s=this.LA_FAST(e+1);if(!1===t(s,n[e]))continue e}return!0}return!1}}!function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"}(pt||(pt={}));class Et extends C{constructor(e,t,s){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=s}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,s,n){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=s.concat(n),!0)}walkOption(e,t,s){this.checkIsTarget(e,pt.OPTION,t,s)||super.walkOption(e,t,s)}walkAtLeastOne(e,t,s){this.checkIsTarget(e,pt.REPETITION_MANDATORY,t,s)||super.walkOption(e,t,s)}walkAtLeastOneSep(e,t,s){this.checkIsTarget(e,pt.REPETITION_MANDATORY_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}walkMany(e,t,s){this.checkIsTarget(e,pt.REPETITION,t,s)||super.walkOption(e,t,s)}walkManySep(e,t,s){this.checkIsTarget(e,pt.REPETITION_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}}class gt extends N{constructor(e,t,s){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=s,this.result=[]}checkIsTarget(e,t){e.idx!==this.targetOccurrence||this.targetProdType!==t||void 0!==this.targetRef&&e!==this.targetRef||(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,pt.OPTION)}visitRepetition(e){this.checkIsTarget(e,pt.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,pt.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,pt.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,pt.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,pt.ALTERNATION)}}function yt(e){const t=new Array(e);for(let s=0;s<e;s++)t[s]=[];return t}function At(e){let t=[""];for(let s=0;s<e.length;s++){const n=e[s],i=[];for(let e=0;e<t.length;e++){const s=t[e];i.push(s+"_"+n.tokenTypeIdx);for(let e=0;e<n.categoryMatches.length;e++){const t="_"+n.categoryMatches[e];i.push(s+t)}}t=i}return t}function St(e,t,s){for(let n=0;n<e.length;n++){if(n===s)continue;const i=e[n];for(let e=0;e<t.length;e++){if(!0===i[t[e]])return!1}}return!0}function Lt(e,t){const s=e.map(e=>dt([e],1)),n=yt(s.length),i=s.map(e=>{const t={};return e.forEach(e=>{At(e.partialPath).forEach(e=>{t[e]=!0})}),t});let a=s;for(let e=1;e<=t;e++){const s=a;a=yt(s.length);for(let r=0;r<s.length;r++){const o=s[r];for(let s=0;s<o.length;s++){const c=o[s].partialPath,l=o[s].suffixDef,h=At(c);if(St(i,h,r)||0===l.length||c.length===t){const e=n[r];if(!1===kt(e,c)){e.push(c);for(let e=0;e<h.length;e++){const t=h[e];i[r][t]=!0}}}else{const t=dt(l,e+1,c);a[r]=a[r].concat(t),t.forEach(e=>{At(e.partialPath).forEach(e=>{i[r][e]=!0})})}}}}return n}function Ot(e,t,s,n){const i=new gt(e,pt.ALTERNATION,n);return t.accept(i),Lt(i.result,s)}function Rt(e,t,s,n){const i=new gt(e,s);t.accept(i);const a=i.result,r=new Et(t,e,s).startWalking();return Lt([new T({definition:a}),new T({definition:r})],n)}function kt(e,t){e:for(let s=0;s<e.length;s++){const n=e[s];if(n.length===t.length){for(let e=0;e<n.length;e++){const s=t[e],i=n[e];if(!1===(s===i||void 0!==i.categoryMatchesMap[s.tokenTypeIdx]))continue e}return!0}}return!1}function Nt(e){return e.every(e=>e.every(e=>e.every(e=>0===e.categoryMatches.length)))}function It(e,t,s,n){const i=e.flatMap(e=>function(e,t){const s=new vt;e.accept(s);const n=s.allProductions,i=Object.groupBy(n,bt),a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t.length>1)),r=Object.values(a).map(s=>{const n=s[0],i=t.buildDuplicateFoundError(e,s),a=b(n),r={message:i,type:Ls.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:n.idx},o=Ct(n);return o&&(r.parameter=o),r});return r}(e,s)),a=function(e,t,s){const n=[],i=t.map(e=>e.name);return e.forEach(e=>{const t=e.name;if(i.includes(t)){const i=s.buildNamespaceConflictError(e);n.push({message:i,type:Ls.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),n}(e,t,s),r=e.flatMap(e=>function(e,t){const s=new wt;e.accept(s);const n=s.alternations.flatMap(s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:Ls.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[]);return n}(e,s)),o=e.flatMap(t=>function(e,t,s,n){const i=[],a=t.reduce((t,s)=>s.name===e.name?t+1:t,0);if(a>1){const t=n.buildDuplicateRuleNameError({topLevelRule:e,grammarName:s});i.push({message:t,type:Ls.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}(t,e,n,s));return i.concat(a,r,o)}function bt(e){return`${b(e)}_#_${e.idx}_#_${Ct(e)}`}function Ct(e){return e instanceof O?e.terminalType.name:e instanceof f?e.nonTerminalName:""}class vt extends N{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}function _t(e,t,s,n=[]){const i=[],a=xt(t.definition);if(0===a.length)return[];{const t=e.name;a.includes(e)&&i.push({message:s.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:n}),type:Ls.LEFT_RECURSION,ruleName:t});const r=n.concat([e]),o=a.filter(e=>!r.includes(e)).flatMap(t=>{const i=[...n];return i.push(t),_t(e,t,s,i)});return i.concat(o)}}function xt(e){let t=[];if(0===e.length)return t;const s=e[0];if(s instanceof f)t.push(s.referencedRule);else if(s instanceof T||s instanceof E||s instanceof g||s instanceof y||s instanceof S||s instanceof A)t=t.concat(xt(s.definition));else if(s instanceof L)t=s.definition.map(e=>xt(e.definition)).flat();else if(!(s instanceof O))throw Error("non exhaustive match");const n=I(s),i=e.length>1;if(n&&i){const s=e.slice(1);return t.concat(xt(s))}return t}class wt extends N{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Ut(e,t){const s=new wt;e.accept(s);return s.alternations.flatMap(s=>s.definition.slice(0,-1).flatMap((n,i)=>0===function(e,t,s,n){const i="EXIT_NONE_TERMINAL",a=[i],r="EXIT_ALTERNATIVE";let o=!1;const c=t.length,l=c-n-1,h=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});0!==d.length;){const e=d.pop();if(e===r){o&&d.at(-1).idx<=l&&d.pop();continue}const n=e.def,u=e.idx,p=e.ruleStack,R=e.occurrenceStack;if(0===n.length)continue;const k=n[0];if(k===i){const e={idx:u,def:n.slice(1),ruleStack:p.slice(0,-1),occurrenceStack:R.slice(0,-1)};d.push(e)}else if(k instanceof O)if(u<c-1){const e=u+1;if(s(t[e],k.terminalType)){const t={idx:e,def:n.slice(1),ruleStack:p,occurrenceStack:R};d.push(t)}}else{if(u!==c-1)throw Error("non exhaustive match");h.push({nextTokenType:k.terminalType,nextTokenOccurrence:k.idx,ruleStack:p,occurrenceStack:R}),o=!0}else if(k instanceof f){const e=[...p];e.push(k.nonTerminalName);const t=[...R];t.push(k.idx);const s={idx:u,def:k.definition.concat(a,n.slice(1)),ruleStack:e,occurrenceStack:t};d.push(s)}else if(k instanceof E){const e={idx:u,def:n.slice(1),ruleStack:p,occurrenceStack:R};d.push(e),d.push(r);const t={idx:u,def:k.definition.concat(n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(t)}else if(k instanceof g){const e=new A({definition:k.definition,idx:k.idx}),t={idx:u,def:k.definition.concat([e],n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(t)}else if(k instanceof y){const e=new O({terminalType:k.separator}),t=new A({definition:[e].concat(k.definition),idx:k.idx}),s={idx:u,def:k.definition.concat([t],n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(s)}else if(k instanceof S){const e={idx:u,def:n.slice(1),ruleStack:p,occurrenceStack:R};d.push(e),d.push(r);const t=new O({terminalType:k.separator}),s=new A({definition:[t].concat(k.definition),idx:k.idx}),i={idx:u,def:k.definition.concat([s],n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(i)}else if(k instanceof A){const e={idx:u,def:n.slice(1),ruleStack:p,occurrenceStack:R};d.push(e),d.push(r);const t=new A({definition:k.definition,idx:k.idx}),s={idx:u,def:k.definition.concat([t],n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(s)}else if(k instanceof L)for(let e=k.definition.length-1;e>=0;e--){const t={idx:u,def:k.definition[e].definition.concat(n.slice(1)),ruleStack:p,occurrenceStack:R};d.push(t),d.push(r)}else if(k instanceof T)d.push({idx:u,def:k.definition.concat(n.slice(1)),ruleStack:p,occurrenceStack:R});else{if(!(k instanceof m))throw Error("non exhaustive match");d.push(ut(k,u,p,R))}}return h}([n],[],Ne,1).length?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:i}),type:Ls.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:i+1}]:[]))}function Mt(e,t,s){const n=new wt;e.accept(n);let i=n.alternations;i=i.filter(e=>!0!==e.ignoreAmbiguities);const a=i.flatMap(n=>{const i=n.idx,a=n.maxLookahead||t,r=Ot(i,e,a,n),o=function(e,t,s,n){const i=[],a=e.reduce((s,n,a)=>(!0===t.definition[a].ignoreAmbiguities||n.forEach(n=>{const r=[a];e.forEach((e,s)=>{a!==s&&kt(e,n)&&!0!==t.definition[s].ignoreAmbiguities&&r.push(s)}),r.length>1&&!kt(i,n)&&(i.push(n),s.push({alts:r,path:n}))}),s),[]),r=a.map(e=>{const i=e.alts.map(e=>e+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:s,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:Ls.AMBIGUOUS_ALTS,ruleName:s.name,occurrence:t.idx,alternatives:e.alts}});return r}(r,n,e,s),c=function(e,t,s,n){const i=e.reduce((e,t,s)=>{const n=t.map(e=>({idx:s,path:e}));return e.concat(n)},[]),a=i.flatMap(e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];const a=e.idx,r=e.path;return i.filter(e=>{return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<a&&(s=e.path,n=r,s.length<n.length&&s.every((e,t)=>{const s=n[t];return e===s||s.categoryMatchesMap[e.tokenTypeIdx]}));var s,n}).map(e=>{const i=[e.idx+1,a+1],r=0===t.idx?"":t.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:s,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:Ls.AMBIGUOUS_PREFIX_ALTS,ruleName:s.name,occurrence:r,alternatives:i}})});return a}(r,n,e,s);return o.concat(c)});return a}class Pt extends N{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}function Dt(e){const t=Object.assign({errMsgProvider:tt},e),s={};return e.rules.forEach(e=>{s[e.name]=e}),function(e,t){const s=new nt(e,t);return s.resolveRefs(),s.errors}(s,t.errMsgProvider)}const Kt="MismatchedTokenException",$t="NoViableAltException",Bt="EarlyExitException",Ft="NotAllInputParsedException",jt=[Kt,$t,Bt,Ft];function Gt(e){return jt.includes(e.name)}Object.freeze(jt);class Wt extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class Vt extends Wt{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=Kt}}class zt extends Wt{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=$t}}class Ht extends Wt{constructor(e,t){super(e,t),this.name=Ft}}class Yt extends Wt{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=Bt}}const Xt={},Jt="InRuleRecoveryException";class qt extends Error{constructor(e){super(e),this.name=Jt}}function Zt(e,t,s,n,i,a,r){var o,c,l;const h=n|i,d=null!==(o=(c=this.firstAfterRepMap)[l=this.currRuleShortName])&&void 0!==o?o:c[l]=[];let u=d[h];if(void 0===u){const e=this.getCurrRuleFullName();u=new a(this.getGAstProductions()[e],i).startWalking(),d[h]=u}let p=u.token,f=u.occurrence;const m=u.isEndOfRule;0===this.RULE_STACK_IDX&&m&&void 0===p&&(p=qe,f=1),void 0!==p&&void 0!==f&&this.shouldInRepetitionRecoveryBeTried(p,f,r)&&this.tryInRepetitionRecovery(e,t,s,p)}const Qt=1024,es=1280,ts=1536;class ss{constructor(e){var t;this.maxLookahead=null!==(t=null==e?void 0:e.maxLookahead)&&void 0!==t?t:As.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(0===t.length){const s=this.validateEmptyOrAlternatives(e.rules),n=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...s,...n,...i]}return t}validateNoLeftRecursion(e){return e.flatMap(e=>_t(e,e,st))}validateEmptyOrAlternatives(e){return e.flatMap(e=>Ut(e,st))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(e=>Mt(e,t,st))}validateSomeNonEmptyLookaheadPath(e,t){return function(e,t,s){const n=[];return e.forEach(e=>{const i=new Pt;e.accept(i),i.allProductions.forEach(i=>{const a=ft(i),r=i.maxLookahead||t;if(0===Rt(i.idx,e,a,r)[0].flat().length){const t=s.buildEmptyRepetitionError({topLevelRule:e,repetition:i});n.push({message:t,type:Ls.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),n}(e,t,st)}buildLookaheadForAlternation(e){return function(e,t,s,n,i,a){const r=Ot(e,t,s);return a(r,n,Nt(r)?Ie:Ne,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,mt)}buildLookaheadForOptional(e){return function(e,t,s,n,i,a){const r=Rt(e,t,i,s),o=Nt(r)?Ie:Ne;return a(r[0],o,n)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,ft(e.prodType),Tt)}}const ns=new class extends N{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};function is(e,t){-1===e.startOffset?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function as(e,t){-1===e.startOffset?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function rs(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function os(e,t){const s=Object.keys(e),n=s.length;for(let i=0;i<n;i++){const n=e[s[i]],a=n.length;for(let e=0;e<a;e++){const s=n[e];void 0===s.tokenTypeIdx&&this[s.name](s.children,t)}}}function cs(e,t){const s=function(){};rs(s,e+"BaseSemantics");const n={visit:function(e,t){if(Array.isArray(e)&&(e=e[0]),void 0!==e)return this[e.name](e.children,t)},validateVisitor:function(){const e=function(e,t){const s=function(e,t){const s=t.filter(t=>"function"==typeof e[t]==!1),n=s.map(t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:ls.MISSING_METHOD,methodName:t}));return n.filter(Boolean)}(e,t);return s}(this,t);if(0!==e.length){const t=e.map(e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(s.prototype=n).constructor=s,s._RULE_NAMES=t,s}var ls;!function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"}(ls||(ls={}));const hs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(hs);const ds=!0,us=Je({name:"RECORDING_PHASE_TOKEN",pattern:Ke.NA});ve([us]);const ps=Ze(us,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(ps);const fs={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function ms(e,t,s,n=!1){gs(s);const i=this.recordingProdStack.at(-1),a="function"==typeof t?t:t.DEF,r=new e({definition:[],idx:s});return n&&(r.separator=t.SEP),Object.hasOwn(t,"MAX_LOOKAHEAD")&&(r.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(r),a.call(this),i.definition.push(r),this.recordingProdStack.pop(),hs}function Ts(e,t){gs(t);const s=this.recordingProdStack.at(-1),n=!1===Array.isArray(e),i=!1===n?e:e.DEF,a=new L({definition:[],idx:t,ignoreAmbiguities:n&&!0===e.IGNORE_AMBIGUITIES});Object.hasOwn(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD);const r=i.some(e=>"function"==typeof e.GATE);return a.hasPredicates=r,s.definition.push(a),i.forEach(e=>{const t=new T({definition:[]});a.definition.push(t),Object.hasOwn(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:Object.hasOwn(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),hs}function Es(e){return 0===e?"":`${e}`}function gs(e){if(e<0||e>255){const t=new Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}const ys=Ze(qe,"",-1,-1,-1,-1,-1,-1);Object.freeze(ys);const As=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:et,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Ss=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var Ls,Os;!function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"}(Ls||(Ls={}));class Rs{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const t=this.className;this.TRACE_INIT("toFastProps",()=>{u(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach(e=>{const t=this[e].originalGrammarAction;let s;this.TRACE_INIT(`${e} Rule`,()=>{s=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=s})}finally{this.disableRecording()}});let s=[];if(this.TRACE_INIT("Grammar Resolving",()=>{s=Dt({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(s)}),this.TRACE_INIT("Grammar Validations",()=>{if(0===s.length&&!1===this.skipValidations){const s=function(e){var t;const s=null!==(t=e.errMsgProvider)&&void 0!==t?t:st;return It(e.rules,e.tokenTypes,s,e.grammarName)}({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:st,grammarName:t}),n=(e={lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:t}).lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map(e=>Object.assign({type:Ls.CUSTOM_LOOKAHEAD_VALIDATION},e));this.definitionErrors=this.definitionErrors.concat(s,n)}var e}),0===this.definitionErrors.length&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const e=function(e){const t={};return e.forEach(e=>{const s=new w(e).startWalking();Object.assign(t,s)}),t}(Object.values(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var e,t;null===(t=(e=this.lookaheadStrategy).initialize)||void 0===t||t.call(e,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!Rs.DEFER_DEFINITION_ERRORS_HANDLING&&0!==this.definitionErrors.length)throw e=this.definitionErrors.map(e=>e.message),new Error(`Parser Definition Errors detected:\n ${e.join("\n-------------------------------\n")}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const s=this;if(s.initErrorHandler(t),s.initLexerAdapter(),s.initLooksAhead(t),s.initRecognizerEngine(e,t),s.initRecoverable(t),s.initTreeBuilder(t),s.initGastRecorder(t),s.initPerformanceTracer(t),Object.hasOwn(t,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=Object.hasOwn(t,"skipValidations")?t.skipValidations:As.skipValidations}}Rs.DEFER_DEFINITION_ERRORS_HANDLING=!1,Os=Rs,[class{initRecoverable(e){this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:As.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Zt)}getTokenToInsert(e){const t=Ze(e,"",-1,-1,-1,-1,-1,-1);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,s,n){const i=this.findReSyncTokenType(),a=this.exportLexerState(),r=[];let o=!1;const c=this.LA_FAST(1);let l=this.LA_FAST(1);const h=()=>{const e=this.LA(0),t=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),s=new Vt(t,c,this.LA(0));s.resyncedTokens=r.slice(0,-1),this.SAVE_ERROR(s)};for(;!o;){if(this.tokenMatcher(l,n))return void h();if(s.call(this))return h(),void e.apply(this,t);this.tokenMatcher(l,i)?o=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,r))}this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,s){return!1!==s&&!this.tokenMatcher(this.LA_FAST(1),e)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t))}getNextPossibleTokenTypes(e){const t=e.ruleStack[0],s=this.getGAstProductions()[t];return new at(s,e).startWalking()}getFollowsForInRuleRecovery(e,t){const s=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(s)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new qt("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(0===t.length)return!1;const s=this.LA_FAST(1);return void 0!==t.find(e=>this.tokenMatcher(s,e))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA_FAST(1),s=2;for(;;){const n=e.find(e=>Qe(t,e));if(void 0!==n)return n;t=this.LA(s),s++}}getCurrFollowKey(){if(0===this.RULE_STACK_IDX)return Xt;const e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),s=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(s)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,s=this.RULE_STACK_IDX+1,n=new Array(s);for(let i=0;i<s;i++)n[i]=0===i?Xt:{ruleName:this.shortRuleNameToFullName(e[i]),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])};return n}flattenFollowSet(){return this.buildFullFollowKeyStack().map(e=>this.getFollowSetFromFollowKey(e)).flat()}getFollowSetFromFollowKey(e){if(e===Xt)return[qe];const t=e.ruleName+e.idxInCallingRule+x+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,qe)||t.push(e),t}reSyncTo(e){const t=[];let s=this.LA_FAST(1);for(;!1===this.tokenMatcher(s,e);)s=this.SKIP_TOKEN(),this.addToResyncTokens(s,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,s,n,i,a,r){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){const e=this.RULE_STACK_IDX+1,t=new Array(e);for(let s=0;s<e;s++)t[s]=this.shortRuleNameToFullName(this.RULE_STACK[s]);return t}},class{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:As.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:As.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new ss({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach(e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{const{alternation:t,repetition:s,option:n,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:r}=function(e){ns.reset(),e.accept(ns);const t=ns.dslMethods;return ns.reset(),t}(e);t.forEach(t=>{const s=0===t.idx?"":t.idx;this.TRACE_INIT(`${b(t)}${s}`,()=>{const s=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[e.name],256|t.idx,s)})}),s.forEach(t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,b(t))}),n.forEach(t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,b(t))}),i.forEach(t=>{this.computeLookaheadFunc(e,t.idx,Qt,"RepetitionMandatory",t.maxLookahead,b(t))}),a.forEach(t=>{this.computeLookaheadFunc(e,t.idx,ts,"RepetitionMandatoryWithSeparator",t.maxLookahead,b(t))}),r.forEach(t=>{this.computeLookaheadFunc(e,t.idx,es,"RepetitionWithSeparator",t.maxLookahead,b(t))})})})}computeLookaheadFunc(e,t,s,n,i,a){this.TRACE_INIT(`${a}${0===t?"":t}`,()=>{const a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n});this.setLaFuncCache(this.fullRuleNameToShort[e.name],s|t,a)})}setLaFuncCache(e,t,s){let n=this.lookAheadFuncsCache[e];void 0===n&&(n=[],this.lookAheadFuncsCache[e]=n),n[t]=s}},class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,"nodeLocationTracking")?e.nodeLocationTracking:As.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=as,this.setNodeLocationFromNode=as,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=is,this.setNodeLocationFromNode=is,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{}}else this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{}}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(e){const t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(e){const t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){const t=this.LA(0),s=e.location;-1!==s.startOffset&&s.startOffset<=t.startOffset==1?(s.endOffset=t.endOffset,s.endLine=t.endLine,s.endColumn=t.endColumn):(s.startOffset=-1,s.startLine=-1,s.startColumn=-1)}cstPostRuleOnlyOffset(e){const t=this.LA(0),s=e.location;-1!==s.startOffset&&s.startOffset<=t.startOffset==1?s.endOffset=t.endOffset:s.startOffset=-1}cstPostTerminal(e,t){const s=this.CST_STACK[this.CST_STACK.length-1];var n,i,a;i=t,a=e,void 0===(n=s).children[a]?n.children[a]=[i]:n.children[a].push(i),this.setNodeLocationFromToken(s.location,t)}cstPostNonTerminal(e,t){const s=this.CST_STACK[this.CST_STACK.length-1];!function(e,t,s){void 0===e.children[t]?e.children[t]=[s]:e.children[t].push(s)}(s,t,e),this.setNodeLocationFromNode(s.location,e.location)}get currCSTNode(){return this.CST_STACK[this.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(void 0===this.baseCstVisitorConstructor){const e=cs(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(void 0===this.baseCstVisitorWithDefaultsConstructor){const e=function(e,t,s){const n=function(){};rs(n,e+"BaseSemanticsWithDefaults");const i=Object.create(s.prototype);return t.forEach(e=>{i[e]=os}),(n.prototype=i).constructor=n,n}(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}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{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):ys}LA_FAST(e){const t=this.currIdx+e;return this.tokVector[t]}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ys:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=Ie,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(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(Array.isArray(e)){if(0===e.length)throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(Array.isArray(e))this.tokensMap=e.reduce((e,t)=>(e[t.name]=t,e),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(Ue)){const t=Object.values(e.modes).flat(),s=[...new Set(t)];this.tokensMap=s.reduce((e,t)=>(e[t.name]=t,e),{})}else{if("object"!=typeof e||null===e)throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=Object.assign({},e)}this.tokensMap.EOF=qe;const s=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every(e=>{var t;return 0==(null===(t=e.categoryMatches)||void 0===t?void 0:t.length)});this.tokenMatcher=s?Ie:Ne,ve(Object.values(this.tokensMap))}defineRule(e,t,s){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const n=Object.hasOwn(s,"resyncEnabled")?s.resyncEnabled:Ss.resyncEnabled,i=Object.hasOwn(s,"recoveryValueFunc")?s.recoveryValueFunc:Ss.recoveryValueFunc,a=this.ruleShortNameIdx++;let r;return this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a,r=!0===this.outputCst?function(...s){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,s);const n=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(n),n}catch(e){return this.invokeRuleCatch(e,n,i)}finally{this.ruleFinallyStateUpdate()}}:function(...s){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,s)}catch(e){return this.invokeRuleCatch(e,n,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...t){this.onBeforeParse(e);try{return r.apply(this,t)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:r})}invokeRuleCatch(e,t,s){const n=0===this.RULE_STACK_IDX,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Gt(e)){const t=e;if(i){const n=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(n)){if(t.resyncedTokens=this.reSyncTo(n),this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return s(e)}if(this.outputCst){const e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(n)return this.moveToTerminatedState(),s(e);throw t}throw e}optionInternal(e,t){const s=512|t;return this.optionInternalLogic(e,t,s)}optionInternalLogic(e,t,s){let n,i=this.currRuleLookaheadFuncs[s];if("function"!=typeof e){n=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else n=e;if(!0===i.call(this))return n.call(this)}atLeastOneInternal(e,t){const s=Qt|e;return this.atLeastOneInternalLogic(e,t,s)}atLeastOneInternalLogic(e,t,s){let n,i=this.currRuleLookaheadFuncs[s];if("function"!=typeof t){n=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else n=t;if(!0!==i.call(this))throw this.raiseEarlyExitException(e,pt.REPETITION_MANDATORY,t.ERR_MSG);{let e=this.doSingleRepetition(n);for(;!0===i.call(this)&&!0===e;)e=this.doSingleRepetition(n)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Qt,e,lt)}atLeastOneSepFirstInternal(e,t){const s=ts|e;this.atLeastOneSepFirstInternalLogic(e,t,s)}atLeastOneSepFirstInternalLogic(e,t,s){const n=t.DEF,i=t.SEP;if(!0!==this.currRuleLookaheadFuncs[s].call(this))throw this.raiseEarlyExitException(e,pt.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG);{n.call(this);const t=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;!0===this.tokenMatcher(this.LA_FAST(1),i);)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,n,ht],t,ts,e,ht)}}manyInternal(e,t){const s=768|e;return this.manyInternalLogic(e,t,s)}manyInternalLogic(e,t,s){let n,i=this.currRuleLookaheadFuncs[s];if("function"!=typeof t){n=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else n=t;let a=!0;for(;!0===i.call(this)&&!0===a;)a=this.doSingleRepetition(n);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,768,e,ot,a)}manySepFirstInternal(e,t){const s=es|e;this.manySepFirstInternalLogic(e,t,s)}manySepFirstInternalLogic(e,t,s){const n=t.DEF,i=t.SEP;if(!0===this.currRuleLookaheadFuncs[s].call(this)){n.call(this);const t=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;!0===this.tokenMatcher(this.LA_FAST(1),i);)this.CONSUME(i),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,n,ct],t,es,e,ct)}}repetitionSepSecondInternal(e,t,s,n,i){for(;s();)this.CONSUME(t),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,s,n,i],s,ts,e,i)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const s=256|t,n=Array.isArray(e)?e:e.DEF,i=this.currRuleLookaheadFuncs[s].call(this,n);if(void 0!==i)return n[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){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(e,t,s){let n;try{const i=void 0!==s?s.ARGS:void 0;return this.subruleIdx=t,n=e.coreRule.apply(this,i),this.cstPostNonTerminal(n,void 0!==s&&void 0!==s.LABEL?s.LABEL:e.ruleName),n}catch(t){throw this.subruleInternalError(t,s,e.ruleName)}}subruleInternalError(e,t,s){throw Gt(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:s),delete e.partialCstResult),e}consumeInternal(e,t,s){let n;try{const t=this.LA_FAST(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),n=t):this.consumeInternalError(e,t,s)}catch(s){n=this.consumeInternalRecovery(e,t,s)}return this.cstPostTerminal(void 0!==s&&void 0!==s.LABEL?s.LABEL:e.name,n),n}consumeInternalError(e,t,s){let n;const i=this.LA(0);throw n=void 0!==s&&s.ERR_MSG?s.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Vt(n,t,i))}consumeInternalRecovery(e,t,s){if(!this.recoveryEnabled||"MismatchedTokenException"!==s.name||this.isBackTracking())throw s;{const n=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,n)}catch(e){throw e.name===Jt?s:e}}}saveRecogState(){const e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);const t=e.RULE_STACK;for(let e=0;e<t.length;e++)this.RULE_STACK[e]=t[e];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName])}ruleInvocationStateUpdate(e,t,s){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=s,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),qe)}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(e){for(let e=0;e<this.maxLookahead+1;e++)this.tokVector.push(ys)}onAfterParse(e){if(!1===this.isAtEndOfInput()){const e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Ht(t,e))}for(;this.tokVector.at(-1)===ys;)this.tokVector.pop()}},class{ACTION(e){return e.call(this)}consume(e,t,s){return this.consumeInternal(t,e,s)}subrule(e,t,s){return this.subruleInternal(t,e,s)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,s=Ss){if(this.definedRulesNames.includes(e)){const t={message:st.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:Ls.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);const n=this.defineRule(e,t,s);return this[e]=n,n}OVERRIDE_RULE(e,t,s=Ss){const n=function(e,t,s){const n=[];let i;return t.includes(e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${s}<-as it is not defined in any of the super grammars `,n.push({message:i,type:Ls.INVALID_RULE_OVERRIDE,ruleName:e})),n}(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);const i=this.defineRule(e,t,s);return this[e]=i,i}BACKTRACK(e,t){var s;const n=null!==(s=e.coreRule)&&void 0!==s?s:e;return function(){this.isBackTrackingStack.push(1);const e=this.saveRecogState();try{return n.apply(this,t),!0}catch(e){if(Gt(e))return!1;throw e}finally{this.reloadRecogState(e),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Object.values(this.gastProductionsCache).map(R)}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:As.errorMessageProvider}SAVE_ERROR(e){if(Gt(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,s){const n=this.getCurrRuleFullName(),i=Rt(e,this.getGAstProductions()[n],t,this.maxLookahead)[0],a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));const r=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:a,previous:this.LA(0),customUserDescription:s,ruleName:n});throw this.SAVE_ERROR(new Yt(r,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const s=this.getCurrRuleFullName(),n=Ot(e,this.getGAstProductions()[s],this.maxLookahead),i=[];for(let e=1;e<=this.maxLookahead;e++)i.push(this.LA(e));const a=this.LA(0),r=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:n,actual:i,previous:a,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new zt(r,this.LA(1),a))}},class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const t=e>0?e:"";this[`CONSUME${t}`]=function(t,s){return this.consumeInternalRecord(t,e,s)},this[`SUBRULE${t}`]=function(t,s){return this.subruleInternalRecord(t,e,s)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,s){return this.consumeInternalRecord(t,e,s)},this.subrule=function(e,t,s){return this.subruleInternalRecord(t,e,s)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let t=0;t<10;t++){const s=t>0?t:"";delete e[`CONSUME${s}`],delete e[`SUBRULE${s}`],delete e[`OPTION${s}`],delete e[`OR${s}`],delete e[`MANY${s}`],delete e[`MANY_SEP${s}`],delete e[`AT_LEAST_ONE${s}`],delete e[`AT_LEAST_ONE_SEP${s}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return ys}topLevelRuleRecord(e,t){try{const s=new m({definition:[],name:e});return s.name=e,this.recordingProdStack.push(s),t.call(this),this.recordingProdStack.pop(),s}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(t){throw e}throw e}}optionInternalRecord(e,t){return ms.call(this,E,e,t)}atLeastOneInternalRecord(e,t){ms.call(this,g,t,e)}atLeastOneSepFirstInternalRecord(e,t){ms.call(this,y,t,e,ds)}manyInternalRecord(e,t){ms.call(this,A,t,e)}manySepFirstInternalRecord(e,t){ms.call(this,S,t,e,ds)}orInternalRecord(e,t){return Ts.call(this,e,t)}subruleInternalRecord(e,t,s){if(gs(t),!e||!Object.hasOwn(e,"ruleName")){const s=new Error(`<SUBRULE${Es(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}const n=this.recordingProdStack.at(-1),i=e.ruleName,a=new f({idx:t,nonTerminalName:i,label:null==s?void 0:s.LABEL,referencedRule:void 0});return n.definition.push(a),this.outputCst?fs:hs}consumeInternalRecord(e,t,s){if(gs(t),!xe(e)){const s=new Error(`<CONSUME${Es(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}const n=this.recordingProdStack.at(-1),i=new O({idx:t,terminalType:e,label:null==s?void 0:s.LABEL});return n.definition.push(i),ps}},class{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){const t=e.traceInitPerf,s="number"==typeof t;this.traceInitMaxIdent=s?t:1/0,this.traceInitPerf=s?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=As.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0===this.traceInitPerf){this.traceInitIndent++;const s=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--\x3e <${e}>`);const{time:n,value:i}=ke(t),a=n>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${n}ms`),this.traceInitIndent--,i}return t()}}].forEach(e=>{const t=e.prototype;Object.getOwnPropertyNames(t).forEach(s=>{if("constructor"===s)return;const n=Object.getOwnPropertyDescriptor(t,s);n&&(n.get||n.set)?Object.defineProperty(Os.prototype,s,n):Os.prototype[s]=e.prototype[s]})});class ks extends Rs{constructor(e,t=As){const s=Object.assign({},t);s.outputCst=!0,super(e,s)}}var Ns=s(51444),Is=(0,d.K)(e=>void 0!==e&&e>=0,"isKnownLocation");function bs(e,t){const s=e.lexer.tokenize(t);if(s.errors.length>0){const n=s.errors[0],i=Is(n.offset)?n.offset:t.length,a=i+(Is(n.length)?n.length:0);throw new Error(`Error lexing ${e.diagramType} diagram: ${n.message} at line ${n.line??1}, column ${n.column??1} [${i},${a})`)}e.parser.input=s.tokens;const n=e.entry();if(e.parser.errors.length>0)throw new Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(n)}(0,d.K)(bs,"runChevrotainParse");var Cs=0,vs=1,_s=2,xs=3,ws=4,Us=5,Ms=6,Ps=l.UI.usecase,Ds=(0,d.K)(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:"LR",relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Ps)}),"createModel"),Ks=(0,d.K)(e=>{if(!(e.actors instanceof Map&&e.useCases instanceof Map&&e.systemBoundaries instanceof Map&&Array.isArray(e.relationships)&&e.notes instanceof Map&&e.jsonNodes instanceof Map&&e.classDefs instanceof Map&&e.symbols instanceof Map&&["TB","TD","BT","RL","LR"].includes(e.direction)&&Number.isSafeInteger(e.relationshipCounter)&&!(e.relationshipCounter<0)&&Number.isSafeInteger(e.noteCounter)&&!(e.noteCounter<0)&&"string"==typeof e.accTitle&&"string"==typeof e.accDescription&&e.config))throw new Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),$s=Ds(),Bs=(0,d.K)(()=>structuredClone($s.config),"getConfig"),Fs=(0,d.K)(()=>$s.ast,"getAST"),js=(0,d.K)(e=>{const t=structuredClone(e);Ks(t);const s=(0,l.iN)(),n=(0,l.m7)();try{(0,l.SV)(t.accTitle),(0,l.EI)(t.accDescription),$s=t}catch(e){throw(0,l.SV)(s),(0,l.EI)(n),e}},"commit"),Gs=(0,d.K)(()=>{$s=Ds(),(0,l.IU)()},"clear"),Ws=(0,d.K)(()=>$s.actors,"getActors"),Vs=(0,d.K)(e=>$s.actors.get(e),"getActor"),zs=(0,d.K)(()=>$s.useCases,"getUseCases"),Hs=(0,d.K)(e=>$s.useCases.get(e),"getUseCase"),Ys=(0,d.K)(()=>$s.systemBoundaries,"getSystemBoundaries"),Xs=(0,d.K)(e=>$s.systemBoundaries.get(e),"getSystemBoundary"),Js=(0,d.K)(()=>$s.relationships,"getRelationships"),qs=(0,d.K)(()=>$s.notes,"getNotes"),Zs=(0,d.K)(e=>$s.notes.get(e),"getNote"),Qs=(0,d.K)(()=>$s.jsonNodes,"getJsonNodes"),en=(0,d.K)(e=>$s.jsonNodes.get(e),"getJsonNode"),tn=(0,d.K)(()=>$s.classDefs,"getClassDefs"),sn=(0,d.K)(e=>$s.classDefs.get(e),"getClassDef"),nn=(0,d.K)(()=>$s.direction,"getDirection"),an=(0,d.K)(e=>{const t=new Map;for(const s of["default",...e]){const e=$s.classDefs.get(s);if(e)for(const s of e.styles){const e=s.trim(),n=e.indexOf(":"),i=(-1===n?e:e.slice(0,n)).trim();i&&t.set(i,e)}}return[...t.values()]},"getCompiledStyles"),rn=(0,d.K)(e=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),on=(0,d.K)(e=>"string"==typeof e?e:null===e?"null":String(e),"displayJsonScalar"),cn=(0,d.K)((e,t,s=e=>e)=>{const n=[],i=(0,d.K)((e,t,i)=>{n.push({key:s(e),accessibleKey:s(t),value:s(i)})},"append"),a=(0,d.K)((e,s,n)=>{if(Array.isArray(e)){if(0===e.length)return void i(s,s,"[]");if(e.every(e=>null===e||["string","number","boolean"].includes(typeof e))){for(const[t,n]of e.entries())i(0===t?s:"",s,on(n));return}for(const[t,i]of e.entries())a(i,`${s}[${t}]`,`${n}/${t}`);return}if(null!==e&&"object"==typeof e){const r=e,o=t[n]??Object.keys(r);if(0===o.length)return void i(s,s,"{}");for(const e of o){const t=s?`${s}.${e}`:e;a(r[e],t,`${n}/${rn(e)}`)}return}i(s,s,on(e))},"visit");return a(e,"",""),n},"flattenJsonRows"),ln=(0,d.K)(e=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),hn=(0,d.K)(e=>"ellipse"===e.shape?e.business?"usecaseBusiness":"usecaseEllipse":e.shape,"useCaseShape"),dn=(0,d.K)(e=>{switch(e){case Cs:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case vs:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case xs:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case ws:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case Us:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case Ms:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case _s:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),un=(0,d.K)(e=>{switch(e.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:e.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...dn(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),pn=(0,d.K)(e=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),fn=(0,d.K)((...e)=>e.filter(e=>Boolean(e)).join(" "),"classNames"),mn=(0,d.K)(()=>{const e=(0,l.D7)(),t={...$s.config,...e.usecase},s=(0,d.K)(t=>(0,l.jZ)(t,e),"sanitize"),n=(0,d.K)(e=>s($s.actors.get(e)?.label??$s.useCases.get(e)?.label??$s.jsonNodes.get(e)?.id??$s.notes.get(e)?.label??e),"endpointLabel"),i=[],a=[];let r=0,o=0;for(const t of $s.actors.values())i.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:ln(t),isGroup:!1,padding:10,look:e.look,colorIndex:r++,cssClasses:fn("default","usecase-actor",`usecase-actor-${t.type}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:an(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(const t of $s.useCases.values())i.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:hn(t),isGroup:!1,padding:"ellipse"===t.shape?20:10,look:e.look,colorIndex:r++,cssClasses:fn("default","usecase-element",`usecase-${t.shape}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:an(t.classes),business:t.business,...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(const t of $s.notes.values())i.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:an([]),noteTarget:t.target,noteTargetLabel:s($s.actors.get(t.target)?.label??$s.useCases.get(t.target)?.label??$s.jsonNodes.get(t.target)?.id??t.target)});for(const t of $s.jsonNodes.values())i.push({id:t.id,label:s(t.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:fn("default","usecase-json-table",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:an(t.classes),jsonRows:cn(t.value,t.propertyOrder,s)});for(const t of $s.systemBoundaries.values())i.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:o++,cssClasses:fn("default","system-boundary",`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:an(t.classes),boundaryType:t.type});for(const t of $s.relationships){const{label:i,...r}=un(t);a.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:n(t.source),targetLabel:n(t.target),type:"edge",relationshipType:t.type,internal:!1,...r,...void 0!==i?{label:s(i)}:{},labelpos:"c",classes:fn("default","relationship",`relationship-${t.type}`,...t.classes,...pn(t)),style:[...t.styles],cssCompiledStyles:an(t.classes),animate:t.animate,...t.animation?{animation:t.animation}:{},look:e.look,thickness:"normal",minlen:t.minlen,isUserDefinedId:t.explicitId})}for(const t of $s.notes.values())a.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:"edge",relationshipType:"note",sourceLabel:n(t.id),targetLabel:n(t.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:an([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(const e of i)e.wrappingWidth??=t.wrappingWidth,e.isGroup||e.shape.startsWith("usecaseActor")||(e.minWidth??=t.minNodeWidth),"usecaseEllipse"!==e.shape&&"usecaseBusiness"!==e.shape||(e.spreadPorts=!0);return{nodes:i,edges:a,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:nn(),nodeSpacing:t.nodeSpacing,rankSpacing:t.rankSpacing,actorFontSize:t.actorFontSize,actorFontFamily:t.actorFontFamily,actorFontWeight:t.actorFontWeight,usecaseFontSize:t.usecaseFontSize,usecaseFontFamily:t.usecaseFontFamily,usecaseFontWeight:t.usecaseFontWeight,diagramPadding:t.diagramPadding,useMaxWidth:t.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Tn={getConfig:Bs,createModel:Ds,commit:js,getAST:Fs,clear:Gs,setDiagramTitle:l.ke,getDiagramTitle:l.ab,setAccTitle:l.SV,getAccTitle:l.iN,setAccDescription:l.EI,getAccDescription:l.m7,getActors:Ws,getActor:Vs,getUseCases:zs,getUseCase:Hs,getSystemBoundaries:Ys,getSystemBoundary:Xs,getRelationships:Js,getNotes:qs,getNote:Zs,getJsonNodes:Qs,getJsonNode:en,getClassDefs:tn,getClassDef:sn,getDirection:nn,getData:mn};function En(e,t,s){const n=[s];return n.index=t,n.input=e,n}(0,d.K)(En,"customMatch");var gn=(0,d.K)((e,t)=>{if('"'!==e[t]||"`"!==e[t+1])return null;for(let s=t+2;s<e.length-1;s++)if("`"===e[s]&&'"'===e[s+1])return En(e,t,e.slice(t,s+2));return null},"matchMarkdownString"),yn=(0,d.K)((e,t)=>{if("%"!==e[t]||"%"!==e[t+1])return null;for(let s=t-1;s>=0;s--){const t=e[s];if("\n"===t||"\r"===t)break;if(" "!==t&&"\t"!==t)return null}let s=t+2;for(;s<e.length&&"\n"!==e[s]&&"\r"!==e[s];)s++;return En(e,t,e.slice(t,s))},"matchComment"),An=(0,d.K)((e,t)=>{for(let s=t-1;s>=0;s--){const t=e[s];if("\n"===t||"\r"===t)return!0;if(" "!==t&&"\t"!==t)return!1}return!0},"isIndentedLineStart"),Sn=(0,d.K)((e,t,s)=>{if(!An(e,t))return null;const n=s.exec(e.slice(t));return n?En(e,t,n[0]):null},"matchAccessibilityLine"),Ln=(0,d.K)((e,t)=>{if(!An(e,t))return null;const s=/^accDescr[\t ]*{/.exec(e.slice(t));if(!s)return null;const n=e.indexOf("}",t+s[0].length);return-1===n?null:En(e,t,e.slice(t,n+1))},"matchAccDescrBlock"),On=(0,d.K)((e,t)=>{if("{"!==e[t])return null;let s=0,n=!1,i=!1;for(let a=t;a<e.length;a++){const r=e[a];if(n)i?i=!1:"\\"===r?i=!0:'"'===r&&(n=!1);else if('"'===r)n=!0;else if("{"===r)s++;else if("}"===r&&0===--s)return En(e,t,e.slice(t,a+1))}return null},"matchJsonObject"),Rn=(0,d.K)((e,t)=>{const s=e.indexOf(">>",t);if(-1===s||/[\n\r]/.test(e.slice(t,s)))return null;const n=e.slice(t,s);return n.trim()?En(e,t,n):null},"matchStereotypeText"),kn=Je({name:"LABEL_TEXT",pattern:Ke.NA}),Nn=Je({name:"WORD",pattern:Ke.NA,categories:kn}),In=Je({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:kn}),bn=Je({name:"IDENTIFIER",pattern:/\w+/,longer_alt:In,categories:Nn}),Cn=Je({name:"HWS",pattern:/[\t ]+/,group:Ke.SKIPPED}),vn=Je({name:"MARKDOWN_STRING",pattern:gn,start_chars_hint:['"'],line_breaks:!0}),_n=Je({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),xn=Je({name:"COMMENT",pattern:yn,start_chars_hint:["%"],line_breaks:!1}),wn=Je({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Un=Je({name:"ACC_DESCR_BLOCK",pattern:Ln,start_chars_hint:["a"],line_breaks:!0}),Mn=/^accTitle[\t ]*:[^\n\r]*/,Pn=/^accDescr[\t ]*:[^\n\r]*/,Dn=Je({name:"ACC_TITLE_LINE",pattern:(0,d.K)((e,t)=>Sn(e,t,Mn),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Kn=Je({name:"ACC_DESCR_LINE",pattern:(0,d.K)((e,t)=>Sn(e,t,Pn),"pattern"),start_chars_hint:["a"],line_breaks:!1}),$n=Je({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),Bn=Je({name:"JSON_OBJECT_LITERAL",pattern:On,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),Fn=Je({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),jn=(0,d.K)((e,t)=>Je({name:e,pattern:t,longer_alt:bn,categories:Nn}),"keyword"),Gn=jn("USECASE",/usecase-beta/),Wn=jn("ACTOR",/actor/),Vn=jn("SYSTEM_BOUNDARY",/systemBoundary/),zn=jn("END",/end/),Hn=jn("DIRECTION",/direction/),Yn=jn("TD",/TD/),Xn=jn("TB",/TB/),Jn=jn("BT",/BT/),qn=jn("LR",/LR/),Zn=jn("RL",/RL/),Qn=jn("NOTE",/note/),ei=jn("FOR",/for/),ti=jn("JSON",/json/),si=jn("CLASS_DEF",/classDef/),ni=jn("CLASS",/class/),ii=jn("STYLE",/style/),ai=jn("INCLUDE",/include/i),ri=jn("EXTEND",/extend/i),oi=jn("TRUE",/true/),ci=jn("FALSE",/false/),li=Je({name:"GENERALIZATION",pattern:/--\|>/}),hi=Je({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),di=Je({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),ui=Je({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),pi=Je({name:"STEREOTYPE_TEXT",pattern:Rn,line_breaks:!1}),fi=Je({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),mi=Je({name:"CLASS_SEPARATOR",pattern:/:::/}),Ti=Je({name:"FORWARD_SOLID",pattern:/--+>/}),Ei=Je({name:"BACKWARD_SOLID",pattern:/<--+/}),gi=Je({name:"FORWARD_CIRCLE",pattern:/--o/}),yi=Je({name:"BACKWARD_CIRCLE",pattern:/o--/}),Ai=Je({name:"FORWARD_CROSS",pattern:/--x/}),Si=Je({name:"BACKWARD_CROSS",pattern:/x--/}),Li=Je({name:"MARKERLESS_SOLID",pattern:/--+/}),Oi=Je({name:"METADATA_START",pattern:/@{/}),Ri=Je({name:"AT",pattern:/@/,categories:kn}),ki=Je({name:"LBRACE",pattern:/{/}),Ni=Je({name:"RBRACE",pattern:/}/}),Ii=Je({name:"LBRACKET",pattern:/\[/}),bi=Je({name:"RBRACKET",pattern:/]/}),Ci=Je({name:"LPAREN",pattern:/\(/}),vi=Je({name:"RPAREN",pattern:/\)/}),_i=Je({name:"COMMA",pattern:/,/,categories:kn}),xi=Je({name:"COLON",pattern:/:/,categories:kn}),wi=Je({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:kn}),Ui=Je({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),Mi=Je({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:kn}),Pi=Je({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:kn}),Di=Je({name:"DASH",pattern:/-/,categories:kn}),Ki=Je({name:"DOT",pattern:/\./,categories:kn}),$i=Je({name:"PERCENT",pattern:/%/,categories:kn}),Bi=Je({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:kn}),Fi=Je({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:kn}),ji=Je({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:kn}),Gi=[kn,Nn,Cn,vn,_n,xn,wn,Un,Dn,Kn,$n,Gn,Wn,Vn,zn,Hn,Yn,Xn,Jn,qn,Zn,Qn,ei,ti,si,ni,ii,ai,ri,oi,ci,li,hi,di,mi,Ti,Ei,gi,yi,Ai,Si,Li,Oi,Ri,ki,Ni,Ii,bi,Ci,vi,_i,xi,wi,Ui,Mi,bn,In,Pi,Di,Ki,$i,Bi,Fi,ji],Wi={defaultMode:"defaultMode",modes:{defaultMode:[...Gi],jsonBody:[Bn,Fn],stereotype:[ui,pi,fi]}},Vi=[...Gi,Bn,Fn,ui,pi,fi],zi=new Ke(Wi),Hi=(0,d.K)(e=>Qe(e,kn)||e.tokenType===Ui||e.tokenType===vn,"isLabelToken"),Yi={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Xi=new class extends ks{static{(0,d.K)(this,"UsecaseParser")}constructor(){super(Vi,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(Gn),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:(0,d.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:(0,d.K)(()=>this.isStatementStart(),"GATE"),ALT:(0,d.K)(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:(0,d.K)(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:(0,d.K)(()=>this.isMetadataAssignment(),"GATE"),ALT:(0,d.K)(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:(0,d.K)(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:(0,d.K)(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(wn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(qe),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(wn)}),this.RULE("commentLine",()=>{this.CONSUME(xn),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Dn),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Kn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Un),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(Wn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:(0,d.K)(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(_i),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:(0,d.K)(()=>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:(0,d.K)(()=>{this.CONSUME(bn),this.OPTION(()=>{this.CONSUME(Ci),this.SUBRULE(this.nodeLabel),this.CONSUME(vi)})},"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(Wn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(_i),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:(0,d.K)(()=>{this.CONSUME(bn),this.OPTION(()=>{this.OR2([{ALT:(0,d.K)(()=>{this.CONSUME(Ci),this.SUBRULE(this.nodeLabel),this.CONSUME(vi)},"ALT")},{ALT:(0,d.K)(()=>{this.CONSUME(Ii),this.SUBRULE2(this.nodeLabel),this.CONSUME(bi)},"ALT")}])})},"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"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:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"ALT")},{ALT:(0,d.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(kn)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:(0,d.K)(()=>this.LA(1).tokenType===bn&&this.LA(2).tokenType===Ri,"GATE"),DEF:(0,d.K)(()=>{this.CONSUME(bn),this.CONSUME(Ri)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:(0,d.K)(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(Ti)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Ei),this.OPTION({GATE:(0,d.K)(()=>"<--"===this.LA(0).image&&this.hasLabeledRight([Li]),"GATE"),DEF:(0,d.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Li)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Li),this.OPTION({GATE:(0,d.K)(()=>"--"===this.LA(0).image&&this.hasLabeledRight([Ti,Li,gi,Ai]),"GATE"),DEF:(0,d.K)(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Ti),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME2(Li),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(gi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ai),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(gi)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(yi),this.OPTION({GATE:(0,d.K)(()=>this.hasLabeledRight([Li]),"GATE"),DEF:(0,d.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Li)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Ai)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Si),this.OPTION({GATE:(0,d.K)(()=>this.hasLabeledRight([Li]),"GATE"),DEF:(0,d.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Li)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"ALT")},{ALT:(0,d.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(kn)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:(0,d.K)(()=>{this.CONSUME(hi),this.CONSUME(xi),this.OR2([{ALT:(0,d.K)(()=>this.CONSUME(ai),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(ri),"ALT")}])},"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(li),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(Oi),this.MANY(()=>this.CONSUME(wn)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(_i)),this.MANY3(()=>this.CONSUME2(wn))}),this.CONSUME(Ni)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(bn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")}]),this.CONSUME(xi),this.OR2([{ALT:(0,d.K)(()=>this.CONSUME2(bn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME2(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(oi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(ci),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:(0,d.K)(()=>{this.CONSUME(_i),this.MANY(()=>this.CONSUME(wn))},"ALT")},{ALT:(0,d.K)(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(wn)),this.OPTION(()=>this.CONSUME2(_i)),this.MANY2(()=>this.CONSUME3(wn))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(Vn),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(zn),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:(0,d.K)(()=>{this.CONSUME(bn),this.OPTION(()=>{this.OR2([{ALT:(0,d.K)(()=>{this.CONSUME(Ci),this.SUBRULE(this.nodeLabel),this.CONSUME(vi)},"ALT")},{ALT:(0,d.K)(()=>{this.CONSUME(Ii),this.SUBRULE2(this.nodeLabel),this.CONSUME(bi)},"ALT")}])})},"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:(0,d.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:(0,d.K)(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:(0,d.K)(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:(0,d.K)(()=>{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:(0,d.K)(()=>this.CONSUME(bn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vn),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(Qn),this.CONSUME(ei),this.CONSUME(bn),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(di),this.CONSUME(pi),this.CONSUME(ui)}),this.RULE("classSuffix",()=>{this.CONSUME(mi),this.CONSUME(bn),this.MANY(()=>{this.CONSUME(_i),this.CONSUME2(bn)})}),this.RULE("jsonStatement",()=>{this.CONSUME($n),this.CONSUME(Bn),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(Hn),this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Yn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Xn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Jn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(qn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Zn),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(si),this.CONSUME(bn),this.MANY(()=>{this.CONSUME(_i),this.CONSUME2(bn)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(ni),this.CONSUME(bn),this.MANY(()=>{this.CONSUME(_i),this.CONSUME2(bn)}),this.CONSUME3(bn),this.MANY2(()=>{this.CONSUME2(_i),this.CONSUME4(bn)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(ii),this.CONSUME(bn),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(_i),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Nn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Mi),"ALT")},{ALT:(0,d.K)(()=>{this.CONSUME(Li),this.CONSUME2(Nn)},"ALT")}]),this.CONSUME(xi),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:(0,d.K)(()=>this.CONSUME(Nn),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ui),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(In),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(wi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Mi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Pi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Di),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ki),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME($i),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Bi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(xi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ci),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(vi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ii),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(bi),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(ki),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ni),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Ri),"ALT")},{ALT:(0,d.K)(()=>this.CONSUME(Li),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){const e=this.LA(1).tokenType;return(e===bn||e===Ui||e===vn)&&this.LA(2).tokenType===Oi}isStatementStart(){const e=this.LA(1).tokenType;return e!==qe&&e!==wn&&e!==xn}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===bn&&!0===Yi[this.LA(1).image.toLowerCase()]}hasLabeledRight(e){if(!Hi(this.LA(1)))return!1;for(let t=2;;t++){const s=this.LA(t);if(e.includes(s.tokenType))return!0;if(!Hi(s))return!1}}},Ji=class extends Error{constructor(e,t,s){super(`${e} (line ${t}, column ${s})`),this.line=t,this.column=s,this.name="UsecaseJsonError"}static{(0,d.K)(this,"UsecaseJsonError")}},qi=(0,d.K)((e,t,s,n)=>{let i=s,a=n;const r=Math.min(Math.max(t,0),e.length);for(let t=0;t<r;t++){const s=e[t];"\r"===s?(i++,a=1):"\n"===s?0!==t&&"\r"===e[t-1]||(i++,a=1):a++}return{line:i,column:a}},"locationAtOffset"),Zi=(0,d.K)((e,t,s,n)=>{const i=/\bposition (\d+)\b/u.exec(e);if(i)return qi(t,Number.parseInt(i[1],10),s,n);const a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){const e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:s+e-1,column:1===e?n+t-1:t}}return/unexpected end|end of json input/iu.test(e)?qi(t,t.length,s,n):void 0},"locationFromErrorMessage"),Qi=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}static{(0,d.K)(this,"JsonWalkError")}},ea=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{(0,d.K)(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new Qi(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();const t=this.text[this.offset];if("{"===t)this.collectObject(e);else if("["===t)this.collectArray(e);else if('"'===t)this.readString(!1);else if("t"===t)this.consumeLiteral("true");else if("f"===t)this.consumeLiteral("false");else if("n"===t)this.consumeLiteral("null");else{if(!("-"===t||t>="0"&&t<="9"))throw new Qi(this.offset);this.consumeNumber()}}collectObject(e){this.offset++;const t=[],s=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),"}"!==this.text[this.offset]){for(;this.offset<this.text.length;){if('"'!==this.text[this.offset])throw new Qi(this.offset);const n=this.readString(!0),i=`${e}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;if(s.has(n)?this.deletePointerSubtree(i):(s.add(n),t.push(n)),this.skipWhitespace(),":"!==this.text[this.offset])throw new Qi(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])throw new Qi(this.offset);this.offset++,this.skipWhitespace()}throw new Qi(this.offset)}this.offset++}collectArray(e){if(this.offset++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])throw new Qi(this.offset);this.offset++,this.skipWhitespace()}throw new Qi(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){const s=this.offset,n=this.text[this.offset++];if('"'===n)return t;if(n.charCodeAt(0)<32)throw new Qi(s);if("\\"!==n){e&&(t+=n);continue}const i=this.offset,a=this.text[this.offset++];switch(a){case'"':case"\\":case"/":e&&(t+=a);break;case"b":e&&(t+="\b");break;case"f":e&&(t+="\f");break;case"n":e&&(t+="\n");break;case"r":e&&(t+="\r");break;case"t":e&&(t+="\t");break;case"u":{const s=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(s))throw new Qi(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(s,16))),this.offset+=4;break}default:throw new Qi(i)}}throw new Qi(this.offset)}consumeLiteral(e){let t=0;for(const s of e){if(this.text[this.offset+t]!==s)throw new Qi(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if("-"===this.text[this.offset]&&this.offset++,"0"===this.text[this.offset])this.offset++;else{if(!(this.text[this.offset]>="1"&&this.text[this.offset]<="9"))throw new Qi(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if("."===this.text[this.offset]){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new Qi(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if("e"===this.text[this.offset]||"E"===this.text[this.offset]){if(this.offset++,"+"!==this.text[this.offset]&&"-"!==this.text[this.offset]||this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new Qi(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){const e=this.text[this.offset];if(" "!==e&&"\t"!==e&&"\n"!==e&&"\r"!==e)return;this.offset++}}deletePointerSubtree(e){const t=`${e}/`;for(const s of Object.keys(this.propertyOrder))(s===e||s.startsWith(t))&&delete this.propertyOrder[s]}};function ta(e,t,s){let n;try{n=JSON.parse(e)}catch(n){const i=n instanceof Error?n.message:String(n);let a=Zi(i,e,t,s);if(!a){let n=0;try{new ea(e).collect()}catch(e){e instanceof Qi&&(n=e.offset)}a=qi(e,n,t,s)}throw new Ji(`Invalid JSON: ${i}`,a.line,a.column)}if("object"!=typeof n||null===n||Array.isArray(n))throw new Ji("JSON value must have an object root",t,s);return{value:n,propertyOrder:new ea(e).collect()}}(0,d.K)(ta,"parseOrderedJsonObject");var sa=(0,d.K)(e=>({shape:"normal"===e.type?"actor":"hollow"===e.type?"actor-hollow":"awesome"===e.type?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),na=(0,d.K)(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),ia=(0,d.K)(e=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),aa=(0,d.K)(e=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),ra=(0,d.K)(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),oa=(0,d.K)(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:_s,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),ca=(0,d.K)((e,t,s,n)=>{const i={};for(const t of e.getActors().values())i[t.id]=sa(t);for(const t of e.getUseCases().values())i[t.id]=na(t);for(const t of e.getNotes().values())i[t.id]=ia(t);for(const t of e.getJsonNodes().values())i[t.id]=aa(t);const a={};for(const t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:t.type,labelType:t.labelType}};const r={};for(const t of e.getClassDefs().values())r[t.id]={styles:[...t.styles]};const o=e.getDirection();return{version:1,diagramType:"usecase",source:t,header:{keyword:"usecase",direction:"TD"===o?"TB":o,span:s},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:i,edges:[...e.getRelationships().map(ra),...[...e.getNotes().values()].map(oa)],groups:a,classDefs:r,statements:n}},"buildUsecaseGraphAST"),la=(0,d.K)(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),ha=(0,d.K)(e=>void 0===e?"":` (label "${e}")`,"labelSuffix"),da=(0,d.K)(e=>e.generated?e.label:void 0,"generatedFrom"),ua=(0,d.K)((e,t)=>{for(const s of t)e.includes(s)||e.push(s)},"pushUnique"),pa=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{(0,d.K)(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,s,n){this.metadataAssignments.push({target:e,targetLocation:t,metadata:s,statement:n})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,s){this.styleAssignments.push({target:e,location:t,styles:s})}setDirection(e){this.directions.push("TD"===e?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){const t=new Map,s=new Map,n=new Map,i=new Map;for(const e of this.relationshipDrafts)this.recordFirst(i,e.source.id,e.source.location.span[0]),this.recordFirst(i,e.target.id,e.target.location.span[0]);for(const e of this.elements)this.recordFirst(i,e.id,e.location.span[0]);for(const e of this.boundaries)this.recordFirst(i,e.id,e.location.span[0]);for(const e of this.jsonDrafts)this.recordFirst(i,e.id,e.location.span[0]);const a=[...this.elements.map(e=>({offset:e.location.span[0],type:"element",value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:"boundary",value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:"json",value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:"edge",value:e}))].sort((e,t)=>e.offset-t.offset);for(const e of a)"element"===e.type?this.collectElement(e.value,t,s):"boundary"===e.type?this.collectBoundary(e.value,t,n):"json"===e.type?this.registerUnique(t,e.value.id,"json",e.value.location,!1):this.registerUnique(t,e.value.explicitId,"edge",e.value.explicitIdLocation,!1);this.materializeElements(s,i),this.materializeBoundaries(n,i),this.materializeJson(i);const r=this.materializeRelationships(t,s,i);this.reorderElements(s,i),this.applyMetadataAssignments(t,s,n,r),this.validateAndRefreshElements(s),this.refreshBoundaries(n,s),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,r),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));const o=ca(this,this.source,e,this.statements);return this.model.ast=o,this.db.commit(this.model),o}collectElement(e,t,s){const n=t.get(e.id),i=da({generated:e.generated,label:e.label.text});n&&n.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${n.kind} and ${e.kind}`,e.location,n.location,i,da(n)),n&&(n.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,n.location,i,da(n));const a=s.get(e.id);if(!a){const n={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};return this.applyDeclarationMetadata(n,e.metadata),s.set(e.id,n),void t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text})}a.label.text===e.label.text&&a.label.type===e.label.type||this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,ua(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,t,s){const n=t.get(e.id),i=da({generated:e.generated,label:e.label.text});n&&"boundary"!==n.kind&&this.conflict(`ID '${e.id}' is declared as both ${n.kind} and boundary`,e.location,n.location,i,da(n)),n&&(n.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,n.location,i,da(n));const a=s.get(e.id);if(a)return a.label.text===e.label.text&&a.label.type===e.label.type||this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),void ua(a.classes,e.classes);s.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(const s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.setElementModel(s)}materializeBoundaries(e,t){for(const s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.model.systemBoundaries.set(s.id,{id:s.id,label:s.label.text,labelType:s.label.type,type:s.type??"rect",members:[],classes:[...s.classes],styles:[...s.styles]})}materializeJson(e){for(const t of[...this.jsonDrafts].sort((t,s)=>(e.get(t.id)??0)-(e.get(s.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,s){const n=new Map;let i=0;for(const a of this.relationshipDrafts){const r=this.resolveEndpoint(a.source,e,t,s),o=this.resolveEndpoint(a.target,e,t,s);this.validateRelationship(a,r,o,e);const c=a.explicitId??"edge-"+i++,l={id:c,explicitId:Boolean(a.explicitId),source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(l),n.set(c,{draft:a,relationship:l})}return this.model.relationshipCounter=i,n}resolveEndpoint(e,t,s,n){if(e.classesOnReference&&!e.declaration)throw new Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${la(e.location)}`);const i=t.get(e.id);return i?i.kind:(s.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),t.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(n,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){const s=new Map(this.model.actors),n=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(const i of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0))){s.has(i.id)||n.has(i.id)||this.setElementModel(i);const e=s.get(i.id)??this.model.actors.get(i.id),t=n.get(i.id)??this.model.useCases.get(i.id);e?this.model.actors.set(i.id,e):t&&this.model.useCases.set(i.id,t)}}applyMetadataAssignments(e,t,s,n){for(const i of this.metadataAssignments){const a=e.get(i.target);if(!a){const e=this.inferMetadataKind(i.metadata);throw new Error(`Metadata target '${i.target}' is unresolved${e?` (metadata implies ${e})`:""} at ${la(i.targetLocation)}`)}if("actor"===a.kind||"usecase"===a.kind)this.applyStandaloneElementMetadata(t.get(i.target),i.metadata);else if("boundary"===a.kind){const e=s.get(i.target);for(const t of i.metadata.properties)("type"!==t.key||"rect"!==t.value&&"package"!==t.value)&&this.invalidMetadata(i.target,a.kind,t),e.type=t.value}else if("edge"===a.kind){const e=n.get(i.target);if(!e)throw new Error(`Metadata target '${i.target}' is not an explicit edge at ${la(i.targetLocation)}`);i.statement.kind="edgeMetadata",i.statement.edges=[{id:i.target,span:i.statement.span,idSpan:i.targetLocation.span,...i.statement.metadata?{metadata:i.statement.metadata}:{}}],delete i.statement.nodes;for(const t of i.metadata.properties)"animate"===t.key&&"boolean"==typeof t.value?e.relationship.animate=t.value:"animation"!==t.key||"fast"!==t.value&&"slow"!==t.value?this.invalidMetadata(i.target,a.kind,t):(e.relationship.animation=t.value,e.relationship.animate=!0)}else for(const e of i.metadata.properties)this.invalidMetadata(i.target,a.kind,e)}for(const{relationship:e}of n.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(const s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!0):"business"===s.key&&"boolean"==typeof s.value?e.business=s.value:this.invalidMetadata(e.id,e.kind,s)}applyDeclarationMetadata(e,t){if(t)for(const s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!1):"business"===s.key&&"boolean"==typeof s.value?(void 0!==e.business&&e.business!==s.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,s.location,e.location),e.business=s.value):this.invalidMetadata(e.id,e.kind,s)}applyActorProperty(e,t,s){"type"!==t.key||"normal"!==t.value&&"hollow"!==t.value&&"awesome"!==t.value?"icon"===t.key&&"string"==typeof t.value?(s||void 0===e.icon||e.icon===t.value||this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):"business"===t.key&&"boolean"==typeof t.value?(s||void 0===e.business||e.business===t.value||this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t):(s||void 0===e.actorType||e.actorType===t.value||this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value)}validateAndRefreshElements(e){for(const t of e.values()){const e=t.icon?"icon":t.actorType??"normal";if("actor"===t.kind){if(t.icon&&t.actorType&&"normal"!==t.actorType)throw new Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${la(t.location)}`);if(t.business&&("icon"===e||"awesome"===e))throw new Error(`Business actor '${t.id}' must use normal or hollow geometry at ${la(t.location)}`)}else if("rect"===(t.shape??"ellipse")&&t.business)throw new Error(`Rectangular use case '${t.id}' cannot be a business use case at ${la(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(const t of e.values())t.members.length=0;for(const t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;const s=e.get(t.parentId);if(!s)throw new Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${la(t.parentLocation??t.location)}`);s.members.includes(t.id)||s.members.push(t.id)}for(const s of t.values())if(s.parentId&&!e.has(s.parentId))throw new Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${la(s.parentLocation??s.location)}`);for(const t of e.values()){const e=this.model.systemBoundaries.get(t.id);e.type=t.type??"rect",e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(const s of this.noteDrafts){const n=e.get(s.target);if(!n)throw new Error(`Note target '${s.target}' is unresolved at ${la(s.targetLocation)}`);"actor"!==n.kind&&"usecase"!==n.kind&&this.conflict(`Note target '${s.target}' must be an actor or use case, not ${n.kind}`,s.targetLocation,n.location);const i="note-"+t++;this.model.notes.set(i,{id:i,target:s.target,label:s.label.text,labelType:s.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(const e of this.classDefinitions)for(const t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(const s of this.classAssignments)for(const n of s.targets)ua(this.getStylable(n.id,e,t,n.location).classes,s.classes);for(const s of this.styleAssignments)this.getStylable(s.target,e,t,s.location).styles.push(...s.styles)}getStylable(e,t,s,n){const i=t.get(e)?.kind,a="actor"===i?this.model.actors.get(e):"usecase"===i?this.model.useCases.get(e):"boundary"===i?this.model.systemBoundaries.get(e):"json"===i?this.model.jsonNodes.get(e):"edge"===i?s.get(e)?.relationship:void 0;if(!a)throw new Error(`Class/style target '${e}' is unresolved or anonymous at ${la(n)}`);return a}validateRelationship(e,t,s,n){const i=(0,d.K)(e=>"actor"===e||"usecase"===e||"json"===e,"allowed");if(i(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,n.get(e.source.id).location),i(s)||this.conflict(`Relationship target '${e.target.id}' cannot be ${s}`,e.target.location,n.get(e.target.id).location),!("include"!==e.type&&"extend"!==e.type||"usecase"===t&&"usecase"===s))throw new Error(`${e.type} relationship requires use-case endpoints at ${la(e.location)}`);if("generalization"===e.type&&("actor"!==t&&"usecase"!==t||t!==s))throw new Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${la(e.location)}`);if("association"===e.type&&("json"===t||"json"===s)&&![0,1,2].includes(e.arrowType))throw new Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${la(e.location)}`)}setElementModel(e){if("actor"===e.kind){const t=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){const t=new Set(["actor","usecase","boundary","edge"]);for(const s of e.properties)if("icon"===s.key)t.clear(),t.add("actor");else if("animate"===s.key||"animation"===s.key)t.clear(),t.add("edge");else if("type"===s.key)t.clear(),"rect"===s.value||"package"===s.value?t.add("boundary"):"normal"!==s.value&&"hollow"!==s.value&&"awesome"!==s.value||t.add("actor");else{if("business"!==s.key)return;t.delete("boundary"),t.delete("edge")}return 1===t.size?[...t][0]:void 0}invalidMetadata(e,t,s){throw new Error(`Metadata property '${s.key}' is invalid for ${t} '${e}' at ${la(s.location)}`)}registerUnique(e,t,s,n,i){const a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${s})`,n,a.location,void 0,da(a)),e.set(t,{kind:s,location:n,generated:i})}recordFirst(e,t,s){const n=e.get(t);(void 0===n||s<n)&&e.set(t,s)}conflict(e,t,s,n,i){throw new Error(`${e} at ${la(t)}${ha(n)}; previous declaration at ${la(s)}${ha(i)}`)}},fa=Xi.getBaseCstVisitorConstructor(),ma=class extends fa{constructor(){super(),this.builder=new pa(Tn),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{(0,d.K)(this,"UsecaseVisitor")}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){const t=this.tokens(e,"USECASE")[0],s=[];for(const t of this.nodes(e,"line"))s.push(this.visit(t));this.builder.setStatements(s),this.builder.finalize(this.tokenSpan(t))}line(e){const t=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){const t=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){const t=this.tokens(e,"ACC_DESCR_LINE")[0],s=this.tokens(e,"ACC_DESCR_BLOCK")[0],n=t?t.image.slice(t.image.indexOf(":")+1).trim():s.image.slice(s.image.indexOf("{")+1,s.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(n),{kind:"accDescr",span:[0,0]}}actorStatement(e){const t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e)),n=this.nodes(e,"relationTail")[0],i=s.map((e,s)=>this.actorOccurrence(t[s],e,!0));for(const e of s)this.builder.addElement(this.actorDraft(e));if(!n)return{kind:"node",span:[0,0],nodes:i};const a=this.visit(n);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));const r=this.relationshipDraft(s[0],a,this.nodeLocation(n));this.builder.addRelationship(r);const o=r.explicitId??"edge-"+this.anonymousEdge++;return i.push(this.entityOccurrence(this.nodes(n.children,"entityName")[0],a.target,a.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:i,edges:[{id:o,span:[0,0],...r.explicitIdLocation?{idSpan:r.explicitIdLocation.span}:{},...r.label?{labelSpan:r.label.span}:{}}]}}actorItem(e){const t=this.visit(this.nodes(e,"actorName")[0]),s=this.nodes(e,"metadata")[0],n=this.nodes(e,"stereotype")[0],i=this.nodes(e,"classSuffix")[0],a=i?this.visit(i):{classes:[],spans:[]};return{...t,...s?{metadata:this.visit(s)}:{},...n?{stereotype:this.visit(n)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){const t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(t){const s=this.nodes(e,"nodeLabel")[0],n=s?this.visit(s):this.tokenLabel(t);return{id:t.image,label:n,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}const n=this.tokenLabel(s);return{id:this.generateId(n.text),label:n,location:this.tokenLocation(s),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){const t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e));for(const e of s)this.builder.addElement(this.actorDraft(e));return{kind:"node",span:[0,0],nodes:s.map((e,s)=>this.actorOccurrence(t[s],e,!0))}}entityStatement(e){const t=this.nodes(e,"entityName"),s=this.visit(t[0]),n=this.nodes(e,"relationTail")[0];if(!n)return s.explicitDeclaration=!0,s.shape??="ellipse",this.builder.addElement(this.entityDraft(s)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(t[0],s,!0)]};s.explicitDeclaration&&this.builder.addElement(this.entityDraft(s));const i=this.visit(n);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));const a={source:this.endpoint(s),target:this.endpoint(i.target),location:this.nodeLocation(n),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(a);const r=a.explicitId??"edge-"+this.anonymousEdge++;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(t[0],s,s.explicitDeclaration),this.entityOccurrence(this.nodes(n.children,"entityName")[0],i.target,i.target.explicitDeclaration)],edges:[{id:r,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){const t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],n=this.nodes(e,"nodeLabel")[0],i=this.nodes(e,"useCaseMetadata")[0],a=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};if(t){const s=n?this.visit(n):this.tokenLabel(t),r=n?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:t.image,label:s,location:this.tokenLocation(t),generated:!1,...r?{shape:r}:{},...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:Boolean(r||i||a)}}const c=this.tokenLabel(s);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(s),generated:!0,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:Boolean(i||a)}}nodeLabel(e){const t=this.allTokens(e);if(1===t.length&&("PLAIN_STRING"===t[0].tokenType.name||"MARKDOWN_STRING"===t[0].tokenType.name))return this.tokenLabel(t[0]);const s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(s[0],s[1]),type:"text",span:s}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){const t=this.tokens(e,"IDENTIFIER")[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:Cs,minlen:1};const t=this.tokens(e,"INCLUDE").length?"include":"extend",s=this.tokens(e,"include"===t?"INCLUDE":"EXTEND")[0];return{type:t,arrowType:Cs,label:{text:t,type:"text",span:this.tokenSpan(s)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){const t=this.allTokens(e).filter(e=>"COLON"!==e.tokenType.name),s=t[0],n=t[1],i="TRUE"===n.tokenType.name||"FALSE"!==n.tokenType.name&&this.decodePlain(n),a=[s.startOffset,(n.endOffset??n.startOffset)+1];return{key:this.decodePlain(s),value:i,span:a,keySpan:this.contentSpan(s),valueSpan:this.contentSpan(n),location:this.tokenLocation(s)}}metadataSeparator(e){}systemBoundaryStatement(e){const t=this.visit(this.nodes(e,"systemBoundaryName")[0]),s=this.nodes(e,"classSuffix")[0],n=s?this.visit(s):{classes:[],spans:[]};t.classes=n.classes,this.builder.addBoundary(t);const i=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};const a=this.nodes(e,"systemBoundaryContent")[0],r=a?this.visit(a):[];this.parentBoundary=i;const o=this.tokens(e,"END")[0],c=this.nodes(e,"metadata")[0],l=c?this.visit(c):void 0,h={kind:"group",span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(o),classSpans:n.spans,...l?{metadata:l.properties.map(({key:e,span:t,keySpan:s,valueSpan:n})=>({key:e,span:t,keySpan:s,valueSpan:n}))}:{},...r.length?{children:r}:{}};return l&&this.builder.addMetadataAssignment(t.id,t.location,l,h),h}systemBoundaryName(e){const t=this.tokens(e,"IDENTIFIER")[0];if(t){const s=this.nodes(e,"nodeLabel")[0];return{id:t.image,label:s?this.visit(s):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}const s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],n=this.tokenLabel(s);return{id:this.generateId(n.text),label:n,location:this.tokenLocation(s),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){const t=this.nodes(e,"actorDeclarationOnly")[0];if(t)return this.visit(t);const s=this.nodes(e,"entityName")[0],n=this.visit(s);return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s,n,!0)]}}metadataAssignmentStatement(e){const t=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),s=this.visit(this.nodes(e,"metadata")[0]),n={kind:"metadata",span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:s.properties.map(({key:e,span:t,keySpan:s,valueSpan:n})=>({key:e,span:t,keySpan:s,valueSpan:n}))};return this.builder.addMetadataAssignment(t.id,t.location,s,n),n}metadataAssignmentTarget(e){const t=this.allTokens(e)[0],s=this.tokenLabel(t);return{id:"IDENTIFIER"===t.tokenType.name?t.image:this.generateId(s.text),location:this.tokenLocation(t)}}noteStatement(e){const t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:s,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:"note-"+this.anonymousNote++,refSpan:s.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){const t=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){const t=this.tokens(e,"IDENTIFIER");return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){const t=this.tokens(e,"JSON_DECLARATION_START")[0],s=this.tokens(e,"JSON_OBJECT_LITERAL")[0],n=/^json[\t ]+(\w+)/.exec(t.image),i=n[1],a=n[0].length-i.length,r={span:[t.startOffset+a,t.startOffset+a+i.length],line:t.startLine??1,column:(t.startColumn??1)+a},o=ta(s.image,s.startLine??1,s.startColumn??1),c=this.nodes(e,"classSuffix")[0],l=c?this.visit(c):{classes:[],spans:[]},h={id:i,value:o.value,propertyOrder:o.propertyOrder,location:r,classes:l.classes};return this.builder.addJson(h),{kind:"json",span:[0,0],nodes:[{id:i,span:r.span,idSpan:r.span,defines:!0,classSpans:l.spans}],classSpans:l.spans}}directionStatement(e){const t=this.allTokens(e).find(e=>["TD","TB","BT","RL","LR"].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:"direction",span:[0,0]}}classDefStatement(e){const t=this.tokens(e,"IDENTIFIER"),s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(t.map(e=>e.image),s),{kind:"classDef",span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){const t=this.tokens(e,"IDENTIFIER");let s=1;for(;s<t.length;s++){if(!this.source.slice((t[s-1].endOffset??t[s-1].startOffset)+1,t[s].startOffset).includes(","))break}const n=t.slice(0,s).map(e=>({id:e.image,location:this.tokenLocation(e)})),i=t.slice(s).map(e=>e.image);return this.builder.addClassAssignment(n,i),{kind:"classAssign",span:[0,0],ref:i[0],refSpan:this.tokenSpan(t[s]),nodes:n.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){const t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),s),{kind:"style",span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,"styleValue").map(e=>this.visit(e))}styleValue(e){const t=this.allTokens(e),s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(s[0],s[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(e=>e.image).join("")}forwardSolidOperator(e){const t=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:Cs,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){const t=this.tokens(e,"BACKWARD_SOLID")[0],s=this.nodes(e,"edgeLabel")[0],n=s?this.tokens(e,"MARKERLESS_SOLID").at(-1):t;return{type:"association",arrowType:vs,minlen:this.solidMinlen(n),...s?{label:this.visit(s)}:{}}}markerlessSolidOperator(e){const t=this.nodes(e,"edgeLabel")[0],s=this.allTokens(e);if(!t)return{type:"association",arrowType:_s,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};const n=s.at(-1),i="FORWARD_SOLID"===n.tokenType.name?Cs:"FORWARD_CIRCLE"===n.tokenType.name?xs:"FORWARD_CROSS"===n.tokenType.name?ws:_s;return{type:"association",arrowType:i,label:this.visit(t),minlen:i===Cs||i===_s?this.solidMinlen(n):1}}forwardCircleOperator(e){return{type:"association",arrowType:xs,minlen:1}}backwardCircleOperator(e){const t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:Us,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:ws,minlen:1}}backwardCrossOperator(e){const t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:Ms,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:"actor",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:"usecase",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,s){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:s,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,s){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...s?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:s,valueSpan:n})=>({key:e,span:t,keySpan:s,valueSpan:n}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,s){return this.actorOccurrence(e,t,s)}wrap(e,t){if("blank"===t.kind||"comment"===t.kind)return t;t.span=this.nodeSpan(e);for(const e of t.edges??[])e.span=t.span;return t}tokenLabel(e){const t="MARKDOWN_STRING"===e.tokenType.name?"markdown":"text",s="markdown"===t?2:"PLAIN_STRING"===e.tokenType.name?1:0,n=this.tokenSpan(e,s);return{text:this.source.slice(n[0],n[1]),type:t,span:n}}decodePlain(e){return"PLAIN_STRING"===e.tokenType.name?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,"PLAIN_STRING"===e.tokenType.name?1:"MARKDOWN_STRING"===e.tokenType.name?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){const t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){const t=this.allTokens(e).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],n=t.at(-1);return{span:[s.startOffset,Math.min(this.source.length,(n.endOffset??n.startOffset+n.image.length-1)+1)],line:s.startLine??1,column:s.startColumn??1}}tokenLocation(e){const t="PLAIN_STRING"===e.tokenType.name?1:"MARKDOWN_STRING"===e.tokenType.name?2:0;return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){const t=this.allTokens(e.children).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],n=t.at(-1);if(!s||!n)throw new Error("Usecase CST node has no source token");return[s.startOffset,Math.min(this.source.length,(n.endOffset??n.startOffset+n.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>"children"in e)}tokens(e,t){return(e[t]??[]).filter(e=>"tokenTypeIdx"in e)}firstNode(e,...t){for(const s of t){const t=this.nodes(e,s)[0];if(t)return t}throw new Error(`Usecase CST is missing one of: ${t.join(", ")}`)}allTokens(e){const t=[];for(const s of Object.values(e))for(const e of s)"tokenTypeIdx"in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},Ta=new ma,Ea={parse:(0,d.K)(async e=>{Tn.clear(),Xi.input=[];try{bs({diagramType:"usecase",lexer:zi,parser:Xi,entry:(0,d.K)(()=>Xi.start(),"entry"),visit:(0,d.K)(t=>Ta.build(t,e),"visit")},e)}catch(t){Tn.clear();const s=Xi.errors[0];if(s){const{token:n}=s,i=Is(n.startOffset)?n.startOffset:e.length,a=Is(n.endOffset)?n.endOffset+1:i,r=Is(n.startLine)?n.startLine:e.slice(0,i).split(/\r\n|\r|\n/).length,o=Math.max(e.lastIndexOf("\n",i-1),e.lastIndexOf("\r",i-1)),c=Is(n.startColumn)?n.startColumn:i-o,l=t instanceof Error?t.message:String(t);throw new Error(`${l} at line ${r}, column ${c} [${i},${a})`)}throw t}},"parse")},ga=["point","circle","cross","extension"],ya={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Aa=(0,d.K)((e,t)=>{const[s,n]=[e,t].map(e=>e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${s}-${n}`},"usecaseDomId"),Sa=(0,d.K)(e=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),La=(0,d.K)((e,t)=>"markdown"!==t?e:(0,r.O6)(e).map(e=>e.map(e=>e.content).join(" ")).join("\n"),"getAccessibleLabel"),Oa=(0,d.K)(e=>{const t=La(e.label??e.id,e.labelType);if(ya[e.shape]){const s=e.actorType&&"normal"!==e.actorType?`${e.actorType} `:"";return`${e.business?"business ":""}${s}actor ${t}${e.stereotype?`, stereotype ${e.stereotype}`:""}`}if("note"===e.shape)return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${t}`;if("usecaseJsonTable"===e.shape){const s=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join("; ");return s?`${t}: ${s}`:t}const s=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${t}${s}`},"getUsecaseNodeAccessibleName"),Ra=(0,d.K)(e=>`${e.boundaryType} system boundary ${La(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),ka=(0,d.K)(e=>{if("note"===e.relationshipType)return"";return`${"association"===e.relationshipType&&e.label?`association ${La(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),Na=(0,d.K)(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Ia=(0,d.K)(e=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),ba=(0,d.K)((e,t)=>{e.diagramId=t,e.markers=[...ga];for(const t of e.nodes){const e=t;if(e.domId=Sa(t.id),void 0!==t.label&&"text"===t.labelType&&(t.label=Na(t.label)),t.stereotype&&(t.stereotype=Na(t.stereotype)),t.isGroup||"usecaseJsonTable"!==t.shape||(t.jsonRows=t.jsonRows?.map(e=>({...e,key:Na(e.key),value:Na(e.value)}))),!t.isGroup&&("usecaseEllipse"===t.shape||"rect"===t.shape)&&t.stereotype){const s=t.label??Na(t.id);t.label=`«${Ia(t.stereotype)}»<br/>${"text"===t.labelType?Ia(s):s}`,t.labelType="markdown",e.hasFoldedStereotype=!0,delete t.stereotype}}for(const t of e.edges)void 0!==t.label&&"text"===t.labelType&&(t.label=Na(t.label));return e},"prepareUsecaseLayoutData"),Ca=(0,d.K)((e,t,s)=>{for(const n of t.nodes){const i="string"==typeof n.domId?n.domId:Aa(t.diagramId,n.id),a=e.select(`#${i}`),r=n.isGroup?"boundary":ya[n.shape]?"actor":"note"===n.shape?"note":"usecaseJsonTable"===n.shape?"json":"usecase",o=s.nodes.get(n.id)??n.id;if(a.attr("data-usecase-id",n.id).attr("data-usecase-kind",r).attr("role","img").attr("aria-label",o),!n.isGroup&&("usecaseEllipse"===n.shape||"rect"===n.shape)&&"hasFoldedStereotype"in n&&!0===n.hasFoldedStereotype){const e=a.node(),t=e?.querySelector(".nodeLabel"),s=t?.querySelector("p")??t,n=s?.firstChild;if(s&&3===n?.nodeType){const e=s.ownerDocument.createElement("span");e.className="usecase-stereotype",s.insertBefore(e,n),e.appendChild(n)}else e?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}const n=new Map(t.edges.map(e=>[e.id,e]));e.selectAll('path[data-et="edge"]').each(function(){const e=n.get(this.getAttribute("data-id")??"");if(!e)return;const i=(0,Ns.Ltv)(this);i.attr("id",Aa(t.diagramId,e.id)).attr("data-usecase-id",e.id).attr("data-usecase-kind",e.internal?"note-connector":"relationship"),e.internal?i.attr("aria-hidden","true"):i.attr("role","img").attr("aria-label",s.edges.get(e.id)??e.id)})},"annotateUsecaseElements"),va=(0,d.K)((e,t)=>{e.style("--mermaid-usecase-actor-font-size",`${t.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",t.actorFontFamily).style("--mermaid-usecase-actor-font-weight",t.actorFontWeight).style("--mermaid-usecase-font-size",`${t.usecaseFontSize}px`).style("--mermaid-usecase-font-family",t.usecaseFontFamily).style("--mermaid-usecase-font-weight",t.usecaseFontWeight)},"applyUsecaseFonts"),_a={draw:(0,d.K)(async(e,t,s,r)=>{h.R.info("Drawing usecase diagram (unified)",t);const{layout:o}=(0,l.D7)(),d=r.db,u=d.getData(),p=new Map(u.nodes.map(e=>[e.id,La(e.label??e.id,e.labelType)])),f={nodes:new Map(u.nodes.map(e=>[e.id,e.isGroup?Ra(e):Oa("note"===e.shape?{...e,noteTargetLabel:p.get(e.noteTarget??"")}:e)])),edges:new Map(u.edges.map(e=>[e.id,ka({...e,sourceLabel:p.get(e.source)??e.sourceLabel,targetLabel:p.get(e.target)??e.targetLabel})]))},m=(0,n.A)(t,u.config.securityLevel);u.layoutAlgorithm=(0,a.q7)(o),ba(u,t),va(m,u),await(0,a.XX)(u,m),Ca(m,u,f);const T=u.diagramPadding;c._K.insertTitle(m,"usecaseDiagramTitleText",0,d.getDiagramTitle?.()??""),(0,i.P)(m,T,"usecaseDiagram",u.useMaxWidth),va(m,u)},"draw")},xa=(0,d.K)(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),wa=(0,d.K)(e=>{const{theme:t,bkgColorArray:s,borderColorArray:n}=e;if(!(0,o.P1)(t,n))return"";const i="rotate"===(0,l.zj)().usecase?.colorScheme,a=(0,o.rq)(e.look),r="handDrawn"===a,c=(0,o.Ic)(s);let h="";for(let e=0;e<(0,o.Hu)(n);e++){const t=n[e],o=c?`fill: ${s[e%s.length]};`:"",l=`[data-look="${a}"][data-color-id="color-${e}"]`;h+=`\n\n & ${l}.system-boundary rect.boundary-body,\n & ${l}.system-boundary rect.boundary-tab,\n & ${l}.system-boundary .boundary-body path,\n & ${l}.system-boundary .boundary-tab path {\n stroke: ${t};\n ${o}\n }\n `,i&&(h+=`\n\n /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and\n the business variant.\n\n Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws\n the body as a *pair* of paths, an outline stroked in the border colour and a hachure\n fill stroked in the background colour, with no class to tell them apart. Stroking\n both repaints the fill lines as border colour and the shape collapses into a solid\n block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the\n theme's uniform colours, exactly as handDrawn flowchart nodes do. */\n & ${l}.usecase-element ellipse,\n & ${l}.usecase-element rect {\n stroke: ${t};\n ${o}\n }\n\n /* The business marker is a single classed path, so it can be reached safely by name --\n without it the marker keeps the uniform border beside a palette-coloured body. No\n \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */\n & ${l}.usecase-element .usecase-business-marker {\n stroke: ${t};\n }\n\n /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph\n group, never on its children, so the hollow variant's own \`fill="none"\` keeps\n winning and a hollow actor stays hollow. Same reason as above for not descending\n into the handDrawn paths. */\n & ${l}.usecase-actor .usecase-actor-shape,\n & ${l}.usecase-actor .usecase-actor-hollow,\n & ${l}.usecase-actor .usecase-actor-awesome,\n & ${l}.usecase-actor .usecase-actor-icon {\n stroke: ${t};\n ${o}\n }\n${r?"":`\n /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it\n ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,\n and a value set directly on the child always beats one inherited from the parent,\n whatever the parent rule's specificity. So name the children too.\n\n Emitted for every look *except* handDrawn, where roughjs draws the glyph as an\n outline path plus a hachure fill path stroked in the fill colour, indistinguishable\n in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no\n \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */\n & ${l}.usecase-actor .usecase-actor-glyph path,\n & ${l}.usecase-actor .usecase-actor-glyph circle {\n stroke: ${t};\n }\n`}\n `)}return h},"genColor"),Ua={parser:Ea,db:Tn,renderer:_a,styles:(0,d.K)(e=>{const t=xa(e),s="handDrawn"===(0,o.rq)(e.look);return`\n ${wa(e)}\n & .usecase-actor {\n color: ${e.actorTextColor??e.primaryTextColor};\n }\n\n & .usecase-actor-shape,\n & .usecase-actor-hollow,\n & .usecase-actor-awesome,\n & .usecase-actor-icon {\n fill: ${t.actorBkg};\n stroke: ${t.actorBorder};\n stroke-width: 2px;\n }\n${s?"":`\n /* The rule above colours the glyph group and lets its children inherit, which the neo\n look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on\n the glyph's own paths, and a value set directly on a child always beats one inherited\n from its parent, whatever the parent rule's specificity. Since neo is the default look,\n without this every actor renders in the node border colour rather than the actor\n colour the rule above asks for.\n\n \`.node\` is in the selector to outrank that neo rule rather than tie with it: both\n would otherwise be one attribute plus one class plus one element, leaving the winner to\n depend on which stylesheet is concatenated last.\n\n Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */\n & .node.usecase-actor .usecase-actor-glyph path,\n & .node.usecase-actor .usecase-actor-glyph circle {\n stroke: ${t.actorBorder};\n }\n`}\n & .usecase-actor .nodeLabel,\n & .actor-label {\n color: ${e.actorTextColor??e.primaryTextColor};\n fill: ${e.actorTextColor??e.primaryTextColor};\n font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});\n font-size: var(--mermaid-usecase-actor-font-size, 14px);\n font-weight: var(--mermaid-usecase-actor-font-weight, normal);\n }\n\n & .usecase-element ellipse,\n & .usecase-element rect,\n & .usecase-business ellipse,\n & .usecase-business rect {\n fill: ${t.bkg};\n stroke: ${t.border};\n stroke-width: 2px;\n }\n${s?"":`\n /* The same interception the actor glyph hits, one element down: neo ships\n \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain\n \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node\n border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no\n equivalent neo rule and is already correct; restating it here costs nothing and means\n the two forms cannot drift apart again.\n\n Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than\n tie with it -- on a tie the later stylesheet would win, which is how neo took this in\n the first place. Skipped under handDrawn, where roughjs draws paths and neither element\n exists. */\n & [data-look="${(0,o.rq)(e.look)}"].node.usecase-element ellipse,\n & [data-look="${(0,o.rq)(e.look)}"].node.usecase-element rect {\n fill: ${t.bkg};\n stroke: ${t.border};\n }\n\n /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same\n way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */\n & [data-look="${(0,o.rq)(e.look)}"].node.usecase-element .usecase-business-marker {\n stroke: ${t.border};\n }\n`}\n & .usecase-element .nodeLabel,\n & .usecase-label {\n color: ${e.primaryTextColor};\n fill: ${e.primaryTextColor};\n font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});\n font-size: var(--mermaid-usecase-font-size, 12px);\n font-weight: var(--mermaid-usecase-font-weight, normal);\n }\n\n & .usecase-stereotype,\n & .usecase-business-marker {\n color: ${e.primaryTextColor};\n fill: ${e.primaryTextColor};\n stroke: ${t.border};\n }\n\n & .system-boundary rect.boundary-body,\n & .system-boundary rect.boundary-tab,\n & .system-boundary-package-tab {\n fill: ${t.boundaryBkg};\n stroke: ${t.boundaryBorder};\n stroke-width: 1px;\n }\n\n & .system-boundary-title text {\n fill: ${e.titleColor??e.primaryTextColor};\n }\n\n /* Only the span, never the <p> inside it: the renderer puts a user-supplied\n 'color' on the span, and that has to stay inheritable by its children. */\n & .system-boundary-title span {\n color: ${e.titleColor??e.primaryTextColor};\n }\n\n & .usecase-note {\n fill: ${e.noteBkgColor};\n stroke: ${e.noteBorderColor};\n color: ${e.noteTextColor};\n }\n\n & .usecase-note .nodeLabel {\n color: ${e.noteTextColor};\n fill: ${e.noteTextColor};\n }\n\n & .usecase-json-table,\n & .usecase-json-table rect,\n & .usecase-json-cell {\n fill: ${e.mainBkg};\n stroke: ${e.nodeBorder??e.primaryColor};\n }\n\n & .usecase-json-title,\n & .usecase-json-key,\n & .usecase-json-value {\n color: ${e.primaryTextColor};\n fill: ${e.primaryTextColor};\n }\n\n & .relationship {\n fill: none;\n stroke: ${e.lineColor};\n }\n\n & .relationship-include,\n & .relationship-extend,\n & .relationship-note {\n stroke-dasharray: 3;\n }\n\n /* Include and extend are both dashed, which is a weak distinction at small sizes. The\n tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */\n & .relationship-include {\n stroke: ${t.includeLine};\n }\n\n & .relationship-extend {\n stroke: ${t.extendLine};\n }\n\n & .relationship.edge-animation-fast,\n & .relationship.edge-animation-slow {\n stroke-linecap: round;\n }\n\n & .edgeLabel,\n & .edgeLabel p {\n background-color: ${e.edgeLabelBackground};\n }\n\n & .labelBkg {\n background-color: ${e.edgeLabelBackground};\n padding: 0 2px;\n }\n\n & .edgeLabel .label rect {\n fill: ${e.edgeLabelBackground};\n }\n\n & .relationship-label,\n & .edgeLabel {\n color: ${e.primaryTextColor};\n fill: ${e.primaryTextColor};\n font-family: ${e.fontFamily};\n font-size: 10px;\n font-weight: normal;\n }\n\n & .marker,\n & .marker.point,\n & .marker.circle,\n & .marker.cross {\n fill: ${e.lineColor};\n stroke: ${e.lineColor};\n }\n\n & .marker.extension {\n fill: ${e.mainBkg};\n stroke: ${e.lineColor};\n }\n`},"getStyles")}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5697],{55697(e,r,t){t.d(r,{diagram:()=>y});var n=t(17022),a=t(99051),s=(t(23980),t(20886),t(84828)),l=t(27698),i=t(63883),p=(0,i.sB)().RailroadAbnf.parser.LangiumParser,m=(0,l.K)(e=>{const r=e.alternatives.map(o);return 1===r.length?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),o=(0,l.K)(e=>{const r=e.elements.map(c);return 1===r.length?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),u=(0,l.K)(e=>{if(e.includes("*")){const[r,t]=e.split("*");return{min:r?parseInt(r,10):0,max:t?parseInt(t,10):1/0}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),c=(0,l.K)(e=>{const r=d(e.primary);if(!e.repeat)return r;const{min:t,max:n}=u(e.repeat);return 0===t&&1===n?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:n}},"transformElement"),d=(0,l.K)(e=>{switch(e.$type){case"AbnfStringLiteral":case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return m(e.element);case"AbnfOptionalGroup":return{type:"optional",element:m(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),f=(0,l.K)(e=>({name:e.name,definition:m(e.definition)}),"transformRule"),b=(0,l.K)(e=>{(0,a.S)(e,n.db),e.title&&n.db.setTitle(e.title),e.rules.map(e=>n.db.addRule(f(e)))},"populateDb"),y={parser:{parse:(0,l.K)(e=>{n.db.clear(),s.R.debug("[ABNF Parser] Starting Langium parse");const r=p.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new i.zg(r);const t=r.value;s.R.debug("[ABNF Parser] Parsed rules:",t.rules.length),b(t),s.R.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:n.db}},db:n.db,renderer:n.U,styles:n.$}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[5741],{55741(t,e,i){i.d(e,{diagram:()=>C});var n=i(15319),s=i(51255),a=i(89983),r=(i(31293),i(86827)),h=i(61057),o=function(){var t=(0,r.K)(function(t,e,i,n){for(i=i||{},n=t.length;n--;i[t[n]]=e);return i},"o"),e=[1,4],i=[1,14],n=[1,12],s=[1,13],a=[6,7,8],h=[1,20],o=[1,18],l=[1,19],c=[6,7,11],u=[1,6,13,14],d=[1,23],y=[1,24],p=[1,6,7,11,13,14],g={trace:(0,r.K)(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:(0,r.K)(function(t,e,i,n,s,a,r){var h=a.length-1;switch(s){case 6:case 7:return n;case 15:n.addNode(a[h-1].length,a[h].trim());break;case 16:n.addNode(0,a[h].trim())}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:i,7:[1,10],9:9,12:11,13:n,14:s},t(a,[2,3]),{1:[2,2]},t(a,[2,4]),t(a,[2,5]),{1:[2,6],6:i,12:15,13:n,14:s},{6:i,9:16,12:11,13:n,14:s},{6:h,7:o,10:17,11:l},t(c,[2,18],{14:[1,21]}),t(c,[2,16]),t(c,[2,17]),{6:h,7:o,10:22,11:l},{1:[2,7],6:i,12:15,13:n,14:s},t(u,[2,14],{7:d,11:y}),t(p,[2,8]),t(p,[2,9]),t(p,[2,10]),t(c,[2,15]),t(u,[2,13],{7:d,11:y}),t(p,[2,11]),t(p,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:(0,r.K)(function(t,e){if(!e.recoverable){var i=new Error(t);throw i.hash=e,i}this.trace(t)},"parseError"),parse:(0,r.K)(function(t){var e=this,i=[0],n=[],s=[null],a=[],h=this.table,o="",l=0,c=0,u=0,d=a.slice.call(arguments,1),y=Object.create(this.lexer),p={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(p.yy[g]=this.yy[g]);y.setInput(t,p.yy),p.yy.lexer=y,p.yy.parser=this,void 0===y.yylloc&&(y.yylloc={});var f=y.yylloc;a.push(f);var k=y.options&&y.options.ranges;function m(){var t;return"number"!=typeof(t=n.pop()||y.lex()||1)&&(t instanceof Array&&(t=(n=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,(0,r.K)(function(t){i.length=i.length-2*t,s.length=s.length-t,a.length=a.length-t},"popStack"),(0,r.K)(m,"lex");for(var w,x,b,_,v,S,K,$,I,E={};;){if(b=i[i.length-1],this.defaultActions[b]?_=this.defaultActions[b]:(null==w&&(w=m()),_=h[b]&&h[b][w]),void 0===_||!_.length||!_[0]){var A="";for(S in I=[],h[b])this.terminals_[S]&&S>2&&I.push("'"+this.terminals_[S]+"'");A=y.showPosition?"Parse error on line "+(l+1)+":\n"+y.showPosition()+"\nExpecting "+I.join(", ")+", got '"+(this.terminals_[w]||w)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==w?"end of input":"'"+(this.terminals_[w]||w)+"'"),this.parseError(A,{text:y.match,token:this.terminals_[w]||w,line:y.yylineno,loc:f,expected:I})}if(_[0]instanceof Array&&_.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+w);switch(_[0]){case 1:i.push(w),s.push(y.yytext),a.push(y.yylloc),i.push(_[1]),w=null,x?(w=x,x=null):(c=y.yyleng,o=y.yytext,l=y.yylineno,f=y.yylloc,u>0&&u--);break;case 2:if(K=this.productions_[_[1]][1],E.$=s[s.length-K],E._$={first_line:a[a.length-(K||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(K||1)].first_column,last_column:a[a.length-1].last_column},k&&(E._$.range=[a[a.length-(K||1)].range[0],a[a.length-1].range[1]]),void 0!==(v=this.performAction.apply(E,[o,c,l,p.yy,_[1],s,a].concat(d))))return v;K&&(i=i.slice(0,-1*K*2),s=s.slice(0,-1*K),a=a.slice(0,-1*K)),i.push(this.productions_[_[1]][0]),s.push(E.$),a.push(E._$),$=h[i[i.length-2]][i[i.length-1]],i.push($);break;case 3:return!0}}return!0},"parse")},f=function(){return{EOF:1,parseError:(0,r.K)(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:(0,r.K)(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:(0,r.K)(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:(0,r.K)(function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===n.length?this.yylloc.first_column:0)+n[n.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:(0,r.K)(function(){return this._more=!0,this},"more"),reject:(0,r.K)(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:(0,r.K)(function(t){this.unput(this.match.slice(t))},"less"),pastInput:(0,r.K)(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:(0,r.K)(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:(0,r.K)(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:(0,r.K)(function(t,e){var i,n,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),(n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var a in s)this[a]=s[a];return!1}return!1},"test_match"),next:(0,r.K)(function(){if(this.done)return this.EOF;var t,e,i,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),a=0;a<s.length;a++)if((i=this._input.match(this.rules[s[a]]))&&(!e||i[0].length>e[0].length)){if(e=i,n=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,s[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,s[n]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:(0,r.K)(function(){var t=this.next();return t||this.lex()},"lex"),begin:(0,r.K)(function(t){this.conditionStack.push(t)},"begin"),popState:(0,r.K)(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:(0,r.K)(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:(0,r.K)(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:(0,r.K)(function(t){this.begin(t)},"pushState"),stateStackSize:(0,r.K)(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:(0,r.K)(function(t,e,i,n){switch(i){case 0:case 3:return 6;case 1:case 2:return 8;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}}}();function k(){this.yy={}}return g.lexer=f,(0,r.K)(k,"Parser"),k.prototype=g,g.Parser=k,new k}();o.parser=o;var l=o,c=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}static{(0,r.K)(this,"IshikawaDB")}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,(0,a.IU)()}getRoot(){return this.root}addNode(t,e){const i=a.Y2.sanitizeText(e,(0,a.D7)());if(!this.root)return this.root={text:i,children:[]},this.stack=[{level:0,node:this.root}],void(0,a.ke)(i);this.baseLevel??=t;let n=t-this.baseLevel+1;for(n<=0&&(n=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=n;)this.stack.pop();const s={text:i,children:[]};this.stack[this.stack.length-1].node.children.push(s),this.stack.push({level:n,node:s})}getAccTitle(){return(0,a.iN)()}setAccTitle(t){(0,a.SV)(t)}getAccDescription(){return(0,a.m7)()}setAccDescription(t){(0,a.EI)(t)}getDiagramTitle(){return(0,a.ab)()}setDiagramTitle(t){(0,a.ke)(t)}},u=250,d=82*Math.PI/180,y=Math.cos(d),p=Math.sin(d),g=(0,r.K)((t,e,i)=>{const n=t.node().getBBox(),s=n.width+2*e,r=n.height+2*e;(0,a.a$)(t,r,s,i),t.attr("viewBox",`${n.x-e} ${n.y-e} ${s} ${r}`)},"applyPaddedViewBox"),f=(0,r.K)((t,e,i,r)=>{const o=r.db.getRoot();if(!o)return;const l=(0,a.D7)(),{look:c,handDrawnSeed:d,themeVariables:y}=l,p=(0,s.I5)(l.fontSize)[0]??14,f="handDrawn"===c,w=o.children??[],x=l.ishikawa?.diagramPadding??20,b=l.ishikawa?.useMaxWidth??!1,v=(0,n.D)(e),S=v.append("g").attr("class","ishikawa"),K=f?h.A.svg(v.node()):void 0,$=K?{roughSvg:K,seed:d??0,lineColor:y?.lineColor??"#333",fillColor:y?.mainBkg??"#fff"}:void 0,E=`ishikawa-arrow-${e}`;f||S.append("defs").append("marker").attr("id",E).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 Z").attr("class","ishikawa-arrow");let A=0,C=u;const L=f?void 0:I(S,A,C,A,C,"ishikawa-spine");if(m(S,A,C,o.text,p,$),!w.length)return f&&I(S,A,C,A,C,"ishikawa-spine",$),void g(v,x,b);A-=20;const M=w.filter((t,e)=>e%2==0),P=w.filter((t,e)=>e%2==1),T=k(M),B=k(P),D=T.total+B.total;let N=u,O=u;if(D>0){const t=500,e=75;N=Math.max(e,t*(T.total/D)),O=Math.max(e,t*(B.total/D))}const W=2*p;N=Math.max(N,T.max*W),O=Math.max(O,B.max*W),C=Math.max(N,u),L&&L.attr("y1",C).attr("y2",C),S.select(".ishikawa-head-group").attr("transform",`translate(0,${C})`);const j=Math.ceil(w.length/2);for(let t=0;t<j;t++){const e=S.append("g").attr("class","ishikawa-pair");for(const[i,n,s]of[[w[2*t],-1,N],[w[2*t+1],1,O]])i&&_(e,i,A,C,n,s,p,$);A=e.selectAll("text").nodes().reduce((t,e)=>Math.min(t,e.getBBox().x),1/0)}if(f)I(S,A,C,0,C,"ishikawa-spine",$);else{L.attr("x1",A);const t=`url(#${E})`;S.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start",t)}g(v,x,b)},"draw"),k=(0,r.K)(t=>{const e=(0,r.K)(t=>t.children.reduce((t,i)=>t+1+e(i),0),"countDescendants");return t.reduce((t,i)=>{const n=e(i);return t.total+=n,t.max=Math.max(t.max,n),t},{total:0,max:0})},"sideStats"),m=(0,r.K)((t,e,i,n,s,a)=>{const r=Math.max(6,Math.floor(110/(.6*s))),h=t.append("g").attr("class","ishikawa-head-group").attr("transform",`translate(${e},${i})`),o=K(h,S(n,r),0,0,"ishikawa-head-label","start",s),l=o.node().getBBox(),c=Math.max(60,l.width+6),u=Math.max(40,2*l.height+40),d=`M 0 ${-u/2} L 0 ${u/2} Q ${2.4*c} 0 0 ${-u/2} Z`;if(a){const t=a.roughSvg.path(d,{roughness:1.5,seed:a.seed,fill:a.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:a.lineColor,strokeWidth:2});h.insert(()=>t,":first-child").attr("class","ishikawa-head")}else h.insert("path",":first-child").attr("class","ishikawa-head").attr("d",d);o.attr("transform",`translate(${(c-l.width)/2-l.x+3},${-l.y-l.height/2})`)},"drawHead"),w=(0,r.K)((t,e)=>{const i=[],n=[],s=(0,r.K)((t,a,r)=>{const h=-1===e?[...t].reverse():t;for(const t of h){const e=i.length,h=t.children??[];i.push({depth:r,text:S(t.text,15),parentIndex:a,childCount:h.length}),r%2==0?(n.push(e),h.length&&s(h,e,r+1)):(h.length&&s(h,e,r+1),n.push(e))}},"walk");return s(t,-1,2),{entries:i,yOrder:n}},"flattenTree"),x=(0,r.K)((t,e,i,n,s,a,r)=>{const h=t.append("g").attr("class","ishikawa-label-group"),o=K(h,e,i,n+11*s,"ishikawa-label cause","middle",a).node().getBBox();if(r){const t=r.roughSvg.rectangle(o.x-20,o.y-2,o.width+40,o.height+4,{roughness:1.5,seed:r.seed,fill:r.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:r.lineColor,strokeWidth:2});h.insert(()=>t,":first-child").attr("class","ishikawa-label-box")}else h.insert("rect",":first-child").attr("class","ishikawa-label-box").attr("x",o.x-20).attr("y",o.y-2).attr("width",o.width+40).attr("height",o.height+4)},"drawCauseLabel"),b=(0,r.K)((t,e,i,n,s,a)=>{const r=Math.sqrt(n*n+s*s);if(0===r)return;const h=n/r,o=s/r,l=6*-o,c=6*h,u=`M ${e} ${i} L ${e-6*h*2+l} ${i-6*o*2+c} L ${e-6*h*2-l} ${i-6*o*2-c} Z`,d=a.roughSvg.path(u,{roughness:1,seed:a.seed,fill:a.lineColor,fillStyle:"solid",stroke:a.lineColor,strokeWidth:1});t.append(()=>d)},"drawArrowMarker"),_=(0,r.K)((t,e,i,n,s,a,r,h)=>{const o=e.children??[],l=a*(o.length?1:.2),c=p*l*s,u=i+-y*l,d=n+c;if(I(t,i,n,u,d,"ishikawa-branch",h),h&&b(t,i,n,i-u,n-d,h),x(t,e.text,u,d,s,r,h),!o.length)return;const{entries:g,yOrder:f}=w(o,s),k=g.length,m=new Array(k);for(const[t,e]of f.entries())m[e]=n+c*((t+1)/(k+1));const _=new Map;_.set(-1,{x0:i,y0:n,x1:u,y1:d,childCount:o.length,childrenDrawn:0});const v=-y,S=p*s,E=s<0?"ishikawa-label up":"ishikawa-label down";for(const[e,i]of g.entries()){const n=m[e],s=_.get(i.parentIndex),a=t.append("g").attr("class","ishikawa-sub-group");let o=0,l=0,c=0;if(i.depth%2==0){const t=s.y1-s.y0;o=$(s.x0,s.x1,t?(n-s.y0)/t:.5),l=n,c=o-(i.childCount>0?60+5*i.childCount:30),I(a,o,n,c,n,"ishikawa-sub-branch",h),h&&b(a,o,n,1,0,h),K(a,i.text,c,n,"ishikawa-label align","end",r)}else{const t=s.childrenDrawn++;o=$(s.x0,s.x1,(s.childCount-t)/(s.childCount+1)),l=s.y0,c=o+v*((n-l)/S),I(a,o,l,c,n,"ishikawa-sub-branch",h),h&&b(a,o,l,o-c,l-n,h),K(a,i.text,c,n,E,"end",r)}i.childCount>0&&_.set(e,{x0:o,y0:l,x1:c,y1:n,childCount:i.childCount,childrenDrawn:0})}},"drawBranch"),v=(0,r.K)(t=>t.split(/<br\s*\/?>|\n/),"splitLines"),S=(0,r.K)((t,e)=>{if(t.length<=e)return t;const i=[];for(const n of t.split(/\s+/)){const t=i.length-1;t>=0&&i[t].length+1+n.length<=e?i[t]+=" "+n:i.push(n)}return i.join("\n")},"wrapText"),K=(0,r.K)((t,e,i,n,s,a,r)=>{const h=v(e),o=1.05*r,l=t.append("text").attr("class",s).attr("text-anchor",a).attr("x",i).attr("y",n-(h.length-1)*o/2);for(const[t,e]of h.entries())l.append("tspan").attr("x",i).attr("dy",0===t?0:o).text(e);return l},"drawMultilineText"),$=(0,r.K)((t,e,i)=>t+(e-t)*i,"lerp"),I=(0,r.K)((t,e,i,n,s,a,r)=>{if(r){const h=r.roughSvg.line(e,i,n,s,{roughness:1.5,seed:r.seed,stroke:r.lineColor,strokeWidth:2});return void t.append(()=>h).attr("class",a)}return t.append("line").attr("class",a).attr("x1",e).attr("y1",i).attr("x2",n).attr("y2",s)},"drawLine"),E={draw:f},A=(0,r.K)(t=>`\n.ishikawa .ishikawa-spine,\n.ishikawa .ishikawa-branch,\n.ishikawa .ishikawa-sub-branch {\n stroke: ${t.lineColor};\n stroke-width: 2;\n fill: none;\n}\n\n.ishikawa .ishikawa-sub-branch {\n stroke-width: 1;\n}\n\n.ishikawa .ishikawa-arrow {\n fill: ${t.lineColor};\n}\n\n.ishikawa .ishikawa-head {\n fill: ${t.mainBkg};\n stroke: ${t.lineColor};\n stroke-width: 2;\n}\n\n.ishikawa .ishikawa-label-box {\n fill: ${t.mainBkg};\n stroke: ${t.lineColor};\n stroke-width: 2;\n}\n\n.ishikawa text {\n font-family: ${t.fontFamily};\n font-size: ${t.fontSize};\n fill: ${t.textColor};\n}\n\n.ishikawa .ishikawa-head-label {\n font-weight: 600;\n text-anchor: middle;\n dominant-baseline: middle;\n font-size: 14px;\n}\n\n.ishikawa .ishikawa-label {\n text-anchor: end;\n}\n\n.ishikawa .ishikawa-label.cause {\n text-anchor: middle;\n dominant-baseline: middle;\n}\n\n.ishikawa .ishikawa-label.align {\n text-anchor: end;\n dominant-baseline: middle;\n}\n\n.ishikawa .ishikawa-label.up {\n dominant-baseline: baseline;\n}\n\n.ishikawa .ishikawa-label.down {\n dominant-baseline: hanging;\n}\n`,"getStyles"),C={parser:l,get db(){return new c},renderer:E,styles:A}}}]);