@shunyasasaki/mkserve 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -0
  3. package/dist/cli.mjs +613 -0
  4. package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  5. package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  6. package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  7. package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  8. package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  9. package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  10. package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  11. package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  12. package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  13. package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  14. package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  15. package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  16. package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  17. package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  18. package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  19. package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  20. package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  21. package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  22. package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  23. package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  24. package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  25. package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  26. package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  27. package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  28. package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  29. package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  30. package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  31. package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  32. package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  33. package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  34. package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  35. package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  36. package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  37. package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  38. package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  39. package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  40. package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  41. package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  42. package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  43. package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  44. package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  45. package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  46. package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  47. package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  48. package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  49. package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  50. package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  51. package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  52. package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  53. package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  54. package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  55. package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  56. package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  57. package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  58. package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  59. package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  60. package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  61. package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  62. package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  63. package/dist/client/assets/abnfDiagram-O67JEVCF-BniYQwXa.js +1 -0
  64. package/dist/client/assets/arc-BJA87daU.js +1 -0
  65. package/dist/client/assets/architecture-7GRP2DOG-Brw-cPmm.js +1 -0
  66. package/dist/client/assets/architectureDiagram-NJMV4G6O-BNbYrQOP.js +36 -0
  67. package/dist/client/assets/array-BifhSqXX.js +1 -0
  68. package/dist/client/assets/blockDiagram-BEXU5L5S-DFIHGD-G.js +140 -0
  69. package/dist/client/assets/c4Diagram-YGBWAQC7-BkFaWKQU.js +38 -0
  70. package/dist/client/assets/channel-BrqIJdOD.js +1 -0
  71. package/dist/client/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  72. package/dist/client/assets/chunk-3FUC2YCW-B4uxGZek.js +2 -0
  73. package/dist/client/assets/chunk-5DYCD2WN-CnbWAgyo.js +1 -0
  74. package/dist/client/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  75. package/dist/client/assets/chunk-742MDFTN-CSlr64s4.js +1 -0
  76. package/dist/client/assets/chunk-7INBJB4K-CelZsjbp.js +62 -0
  77. package/dist/client/assets/chunk-7M6MHVWA-De6KLJmg.js +213 -0
  78. package/dist/client/assets/chunk-7PRAP22T-CE6VUtLz.js +1 -0
  79. package/dist/client/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  80. package/dist/client/assets/chunk-FOHPRMQF-DzxwRta7.js +161 -0
  81. package/dist/client/assets/chunk-GTNCS2PH-DfgoKLZ5.js +88 -0
  82. package/dist/client/assets/chunk-GWA4HPMP-CPJ61ePi.js +1 -0
  83. package/dist/client/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  84. package/dist/client/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  85. package/dist/client/assets/chunk-MBY4JIJT--fcyBAwh.js +72 -0
  86. package/dist/client/assets/chunk-NETBCI7D-Rdu9faBx.js +1 -0
  87. package/dist/client/assets/chunk-O7XYJQB3-Bqi4DWie.js +128 -0
  88. package/dist/client/assets/chunk-UA2S7LBM-BjrJ4RAw.js +1 -0
  89. package/dist/client/assets/chunk-WEXAMYUT-CnyLp8pC.js +1 -0
  90. package/dist/client/assets/chunk-XXDRQBXY-C1_eEj17.js +1 -0
  91. package/dist/client/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  92. package/dist/client/assets/chunk-Z7XXMR3K-BFUBfhD1.js +10 -0
  93. package/dist/client/assets/chunk-ZIGJFQKS-8PrSySWh.js +2 -0
  94. package/dist/client/assets/classDiagram-v2-NBCMYWYE-KufjDRbB.js +217 -0
  95. package/dist/client/assets/cose-bilkent-JH36ORCC-Bm2Bhb7n.js +1 -0
  96. package/dist/client/assets/cynefin-OW5HDTMX-H13mnOIn.js +1 -0
  97. package/dist/client/assets/cynefinDiagram-VND7K2PF-CI5Kf3Kt.js +62 -0
  98. package/dist/client/assets/cytoscape.esm-Yq6u8L66.js +321 -0
  99. package/dist/client/assets/dagre-6A5THRUB-DtRiYFPQ.js +4 -0
  100. package/dist/client/assets/defaultLocale-BFoDCU3G.js +1 -0
  101. package/dist/client/assets/diagram-22UHCM2B-DqFq9NIL.js +200 -0
  102. package/dist/client/assets/diagram-3UASUU5V-C2qQgCvw.js +24 -0
  103. package/dist/client/assets/diagram-ATOU4E4O-B6wVKZ5z.js +3 -0
  104. package/dist/client/assets/diagram-CDSNMT55-owh05Yfi.js +30 -0
  105. package/dist/client/assets/diagram-MLGK6HIB-C55nJ_CR.js +24 -0
  106. package/dist/client/assets/diagram-MPIPVDR6-DeYo8-yc.js +41 -0
  107. package/dist/client/assets/dist-Bfr8PhAA.js +1 -0
  108. package/dist/client/assets/ebnfDiagram-ZINNZB2B-BoJE7Elt.js +1 -0
  109. package/dist/client/assets/elk-276RUBZZ-F1vDPlT8.js +27 -0
  110. package/dist/client/assets/erDiagram-OPXOYQCR-JFHuQAWq.js +99 -0
  111. package/dist/client/assets/eventmodeling-NTZA5JFV-BDnaXJON.js +1 -0
  112. package/dist/client/assets/flowDiagram-KWPJA3E3-DC2FrXkH.js +1 -0
  113. package/dist/client/assets/ganttDiagram-FUAMR5RP-C5psbznc.js +292 -0
  114. package/dist/client/assets/gitGraph-4MIJSDKK-CUDLWiCq.js +1 -0
  115. package/dist/client/assets/gitGraphDiagram-X574FWY7-Cy-gNPac.js +106 -0
  116. package/dist/client/assets/graphlib-DS17s2tU.js +1 -0
  117. package/dist/client/assets/index-BEY9E2Q9.js +2 -0
  118. package/dist/client/assets/index-FULGulkF.css +2 -0
  119. package/dist/client/assets/info-A6RAGUB7-mIpFX_UH.js +1 -0
  120. package/dist/client/assets/infoDiagram-VRGFBTTK-DnkrYsVs.js +2 -0
  121. package/dist/client/assets/init-C-OQMol4.js +1 -0
  122. package/dist/client/assets/ishikawaDiagram-OU5B5YK6-_u6_xJba.js +70 -0
  123. package/dist/client/assets/journeyDiagram-ZHPQQLJL-CY5HU_eC.js +139 -0
  124. package/dist/client/assets/kanban-definition-PNTS6WVX-DvzRwcD7.js +89 -0
  125. package/dist/client/assets/katex-ZlcWpGUi.js +257 -0
  126. package/dist/client/assets/line-B4MFnJjP.js +1 -0
  127. package/dist/client/assets/linear-ZUqVn2xB.js +1 -0
  128. package/dist/client/assets/mermaid-parser.core-DYtj8_hH.js +7 -0
  129. package/dist/client/assets/mermaid.core-DQoUVKoE.js +44 -0
  130. package/dist/client/assets/mindmap-definition-NLK3R4M7-yqrZgVjd.js +96 -0
  131. package/dist/client/assets/ordinal-BDEzSJ7C.js +1 -0
  132. package/dist/client/assets/packet-AYTQ26CC-B26SBXWV.js +1 -0
  133. package/dist/client/assets/path-fybaL0A-.js +1 -0
  134. package/dist/client/assets/pegDiagram-GJSIUBJH-BfvMLRyD.js +1 -0
  135. package/dist/client/assets/pie-WAS4IAKB-DBtOIS90.js +1 -0
  136. package/dist/client/assets/pieDiagram-5QR66LMP-MLPjQpFM.js +39 -0
  137. package/dist/client/assets/quadrantDiagram-O4NWA36T-CprY7yVN.js +7 -0
  138. package/dist/client/assets/radar-RG4KPBEZ-Ced1CHqa.js +1 -0
  139. package/dist/client/assets/railroad-74A4TZTK-BsND1cV-.js +1 -0
  140. package/dist/client/assets/railroad-abnf-HS5TGJTU-DiXPG6oV.js +1 -0
  141. package/dist/client/assets/railroad-ebnf-LZEXJU2U-DgNTMybz.js +1 -0
  142. package/dist/client/assets/railroad-peg-WCYAUIDC-CvY-xH_Q.js +1 -0
  143. package/dist/client/assets/railroadDiagram-XR7U4H2S-BeHaiLp2.js +1 -0
  144. package/dist/client/assets/requirementDiagram-PLB6GJNP-Ck-7Hpab.js +84 -0
  145. package/dist/client/assets/rough.esm-Dy-Kn_BL.js +1 -0
  146. package/dist/client/assets/sankeyDiagram-IPEJSGJF-DmstfGGj.js +40 -0
  147. package/dist/client/assets/sequenceDiagram-PO4LG4MO-wco_mvTt.js +169 -0
  148. package/dist/client/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  149. package/dist/client/assets/src-D_iIdUkB.js +1 -0
  150. package/dist/client/assets/stateDiagram-v2-GCMORJYK-B1l0Xks5.js +291 -0
  151. package/dist/client/assets/swimlanes-2SLR337P-0YucaaVy.js +1 -0
  152. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-Dx92YAeU.js +8 -0
  153. package/dist/client/assets/timeline-definition-EJHVYXUP-BvXqIXyV.js +120 -0
  154. package/dist/client/assets/treeView-Q6P3EWNA-DrBl-X_2.js +1 -0
  155. package/dist/client/assets/treemap-WGGIJYW6-bl_fzdzs.js +1 -0
  156. package/dist/client/assets/usecaseDiagram-POWQR4AR-D_lJYuuq.js +328 -0
  157. package/dist/client/assets/vennDiagram-UO4OBE2U-BCmaseck.js +34 -0
  158. package/dist/client/assets/wardley-WFR3VGLG-B2g3_G7F.js +1 -0
  159. package/dist/client/assets/wardleyDiagram-VNRHLVJA-CZ-FrOG9.js +78 -0
  160. package/dist/client/assets/xychartDiagram-PMCCYNJV-C3xVeS8n.js +7 -0
  161. package/dist/client/index.html +59 -0
  162. package/package.json +96 -0
@@ -0,0 +1,328 @@
1
+ import{m as e,p as t}from"./src-D_iIdUkB.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{H as r,U as i,a,b as o,f as s,q as c,v as l,w as u,x as d,y as f,z as p}from"./chunk-O7XYJQB3-Bqi4DWie.js";import{g as m}from"./chunk-ZIGJFQKS-8PrSySWh.js";import"./chunk-742MDFTN-CSlr64s4.js";import{i as h}from"./chunk-MBY4JIJT--fcyBAwh.js";import"./chunk-7PRAP22T-CE6VUtLz.js";import{a as g,i as ee,o as te,r as _}from"./chunk-J5ZVWO5B-oDCd-gWO.js";import"./chunk-7INBJB4K-CelZsjbp.js";import"./chunk-5DYCD2WN-CnbWAgyo.js";import"./chunk-Z7XXMR3K-BFUBfhD1.js";import{t as ne}from"./chunk-XXDRQBXY-C1_eEj17.js";import{t as re}from"./chunk-WEXAMYUT-CnyLp8pC.js";import"./chunk-UA2S7LBM-BjrJ4RAw.js";import{i as ie,r as ae}from"./mermaid.core-DQoUVKoE.js";var oe=typeof global==`object`&&global&&global.Object===Object&&global,se=typeof self==`object`&&self&&self.Object===Object&&self,v=oe||se||Function(`return this`)(),y=v.Symbol,ce=Object.prototype,le=ce.hasOwnProperty,ue=ce.toString,de=y?y.toStringTag:void 0;function fe(e){var t=le.call(e,de),n=e[de];try{e[de]=void 0;var r=!0}catch{}var i=ue.call(e);return r&&(t?e[de]=n:delete e[de]),i}var pe=Object.prototype.toString;function me(e){return pe.call(e)}var he=`[object Null]`,ge=`[object Undefined]`,_e=y?y.toStringTag:void 0;function ve(e){return e==null?e===void 0?ge:he:_e&&_e in Object(e)?fe(e):me(e)}function ye(e){return typeof e==`object`&&!!e}var be=`[object Symbol]`;function xe(e){return typeof e==`symbol`||ye(e)&&ve(e)==be}function Se(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var b=Array.isArray,Ce=1/0,we=y?y.prototype:void 0,Te=we?we.toString:void 0;function Ee(e){if(typeof e==`string`)return e;if(b(e))return Se(e,Ee)+``;if(xe(e))return Te?Te.call(e):``;var t=e+``;return t==`0`&&1/e==-Ce?`-0`:t}var De=/\s/;function Oe(e){for(var t=e.length;t--&&De.test(e.charAt(t)););return t}var ke=/^\s+/;function Ae(e){return e&&e.slice(0,Oe(e)+1).replace(ke,``)}function je(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Me=NaN,Ne=/^[-+]0x[0-9a-f]+$/i,Pe=/^0b[01]+$/i,Fe=/^0o[0-7]+$/i,Ie=parseInt;function Le(e){if(typeof e==`number`)return e;if(xe(e))return Me;if(je(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=je(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Ae(e);var n=Pe.test(e);return n||Fe.test(e)?Ie(e.slice(2),n?2:8):Ne.test(e)?Me:+e}var Re=1/0,ze=17976931348623157e292;function Be(e){return e?(e=Le(e),e===Re||e===-Re?(e<0?-1:1)*ze:e===e?e:0):e===0?e:0}function Ve(e){var t=Be(e),n=t%1;return t===t?n?t-n:t:0}function He(e){return e}var Ue=`[object AsyncFunction]`,We=`[object Function]`,Ge=`[object GeneratorFunction]`,Ke=`[object Proxy]`;function qe(e){if(!je(e))return!1;var t=ve(e);return t==We||t==Ge||t==Ue||t==Ke}var Je=v[`__core-js_shared__`],Ye=function(){var e=/[^.]+$/.exec(Je&&Je.keys&&Je.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Xe(e){return!!Ye&&Ye in e}var Ze=Function.prototype.toString;function Qe(e){if(e!=null){try{return Ze.call(e)}catch{}try{return e+``}catch{}}return``}var $e=/[\\^$.*+?()[\]{}|]/g,et=/^\[object .+?Constructor\]$/,tt=Function.prototype,nt=Object.prototype,rt=tt.toString,it=nt.hasOwnProperty,at=RegExp(`^`+rt.call(it).replace($e,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function ot(e){return!je(e)||Xe(e)?!1:(qe(e)?at:et).test(Qe(e))}function st(e,t){return e?.[t]}function ct(e,t){var n=st(e,t);return ot(n)?n:void 0}var lt=ct(v,`WeakMap`),ut=Object.create,dt=function(){function e(){}return function(t){if(!je(t))return{};if(ut)return ut(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function ft(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function x(){}function pt(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var mt=800,ht=16,gt=Date.now;function _t(e){var t=0,n=0;return function(){var r=gt(),i=ht-(r-n);if(n=r,i>0){if(++t>=mt)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function vt(e){return function(){return e}}var yt=function(){try{var e=ct(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),bt=_t(yt?function(e,t){return yt(e,`toString`,{configurable:!0,enumerable:!1,value:vt(t),writable:!0})}:He);function xt(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function St(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Ct(e){return e!==e}function wt(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Tt(e,t,n){return t===t?wt(e,t,n):St(e,Ct,n)}function Et(e,t){return!!(e!=null&&e.length)&&Tt(e,t,0)>-1}var Dt=9007199254740991,Ot=/^(?:0|[1-9]\d*)$/;function kt(e,t){var n=typeof e;return t??=Dt,!!t&&(n==`number`||n!=`symbol`&&Ot.test(e))&&e>-1&&e%1==0&&e<t}function At(e,t,n){t==`__proto__`&&yt?yt(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function jt(e,t){return e===t||e!==e&&t!==t}var Mt=Object.prototype.hasOwnProperty;function Nt(e,t,n){var r=e[t];(!(Mt.call(e,t)&&jt(r,n))||n===void 0&&!(t in e))&&At(e,t,n)}function Pt(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?At(n,s,c):Nt(n,s,c)}return n}var Ft=Math.max;function It(e,t,n){return t=Ft(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Ft(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),ft(e,this,s)}}function Lt(e,t){return bt(It(e,t,He),e+``)}var Rt=9007199254740991;function zt(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Rt}function Bt(e){return e!=null&&zt(e.length)&&!qe(e)}function Vt(e,t,n){if(!je(n))return!1;var r=typeof t;return(r==`number`?Bt(n)&&kt(t,n.length):r==`string`&&t in n)?jt(n[t],e):!1}function Ht(e){return Lt(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Vt(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var Ut=Object.prototype;function Wt(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ut)}function Gt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Kt=`[object Arguments]`;function qt(e){return ye(e)&&ve(e)==Kt}var Jt=Object.prototype,Yt=Jt.hasOwnProperty,Xt=Jt.propertyIsEnumerable,Zt=qt(function(){return arguments}())?qt:function(e){return ye(e)&&Yt.call(e,`callee`)&&!Xt.call(e,`callee`)};function Qt(){return!1}var $t=typeof exports==`object`&&exports&&!exports.nodeType&&exports,en=$t&&typeof module==`object`&&module&&!module.nodeType&&module,tn=en&&en.exports===$t?v.Buffer:void 0,nn=(tn?tn.isBuffer:void 0)||Qt,rn=`[object Arguments]`,an=`[object Array]`,on=`[object Boolean]`,sn=`[object Date]`,cn=`[object Error]`,ln=`[object Function]`,un=`[object Map]`,dn=`[object Number]`,fn=`[object Object]`,pn=`[object RegExp]`,mn=`[object Set]`,hn=`[object String]`,gn=`[object WeakMap]`,_n=`[object ArrayBuffer]`,vn=`[object DataView]`,yn=`[object Float32Array]`,bn=`[object Float64Array]`,xn=`[object Int8Array]`,Sn=`[object Int16Array]`,Cn=`[object Int32Array]`,wn=`[object Uint8Array]`,Tn=`[object Uint8ClampedArray]`,En=`[object Uint16Array]`,Dn=`[object Uint32Array]`,S={};S[yn]=S[bn]=S[xn]=S[Sn]=S[Cn]=S[wn]=S[Tn]=S[En]=S[Dn]=!0,S[rn]=S[an]=S[_n]=S[on]=S[vn]=S[sn]=S[cn]=S[ln]=S[un]=S[dn]=S[fn]=S[pn]=S[mn]=S[hn]=S[gn]=!1;function On(e){return ye(e)&&zt(e.length)&&!!S[ve(e)]}function kn(e){return function(t){return e(t)}}var An=typeof exports==`object`&&exports&&!exports.nodeType&&exports,jn=An&&typeof module==`object`&&module&&!module.nodeType&&module,Mn=jn&&jn.exports===An&&oe.process,Nn=function(){try{return jn&&jn.require&&jn.require(`util`).types||Mn&&Mn.binding&&Mn.binding(`util`)}catch{}}(),Pn=Nn&&Nn.isTypedArray,Fn=Pn?kn(Pn):On,In=Object.prototype.hasOwnProperty;function Ln(e,t){var n=b(e),r=!n&&Zt(e),i=!n&&!r&&nn(e),a=!n&&!r&&!i&&Fn(e),o=n||r||i||a,s=o?Gt(e.length,String):[],c=s.length;for(var l in e)(t||In.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||kt(l,c)))&&s.push(l);return s}function Rn(e,t){return function(n){return e(t(n))}}var zn=Rn(Object.keys,Object),Bn=Object.prototype.hasOwnProperty;function Vn(e){if(!Wt(e))return zn(e);var t=[];for(var n in Object(e))Bn.call(e,n)&&n!=`constructor`&&t.push(n);return t}function C(e){return Bt(e)?Ln(e):Vn(e)}var Hn=Object.prototype.hasOwnProperty,w=Ht(function(e,t){if(Wt(t)||Bt(t)){Pt(t,C(t),e);return}for(var n in t)Hn.call(t,n)&&Nt(e,n,t[n])});function Un(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Wn=Object.prototype.hasOwnProperty;function Gn(e){if(!je(e))return Un(e);var t=Wt(e),n=[];for(var r in e)(r!=`constructor`||!t&&Wn.call(e,r))&&n.push(r);return n}function Kn(e){return Bt(e)?Ln(e,!0):Gn(e)}var qn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jn=/^\w*$/;function Yn(e,t){if(b(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||xe(e)?!0:Jn.test(e)||!qn.test(e)||t!=null&&e in Object(t)}var Xn=ct(Object,`create`);function Zn(){this.__data__=Xn?Xn(null):{},this.size=0}function Qn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var $n=`__lodash_hash_undefined__`,er=Object.prototype.hasOwnProperty;function tr(e){var t=this.__data__;if(Xn){var n=t[e];return n===$n?void 0:n}return er.call(t,e)?t[e]:void 0}var nr=Object.prototype.hasOwnProperty;function rr(e){var t=this.__data__;return Xn?t[e]!==void 0:nr.call(t,e)}var ir=`__lodash_hash_undefined__`;function ar(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Xn&&t===void 0?ir:t,this}function or(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}or.prototype.clear=Zn,or.prototype.delete=Qn,or.prototype.get=tr,or.prototype.has=rr,or.prototype.set=ar;function sr(){this.__data__=[],this.size=0}function cr(e,t){for(var n=e.length;n--;)if(jt(e[n][0],t))return n;return-1}var lr=Array.prototype.splice;function ur(e){var t=this.__data__,n=cr(t,e);return n<0?!1:(n==t.length-1?t.pop():lr.call(t,n,1),--this.size,!0)}function dr(e){var t=this.__data__,n=cr(t,e);return n<0?void 0:t[n][1]}function fr(e){return cr(this.__data__,e)>-1}function pr(e,t){var n=this.__data__,r=cr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function mr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}mr.prototype.clear=sr,mr.prototype.delete=ur,mr.prototype.get=dr,mr.prototype.has=fr,mr.prototype.set=pr;var hr=ct(v,`Map`);function gr(){this.size=0,this.__data__={hash:new or,map:new(hr||mr),string:new or}}function _r(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function vr(e,t){var n=e.__data__;return _r(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function yr(e){var t=vr(this,e).delete(e);return this.size-=+!!t,t}function br(e){return vr(this,e).get(e)}function xr(e){return vr(this,e).has(e)}function Sr(e,t){var n=vr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Cr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Cr.prototype.clear=gr,Cr.prototype.delete=yr,Cr.prototype.get=br,Cr.prototype.has=xr,Cr.prototype.set=Sr;var wr=`Expected a function`;function Tr(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(wr);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Tr.Cache||Cr),n}Tr.Cache=Cr;var Er=500;function Dr(e){var t=Tr(e,function(e){return n.size===Er&&n.clear(),e}),n=t.cache;return t}var Or=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,kr=/\\(\\)?/g,Ar=Dr(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Or,function(e,n,r,i){t.push(r?i.replace(kr,`$1`):n||e)}),t});function jr(e){return e==null?``:Ee(e)}function Mr(e,t){return b(e)?e:Yn(e,t)?[e]:Ar(jr(e))}var Nr=1/0;function Pr(e){if(typeof e==`string`||xe(e))return e;var t=e+``;return t==`0`&&1/e==-Nr?`-0`:t}function Fr(e,t){t=Mr(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[Pr(t[n++])];return n&&n==r?e:void 0}function Ir(e,t,n){var r=e==null?void 0:Fr(e,t);return r===void 0?n:r}function Lr(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Rr=y?y.isConcatSpreadable:void 0;function zr(e){return b(e)||Zt(e)||!!(Rr&&e&&e[Rr])}function Br(e,t,n,r,i){var a=-1,o=e.length;for(n||=zr,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?Br(s,t-1,n,r,i):Lr(i,s):r||(i[i.length]=s)}return i}function Vr(e){return e!=null&&e.length?Br(e,1):[]}var Hr=Rn(Object.getPrototypeOf,Object);function Ur(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function Wr(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Gr(){this.__data__=new mr,this.size=0}function Kr(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function qr(e){return this.__data__.get(e)}function Jr(e){return this.__data__.has(e)}var Yr=200;function Xr(e,t){var n=this.__data__;if(n instanceof mr){var r=n.__data__;if(!hr||r.length<Yr-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Cr(r)}return n.set(e,t),this.size=n.size,this}function Zr(e){var t=this.__data__=new mr(e);this.size=t.size}Zr.prototype.clear=Gr,Zr.prototype.delete=Kr,Zr.prototype.get=qr,Zr.prototype.has=Jr,Zr.prototype.set=Xr;function Qr(e,t){return e&&Pt(t,C(t),e)}function $r(e,t){return e&&Pt(t,Kn(t),e)}var ei=typeof exports==`object`&&exports&&!exports.nodeType&&exports,ti=ei&&typeof module==`object`&&module&&!module.nodeType&&module,ni=ti&&ti.exports===ei?v.Buffer:void 0,ri=ni?ni.allocUnsafe:void 0;function ii(e,t){if(t)return e.slice();var n=e.length,r=ri?ri(n):new e.constructor(n);return e.copy(r),r}function ai(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function oi(){return[]}var si=Object.prototype.propertyIsEnumerable,ci=Object.getOwnPropertySymbols,li=ci?function(e){return e==null?[]:(e=Object(e),ai(ci(e),function(t){return si.call(e,t)}))}:oi;function ui(e,t){return Pt(e,li(e),t)}var di=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Lr(t,li(e)),e=Hr(e);return t}:oi;function fi(e,t){return Pt(e,di(e),t)}function pi(e,t,n){var r=t(e);return b(e)?r:Lr(r,n(e))}function mi(e){return pi(e,C,li)}function hi(e){return pi(e,Kn,di)}var gi=ct(v,`DataView`),_i=ct(v,`Promise`),vi=ct(v,`Set`),yi=`[object Map]`,bi=`[object Object]`,xi=`[object Promise]`,Si=`[object Set]`,Ci=`[object WeakMap]`,wi=`[object DataView]`,Ti=Qe(gi),Ei=Qe(hr),Di=Qe(_i),Oi=Qe(vi),ki=Qe(lt),Ai=ve;(gi&&Ai(new gi(new ArrayBuffer(1)))!=wi||hr&&Ai(new hr)!=yi||_i&&Ai(_i.resolve())!=xi||vi&&Ai(new vi)!=Si||lt&&Ai(new lt)!=Ci)&&(Ai=function(e){var t=ve(e),n=t==bi?e.constructor:void 0,r=n?Qe(n):``;if(r)switch(r){case Ti:return wi;case Ei:return yi;case Di:return xi;case Oi:return Si;case ki:return Ci}return t});var ji=Ai,Mi=Object.prototype.hasOwnProperty;function Ni(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&Mi.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var Pi=v.Uint8Array;function Fi(e){var t=new e.constructor(e.byteLength);return new Pi(t).set(new Pi(e)),t}function Ii(e,t){var n=t?Fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var Li=/\w*$/;function Ri(e){var t=new e.constructor(e.source,Li.exec(e));return t.lastIndex=e.lastIndex,t}var zi=y?y.prototype:void 0,Bi=zi?zi.valueOf:void 0;function Vi(e){return Bi?Object(Bi.call(e)):{}}function Hi(e,t){var n=t?Fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var Ui=`[object Boolean]`,Wi=`[object Date]`,Gi=`[object Map]`,Ki=`[object Number]`,qi=`[object RegExp]`,Ji=`[object Set]`,Yi=`[object String]`,Xi=`[object Symbol]`,Zi=`[object ArrayBuffer]`,Qi=`[object DataView]`,$i=`[object Float32Array]`,ea=`[object Float64Array]`,ta=`[object Int8Array]`,na=`[object Int16Array]`,ra=`[object Int32Array]`,ia=`[object Uint8Array]`,aa=`[object Uint8ClampedArray]`,oa=`[object Uint16Array]`,sa=`[object Uint32Array]`;function ca(e,t,n){var r=e.constructor;switch(t){case Zi:return Fi(e);case Ui:case Wi:return new r(+e);case Qi:return Ii(e,n);case $i:case ea:case ta:case na:case ra:case ia:case aa:case oa:case sa:return Hi(e,n);case Gi:return new r;case Ki:case Yi:return new r(e);case qi:return Ri(e);case Ji:return new r;case Xi:return Vi(e)}}function la(e){return typeof e.constructor==`function`&&!Wt(e)?dt(Hr(e)):{}}var ua=`[object Map]`;function da(e){return ye(e)&&ji(e)==ua}var fa=Nn&&Nn.isMap,pa=fa?kn(fa):da,ma=`[object Set]`;function ha(e){return ye(e)&&ji(e)==ma}var ga=Nn&&Nn.isSet,_a=ga?kn(ga):ha,va=1,ya=2,ba=4,xa=`[object Arguments]`,Sa=`[object Array]`,Ca=`[object Boolean]`,wa=`[object Date]`,Ta=`[object Error]`,Ea=`[object Function]`,Da=`[object GeneratorFunction]`,Oa=`[object Map]`,ka=`[object Number]`,Aa=`[object Object]`,ja=`[object RegExp]`,Ma=`[object Set]`,Na=`[object String]`,Pa=`[object Symbol]`,Fa=`[object WeakMap]`,Ia=`[object ArrayBuffer]`,La=`[object DataView]`,Ra=`[object Float32Array]`,za=`[object Float64Array]`,Ba=`[object Int8Array]`,Va=`[object Int16Array]`,Ha=`[object Int32Array]`,Ua=`[object Uint8Array]`,Wa=`[object Uint8ClampedArray]`,Ga=`[object Uint16Array]`,Ka=`[object Uint32Array]`,T={};T[xa]=T[Sa]=T[Ia]=T[La]=T[Ca]=T[wa]=T[Ra]=T[za]=T[Ba]=T[Va]=T[Ha]=T[Oa]=T[ka]=T[Aa]=T[ja]=T[Ma]=T[Na]=T[Pa]=T[Ua]=T[Wa]=T[Ga]=T[Ka]=!0,T[Ta]=T[Ea]=T[Fa]=!1;function qa(e,t,n,r,i,a){var o,s=t&va,c=t&ya,l=t&ba;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!je(e))return e;var u=b(e);if(u){if(o=Ni(e),!s)return pt(e,o)}else{var d=ji(e),f=d==Ea||d==Da;if(nn(e))return ii(e,s);if(d==Aa||d==xa||f&&!i){if(o=c||f?{}:la(e),!s)return c?fi(e,$r(o,e)):ui(e,Qr(o,e))}else{if(!T[d])return i?e:{};o=ca(e,d,s)}}a||=new Zr;var p=a.get(e);if(p)return p;a.set(e,o),_a(e)?e.forEach(function(r){o.add(qa(r,t,n,r,e,a))}):pa(e)&&e.forEach(function(r,i){o.set(i,qa(r,t,n,i,e,a))});var m=u?void 0:(l?c?hi:mi:c?Kn:C)(e);return xt(m||e,function(r,i){m&&(i=r,r=e[i]),Nt(o,i,qa(r,t,n,i,e,a))}),o}var Ja=4;function E(e){return qa(e,Ja)}function Ya(e){for(var t=-1,n=e==null?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i}var Xa=`__lodash_hash_undefined__`;function Za(e){return this.__data__.set(e,Xa),this}function Qa(e){return this.__data__.has(e)}function $a(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Cr;++t<n;)this.add(e[t])}$a.prototype.add=$a.prototype.push=Za,$a.prototype.has=Qa;function eo(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function to(e,t){return e.has(t)}var no=1,ro=2;function io(e,t,n,r,i,a){var o=n&no,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&ro?new $a:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!eo(t,function(e,t){if(!to(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function ao(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function oo(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var so=1,co=2,lo=`[object Boolean]`,uo=`[object Date]`,fo=`[object Error]`,po=`[object Map]`,mo=`[object Number]`,ho=`[object RegExp]`,go=`[object Set]`,_o=`[object String]`,vo=`[object Symbol]`,yo=`[object ArrayBuffer]`,bo=`[object DataView]`,xo=y?y.prototype:void 0,So=xo?xo.valueOf:void 0;function Co(e,t,n,r,i,a,o){switch(n){case bo:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case yo:return!(e.byteLength!=t.byteLength||!a(new Pi(e),new Pi(t)));case lo:case uo:case mo:return jt(+e,+t);case fo:return e.name==t.name&&e.message==t.message;case ho:case _o:return e==t+``;case po:var s=ao;case go:var c=r&so;if(s||=oo,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=co,o.set(e,t);var u=io(s(e),s(t),r,i,a,o);return o.delete(e),u;case vo:if(So)return So.call(e)==So.call(t)}return!1}var wo=1,To=Object.prototype.hasOwnProperty;function Eo(e,t,n,r,i,a){var o=n&wo,s=mi(e),c=s.length;if(c!=mi(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:To.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var ee=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(ee===void 0?h===g||i(h,g,n,r,a):ee)){p=!1;break}m||=u==`constructor`}if(p&&!m){var te=e.constructor,_=t.constructor;te!=_&&`constructor`in e&&`constructor`in t&&!(typeof te==`function`&&te instanceof te&&typeof _==`function`&&_ instanceof _)&&(p=!1)}return a.delete(e),a.delete(t),p}var Do=1,Oo=`[object Arguments]`,ko=`[object Array]`,Ao=`[object Object]`,jo=Object.prototype.hasOwnProperty;function Mo(e,t,n,r,i,a){var o=b(e),s=b(t),c=o?ko:ji(e),l=s?ko:ji(t);c=c==Oo?Ao:c,l=l==Oo?Ao:l;var u=c==Ao,d=l==Ao,f=c==l;if(f&&nn(e)){if(!nn(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new Zr,o||Fn(e)?io(e,t,n,r,i,a):Co(e,t,c,n,r,i,a);if(!(n&Do)){var p=u&&jo.call(e,`__wrapped__`),m=d&&jo.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new Zr,i(h,g,n,r,a)}}return f?(a||=new Zr,Eo(e,t,n,r,i,a)):!1}function No(e,t,n,r,i){return e===t?!0:e==null||t==null||!ye(e)&&!ye(t)?e!==e&&t!==t:Mo(e,t,n,r,No,i)}var Po=1,Fo=2;function Io(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new Zr;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?No(u,l,Po|Fo,r,d):f))return!1}}return!0}function Lo(e){return e===e&&!je(e)}function Ro(e){for(var t=C(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Lo(i)]}return t}function zo(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function Bo(e){var t=Ro(e);return t.length==1&&t[0][2]?zo(t[0][0],t[0][1]):function(n){return n===e||Io(n,e,t)}}function Vo(e,t){return e!=null&&t in Object(e)}function Ho(e,t,n){t=Mr(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=Pr(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&zt(i)&&kt(o,i)&&(b(e)||Zt(e)))}function Uo(e,t){return e!=null&&Ho(e,t,Vo)}var Wo=1,Go=2;function Ko(e,t){return Yn(e)&&Lo(t)?zo(Pr(e),t):function(n){var r=Ir(n,e);return r===void 0&&r===t?Uo(n,e):No(t,r,Wo|Go)}}function qo(e){return function(t){return t?.[e]}}function Jo(e){return function(t){return Fr(t,e)}}function Yo(e){return Yn(e)?qo(Pr(e)):Jo(e)}function Xo(e){return typeof e==`function`?e:e==null?He:typeof e==`object`?b(e)?Ko(e[0],e[1]):Bo(e):Yo(e)}function Zo(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Qo(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var $o=Qo();function es(e,t){return e&&$o(e,t,C)}function ts(e,t){return function(n,r){if(n==null)return n;if(!Bt(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var ns=ts(es);function rs(e,t,n,r){return ns(e,function(e,i,a){t(r,e,n(e),a)}),r}function is(e,t){return function(n,r){var i=b(n)?Zo:rs,a=t?t():{};return i(n,e,Xo(r,2),a)}}var as=Object.prototype,os=as.hasOwnProperty,ss=Lt(function(e,t){e=Object(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&Vt(t[0],t[1],i)&&(r=1);++n<r;)for(var a=t[n],o=Kn(a),s=-1,c=o.length;++s<c;){var l=o[s],u=e[l];(u===void 0||jt(u,as[l])&&!os.call(e,l))&&(e[l]=a[l])}return e});function cs(e){return ye(e)&&Bt(e)}function ls(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}var us=200;function ds(e,t,n,r){var i=-1,a=Et,o=!0,s=e.length,c=[],l=t.length;if(!s)return c;n&&(t=Se(t,kn(n))),r?(a=ls,o=!1):t.length>=us&&(a=to,o=!1,t=new $a(t));outer:for(;++i<s;){var u=e[i],d=n==null?u:n(u);if(u=r||u!==0?u:0,o&&d===d){for(var f=l;f--;)if(t[f]===d)continue outer;c.push(u)}else a(t,d,r)||c.push(u)}return c}var fs=Lt(function(e,t){return cs(e)?ds(e,Br(t,1,cs,!0)):[]});function ps(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}function D(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:Ve(t),Ur(e,t<0?0:t,r)):[]}function ms(e,t,n){var r=e==null?0:e.length;return r?(t=n||t===void 0?1:Ve(t),t=r-t,Ur(e,0,t<0?0:t)):[]}function hs(e){return typeof e==`function`?e:He}function O(e,t){return(b(e)?xt:ns)(e,hs(t))}function gs(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function _s(e,t){var n=!0;return ns(e,function(e,r,i){return n=!!t(e,r,i),n}),n}function vs(e,t,n){var r=b(e)?gs:_s;return n&&Vt(e,t,n)&&(t=void 0),r(e,Xo(t,3))}function ys(e,t){var n=[];return ns(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function bs(e,t){return(b(e)?ai:ys)(e,Xo(t,3))}function xs(e){return function(t,n,r){var i=Object(t);if(!Bt(t)){var a=Xo(n,3);t=C(t),n=function(e){return a(i[e],e,i)}}var o=e(t,n,r);return o>-1?i[a?t[o]:o]:void 0}}var Ss=Math.max;function Cs(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:Ve(n);return i<0&&(i=Ss(r+i,0)),St(e,Xo(t,3),i)}var ws=xs(Cs);function Ts(e){return e&&e.length?e[0]:void 0}function Es(e,t){var n=-1,r=Bt(e)?Array(e.length):[];return ns(e,function(e,i,a){r[++n]=t(e,i,a)}),r}function k(e,t){return(b(e)?Se:Es)(e,Xo(t,3))}function Ds(e,t){return Br(k(e,t),1)}var Os=Object.prototype.hasOwnProperty,ks=is(function(e,t,n){Os.call(e,n)?e[n].push(t):At(e,n,[t])}),As=Object.prototype.hasOwnProperty;function js(e,t){return e!=null&&As.call(e,t)}function A(e,t){return e!=null&&Ho(e,t,js)}var Ms=`[object String]`;function j(e){return typeof e==`string`||!b(e)&&ye(e)&&ve(e)==Ms}function Ns(e,t){return Se(t,function(t){return e[t]})}function M(e){return e==null?[]:Ns(e,C(e))}var Ps=Math.max;function N(e,t,n,r){e=Bt(e)?e:M(e),n=n&&!r?Ve(n):0;var i=e.length;return n<0&&(n=Ps(i+n,0)),j(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Tt(e,t,n)>-1}var Fs=Math.max;function Is(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:Ve(n);return i<0&&(i=Fs(r+i,0)),Tt(e,t,i)}var Ls=`[object Map]`,Rs=`[object Set]`,zs=Object.prototype.hasOwnProperty;function P(e){if(e==null)return!0;if(Bt(e)&&(b(e)||typeof e==`string`||typeof e.splice==`function`||nn(e)||Fn(e)||Zt(e)))return!e.length;var t=ji(e);if(t==Ls||t==Rs)return!e.size;if(Wt(e))return!Vn(e).length;for(var n in e)if(zs.call(e,n))return!1;return!0}var Bs=`[object RegExp]`;function Vs(e){return ye(e)&&ve(e)==Bs}var Hs=Nn&&Nn.isRegExp,Us=Hs?kn(Hs):Vs;function Ws(e){return e===void 0}var Gs=`Expected a function`;function Ks(e){if(typeof e!=`function`)throw TypeError(Gs);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function qs(e,t,n,r){if(!je(e))return e;t=Mr(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=Pr(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=je(u)?u:kt(t[i+1])?[]:{})}Nt(s,c,l),s=s[c]}return e}function Js(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Fr(e,o);n(s,o)&&qs(a,Mr(o,e),s)}return a}function Ys(e,t){if(e==null)return{};var n=Se(hi(e),function(e){return[e]});return t=Xo(t),Js(e,n,function(e,n){return t(e,n[0])})}function Xs(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function F(e,t,n){var r=b(e)?Wr:Xs,i=arguments.length<3;return r(e,Xo(t,4),n,i,ns)}function Zs(e,t){return(b(e)?ai:ys)(e,Ks(Xo(t,3)))}function Qs(e,t){var n;return ns(e,function(e,r,i){return n=t(e,r,i),!n}),!!n}function $s(e,t,n){var r=b(e)?eo:Qs;return n&&Vt(e,t,n)&&(t=void 0),r(e,Xo(t,3))}var ec=vi&&1/oo(new vi([,-0]))[1]==1/0?function(e){return new vi(e)}:x,tc=200;function nc(e,t,n){var r=-1,i=Et,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=ls;else if(a>=tc){var l=t?null:ec(e);if(l)return oo(l);o=!1,i=to,c=new $a}else c=t?[]:s;outer:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue outer;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}function rc(e){return e&&e.length?nc(e):[]}function ic(e){console&&console.error&&console.error(`Error: ${e}`)}function ac(e){console&&console.warn&&console.warn(`Warning: ${e}`)}function oc(e){let t=new Date().getTime(),n=e();return{time:new Date().getTime()-t,value:n}}function sc(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}function cc(e){return lc(e)?e.LABEL:e.name}function lc(e){return j(e.LABEL)&&e.LABEL!==``}var uc=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),O(this.definition,t=>{t.accept(e)})}},I=class extends uc{constructor(e){super([]),this.idx=1,w(this,Ys(e,e=>e!==void 0))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},dc=class extends uc{constructor(e){super(e.definition),this.orgText=``,w(this,Ys(e,e=>e!==void 0))}},L=class extends uc{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,w(this,Ys(e,e=>e!==void 0))}},R=class extends uc{constructor(e){super(e.definition),this.idx=1,w(this,Ys(e,e=>e!==void 0))}},fc=class extends uc{constructor(e){super(e.definition),this.idx=1,w(this,Ys(e,e=>e!==void 0))}},pc=class extends uc{constructor(e){super(e.definition),this.idx=1,w(this,Ys(e,e=>e!==void 0))}},z=class extends uc{constructor(e){super(e.definition),this.idx=1,w(this,Ys(e,e=>e!==void 0))}},mc=class extends uc{constructor(e){super(e.definition),this.idx=1,w(this,Ys(e,e=>e!==void 0))}},hc=class extends uc{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,w(this,Ys(e,e=>e!==void 0))}},B=class{constructor(e){this.idx=1,w(this,Ys(e,e=>e!==void 0))}accept(e){e.visit(this)}};function gc(e){return k(e,_c)}function _c(e){function t(e){return k(e,_c)}if(e instanceof I){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return j(e.label)&&(t.label=e.label),t}if(e instanceof L)return{type:`Alternative`,definition:t(e.definition)};if(e instanceof R)return{type:`Option`,idx:e.idx,definition:t(e.definition)};if(e instanceof fc)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};if(e instanceof pc)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:_c(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof mc)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:_c(new B({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof z)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};if(e instanceof hc)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};if(e instanceof B){let t={type:`Terminal`,name:e.terminalType.name,label:cc(e.terminalType),idx:e.idx};j(e.label)&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=Us(n)?n.source:n),t}if(e instanceof dc)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error(`non exhaustive match`)}var vc=class{visit(e){let t=e;switch(t.constructor){case I:return this.visitNonTerminal(t);case L:return this.visitAlternative(t);case R:return this.visitOption(t);case fc:return this.visitRepetitionMandatory(t);case pc:return this.visitRepetitionMandatoryWithSeparator(t);case mc:return this.visitRepetitionWithSeparator(t);case z:return this.visitRepetition(t);case hc:return this.visitAlternation(t);case B:return this.visitTerminal(t);case dc: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 yc(e){return e instanceof L||e instanceof R||e instanceof z||e instanceof fc||e instanceof pc||e instanceof mc||e instanceof B||e instanceof dc}function bc(e,t=[]){return e instanceof R||e instanceof z||e instanceof mc?!0:e instanceof hc?$s(e.definition,e=>bc(e,t)):e instanceof I&&N(t,e)?!1:e instanceof uc&&(e instanceof I&&t.push(e),vs(e.definition,e=>bc(e,t)))}function xc(e){return e instanceof hc}function Sc(e){if(e instanceof I)return`SUBRULE`;if(e instanceof R)return`OPTION`;if(e instanceof hc)return`OR`;if(e instanceof fc)return`AT_LEAST_ONE`;if(e instanceof pc)return`AT_LEAST_ONE_SEP`;if(e instanceof mc)return`MANY_SEP`;if(e instanceof z)return`MANY`;if(e instanceof B)return`CONSUME`;throw Error(`non exhaustive match`)}var Cc=class{walk(e,t=[]){O(e.definition,(n,r)=>{let i=D(e.definition,r+1);if(n instanceof I)this.walkProdRef(n,i,t);else if(n instanceof B)this.walkTerminal(n,i,t);else if(n instanceof L)this.walkFlat(n,i,t);else if(n instanceof R)this.walkOption(n,i,t);else if(n instanceof fc)this.walkAtLeastOne(n,i,t);else if(n instanceof pc)this.walkAtLeastOneSep(n,i,t);else if(n instanceof mc)this.walkManySep(n,i,t);else if(n instanceof z)this.walkMany(n,i,t);else if(n instanceof hc)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new R({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=wc(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new R({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=wc(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);O(e.definition,e=>{let t=new L({definition:[e]});this.walk(t,r)})}};function wc(e,t,n){return[new R({definition:[new B({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function Tc(e){if(e instanceof I)return Tc(e.referencedRule);if(e instanceof B)return Oc(e);if(yc(e))return Ec(e);if(xc(e))return Dc(e);throw Error(`non exhaustive match`)}function Ec(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=bc(a),t=t.concat(Tc(a)),r+=1,i=n.length>r;return rc(t)}function Dc(e){return rc(Vr(k(e.definition,e=>Tc(e))))}function Oc(e){return[e.terminalType]}var kc=`_~IN~_`,Ac=class extends Cc{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=Mc(e.referencedRule,e.idx)+this.topProd.name,i=Tc(new L({definition:t.concat(n)}));this.follows[r]=i}};function jc(e){let t={};return O(e,e=>{let n=new Ac(e).startWalking();w(t,n)}),t}function Mc(e,t){return e.name+t+kc}function V(e){return e.charCodeAt(0)}function Nc(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function Pc(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function Fc(e){if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}function Ic(){throw Error(`Internal Error - Should never get here!`)}function Lc(e){return e.type===`Character`}var Rc=[];for(let e=V(`0`);e<=V(`9`);e++)Rc.push(e);var zc=[V(`_`)].concat(Rc);for(let e=V(`a`);e<=V(`z`);e++)zc.push(e);for(let e=V(`A`);e<=V(`Z`);e++)zc.push(e);var Bc=[V(` `),V(`\f`),V(`
2
+ `),V(`\r`),V(` `),V(`\v`),V(` `),V(`\xA0`),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(` `),V(`\u2028`),V(`\u2029`),V(` `),V(` `),V(` `),V(``)],Vc=/[0-9a-fA-F]/,Hc=/[0-9]/,Uc=/[1-9]/,Wc=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let n={type:`Flags`,loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case`g`:Pc(n,`global`);break;case`i`:Pc(n,`ignoreCase`);break;case`m`:Pc(n,`multiLine`);break;case`u`:Pc(n,`unicode`);break;case`y`:Pc(n,`sticky`)}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}}Fc(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}return Ic()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`)}if(e===!0&&t===void 0)return;Fc(t)}if((e!==!0||t!==void 0)&&Fc(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group()}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Fc(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Ic()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[V(`
3
+ `),V(`\r`),V(`\u2028`),V(`\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=Rc;break;case`D`:e=Rc,t=!0;break;case`s`:e=Bc;break;case`S`:e=Bc,t=!0;break;case`w`:e=zc;break;case`W`:e=zc,t=!0}return Fc(e)?{type:`Set`,value:e,complement:t}:Ic()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=V(`\f`);break;case`n`:e=V(`
4
+ `);break;case`r`:e=V(`\r`);break;case`t`:e=V(` `);break;case`v`:e=V(`\v`)}return Fc(e)?{type:`Character`,value:e}:Ic()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:V(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:V(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case`\r`:case`\u2028`:case`\u2029`:case`\\`:case`]`:throw Error(`TBD`);default:return{type:`Character`,value:V(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,Lc(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,Lc(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else Nc(t.value,e),e.push(V(`-`)),Nc(n.value,e)}else Nc(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){case`]`:case`
6
+ `:case`\r`:case`\u2028`:case`\u2029`:throw Error(`TBD`);case`\\`:return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`b`:return this.consumeChar(`b`),{type:`Character`,value:V(`\b`)};case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar(`(`),this.peekChar(0)){case`?`:this.consumeChar(`?`),this.consumeChar(`:`),e=!1;break;default:this.groupIdx++}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(Uc.test(e)===!1)throw Error(`Expecting a positive integer`);for(;Hc.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Hc.test(e)===!1)throw Error(`Expecting an integer`);for(;Hc.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
7
+ `:case`\r`:case`\u2028`:case`\u2029`:case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:throw Error(`TBD`);default:return{type:`Character`,value:V(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 Hc.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
8
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`||this.peekChar(2)===`<`&&(this.peekChar(3)===`=`||this.peekChar(3)===`!`));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
9
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(Vc.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error(`Expected: '`+e+`' but found: '`+this.input[this.idx]+`' at offset: `+this.idx);if(this.idx>=this.input.length)throw Error(`Unexpected end of input`);this.idx++}loc(e){return{begin:e,end:this.idx}}},Gc=class{visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Lookbehind`:this.visitLookbehind(e);break;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},Kc={},qc=new Wc;function Jc(e){let t=e.toString();if(Kc.hasOwnProperty(t))return Kc[t];{let e=qc.pattern(t);return Kc[t]=e,e}}function Yc(){Kc={}}var Xc=`Complement Sets are not supported for first char optimization`,Zc=`Unable to use "first char" lexer optimizations:
10
+ `;function Qc(e,t=!1){try{let t=Jc(e);return $c(t.value,{},t.flags.ignoreCase)}catch(n){if(n.message===Xc)t&&ac(`${Zc}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
11
+ This will disable the lexer's first char optimizations.
12
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
13
+ This will disable the lexer's first char optimizations.
14
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),ic(`${Zc}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function $c(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)$c(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`Lookbehind`:case`NegativeLookbehind`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:el(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(Xc);O(a.value,e=>{if(typeof e==`number`)el(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)el(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)el(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=Rl(e),a=Rl(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:$c(a.value,t,n);break;default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&rl(a)===!1||a.type!==`Group`&&o===!1)break}break;default:throw Error(`non exhaustive match!`)}return M(t)}function el(e,t,n){let r=Rl(e);t[r]=r,n===!0&&tl(e,t)}function tl(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();if(r!==n){let e=Rl(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=Rl(e.charCodeAt(0));t[n]=n}}}function nl(e,t){return ws(e.value,e=>{if(typeof e==`number`)return N(t,e);{let n=e;return ws(t,e=>n.from<=e&&e<=n.to)!==void 0}})}function rl(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?b(e.value)?vs(e.value,rl):rl(e.value):!1}var il=class extends Gc{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case`Lookahead`:this.visitLookahead(e);return;case`NegativeLookahead`:this.visitNegativeLookahead(e);return;case`Lookbehind`:this.visitLookbehind(e);return;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){N(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?nl(e,this.targetCharCodes)===void 0&&(this.found=!0):nl(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function al(e,t){if(t instanceof RegExp){let n=Jc(t),r=new il(e);return r.visit(n),r.found}return ws(t,t=>N(e,t.charCodeAt(0)))!==void 0}var ol=`PATTERN`,sl=`defaultMode`;function cl(e,t){t=ss(t,{debug:!1,safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
15
+ `],tracer:(e,t)=>t()});let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{zl()});let r;n(`Reject Lexer.NA`,()=>{r=Zs(e,e=>e[ol]===U.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=k(r,e=>{let t=e[ol];if(Us(t)){let e=t.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!t.ignoreCase?e:e.length===2&&e[0]===`\\`&&!N([`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`],e[1])?e[1]:El(t)}if(qe(t))return i=!0,{exec:t};if(typeof t==`object`)return i=!0,t;if(typeof t==`string`){if(t.length===1)return t;{let e=t.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`);return El(new RegExp(e))}}throw Error(`non exhaustive match`)})});let o,s,c,l,u;n(`misc mapping`,()=>{o=k(r,e=>e.tokenTypeIdx),s=k(r,e=>{let t=e.GROUP;if(t!==U.SKIPPED){if(j(t))return t;if(Ws(t))return!1;throw Error(`non exhaustive match`)}}),c=k(r,e=>{let t=e.LONGER_ALT;if(t)return b(t)?k(t,e=>Is(r,e)):[Is(r,t)]}),l=k(r,e=>e.PUSH_MODE),u=k(r,e=>A(e,`POP_MODE`))});let d;n(`Line Terminator Handling`,()=>{let e=Fl(t.lineTerminatorCharacters);d=k(r,e=>!1),t.positionTracking!==`onlyOffset`&&(d=k(r,t=>A(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:Nl(t,e)===!1&&al(e,t.PATTERN)))});let f,p,m,h;n(`Misc Mapping #2`,()=>{f=k(r,Al),p=k(a,jl),m=F(r,(e,t)=>{let n=t.GROUP;return j(n)&&n!==U.SKIPPED&&(e[n]=[]),e},{}),h=k(a,(e,t)=>({pattern:a[t],longerAlt:c[t],canLineTerminator:d[t],isCustom:f[t],short:p[t],group:s[t],push:l[t],pop:u[t],tokenTypeIdx:o[t],tokenType:r[t]}))});let g=!0,ee=[];return t.safeMode||n(`First Char Optimization`,()=>{ee=F(r,(e,n,r)=>{if(typeof n.PATTERN==`string`)Il(e,Rl(n.PATTERN.charCodeAt(0)),h[r]);else if(b(n.START_CHARS_HINT)){let t;O(n.START_CHARS_HINT,n=>{let i=Rl(typeof n==`string`?n.charCodeAt(0):n);t!==i&&(t=i,Il(e,i,h[r]))})}else if(Us(n.PATTERN)){if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&ic(`${Zc}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
16
+ This will disable the lexer's first char optimizations.
17
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=Qc(n.PATTERN,t.ensureOptimizations);P(i)&&(g=!1),O(i,t=>{Il(e,t,h[r])})}}else t.ensureOptimizations&&ic(`${Zc}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
18
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e},[])}),{emptyGroups:m,patternIdxToConfig:h,charCodeToPatternIdxToConfig:ee,hasCustom:i,canBeOptimized:g}}function ll(e,t){let n=[],r=dl(e);n=n.concat(r.errors);let i=fl(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(ul(a)),n=n.concat(bl(a)),n=n.concat(xl(a,t)),n=n.concat(Sl(a)),n}function ul(e){let t=[],n=bs(e,e=>Us(e[ol]));return t=t.concat(ml(n)),t=t.concat(_l(n)),t=t.concat(vl(n)),t=t.concat(yl(n)),t=t.concat(hl(n)),t}function dl(e){let t=bs(e,e=>!A(e,ol));return{errors:k(t,e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:H.MISSING_PATTERN,tokenTypes:[e]})),valid:fs(e,t)}}function fl(e){let t=bs(e,e=>{let t=e[ol];return!Us(t)&&!qe(t)&&!A(t,`exec`)&&!j(t)});return{errors:k(t,e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:H.INVALID_PATTERN,tokenTypes:[e]})),valid:fs(e,t)}}var pl=/[^\\][$]/;function ml(e){class t extends Gc{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return k(bs(e,e=>{let n=e.PATTERN;try{let e=Jc(n),r=new t;return r.visit(e),r.found}catch{return pl.test(n.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
19
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
20
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:H.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function hl(e){return k(bs(e,e=>e.PATTERN.test(``)),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:H.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}var gl=/[^\\[][\^]|^\^/;function _l(e){class t extends Gc{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return k(bs(e,e=>{let n=e.PATTERN;try{let e=Jc(n),r=new t;return r.visit(e),r.found}catch{return gl.test(n.source)}}),e=>({message:`Unexpected RegExp Anchor Error:
21
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
22
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:H.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function vl(e){return k(bs(e,e=>{let t=e[ol];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:H.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function yl(e){let t=[],n=k(e,n=>F(e,(e,r)=>n.PATTERN.source===r.PATTERN.source&&!N(t,r)&&r.PATTERN!==U.NA?(t.push(r),e.push(r),e):e,[]));return n=Ya(n),k(bs(n,e=>e.length>1),e=>{let t=k(e,e=>e.name);return{message:`The same RegExp pattern ->${Ts(e).PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:H.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function bl(e){return k(bs(e,e=>{if(!A(e,`GROUP`))return!1;let t=e.GROUP;return t!==U.SKIPPED&&t!==U.NA&&!j(t)}),e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:H.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function xl(e,t){return k(bs(e,e=>e.PUSH_MODE!==void 0&&!N(t,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:H.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function Sl(e){let t=[],n=F(e,(e,t,n)=>{let r=t.PATTERN;return r===U.NA||(j(r)?e.push({str:r,idx:n,tokenType:t}):Us(r)&&wl(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return O(e,(e,r)=>{O(n,({str:n,idx:i,tokenType:a})=>{if(r<i&&Cl(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:H.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function Cl(e,t){if(Us(t)){if(Tl(t))return!1;let n=t.exec(e);return n!==null&&n.index===0}if(qe(t))return t(e,0,[],{});if(A(t,`exec`))return t.exec(e,0,[],{});if(typeof t==`string`)return t===e;throw Error(`non exhaustive match`)}function wl(e){return ws([`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`],t=>e.source.indexOf(t)!==-1)===void 0}function Tl(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}function El(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function Dl(e,t,n){let r=[];return A(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition
23
+ `,type:H.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),A(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
24
+ `,type:H.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),A(e,`modes`)&&A(e,`defaultMode`)&&!A(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${sl}: <${e.defaultMode}>which does not exist\n`,type:H.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),A(e,`modes`)&&O(e.modes,(e,t)=>{O(e,(n,i)=>{Ws(n)?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:H.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):A(n,`LONGER_ALT`)&&O(b(n.LONGER_ALT)?n.LONGER_ALT:[n.LONGER_ALT],i=>{!Ws(i)&&!N(e,i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${n.name}> outside of mode <${t}>\n`,type:H.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function Ol(e,t,n){let r=[],i=!1,a=Zs(Ya(Vr(M(e.modes))),e=>e[ol]===U.NA),o=Fl(n);return t&&O(a,e=>{let t=Nl(e,o);if(t!==!1){let n={message:Pl(e,t),type:t.issue,tokenType:e};r.push(n)}else A(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):al(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
25
+ This Lexer has been defined to track line and column information,
26
+ But none of the Token Types can be identified as matching a line terminator.
27
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
28
+ for details.`,type:H.NO_LINE_BREAKS_FLAGS}),r}function kl(e){let t={};return O(C(e),n=>{let r=e[n];if(b(r))t[n]=[];else throw Error(`non exhaustive match`)}),t}function Al(e){let t=e.PATTERN;if(Us(t))return!1;if(qe(t)||A(t,`exec`))return!0;if(j(t))return!1;throw Error(`non exhaustive match`)}function jl(e){return j(e)&&e.length===1?e.charCodeAt(0):!1}var Ml={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return this.lastIndex=e.charCodeAt(n+1)===10?n+2:n+1,!0}return!1},lastIndex:0};function Nl(e,t){if(A(e,`LINE_BREAKS`))return!1;if(Us(e.PATTERN)){try{al(t,e.PATTERN)}catch(e){return{issue:H.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(j(e.PATTERN))return!1;if(Al(e))return{issue:H.CUSTOM_LINE_BREAK};throw Error(`non exhaustive match`)}function Pl(e,t){if(t.issue===H.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
29
+ \tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===H.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
30
+ \tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function Fl(e){return k(e,e=>j(e)?e.charCodeAt(0):e)}function Il(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}var Ll=[];function Rl(e){return e<256?e:Ll[e]}function zl(){if(P(Ll)){Ll=Array(65536);for(let e=0;e<65536;e++)Ll[e]=e>255?255+~~(e/255):e}}function Bl(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx||t.isParent===!0&&t.categoryMatchesMap[n]===!0}function Vl(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Hl=1,Ul={};function Wl(e){let t=Gl(e);Kl(t),Jl(t),ql(t),O(t,e=>{e.isParent=e.categoryMatches.length>0})}function Gl(e){let t=E(e),n=e,r=!0;for(;r;){n=Ya(Vr(k(n,e=>e.CATEGORIES)));let e=fs(n,t);t=t.concat(e),P(e)?r=!1:n=e}return t}function Kl(e){O(e,e=>{Xl(e)||(Ul[Hl]=e,e.tokenTypeIdx=Hl++),Zl(e)&&!b(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Zl(e)||(e.CATEGORIES=[]),Ql(e)||(e.categoryMatches=[]),$l(e)||(e.categoryMatchesMap={})})}function ql(e){O(e,e=>{e.categoryMatches=[],O(e.categoryMatchesMap,(t,n)=>{e.categoryMatches.push(Ul[n].tokenTypeIdx)})})}function Jl(e){O(e,e=>{Yl([],e)})}function Yl(e,t){O(e,e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),O(t.CATEGORIES,n=>{let r=e.concat(t);N(r,n)||Yl(r,n)})}function Xl(e){return A(e,`tokenTypeIdx`)}function Zl(e){return A(e,`CATEGORIES`)}function Ql(e){return A(e,`categoryMatches`)}function $l(e){return A(e,`categoryMatchesMap`)}function eu(e){return A(e,`tokenTypeIdx`)}var tu={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i,a){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}},H;(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`})(H||={});var nu={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
31
+ `,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:tu,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(nu);var U=class{constructor(e,t=nu){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=oc(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
32
+ a boolean 2nd argument is no longer supported`);this.config=w({},nu,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT(`Lexer Constructor`,()=>{let n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===nu.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Ml;else if(this.config.lineTerminatorCharacters===nu.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
33
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),b(e)?n={modes:{defaultMode:E(e)},defaultMode:sl}:(r=!1,n=E(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Dl(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Ol(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},O(n.modes,(e,t)=>{n.modes[t]=Zs(e,e=>Ws(e))});let i=C(n.modes);if(O(n.modes,(e,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(ll(e,i))}),P(this.lexerDefinitionErrors)){Wl(e);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=cl(e,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=w({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!P(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let e=k(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
34
+ `);throw Error(`Errors detected in definition of Lexer:
35
+ `+e)}O(this.lexerDefinitionWarning,e=>{ac(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(r&&(this.handleModes=x),this.trackStartLines===!1&&(this.computeNewColumn=He),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=x),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=F(this.canModeBeOptimized,(e,t,n)=>(t===!1&&e.push(n),e),[]);if(t.ensureOptimizations&&!P(e))throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
36
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{Yc()}),this.TRACE_INIT(`toFastProperties`,()=>{sc(this)})})}tokenize(e,t=this.defaultMode){if(!P(this.lexerDefinitionErrors)){let e=k(this.lexerDefinitionErrors,e=>e.message).join(`-----------------------
37
+ `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
38
+ `+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,ee=e,te=ee.length,_=0,ne=0,re=this.hasCustom?0:Math.floor(e.length/10),ie=Array(re),ae=[],oe=this.trackStartLines?1:void 0,se=this.trackStartLines?1:void 0,v=kl(this.emptyGroups),y=this.trackStartLines,ce=this.config.lineTerminatorsPattern,le=0,ue=[],de=[],fe=[],pe=[];Object.freeze(pe);let me=!1,he=e=>{if(fe.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);ae.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{fe.pop();let e=ps(fe);ue=this.patternIdxToConfig[e],de=this.charCodeToPatternIdxToConfig[e],le=ue.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;me=!!(de&&t)}};function ge(e){fe.push(e),de=this.charCodeToPatternIdxToConfig[e],ue=this.patternIdxToConfig[e],le=ue.length,le=ue.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;me=!!(de&&t)}ge.call(this,t);let _e,ve=this.config.recoveryEnabled;for(;_<te;){s=null,u=-1;let t=ee.charCodeAt(_),re;if(me){let e=Rl(t),n=de[e];re=n===void 0?pe:n}else re=ue;let ye=re.length;for(n=0;n<ye;n++){_e=re[n];let r=_e.pattern;c=null;let d=_e.short;if(d===!1?_e.isCustom===!0?(g=r.exec(ee,_,ie,v),g===null?s=null:(s=g[0],u=s.length,g.payload!==void 0&&(c=g.payload))):(r.lastIndex=_,u=this.matchLength(r,e,_)):t===d&&(u=1,s=r),u!==-1){if(o=_e.longerAlt,o!==void 0){s=e.substring(_,_+u);let t=o.length;for(i=0;i<t;i++){let t=ue[o[i]],n=t.pattern;if(l=null,t.isCustom===!0?(g=n.exec(ee,_,ie,v),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(n.lastIndex=_,a=this.match(n,e,_)),a&&a.length>s.length){s=a,u=a.length,c=l,_e=t;break}}}break}}if(u!==-1){if(d=_e.group,d!==void 0&&(s=s===null?e.substring(_,_+u):s,f=_e.tokenTypeIdx,p=this.createTokenInstance(s,_,f,_e.tokenType,oe,se,u),this.handlePayload(p,c),d===!1?ne=this.addToken(ie,ne,p):v[d].push(p)),y===!0&&_e.canLineTerminator===!0){let t=0,n,r;ce.lastIndex=0;do s=s===null?e.substring(_,_+u):s,n=ce.test(s),n===!0&&(r=ce.lastIndex-1,t++);while(n===!0);t===0?se=this.computeNewColumn(se,u):(oe+=t,se=u-r,this.updateTokenEndLineColumnLocation(p,d,r,t,oe,se,u))}else se=this.computeNewColumn(se,u);_+=u,this.handleModes(_e,he,ge,p)}else{let t=_,n=oe,i=se,a=ve===!1;for(;a===!1&&_<te;)for(_++,r=0;r<le;r++){let t=ue[r],n=t.pattern,i=t.short;if(i===!1?t.isCustom===!0?a=n.exec(ee,_,ie,v)!==null:(n.lastIndex=_,a=n.exec(e)!==null):ee.charCodeAt(_)===i&&(a=!0),a===!0)break}if(m=_-t,se=this.computeNewColumn(se,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(ee,t,m,n,i,ps(fe)),ae.push({offset:t,line:n,column:i,length:m,message:h}),ve===!1)break}}return this.hasCustom||(ie.length=ne),{tokens:ie,groups:v,errors:ae}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,(r!==1||s!==!0)&&(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchLength(e,t,n){return e.test(t)===!0?e.lastIndex-n:-1}};U.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.`,U.NA=/NOT_APPLICABLE/;function ru(e){return iu(e)?e.LABEL:e.name}function iu(e){return j(e.LABEL)&&e.LABEL!==``}var au=`parent`,ou=`categories`,su=`label`,cu=`group`,lu=`push_mode`,uu=`pop_mode`,du=`longer_alt`,fu=`line_breaks`,pu=`start_chars_hint`;function W(e){return mu(e)}function mu(e){let t=e.pattern,n={};if(n.name=e.name,Ws(t)||(n.PATTERN=t),A(e,au))throw`The parent property is no longer supported.
39
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return A(e,ou)&&(n.CATEGORIES=e[ou]),Wl([n]),A(e,su)&&(n.LABEL=e[su]),A(e,cu)&&(n.GROUP=e[cu]),A(e,uu)&&(n.POP_MODE=e[uu]),A(e,lu)&&(n.PUSH_MODE=e[lu]),A(e,du)&&(n.LONGER_ALT=e[du]),A(e,fu)&&(n.LINE_BREAKS=e[fu]),A(e,pu)&&(n.START_CHARS_HINT=e[pu]),n}var hu=W({name:`EOF`,pattern:U.NA});Wl([hu]);function gu(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function _u(e,t){return Bl(e,t)}var vu={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${iu(e)?`--> ${ru(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
40
+ but found: '`+Ts(t).image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${k(k(F(e,(e,t)=>e.concat(t),[]),e=>`[${k(e,e=>ru(e)).join(`, `)}]`),(e,t)=>` ${t+1}. ${e}`).join(`
41
+ `)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
42
+ but found: '`+Ts(t).image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${k(e,e=>`[${k(e,e=>ru(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(vu);var yu={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
43
+ inside top level rule: ->`+e.name+`<-`}},bu={buildDuplicateFoundError(e,t){function n(e){return e instanceof B?e.terminalType.name:e instanceof I?e.nonTerminalName:``}let r=e.name,i=Ts(t),a=i.idx,o=Sc(i),s=n(i),c=`->${o}${a>0?a:``}<- ${s?`with argument: ->${s}<-`:``}
44
+ appears more than once (${t.length} times) in the top level rule: ->${r}<-.
45
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
46
+ `;return c=c.replace(/[ \t]+/g,` `),c=c.replace(/\s\s+/g,`
47
+ `),c},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=k(e.prefixPath,e=>ru(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=e.alternation.idx===0?``:e.alternation.idx,n=e.prefixPath.length===0,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;if(n)r+=`These alternatives are all empty (match no tokens), making them indistinguishable.
48
+ Only the last alternative may be empty.
49
+ `;else{let t=k(e.prefixPath,e=>ru(e)).join(`, `);r+=`<${t}> may appears as a prefix path in all these alternatives.\n`}return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
50
+ For Further details.`,r},buildEmptyRepetitionError(e){let t=Sc(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){return`deprecated`},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${k(e.leftRecursionPath,e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof dc?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function xu(e,t){let n=new Su(e,t);return n.resolveRefs(),n.errors}var Su=class extends vc{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){O(M(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:K.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},Cu=class extends Cc{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=E(this.path.ruleStack).reverse(),this.occurrenceStack=E(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){P(this.ruleStack)?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},wu=class extends Cu{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new L({definition:t.concat(n)});this.possibleTokTypes=Tc(e),this.found=!0}}},Tu=class extends Cc{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}},Eu=class extends Tu{walkMany(e,t,n){if(e.idx===this.occurrence){let e=Ts(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof B&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},Du=class extends Tu{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=Ts(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof B&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},Ou=class extends Tu{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=Ts(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof B&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},ku=class extends Tu{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=Ts(t.concat(n));this.result.isEndOfRule=e===void 0,e instanceof B&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function Au(e,t,n=[]){n=E(n);let r=[],i=0;function a(t){return t.concat(D(e,i+1))}function o(e){let i=Au(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof L||t instanceof I)return o(t.definition);if(t instanceof R)r=o(t.definition);else if(t instanceof fc)return o(t.definition.concat([new z({definition:t.definition})]));else if(t instanceof pc)return o([new L({definition:t.definition}),new z({definition:[new B({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof mc)r=o(t.definition.concat([new z({definition:[new B({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof z)r=o(t.definition.concat([new z({definition:t.definition})]));else if(t instanceof hc)return O(t.definition,e=>{P(e.definition)===!1&&(r=o(e.definition))}),r;else if(t instanceof B)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:D(e,i)}),r}function ju(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!P(d);){let e=d.pop();if(e===o){s&&ps(d).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(P(r))continue;let h=r[0];if(h===i){let e={idx:f,def:D(r),ruleStack:ms(p),occurrenceStack:ms(m)};d.push(e)}else if(h instanceof B){if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:D(r),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`)}else if(h instanceof I){let e=E(p);e.push(h.nonTerminalName);let t=E(m);t.push(h.idx);let n={idx:f,def:h.definition.concat(a,D(r)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof R){let e={idx:f,def:D(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(D(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof fc){let e=new z({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],D(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof pc){let e=new z({definition:[new B({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],D(r)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof mc){let e={idx:f,def:D(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new z({definition:[new B({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],D(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof z){let e={idx:f,def:D(r),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new z({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],D(r)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof hc)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(D(r)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof L)d.push({idx:f,def:h.definition.concat(D(r)),ruleStack:p,occurrenceStack:m});else if(h instanceof dc)d.push(Mu(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function Mu(e,t,n,r){let i=E(n);i.push(e.name);let a=E(r);return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var G;(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`})(G||={});function Nu(e){if(e instanceof R||e===`Option`)return G.OPTION;if(e instanceof z||e===`Repetition`)return G.REPETITION;if(e instanceof fc||e===`RepetitionMandatory`)return G.REPETITION_MANDATORY;if(e instanceof pc||e===`RepetitionMandatoryWithSeparator`)return G.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof mc||e===`RepetitionWithSeparator`)return G.REPETITION_WITH_SEPARATOR;if(e instanceof hc||e===`Alternation`)return G.ALTERNATION;throw Error(`non exhaustive match`)}function Pu(e,t,n,r,i,a){let o=Wu(e,t,n);return a(o,r,Ju(o)?Vl:Bl,i)}function Fu(e,t,n,r,i,a){let o=Gu(e,t,i,n),s=Ju(o)?Vl:Bl;return a(o[0],s,r)}function Iu(e,t,n,r){let i=e.length,a=vs(e,e=>vs(e,e=>e.length===1));if(t)return function(t){let r=k(t,e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(o===void 0||o.call(this)!==!1)nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=F(k(e,e=>Vr(e)),(e,t,n)=>(O(t,t=>{A(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=n),O(t.categoryMatches,t=>{A(e,t)||(e[t]=n)})}),e),{});return function(){let e=this.LA(1);return t[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA(e+1),i[e])===!1)continue nextPath;return t}}}}function Lu(e,t,n){let r=vs(e,e=>e.length===1),i=e.length;if(r&&!n){let t=Vr(e);if(t.length===1&&P(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{let e=F(t,(e,t,n)=>(e[t.tokenTypeIdx]=!0,O(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){let t=this.LA(1);return e[t.tokenTypeIdx]===!0}}}return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var Ru=class extends Cc{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)}walkOption(e,t,n){this.checkIsTarget(e,G.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,G.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,G.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,G.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,G.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},zu=class extends vc{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,G.OPTION)}visitRepetition(e){this.checkIsTarget(e,G.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,G.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,G.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,G.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,G.ALTERNATION)}};function Bu(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function Vu(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function Hu(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function Uu(e,t){let n=k(e,e=>Au([e],1)),r=Bu(n.length),i=k(n,e=>{let t={};return O(e,e=>{O(Vu(e.partialPath),e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=Bu(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=Vu(c);if(Hu(i,u,o)||P(l)||c.length===t){let e=r[o];if(Ku(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=Au(l,e+1,c);a[o]=a[o].concat(t),O(t,e=>{O(Vu(e.partialPath),e=>{i[o][e]=!0})})}}}}return r}function Wu(e,t,n,r){let i=new zu(e,G.ALTERNATION,r);return t.accept(i),Uu(i.result,n)}function Gu(e,t,n,r){let i=new zu(e,n);t.accept(i);let a=i.result,o=new Ru(t,e,n).startWalking();return Uu([new L({definition:a}),new L({definition:o})],r)}function Ku(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(n!==i&&i.categoryMatchesMap[n.tokenTypeIdx]===void 0)continue compareOtherPath}return!0}}return!1}function qu(e,t){return e.length<t.length&&vs(e,(e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function Ju(e){return vs(e,e=>vs(e,e=>vs(e,e=>P(e.categoryMatches))))}function Yu(e){return k(e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}),e=>Object.assign({type:K.CUSTOM_LOOKAHEAD_VALIDATION},e))}function Xu(e,t,n,r){let i=Ds(e,e=>Zu(e,n)),a=pd(e,t,n),o=Ds(e,e=>ld(e,n)),s=Ds(e,t=>td(t,e,r,n));return i.concat(a,o,s)}function Zu(e,t){let n=new ed;e.accept(n);let r=n.allProductions;return k(M(Ys(ks(r,Qu),e=>e.length>1)),n=>{let r=Ts(n),i=t.buildDuplicateFoundError(e,n),a=Sc(r),o={message:i,type:K.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=$u(r);return s&&(o.parameter=s),o})}function Qu(e){return`${Sc(e)}_#_${e.idx}_#_${$u(e)}`}function $u(e){return e instanceof B?e.terminalType.name:e instanceof I?e.nonTerminalName:``}var ed=class extends vc{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 td(e,t,n,r){let i=[];if(F(t,(t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:K.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function nd(e,t,n){let r=[],i;return N(t,e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:K.INVALID_RULE_OVERRIDE,ruleName:e})),r}function rd(e,t,n,r=[]){let i=[],a=id(t.definition);if(P(a))return[];{let t=e.name;N(a,e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:K.LEFT_RECURSION,ruleName:t});let o=Ds(fs(a,r.concat([e])),t=>{let i=E(r);return i.push(t),rd(e,t,n,i)});return i.concat(o)}}function id(e){let t=[];if(P(e))return t;let n=Ts(e);if(n instanceof I)t.push(n.referencedRule);else if(n instanceof L||n instanceof R||n instanceof fc||n instanceof pc||n instanceof mc||n instanceof z)t=t.concat(id(n.definition));else if(n instanceof hc)t=Vr(k(n.definition,e=>id(e.definition)));else if(!(n instanceof B))throw Error(`non exhaustive match`);let r=bc(n),i=e.length>1;if(r&&i){let n=D(e);return t.concat(id(n))}return t}var ad=class extends vc{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function od(e,t){let n=new ad;e.accept(n);let r=n.alternations;return Ds(r,n=>Ds(ms(n.definition),(r,i)=>P(ju([r],[],Bl,1))?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:K.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function sd(e,t,n){let r=new ad;e.accept(r);let i=r.alternations;return i=Zs(i,e=>e.ignoreAmbiguities===!0),Ds(i,r=>{let i=r.idx,a=Wu(i,e,r.maxLookahead||t,r),o=dd(a,r,e,n),s=fd(a,r,e,n);return o.concat(s)})}var cd=class extends vc{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 ld(e,t){let n=new ad;e.accept(n);let r=n.alternations;return Ds(r,n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:K.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function ud(e,t,n){let r=[];return O(e,e=>{let i=new cd;e.accept(i);let a=i.allProductions;O(a,i=>{let a=Nu(i),o=i.maxLookahead||t,s=i.idx,c=Gu(s,e,a,o)[0];if(P(Vr(c))){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:K.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function dd(e,t,n,r){let i=[];return k(F(e,(n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||O(r,r=>{let o=[a];O(e,(e,n)=>{a!==n&&Ku(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!Ku(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),e=>{let i=k(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:K.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function fd(e,t,n,r){let i=F(e,(e,t,n)=>{let r=k(t,e=>({idx:n,path:e}));return e.concat(r)},[]);return Ya(Ds(i,e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,o=e.path;return k(bs(i,e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&qu(e.path,o)),e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:K.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}))}function pd(e,t,n){let r=[],i=k(t,e=>e.name);return O(e,e=>{let t=e.name;if(N(i,t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:K.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function md(e){let t=ss(e,{errMsgProvider:yu}),n={};return O(e.rules,e=>{n[e.name]=e}),xu(n,t.errMsgProvider)}function hd(e){return e=ss(e,{errMsgProvider:bu}),Xu(e.rules,e.tokenTypes,e.errMsgProvider,e.grammarName)}var gd=`MismatchedTokenException`,_d=`NoViableAltException`,vd=`EarlyExitException`,yd=`NotAllInputParsedException`,bd=[gd,_d,vd,yd];Object.freeze(bd);function xd(e){return N(bd,e.name)}var Sd=class extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Cd=class extends Sd{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=gd}},wd=class extends Sd{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=_d}},Td=class extends Sd{constructor(e,t){super(e,t),this.name=yd}},Ed=class extends Sd{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=vd}},Dd={},Od=`InRuleRecoveryException`,kd=class extends Error{constructor(e){super(e),this.name=Od}},Ad=class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=A(e,`recoveryEnabled`)?e.recoveryEnabled:yf.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=jd)}getTokenToInsert(e){let t=gu(e,``,NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA(1),l=this.LA(1),u=()=>{let e=this.LA(0),t=new Cd(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=ms(o),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new kd(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||P(t))return!1;let n=this.LA(1);return ws(t,e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return N(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),n=2;for(;;){let r=ws(e,e=>_u(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Dd;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return k(e,(n,r)=>r===0?Dd:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:t[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){return Vr(k(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===Dd)return[hu];let t=e.ruleName+e.idxInCallingRule+kc+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,hu)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return ms(t)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:E(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return k(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function jd(e,t,n,r,i,a,o){let s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(c===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];c=new a(t,i).startWalking(),this.firstAfterRepMap[s]=c}let l=c.token,u=c.occurrence,d=c.isEndOfRule;this.RULE_STACK.length===1&&d&&l===void 0&&(l=hu,u=1),l!==void 0&&u!==void 0&&this.shouldInRepetitionRecoveryBeTried(l,u,o)&&this.tryInRepetitionRecovery(e,t,n,l)}var Md=1024,Nd=1280,Pd=1536;function Fd(e,t,n){return n|t|e}var Id=class{constructor(e){this.maxLookahead=e?.maxLookahead??yf.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(P(t)){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return Ds(e,e=>rd(e,e,bu))}validateEmptyOrAlternatives(e){return Ds(e,e=>od(e,bu))}validateAmbiguousAlternationAlternatives(e,t){return Ds(e,e=>sd(e,t,bu))}validateSomeNonEmptyLookaheadPath(e,t){return ud(e,t,bu)}buildLookaheadForAlternation(e){return Pu(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Iu)}buildLookaheadForOptional(e){return Fu(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Nu(e.prodType),Lu)}},Ld=class{initLooksAhead(e){this.dynamicTokensEnabled=A(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:yf.dynamicTokensEnabled,this.maxLookahead=A(e,`maxLookahead`)?e.maxLookahead:yf.maxLookahead,this.lookaheadStrategy=A(e,`lookaheadStrategy`)?e.lookaheadStrategy:new Id({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){O(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=zd(e);O(t,t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${Sc(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=Fd(this.fullRuleNameToShort[e.name],256,t.idx);this.setLaFuncCache(r,n)})}),O(n,t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,Sc(t))}),O(r,t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,Sc(t))}),O(i,t=>{this.computeLookaheadFunc(e,t.idx,Md,`RepetitionMandatory`,t.maxLookahead,Sc(t))}),O(a,t=>{this.computeLookaheadFunc(e,t.idx,Pd,`RepetitionMandatoryWithSeparator`,t.maxLookahead,Sc(t))}),O(o,t=>{this.computeLookaheadFunc(e,t.idx,Nd,`RepetitionWithSeparator`,t.maxLookahead,Sc(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=Fd(this.fullRuleNameToShort[e.name],n,t);this.setLaFuncCache(o,a)})}getKeyForAutomaticLookahead(e,t){return Fd(this.getLastExplicitRuleShortName(),e,t)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},Rd=new class extends vc{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 zd(e){Rd.reset(),e.accept(Rd);let t=Rd.dslMethods;return Rd.reset(),t}function Bd(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function Vd(e,t){isNaN(e.startOffset)===!0?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Hd(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function Ud(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}var Wd=`name`;function Gd(e,t){Object.defineProperty(e,Wd,{enumerable:!1,configurable:!0,writable:!1,value:t})}function Kd(e,t){let n=C(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function qd(e,t){let n=function(){};return Gd(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(b(e)&&(e=e[0]),!Ws(e))return this[e.name](e.children,t)},validateVisitor:function(){let e=Xd(this,t);if(!P(e)){let t=k(e,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
51
+
52
+ `).replace(/\n/g,`
53
+ `)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function Jd(e,t,n){let r=function(){};Gd(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return O(t,e=>{i[e]=Kd}),r.prototype=i,r.prototype.constructor=r,r}var Yd;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Yd||={});function Xd(e,t){return Zd(e,t)}function Zd(e,t){return Ya(k(bs(t,t=>qe(e[t])===!1),t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Yd.MISSING_METHOD,methodName:t})))}var Qd=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=A(e,`nodeLocationTracking`)?e.nodeLocationTracking:yf.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=x,this.cstFinallyStateUpdate=x,this.cstPostTerminal=x,this.cstPostNonTerminal=x,this.cstPostRule=x;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Vd,this.setNodeLocationFromNode=Vd,this.cstPostRule=x,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=x,this.setNodeLocationFromNode=x,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Bd,this.setNodeLocationFromNode=Bd,this.cstPostRule=x,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=x,this.setNodeLocationFromNode=x,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=x,this.setNodeLocationFromNode=x,this.cstPostRule=x,this.setInitialNodeLocation=x;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=NaN}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Hd(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Ud(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}getBaseCstVisitorConstructor(){if(Ws(this.baseCstVisitorConstructor)){let e=qd(this.className,C(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Ws(this.baseCstVisitorWithDefaultsConstructor)){let e=Jd(this.className,C(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},$d=class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error(`Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.`);this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):vf}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?vf:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},ef=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=bf){if(N(this.definedRulesNames,e)){let t={message:bu.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:K.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=bf){let r=nd(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let n=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(xd(e))return!1;throw e}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return gc(M(this.gastProductionsCache))}},tf=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Vl,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},A(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
54
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
55
+ For Further details.`);if(b(e)){if(P(e))throw Error(`A Token Vocabulary cannot be empty.
56
+ Note that the first argument for the parser constructor
57
+ is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset==`number`)throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
58
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
59
+ For Further details.`)}if(b(e))this.tokensMap=F(e,(e,t)=>(e[t.name]=t,e),{});else if(A(e,`modes`)&&vs(Vr(M(e.modes)),eu)){let t=rc(Vr(M(e.modes)));this.tokensMap=F(t,(e,t)=>(e[t.name]=t,e),{})}else if(je(e))this.tokensMap=E(e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=hu;let n=vs(A(e,`modes`)?Vr(M(e.modes)):M(e),e=>P(e.categoryMatches));this.tokenMatcher=n?Vl:Bl,Wl(M(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=A(n,`resyncEnabled`)?n.resyncEnabled:bf.resyncEnabled,i=A(n,`recoveryValueFunc`)?n.recoveryValueFunc:bf.recoveryValueFunc,a=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK.length===1,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(xd(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(r)return this.moveToTerminatedState(),n(e);throw t}throw e}optionInternal(e,t){let n=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof e!=`function`){i=e.DEF;let t=e.GATE;if(t!==void 0){let e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=this.getKeyForAutomaticLookahead(Md,e);return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;if(r.call(this)===!0){let e=this.doSingleRepetition(i);for(;r.call(this)===!0&&e===!0;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,G.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,Md,e,Ou)}atLeastOneSepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Pd,e);this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,ku],t,Pd,e,ku)}else throw this.raiseEarlyExitException(e,G.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.getLaFuncFromCache(n),i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,Eu,a)}manySepFirstInternal(e,t){let n=this.getKeyForAutomaticLookahead(Nd,e);this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,Du],t,Nd,e,Du)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Pd,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=this.getKeyForAutomaticLookahead(256,t),r=b(e)?e:e.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Td(t,e))}}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw xd(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Cd(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}throw n}saveRecogState(){let e=this.errors,t=E(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),hu)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},nf=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=A(e,`errorMessageProvider`)?e.errorMessageProvider:yf.errorMessageProvider}SAVE_ERROR(e){if(xd(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:E(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return E(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=Gu(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new Ed(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=Wu(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new wd(s,this.LA(1),o))}},rf=class{initContentAssist(){}computeContentAssist(e,t){let n=this.gastProductionsCache[e];if(Ws(n))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return ju([n],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=Ts(e.ruleStack),n=this.getGAstProductions()[t];return new wu(n,e).startWalking()}},af={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(af);var of=!0,sf=255,cf=W({name:`RECORDING_PHASE_TOKEN`,pattern:U.NA});Wl([cf]);var lf=gu(cf,`This IToken indicates the Parser is in Recording Phase
60
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(lf);var uf={name:`This CSTNode indicates the Parser is in Recording Phase
61
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},df=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT(`Enable Recording`,()=>{for(let e=0;e<10;e++){let t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT(`Deleting Recording methods`,()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:``;delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return vf}topLevelRuleRecord(e,t){try{let n=new dc({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
62
+ This error was thrown during the "grammar recording phase" For more info see:
63
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return ff.call(this,R,e,t)}atLeastOneInternalRecord(e,t){ff.call(this,fc,t,e)}atLeastOneSepFirstInternalRecord(e,t){ff.call(this,pc,t,e,of)}manyInternalRecord(e,t){ff.call(this,z,t,e)}manySepFirstInternalRecord(e,t){ff.call(this,mc,t,e,of)}orInternalRecord(e,t){return pf.call(this,e,t)}subruleInternalRecord(e,t,n){if(hf(t),!e||A(e,`ruleName`)===!1){let n=Error(`<SUBRULE${mf(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=ps(this.recordingProdStack),i=e.ruleName,a=new I({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?uf:af}consumeInternalRecord(e,t,n){if(hf(t),!Xl(e)){let n=Error(`<CONSUME${mf(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=ps(this.recordingProdStack),i=new B({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),lf}};function ff(e,t,n,r=!1){hf(n);let i=ps(this.recordingProdStack),a=qe(t)?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),A(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),af}function pf(e,t){hf(t);let n=ps(this.recordingProdStack),r=b(e)===!1,i=r===!1?e:e.DEF,a=new hc({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return A(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=$s(i,e=>qe(e.GATE)),n.definition.push(a),O(i,e=>{let t=new L({definition:[]});a.definition.push(t),A(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:A(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),af}function mf(e){return e===0?``:`${e}`}function hf(e){if(e<0||e>sf){let t=Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than ${sf+1}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var gf=class{initPerformanceTracer(e){if(A(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=yf.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=oc(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}};function _f(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}var vf=gu(hu,``,NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(vf);var yf=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:vu,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),bf=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0}),K;(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`})(K||={});var xf=class e{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT(`performSelfAnalysis`,()=>{let t;this.selfAnalysisDone=!0;let n=this.className;this.TRACE_INIT(`toFastProps`,()=>{sc(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),O(this.definedRulesNames,e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{r=md({rules:M(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(P(r)&&this.skipValidations===!1){let e=hd({rules:M(this.gastProductionsCache),tokenTypes:M(this.tokensMap),errMsgProvider:bu,grammarName:n}),t=Yu({lookaheadStrategy:this.lookaheadStrategy,rules:M(this.gastProductionsCache),tokenTypes:M(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),P(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=jc(M(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:M(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(M(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&!P(this.definitionErrors))throw t=k(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:\n ${t.join(`
64
+ -------------------------------
65
+ `)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initContentAssist(),n.initGastRecorder(t),n.initPerformanceTracer(t),A(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
66
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
67
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
68
+ For further details.`);this.skipValidations=A(t,`skipValidations`)?t.skipValidations:yf.skipValidations}};xf.DEFER_DEFINITION_ERRORS_HANDLING=!1,_f(xf,[Ad,Ld,Qd,$d,tf,ef,nf,rf,df,gf]);var Sf=class extends xf{constructor(e,t=yf){let n=E(t);n.outputCst=!0,super(e,n)}};function Cf(e,t){let n=e.lexer.tokenize(t);if(n.errors.length>0){let r=n.errors[0],i=Number.isFinite(r.offset)?r.offset:t.length,a=i+(Number.isFinite(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${i},${a})`)}e.parser.input=n.tokens;let r=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(r)}n(Cf,`runChevrotainParse`);var q={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},wf=`LR`,Tf=s.usecase,Ef=n(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:wf,relationshipCounter:0,noteCounter:0,accTitle:``,accDescription:``,ast:void 0,config:structuredClone(Tf)}),`createModel`),Df=n(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||![`TB`,`TD`,`BT`,`RL`,`LR`].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||typeof e.accTitle!=`string`||typeof e.accDescription!=`string`||!e.config)throw Error(`Cannot commit an incomplete usecase model`)},`assertCompleteModel`),J=Ef(),Of=n(()=>structuredClone(J.config),`getConfig`),kf=n(()=>J.ast,`getAST`),Af=n(e=>{let t=structuredClone(e);Df(t);let n=f(),a=l();try{i(t.accTitle),r(t.accDescription),J=t}catch(e){throw i(n),r(a),e}},`commit`),jf=n(()=>{J=Ef(),a()},`clear`),Mf=n(()=>J.actors,`getActors`),Nf=n(e=>J.actors.get(e),`getActor`),Pf=n(()=>J.useCases,`getUseCases`),Ff=n(e=>J.useCases.get(e),`getUseCase`),If=n(()=>J.systemBoundaries,`getSystemBoundaries`),Lf=n(e=>J.systemBoundaries.get(e),`getSystemBoundary`),Rf=n(()=>J.relationships,`getRelationships`),zf=n(()=>J.notes,`getNotes`),Bf=n(e=>J.notes.get(e),`getNote`),Vf=n(()=>J.jsonNodes,`getJsonNodes`),Hf=n(e=>J.jsonNodes.get(e),`getJsonNode`),Uf=n(()=>J.classDefs,`getClassDefs`),Wf=n(e=>J.classDefs.get(e),`getClassDef`),Gf=n(()=>J.direction,`getDirection`),Kf=n(e=>{let t=new Map;for(let n of[`default`,...e]){let e=J.classDefs.get(n);if(e)for(let n of e.styles){let e=n.trim(),r=e.indexOf(`:`),i=(r===-1?e:e.slice(0,r)).trim();i&&t.set(i,e)}}return[...t.values()]},`getCompiledStyles`),qf=n(e=>e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`),`escapeJsonPointerPart`),Jf=n(e=>typeof e==`string`?e:e===null?`null`:String(e),`displayJsonScalar`),Yf=n((e,t,r=e=>e)=>{let i=[],a=n((e,t,n)=>{i.push({key:r(e),accessibleKey:r(t),value:r(n)})},`append`),o=n((e,n,r)=>{if(Array.isArray(e)){if(e.length===0){a(n,n,`[]`);return}if(e.every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))){for(let[t,r]of e.entries())a(t===0?n:``,n,Jf(r));return}for(let[t,i]of e.entries())o(i,`${n}[${t}]`,`${r}/${t}`);return}if(typeof e==`object`&&e){let i=e,s=t[r]??Object.keys(i);if(s.length===0){a(n,n,`{}`);return}for(let e of s){let t=n?`${n}.${e}`:e;o(i[e],t,`${r}/${qf(e)}`)}return}a(n,n,Jf(e))},`visit`);return o(e,``,``),i},`flattenJsonRows`),Xf=n(e=>{switch(e.type){case`hollow`:return`usecaseActorHollow`;case`awesome`:return`usecaseActorAwesome`;case`icon`:return`usecaseActorIcon`;case`normal`:return`usecaseActor`}},`actorShape`),Zf=n(e=>e.shape===`ellipse`?e.business?`usecaseBusiness`:`usecaseEllipse`:e.shape,`useCaseShape`),Qf=n(e=>{switch(e){case q.SOLID_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_point`};case q.BACK_ARROW:return{arrowTypeStart:`arrow_point`,arrowTypeEnd:`none`};case q.CIRCLE_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_circle`};case q.CROSS_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_cross`};case q.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:`arrow_circle`,arrowTypeEnd:`none`};case q.CROSS_ARROW_REVERSED:return{arrowTypeStart:`arrow_cross`,arrowTypeEnd:`none`};case q.LINE_SOLID:return{arrowTypeStart:`none`,arrowTypeEnd:`none`}}},`associationMarkers`),$f=n(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{...Qf(e.arrowType),pattern:`solid`,...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},`relationshipVisuals`),ep=n(e=>e.animate||e.animation?[`edge-animation-${e.animation??`fast`}`]:[],`animationClasses`),tp=n((...e)=>e.filter(e=>!!e).join(` `),`classNames`),np={getConfig:Of,createModel:Ef,commit:Af,getAST:kf,clear:jf,setDiagramTitle:c,getDiagramTitle:u,setAccTitle:i,getAccTitle:f,setAccDescription:r,getAccDescription:l,getActors:Mf,getActor:Nf,getUseCases:Pf,getUseCase:Ff,getSystemBoundaries:If,getSystemBoundary:Lf,getRelationships:Rf,getNotes:zf,getNote:Bf,getJsonNodes:Vf,getJsonNode:Hf,getClassDefs:Uf,getClassDef:Wf,getDirection:Gf,getData:n(()=>{let e=d(),t={...J.config,...e.usecase},r=n(t=>p(t,e),`sanitize`),i=n(e=>r(J.actors.get(e)?.label??J.useCases.get(e)?.label??J.jsonNodes.get(e)?.id??J.notes.get(e)?.label??e),`endpointLabel`),a=[],o=[],s=0,c=0;for(let t of J.actors.values())a.push({id:t.id,label:r(t.label),labelType:t.labelType,shape:Xf(t),isGroup:!1,padding:10,look:e.look,colorIndex:s++,cssClasses:tp(`default`,`usecase-actor`,`usecase-actor-${t.type}`,t.business&&`usecase-business`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Kf(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:r(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of J.useCases.values())a.push({id:t.id,label:r(t.label),labelType:t.labelType,shape:Zf(t),isGroup:!1,padding:t.shape===`ellipse`?20:10,look:e.look,colorIndex:s++,cssClasses:tp(`default`,`usecase-element`,`usecase-${t.shape}`,t.business&&`usecase-business`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Kf(t.classes),business:t.business,...t.stereotype?{stereotype:r(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of J.notes.values())a.push({id:t.id,label:r(t.label),labelType:t.labelType,shape:`note`,isGroup:!1,padding:10,look:e.look,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:Kf([]),noteTarget:t.target,noteTargetLabel:r(J.actors.get(t.target)?.label??J.useCases.get(t.target)?.label??J.jsonNodes.get(t.target)?.id??t.target)});for(let t of J.jsonNodes.values())a.push({id:t.id,label:r(t.id),labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,look:e.look,cssClasses:tp(`default`,`usecase-json-table`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Kf(t.classes),jsonRows:Yf(t.value,t.propertyOrder,r)});for(let t of J.systemBoundaries.values())a.push({id:t.id,label:r(t.label),labelType:t.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,look:e.look,colorIndex:c++,cssClasses:tp(`default`,`system-boundary`,`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Kf(t.classes),boundaryType:t.type});for(let t of J.relationships){let{label:n,...a}=$f(t);o.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:i(t.source),targetLabel:i(t.target),type:`edge`,relationshipType:t.type,internal:!1,...a,...n===void 0?{}:{label:r(n)},labelpos:`c`,classes:tp(`default`,`relationship`,`relationship-${t.type}`,...t.classes,...ep(t)),style:[...t.styles],cssCompiledStyles:Kf(t.classes),animate:t.animate,...t.animation?{animation:t.animation}:{},look:e.look,thickness:`normal`,minlen:t.minlen,isUserDefinedId:t.explicitId})}for(let t of J.notes.values())o.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:`edge`,relationshipType:`note`,sourceLabel:i(t.id),targetLabel:i(t.target),internal:!0,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,labelpos:`c`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:Kf([]),animate:!1,look:e.look,thickness:`normal`,minlen:1,isUserDefinedId:!1});for(let e of a)e.wrappingWidth??=t.wrappingWidth,!e.isGroup&&!e.shape.startsWith(`usecaseActor`)&&(e.minWidth??=t.minNodeWidth),(e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`)&&(e.spreadPorts=!0);return{nodes:a,edges:o,config:e,type:`usecase`,layoutAlgorithm:`dagre`,direction:Gf(),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`)};function rp(e,t,n){let r=[n];return r.index=t,r.input=e,r}n(rp,`customMatch`);var ip=n((e,t)=>{if(e[t]!==`"`||e[t+1]!=="`")return null;for(let n=t+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]===`"`)return rp(e,t,e.slice(t,n+2));return null},`matchMarkdownString`),ap=n((e,t)=>{if(e[t]!==`%`||e[t+1]!==`%`)return null;for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
69
+ `||t===`\r`)break;if(t!==` `&&t!==` `)return null}let n=t+2;for(;n<e.length&&e[n]!==`
70
+ `&&e[n]!==`\r`;)n++;return rp(e,t,e.slice(t,n))},`matchComment`),op=n((e,t)=>{for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
71
+ `||t===`\r`)return!0;if(t!==` `&&t!==` `)return!1}return!0},`isIndentedLineStart`),sp=n((e,t,n)=>{if(!op(e,t))return null;let r=n.exec(e.slice(t));return r?rp(e,t,r[0]):null},`matchAccessibilityLine`),cp=n((e,t)=>{if(!op(e,t))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(t));if(!n)return null;let r=e.indexOf(`}`,t+n[0].length);return r===-1?null:rp(e,t,e.slice(t,r+1))},`matchAccDescrBlock`),lp=n((e,t)=>{if(e[t]!==`{`)return null;let n=0,r=!1,i=!1;for(let a=t;a<e.length;a++){let o=e[a];if(r){i?i=!1:o===`\\`?i=!0:o===`"`&&(r=!1);continue}if(o===`"`)r=!0;else if(o===`{`)n++;else if(o===`}`&&--n===0)return rp(e,t,e.slice(t,a+1))}return null},`matchJsonObject`),up=n((e,t)=>{let n=e.indexOf(`>>`,t);if(n===-1||/[\n\r]/.test(e.slice(t,n)))return null;let r=e.slice(t,n);return r.trim()?rp(e,t,r):null},`matchStereotypeText`),Y=W({name:`LABEL_TEXT`,pattern:U.NA}),dp=W({name:`WORD`,pattern:U.NA,categories:Y}),fp=W({name:`NUMBER`,pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:Y}),X=W({name:`IDENTIFIER`,pattern:/\w+/,longer_alt:fp,categories:dp}),pp=W({name:`HWS`,pattern:/[\t ]+/,group:U.SKIPPED}),mp=W({name:`MARKDOWN_STRING`,pattern:ip,start_chars_hint:[`"`],line_breaks:!0}),hp=W({name:`UNCLOSED_MARKDOWN_STRING`,pattern:/"`[^]*/,line_breaks:!0}),gp=W({name:`COMMENT`,pattern:ap,start_chars_hint:[`%`],line_breaks:!1}),_p=W({name:`NEWLINE`,pattern:/\r\n|\n|\r/,line_breaks:!0}),vp=W({name:`ACC_DESCR_BLOCK`,pattern:cp,start_chars_hint:[`a`],line_breaks:!0}),yp=/^accTitle[\t ]*:[^\n\r]*/,bp=/^accDescr[\t ]*:[^\n\r]*/,xp=W({name:`ACC_TITLE_LINE`,pattern:n((e,t)=>sp(e,t,yp),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),Sp=W({name:`ACC_DESCR_LINE`,pattern:n((e,t)=>sp(e,t,bp),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),Cp=W({name:`JSON_DECLARATION_START`,pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:`jsonBody`}),wp=W({name:`JSON_OBJECT_LITERAL`,pattern:lp,start_chars_hint:[`{`],line_breaks:!0,pop_mode:!0}),Tp=W({name:`UNCLOSED_JSON_OBJECT_LITERAL`,pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),Z=n((e,t)=>W({name:e,pattern:t,longer_alt:X,categories:dp}),`keyword`),Ep=Z(`USECASE`,/usecase-beta/),Dp=Z(`ACTOR`,/actor/),Op=Z(`SYSTEM_BOUNDARY`,/systemBoundary/),kp=Z(`END`,/end/),Ap=Z(`DIRECTION`,/direction/),jp=Z(`TD`,/TD/),Mp=Z(`TB`,/TB/),Np=Z(`BT`,/BT/),Pp=Z(`LR`,/LR/),Fp=Z(`RL`,/RL/),Ip=Z(`NOTE`,/note/),Lp=Z(`FOR`,/for/),Rp=Z(`JSON`,/json/),zp=Z(`CLASS_DEF`,/classDef/),Bp=Z(`CLASS`,/class/),Vp=Z(`STYLE`,/style/),Hp=Z(`INCLUDE`,/include/i),Up=Z(`EXTEND`,/extend/i),Wp=Z(`TRUE`,/true/),Gp=Z(`FALSE`,/false/),Kp=W({name:`GENERALIZATION`,pattern:/--\|>/}),qp=W({name:`DEPENDENCY_ARROW`,pattern:/\.\.>/}),Jp=W({name:`STEREOTYPE_START`,pattern:/<</,push_mode:`stereotype`}),Yp=W({name:`STEREOTYPE_END`,pattern:/>>/,pop_mode:!0}),Xp=W({name:`STEREOTYPE_TEXT`,pattern:up,line_breaks:!1}),Zp=W({name:`UNCLOSED_STEREOTYPE_TEXT`,pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Qp=W({name:`CLASS_SEPARATOR`,pattern:/:::/}),$p=W({name:`FORWARD_SOLID`,pattern:/--+>/}),em=W({name:`BACKWARD_SOLID`,pattern:/<--+/}),tm=W({name:`FORWARD_CIRCLE`,pattern:/--o/}),nm=W({name:`BACKWARD_CIRCLE`,pattern:/o--/}),rm=W({name:`FORWARD_CROSS`,pattern:/--x/}),im=W({name:`BACKWARD_CROSS`,pattern:/x--/}),am=W({name:`MARKERLESS_SOLID`,pattern:/--+/}),om=W({name:`METADATA_START`,pattern:/@{/}),sm=W({name:`AT`,pattern:/@/,categories:Y}),cm=W({name:`LBRACE`,pattern:/{/}),lm=W({name:`RBRACE`,pattern:/}/}),um=W({name:`LBRACKET`,pattern:/\[/}),dm=W({name:`RBRACKET`,pattern:/]/}),fm=W({name:`LPAREN`,pattern:/\(/}),pm=W({name:`RPAREN`,pattern:/\)/}),mm=W({name:`COMMA`,pattern:/,/,categories:Y}),hm=W({name:`COLON`,pattern:/:/,categories:Y}),gm=W({name:`HASH_COLOR`,pattern:/#[\dA-Fa-f]+/,categories:Y}),_m=W({name:`PLAIN_STRING`,pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),vm=W({name:`CSS_IDENTIFIER`,pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:Y}),ym=W({name:`CSS_ESCAPED_COMMA`,pattern:/\\,/,categories:Y}),bm=W({name:`DASH`,pattern:/-/,categories:Y}),xm=W({name:`DOT`,pattern:/\./,categories:Y}),Sm=W({name:`PERCENT`,pattern:/%/,categories:Y}),Cm=W({name:`CSS_PUNCTUATION`,pattern:/[!#$&*+/=?^_|~]/,categories:Y}),wm=[Y,dp,pp,mp,hp,gp,_p,vp,xp,Sp,Cp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Qp,$p,em,tm,nm,rm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,X,fp,ym,bm,xm,Sm,Cm,W({name:`LABEL_PUNCTUATION`,pattern:/[;<>\\`]/,categories:Y}),W({name:`LABEL_SYMBOL`,pattern:/[^\t\n\r !-~]+/,categories:Y})],Tm={defaultMode:`defaultMode`,modes:{defaultMode:[...wm],jsonBody:[wp,Tp],stereotype:[Yp,Xp,Zp]}},Em=[...wm,wp,Tp,Yp,Xp,Zp],Dm=new U(Tm),Om=n(e=>_u(e,Y)||e.tokenType===_m||e.tokenType===mp,`isLabelToken`),km={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Am=new class extends Sf{static{n(this,`UsecaseParser`)}constructor(){super(Em,{nodeLocationTracking:`full`}),this.RULE(`start`,()=>{this.CONSUME(Ep),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE(`line`,()=>{this.OR([{ALT:n(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:n(()=>this.SUBRULE(this.commentLine),`ALT`)},{GATE:n(()=>this.isStatementStart(),`GATE`),ALT:n(()=>this.SUBRULE(this.statement),`ALT`)}])}),this.RULE(`statement`,()=>{this.OR([{ALT:n(()=>this.SUBRULE(this.accTitleStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.accDescrStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.directionStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.actorStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.systemBoundaryStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.noteStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.jsonStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.classDefStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.classStatement),`ALT`)},{ALT:n(()=>this.SUBRULE(this.styleStatement),`ALT`)},{GATE:n(()=>this.isMetadataAssignment(),`GATE`),ALT:n(()=>this.SUBRULE(this.metadataAssignmentStatement),`ALT`)},{GATE:n(()=>!this.isForbiddenPlantUmlStatement(),`GATE`),ALT:n(()=>this.SUBRULE(this.entityStatement),`ALT`)}])}),this.RULE(`lineEnd`,()=>{this.OR([{ALT:n(()=>this.CONSUME(_p),`ALT`)},{ALT:n(()=>this.CONSUME(hu),`ALT`)}])}),this.RULE(`blankLine`,()=>{this.CONSUME(_p)}),this.RULE(`commentLine`,()=>{this.CONSUME(gp),this.SUBRULE(this.lineEnd)}),this.RULE(`accTitleStatement`,()=>{this.CONSUME(xp),this.SUBRULE(this.lineEnd)}),this.RULE(`accDescrStatement`,()=>{this.OR([{ALT:n(()=>this.CONSUME(Sp),`ALT`)},{ALT:n(()=>this.CONSUME(vp),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`actorStatement`,()=>{this.CONSUME(Dp),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:n(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(mm),this.SUBRULE2(this.actorItem)}),`ALT`)},{ALT:n(()=>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:n(()=>{this.CONSUME(X),this.OPTION(()=>{this.CONSUME(fm),this.SUBRULE(this.nodeLabel),this.CONSUME(pm)})},`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`ALT`)}])}),this.RULE(`actorDeclarationOnly`,()=>{this.CONSUME(Dp),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(mm),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:n(()=>{this.CONSUME(X),this.OPTION(()=>{this.OR2([{ALT:n(()=>{this.CONSUME(fm),this.SUBRULE(this.nodeLabel),this.CONSUME(pm)},`ALT`)},{ALT:n(()=>{this.CONSUME(um),this.SUBRULE2(this.nodeLabel),this.CONSUME(dm)},`ALT`)}])})},`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`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:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`ALT`)},{ALT:n(()=>this.AT_LEAST_ONE(()=>this.CONSUME(Y)),`ALT`)}])}),this.RULE(`useCaseMetadata`,()=>{this.SUBRULE(this.metadata)}),this.RULE(`relationTail`,()=>{this.OPTION({GATE:n(()=>this.LA(1).tokenType===X&&this.LA(2).tokenType===sm,`GATE`),DEF:n(()=>{this.CONSUME(X),this.CONSUME(sm)},`DEF`)}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE(`arrow`,()=>{this.OR([{ALT:n(()=>this.SUBRULE(this.semanticRelation),`ALT`)},{ALT:n(()=>this.SUBRULE(this.forwardSolidOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.backwardSolidOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.markerlessSolidOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.forwardCircleOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.backwardCircleOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.forwardCrossOperator),`ALT`)},{ALT:n(()=>this.SUBRULE(this.backwardCrossOperator),`ALT`)}])}),this.RULE(`forwardSolidOperator`,()=>{this.CONSUME($p)}),this.RULE(`backwardSolidOperator`,()=>{this.CONSUME(em),this.OPTION({GATE:n(()=>this.LA(0).image===`<--`&&this.hasLabeledRight([am]),`GATE`),DEF:n(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(am)},`DEF`)})}),this.RULE(`markerlessSolidOperator`,()=>{this.CONSUME(am),this.OPTION({GATE:n(()=>this.LA(0).image===`--`&&this.hasLabeledRight([$p,am,tm,rm]),`GATE`),DEF:n(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:n(()=>this.CONSUME($p),`ALT`)},{ALT:n(()=>this.CONSUME2(am),`ALT`)},{ALT:n(()=>this.CONSUME(tm),`ALT`)},{ALT:n(()=>this.CONSUME(rm),`ALT`)}])},`DEF`)})}),this.RULE(`forwardCircleOperator`,()=>{this.CONSUME(tm)}),this.RULE(`backwardCircleOperator`,()=>{this.CONSUME(nm),this.OPTION({GATE:n(()=>this.hasLabeledRight([am]),`GATE`),DEF:n(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(am)},`DEF`)})}),this.RULE(`forwardCrossOperator`,()=>{this.CONSUME(rm)}),this.RULE(`backwardCrossOperator`,()=>{this.CONSUME(im),this.OPTION({GATE:n(()=>this.hasLabeledRight([am]),`GATE`),DEF:n(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(am)},`DEF`)})}),this.RULE(`edgeLabel`,()=>{this.OR([{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`ALT`)},{ALT:n(()=>this.AT_LEAST_ONE(()=>this.CONSUME(Y)),`ALT`)}])}),this.RULE(`semanticRelation`,()=>{this.OR([{ALT:n(()=>{this.CONSUME(qp),this.CONSUME(hm),this.OR2([{ALT:n(()=>this.CONSUME(Hp),`ALT`)},{ALT:n(()=>this.CONSUME(Up),`ALT`)}])},`ALT`)},{ALT:n(()=>this.CONSUME(Kp),`ALT`)}])}),this.RULE(`metadata`,()=>{this.CONSUME(om),this.MANY(()=>this.CONSUME(_p)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(mm)),this.MANY3(()=>this.CONSUME2(_p))}),this.CONSUME(lm)}),this.RULE(`metadataProperty`,()=>{this.OR([{ALT:n(()=>this.CONSUME(X),`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)}]),this.CONSUME(hm),this.OR2([{ALT:n(()=>this.CONSUME2(X),`ALT`)},{ALT:n(()=>this.CONSUME2(_m),`ALT`)},{ALT:n(()=>this.CONSUME(Wp),`ALT`)},{ALT:n(()=>this.CONSUME(Gp),`ALT`)}])}),this.RULE(`metadataSeparator`,()=>{this.OR([{ALT:n(()=>{this.CONSUME(mm),this.MANY(()=>this.CONSUME(_p))},`ALT`)},{ALT:n(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(_p)),this.OPTION(()=>this.CONSUME2(mm)),this.MANY2(()=>this.CONSUME3(_p))},`ALT`)}])}),this.RULE(`systemBoundaryStatement`,()=>{this.CONSUME(Op),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(kp),this.SUBRULE2(this.lineEnd)}),this.RULE(`systemBoundaryName`,()=>{this.OR([{ALT:n(()=>{this.CONSUME(X),this.OPTION(()=>{this.OR2([{ALT:n(()=>{this.CONSUME(fm),this.SUBRULE(this.nodeLabel),this.CONSUME(pm)},`ALT`)},{ALT:n(()=>{this.CONSUME(um),this.SUBRULE2(this.nodeLabel),this.CONSUME(dm)},`ALT`)}])})},`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`ALT`)}])}),this.RULE(`systemBoundaryContent`,()=>{this.MANY(()=>{this.OR([{ALT:n(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:n(()=>this.SUBRULE(this.commentLine),`ALT`)},{ALT:n(()=>this.SUBRULE(this.boundaryElement),`ALT`)}])})}),this.RULE(`boundaryElement`,()=>{this.OR([{ALT:n(()=>this.SUBRULE(this.actorDeclarationOnly),`ALT`)},{ALT:n(()=>{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:n(()=>this.CONSUME(X),`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(mp),`ALT`)}])}),this.RULE(`noteStatement`,()=>{this.CONSUME(Ip),this.CONSUME(Lp),this.CONSUME(X),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE(`stereotype`,()=>{this.CONSUME(Jp),this.CONSUME(Xp),this.CONSUME(Yp)}),this.RULE(`classSuffix`,()=>{this.CONSUME(Qp),this.CONSUME(X),this.MANY(()=>{this.CONSUME(mm),this.CONSUME2(X)})}),this.RULE(`jsonStatement`,()=>{this.CONSUME(Cp),this.CONSUME(wp),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE(`directionStatement`,()=>{this.CONSUME(Ap),this.OR([{ALT:n(()=>this.CONSUME(jp),`ALT`)},{ALT:n(()=>this.CONSUME(Mp),`ALT`)},{ALT:n(()=>this.CONSUME(Np),`ALT`)},{ALT:n(()=>this.CONSUME(Pp),`ALT`)},{ALT:n(()=>this.CONSUME(Fp),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`classDefStatement`,()=>{this.CONSUME(zp),this.CONSUME(X),this.MANY(()=>{this.CONSUME(mm),this.CONSUME2(X)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`classStatement`,()=>{this.CONSUME(Bp),this.CONSUME(X),this.MANY(()=>{this.CONSUME(mm),this.CONSUME2(X)}),this.CONSUME3(X),this.MANY2(()=>{this.CONSUME2(mm),this.CONSUME4(X)}),this.SUBRULE(this.lineEnd)}),this.RULE(`styleStatement`,()=>{this.CONSUME(Vp),this.CONSUME(X),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`styles`,()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(mm),this.SUBRULE2(this.styleValue)})}),this.RULE(`styleValue`,()=>{this.OR([{ALT:n(()=>this.CONSUME(dp),`ALT`)},{ALT:n(()=>this.CONSUME(vm),`ALT`)},{ALT:n(()=>{this.CONSUME(am),this.CONSUME2(dp)},`ALT`)}]),this.CONSUME(hm),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE(`styleComponent`,()=>{this.OR([{ALT:n(()=>this.CONSUME(dp),`ALT`)},{ALT:n(()=>this.CONSUME(_m),`ALT`)},{ALT:n(()=>this.CONSUME(fp),`ALT`)},{ALT:n(()=>this.CONSUME(gm),`ALT`)},{ALT:n(()=>this.CONSUME(vm),`ALT`)},{ALT:n(()=>this.CONSUME(ym),`ALT`)},{ALT:n(()=>this.CONSUME(bm),`ALT`)},{ALT:n(()=>this.CONSUME(xm),`ALT`)},{ALT:n(()=>this.CONSUME(Sm),`ALT`)},{ALT:n(()=>this.CONSUME(Cm),`ALT`)},{ALT:n(()=>this.CONSUME(hm),`ALT`)},{ALT:n(()=>this.CONSUME(fm),`ALT`)},{ALT:n(()=>this.CONSUME(pm),`ALT`)},{ALT:n(()=>this.CONSUME(um),`ALT`)},{ALT:n(()=>this.CONSUME(dm),`ALT`)},{ALT:n(()=>this.CONSUME(cm),`ALT`)},{ALT:n(()=>this.CONSUME(lm),`ALT`)},{ALT:n(()=>this.CONSUME(sm),`ALT`)},{ALT:n(()=>this.CONSUME(am),`ALT`)}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===X||e===_m||e===mp)&&this.LA(2).tokenType===om}isStatementStart(){let e=this.LA(1).tokenType;return e!==hu&&e!==_p&&e!==gp}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===X&&km[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Om(this.LA(1)))return!1;for(let t=2;;t++){let n=this.LA(t);if(e.includes(n.tokenType))return!0;if(!Om(n))return!1}}},jm=class extends Error{constructor(e,t,n){super(`${e} (line ${t}, column ${n})`),this.line=t,this.column=n,this.name=`UsecaseJsonError`}static{n(this,`UsecaseJsonError`)}},Mm=n((e,t,n,r)=>{let i=n,a=r,o=Math.min(Math.max(t,0),e.length);for(let t=0;t<o;t++){let n=e[t];n===`\r`?(i++,a=1):n===`
72
+ `?(t===0||e[t-1]!==`\r`)&&(i++,a=1):a++}return{line:i,column:a}},`locationAtOffset`),Nm=n((e,t,n,r)=>{let i=/\bposition (\d+)\b/u.exec(e);if(i)return Mm(t,Number.parseInt(i[1],10),n,r);let a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){let e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:n+e-1,column:e===1?r+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return Mm(t,t.length,n,r)},`locationFromErrorMessage`),Q=class extends Error{constructor(e){super(`Invalid JSON token`),this.offset=e}static{n(this,`JsonWalkError`)}},Pm=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{n(this,`PropertyOrderCollector`)}collect(){if(this.skipWhitespace(),this.collectValue(``),this.skipWhitespace(),this.offset!==this.text.length)throw new Q(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if(t===`{`)this.collectObject(e);else if(t===`[`)this.collectArray(e);else if(t===`"`)this.readString(!1);else if(t===`t`)this.consumeLiteral(`true`);else if(t===`f`)this.consumeLiteral(`false`);else if(t===`n`)this.consumeLiteral(`null`);else if(t===`-`||t>=`0`&&t<=`9`)this.consumeNumber();else throw new Q(this.offset)}collectObject(e){this.offset++;let t=[],n=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),this.text[this.offset]===`}`){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!==`"`)throw new Q(this.offset);let r=this.readString(!0),i=`${e}/${r.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`;if(n.has(r)?this.deletePointerSubtree(i):(n.add(r),t.push(r)),this.skipWhitespace(),this.text[this.offset]!==`:`)throw new Q(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),this.text[this.offset]===`}`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}readString(e){this.offset++;let t=``;for(;this.offset<this.text.length;){let n=this.offset,r=this.text[this.offset++];if(r===`"`)return t;if(r.charCodeAt(0)<32)throw new Q(n);if(r!==`\\`){e&&(t+=r);continue}let i=this.offset,a=this.text[this.offset++];switch(a){case`"`:case`\\`:case`/`:e&&(t+=a);break;case`b`:e&&(t+=`\b`);break;case`f`:e&&(t+=`\f`);break;case`n`:e&&(t+=`
73
+ `);break;case`r`:e&&(t+=`\r`);break;case`t`:e&&(t+=` `);break;case`u`:{let n=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(n))throw new Q(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(n,16))),this.offset+=4;break}default:throw new Q(i)}}throw new Q(this.offset)}consumeLiteral(e){let t=0;for(let n of e){if(this.text[this.offset+t]!==n)throw new Q(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]===`-`&&this.offset++,this.text[this.offset]===`0`)this.offset++;else if(this.text[this.offset]>=`1`&&this.text[this.offset]<=`9`)for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++;else throw new Q(this.offset);if(this.text[this.offset]===`.`){if(this.offset++,this.text[this.offset]<`0`||this.text[this.offset]>`9`)throw new Q(this.offset);for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++}if(this.text[this.offset]===`e`||this.text[this.offset]===`E`){if(this.offset++,(this.text[this.offset]===`+`||this.text[this.offset]===`-`)&&this.offset++,this.text[this.offset]<`0`||this.text[this.offset]>`9`)throw new Q(this.offset);for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(e!==` `&&e!==` `&&e!==`
74
+ `&&e!==`\r`)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let n of Object.keys(this.propertyOrder))(n===e||n.startsWith(t))&&delete this.propertyOrder[n]}};function Fm(e,t,n){let r;try{r=JSON.parse(e)}catch(r){let i=r instanceof Error?r.message:String(r),a=Nm(i,e,t,n);if(!a){let r=0;try{new Pm(e).collect()}catch(e){e instanceof Q&&(r=e.offset)}a=Mm(e,r,t,n)}throw new jm(`Invalid JSON: ${i}`,a.line,a.column)}if(typeof r!=`object`||!r||Array.isArray(r))throw new jm(`JSON value must have an object root`,t,n);return{value:r,propertyOrder:new Pm(e).collect()}}n(Fm,`parseOrderedJsonObject`);var Im=n(e=>({shape:e.type===`normal`?`actor`:e.type===`hollow`?`actor-hollow`:e.type===`awesome`?`actor-awesome`:`actor-icon`,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`actor`,actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),`actorNode`),Lm=n(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`),Rm=n(e=>({label:e.label,shape:`note`,attrs:{kind:`note`,target:e.target,labelType:e.labelType}}),`noteNode`),zm=n(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`),Bm=n(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`),Vm=n(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:`note`,arrowType:q.LINE_SOLID,pattern:`dotted`,minlen:1,explicitId:!1,animate:!1,internal:!0}}),`noteEdge`),Hm=n((e,t,n,r)=>{let i={};for(let t of e.getActors().values())i[t.id]=Im(t);for(let t of e.getUseCases().values())i[t.id]=Lm(t);for(let t of e.getNotes().values())i[t.id]=Rm(t);for(let t of e.getJsonNodes().values())i[t.id]=zm(t);let a={};for(let t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:`systemBoundary`,boundaryType:t.type,labelType:t.labelType}};let o={};for(let t of e.getClassDefs().values())o[t.id]={styles:[...t.styles]};let s=e.getDirection();return{version:1,diagramType:`usecase`,source:t,header:{keyword:`usecase`,direction:s===`TD`?`TB`:s,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:i,edges:[...e.getRelationships().map(Bm),...[...e.getNotes().values()].map(Vm)],groups:a,classDefs:o,statements:r}},`buildUsecaseGraphAST`),$=n(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,`locationText`),Um=n(e=>e===void 0?``:` (label "${e}")`,`labelSuffix`),Wm=n(e=>e.generated?e.label:void 0,`generatedFrom`),Gm=n((e,t)=>{for(let n of t)e.includes(n)||e.push(n)},`pushUnique`),Km=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{n(this,`UsecaseModelBuilder`)}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,n,r){this.metadataAssignments.push({target:e,targetLocation:t,metadata:n,statement:r})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,n){this.styleAssignments.push({target:e,location:t,styles:n})}setDirection(e){this.directions.push(e===`TD`?`TB`:e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let e of this.relationshipDrafts)this.recordFirst(i,e.source.id,e.source.location.span[0]),this.recordFirst(i,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(i,e.id,e.location.span[0]);let a=[...this.elements.map(e=>({offset:e.location.span[0],type:`element`,value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:`boundary`,value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:`json`,value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:`edge`,value:e}))].sort((e,t)=>e.offset-t.offset);for(let e of a)e.type===`element`?this.collectElement(e.value,t,n):e.type===`boundary`?this.collectBoundary(e.value,t,r):e.type===`json`?this.registerUnique(t,e.value.id,`json`,e.value.location,!1):this.registerUnique(t,e.value.explicitId,`edge`,e.value.explicitIdLocation,!1);this.materializeElements(n,i),this.materializeBoundaries(r,i),this.materializeJson(i);let o=this.materializeRelationships(t,n,i);this.reorderElements(n,i),this.applyMetadataAssignments(t,n,r,o),this.validateAndRefreshElements(n),this.refreshBoundaries(r,n),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,o),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let s=Hm(this,this.source,e,this.statements);return this.model.ast=s,this.db.commit(this.model),s}collectElement(e,t,n){let r=t.get(e.id),i=Wm({generated:e.generated,label:e.label.text});r&&r.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and ${e.kind}`,e.location,r.location,i,Wm(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,Wm(r));let a=n.get(e.id);if(!a){let r={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(r,e.metadata),n.set(e.id,r),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,Gm(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,t,n){let r=t.get(e.id),i=Wm({generated:e.generated,label:e.label.text});r&&r.kind!==`boundary`&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and boundary`,e.location,r.location,i,Wm(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,Wm(r));let a=n.get(e.id);if(a){(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),Gm(a.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:`boundary`,location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.setElementModel(n)}materializeBoundaries(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??`rect`,members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,n)=>(e.get(t.id)??0)-(e.get(n.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,n){let r=new Map,i=0;for(let a of this.relationshipDrafts){let o=this.resolveEndpoint(a.source,e,t,n),s=this.resolveEndpoint(a.target,e,t,n);this.validateRelationship(a,o,s,e);let c=a.explicitId??`edge-${i++}`,l={id:c,explicitId:!!a.explicitId,source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(l),r.set(c,{draft:a,relationship:l})}return this.model.relationshipCounter=i,r}resolveEndpoint(e,t,n,r){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${$(e.location)}`);let i=t.get(e.id);return i?i.kind:(n.set(e.id,{kind:`usecase`,id:e.id,label:e.label,location:e.location,generated:e.generated,shape:`ellipse`,classes:[]}),t.set(e.id,{kind:`usecase`,location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(r,e.id,e.location.span[0]),`usecase`)}reorderElements(e,t){let n=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let i of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0))){!n.has(i.id)&&!r.has(i.id)&&this.setElementModel(i);let e=n.get(i.id)??this.model.actors.get(i.id),t=r.get(i.id)??this.model.useCases.get(i.id);e?this.model.actors.set(i.id,e):t&&this.model.useCases.set(i.id,t)}}applyMetadataAssignments(e,t,n,r){for(let i of this.metadataAssignments){let a=e.get(i.target);if(!a){let e=this.inferMetadataKind(i.metadata);throw Error(`Metadata target '${i.target}' is unresolved${e?` (metadata implies ${e})`:``} at ${$(i.targetLocation)}`)}if(a.kind===`actor`||a.kind===`usecase`)this.applyStandaloneElementMetadata(t.get(i.target),i.metadata);else if(a.kind===`boundary`){let e=n.get(i.target);for(let t of i.metadata.properties)(t.key!==`type`||t.value!==`rect`&&t.value!==`package`)&&this.invalidMetadata(i.target,a.kind,t),e.type=t.value}else if(a.kind===`edge`){let e=r.get(i.target);if(!e)throw Error(`Metadata target '${i.target}' is not an explicit edge at ${$(i.targetLocation)}`);i.statement.kind=`edgeMetadata`,i.statement.edges=[{id:i.target,span:i.statement.span,idSpan:i.targetLocation.span,...i.statement.metadata?{metadata:i.statement.metadata}:{}}],delete i.statement.nodes;for(let t of i.metadata.properties)t.key===`animate`&&typeof t.value==`boolean`?e.relationship.animate=t.value:t.key===`animation`&&(t.value===`fast`||t.value===`slow`)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(i.target,a.kind,t)}else for(let e of i.metadata.properties)this.invalidMetadata(i.target,a.kind,e)}for(let{relationship:e}of r.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!0):n.key===`business`&&typeof n.value==`boolean`?e.business=n.value:this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,t){if(t)for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!1):n.key===`business`&&typeof n.value==`boolean`?(e.business!==void 0&&e.business!==n.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,t,n){t.key===`type`&&(t.value===`normal`||t.value===`hollow`||t.value===`awesome`)?(!n&&e.actorType!==void 0&&e.actorType!==t.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):t.key===`icon`&&typeof t.value==`string`?(!n&&e.icon!==void 0&&e.icon!==t.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):t.key===`business`&&typeof t.value==`boolean`?(!n&&e.business!==void 0&&e.business!==t.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?`icon`:t.actorType??`normal`;if(t.kind===`actor`){if(t.icon&&t.actorType&&t.actorType!==`normal`)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${$(t.location)}`);if(t.business&&(e===`icon`||e===`awesome`))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${$(t.location)}`)}else if((t.shape??`ellipse`)===`rect`&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${$(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let n=e.get(t.parentId);if(!n)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${$(t.parentLocation??t.location)}`);n.members.includes(t.id)||n.members.push(t.id)}for(let n of t.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${$(n.parentLocation??n.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??`rect`,e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let n of this.noteDrafts){let r=e.get(n.target);if(!r)throw Error(`Note target '${n.target}' is unresolved at ${$(n.targetLocation)}`);r.kind!==`actor`&&r.kind!==`usecase`&&this.conflict(`Note target '${n.target}' must be an actor or use case, not ${r.kind}`,n.targetLocation,r.location);let i=`note-${t++}`;this.model.notes.set(i,{id:i,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let n of this.classAssignments)for(let r of n.targets)Gm(this.getStylable(r.id,e,t,r.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,t,n.location).styles.push(...n.styles)}getStylable(e,t,n,r){let i=t.get(e)?.kind,a=i===`actor`?this.model.actors.get(e):i===`usecase`?this.model.useCases.get(e):i===`boundary`?this.model.systemBoundaries.get(e):i===`json`?this.model.jsonNodes.get(e):i===`edge`?n.get(e)?.relationship:void 0;if(!a)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${$(r)}`);return a}validateRelationship(e,t,r,i){let a=n(e=>e===`actor`||e===`usecase`||e===`json`,`allowed`);if(a(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,i.get(e.source.id).location),a(r)||this.conflict(`Relationship target '${e.target.id}' cannot be ${r}`,e.target.location,i.get(e.target.id).location),(e.type===`include`||e.type===`extend`)&&(t!==`usecase`||r!==`usecase`))throw Error(`${e.type} relationship requires use-case endpoints at ${$(e.location)}`);if(e.type===`generalization`&&(t!==`actor`&&t!==`usecase`||t!==r))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${$(e.location)}`);if(e.type===`association`&&(t===`json`||r===`json`)&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${$(e.location)}`)}setElementModel(e){if(e.kind===`actor`){let t=e.icon?`icon`:e.actorType??`normal`;this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??`ellipse`,business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let n of e.properties)if(n.key===`icon`)t.clear(),t.add(`actor`);else if(n.key===`animate`||n.key===`animation`)t.clear(),t.add(`edge`);else if(n.key===`type`)t.clear(),n.value===`rect`||n.value===`package`?t.add(`boundary`):(n.value===`normal`||n.value===`hollow`||n.value===`awesome`)&&t.add(`actor`);else if(n.key===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}invalidMetadata(e,t,n){throw Error(`Metadata property '${n.key}' is invalid for ${t} '${e}' at ${$(n.location)}`)}registerUnique(e,t,n,r,i){let a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${n})`,r,a.location,void 0,Wm(a)),e.set(t,{kind:n,location:r,generated:i})}recordFirst(e,t,n){let r=e.get(t);(r===void 0||n<r)&&e.set(t,n)}conflict(e,t,n,r,i){throw Error(`${e} at ${$(t)}${Um(r)}; previous declaration at ${$(n)}${Um(i)}`)}},qm=Am.getBaseCstVisitorConstructor(),Jm=new class extends qm{constructor(){super(),this.builder=new Km(np),this.source=``,this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{n(this,`UsecaseVisitor`)}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,`USECASE`)[0],n=[];for(let t of this.nodes(e,`line`))n.push(this.visit(t));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,`blankLine`,`commentLine`,`statement`);return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,`accTitleStatement`,`accDescrStatement`,`directionStatement`,`actorStatement`,`systemBoundaryStatement`,`noteStatement`,`jsonStatement`,`classDefStatement`,`classStatement`,`styleStatement`,`metadataAssignmentStatement`,`entityStatement`))}lineEnd(e){}blankLine(e){return{kind:`blank`,span:this.tokenSpan(this.tokens(e,`NEWLINE`)[0])}}commentLine(e){return{kind:`comment`,span:this.tokenSpan(this.tokens(e,`COMMENT`)[0])}}accTitleStatement(e){let t=this.tokens(e,`ACC_TITLE_LINE`)[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(`:`)+1).trim()),{kind:`accTitle`,span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,`ACC_DESCR_LINE`)[0],n=this.tokens(e,`ACC_DESCR_BLOCK`)[0],r=t?t.image.slice(t.image.indexOf(`:`)+1).trim():n.image.slice(n.image.indexOf(`{`)+1,n.image.lastIndexOf(`}`)).trim();return this.builder.setAccDescription(r),{kind:`accDescr`,span:[0,0]}}actorStatement(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e)),r=this.nodes(e,`relationTail`)[0],i=n.map((e,n)=>this.actorOccurrence(t[n],e,!0));for(let e of n)this.builder.addElement(this.actorDraft(e));if(!r)return{kind:`node`,span:[0,0],nodes:i};let a=this.visit(r);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));let o=this.relationshipDraft(n[0],a,this.nodeLocation(r));this.builder.addRelationship(o);let s=o.explicitId??`edge-${this.anonymousEdge++}`;return i.push(this.entityOccurrence(this.nodes(r.children,`entityName`)[0],a.target,a.target.explicitDeclaration)),{kind:`edge`,span:[0,0],nodes:i,edges:[{id:s,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,`actorName`)[0]),n=this.nodes(e,`metadata`)[0],r=this.nodes(e,`stereotype`)[0],i=this.nodes(e,`classSuffix`)[0],a=i?this.visit(i):{classes:[],spans:[]};return{...t,...n?{metadata:this.visit(n)}:{},...r?{stereotype:this.visit(r)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0],r=n?this.visit(n):this.tokenLabel(t);return{id:t.image,label:r,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e));for(let e of n)this.builder.addElement(this.actorDraft(e));return{kind:`node`,span:[0,0],nodes:n.map((e,n)=>this.actorOccurrence(t[n],e,!0))}}entityStatement(e){let t=this.nodes(e,`entityName`),n=this.visit(t[0]),r=this.nodes(e,`relationTail`)[0];if(!r)return n.explicitDeclaration=!0,n.shape??=`ellipse`,this.builder.addElement(this.entityDraft(n)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,!0)]};n.explicitDeclaration&&this.builder.addElement(this.entityDraft(n));let i=this.visit(r);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));let a={source:this.endpoint(n),target:this.endpoint(i.target),location:this.nodeLocation(r),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(a);let o=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:`edge`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(r.children,`entityName`)[0],i.target,i.target.explicitDeclaration)],edges:[{id:o,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0],r=this.nodes(e,`nodeLabel`)[0],i=this.nodes(e,`useCaseMetadata`)[0],a=this.nodes(e,`stereotype`)[0],o=this.nodes(e,`classSuffix`)[0],s=o?this.visit(o):{classes:[],spans:[]};if(t){let n=r?this.visit(r):this.tokenLabel(t),o=r?this.tokens(e,`LBRACKET`).length?`rect`:`ellipse`:void 0;return{id:t.image,label:n,location:this.tokenLocation(t),generated:!1,...o?{shape:o}:{},...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(o||i||a)}}let c=this.tokenLabel(n);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(n),generated:!0,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(i||a)}}nodeLabel(e){let t=this.allTokens(e);if(t.length===1&&(t[0].tokenType.name===`PLAIN_STRING`||t[0].tokenType.name===`MARKDOWN_STRING`))return this.tokenLabel(t[0]);let n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:`text`,span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,`metadata`)[0])}relationTail(e){let t=this.tokens(e,`IDENTIFIER`)[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,`arrow`)[0]),target:this.visit(this.nodes(e,`entityName`)[0])}}arrow(e){return this.visit(this.firstNode(e,`semanticRelation`,`forwardSolidOperator`,`backwardSolidOperator`,`markerlessSolidOperator`,`forwardCircleOperator`,`backwardCircleOperator`,`forwardCrossOperator`,`backwardCrossOperator`))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,`GENERALIZATION`).length)return{type:`generalization`,arrowType:q.SOLID_ARROW,minlen:1};let t=this.tokens(e,`INCLUDE`).length?`include`:`extend`,n=this.tokens(e,t===`include`?`INCLUDE`:`EXTEND`)[0];return{type:t,arrowType:q.SOLID_ARROW,label:{text:t,type:`text`,span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,`metadataProperty`).map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`COLON`),n=t[0],r=t[1],i=r.tokenType.name===`TRUE`||r.tokenType.name!==`FALSE`&&this.decodePlain(r),a=[n.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(n),value:i,span:a,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(r),location:this.tokenLocation(n)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,`systemBoundaryName`)[0]),n=this.nodes(e,`classSuffix`)[0],r=n?this.visit(n):{classes:[],spans:[]};t.classes=r.classes,this.builder.addBoundary(t);let i=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let a=this.nodes(e,`systemBoundaryContent`)[0],o=a?this.visit(a):[];this.parentBoundary=i;let s=this.tokens(e,`END`)[0],c=this.nodes(e,`metadata`)[0],l=c?this.visit(c):void 0,u={kind:`group`,span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(s),classSpans:r.spans,...l?{metadata:l.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...o.length?{children:o}:{}};return l&&this.builder.addMetadataAssignment(t.id,t.location,l,u),u}systemBoundaryName(e){let t=this.tokens(e,`IDENTIFIER`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0];return{id:t.image,label:n?this.visit(n):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0],r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,`blankLine`),...this.nodes(e,`commentLine`),...this.nodes(e,`boundaryElement`)].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,`actorDeclarationOnly`)[0];if(t)return this.visit(t);let n=this.nodes(e,`entityName`)[0],r=this.visit(n);return r.explicitDeclaration=!0,r.shape??=`ellipse`,this.builder.addElement(this.entityDraft(r)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(n,r,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,`metadataAssignmentTarget`)[0]),n=this.visit(this.nodes(e,`metadata`)[0]),r={kind:`metadata`,span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:n.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))};return this.builder.addMetadataAssignment(t.id,t.location,n,r),r}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],n=this.tokenLabel(t);return{id:t.tokenType.name===`IDENTIFIER`?t.image:this.generateId(n.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`nodeLabel`)[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:n,location:this.ctxLocation(e)}),{kind:`note`,span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,`STEREOTYPE_TEXT`)[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,`IDENTIFIER`);return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,`JSON_DECLARATION_START`)[0],n=this.tokens(e,`JSON_OBJECT_LITERAL`)[0],r=/^json[\t ]+(\w+)/.exec(t.image),i=r[1],a=r[0].length-i.length,o={span:[t.startOffset+a,t.startOffset+a+i.length],line:t.startLine??1,column:(t.startColumn??1)+a},s=Fm(n.image,n.startLine??1,n.startColumn??1),c=this.nodes(e,`classSuffix`)[0],l=c?this.visit(c):{classes:[],spans:[]},u={id:i,value:s.value,propertyOrder:s.propertyOrder,location:o,classes:l.classes};return this.builder.addJson(u),{kind:`json`,span:[0,0],nodes:[{id:i,span:o.span,idSpan:o.span,defines:!0,classSpans:l.spans}],classSpans:l.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>[`TD`,`TB`,`BT`,`RL`,`LR`].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:`direction`,span:[0,0]}}classDefStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addClassDef(t.map(e=>e.image),n),{kind:`classDef`,span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=1;for(;n<t.length&&this.source.slice((t[n-1].endOffset??t[n-1].startOffset)+1,t[n].startOffset).includes(`,`);n++);let r=t.slice(0,n).map(e=>({id:e.image,location:this.tokenLocation(e)})),i=t.slice(n).map(e=>e.image);return this.builder.addClassAssignment(r,i),{kind:`classAssign`,span:[0,0],ref:i[0],refSpan:this.tokenSpan(t[n]),nodes:r.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),n),{kind:`style`,span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,`styleValue`).map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll(`\\,`,`,`)}styleComponent(e){return this.allTokens(e).map(e=>e.image).join(``)}forwardSolidOperator(e){let t=this.tokens(e,`FORWARD_SOLID`)[0];return{type:`association`,arrowType:q.SOLID_ARROW,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,`BACKWARD_SOLID`)[0],n=this.nodes(e,`edgeLabel`)[0],r=n?this.tokens(e,`MARKERLESS_SOLID`).at(-1):t;return{type:`association`,arrowType:q.BACK_ARROW,minlen:this.solidMinlen(r),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,`edgeLabel`)[0],n=this.allTokens(e);if(!t)return{type:`association`,arrowType:q.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,`MARKERLESS_SOLID`)[0])};let r=n.at(-1),i=r.tokenType.name===`FORWARD_SOLID`?q.SOLID_ARROW:r.tokenType.name===`FORWARD_CIRCLE`?q.CIRCLE_ARROW:r.tokenType.name===`FORWARD_CROSS`?q.CROSS_ARROW:q.LINE_SOLID;return{type:`association`,arrowType:i,label:this.visit(t),minlen:i===q.SOLID_ARROW||i===q.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(e){return{type:`association`,arrowType:q.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:q.CIRCLE_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:`association`,arrowType:q.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:q.CROSS_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:`actor`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:`usecase`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,n){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:n,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,n){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...n?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,n){return this.actorOccurrence(e,t,n)}wrap(e,t){if(t.kind===`blank`||t.kind===`comment`)return t;t.span=this.nodeSpan(e);for(let e of t.edges??[])e.span=t.span;return t}tokenLabel(e){let t=e.tokenType.name===`MARKDOWN_STRING`?`markdown`:`text`,n=t===`markdown`?2:+(e.tokenType.name===`PLAIN_STRING`),r=this.tokenSpan(e,n);return{text:this.source.slice(r[0],r[1]),type:t,span:r}}decodePlain(e){return e.tokenType.name===`PLAIN_STRING`?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name===`PLAIN_STRING`?1:e.tokenType.name===`MARKDOWN_STRING`?2:0)}generateId(e){return e.replace(/\W/g,`_`)}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let t=e.tokenType.name===`PLAIN_STRING`?1:e.tokenType.name===`MARKDOWN_STRING`?2:0;return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);if(!n||!r)throw Error(`Usecase CST node has no source token`);return[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>`children`in e)}tokens(e,t){return(e[t]??[]).filter(e=>`tokenTypeIdx`in e)}firstNode(e,...t){for(let n of t){let t=this.nodes(e,n)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(`, `)}`)}allTokens(e){let t=[];for(let n of Object.values(e))for(let e of n)`tokenTypeIdx`in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},Ym={parse:n(async e=>{np.clear(),Am.input=[];try{Cf({diagramType:`usecase`,lexer:Dm,parser:Am,entry:n(()=>Am.start(),`entry`),visit:n(t=>Jm.build(t,e),`visit`)},e)}catch(t){np.clear();let n=Am.errors[0];if(n){let{token:r}=n,i=Number.isFinite(r.startOffset)?r.startOffset:e.length,a=typeof r.endOffset==`number`&&Number.isFinite(r.endOffset)?r.endOffset+1:i,o=r.startLine??e.slice(0,i).split(/\r\n|\r|\n/).length,s=Math.max(e.lastIndexOf(`
75
+ `,i-1),e.lastIndexOf(`\r`,i-1)),c=r.startColumn??i-s,l=t instanceof Error?t.message:String(t);throw Error(`${l} at line ${o}, column ${c} [${i},${a})`)}throw t}},`parse`)},Xm=[`point`,`circle`,`cross`,`extension`],Zm={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Qm=n((e,t)=>{let[n,r]=[e,t].map(e=>e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`);return`usecase-${n}-${r}`},`usecaseDomId`),$m=n(e=>`usecase-${e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`}`,`usecaseNodeDomId`),eh=n((e,t)=>t===`markdown`?h(e).map(e=>e.map(e=>e.content).join(` `)).join(`
76
+ `):e,`getAccessibleLabel`),th=n(e=>{let t=eh(e.label??e.id,e.labelType);if(Zm[e.shape]){let n=e.actorType&&e.actorType!==`normal`?`${e.actorType} `:``;return`${e.business?`business `:``}${n}actor ${t}${e.stereotype?`, stereotype ${e.stereotype}`:``}`}if(e.shape===`note`)return`Note for ${e.noteTargetLabel??e.noteTarget??``}: ${t}`;if(e.shape===`usecaseJsonTable`){let n=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join(`; `);return n?`${t}: ${n}`:t}let n=e.stereotype?`, stereotype ${e.stereotype}`:``;return`${e.business?`business `:``}use case ${t}${n}`},`getUsecaseNodeAccessibleName`),nh=n(e=>`${e.boundaryType} system boundary ${eh(e.label??e.id,e.labelType)}`,`getUsecaseBoundaryAccessibleName`),rh=n(e=>e.relationshipType===`note`?``:`${e.relationshipType===`association`&&e.label?`association ${eh(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`,`getUsecaseEdgeAccessibleName`),ih=n(e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),`escapePlainLabel`),ah=n(e=>e.replace(/([*[\\\]_`])/g,`\\$1`),`escapeMarkdownMarkers`),oh=n((e,t)=>{e.diagramId=t,e.markers=[...Xm];for(let t of e.nodes){let e=t;if(e.domId=$m(t.id),t.label!==void 0&&t.labelType===`text`&&(t.label=ih(t.label)),t.stereotype&&=ih(t.stereotype),!t.isGroup&&t.shape===`usecaseJsonTable`&&(t.jsonRows=t.jsonRows?.map(e=>({...e,key:ih(e.key),value:ih(e.value)}))),!t.isGroup&&(t.shape===`usecaseEllipse`||t.shape===`rect`)&&t.stereotype){let n=t.label??ih(t.id);t.label=`\xAB${ah(t.stereotype)}\xBB<br/>${t.labelType===`text`?ah(n):n}`,t.labelType=`markdown`,e.hasFoldedStereotype=!0,delete t.stereotype}}for(let t of e.edges)t.label!==void 0&&t.labelType===`text`&&(t.label=ih(t.label));return e},`prepareUsecaseLayoutData`),sh=n((e,n,r)=>{for(let t of n.nodes){let i=typeof t.domId==`string`?t.domId:Qm(n.diagramId,t.id),a=e.select(`#${i}`),o=t.isGroup?`boundary`:Zm[t.shape]?`actor`:t.shape===`note`?`note`:t.shape===`usecaseJsonTable`?`json`:`usecase`,s=r.nodes.get(t.id)??t.id;if(a.attr(`data-usecase-id`,t.id).attr(`data-usecase-kind`,o).attr(`role`,`img`).attr(`aria-label`,s),!t.isGroup&&(t.shape===`usecaseEllipse`||t.shape===`rect`)&&`hasFoldedStereotype`in t&&t.hasFoldedStereotype===!0){let e=a.node(),t=e?.querySelector(`.nodeLabel`),n=t?.querySelector(`p`)??t,r=n?.firstChild;if(n&&r?.nodeType===3){let e=n.ownerDocument.createElement(`span`);e.className=`usecase-stereotype`,n.insertBefore(e,r),e.appendChild(r)}else e?.querySelector(`.label tspan tspan, .label tspan`)?.classList.add(`usecase-stereotype`)}}let i=new Map(n.edges.map(e=>[e.id,e]));e.selectAll(`path[data-et="edge"]`).each(function(){let e=i.get(this.getAttribute(`data-id`)??``);if(!e)return;let a=t(this);a.attr(`id`,Qm(n.diagramId,e.id)).attr(`data-usecase-id`,e.id).attr(`data-usecase-kind`,e.internal?`note-connector`:`relationship`),e.internal?a.attr(`aria-hidden`,`true`):a.attr(`role`,`img`).attr(`aria-label`,r.edges.get(e.id)??e.id)})},`annotateUsecaseElements`),ch=n((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`),lh={draw:n(async(t,n,r,i)=>{e.info(`Drawing usecase diagram (unified)`,n);let{layout:a}=d(),o=i.db,s=o.getData(),c=new Map(s.nodes.map(e=>[e.id,eh(e.label??e.id,e.labelType)])),l={nodes:new Map(s.nodes.map(e=>[e.id,e.isGroup?nh(e):th(e.shape===`note`?{...e,noteTargetLabel:c.get(e.noteTarget??``)}:e)])),edges:new Map(s.edges.map(e=>[e.id,rh({...e,sourceLabel:c.get(e.source)??e.sourceLabel,targetLabel:c.get(e.target)??e.targetLabel})]))},u=ne(n,s.config.securityLevel);s.layoutAlgorithm=ae(a),oh(s,n),ch(u,s),await ie(s,u),sh(u,s,l);let f=s.diagramPadding;m.insertTitle(u,`usecaseDiagramTitleText`,0,o.getDiagramTitle?.()??``),re(u,f,`usecaseDiagram`,s.useMaxWidth),ch(u,s)},`draw`)},uh=n(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`),dh=n(e=>{let{theme:t,bkgColorArray:n,borderColorArray:r}=e;if(!ee(t,r))return``;let i=o().usecase?.colorScheme===`rotate`,a=te(e.look),s=a===`handDrawn`,c=_(n),l=``;for(let e=0;e<g(r);e++){let t=r[e],o=c?`fill: ${n[e%n.length]};`:``,u=`[data-look="${a}"][data-color-id="color-${e}"]`;l+=`
77
+
78
+ & ${u}.system-boundary rect.boundary-body,
79
+ & ${u}.system-boundary rect.boundary-tab,
80
+ & ${u}.system-boundary .boundary-body path,
81
+ & ${u}.system-boundary .boundary-tab path {
82
+ stroke: ${t};
83
+ ${o}
84
+ }
85
+ `,i&&(l+=`
86
+
87
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
88
+ the business variant.
89
+
90
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
91
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
92
+ fill stroked in the background colour, with no class to tell them apart. Stroking
93
+ both repaints the fill lines as border colour and the shape collapses into a solid
94
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
95
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
96
+ & ${u}.usecase-element ellipse,
97
+ & ${u}.usecase-element rect {
98
+ stroke: ${t};
99
+ ${o}
100
+ }
101
+
102
+ /* The business marker is a single classed path, so it can be reached safely by name --
103
+ without it the marker keeps the uniform border beside a palette-coloured body. No
104
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
105
+ & ${u}.usecase-element .usecase-business-marker {
106
+ stroke: ${t};
107
+ }
108
+
109
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
110
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
111
+ winning and a hollow actor stays hollow. Same reason as above for not descending
112
+ into the handDrawn paths. */
113
+ & ${u}.usecase-actor .usecase-actor-shape,
114
+ & ${u}.usecase-actor .usecase-actor-hollow,
115
+ & ${u}.usecase-actor .usecase-actor-awesome,
116
+ & ${u}.usecase-actor .usecase-actor-icon {
117
+ stroke: ${t};
118
+ ${o}
119
+ }
120
+ ${s?``:`
121
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
122
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
123
+ and a value set directly on the child always beats one inherited from the parent,
124
+ whatever the parent rule's specificity. So name the children too.
125
+
126
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
127
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
128
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
129
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
130
+ & ${u}.usecase-actor .usecase-actor-glyph path,
131
+ & ${u}.usecase-actor .usecase-actor-glyph circle {
132
+ stroke: ${t};
133
+ }
134
+ `}
135
+ `)}return l},`genColor`),fh={parser:Ym,db:np,renderer:lh,styles:n(e=>{let t=uh(e),n=te(e.look)===`handDrawn`;return`
136
+ ${dh(e)}
137
+ & .usecase-actor {
138
+ color: ${e.actorTextColor??e.primaryTextColor};
139
+ }
140
+
141
+ & .usecase-actor-shape,
142
+ & .usecase-actor-hollow,
143
+ & .usecase-actor-awesome,
144
+ & .usecase-actor-icon {
145
+ fill: ${t.actorBkg};
146
+ stroke: ${t.actorBorder};
147
+ stroke-width: 2px;
148
+ }
149
+ ${n?``:`
150
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
151
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
152
+ the glyph's own paths, and a value set directly on a child always beats one inherited
153
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
154
+ without this every actor renders in the node border colour rather than the actor
155
+ colour the rule above asks for.
156
+
157
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
158
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
159
+ depend on which stylesheet is concatenated last.
160
+
161
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
162
+ & .node.usecase-actor .usecase-actor-glyph path,
163
+ & .node.usecase-actor .usecase-actor-glyph circle {
164
+ stroke: ${t.actorBorder};
165
+ }
166
+ `}
167
+ & .usecase-actor .nodeLabel,
168
+ & .actor-label {
169
+ color: ${e.actorTextColor??e.primaryTextColor};
170
+ fill: ${e.actorTextColor??e.primaryTextColor};
171
+ font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
172
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
173
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
174
+ }
175
+
176
+ & .usecase-element ellipse,
177
+ & .usecase-element rect,
178
+ & .usecase-business ellipse,
179
+ & .usecase-business rect {
180
+ fill: ${t.bkg};
181
+ stroke: ${t.border};
182
+ stroke-width: 2px;
183
+ }
184
+ ${n?``:`
185
+ /* The same interception the actor glyph hits, one element down: neo ships
186
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
187
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
188
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
189
+ equivalent neo rule and is already correct; restating it here costs nothing and means
190
+ the two forms cannot drift apart again.
191
+
192
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
193
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
194
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
195
+ exists. */
196
+ & [data-look="${te(e.look)}"].node.usecase-element ellipse,
197
+ & [data-look="${te(e.look)}"].node.usecase-element rect {
198
+ fill: ${t.bkg};
199
+ stroke: ${t.border};
200
+ }
201
+
202
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
203
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
204
+ & [data-look="${te(e.look)}"].node.usecase-element .usecase-business-marker {
205
+ stroke: ${t.border};
206
+ }
207
+ `}
208
+ & .usecase-element .nodeLabel,
209
+ & .usecase-label {
210
+ color: ${e.primaryTextColor};
211
+ fill: ${e.primaryTextColor};
212
+ font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
213
+ font-size: var(--mermaid-usecase-font-size, 12px);
214
+ font-weight: var(--mermaid-usecase-font-weight, normal);
215
+ }
216
+
217
+ & .usecase-stereotype,
218
+ & .usecase-business-marker {
219
+ color: ${e.primaryTextColor};
220
+ fill: ${e.primaryTextColor};
221
+ stroke: ${t.border};
222
+ }
223
+
224
+ & .system-boundary rect.boundary-body,
225
+ & .system-boundary rect.boundary-tab,
226
+ & .system-boundary-package-tab {
227
+ fill: ${t.boundaryBkg};
228
+ stroke: ${t.boundaryBorder};
229
+ stroke-width: 1px;
230
+ }
231
+
232
+ & .system-boundary-title text {
233
+ fill: ${e.titleColor??e.primaryTextColor};
234
+ }
235
+
236
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
237
+ 'color' on the span, and that has to stay inheritable by its children. */
238
+ & .system-boundary-title span {
239
+ color: ${e.titleColor??e.primaryTextColor};
240
+ }
241
+
242
+ & .usecase-note {
243
+ fill: ${e.noteBkgColor};
244
+ stroke: ${e.noteBorderColor};
245
+ color: ${e.noteTextColor};
246
+ }
247
+
248
+ & .usecase-note .nodeLabel {
249
+ color: ${e.noteTextColor};
250
+ fill: ${e.noteTextColor};
251
+ }
252
+
253
+ & .usecase-json-table,
254
+ & .usecase-json-table rect,
255
+ & .usecase-json-cell {
256
+ fill: ${e.mainBkg};
257
+ stroke: ${e.nodeBorder??e.primaryColor};
258
+ }
259
+
260
+ & .usecase-json-title,
261
+ & .usecase-json-key,
262
+ & .usecase-json-value {
263
+ color: ${e.primaryTextColor};
264
+ fill: ${e.primaryTextColor};
265
+ }
266
+
267
+ & .relationship {
268
+ fill: none;
269
+ stroke: ${e.lineColor};
270
+ }
271
+
272
+ & .relationship-include,
273
+ & .relationship-extend,
274
+ & .relationship-note {
275
+ stroke-dasharray: 3;
276
+ }
277
+
278
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
279
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
280
+ & .relationship-include {
281
+ stroke: ${t.includeLine};
282
+ }
283
+
284
+ & .relationship-extend {
285
+ stroke: ${t.extendLine};
286
+ }
287
+
288
+ & .relationship.edge-animation-fast,
289
+ & .relationship.edge-animation-slow {
290
+ stroke-linecap: round;
291
+ }
292
+
293
+ & .edgeLabel,
294
+ & .edgeLabel p {
295
+ background-color: ${e.edgeLabelBackground};
296
+ }
297
+
298
+ & .labelBkg {
299
+ background-color: ${e.edgeLabelBackground};
300
+ padding: 0 2px;
301
+ }
302
+
303
+ & .edgeLabel .label rect {
304
+ fill: ${e.edgeLabelBackground};
305
+ }
306
+
307
+ & .relationship-label,
308
+ & .edgeLabel {
309
+ color: ${e.primaryTextColor};
310
+ fill: ${e.primaryTextColor};
311
+ font-family: ${e.fontFamily};
312
+ font-size: 10px;
313
+ font-weight: normal;
314
+ }
315
+
316
+ & .marker,
317
+ & .marker.point,
318
+ & .marker.circle,
319
+ & .marker.cross {
320
+ fill: ${e.lineColor};
321
+ stroke: ${e.lineColor};
322
+ }
323
+
324
+ & .marker.extension {
325
+ fill: ${e.mainBkg};
326
+ stroke: ${e.lineColor};
327
+ }
328
+ `},`getStyles`)};export{fh as diagram};