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