ompchamber 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +46 -1
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/static/css/{index.5291f58223.css → index.51f68210a5.css} +1 -1
  4. package/dist/client/static/js/async/{3y.ededeebde8.js → 3y.4c2596f64c.js} +3 -3
  5. package/dist/client/static/js/async/73.308dff4da8.js +1 -0
  6. package/dist/client/static/js/async/{ty.3d93cf5f5f.js → 7g.a7814350c3.js} +1 -1
  7. package/dist/client/static/js/async/a.bce4542392.js +1 -0
  8. package/dist/client/static/js/async/g.8515cbc6f7.js +2 -0
  9. package/dist/client/static/js/async/hn.b645041e00.js +1 -0
  10. package/dist/client/static/js/async/{jg.69a4beade8.js → jg.d86ebd4013.js} +1 -1
  11. package/dist/client/static/js/async/l.12dd34e1be.js +1 -0
  12. package/dist/client/static/js/async/ls.9d9a01026c.js +104 -0
  13. package/dist/client/static/js/async/mw.ca1512563c.js +10 -0
  14. package/dist/client/static/js/async/nk.fc7e58325e.js +1 -0
  15. package/dist/client/static/js/async/{q.7fb4d2f374.js → q.542c184fec.js} +3 -3
  16. package/dist/client/static/js/async/t.cda4891526.js +1 -0
  17. package/dist/client/static/js/async/tr.e878658140.js +309 -0
  18. package/dist/client/static/js/async/uf.24ca3d49c3.js +2 -0
  19. package/dist/client/static/js/{index.0ac93ee878.js → index.47d3b04d5f.js} +7 -7
  20. package/dist/client/static/js/{uy.5f791144ce.js → uy.2e8929ed0c.js} +2 -2
  21. package/package.json +13 -5
  22. package/src/cli/lib/args.js +6 -6
  23. package/src/cli/lib/commands/logs.js +76 -34
  24. package/src/cli/lib/commands/restart.js +30 -9
  25. package/src/cli/lib/commands/serve.js +12 -4
  26. package/src/cli/lib/commands/status.js +40 -18
  27. package/src/cli/lib/commands/stop.js +12 -7
  28. package/src/cli/lib/commands/update.js +2 -5
  29. package/src/cli/lib/paths.js +8 -28
  30. package/src/cli/lib/runtime.js +118 -108
  31. package/src/client/components/common/code-editor/index.tsx +5 -1
  32. package/src/client/components/common/code-surface/index.tsx +49 -1
  33. package/src/client/components/common/code-surface/measure.ts +99 -0
  34. package/src/client/components/layout/RightActivityBar.tsx +42 -69
  35. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +5 -6
  36. package/src/client/components/layout/desktop-layout/index.tsx +11 -9
  37. package/src/client/components/layout/desktop-layout/resizer/index.tsx +22 -29
  38. package/src/client/components/layout/desktop-layout/resizer/utils.test.ts +33 -0
  39. package/src/client/components/layout/desktop-layout/resizer/utils.ts +34 -0
  40. package/src/client/components/mobile/RightSidebar.tsx +42 -119
  41. package/src/client/components/mobile/mobile-main-view/Header.tsx +17 -1
  42. package/src/client/components/workspace/editor/index.tsx +4 -1
  43. package/src/client/hooks/editor/use-file-editor.test.ts +158 -0
  44. package/src/client/hooks/editor/use-file-editor.ts +35 -19
  45. package/src/server/index.ts +51 -1
  46. package/src/server/lib/lifecycle/identity.ts +108 -0
  47. package/src/server/lib/lifecycle/instance.ts +102 -0
  48. package/src/server/lib/lifecycle/occupant.ts +101 -0
  49. package/src/server/lib/lifecycle/paths.ts +50 -0
  50. package/src/server/lib/lifecycle/port-guard.ts +170 -0
  51. package/src/server/lib/lifecycle/probe.ts +121 -0
  52. package/src/server/plugins/static.test.ts +63 -0
  53. package/src/server/plugins/static.ts +28 -4
  54. package/src/server/routes/health/probe.ts +8 -0
  55. package/src/shared/lib/markdown/mermaid.ts +8 -0
  56. package/src/shared/lib/workspace/panel-widths.test.ts +5 -5
  57. package/src/shared/lib/workspace/panel-widths.ts +23 -10
  58. package/src/shared/lib/workspace/right-panels.ts +10 -4
  59. package/dist/client/static/js/async/73.50280ce58d.js +0 -1
  60. package/dist/client/static/js/async/a.e05da304c8.js +0 -10
  61. package/dist/client/static/js/async/ar.1e14da5588.js +0 -1
  62. package/dist/client/static/js/async/g.7a4bbd4798.js +0 -2
  63. package/dist/client/static/js/async/hn.7568bdb58b.js +0 -1
  64. package/dist/client/static/js/async/l.102a97fce6.js +0 -104
  65. package/dist/client/static/js/async/l6.c56640c205.js +0 -1
  66. package/dist/client/static/js/async/nk.6de011832e.js +0 -1
  67. package/dist/client/static/js/async/t.cb3fcf8615.js +0 -1
  68. package/dist/client/static/js/async/uf.46ad6209fa.js +0 -2
  69. package/dist/client/static/js/async/vn.e98e2f3b61.js +0 -309
  70. /package/dist/client/static/js/async/{3y.ededeebde8.js.LICENSE.txt → 3y.4c2596f64c.js.LICENSE.txt} +0 -0
  71. /package/dist/client/static/js/async/{g.7a4bbd4798.js.LICENSE.txt → g.8515cbc6f7.js.LICENSE.txt} +0 -0
  72. /package/dist/client/static/js/async/{a.e05da304c8.js.LICENSE.txt → mw.ca1512563c.js.LICENSE.txt} +0 -0
  73. /package/dist/client/static/js/async/{q.7fb4d2f374.js.LICENSE.txt → q.542c184fec.js.LICENSE.txt} +0 -0
  74. /package/dist/client/static/js/async/{uf.46ad6209fa.js.LICENSE.txt → uf.24ca3d49c3.js.LICENSE.txt} +0 -0
  75. /package/dist/client/static/js/{index.0ac93ee878.js.LICENSE.txt → index.47d3b04d5f.js.LICENSE.txt} +0 -0
  76. /package/dist/client/static/js/{uy.5f791144ce.js.LICENSE.txt → uy.2e8929ed0c.js.LICENSE.txt} +0 -0
@@ -1,309 +0,0 @@
1
- "use strict";(self.rspackChunkompchamber=self.rspackChunkompchamber||[]).push([["vn"],{WJ(e,t,i){var s=i("Yr"),n=i("M4"),r=i("Gt"),a=(0,r.K)((e,t,i,r)=>{e.attr("class",i);let{width:a,height:c,x:h,y:u}=o(e,t);(0,s.a$)(e,c,a,r);let d=l(h,u,a,c,t);e.attr("viewBox",d),n.R.debug(`viewBox configured: ${d} with padding: ${t}`)},"setupViewPortForSVG"),o=(0,r.K)((e,t)=>{let i=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:i.width+2*t,height:i.height+2*t,x:i.x,y:i.y}},"calculateDimensionsWithPadding"),l=(0,r.K)((e,t,i,s,n)=>`${e-n} ${t-n} ${i} ${s}`,"createViewBox");i.d(t,{P:()=>a})},OT(e,t,i){var s=i("Gt"),n=i("El"),r=(0,s.K)((e,t)=>{let i;return"sandbox"===t&&(i=(0,n.Ltv)("#i"+e)),("sandbox"===t?(0,n.Ltv)(i.nodes()[0].contentDocument.body):(0,n.Ltv)("body")).select(`[id="${e}"]`)},"getDiagramElement");i.d(t,{A:()=>r})},Nb(e,t,i){i.d(t,{diagram:()=>lw});var s,n,r,a,o,l,c,h,u,d,p,f,m,T,g,E,y,A,L=i("OT"),S=i("WJ"),O=i("mW");i("Q"),i("ix"),i("LC"),i("bQ"),i("Ut"),i("PF");var b=i("iV");i("h5");var R=i("pK"),k=i("NH"),N=i("Yr"),v=i("M4"),I=i("Gt"),C=function(e,t){for(var i=-1,s=null==e?0:e.length;++i<s&&!1!==t(e[i],i,e););return e},_=function(e,t,i){for(var s=-1,n=Object(e),r=i(e),a=r.length;a--;){var o=r[++s];if(!1===t(n[o],o,n))break}return e},x=function(e,t){for(var i=-1,s=Array(e);++i<e;)s[i]=t(i);return s},U="object"==typeof global&&global&&global.Object===Object&&global,M="object"==typeof self&&self&&self.Object===Object&&self,w=U||M||Function("return this")(),P=w.Symbol,D=Object.prototype,$=D.hasOwnProperty,F=D.toString,B=P?P.toStringTag:void 0,K=function(e){var t=$.call(e,B),i=e[B];try{e[B]=void 0;var s=!0}catch(e){}var n=F.call(e);return s&&(t?e[B]=i:delete e[B]),n},j=Object.prototype.toString,G=P?P.toStringTag:void 0,W=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":G&&G in Object(e)?K(e):j.call(e)},z=function(e){return null!=e&&"object"==typeof e},V=function(e){return z(e)&&"[object Arguments]"==W(e)},H=Object.prototype,Y=H.hasOwnProperty,X=H.propertyIsEnumerable,J=V(function(){return arguments}())?V:function(e){return z(e)&&Y.call(e,"callee")&&!X.call(e,"callee")},q=Array.isArray,Z="object"==typeof exports&&exports&&!exports.nodeType&&exports,Q=Z&&"object"==typeof module&&module&&!module.nodeType&&module,ee=Q&&Q.exports===Z?w.Buffer:void 0,et=(ee?ee.isBuffer:void 0)||function(){return!1},ei=/^(?:0|[1-9]\d*)$/,es=function(e,t){var i=typeof e;return!!(t=null==t?0x1fffffffffffff:t)&&("number"==i||"symbol"!=i&&ei.test(e))&&e>-1&&e%1==0&&e<t},en=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff},er={};er["[object Float32Array]"]=er["[object Float64Array]"]=er["[object Int8Array]"]=er["[object Int16Array]"]=er["[object Int32Array]"]=er["[object Uint8Array]"]=er["[object Uint8ClampedArray]"]=er["[object Uint16Array]"]=er["[object Uint32Array]"]=!0,er["[object Arguments]"]=er["[object Array]"]=er["[object ArrayBuffer]"]=er["[object Boolean]"]=er["[object DataView]"]=er["[object Date]"]=er["[object Error]"]=er["[object Function]"]=er["[object Map]"]=er["[object Number]"]=er["[object Object]"]=er["[object RegExp]"]=er["[object Set]"]=er["[object String]"]=er["[object WeakMap]"]=!1;var ea=function(e){return function(t){return e(t)}},eo="object"==typeof exports&&exports&&!exports.nodeType&&exports,el=eo&&"object"==typeof module&&module&&!module.nodeType&&module,ec=el&&el.exports===eo&&U.process,eh=function(){try{var e=el&&el.require&&el.require("util").types;if(e)return e;return ec&&ec.binding&&ec.binding("util")}catch(e){}}(),eu=eh&&eh.isTypedArray,ed=eu?ea(eu):function(e){return z(e)&&en(e.length)&&!!er[W(e)]},ep=Object.prototype.hasOwnProperty,ef=function(e,t){var i=q(e),s=!i&&J(e),n=!i&&!s&&et(e),r=!i&&!s&&!n&&ed(e),a=i||s||n||r,o=a?x(e.length,String):[],l=o.length;for(var c in e)(t||ep.call(e,c))&&!(a&&("length"==c||n&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||es(c,l)))&&o.push(c);return o},em=Object.prototype,eT=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||em)},eg=function(e,t){return function(i){return e(t(i))}},eE=eg(Object.keys,Object),ey=Object.prototype.hasOwnProperty,eA=function(e){if(!eT(e))return eE(e);var t=[];for(var i in Object(e))ey.call(e,i)&&"constructor"!=i&&t.push(i);return t},eL=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},eS=function(e){if(!eL(e))return!1;var t=W(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},eO=function(e){return null!=e&&en(e.length)&&!eS(e)},eb=function(e){return eO(e)?ef(e):eA(e)},eR=(s=function(e,t){return e&&_(e,t,eb)},function(e,t){if(null==e)return e;if(!eO(e))return s(e,t);for(var i=e.length,n=-1,r=Object(e);++n<i&&!1!==t(r[n],n,r););return e}),ek=function(e){return e},eN=function(e,t){return(q(e)?C:eR)(e,"function"==typeof t?t:ek)},ev=function(e,t){for(var i=-1,s=null==e?0:e.length,n=Array(s);++i<s;)n[i]=t(e[i],i,e);return n},eI=function(e){return null==e?[]:ev(eb(e),function(t){return e[t]})},eC=w["__core-js_shared__"],e_=(n=/[^.]+$/.exec(eC&&eC.keys&&eC.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",ex=Function.prototype.toString,eU=function(e){if(null!=e){try{return ex.call(e)}catch(e){}try{return e+""}catch(e){}}return""},eM=/^\[object .+?Constructor\]$/,ew=Object.prototype,eP=Function.prototype.toString,eD=ew.hasOwnProperty,e$=RegExp("^"+eP.call(eD).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),eF=function(e){return!!eL(e)&&(!e_||!(e_ in e))&&(eS(e)?e$:eM).test(eU(e))},eB=function(e,t){var i=null==e?void 0:e[t];return eF(i)?i:void 0},eK=eB(w,"DataView"),ej=eB(w,"Map"),eG=eB(w,"Promise"),eW=eB(w,"Set"),ez=eB(w,"WeakMap"),eV="[object Map]",eH="[object Promise]",eY="[object Set]",eX="[object WeakMap]",eJ="[object DataView]",eq=eU(eK),eZ=eU(ej),eQ=eU(eG),e0=eU(eW),e1=eU(ez),e2=W;(eK&&e2(new eK(new ArrayBuffer(1)))!=eJ||ej&&e2(new ej)!=eV||eG&&e2(eG.resolve())!=eH||eW&&e2(new eW)!=eY||ez&&e2(new ez)!=eX)&&(e2=function(e){var t=W(e),i="[object Object]"==t?e.constructor:void 0,s=i?eU(i):"";if(s)switch(s){case eq:return eJ;case eZ:return eV;case eQ:return eH;case e0:return eY;case e1:return eX}return t});var e3=e2,e6=Object.prototype.hasOwnProperty,e5=function(e){if(null==e)return!0;if(eO(e)&&(q(e)||"string"==typeof e||"function"==typeof e.splice||et(e)||ed(e)||J(e)))return!e.length;var t=e3(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(eT(e))return!eA(e).length;for(var i in e)if(e6.call(e,i))return!1;return!0},e4=function(e,t){return e===t||e!=e&&t!=t},e8=function(e,t){for(var i=e.length;i--;)if(e4(e[i][0],t))return i;return -1},e9=Array.prototype.splice;function e7(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}e7.prototype.clear=function(){this.__data__=[],this.size=0},e7.prototype.delete=function(e){var t=this.__data__,i=e8(t,e);return!(i<0)&&(i==t.length-1?t.pop():e9.call(t,i,1),--this.size,!0)},e7.prototype.get=function(e){var t=this.__data__,i=e8(t,e);return i<0?void 0:t[i][1]},e7.prototype.has=function(e){return e8(this.__data__,e)>-1},e7.prototype.set=function(e,t){var i=this.__data__,s=e8(i,e);return s<0?(++this.size,i.push([e,t])):i[s][1]=t,this};var te=eB(Object,"create"),tt=Object.prototype.hasOwnProperty,ti=Object.prototype.hasOwnProperty;function ts(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}ts.prototype.clear=function(){this.__data__=te?te(null):{},this.size=0},ts.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t},ts.prototype.get=function(e){var t=this.__data__;if(te){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return tt.call(t,e)?t[e]:void 0},ts.prototype.has=function(e){var t=this.__data__;return te?void 0!==t[e]:ti.call(t,e)},ts.prototype.set=function(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=te&&void 0===t?"__lodash_hash_undefined__":t,this};var tn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},tr=function(e,t){var i=e.__data__;return tn(t)?i["string"==typeof t?"string":"hash"]:i.map};function ta(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function to(e){var t=this.__data__=new e7(e);this.size=t.size}function tl(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new ta;++t<i;)this.add(e[t])}ta.prototype.clear=function(){this.size=0,this.__data__={hash:new ts,map:new(ej||e7),string:new ts}},ta.prototype.delete=function(e){var t=tr(this,e).delete(e);return this.size-=!!t,t},ta.prototype.get=function(e){return tr(this,e).get(e)},ta.prototype.has=function(e){return tr(this,e).has(e)},ta.prototype.set=function(e,t){var i=tr(this,e),s=i.size;return i.set(e,t),this.size+=+(i.size!=s),this},to.prototype.clear=function(){this.__data__=new e7,this.size=0},to.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},to.prototype.get=function(e){return this.__data__.get(e)},to.prototype.has=function(e){return this.__data__.has(e)},to.prototype.set=function(e,t){var i=this.__data__;if(i instanceof e7){var s=i.__data__;if(!ej||s.length<199)return s.push([e,t]),this.size=++i.size,this;i=this.__data__=new ta(s)}return i.set(e,t),this.size=i.size,this},tl.prototype.add=tl.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},tl.prototype.has=function(e){return this.__data__.has(e)};var tc=function(e,t){for(var i=-1,s=null==e?0:e.length;++i<s;)if(t(e[i],i,e))return!0;return!1},th=function(e,t){return e.has(t)},tu=function(e,t,i,s,n,r){var a=1&i,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var c=r.get(e),h=r.get(t);if(c&&h)return c==t&&h==e;var u=-1,d=!0,p=2&i?new tl:void 0;for(r.set(e,t),r.set(t,e);++u<o;){var f=e[u],m=t[u];if(s)var T=a?s(m,f,u,t,e,r):s(f,m,u,e,t,r);if(void 0!==T){if(T)continue;d=!1;break}if(p){if(!tc(t,function(e,t){if(!th(p,t)&&(f===e||n(f,e,i,s,r)))return p.push(t)})){d=!1;break}}else if(!(f===m||n(f,m,i,s,r))){d=!1;break}}return r.delete(e),r.delete(t),d},td=w.Uint8Array,tp=function(e){var t=-1,i=Array(e.size);return e.forEach(function(e,s){i[++t]=[s,e]}),i},tf=function(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i},tm=P?P.prototype:void 0,tT=tm?tm.valueOf:void 0,tg=function(e,t,i,s,n,r,a){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":if(e.byteLength!=t.byteLength||!r(new td(e),new td(t)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return e4(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var o=tp;case"[object Set]":var l=1&s;if(o||(o=tf),e.size!=t.size&&!l)break;var c=a.get(e);if(c)return c==t;s|=2,a.set(e,t);var h=tu(o(e),o(t),s,n,r,a);return a.delete(e),h;case"[object Symbol]":if(tT)return tT.call(e)==tT.call(t)}return!1},tE=function(e,t){for(var i=-1,s=t.length,n=e.length;++i<s;)e[n+i]=t[i];return e},ty=function(e,t,i){var s=t(e);return q(e)?s:tE(s,i(e))},tA=function(e,t){for(var i=-1,s=null==e?0:e.length,n=0,r=[];++i<s;){var a=e[i];t(a,i,e)&&(r[n++]=a)}return r},tL=function(){return[]},tS=Object.prototype.propertyIsEnumerable,tO=Object.getOwnPropertySymbols,tb=tO?function(e){return null==e?[]:tA(tO(e=Object(e)),function(t){return tS.call(e,t)})}:tL,tR=function(e){return ty(e,eb,tb)},tk=Object.prototype.hasOwnProperty,tN=function(e,t,i,s,n,r){var a=1&i,o=tR(e),l=o.length;if(l!=tR(t).length&&!a)return!1;for(var c=l;c--;){var h=o[c];if(!(a?h in t:tk.call(t,h)))return!1}var u=r.get(e),d=r.get(t);if(u&&d)return u==t&&d==e;var p=!0;r.set(e,t),r.set(t,e);for(var f=a;++c<l;){var m=e[h=o[c]],T=t[h];if(s)var g=a?s(T,m,h,t,e,r):s(m,T,h,e,t,r);if(!(void 0===g?m===T||n(m,T,i,s,r):g)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var E=e.constructor,y=t.constructor;E!=y&&"constructor"in e&&"constructor"in t&&!("function"==typeof E&&E instanceof E&&"function"==typeof y&&y instanceof y)&&(p=!1)}return r.delete(e),r.delete(t),p},tv="[object Arguments]",tI="[object Array]",tC="[object Object]",t_=Object.prototype.hasOwnProperty,tx=function(e,t,i,s,n,r){var a=q(e),o=q(t),l=a?tI:e3(e),c=o?tI:e3(t);l=l==tv?tC:l,c=c==tv?tC:c;var h=l==tC,u=c==tC,d=l==c;if(d&&et(e)){if(!et(t))return!1;a=!0,h=!1}if(d&&!h)return r||(r=new to),a||ed(e)?tu(e,t,i,s,n,r):tg(e,t,l,i,s,n,r);if(!(1&i)){var p=h&&t_.call(e,"__wrapped__"),f=u&&t_.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,T=f?t.value():t;return r||(r=new to),n(m,T,i,s,r)}}return!!d&&(r||(r=new to),tN(e,t,i,s,n,r))},tU=function e(t,i,s,n,r){return t===i||(null!=t&&null!=i&&(z(t)||z(i))?tx(t,i,s,n,e,r):t!=t&&i!=i)},tM=function(e,t,i,s){var n=i.length,r=n,a=!s;if(null==e)return!r;for(e=Object(e);n--;){var o=i[n];if(a&&o[2]?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++n<r;){var l=(o=i[n])[0],c=e[l],h=o[1];if(a&&o[2]){if(void 0===c&&!(l in e))return!1}else{var u=new to;if(s)var d=s(c,h,l,e,t,u);if(!(void 0===d?tU(h,c,3,s,u):d))return!1}}return!0},tw=function(e){return e==e&&!eL(e)},tP=function(e){for(var t=eb(e),i=t.length;i--;){var s=t[i],n=e[s];t[i]=[s,n,tw(n)]}return t},tD=function(e,t){return function(i){return null!=i&&i[e]===t&&(void 0!==t||e in Object(i))}},t$=function(e){var t=tP(e);return 1==t.length&&t[0][2]?tD(t[0][0],t[0][1]):function(i){return i===e||tM(i,e,t)}},tF=function(e){return"symbol"==typeof e||z(e)&&"[object Symbol]"==W(e)},tB=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tK=/^\w*$/,tj=function(e,t){if(q(e))return!1;var i=typeof e;return!!("number"==i||"symbol"==i||"boolean"==i||null==e||tF(e))||tK.test(e)||!tB.test(e)||null!=t&&e in Object(t)};function tG(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError("Expected a function");var i=function(){var s=arguments,n=t?t.apply(this,s):s[0],r=i.cache;if(r.has(n))return r.get(n);var a=e.apply(this,s);return i.cache=r.set(n,a)||r,a};return i.cache=new(tG.Cache||ta),i}tG.Cache=ta;var tW=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tz=/\\(\\)?/g,tV=(a=(r=tG(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(tW,function(e,i,s,n){t.push(s?n.replace(tz,"$1"):i||e)}),t},function(e){return 500===a.size&&a.clear(),e})).cache,r),tH=P?P.prototype:void 0,tY=tH?tH.toString:void 0,tX=function e(t){if("string"==typeof t)return t;if(q(t))return ev(t,e)+"";if(tF(t))return tY?tY.call(t):"";var i=t+"";return"0"==i&&1/t==-1/0?"-0":i},tJ=function(e,t){return q(e)?e:tj(e,t)?[e]:tV(null==e?"":tX(e))},tq=function(e){if("string"==typeof e||tF(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t},tZ=function(e,t){t=tJ(t,e);for(var i=0,s=t.length;null!=e&&i<s;)e=e[tq(t[i++])];return i&&i==s?e:void 0},tQ=function(e,t,i){var s=null==e?void 0:tZ(e,t);return void 0===s?i:s},t0=function(e,t){return null!=e&&t in Object(e)},t1=function(e,t,i){t=tJ(t,e);for(var s=-1,n=t.length,r=!1;++s<n;){var a=tq(t[s]);if(!(r=null!=e&&i(e,a)))break;e=e[a]}return r||++s!=n?r:!!(n=null==e?0:e.length)&&en(n)&&es(a,n)&&(q(e)||J(e))},t2=function(e){var t;return tj(e)?(t=tq(e),function(e){return null==e?void 0:e[t]}):function(t){return tZ(t,e)}},t3=function(e){if("function"==typeof e)return e;if(null==e)return ek;if("object"==typeof e){var t,i;return q(e)?(t=e[0],i=e[1],tj(t)&&tw(i)?tD(tq(t),i):function(e){var s=tQ(e,t);return void 0===s&&s===i?null!=e&&t1(e,t,t0):tU(i,s,3)}):t$(e)}return t2(e)},t6=function(e,t){var i=-1,s=eO(e)?Array(e.length):[];return eR(e,function(e,n,r){s[++i]=t(e,n,r)}),s},t5=function(e,t){return(q(e)?ev:t6)(e,t3(t))},t4=Object.prototype.hasOwnProperty,t8=function(e,t){return null!=e&&t4.call(e,t)},t9=function(e,t){return null!=e&&t1(e,t,t8)},t7=function(){try{var e=eB(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),ie=function(e,t,i){"__proto__"==t&&t7?t7(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i},it=Object.prototype.hasOwnProperty,ii=function(e,t,i){var s=e[t];it.call(e,t)&&e4(s,i)&&(void 0!==i||t in e)||ie(e,t,i)},is=function(e,t,i,s){var n=!i;i||(i={});for(var r=-1,a=t.length;++r<a;){var o=t[r],l=s?s(i[o],e[o],o,i,e):void 0;void 0===l&&(l=e[o]),n?ie(i,o,l):ii(i,o,l)}return i},ir=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t},ia=Object.prototype.hasOwnProperty,io=function(e){if(!eL(e))return ir(e);var t=eT(e),i=[];for(var s in e)"constructor"==s&&(t||!ia.call(e,s))||i.push(s);return i},il=function(e){return eO(e)?ef(e,!0):io(e)},ic="object"==typeof exports&&exports&&!exports.nodeType&&exports,ih=ic&&"object"==typeof module&&module&&!module.nodeType&&module,iu=ih&&ih.exports===ic?w.Buffer:void 0,id=iu?iu.allocUnsafe:void 0,ip=function(e,t){if(t)return e.slice();var i=e.length,s=id?id(i):new e.constructor(i);return e.copy(s),s},im=function(e,t){var i=-1,s=e.length;for(t||(t=Array(s));++i<s;)t[i]=e[i];return t},iT=eg(Object.getPrototypeOf,Object),ig=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)tE(t,tb(e)),e=iT(e);return t}:tL,iE=function(e){return ty(e,il,ig)},iy=Object.prototype.hasOwnProperty,iA=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&iy.call(e,"index")&&(i.index=e.index,i.input=e.input),i},iL=function(e){var t=new e.constructor(e.byteLength);return new td(t).set(new td(e)),t},iS=function(e,t){var i=t?iL(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)},iO=/\w*$/,ib=function(e){var t=new e.constructor(e.source,iO.exec(e));return t.lastIndex=e.lastIndex,t},iR=P?P.prototype:void 0,ik=iR?iR.valueOf:void 0,iN=function(e,t){var i=t?iL(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)},iv=function(e,t,i){var s=e.constructor;switch(t){case"[object ArrayBuffer]":return iL(e);case"[object Boolean]":case"[object Date]":return new s(+e);case"[object DataView]":return iS(e,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return iN(e,i);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(e);case"[object RegExp]":return ib(e);case"[object Symbol]":return ik?Object(ik.call(e)):{}}},iI=Object.create,iC=function(){function e(){}return function(t){if(!eL(t))return{};if(iI)return iI(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),i_=eh&&eh.isMap,ix=i_?ea(i_):function(e){return z(e)&&"[object Map]"==e3(e)},iU=eh&&eh.isSet,iM=iU?ea(iU):function(e){return z(e)&&"[object Set]"==e3(e)},iw="[object Arguments]",iP="[object Function]",iD="[object Object]",i$={};i$[iw]=i$["[object Array]"]=i$["[object ArrayBuffer]"]=i$["[object DataView]"]=i$["[object Boolean]"]=i$["[object Date]"]=i$["[object Float32Array]"]=i$["[object Float64Array]"]=i$["[object Int8Array]"]=i$["[object Int16Array]"]=i$["[object Int32Array]"]=i$["[object Map]"]=i$["[object Number]"]=i$[iD]=i$["[object RegExp]"]=i$["[object Set]"]=i$["[object String]"]=i$["[object Symbol]"]=i$["[object Uint8Array]"]=i$["[object Uint8ClampedArray]"]=i$["[object Uint16Array]"]=i$["[object Uint32Array]"]=!0,i$["[object Error]"]=i$[iP]=i$["[object WeakMap]"]=!1;var iF=function e(t,i,s,n,r,a){var o,l=1&i,c=2&i,h=4&i;if(s&&(o=r?s(t,n,r,a):s(t)),void 0!==o)return o;if(!eL(t))return t;var u=q(t);if(u){if(o=iA(t),!l)return im(t,o)}else{var d,p,f,m,T,g=e3(t),E=g==iP||"[object GeneratorFunction]"==g;if(et(t))return ip(t,l);if(g==iD||g==iw||E&&!r){if(o=c||E||"function"!=typeof(d=t).constructor||eT(d)?{}:iC(iT(d)),!l)return c?(f=(p=o)&&is(t,il(t),p),is(t,ig(t),f)):(T=(m=o)&&is(t,eb(t),m),is(t,tb(t),T))}else{if(!i$[g])return r?t:{};o=iv(t,g,l)}}a||(a=new to);var y=a.get(t);if(y)return y;a.set(t,o),iM(t)?t.forEach(function(n){o.add(e(n,i,s,n,t,a))}):ix(t)&&t.forEach(function(n,r){o.set(r,e(n,i,s,r,t,a))});var A=h?c?iE:tR:c?il:eb,L=u?void 0:A(t);return C(L||t,function(n,r){L&&(n=t[r=n]),ii(o,r,e(n,i,s,r,t,a))}),o},iB=function(e){return iF(e,4)};function iK(e){function t(){}t.prototype=e;let i=new t;function s(){return typeof i.bar}return s(),s(),e}var ij=function(e,t,i){var s=-1,n=e.length;t<0&&(t=-t>n?0:n+t),(i=i>n?n:i)<0&&(i+=n),n=t>i?0:i-t>>>0,t>>>=0;for(var r=Array(n);++s<n;)r[s]=e[s+t];return r},iG=/\s/,iW=function(e){for(var t=e.length;t--&&iG.test(e.charAt(t)););return t},iz=/^\s+/,iV=/^[-+]0x[0-9a-f]+$/i,iH=/^0b[01]+$/i,iY=/^0o[0-7]+$/i,iX=parseInt,iJ=function(e){if("number"==typeof e)return e;if(tF(e))return 0/0;if(eL(e)){var t,i="function"==typeof e.valueOf?e.valueOf():e;e=eL(i)?i+"":i}if("string"!=typeof e)return 0===e?e:+e;e=(t=e)?t.slice(0,iW(t)+1).replace(iz,""):t;var s=iH.test(e);return s||iY.test(e)?iX(e.slice(2),s?2:8):iV.test(e)?0/0:+e},iq=function(e){var t,i=(t=e)?1/0===(t=iJ(t))||-1/0===t?(t<0?-1:1)*17976931348623157e292:t==t?t:0:0===t?t:0,s=i%1;return i==i?s?i-s:i:0},iZ=function(e,t,i){var s=null==e?0:e.length;return s?ij(e,(t=i||void 0===t?1:iq(t))<0?0:t,s):[]},iQ=function(e){return"string"==typeof e||!q(e)&&z(e)&&"[object String]"==W(e)},i0=function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)},i1=Math.max,i2=Date.now,i3=(o=t7?function(e,t){return t7(e,"toString",{configurable:!0,enumerable:!1,value:function(){return t},writable:!0})}:ek,l=0,c=0,function(){var e=i2(),t=16-(e-c);if(c=e,t>0){if(++l>=800)return arguments[0]}else l=0;return o.apply(void 0,arguments)}),i6=function(e,t){var i;return i3((i=i1(void 0===(i=t)?e.length-1:i,0),function(){for(var t=arguments,s=-1,n=i1(t.length-i,0),r=Array(n);++s<n;)r[s]=t[i+s];s=-1;for(var a=Array(i+1);++s<i;)a[s]=t[s];return a[i]=ek(r),i0(e,this,a)}),e+"")},i5=function(e,t,i){if(!eL(i))return!1;var s=typeof t;return("number"==s?!!(eO(i)&&es(t,i.length)):"string"==s&&t in i)&&e4(i[t],e)},i4=Object.prototype.hasOwnProperty,i8=(h=function(e,t){if(eT(t)||eO(t))return void is(t,eb(t),e);for(var i in t)i4.call(t,i)&&ii(e,i,t[i])},i6(function(e,t){var i=-1,s=t.length,n=s>1?t[s-1]:void 0,r=s>2?t[2]:void 0;for(n=h.length>3&&"function"==typeof n?(s--,n):void 0,r&&i5(t[0],t[1],r)&&(n=s<3?void 0:n,s=1),e=Object(e);++i<s;){var a=t[i];a&&h(e,a)}return e})),i9=function(e,t,i,s){if(!eL(e))return e;t=tJ(t,e);for(var n=-1,r=t.length,a=r-1,o=e;null!=o&&++n<r;){var l=tq(t[n]),c=i;if("__proto__"===l||"constructor"===l||"prototype"===l)break;if(n!=a){var h=o[l];void 0===(c=s?s(h,l,o):void 0)&&(c=eL(h)?h:es(t[n+1])?[]:{})}ii(o,l,c),o=o[l]}return e},i7=function(e,t,i){for(var s=-1,n=t.length,r={};++s<n;){var a=t[s],o=tZ(e,a);i(o,a)&&i9(r,tJ(a,e),o)}return r},se=function(e,t){if(null==e)return{};var i=ev(iE(e),function(e){return[e]});return t=t3(t),i7(e,i,function(e,i){return t(e,i[0])})},st=eh&&eh.isRegExp,si=st?ea(st):function(e){return z(e)&&"[object RegExp]"==W(e)};class ss{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),eN(this.definition,t=>{t.accept(e)})}}class sn extends ss{constructor(e){super([]),this.idx=1,i8(this,se(e,e=>void 0!==e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class sr extends ss{constructor(e){super(e.definition),this.orgText="",i8(this,se(e,e=>void 0!==e))}}class sa extends ss{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,i8(this,se(e,e=>void 0!==e))}}class so extends ss{constructor(e){super(e.definition),this.idx=1,i8(this,se(e,e=>void 0!==e))}}class sl extends ss{constructor(e){super(e.definition),this.idx=1,i8(this,se(e,e=>void 0!==e))}}class sc extends ss{constructor(e){super(e.definition),this.idx=1,i8(this,se(e,e=>void 0!==e))}}class sh extends ss{constructor(e){super(e.definition),this.idx=1,i8(this,se(e,e=>void 0!==e))}}class su extends ss{constructor(e){super(e.definition),this.idx=1,i8(this,se(e,e=>void 0!==e))}}class sd extends ss{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,i8(this,se(e,e=>void 0!==e))}}class sp{constructor(e){this.idx=1,i8(this,se(e,e=>void 0!==e))}accept(e){e.visit(this)}}class sf{visit(e){switch(e.constructor){case sn:return this.visitNonTerminal(e);case sa:return this.visitAlternative(e);case so:return this.visitOption(e);case sl:return this.visitRepetitionMandatory(e);case sc:return this.visitRepetitionMandatoryWithSeparator(e);case su:return this.visitRepetitionWithSeparator(e);case sh:return this.visitRepetition(e);case sd:return this.visitAlternation(e);case sp:return this.visitTerminal(e);case sr:return this.visitRule(e);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){}}var sm=function(e,t){var i;return eR(e,function(e,s,n){return!(i=t(e,s,n))}),!!i},sT=function(e,t,i){var s=q(e)?tc:sm;return i&&i5(e,t,i)&&(t=void 0),s(e,t3(t))},sg=function(e,t,i,s){for(var n=e.length,r=i+(s?1:-1);s?r--:++r<n;)if(t(e[r],r,e))return r;return -1},sE=function(e){return e!=e},sy=function(e,t,i){for(var s=i-1,n=e.length;++s<n;)if(e[s]===t)return s;return -1},sA=function(e,t,i){return t==t?sy(e,t,i):sg(e,sE,i)},sL=Math.max,sS=function(e,t,i,s){e=eO(e)?e:eI(e),i=i&&!s?iq(i):0;var n=e.length;return i<0&&(i=sL(n+i,0)),iQ(e)?i<=n&&e.indexOf(t,i)>-1:!!n&&sA(e,t,i)>-1},sO=function(e,t){for(var i=-1,s=null==e?0:e.length;++i<s;)if(!t(e[i],i,e))return!1;return!0},sb=function(e,t){var i=!0;return eR(e,function(e,s,n){return i=!!t(e,s,n)}),i},sR=function(e,t,i){var s=q(e)?sO:sb;return i&&i5(e,t,i)&&(t=void 0),s(e,t3(t))};function sk(e,t=[]){return e instanceof so||e instanceof sh||e instanceof su||(e instanceof sd?sT(e.definition,e=>sk(e,t)):!(e instanceof sn&&sS(t,e))&&e instanceof ss&&(e instanceof sn&&t.push(e),sR(e.definition,e=>sk(e,t))))}function sN(e){if(e instanceof sn)return"SUBRULE";if(e instanceof so)return"OPTION";if(e instanceof sd)return"OR";if(e instanceof sl)return"AT_LEAST_ONE";if(e instanceof sc)return"AT_LEAST_ONE_SEP";else if(e instanceof su)return"MANY_SEP";else if(e instanceof sh)return"MANY";else if(e instanceof sp)return"CONSUME";else throw Error("non exhaustive match")}class sv{walk(e,t=[]){eN(e.definition,(i,s)=>{let n=iZ(e.definition,s+1);if(i instanceof sn)this.walkProdRef(i,n,t);else if(i instanceof sp)this.walkTerminal(i,n,t);else if(i instanceof sa)this.walkFlat(i,n,t);else if(i instanceof so)this.walkOption(i,n,t);else if(i instanceof sl)this.walkAtLeastOne(i,n,t);else if(i instanceof sc)this.walkAtLeastOneSep(i,n,t);else if(i instanceof su)this.walkManySep(i,n,t);else if(i instanceof sh)this.walkMany(i,n,t);else if(i instanceof sd)this.walkOr(i,n,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,i){}walkProdRef(e,t,i){}walkFlat(e,t,i){let s=t.concat(i);this.walk(e,s)}walkOption(e,t,i){let s=t.concat(i);this.walk(e,s)}walkAtLeastOne(e,t,i){let s=[new so({definition:e.definition})].concat(t,i);this.walk(e,s)}walkAtLeastOneSep(e,t,i){let s=sI(e,t,i);this.walk(e,s)}walkMany(e,t,i){let s=[new so({definition:e.definition})].concat(t,i);this.walk(e,s)}walkManySep(e,t,i){let s=sI(e,t,i);this.walk(e,s)}walkOr(e,t,i){let s=t.concat(i);eN(e.definition,e=>{let t=new sa({definition:[e]});this.walk(t,s)})}}function sI(e,t,i){return[new so({definition:[new sp({terminalType:e.separator})].concat(e.definition)})].concat(t,i)}var sC=function(e,t){return!!(null==e?0:e.length)&&sA(e,t,0)>-1},s_=function(e,t,i){for(var s=-1,n=null==e?0:e.length;++s<n;)if(i(t,e[s]))return!0;return!1},sx=function(){},sU=eW&&1/tf(new eW([,-0]))[1]==1/0?function(e){return new eW(e)}:sx,sM=function(e,t,i){var s=-1,n=sC,r=e.length,a=!0,o=[],l=o;if(i)a=!1,n=s_;else if(r>=200){var c=t?null:sU(e);if(c)return tf(c);a=!1,n=th,l=new tl}else l=t?[]:o;e:for(;++s<r;){var h=e[s],u=t?t(h):h;if(h=i||0!==h?h:0,a&&u==u){for(var d=l.length;d--;)if(l[d]===u)continue e;t&&l.push(u),o.push(h)}else n(l,u,i)||(l!==o&&l.push(u),o.push(h))}return o},sw=function(e){return e&&e.length?sM(e):[]},sP=P?P.isConcatSpreadable:void 0,sD=function(e){return q(e)||J(e)||!!(sP&&e&&e[sP])},s$=function e(t,i,s,n,r){var a=-1,o=t.length;for(s||(s=sD),r||(r=[]);++a<o;){var l=t[a];i>0&&s(l)?i>1?e(l,i-1,s,n,r):tE(r,l):n||(r[r.length]=l)}return r},sF=function(e){return(null==e?0:e.length)?s$(e,1):[]};function sB(e){if(e instanceof sn)return sB(e.referencedRule);if(e instanceof sp)return[e.terminalType];if(e instanceof sa||e instanceof so||e instanceof sh||e instanceof sl||e instanceof sc||e instanceof su||e instanceof sp||e instanceof sr)return function(e){let t,i=[],s=e.definition,n=0,r=s.length>n,a=!0;for(;r&&a;)a=sk(t=s[n]),i=i.concat(sB(t)),n+=1,r=s.length>n;return sw(i)}(e);if(e instanceof sd)return sw(sF(t5(e.definition,e=>sB(e))));throw Error("non exhaustive match")}class sK extends sv{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,i){}walkProdRef(e,t,i){var s,n;let r=(s=e.referencedRule,n=e.idx,s.name+n+"_~IN~_"+this.topProd.name),a=sB(new sa({definition:t.concat(i)}));this.follows[r]=a}}var sj=function(e){return void 0===e};function sG(e){return e.charCodeAt(0)}function sW(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function sz(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function sV(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function sH(){throw Error("Internal Error - Should never get here!")}function sY(e){return"Character"===e.type}let sX=[];for(let e=sG("0");e<=sG("9");e++)sX.push(e);let sJ=[sG("_")].concat(sX);for(let e=sG("a");e<=sG("z");e++)sJ.push(e);for(let e=sG("A");e<=sG("Z");e++)sJ.push(e);let sq=[sG(" "),sG("\f"),sG("\n"),sG("\r"),sG(" "),sG("\v"),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG(" "),sG("\u2028"),sG("\u2029"),sG(" "),sG(" "),sG(" "),sG("\uFEFF")],sZ=/[0-9a-fA-F]/,sQ=/[0-9]/,s0=/[1-9]/;class s1{visitChildren(e){for(let t in e){let i=e[t];e.hasOwnProperty(t)&&(void 0!==i.type?this.visit(i):Array.isArray(i)&&i.forEach(e=>{this.visit(e)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}var s2=Object.prototype,s3=s2.hasOwnProperty,s6=i6(function(e,t){e=Object(e);var i=-1,s=t.length,n=s>2?t[2]:void 0;for(n&&i5(t[0],t[1],n)&&(s=1);++i<s;)for(var r=t[i],a=il(r),o=-1,l=a.length;++o<l;){var c=a[o],h=e[c];(void 0===h||e4(h,s2[c])&&!s3.call(e,c))&&(e[c]=r[c])}return e}),s5=function(e,t){var i=[];return eR(e,function(e,s,n){t(e,s,n)&&i.push(e)}),i},s4=function(e){if("function"!=typeof e)throw TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}},s8=function(e,t){return(q(e)?tA:s5)(e,s4(t3(t)))},s9=Math.max,s7=function(e,t,i){var s=null==e?0:e.length;if(!s)return -1;var n=null==i?0:iq(i);return n<0&&(n=s9(s+n,0)),sA(e,t,n)},ne=function(e,t,i,s){var n=-1,r=null==e?0:e.length;for(s&&r&&(i=e[++n]);++n<r;)i=t(i,e[n],n,e);return i},nt=function(e,t,i,s,n){return n(e,function(e,n,r){i=s?(s=!1,e):t(i,e,n,r)}),i},ni=function(e,t,i){var s=q(e)?ne:nt,n=arguments.length<3;return s(e,t3(t),i,n,eR)},ns=function(e,t){return(q(e)?tA:s5)(e,t3(t))},nn=function(e,t,i,s){var n=-1,r=sC,a=!0,o=e.length,l=[],c=t.length;if(!o)return l;i&&(t=ev(t,ea(i))),s?(r=s_,a=!1):t.length>=200&&(r=th,a=!1,t=new tl(t));e:for(;++n<o;){var h=e[n],u=null==i?h:i(h);if(h=s||0!==h?h:0,a&&u==u){for(var d=c;d--;)if(t[d]===u)continue e;l.push(h)}else r(t,u,s)||l.push(h)}return l},nr=function(e){return z(e)&&eO(e)},na=i6(function(e,t){return nr(e)?nn(e,s$(t,1,nr,!0)):[]}),no=function(e){for(var t=-1,i=null==e?0:e.length,s=0,n=[];++t<i;){var r=e[t];r&&(n[s++]=r)}return n},nl=function(e){return e&&e.length?e[0]:void 0},nc=Math.max,nh=(u=function(e,t,i){var s=null==e?0:e.length;if(!s)return -1;var n=null==i?0:iq(i);return n<0&&(n=nc(s+n,0)),sg(e,t3(t),n)},function(e,t,i){var s=Object(e);if(!eO(e)){var n=t3(t);e=eb(e),t=function(e){return n(s[e],e,s)}}var r=u(e,t,i);return r>-1?s[n?e[r]:r]:void 0});function nu(e){console&&console.error&&console.error(`Error: ${e}`)}function nd(e){console&&console.warn&&console.warn(`Warning: ${e}`)}let np={},nf=new class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let i={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":sz(i,"global");break;case"i":sz(i,"ignoreCase");break;case"m":sz(i,"multiLine");break;case"u":sz(i,"unicode");break;case"y":sz(i,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:i,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}}sV(t);let i=this.disjunction();return this.consumeChar(")"),{type:t,value:i,loc:this.loc(e)}}return sH()}quantifier(e=!1){let t,i=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let s=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:s,atMost:s};break;case",":t=this.isDigit()?{atLeast:s,atMost:this.integerIncludingZero()}:{atLeast:s,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;sV(t)}if((!0!==e||void 0!==t)&&sV(t))return"?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(i),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),sV(e))?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):sH()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[sG("\n"),sG("\r"),sG("\u2028"),sG("\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=sX;break;case"D":e=sX,t=!0;break;case"s":e=sq;break;case"S":e=sq,t=!0;break;case"w":e=sJ;break;case"W":e=sJ,t=!0}return sV(e)?{type:"Set",value:e,complement:t}:sH()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=sG("\f");break;case"n":e=sG("\n");break;case"r":e=sG("\r");break;case"t":e=sG(" ");break;case"v":e=sG("\v")}return sV(e)?{type:"Character",value:e}:sH()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:sG("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:sG(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:sG(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,sY(t)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom();if(i.type,sY(i)){if(i.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:i.value})}else sW(t.value,e),e.push(sG("-")),sW(i.value,e)}else sW(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:sG("\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++;let t=this.disjunction();this.consumeChar(")");let i={type:"Group",capturing:e,value:t};return e&&(i.idx=this.groupIdx),i}positiveInteger(){let e=this.popChar();if(!1===s0.test(e))throw Error("Expecting a positive integer");for(;sQ.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===sQ.test(e))throw Error("Expecting an integer");for(;sQ.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:sG(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 sQ.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2)||"<"===this.peekChar(2)&&("="===this.peekChar(3)||"!"===this.peekChar(3)));default:return!1}}isQuantifier(){let e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let i=0;i<e;i++){let e=this.popChar();if(!1===sZ.test(e))throw Error("Expecting a HexDecimal digits");t+=e}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};function nm(e){let t=e.toString();if(np.hasOwnProperty(t))return np[t];{let e=nf.pattern(t);return np[t]=e,e}}let nT="Complement Sets are not supported for first char optimization",ng='Unable to use "first char" lexer optimizations:\n';function nE(e,t,i){let s=nw(e);t[s]=s,!0===i&&function(e,t){let i=String.fromCharCode(e),s=i.toUpperCase();if(s!==i){let e=nw(s.charCodeAt(0));t[e]=e}else{let e=i.toLowerCase();if(e!==i){let i=nw(e.charCodeAt(0));t[i]=i}}}(e,t)}function ny(e,t){return nh(e.value,e=>"number"==typeof e?sS(t,e):void 0!==nh(t,t=>e.from<=t&&t<=e.to))}class nA extends s1{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){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){sS(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===ny(e,this.targetCharCodes)&&(this.found=!0):void 0!==ny(e,this.targetCharCodes)&&(this.found=!0)}}function nL(e,t){if(!(t instanceof RegExp))return void 0!==nh(t,t=>sS(e,t.charCodeAt(0)));{let i=nm(t),s=new nA(e);return s.visit(i),s.found}}let nS="PATTERN",nO="defaultMode",nb="modes",nR=/[^\\][$]/,nk=/[^\\[][\^]|^\^/;function nN(e){let t=e.ignoreCase?"iy":"y";return RegExp(`${e.source}`,t)}function nv(e){let t=e.PATTERN;if(si(t))return!1;if(eS(t))return!0;if(t9(t,"exec"))return!0;if(iQ(t))return!1;throw Error("non exhaustive match")}function nI(e){return!!iQ(e)&&1===e.length&&e.charCodeAt(0)}let nC={test:function(e){let t=e.length;for(let i=this.lastIndex;i<t;i++){let t=e.charCodeAt(i);if(10===t)return this.lastIndex=i+1,!0;if(13===t)return 10===e.charCodeAt(i+1)?this.lastIndex=i+2:this.lastIndex=i+1,!0}return!1},lastIndex:0};function n_(e,t){if(t9(e,"LINE_BREAKS"))return!1;if(si(e.PATTERN)){try{nL(t,e.PATTERN)}catch(e){return{issue:g.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(iQ(e.PATTERN))return!1;if(nv(e))return{issue:g.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function nx(e){return t5(e,e=>iQ(e)?e.charCodeAt(0):e)}function nU(e,t,i){void 0===e[t]?e[t]=[i]:e[t].push(i)}let nM=[];function nw(e){return e<256?e:nM[e]}var nP=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};function nD(e){let t=new Date().getTime(),i=e();return{time:new Date().getTime()-t,value:i}}function n$(e,t){let i=e.tokenTypeIdx;return i===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[i]}function nF(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let nB=1,nK={};function nj(e){let t=function(e){let t=iB(e),i=e,s=!0;for(;s;){let e=na(i=no(sF(t5(i,e=>e.CATEGORIES))),t);t=t.concat(e),e5(e)?s=!1:i=e}return t}(e);eN(t,e=>{nG(e)||(nK[nB]=e,e.tokenTypeIdx=nB++),nW(e)&&!q(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),nW(e)||(e.CATEGORIES=[]),t9(e,"categoryMatches")||(e.categoryMatches=[]),t9(e,"categoryMatchesMap")||(e.categoryMatchesMap={})}),eN(t,e=>{!function e(t,i){eN(t,e=>{i.categoryMatchesMap[e.tokenTypeIdx]=!0}),eN(i.CATEGORIES,s=>{let n=t.concat(i);sS(n,s)||e(n,s)})}([],e)}),eN(t,e=>{e.categoryMatches=[],eN(e.categoryMatchesMap,(t,i)=>{e.categoryMatches.push(nK[i].tokenTypeIdx)})}),eN(t,e=>{e.isParent=e.categoryMatches.length>0})}function nG(e){return t9(e,"tokenTypeIdx")}function nW(e){return t9(e,"CATEGORIES")}function nz(e){return t9(e,"tokenTypeIdx")}(d=g||(g={}))[d.MISSING_PATTERN=0]="MISSING_PATTERN",d[d.INVALID_PATTERN=1]="INVALID_PATTERN",d[d.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",d[d.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",d[d.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",d[d.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",d[d.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",d[d.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",d[d.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",d[d.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",d[d.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",d[d.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",d[d.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",d[d.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",d[d.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",d[d.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",d[d.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",d[d.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";let nV={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:{buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,i,s,n,r)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${i} characters.`},traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(nV);class nH{constructor(e,t=nV){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let i=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${i}--\x3e <${e}>`);let{time:s,value:n}=nD(t),r=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&r(`${i}<-- <${e}> time: ${s}ms`),this.traceInitIndent--,n}},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=i8({},nV,t);let i=this.config.traceInitPerf;!0===i?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof i&&(this.traceInitMaxIdent=i,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,s=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===nV.lineTerminatorsPattern)this.config.lineTerminatorsPattern=nC;else if(this.config.lineTerminatorCharacters===nV.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n 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),q(e)?i={modes:{defaultMode:iB(e)},defaultMode:nO}:(s=!1,i=iB(e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{var e;let t;this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat((e=i,this.trackStartLines,this.config.lineTerminatorCharacters,t=[],t9(e,nO)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+nO+"> property in its definition\n",type:g.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),t9(e,nb)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+nb+"> property in its definition\n",type:g.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),t9(e,nb)&&t9(e,nO)&&!t9(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${nO}: <${e.defaultMode}>which does not exist
2
- `,type:g.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),t9(e,nb)&&eN(e.modes,(e,i)=>{eN(e,(s,n)=>{sj(s)?t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${i}> at index: <${n}>
3
- `,type:g.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):t9(s,"LONGER_ALT")&&eN(q(s.LONGER_ALT)?s.LONGER_ALT:[s.LONGER_ALT],n=>{sj(n)||sS(e,n)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${n.name}> on token <${s.name}> outside of mode <${i}>
4
- `,type:g.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),t))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{var e,t,s;let n,r,a,o;this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat((e=i,t=this.trackStartLines,s=this.config.lineTerminatorCharacters,n=[],r=!1,a=s8(no(sF(eI(e.modes))),e=>e[nS]===nH.NA),o=nx(s),t&&eN(a,e=>{let t=n_(e,o);if(!1!==t){let i={message:function(e,t){if(t.issue===g.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
5
- The problem is in the <${e.name}> Token Type
6
- Root cause: ${t.errMsg}.
7
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===g.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
8
- The problem is in the <${e.name}> Token Type
9
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),type:t.issue,tokenType:e};n.push(i)}else t9(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(r=!0):nL(o,e.PATTERN)&&(r=!0)}),t&&!r&&n.push({message:"Warning: No LINE_BREAKS Found.\n This Lexer has been defined to track line and column information,\n But none of the Token Types can be identified as matching a line terminator.\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n for details.",type:g.NO_LINE_BREAKS_FLAGS}),n))})),i.modes=i.modes?i.modes:{},eN(i.modes,(e,t)=>{i.modes[t]=s8(e,e=>sj(e))});let n=eb(i.modes);if(eN(i.modes,(e,i)=>{this.TRACE_INIT(`Mode: <${i}> processing`,()=>{if(this.modes.push(i),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{var t,i,s,r,a,o;let l,c,h,u,d,p,f,m,T,E,y,A;this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat((l=[],c={errors:t5(d=ns(t=e,e=>!t9(e,nS)),e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:g.MISSING_PATTERN,tokenTypes:[e]})),valid:na(t,d)},l=l.concat(c.errors),u=(h={errors:t5(p=ns(i=c.valid,e=>{let t=e[nS];return!si(t)&&!eS(t)&&!t9(t,"exec")&&!iQ(t)}),e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:g.INVALID_PATTERN,tokenTypes:[e]})),valid:na(i,p)}).valid,l=(l=(l=(l=(l=l.concat(h.errors)).concat((f=[],m=ns(u,e=>si(e[nS])),(f=(f=(f=(f=f.concat(function(e){class t extends s1{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return t5(ns(e,e=>{let i=e.PATTERN;try{let e=nm(i),s=new t;return s.visit(e),s.found}catch(e){return nR.test(i.source)}}),e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:g.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}(m))).concat(function(e){class t extends s1{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return t5(ns(e,e=>{let i=e.PATTERN;try{let e=nm(i),s=new t;return s.visit(e),s.found}catch(e){return nk.test(i.source)}}),e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:g.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}(m))).concat(t5(ns(m,e=>{let t=e[nS];return t instanceof RegExp&&(t.multiline||t.global)}),e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:g.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]})))).concat((T=[],E=t5(s=m,e=>ni(s,(t,i)=>(e.PATTERN.source!==i.PATTERN.source||sS(T,i)||i.PATTERN===nH.NA||(T.push(i),t.push(i)),t),[])),t5(ns(E=no(E),e=>e.length>1),e=>{let t=t5(e,e=>e.name),i=nl(e).PATTERN;return{message:`The same RegExp pattern ->${i}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:g.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})))).concat(t5(ns(m,e=>e.PATTERN.test("")),e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:g.EMPTY_MATCH_PATTERN,tokenTypes:[e]})))))).concat(t5(ns(u,e=>{if(!t9(e,"GROUP"))return!1;let t=e.GROUP;return t!==nH.SKIPPED&&t!==nH.NA&&!iQ(t)}),e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:g.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]})))).concat((r=u,a=n,t5(ns(r,e=>void 0!==e.PUSH_MODE&&!sS(a,e.PUSH_MODE)),e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:g.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))))).concat((y=[],A=ni(o=u,(e,t,i)=>{var s;let n=t.PATTERN;return n===nH.NA||(iQ(n)?e.push({str:n,idx:i,tokenType:t}):si(n)&&(s=n,void 0===nh([".","\\","[","]","|","^","$","(",")","?","*","+","{"],e=>-1!==s.source.indexOf(e)))&&e.push({str:n.source,idx:i,tokenType:t})),e},[]),eN(o,(e,t)=>{eN(A,({str:i,idx:s,tokenType:n})=>{if(t<s&&function(e,t){if(si(t)){var i;if(i=t,/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(i.source))return!1;let s=t.exec(e);return null!==s&&0===s.index}if(eS(t))return t(e,0,[],{});if(t9(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(i,e.PATTERN)){let t=`Token: ->${n.name}<- can never be matched.
10
- Because it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.
11
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;y.push({message:t,type:g.UNREACHABLE_PATTERN,tokenTypes:[e,n]})}})}),y))))}),e5(this.lexerDefinitionErrors)){let s;nj(e),this.TRACE_INIT("analyzeTokenTypes",()=>{var i;let n,r,a,o,l,c,h,u,d,p,f,m,T,g,E,y;(T=(i=s6(i={lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT},{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer)("initCharCodeToOptimizedIndexMap",()=>{if(e5(nM)){nM=Array(65536);for(let e=0;e<65536;e++)nM[e]=e>255?255+~~(e/255):e}}),T("Reject Lexer.NA",()=>{n=s8(e,e=>e[nS]===nH.NA)}),g=!1,T("Transform Patterns",()=>{g=!1,r=t5(n,e=>{let t=e[nS];if(si(t)){let e=t.source;return 1!==e.length||"^"===e||"$"===e||"."===e||t.ignoreCase?2!==e.length||"\\"!==e[0]||sS(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?nN(t):e[1]:e}if(eS(t))return g=!0,{exec:t};if("object"==typeof t)return g=!0,t;if("string"==typeof t)if(1===t.length)return t;else return nN(new RegExp(t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")));throw Error("non exhaustive match")})}),T("misc mapping",()=>{a=t5(n,e=>e.tokenTypeIdx),o=t5(n,e=>{let t=e.GROUP;if(t!==nH.SKIPPED){if(iQ(t))return t;if(sj(t))return!1;throw Error("non exhaustive match")}}),l=t5(n,e=>{let t=e.LONGER_ALT;if(t)return q(t)?t5(t,e=>s7(n,e)):[s7(n,t)]}),c=t5(n,e=>e.PUSH_MODE),h=t5(n,e=>t9(e,"POP_MODE"))}),T("Line Terminator Handling",()=>{let e=nx(i.lineTerminatorCharacters);u=t5(n,e=>!1),"onlyOffset"!==i.positionTracking&&(u=t5(n,t=>t9(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===n_(t,e)&&nL(e,t.PATTERN)))}),T("Misc Mapping #2",()=>{d=t5(n,nv),p=t5(r,nI),f=ni(n,(e,t)=>{let i=t.GROUP;return iQ(i)&&i!==nH.SKIPPED&&(e[i]=[]),e},{}),m=t5(r,(e,t)=>({pattern:r[t],longerAlt:l[t],canLineTerminator:u[t],isCustom:d[t],short:p[t],group:o[t],push:c[t],pop:h[t],tokenTypeIdx:a[t],tokenType:n[t]}))}),E=!0,y=[],i.safeMode||T("First Char Optimization",()=>{y=ni(n,(e,t,s)=>{if("string"==typeof t.PATTERN)nU(e,nw(t.PATTERN.charCodeAt(0)),m[s]);else if(q(t.START_CHARS_HINT)){let i;eN(t.START_CHARS_HINT,t=>{let n=nw("string"==typeof t?t.charCodeAt(0):t);i!==n&&(i=n,nU(e,n,m[s]))})}else if(si(t.PATTERN))if(t.PATTERN.unicode)E=!1,i.ensureOptimizations&&nu(`${ng} Unable to analyze < ${t.PATTERN.toString()} > pattern.
12
- The regexp unicode flag is not currently supported by the regexp-to-ast library.
13
- This will disable the lexer's first char optimizations.
14
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let n=function(e,t=!1){try{let t=nm(e);return function e(t,i,s){switch(t.type){case"Disjunction":for(let n=0;n<t.value.length;n++)e(t.value[n],i,s);break;case"Alternative":let n=t.value;for(let t=0;t<n.length;t++){let r=n[t];switch(r.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}switch(r.type){case"Character":nE(r.value,i,s);break;case"Set":if(!0===r.complement)throw Error(nT);eN(r.value,e=>{if("number"==typeof e)nE(e,i,s);else if(!0===s)for(let t=e.from;t<=e.to;t++)nE(t,i,s);else{for(let t=e.from;t<=e.to&&t<256;t++)nE(t,i,s);if(e.to>=256){let t=e.from>=256?e.from:256,s=e.to,n=nw(t),r=nw(s);for(let e=n;e<=r;e++)i[e]=e}}});break;case"Group":e(r.value,i,s);break;default:throw Error("Non Exhaustive Match")}let a=void 0!==r.quantifier&&0===r.quantifier.atLeast;if("Group"===r.type&&!1===function e(t){let i=t.quantifier;return!!i&&0===i.atLeast||!!t.value&&(q(t.value)?sR(t.value,e):e(t.value))}(r)||"Group"!==r.type&&!1===a)break}break;default:throw Error("non exhaustive match!")}return eI(i)}(t.value,{},t.flags.ignoreCase)}catch(i){if(i.message===nT)t&&nd(`${ng} Unable to optimize: < ${e.toString()} >
15
- Complement Sets cannot be automatically optimized.
16
- This will disable the lexer's first char optimizations.
17
- See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let i="";t&&(i="\n This will disable the lexer's first char optimizations.\n See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),nu(`${ng}
18
- Failed parsing: < ${e.toString()} >
19
- Using the @chevrotain/regexp-to-ast library
20
- Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+i)}}return[]}(t.PATTERN,i.ensureOptimizations);e5(n)&&(E=!1),eN(n,t=>{nU(e,t,m[s])})}else i.ensureOptimizations&&nu(`${ng} TokenType: <${t.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
21
- This will disable the lexer's first char optimizations.
22
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return e},[])}),s={emptyGroups:f,patternIdxToConfig:m,charCodeToPatternIdxToConfig:y,hasCustom:g,canBeOptimized:E}}),this.patternIdxToConfig[i]=s.patternIdxToConfig,this.charCodeToPatternIdxToConfig[i]=s.charCodeToPatternIdxToConfig,this.emptyGroups=i8({},this.emptyGroups,s.emptyGroups),this.hasCustom=s.hasCustom||this.hasCustom,this.canModeBeOptimized[i]=s.canBeOptimized}})}),this.defaultMode=i.defaultMode,!e5(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling)throw Error("Errors detected in definition of Lexer:\n"+t5(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n"));eN(this.lexerDefinitionWarning,e=>{nd(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(s&&(this.handleModes=sx),!1===this.trackStartLines&&(this.computeNewColumn=ek),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=sx),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let e=ni(this.canModeBeOptimized,(e,t,i)=>(!1===t&&e.push(i),e),[]);if(t.ensureOptimizations&&!e5(e))throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.
23
- Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
24
- Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{np={}}),this.TRACE_INIT("toFastProperties",()=>{iK(this)})})}tokenize(e,t=this.defaultMode){if(!e5(this.lexerDefinitionErrors))throw Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+t5(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n"));return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){var i;let s,n,r,a,o,l,c,h,u,d,p,f,m,T,g,E,y,A=e.length,L=0,S=0,O=Array(this.hasCustom?0:Math.floor(e.length/10)),b=[],R=this.trackStartLines?1:void 0,k=this.trackStartLines?1:void 0,N=(i=this.emptyGroups,y={},eN(eb(i),e=>{if(q(i[e]))y[e]=[];else throw Error("non exhaustive match")}),y),v=this.trackStartLines,I=this.config.lineTerminatorsPattern,C=0,_=[],x=[],U=[],M=[];Object.freeze(M);let w=!1,P=e=>{if(1===U.length&&void 0===e.tokenType.PUSH_MODE){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);b.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{U.pop();let e=nP(U);_=this.patternIdxToConfig[e],x=this.charCodeToPatternIdxToConfig[e],C=_.length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;w=!!x&&!!t}};function D(e){U.push(e),x=this.charCodeToPatternIdxToConfig[e],C=(_=this.patternIdxToConfig[e]).length,C=_.length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;w=!!x&&!!t}D.call(this,t);let $=this.config.recoveryEnabled;for(;L<A;){let t;l=null,u=-1;let i=e.charCodeAt(L);if(w){let e=x[nw(i)];t=void 0!==e?e:M}else t=_;let y=t.length;for(s=0;s<y;s++){let n=(E=t[s]).pattern;c=null;let d=E.short;if(!1!==d?i===d&&(u=1,l=n):!0===E.isCustom?null!==(g=n.exec(e,L,O,N))?(u=(l=g[0]).length,void 0!==g.payload&&(c=g.payload)):l=null:(n.lastIndex=L,u=this.matchLength(n,e,L)),-1!==u){if(void 0!==(o=E.longerAlt)){l=e.substring(L,L+u);let t=o.length;for(r=0;r<t;r++){let t=_[o[r]],i=t.pattern;if(h=null,!0===t.isCustom?null!==(g=i.exec(e,L,O,N))?(a=g[0],void 0!==g.payload&&(h=g.payload)):a=null:(i.lastIndex=L,a=this.match(i,e,L)),a&&a.length>l.length){l=a,u=a.length,c=h,E=t;break}}}break}}if(-1!==u){if(void 0!==(d=E.group)&&(l=null!==l?l:e.substring(L,L+u),p=E.tokenTypeIdx,f=this.createTokenInstance(l,L,p,E.tokenType,R,k,u),this.handlePayload(f,c),!1===d?S=this.addToken(O,S,f):N[d].push(f)),!0===v&&!0===E.canLineTerminator){let t,i,s=0;I.lastIndex=0;do l=null!==l?l:e.substring(L,L+u),!0===(t=I.test(l))&&(i=I.lastIndex-1,s++);while(!0===t)0!==s?(R+=s,k=u-i,this.updateTokenEndLineColumnLocation(f,d,i,s,R,k,u)):k=this.computeNewColumn(k,u)}else k=this.computeNewColumn(k,u);L+=u,this.handleModes(E,P,D,f)}else{let t=L,i=R,s=k,r=!1===$;for(;!1===r&&L<A;)for(L++,n=0;n<C;n++){let t=_[n],i=t.pattern,s=t.short;if(!1!==s?e.charCodeAt(L)===s&&(r=!0):!0===t.isCustom?r=null!==i.exec(e,L,O,N):(i.lastIndex=L,r=null!==i.exec(e)),!0===r)break}if(m=L-t,k=this.computeNewColumn(k,m),T=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(e,t,m,i,s,nP(U)),b.push({offset:t,line:i,column:s,length:m,message:T}),!1===$)break}}return this.hasCustom||(O.length=S),{tokens:O,groups:N,errors:b}}handleModes(e,t,i,s){if(!0===e.pop){let n=e.push;t(s),void 0!==n&&i.call(this,n)}else void 0!==e.push&&i.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,i,s,n,r,a){let o,l;void 0!==t&&(l=(o=i===a-1)?-1:0,(1!==s||!0!==o)&&(e.endLine=n+l,e.endColumn=r-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,i,s){return{image:e,startOffset:t,tokenTypeIdx:i,tokenType:s}}createStartOnlyToken(e,t,i,s,n,r){return{image:e,startOffset:t,startLine:n,startColumn:r,tokenTypeIdx:i,tokenType:s}}createFullToken(e,t,i,s,n,r,a){return{image:e,startOffset:t,endOffset:t+a-1,startLine:n,endLine:n,startColumn:r,endColumn:r+a-1,tokenTypeIdx:i,tokenType:s}}addTokenUsingPush(e,t,i){return e.push(i),t}addTokenUsingMemberAccess(e,t,i){return e[t]=i,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}match(e,t,i){return!0===e.test(t)?t.substring(i,e.lastIndex):null}matchLength(e,t,i){return!0===e.test(t)?e.lastIndex-i:-1}}function nY(e){return nX(e)?e.LABEL:e.name}function nX(e){return iQ(e.LABEL)&&""!==e.LABEL}nH.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.",nH.NA=/NOT_APPLICABLE/;let nJ="categories",nq="label",nZ="group",nQ="push_mode",n0="pop_mode",n1="longer_alt",n2="line_breaks",n3="start_chars_hint";function n6(e){let t=e.pattern,i={};if(i.name=e.name,sj(t)||(i.PATTERN=t),t9(e,"parent"))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";return t9(e,nJ)&&(i.CATEGORIES=e[nJ]),nj([i]),t9(e,nq)&&(i.LABEL=e[nq]),t9(e,nZ)&&(i.GROUP=e[nZ]),t9(e,n0)&&(i.POP_MODE=e[n0]),t9(e,nQ)&&(i.PUSH_MODE=e[nQ]),t9(e,n1)&&(i.LONGER_ALT=e[n1]),t9(e,n2)&&(i.LINE_BREAKS=e[n2]),t9(e,n3)&&(i.START_CHARS_HINT=e[n3]),i}let n5=n6({name:"EOF",pattern:nH.NA});function n4(e,t,i,s,n,r,a,o){return{image:t,startOffset:i,endOffset:s,startLine:n,endLine:r,startColumn:a,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}nj([n5]);let n8={buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:s}){let n=nX(e)?`--\x3e ${nY(e)} <--`:`token of type --\x3e ${e.name} <--`;return`Expecting ${n} but found --\x3e '${t.image}' <--`},buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:i,customUserDescription:s,ruleName:n}){let r="Expecting: ",a="\nbut found: '"+nl(t).image+"'";if(s)return r+s+a;{let t=t5(ni(e,(e,t)=>e.concat(t),[]),e=>`[${t5(e,e=>nY(e)).join(", ")}]`),i=t5(t,(e,t)=>` ${t+1}. ${e}`);return r+`one of these possible Token sequences:
25
- ${i.join("\n")}`+a}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:i,ruleName:s}){let n="Expecting: ",r="\nbut found: '"+nl(t).image+"'";if(i)return n+i+r;{let t=t5(e,e=>`[${t5(e,e=>nY(e)).join(",")}]`);return n+`expecting at least one iteration which starts with one of these possible Token sequences::
26
- <${t.join(" ,")}>`+r}}};Object.freeze(n8);let n9={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},n7={buildDuplicateFoundError(e,t){let i=e.name,s=nl(t),n=s.idx,r=sN(s),a=s instanceof sp?s.terminalType.name:s instanceof sn?s.nonTerminalName:"",o=`->${r}${n>0?n:""}<- ${a?`with argument: ->${a}<-`:""}
27
- appears more than once (${t.length} times) in the top level rule: ->${i}<-.
28
- For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
29
- `;return(o=o.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.
30
- The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
31
- To resolve this make sure each Terminal and Non-Terminal names are unique
32
- This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
33
- and Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){let t=t5(e.prefixPath,e=>nY(e)).join(", "),i=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
34
- in <OR${i}> inside <${e.topLevelRule.name}> Rule,
35
- <${t}> may appears as a prefix path in all these alternatives.
36
- See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
37
- For Further details.`},buildAlternationAmbiguityError(e){let t=0===e.alternation.idx?"":e.alternation.idx,i=0===e.prefixPath.length,s=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,
38
- `;if(i)s+=`These alternatives are all empty (match no tokens), making them indistinguishable.
39
- Only the last alternative may be empty.
40
- `;else{let t=t5(e.prefixPath,e=>nY(e)).join(", ");s+=`<${t}> may appears as a prefix path in all these alternatives.
41
- `}return s+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
42
- For Further details.`},buildEmptyRepetitionError(e){let t=sN(e.repetition);return 0!==e.repetition.idx&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
43
- This could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
44
- Only the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:
45
- <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
46
- has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){let t=e.topLevelRule.name,i=t5(e.leftRecursionPath,e=>e.name),s=`${t} --\x3e ${i.concat([t]).join(" --\x3e ")}`;return`Left Recursion found in grammar.
47
- rule: <${t}> can be invoked from itself (directly or indirectly)
48
- without consuming any Tokens. The grammar path that causes this is:
49
- ${s}
50
- To fix this refactor your grammar to remove the left recursion.
51
- see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof sr?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class re extends sf{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){eN(eI(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:A.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}var rt=function(e,t){return s$(t5(e,t),1)},ri=function(e,t,i,s){for(var n=-1,r=null==e?0:e.length;++n<r;){var a=e[n];t(s,a,i(a),e)}return s},rs=function(e,t,i,s){return eR(e,function(e,n,r){t(s,e,i(e),r)}),s},rn=Object.prototype.hasOwnProperty,rr=(p=function(e,t,i){rn.call(e,i)?e[i].push(t):ie(e,i,[t])},function(e,t){return(q(e)?ri:rs)(e,p,t3(t),{})}),ra=function(e,t,i){var s=null==e?0:e.length;return s?ij(e,0,(t=s-(t=i||void 0===t?1:iq(t)))<0?0:t):[]};class ro extends sv{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=iB(this.path.ruleStack).reverse(),this.occurrenceStack=iB(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,i){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let s=t.concat(i);this.updateExpectedNext(),this.walk(e.referencedRule,s)}}updateExpectedNext(){e5(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class rl 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,i){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new sa({definition:t.concat(i)});this.possibleTokTypes=sB(e),this.found=!0}}}class rc extends sv{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 rh extends rc{walkMany(e,t,i){if(e.idx===this.occurrence){let e=nl(t.concat(i));this.result.isEndOfRule=void 0===e,e instanceof sp&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,i)}}class ru extends rc{walkManySep(e,t,i){if(e.idx===this.occurrence){let e=nl(t.concat(i));this.result.isEndOfRule=void 0===e,e instanceof sp&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,i)}}class rd extends rc{walkAtLeastOne(e,t,i){if(e.idx===this.occurrence){let e=nl(t.concat(i));this.result.isEndOfRule=void 0===e,e instanceof sp&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,i)}}class rp extends rc{walkAtLeastOneSep(e,t,i){if(e.idx===this.occurrence){let e=nl(t.concat(i));this.result.isEndOfRule=void 0===e,e instanceof sp&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,i)}}function rf(e,t,i=[]){i=iB(i);let s=[],n=0;function r(r){let a=rf(r.concat(iZ(e,n+1)),t,i);return s.concat(a)}for(;i.length<t&&n<e.length;){let t=e[n];if(t instanceof sa)return r(t.definition);if(t instanceof sn)return r(t.definition);if(t instanceof so)s=r(t.definition);else if(t instanceof sl)return r(t.definition.concat([new sh({definition:t.definition})]));else if(t instanceof sc)return r([new sa({definition:t.definition}),new sh({definition:[new sp({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof su)s=r(t.definition.concat([new sh({definition:[new sp({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof sh)s=r(t.definition.concat([new sh({definition:t.definition})]));else if(t instanceof sd)return eN(t.definition,e=>{!1===e5(e.definition)&&(s=r(e.definition))}),s;else if(t instanceof sp)i.push(t.terminalType);else throw Error("non exhaustive match");n++}return s.push({partialPath:i,suffixDef:iZ(e,n)}),s}function rm(e,t,i,s){let n="EXIT_NONE_TERMINAL",r=[n],a="EXIT_ALTERNATIVE",o=!1,l=t.length,c=l-s-1,h=[],u=[];for(u.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!e5(u);){let e=u.pop();if(e===a){o&&nP(u).idx<=c&&u.pop();continue}let s=e.def,d=e.idx,p=e.ruleStack,f=e.occurrenceStack;if(e5(s))continue;let m=s[0];if(m===n){let e={idx:d,def:iZ(s),ruleStack:ra(p),occurrenceStack:ra(f)};u.push(e)}else if(m instanceof sp)if(d<l-1){let e=d+1;if(i(t[e],m.terminalType)){let t={idx:e,def:iZ(s),ruleStack:p,occurrenceStack:f};u.push(t)}}else if(d===l-1)h.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:p,occurrenceStack:f}),o=!0;else throw Error("non exhaustive match");else if(m instanceof sn){let e=iB(p);e.push(m.nonTerminalName);let t=iB(f);t.push(m.idx);let i={idx:d,def:m.definition.concat(r,iZ(s)),ruleStack:e,occurrenceStack:t};u.push(i)}else if(m instanceof so){let e={idx:d,def:iZ(s),ruleStack:p,occurrenceStack:f};u.push(e),u.push(a);let t={idx:d,def:m.definition.concat(iZ(s)),ruleStack:p,occurrenceStack:f};u.push(t)}else if(m instanceof sl){let e=new sh({definition:m.definition,idx:m.idx}),t={idx:d,def:m.definition.concat([e],iZ(s)),ruleStack:p,occurrenceStack:f};u.push(t)}else if(m instanceof sc){let e=new sh({definition:[new sp({terminalType:m.separator})].concat(m.definition),idx:m.idx}),t={idx:d,def:m.definition.concat([e],iZ(s)),ruleStack:p,occurrenceStack:f};u.push(t)}else if(m instanceof su){let e={idx:d,def:iZ(s),ruleStack:p,occurrenceStack:f};u.push(e),u.push(a);let t=new sh({definition:[new sp({terminalType:m.separator})].concat(m.definition),idx:m.idx}),i={idx:d,def:m.definition.concat([t],iZ(s)),ruleStack:p,occurrenceStack:f};u.push(i)}else if(m instanceof sh){let e={idx:d,def:iZ(s),ruleStack:p,occurrenceStack:f};u.push(e),u.push(a);let t=new sh({definition:m.definition,idx:m.idx}),i={idx:d,def:m.definition.concat([t],iZ(s)),ruleStack:p,occurrenceStack:f};u.push(i)}else if(m instanceof sd)for(let e=m.definition.length-1;e>=0;e--){let t={idx:d,def:m.definition[e].definition.concat(iZ(s)),ruleStack:p,occurrenceStack:f};u.push(t),u.push(a)}else if(m instanceof sa)u.push({idx:d,def:m.definition.concat(iZ(s)),ruleStack:p,occurrenceStack:f});else if(m instanceof sr)u.push(function(e,t,i,s){let n=iB(i);n.push(e.name);let r=iB(s);return r.push(1),{idx:t,def:e.definition,ruleStack:n,occurrenceStack:r}}(m,d,p,f));else throw Error("non exhaustive match")}return h}function rT(e){if(e instanceof so||"Option"===e)return E.OPTION;if(e instanceof sh||"Repetition"===e)return E.REPETITION;if(e instanceof sl||"RepetitionMandatory"===e)return E.REPETITION_MANDATORY;if(e instanceof sc||"RepetitionMandatoryWithSeparator"===e)return E.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof su||"RepetitionWithSeparator"===e)return E.REPETITION_WITH_SEPARATOR;else if(e instanceof sd||"Alternation"===e)return E.ALTERNATION;else throw Error("non exhaustive match")}function rg(e,t,i,s){let n=e.length,r=sR(e,e=>sR(e,e=>1===e.length));if(t)return function(t){let s=t5(t,e=>e.GATE);for(let t=0;t<n;t++){let n=e[t],r=n.length,a=s[t];if(void 0===a||!1!==a.call(this))t:for(let e=0;e<r;e++){let s=n[e],r=s.length;for(let e=0;e<r;e++)if(!1===i(this.LA(e+1),s[e]))continue t;return t}}};if(!r||s)return function(){for(let t=0;t<n;t++){let s=e[t],n=s.length;t:for(let e=0;e<n;e++){let n=s[e],r=n.length;for(let e=0;e<r;e++)if(!1===i(this.LA(e+1),n[e]))continue t;return t}}};{let t=ni(t5(e,e=>sF(e)),(e,t,i)=>(eN(t,t=>{t9(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=i),eN(t.categoryMatches,t=>{t9(e,t)||(e[t]=i)})}),e),{});return function(){return t[this.LA(1).tokenTypeIdx]}}}function rE(e,t,i){let s=sR(e,e=>1===e.length),n=e.length;if(!s||i)return function(){t:for(let i=0;i<n;i++){let s=e[i],n=s.length;for(let e=0;e<n;e++)if(!1===t(this.LA(e+1),s[e]))continue t;return!0}return!1};{let t=sF(e);if(1===t.length&&e5(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{let e=ni(t,(e,t,i)=>(e[t.tokenTypeIdx]=!0,eN(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return!0===e[this.LA(1).tokenTypeIdx]}}}}(f=E||(E={}))[f.OPTION=0]="OPTION",f[f.REPETITION=1]="REPETITION",f[f.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",f[f.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",f[f.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",f[f.ALTERNATION=5]="ALTERNATION";class ry extends sv{constructor(e,t,i){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=i}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,i,s){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=i.concat(s),!0)}walkOption(e,t,i){this.checkIsTarget(e,E.OPTION,t,i)||super.walkOption(e,t,i)}walkAtLeastOne(e,t,i){this.checkIsTarget(e,E.REPETITION_MANDATORY,t,i)||super.walkOption(e,t,i)}walkAtLeastOneSep(e,t,i){this.checkIsTarget(e,E.REPETITION_MANDATORY_WITH_SEPARATOR,t,i)||super.walkOption(e,t,i)}walkMany(e,t,i){this.checkIsTarget(e,E.REPETITION,t,i)||super.walkOption(e,t,i)}walkManySep(e,t,i){this.checkIsTarget(e,E.REPETITION_WITH_SEPARATOR,t,i)||super.walkOption(e,t,i)}}class rA extends sf{constructor(e,t,i){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=i,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(void 0===this.targetRef||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,E.OPTION)}visitRepetition(e){this.checkIsTarget(e,E.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,E.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,E.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,E.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,E.ALTERNATION)}}function rL(e){let t=Array(e);for(let i=0;i<e;i++)t[i]=[];return t}function rS(e){let t=[""];for(let i=0;i<e.length;i++){let s=e[i],n=[];for(let e=0;e<t.length;e++){let i=t[e];n.push(i+"_"+s.tokenTypeIdx);for(let e=0;e<s.categoryMatches.length;e++){let t="_"+s.categoryMatches[e];n.push(i+t)}}t=n}return t}function rO(e,t){let i=t5(e,e=>rf([e],1)),s=rL(i.length),n=t5(i,e=>{let t={};return eN(e,e=>{eN(rS(e.partialPath),e=>{t[e]=!0})}),t}),r=i;for(let e=1;e<=t;e++){let i=r;r=rL(i.length);for(let a=0;a<i.length;a++){let o=i[a];for(let i=0;i<o.length;i++){let l=o[i].partialPath,c=o[i].suffixDef,h=rS(l);if(function(e,t,i){for(let s=0;s<e.length;s++){if(s===i)continue;let n=e[s];for(let e=0;e<t.length;e++)if(!0===n[t[e]])return!1}return!0}(n,h,a)||e5(c)||l.length===t){let e=s[a];if(!1===rk(e,l)){e.push(l);for(let e=0;e<h.length;e++){let t=h[e];n[a][t]=!0}}}else{let t=rf(c,e+1,l);r[a]=r[a].concat(t),eN(t,e=>{eN(rS(e.partialPath),e=>{n[a][e]=!0})})}}}}return s}function rb(e,t,i,s){let n=new rA(e,E.ALTERNATION,s);return t.accept(n),rO(n.result,i)}function rR(e,t,i,s){let n=new rA(e,i);t.accept(n);let r=n.result,a=new ry(t,e,i).startWalking();return rO([new sa({definition:r}),new sa({definition:a})],s)}function rk(e,t){i:for(let i=0;i<e.length;i++){let s=e[i];if(s.length===t.length){for(let e=0;e<s.length;e++){let i=t[e],n=s[e];if(!1==(i===n||void 0!==n.categoryMatchesMap[i.tokenTypeIdx]))continue i}return!0}}return!1}function rN(e){return sR(e,e=>sR(e,e=>sR(e,e=>e5(e.categoryMatches))))}function rv(e){return`${sN(e)}_#_${e.idx}_#_${rI(e)}`}function rI(e){return e instanceof sp?e.terminalType.name:e instanceof sn?e.nonTerminalName:""}class rC extends sf{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)}}class r_ extends sf{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}class rx extends sf{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)}}let rU="MismatchedTokenException",rM="NoViableAltException",rw="EarlyExitException",rP="NotAllInputParsedException",rD=[rU,rM,rw,rP];function r$(e){return sS(rD,e.name)}Object.freeze(rD);class rF 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 rB extends rF{constructor(e,t,i){super(e,t),this.previousToken=i,this.name=rU}}class rK extends rF{constructor(e,t,i){super(e,t),this.previousToken=i,this.name=rM}}class rj extends rF{constructor(e,t){super(e,t),this.name=rP}}class rG extends rF{constructor(e,t,i){super(e,t),this.previousToken=i,this.name=rw}}let rW={},rz="InRuleRecoveryException";class rV extends Error{constructor(e){super(e),this.name=rz}}function rH(e,t,i,s,n,r,a){let o=this.getKeyForAutomaticLookahead(s,n),l=this.firstAfterRepMap[o];if(void 0===l){let e=this.getCurrRuleFullName();l=new r(this.getGAstProductions()[e],n).startWalking(),this.firstAfterRepMap[o]=l}let c=l.token,h=l.occurrence,u=l.isEndOfRule;1===this.RULE_STACK.length&&u&&void 0===c&&(c=n5,h=1),void 0!==c&&void 0!==h&&this.shouldInRepetitionRecoveryBeTried(c,h,a)&&this.tryInRepetitionRecovery(e,t,i,c)}class rY{constructor(e){var t;this.maxLookahead=null!=(t=null==e?void 0:e.maxLookahead)?t:r7.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);return e5(t)?[...t,...this.validateEmptyOrAlternatives(e.rules),...this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),...this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead)]:t}validateNoLeftRecursion(e){return rt(e,e=>(function e(t,i,s,n=[]){let r=[],a=function e(t){let i=[];if(e5(t))return i;let s=nl(t);if(s instanceof sn)i.push(s.referencedRule);else if(s instanceof sa||s instanceof so||s instanceof sl||s instanceof sc||s instanceof su||s instanceof sh)i=i.concat(e(s.definition));else if(s instanceof sd)i=sF(t5(s.definition,t=>e(t.definition)));else if(s instanceof sp);else throw Error("non exhaustive match");let n=sk(s),r=t.length>1;if(!n||!r)return i;{let s=iZ(t);return i.concat(e(s))}}(i.definition);if(e5(a))return[];{let i=t.name;sS(a,t)&&r.push({message:s.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:A.LEFT_RECURSION,ruleName:i});let o=rt(na(a,n.concat([t])),i=>{let r=iB(n);return r.push(i),e(t,i,s,r)});return r.concat(o)}})(e,e,n7))}validateEmptyOrAlternatives(e){return rt(e,e=>{let t;return t=new r_,e.accept(t),rt(t.alternations,t=>rt(ra(t.definition),(i,s)=>e5(rm([i],[],n$,1))?[{message:n7.buildEmptyAlternationError({topLevelRule:e,alternation:t,emptyChoiceIdx:s}),type:A.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:t.idx,alternative:s+1}]:[]))})}validateAmbiguousAlternationAlternatives(e,t){return rt(e,e=>{let i;return i=new r_,e.accept(i),rt(s8(i.alternations,e=>!0===e.ignoreAmbiguities),i=>{var s,n,r,a,o,l,c,h;let u,d,p=rb(i.idx,e,i.maxLookahead||t,i),f=(s=p,n=i,r=e,a=n7,u=[],t5(ni(s,(e,t,i)=>(!0===n.definition[i].ignoreAmbiguities||eN(t,t=>{let r=[i];eN(s,(e,s)=>{i!==s&&rk(e,t)&&!0!==n.definition[s].ignoreAmbiguities&&r.push(s)}),r.length>1&&!rk(u,t)&&(u.push(t),e.push({alts:r,path:t}))}),e),[]),e=>{let t=t5(e.alts,e=>e+1);return{message:a.buildAlternationAmbiguityError({topLevelRule:r,alternation:n,ambiguityIndices:t,prefixPath:e.path}),type:A.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:n.idx,alternatives:e.alts}})),m=(o=p,l=i,c=e,h=n7,no(rt(d=ni(o,(e,t,i)=>{let s=t5(t,e=>({idx:i,path:e}));return e.concat(s)},[]),e=>{if(!0===l.definition[e.idx].ignoreAmbiguities)return[];let t=e.idx,i=e.path;return t5(ns(d,e=>{var s;return!0!==l.definition[e.idx].ignoreAmbiguities&&e.idx<t&&(s=e.path,s.length<i.length&&sR(s,(e,t)=>{let s=i[t];return e===s||s.categoryMatchesMap[e.tokenTypeIdx]}))}),e=>{let i=[e.idx+1,t+1],s=0===l.idx?"":l.idx;return{message:h.buildAlternationPrefixAmbiguityError({topLevelRule:c,alternation:l,ambiguityIndices:i,prefixPath:e.path}),type:A.AMBIGUOUS_PREFIX_ALTS,ruleName:c.name,occurrence:s,alternatives:i}})})));return f.concat(m)})})}validateSomeNonEmptyLookaheadPath(e,t){let i;return i=[],eN(e,e=>{let s=new rx;e.accept(s),eN(s.allProductions,s=>{let n=rT(s),r=s.maxLookahead||t;if(e5(sF(rR(s.idx,e,n,r)[0]))){let t=n7.buildEmptyRepetitionError({topLevelRule:e,repetition:s});i.push({message:t,type:A.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),i}buildLookaheadForAlternation(e){var t,i,s,n,r;let a,o;return t=e.prodOccurrence,i=e.rule,s=e.maxLookahead,n=e.hasPredicates,r=e.dynamicTokensEnabled,o=rN(a=rb(t,i,s))?nF:n$,rg(a,n,o,r)}buildLookaheadForOptional(e){var t,i,s,n,r;let a,o;return t=e.prodOccurrence,i=e.rule,s=e.maxLookahead,n=e.dynamicTokensEnabled,r=rT(e.prodType),o=rN(a=rR(t,i,r,s))?nF:n$,rE(a[0],o,n)}}let rX=new class extends sf{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}};function rJ(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function rq(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function rZ(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function rQ(e,t){let i=eb(e),s=i.length;for(let n=0;n<s;n++){let s=e[i[n]],r=s.length;for(let e=0;e<r;e++){let i=s[e];void 0===i.tokenTypeIdx&&this[i.name](i.children,t)}}}(m=y||(y={}))[m.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",m[m.MISSING_METHOD=1]="MISSING_METHOD";let r0={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(r0);let r1=n6({name:"RECORDING_PHASE_TOKEN",pattern:nH.NA});nj([r1]);let r2=n4(r1,"This IToken indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(r2);let r3={name:"This CSTNode indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function r6(e,t,i,s=!1){r8(i);let n=nP(this.recordingProdStack),r=eS(t)?t:t.DEF,a=new e({definition:[],idx:i});return s&&(a.separator=t.SEP),t9(t,"MAX_LOOKAHEAD")&&(a.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(a),r.call(this),n.definition.push(a),this.recordingProdStack.pop(),r0}function r5(e,t){r8(t);let i=nP(this.recordingProdStack),s=!1===q(e),n=!1===s?e:e.DEF,r=new sd({definition:[],idx:t,ignoreAmbiguities:s&&!0===e.IGNORE_AMBIGUITIES});return t9(e,"MAX_LOOKAHEAD")&&(r.maxLookahead=e.MAX_LOOKAHEAD),r.hasPredicates=sT(n,e=>eS(e.GATE)),i.definition.push(r),eN(n,e=>{let t=new sa({definition:[]});r.definition.push(t),t9(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:t9(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),r0}function r4(e){return 0===e?"":`${e}`}function r8(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>
52
- Idx value must be a none negative value smaller than ${256}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}let r9=n4(n5,"",0/0,0/0,0/0,0/0,0/0,0/0);Object.freeze(r9);let r7=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:n8,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ae=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});(T=A||(A={}))[T.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",T[T.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",T[T.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",T[T.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",T[T.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",T[T.LEFT_RECURSION=5]="LEFT_RECURSION",T[T.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",T[T.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",T[T.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",T[T.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",T[T.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",T[T.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",T[T.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",T[T.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class at{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;let t=this.className;this.TRACE_INIT("toFastProps",()=>{iK(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),eN(this.definedRulesNames,e=>{let t,i=this[e].originalGrammarAction;this.TRACE_INIT(`${e} Rule`,()=>{t=this.topLevelRuleRecord(e,i)}),this.gastProductionsCache[e]=t})}finally{this.disableRecording()}});let i=[];if(this.TRACE_INIT("Grammar Resolving",()=>{var e;let t,s,n;s=s6(e={rules:eI(this.gastProductionsCache)},{errMsgProvider:n9}),n={},eN(e.rules,e=>{n[e.name]=e}),(t=new re(n,s.errMsgProvider)).resolveRefs(),i=t.errors,this.definitionErrors=this.definitionErrors.concat(i)}),this.TRACE_INIT("Grammar Validations",()=>{if(e5(i)&&!1===this.skipValidations){var e,s,n,r,a,o,l,c,h;let i,u,d,p,f,m,T=(s=(e=s6(e={rules:eI(this.gastProductionsCache),tokenTypes:eI(this.tokensMap),errMsgProvider:n7,grammarName:t},{errMsgProvider:n7})).rules,n=e.tokenTypes,r=e.errMsgProvider,a=e.grammarName,d=rt(s,e=>{var t,i;let s;return t=e,i=r,s=new rC,t.accept(s),t5(eI(se(rr(s.allProductions,rv),e=>e.length>1)),e=>{let s=nl(e),n=i.buildDuplicateFoundError(t,e),r=sN(s),a={message:n,type:A.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:r,occurrence:s.idx},o=rI(s);return o&&(a.parameter=o),a})}),l=s,c=n,h=r,i=[],u=t5(c,e=>e.name),eN(l,e=>{let t=e.name;if(sS(u,t)){let s=h.buildNamespaceConflictError(e);i.push({message:s,type:A.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),p=i,f=rt(s,e=>{var t,i;let s;return t=e,i=r,s=new r_,t.accept(s),rt(s.alternations,e=>e.definition.length>255?[{message:i.buildTooManyAlternativesError({topLevelRule:t,alternation:e}),type:A.TOO_MANY_ALTS,ruleName:t.name,occurrence:e.idx}]:[])}),m=rt(s,e=>(function(e,t,i,s){let n=[];if(ni(t,(t,i)=>i.name===e.name?t+1:t,0)>1){let t=s.buildDuplicateRuleNameError({topLevelRule:e,grammarName:i});n.push({message:t,type:A.DUPLICATE_RULE_NAME,ruleName:e.name})}return n})(e,s,a,r)),d.concat(p,f,m)),g=t5((o={lookaheadStrategy:this.lookaheadStrategy,rules:eI(this.gastProductionsCache),tokenTypes:eI(this.tokensMap),grammarName:t}).lookaheadStrategy.validate({rules:o.rules,tokenTypes:o.tokenTypes,grammarName:o.grammarName}),e=>Object.assign({type:A.CUSTOM_LOOKAHEAD_VALIDATION},e));this.definitionErrors=this.definitionErrors.concat(T,g)}}),e5(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{var e;let t,i=(e=eI(this.gastProductionsCache),t={},eN(e,e=>{i8(t,new sK(e).startWalking())}),t);this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var e,t;null==(t=(e=this.lookaheadStrategy).initialize)||t.call(e,{rules:eI(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(eI(this.gastProductionsCache))})),!at.DEFER_DEFINITION_ERRORS_HANDLING&&!e5(this.definitionErrors))throw e=t5(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:
53
- ${e.join("\n-------------------------------\n")}`)})}constructor(e,t){if(this.definitionErrors=[],this.selfAnalysisDone=!1,this.initErrorHandler(t),this.initLexerAdapter(),this.initLooksAhead(t),this.initRecognizerEngine(e,t),this.initRecoverable(t),this.initTreeBuilder(t),this.initContentAssist(),this.initGastRecorder(t),this.initPerformanceTracer(t),t9(t,"ignoredIssues"))throw Error("The <ignoredIssues> IParserConfig property has been deprecated.\n Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n For further details.");this.skipValidations=t9(t,"skipValidations")?t.skipValidations:r7.skipValidations}}at.DEFER_DEFINITION_ERRORS_HANDLING=!1,[class{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t9(e,"recoveryEnabled")?e.recoveryEnabled:r7.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=rH)}getTokenToInsert(e){let t=n4(e,"",0/0,0/0,0/0,0/0,0/0,0/0);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,i,s){let n=this.findReSyncTokenType(),r=this.exportLexerState(),a=[],o=!1,l=this.LA(1),c=this.LA(1),h=()=>{let e=this.LA(0),t=new rB(this.errorMessageProvider.buildMismatchTokenMessage({expected:s,actual:l,previous:e,ruleName:this.getCurrRuleFullName()}),l,this.LA(0));t.resyncedTokens=ra(a),this.SAVE_ERROR(t)};for(;!o;)if(this.tokenMatcher(c,s))return void h();else if(i.call(this)){h(),e.apply(this,t);return}else this.tokenMatcher(c,n)?o=!0:(c=this.SKIP_TOKEN(),this.addToResyncTokens(c,a));this.importLexerState(r)}shouldInRepetitionRecoveryBeTried(e,t,i){return!(!1===i||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let i=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(i)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new rV("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||e5(t))return!1;let i=this.LA(1);return void 0!==nh(t,e=>this.tokenMatcher(i,e))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return sS(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),i=2;for(;;){let s=nh(e,e=>n$(t,e));if(void 0!==s)return s;t=this.LA(i),i++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return rW;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(i)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return t5(e,(i,s)=>0===s?rW:{ruleName:this.shortRuleNameToFullName(i),idxInCallingRule:t[s],inRule:this.shortRuleNameToFullName(e[s-1])})}flattenFollowSet(){return sF(t5(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e)))}getFollowSetFromFollowKey(e){if(e===rW)return[n5];let t=e.ruleName+e.idxInCallingRule+"_~IN~_"+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,n5)||t.push(e),t}reSyncTo(e){let t=[],i=this.LA(1);for(;!1===this.tokenMatcher(i,e);)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,t);return ra(t)}attemptInRepetitionRecovery(e,t,i,s,n,r,a){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:iB(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return t5(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}},class{initLooksAhead(e){this.dynamicTokensEnabled=t9(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:r7.dynamicTokensEnabled,this.maxLookahead=t9(e,"maxLookahead")?e.maxLookahead:r7.maxLookahead,this.lookaheadStrategy=t9(e,"lookaheadStrategy")?e.lookaheadStrategy:new rY({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){eN(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{var t;let i,{alternation:s,repetition:n,option:r,repetitionMandatory:a,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:l}=(t=e,rX.reset(),t.accept(rX),i=rX.dslMethods,rX.reset(),i);eN(s,t=>{let i=0===t.idx?"":t.idx;this.TRACE_INIT(`${sN(t)}${i}`,()=>{var i;let s=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),n=(i=this.fullRuleNameToShort[e.name],256|t.idx|i);this.setLaFuncCache(n,s)})}),eN(n,t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,sN(t))}),eN(r,t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,sN(t))}),eN(a,t=>{this.computeLookaheadFunc(e,t.idx,1024,"RepetitionMandatory",t.maxLookahead,sN(t))}),eN(o,t=>{this.computeLookaheadFunc(e,t.idx,1536,"RepetitionMandatoryWithSeparator",t.maxLookahead,sN(t))}),eN(l,t=>{this.computeLookaheadFunc(e,t.idx,1280,"RepetitionWithSeparator",t.maxLookahead,sN(t))})})})}computeLookaheadFunc(e,t,i,s,n,r){this.TRACE_INIT(`${r}${0===t?"":t}`,()=>{let r=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:n||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:s}),a=t|i|this.fullRuleNameToShort[e.name];this.setLaFuncCache(a,r)})}getKeyForAutomaticLookahead(e,t){return t|e|this.getLastExplicitRuleShortName()}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}},class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=t9(e,"nodeLocationTracking")?e.nodeLocationTracking:r7.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=rq,this.setNodeLocationFromNode=rq,this.cstPostRule=sx,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=sx,this.setNodeLocationFromNode=sx,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=rJ,this.setNodeLocationFromNode=rJ,this.cstPostRule=sx,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=sx,this.setNodeLocationFromNode=sx,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=sx,this.setNodeLocationFromNode=sx,this.cstPostRule=sx,this.setInitialNodeLocation=sx;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);else this.cstInvocationStateUpdate=sx,this.cstFinallyStateUpdate=sx,this.cstPostTerminal=sx,this.cstPostNonTerminal=sx,this.cstPostRule=sx}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:0/0,endOffset:0/0}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:0/0}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:0/0,startLine:0/0,startColumn:0/0,endOffset:0/0,endLine:0/0,endColumn:0/0}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:0/0,endLine:0/0,endColumn:0/0}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),i=e.location;i.startOffset<=t.startOffset==!0?(i.endOffset=t.endOffset,i.endLine=t.endLine,i.endColumn=t.endColumn):(i.startOffset=0/0,i.startLine=0/0,i.startColumn=0/0)}cstPostRuleOnlyOffset(e){let t=this.LA(0),i=e.location;i.startOffset<=t.startOffset==!0?i.endOffset=t.endOffset:i.startOffset=0/0}cstPostTerminal(e,t){let i=this.CST_STACK[this.CST_STACK.length-1];void 0===i.children[e]?i.children[e]=[t]:i.children[e].push(t),this.setNodeLocationFromToken(i.location,t)}cstPostNonTerminal(e,t){let i=this.CST_STACK[this.CST_STACK.length-1];void 0===i.children[t]?i.children[t]=[e]:i.children[t].push(e),this.setNodeLocationFromNode(i.location,e.location)}getBaseCstVisitorConstructor(){if(sj(this.baseCstVisitorConstructor)){var e,t;let i,s=(e=this.className,t=eb(this.gastProductionsCache),rZ(i=function(){},e+"BaseSemantics"),i.prototype={visit:function(e,t){if(q(e)&&(e=e[0]),!sj(e))return this[e.name](e.children,t)},validateVisitor:function(){var e,i,s;let n=(e=this,i=t,s=e,no(t5(ns(i,e=>!1===eS(s[e])),e=>({msg:`Missing visitor method: <${e}> on ${s.constructor.name} CST Visitor.`,type:y.MISSING_METHOD,methodName:e}))));if(!e5(n)){let e=t5(n,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
54
- ${e.join("\n\n").replace(/\n/g,"\n ")}`)}}},i.prototype.constructor=i,i._RULE_NAMES=t,i);return this.baseCstVisitorConstructor=s,s}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(sj(this.baseCstVisitorWithDefaultsConstructor)){var e,t,i;let s,n,r=(e=this.className,t=eb(this.gastProductionsCache),i=this.getBaseCstVisitorConstructor(),rZ(s=function(){},e+"BaseSemanticsWithDefaults"),n=Object.create(i.prototype),eN(t,e=>{n[e]=rQ}),s.prototype=n,s.prototype.constructor=s,s);return this.baseCstVisitorWithDefaultsConstructor=r,r}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}},class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):r9}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?r9: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{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=nF,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},t9(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n For Further details.");if(q(e)){if(e5(e))throw Error("A Token Vocabulary cannot be empty.\n Note that the first argument for the parser constructor\n is no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n For Further details.")}if(q(e))this.tokensMap=ni(e,(e,t)=>(e[t.name]=t,e),{});else if(t9(e,"modes")&&sR(sF(eI(e.modes)),nz)){let t=sw(sF(eI(e.modes)));this.tokensMap=ni(t,(e,t)=>(e[t.name]=t,e),{})}else if(eL(e))this.tokensMap=iB(e);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=n5;let i=sR(t9(e,"modes")?sF(eI(e.modes)):eI(e),e=>e5(e.categoryMatches));this.tokenMatcher=i?nF:n$,nj(eI(this.tokensMap))}defineRule(e,t,i){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
55
- Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let s=t9(i,"resyncEnabled")?i.resyncEnabled:ae.resyncEnabled,n=t9(i,"recoveryValueFunc")?i.recoveryValueFunc:ae.recoveryValueFunc,r=this.ruleShortNameIdx<<12;return this.ruleShortNameIdx++,this.shortRuleNameToFull[r]=e,this.fullRuleNameToShort[e]=r,Object.assign(!0===this.outputCst?function(...i){try{this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,i);let s=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(s),s}catch(e){return this.invokeRuleCatch(e,s,n)}finally{this.ruleFinallyStateUpdate()}}:function(...i){try{return this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,i)}catch(e){return this.invokeRuleCatch(e,s,n)}finally{this.ruleFinallyStateUpdate()}},{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,i){let s=1===this.RULE_STACK.length,n=t&&!this.isBackTracking()&&this.recoveryEnabled;if(r$(e)){if(n){let t=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(t)){if(e.resyncedTokens=this.reSyncTo(t),!this.outputCst)return i(e);{let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}}if(this.outputCst){let t=this.CST_STACK[this.CST_STACK.length-1];t.recoveredNode=!0,e.partialCstResult=t}throw e}if(s)return this.moveToTerminatedState(),i(e)}throw e}optionInternal(e,t){let i=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,i)}optionInternalLogic(e,t,i){let s,n=this.getLaFuncFromCache(i);if("function"!=typeof e){s=e.DEF;let t=e.GATE;if(void 0!==t){let e=n;n=()=>t.call(this)&&e.call(this)}}else s=e;if(!0===n.call(this))return s.call(this)}atLeastOneInternal(e,t){let i=this.getKeyForAutomaticLookahead(1024,e);return this.atLeastOneInternalLogic(e,t,i)}atLeastOneInternalLogic(e,t,i){let s,n=this.getLaFuncFromCache(i);if("function"!=typeof t){s=t.DEF;let e=t.GATE;if(void 0!==e){let t=n;n=()=>e.call(this)&&t.call(this)}}else s=t;if(!0===n.call(this)){let e=this.doSingleRepetition(s);for(;!0===n.call(this)&&!0===e;)e=this.doSingleRepetition(s)}else throw this.raiseEarlyExitException(e,E.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,1024,e,rd)}atLeastOneSepFirstInternal(e,t){let i=this.getKeyForAutomaticLookahead(1536,e);this.atLeastOneSepFirstInternalLogic(e,t,i)}atLeastOneSepFirstInternalLogic(e,t,i){let s=t.DEF,n=t.SEP;if(!0===this.getLaFuncFromCache(i).call(this)){s.call(this);let t=()=>this.tokenMatcher(this.LA(1),n);for(;!0===this.tokenMatcher(this.LA(1),n);)this.CONSUME(n),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,t,s,rp],t,1536,e,rp)}else throw this.raiseEarlyExitException(e,E.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let i=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,i)}manyInternalLogic(e,t,i){let s,n=this.getLaFuncFromCache(i);if("function"!=typeof t){s=t.DEF;let e=t.GATE;if(void 0!==e){let t=n;n=()=>e.call(this)&&t.call(this)}}else s=t;let r=!0;for(;!0===n.call(this)&&!0===r;)r=this.doSingleRepetition(s);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,768,e,rh,r)}manySepFirstInternal(e,t){let i=this.getKeyForAutomaticLookahead(1280,e);this.manySepFirstInternalLogic(e,t,i)}manySepFirstInternalLogic(e,t,i){let s=t.DEF,n=t.SEP;if(!0===this.getLaFuncFromCache(i).call(this)){s.call(this);let t=()=>this.tokenMatcher(this.LA(1),n);for(;!0===this.tokenMatcher(this.LA(1),n);)this.CONSUME(n),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,t,s,ru],t,1280,e,ru)}}repetitionSepSecondInternal(e,t,i,s,n){for(;i();)this.CONSUME(t),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,i,s,n],i,1536,e,n)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let i=this.getKeyForAutomaticLookahead(256,t),s=q(e)?e:e.DEF,n=this.getLaFuncFromCache(i).call(this,s);if(void 0!==n)return s[n].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new rj(t,e))}}subruleInternal(e,t,i){let s;try{let n=void 0!==i?i.ARGS:void 0;return this.subruleIdx=t,s=e.apply(this,n),this.cstPostNonTerminal(s,void 0!==i&&void 0!==i.LABEL?i.LABEL:e.ruleName),s}catch(t){throw this.subruleInternalError(t,i,e.ruleName)}}subruleInternalError(e,t,i){throw r$(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:i),delete e.partialCstResult),e}consumeInternal(e,t,i){let s;try{let t=this.LA(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),s=t):this.consumeInternalError(e,t,i)}catch(i){s=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(void 0!==i&&void 0!==i.LABEL?i.LABEL:e.name,s),s}consumeInternalError(e,t,i){let s,n=this.LA(0);throw s=void 0!==i&&i.ERR_MSG?i.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new rB(s,t,n))}consumeInternalRecovery(e,t,i){if(this.recoveryEnabled&&"MismatchedTokenException"===i.name&&!this.isBackTracking()){let s=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,s)}catch(e){if(e.name===rz)throw i;throw e}}throw i}saveRecogState(){let e=this.errors,t=iB(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,i){this.RULE_OCCURRENCE_STACK.push(i),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),n5)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},class{ACTION(e){return e.call(this)}consume(e,t,i){return this.consumeInternal(t,e,i)}subrule(e,t,i){return this.subruleInternal(t,e,i)}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,i=ae){if(sS(this.definedRulesNames,e)){let t={message:n7.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:A.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let s=this.defineRule(e,t,i);return this[e]=s,s}OVERRIDE_RULE(e,t,i=ae){var s,n;let r,a,o=(s=this.definedRulesNames,n=this.className,a=[],sS(s,e)||(r=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,a.push({message:r,type:A.INVALID_RULE_OVERRIDE,ruleName:e})),a);this.definitionErrors=this.definitionErrors.concat(o);let l=this.defineRule(e,t,i);return this[e]=l,l}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(r$(e))return!1;throw e}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return t5(eI(this.gastProductionsCache),function e(t){function i(t){return t5(t,e)}if(t instanceof sn){let e={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return iQ(t.label)&&(e.label=t.label),e}if(t instanceof sa)return{type:"Alternative",definition:i(t.definition)};if(t instanceof so)return{type:"Option",idx:t.idx,definition:i(t.definition)};if(t instanceof sl)return{type:"RepetitionMandatory",idx:t.idx,definition:i(t.definition)};if(t instanceof sc)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:e(new sp({terminalType:t.separator})),definition:i(t.definition)};else if(t instanceof su)return{type:"RepetitionWithSeparator",idx:t.idx,separator:e(new sp({terminalType:t.separator})),definition:i(t.definition)};else if(t instanceof sh)return{type:"Repetition",idx:t.idx,definition:i(t.definition)};else if(t instanceof sd)return{type:"Alternation",idx:t.idx,definition:i(t.definition)};else if(t instanceof sp){var s,n;let e={type:"Terminal",name:t.terminalType.name,label:iQ((n=s=t.terminalType).LABEL)&&""!==n.LABEL?s.LABEL:s.name,idx:t.idx};iQ(t.label)&&(e.terminalLabel=t.label);let i=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(e.pattern=si(i)?i.source:i),e}else if(t instanceof sr)return{type:"Rule",name:t.name,orgText:t.orgText,definition:i(t.definition)};else throw Error("non exhaustive match")})}},class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=t9(e,"errorMessageProvider")?e.errorMessageProvider:r7.errorMessageProvider}SAVE_ERROR(e){if(r$(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:iB(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return iB(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,i){let s=this.getCurrRuleFullName(),n=rR(e,this.getGAstProductions()[s],t,this.maxLookahead)[0],r=[];for(let e=1;e<=this.maxLookahead;e++)r.push(this.LA(e));let a=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:n,actual:r,previous:this.LA(0),customUserDescription:i,ruleName:s});throw this.SAVE_ERROR(new rG(a,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let i=this.getCurrRuleFullName(),s=rb(e,this.getGAstProductions()[i],this.maxLookahead),n=[];for(let e=1;e<=this.maxLookahead;e++)n.push(this.LA(e));let r=this.LA(0),a=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:n,previous:r,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new rK(a,this.LA(1),r))}},class{initContentAssist(){}computeContentAssist(e,t){let i=this.gastProductionsCache[e];if(sj(i))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return rm([i],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=nl(e.ruleStack);return new rl(this.getGAstProductions()[t],e).startWalking()}},class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(t,i){return this.consumeInternalRecord(t,e,i)},this[`SUBRULE${t}`]=function(t,i){return this.subruleInternalRecord(t,e,i)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,i){return this.consumeInternalRecord(t,e,i)},this.subrule=function(e,t,i){return this.subruleInternalRecord(t,e,i)},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",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";delete this[`CONSUME${t}`],delete this[`SUBRULE${t}`],delete this[`OPTION${t}`],delete this[`OR${t}`],delete this[`MANY${t}`],delete this[`MANY_SEP${t}`],delete this[`AT_LEAST_ONE${t}`],delete this[`AT_LEAST_ONE_SEP${t}`]}delete this.consume,delete this.subrule,delete this.option,delete this.or,delete this.many,delete this.atLeastOne,delete this.ACTION,delete this.BACKTRACK,delete this.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return r9}topLevelRuleRecord(e,t){try{let i=new sr({definition:[],name:e});return i.name=e,this.recordingProdStack.push(i),t.call(this),this.recordingProdStack.pop(),i}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n This error was thrown during the "grammar recording phase" For more info see:\n https://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(t){throw e}throw e}}optionInternalRecord(e,t){return r6.call(this,so,e,t)}atLeastOneInternalRecord(e,t){r6.call(this,sl,t,e)}atLeastOneSepFirstInternalRecord(e,t){r6.call(this,sc,t,e,!0)}manyInternalRecord(e,t){r6.call(this,sh,t,e)}manySepFirstInternalRecord(e,t){r6.call(this,su,t,e,!0)}orInternalRecord(e,t){return r5.call(this,e,t)}subruleInternalRecord(e,t,i){if(r8(t),!e||!1===t9(e,"ruleName")){let i=Error(`<SUBRULE${r4(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
56
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw i.KNOWN_RECORDER_ERROR=!0,i}let s=nP(this.recordingProdStack),n=new sn({idx:t,nonTerminalName:e.ruleName,label:null==i?void 0:i.LABEL,referencedRule:void 0});return s.definition.push(n),this.outputCst?r3:r0}consumeInternalRecord(e,t,i){if(r8(t),!nG(e)){let i=Error(`<CONSUME${r4(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
57
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw i.KNOWN_RECORDER_ERROR=!0,i}let s=nP(this.recordingProdStack),n=new sp({idx:t,terminalType:e,label:null==i?void 0:i.LABEL});return s.definition.push(n),r2}},class{initPerformanceTracer(e){if(t9(e,"traceInitPerf")){let t=e.traceInitPerf,i="number"==typeof t;this.traceInitMaxIdent=i?t:1/0,this.traceInitPerf=i?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=r7.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let i=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${i}--\x3e <${e}>`);let{time:s,value:n}=nD(t),r=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&r(`${i}<-- <${e}> time: ${s}ms`),this.traceInitIndent--,n}}}].forEach(e=>{let t=e.prototype;Object.getOwnPropertyNames(t).forEach(i=>{if("constructor"===i)return;let s=Object.getOwnPropertyDescriptor(t,i);s&&(s.get||s.set)?Object.defineProperty(at.prototype,i,s):at.prototype[i]=e.prototype[i]})});class ai extends at{constructor(e,t=r7){let i=iB(t);i.outputCst=!0,super(e,i)}}var as=i("El");function an(e,t){let i=e.lexer.tokenize(t);if(i.errors.length>0){let s=i.errors[0],n=Number.isFinite(s.offset)?s.offset:t.length,r=n+(Number.isFinite(s.length)?s.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${s.message} at line ${s.line??1}, column ${s.column??1} [${n},${r})`)}e.parser.input=i.tokens;let s=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(s)}(0,I.K)(an,"runChevrotainParse");var ar=N.UI.usecase,aa=(0,I.K)(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:"LR",relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(ar)}),"createModel"),ao=(0,I.K)(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||"string"!=typeof e.accTitle||"string"!=typeof e.accDescription||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),al=aa(),ac=(0,I.K)(()=>structuredClone(al.config),"getConfig"),ah=(0,I.K)(()=>al.ast,"getAST"),au=(0,I.K)(e=>{let t=structuredClone(e);ao(t);let i=(0,N.iN)(),s=(0,N.m7)();try{(0,N.SV)(t.accTitle),(0,N.EI)(t.accDescription),al=t}catch(e){throw(0,N.SV)(i),(0,N.EI)(s),e}},"commit"),ad=(0,I.K)(()=>{al=aa(),(0,N.IU)()},"clear"),ap=(0,I.K)(()=>al.actors,"getActors"),af=(0,I.K)(e=>al.actors.get(e),"getActor"),am=(0,I.K)(()=>al.useCases,"getUseCases"),aT=(0,I.K)(e=>al.useCases.get(e),"getUseCase"),ag=(0,I.K)(()=>al.systemBoundaries,"getSystemBoundaries"),aE=(0,I.K)(e=>al.systemBoundaries.get(e),"getSystemBoundary"),ay=(0,I.K)(()=>al.relationships,"getRelationships"),aA=(0,I.K)(()=>al.notes,"getNotes"),aL=(0,I.K)(e=>al.notes.get(e),"getNote"),aS=(0,I.K)(()=>al.jsonNodes,"getJsonNodes"),aO=(0,I.K)(e=>al.jsonNodes.get(e),"getJsonNode"),ab=(0,I.K)(()=>al.classDefs,"getClassDefs"),aR=(0,I.K)(e=>al.classDefs.get(e),"getClassDef"),ak=(0,I.K)(()=>al.direction,"getDirection"),aN=(0,I.K)(e=>{let t=new Map;for(let i of["default",...e]){let e=al.classDefs.get(i);if(e)for(let i of e.styles){let e=i.trim(),s=e.indexOf(":"),n=(-1===s?e:e.slice(0,s)).trim();n&&t.set(n,e)}}return[...t.values()]},"getCompiledStyles"),av=(0,I.K)(e=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),aI=(0,I.K)(e=>"string"==typeof e?e:null===e?"null":String(e),"displayJsonScalar"),aC=(0,I.K)((e,t,i=e=>e)=>{let s=[],n=(0,I.K)((e,t,n)=>{s.push({key:i(e),accessibleKey:i(t),value:i(n)})},"append"),r=(0,I.K)((e,i,s)=>{if(Array.isArray(e)){if(0===e.length)return void n(i,i,"[]");if(e.every(e=>null===e||["string","number","boolean"].includes(typeof e))){for(let[t,s]of e.entries())n(0===t?i:"",i,aI(s));return}for(let[t,n]of e.entries())r(n,`${i}[${t}]`,`${s}/${t}`);return}if(null!==e&&"object"==typeof e){let a=t[s]??Object.keys(e);if(0===a.length)return void n(i,i,"{}");for(let t of a){let n=i?`${i}.${t}`:t;r(e[t],n,`${s}/${av(t)}`)}return}n(i,i,aI(e))},"visit");return r(e,"",""),s},"flattenJsonRows"),a_=(0,I.K)(e=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),ax=(0,I.K)(e=>"ellipse"===e.shape?e.business?"usecaseBusiness":"usecaseEllipse":e.shape,"useCaseShape"),aU=(0,I.K)(e=>{switch(e){case 0:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case 1:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case 3:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case 4:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case 5:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case 6:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case 2:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),aM=(0,I.K)(e=>{switch(e.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:e.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...aU(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),aw=(0,I.K)(e=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),aP=(0,I.K)((...e)=>e.filter(e=>!!e).join(" "),"classNames"),aD=(0,I.K)(()=>{let e=(0,N.D7)(),t={...al.config,...e.usecase},i=(0,I.K)(t=>(0,N.jZ)(t,e),"sanitize"),s=(0,I.K)(e=>i(al.actors.get(e)?.label??al.useCases.get(e)?.label??al.jsonNodes.get(e)?.id??al.notes.get(e)?.label??e),"endpointLabel"),n=[],r=[],a=0,o=0;for(let t of al.actors.values())n.push({id:t.id,label:i(t.label),labelType:t.labelType,shape:a_(t),isGroup:!1,padding:10,look:e.look,colorIndex:a++,cssClasses:aP("default","usecase-actor",`usecase-actor-${t.type}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:aN(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:i(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of al.useCases.values())n.push({id:t.id,label:i(t.label),labelType:t.labelType,shape:ax(t),isGroup:!1,padding:"ellipse"===t.shape?20:10,look:e.look,colorIndex:a++,cssClasses:aP("default","usecase-element",`usecase-${t.shape}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:aN(t.classes),business:t.business,...t.stereotype?{stereotype:i(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of al.notes.values())n.push({id:t.id,label:i(t.label),labelType:t.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:aN([]),noteTarget:t.target,noteTargetLabel:i(al.actors.get(t.target)?.label??al.useCases.get(t.target)?.label??al.jsonNodes.get(t.target)?.id??t.target)});for(let t of al.jsonNodes.values())n.push({id:t.id,label:i(t.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:aP("default","usecase-json-table",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:aN(t.classes),jsonRows:aC(t.value,t.propertyOrder,i)});for(let t of al.systemBoundaries.values())n.push({id:t.id,label:i(t.label),labelType:t.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:o++,cssClasses:aP("default","system-boundary",`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:aN(t.classes),boundaryType:t.type});for(let t of al.relationships){let{label:n,...a}=aM(t);r.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:s(t.source),targetLabel:s(t.target),type:"edge",relationshipType:t.type,internal:!1,...a,...void 0!==n?{label:i(n)}:{},labelpos:"c",classes:aP("default","relationship",`relationship-${t.type}`,...t.classes,...aw(t)),style:[...t.styles],cssCompiledStyles:aN(t.classes),animate:t.animate,...t.animation?{animation:t.animation}:{},look:e.look,thickness:"normal",minlen:t.minlen,isUserDefinedId:t.explicitId})}for(let t of al.notes.values())r.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:"edge",relationshipType:"note",sourceLabel:s(t.id),targetLabel:s(t.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:aN([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let e of n)e.wrappingWidth??=t.wrappingWidth,e.isGroup||e.shape.startsWith("usecaseActor")||(e.minWidth??=t.minNodeWidth),("usecaseEllipse"===e.shape||"usecaseBusiness"===e.shape)&&(e.spreadPorts=!0);return{nodes:n,edges:r,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:ak(),nodeSpacing:t.nodeSpacing,rankSpacing:t.rankSpacing,actorFontSize:t.actorFontSize,actorFontFamily:t.actorFontFamily,actorFontWeight:t.actorFontWeight,usecaseFontSize:t.usecaseFontSize,usecaseFontFamily:t.usecaseFontFamily,usecaseFontWeight:t.usecaseFontWeight,diagramPadding:t.diagramPadding,useMaxWidth:t.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),a$={getConfig:ac,createModel:aa,commit:au,getAST:ah,clear:ad,setDiagramTitle:N.ke,getDiagramTitle:N.ab,setAccTitle:N.SV,getAccTitle:N.iN,setAccDescription:N.EI,getAccDescription:N.m7,getActors:ap,getActor:af,getUseCases:am,getUseCase:aT,getSystemBoundaries:ag,getSystemBoundary:aE,getRelationships:ay,getNotes:aA,getNote:aL,getJsonNodes:aS,getJsonNode:aO,getClassDefs:ab,getClassDef:aR,getDirection:ak,getData:aD};function aF(e,t,i){let s=[i];return s.index=t,s.input=e,s}(0,I.K)(aF,"customMatch");var aB=(0,I.K)((e,t)=>{if('"'!==e[t]||"`"!==e[t+1])return null;for(let i=t+2;i<e.length-1;i++)if("`"===e[i]&&'"'===e[i+1])return aF(e,t,e.slice(t,i+2));return null},"matchMarkdownString"),aK=(0,I.K)((e,t)=>{if("%"!==e[t]||"%"!==e[t+1])return null;for(let i=t-1;i>=0;i--){let t=e[i];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return null}let i=t+2;for(;i<e.length&&"\n"!==e[i]&&"\r"!==e[i];)i++;return aF(e,t,e.slice(t,i))},"matchComment"),aj=(0,I.K)((e,t)=>{for(let i=t-1;i>=0;i--){let t=e[i];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return!1}return!0},"isIndentedLineStart"),aG=(0,I.K)((e,t,i)=>{if(!aj(e,t))return null;let s=i.exec(e.slice(t));return s?aF(e,t,s[0]):null},"matchAccessibilityLine"),aW=(0,I.K)((e,t)=>{if(!aj(e,t))return null;let i=/^accDescr[\t ]*{/.exec(e.slice(t));if(!i)return null;let s=e.indexOf("}",t+i[0].length);return -1===s?null:aF(e,t,e.slice(t,s+1))},"matchAccDescrBlock"),az=(0,I.K)((e,t)=>{if("{"!==e[t])return null;let i=0,s=!1,n=!1;for(let r=t;r<e.length;r++){let a=e[r];if(s){n?n=!1:"\\"===a?n=!0:'"'===a&&(s=!1);continue}if('"'===a)s=!0;else if("{"===a)i++;else if("}"===a&&0==--i)return aF(e,t,e.slice(t,r+1))}return null},"matchJsonObject"),aV=(0,I.K)((e,t)=>{let i=e.indexOf(">>",t);if(-1===i||/[\n\r]/.test(e.slice(t,i)))return null;let s=e.slice(t,i);return s.trim()?aF(e,t,s):null},"matchStereotypeText"),aH=n6({name:"LABEL_TEXT",pattern:nH.NA}),aY=n6({name:"WORD",pattern:nH.NA,categories:aH}),aX=n6({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:aH}),aJ=n6({name:"IDENTIFIER",pattern:/\w+/,longer_alt:aX,categories:aY}),aq=n6({name:"HWS",pattern:/[\t ]+/,group:nH.SKIPPED}),aZ=n6({name:"MARKDOWN_STRING",pattern:aB,start_chars_hint:['"'],line_breaks:!0}),aQ=n6({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),a0=n6({name:"COMMENT",pattern:aK,start_chars_hint:["%"],line_breaks:!1}),a1=n6({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),a2=n6({name:"ACC_DESCR_BLOCK",pattern:aW,start_chars_hint:["a"],line_breaks:!0}),a3=/^accTitle[\t ]*:[^\n\r]*/,a6=/^accDescr[\t ]*:[^\n\r]*/,a5=n6({name:"ACC_TITLE_LINE",pattern:(0,I.K)((e,t)=>aG(e,t,a3),"pattern"),start_chars_hint:["a"],line_breaks:!1}),a4=n6({name:"ACC_DESCR_LINE",pattern:(0,I.K)((e,t)=>aG(e,t,a6),"pattern"),start_chars_hint:["a"],line_breaks:!1}),a8=n6({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),a9=n6({name:"JSON_OBJECT_LITERAL",pattern:az,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),a7=n6({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),oe=(0,I.K)((e,t)=>n6({name:e,pattern:t,longer_alt:aJ,categories:aY}),"keyword"),ot=oe("USECASE",/usecase-beta/),oi=oe("ACTOR",/actor/),os=oe("SYSTEM_BOUNDARY",/systemBoundary/),on=oe("END",/end/),or=oe("DIRECTION",/direction/),oa=oe("TD",/TD/),oo=oe("TB",/TB/),ol=oe("BT",/BT/),oc=oe("LR",/LR/),oh=oe("RL",/RL/),ou=oe("NOTE",/note/),od=oe("FOR",/for/),op=oe("JSON",/json/),of=oe("CLASS_DEF",/classDef/),om=oe("CLASS",/class/),oT=oe("STYLE",/style/),og=oe("INCLUDE",/include/i),oE=oe("EXTEND",/extend/i),oy=oe("TRUE",/true/),oA=oe("FALSE",/false/),oL=n6({name:"GENERALIZATION",pattern:/--\|>/}),oS=n6({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),oO=n6({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),ob=n6({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),oR=n6({name:"STEREOTYPE_TEXT",pattern:aV,line_breaks:!1}),ok=n6({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),oN=n6({name:"CLASS_SEPARATOR",pattern:/:::/}),ov=n6({name:"FORWARD_SOLID",pattern:/--+>/}),oI=n6({name:"BACKWARD_SOLID",pattern:/<--+/}),oC=n6({name:"FORWARD_CIRCLE",pattern:/--o/}),o_=n6({name:"BACKWARD_CIRCLE",pattern:/o--/}),ox=n6({name:"FORWARD_CROSS",pattern:/--x/}),oU=n6({name:"BACKWARD_CROSS",pattern:/x--/}),oM=n6({name:"MARKERLESS_SOLID",pattern:/--+/}),ow=n6({name:"METADATA_START",pattern:/@{/}),oP=n6({name:"AT",pattern:/@/,categories:aH}),oD=n6({name:"LBRACE",pattern:/{/}),o$=n6({name:"RBRACE",pattern:/}/}),oF=n6({name:"LBRACKET",pattern:/\[/}),oB=n6({name:"RBRACKET",pattern:/]/}),oK=n6({name:"LPAREN",pattern:/\(/}),oj=n6({name:"RPAREN",pattern:/\)/}),oG=n6({name:"COMMA",pattern:/,/,categories:aH}),oW=n6({name:"COLON",pattern:/:/,categories:aH}),oz=n6({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:aH}),oV=n6({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),oH=n6({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:aH}),oY=n6({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:aH}),oX=n6({name:"DASH",pattern:/-/,categories:aH}),oJ=n6({name:"DOT",pattern:/\./,categories:aH}),oq=n6({name:"PERCENT",pattern:/%/,categories:aH}),oZ=n6({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:aH}),oQ=n6({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:aH}),o0=n6({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:aH}),o1=[aH,aY,aq,aZ,aQ,a0,a1,a2,a5,a4,a8,ot,oi,os,on,or,oa,oo,ol,oc,oh,ou,od,op,of,om,oT,og,oE,oy,oA,oL,oS,oO,oN,ov,oI,oC,o_,ox,oU,oM,ow,oP,oD,o$,oF,oB,oK,oj,oG,oW,oz,oV,oH,aJ,aX,oY,oX,oJ,oq,oZ,oQ,o0],o2={defaultMode:"defaultMode",modes:{defaultMode:[...o1],jsonBody:[a9,a7],stereotype:[ob,oR,ok]}},o3=[...o1,a9,a7,ob,oR,ok],o6=new nH(o2),o5=(0,I.K)(e=>n$(e,aH)||e.tokenType===oV||e.tokenType===aZ,"isLabelToken"),o4={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},o8=new class extends ai{static{(0,I.K)(this,"UsecaseParser")}constructor(){super(o3,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(ot),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:(0,I.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:(0,I.K)(()=>this.isStatementStart(),"GATE"),ALT:(0,I.K)(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:(0,I.K)(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:(0,I.K)(()=>this.isMetadataAssignment(),"GATE"),ALT:(0,I.K)(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:(0,I.K)(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:(0,I.K)(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(a1),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(n5),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(a1)}),this.RULE("commentLine",()=>{this.CONSUME(a0),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(a5),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(a4),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(a2),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(oi),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:(0,I.K)(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(oG),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:(0,I.K)(()=>{this.CONSUME(aJ),this.OPTION(()=>{this.CONSUME(oK),this.SUBRULE(this.nodeLabel),this.CONSUME(oj)})},"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(oi),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(oG),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:(0,I.K)(()=>{this.CONSUME(aJ),this.OPTION(()=>{this.OR2([{ALT:(0,I.K)(()=>{this.CONSUME(oK),this.SUBRULE(this.nodeLabel),this.CONSUME(oj)},"ALT")},{ALT:(0,I.K)(()=>{this.CONSUME(oF),this.SUBRULE2(this.nodeLabel),this.CONSUME(oB)},"ALT")}])})},"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")},{ALT:(0,I.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(aH)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:(0,I.K)(()=>this.LA(1).tokenType===aJ&&this.LA(2).tokenType===oP,"GATE"),DEF:(0,I.K)(()=>{this.CONSUME(aJ),this.CONSUME(oP)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:(0,I.K)(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(ov)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(oI),this.OPTION({GATE:(0,I.K)(()=>"<--"===this.LA(0).image&&this.hasLabeledRight([oM]),"GATE"),DEF:(0,I.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(oM)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(oM),this.OPTION({GATE:(0,I.K)(()=>"--"===this.LA(0).image&&this.hasLabeledRight([ov,oM,oC,ox]),"GATE"),DEF:(0,I.K)(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:(0,I.K)(()=>this.CONSUME(ov),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME2(oM),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oC),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(ox),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(oC)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(o_),this.OPTION({GATE:(0,I.K)(()=>this.hasLabeledRight([oM]),"GATE"),DEF:(0,I.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(oM)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(ox)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(oU),this.OPTION({GATE:(0,I.K)(()=>this.hasLabeledRight([oM]),"GATE"),DEF:(0,I.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(oM)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")},{ALT:(0,I.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(aH)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:(0,I.K)(()=>{this.CONSUME(oS),this.CONSUME(oW),this.OR2([{ALT:(0,I.K)(()=>this.CONSUME(og),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oE),"ALT")}])},"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oL),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(ow),this.MANY(()=>this.CONSUME(a1)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(oG)),this.MANY3(()=>this.CONSUME2(a1))}),this.CONSUME(o$)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(aJ),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")}]),this.CONSUME(oW),this.OR2([{ALT:(0,I.K)(()=>this.CONSUME2(aJ),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME2(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oy),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oA),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:(0,I.K)(()=>{this.CONSUME(oG),this.MANY(()=>this.CONSUME(a1))},"ALT")},{ALT:(0,I.K)(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(a1)),this.OPTION(()=>this.CONSUME2(oG)),this.MANY2(()=>this.CONSUME3(a1))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(os),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(on),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:(0,I.K)(()=>{this.CONSUME(aJ),this.OPTION(()=>{this.OR2([{ALT:(0,I.K)(()=>{this.CONSUME(oK),this.SUBRULE(this.nodeLabel),this.CONSUME(oj)},"ALT")},{ALT:(0,I.K)(()=>{this.CONSUME(oF),this.SUBRULE2(this.nodeLabel),this.CONSUME(oB)},"ALT")}])})},"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:(0,I.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:(0,I.K)(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:(0,I.K)(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:(0,I.K)(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(aJ),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aZ),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(ou),this.CONSUME(od),this.CONSUME(aJ),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(oO),this.CONSUME(oR),this.CONSUME(ob)}),this.RULE("classSuffix",()=>{this.CONSUME(oN),this.CONSUME(aJ),this.MANY(()=>{this.CONSUME(oG),this.CONSUME2(aJ)})}),this.RULE("jsonStatement",()=>{this.CONSUME(a8),this.CONSUME(a9),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(or),this.OR([{ALT:(0,I.K)(()=>this.CONSUME(oa),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oo),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(ol),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oc),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oh),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(of),this.CONSUME(aJ),this.MANY(()=>{this.CONSUME(oG),this.CONSUME2(aJ)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(om),this.CONSUME(aJ),this.MANY(()=>{this.CONSUME(oG),this.CONSUME2(aJ)}),this.CONSUME3(aJ),this.MANY2(()=>{this.CONSUME2(oG),this.CONSUME4(aJ)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(oT),this.CONSUME(aJ),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(oG),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(aY),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oH),"ALT")},{ALT:(0,I.K)(()=>{this.CONSUME(oM),this.CONSUME2(aY)},"ALT")}]),this.CONSUME(oW),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:(0,I.K)(()=>this.CONSUME(aY),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oV),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(aX),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oz),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oH),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oY),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oX),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oJ),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oq),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oZ),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oW),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oK),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oj),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oF),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oB),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oD),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(o$),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oP),"ALT")},{ALT:(0,I.K)(()=>this.CONSUME(oM),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===aJ||e===oV||e===aZ)&&this.LA(2).tokenType===ow}isStatementStart(){let e=this.LA(1).tokenType;return e!==n5&&e!==a1&&e!==a0}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===aJ&&!0===o4[this.LA(1).image.toLowerCase()]}hasLabeledRight(e){if(!o5(this.LA(1)))return!1;for(let t=2;;t++){let i=this.LA(t);if(e.includes(i.tokenType))return!0;if(!o5(i))return!1}}},o9=class extends Error{constructor(e,t,i){super(`${e} (line ${t}, column ${i})`),this.line=t,this.column=i,this.name="UsecaseJsonError"}static{(0,I.K)(this,"UsecaseJsonError")}},o7=(0,I.K)((e,t,i,s)=>{let n=i,r=s,a=Math.min(Math.max(t,0),e.length);for(let t=0;t<a;t++){let i=e[t];"\r"===i?(n++,r=1):"\n"===i?(0===t||"\r"!==e[t-1])&&(n++,r=1):r++}return{line:n,column:r}},"locationAtOffset"),le=(0,I.K)((e,t,i,s)=>{let n=/\bposition (\d+)\b/u.exec(e);if(n)return o7(t,Number.parseInt(n[1],10),i,s);let r=/\bline (\d+) column (\d+)\b/u.exec(e);if(r){let e=Number.parseInt(r[1],10),t=Number.parseInt(r[2],10);return{line:i+e-1,column:1===e?s+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return o7(t,t.length,i,s)},"locationFromErrorMessage"),lt=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}static{(0,I.K)(this,"JsonWalkError")}},li=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{(0,I.K)(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new lt(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if("{"===t)this.collectObject(e);else if("["===t)this.collectArray(e);else if('"'===t)this.readString(!1);else if("t"===t)this.consumeLiteral("true");else if("f"===t)this.consumeLiteral("false");else if("n"===t)this.consumeLiteral("null");else if("-"===t||t>="0"&&t<="9")this.consumeNumber();else throw new lt(this.offset)}collectObject(e){this.offset++;let t=[],i=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;for(;this.offset<this.text.length&&'"'===this.text[this.offset];){let s=this.readString(!0),n=`${e}/${s.replaceAll("~","~0").replaceAll("/","~1")}`;if(i.has(s)?this.deletePointerSubtree(n):(i.add(s),t.push(s)),this.skipWhitespace(),":"!==this.text[this.offset])break;if(this.offset++,this.collectValue(n),this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new lt(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new lt(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){let i=this.offset,s=this.text[this.offset++];if('"'===s)return t;if(32>s.charCodeAt(0))throw new lt(i);if("\\"!==s){e&&(t+=s);continue}let n=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+="\n");break;case"r":e&&(t+="\r");break;case"t":e&&(t+=" ");break;case"u":{let i=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(i))throw new lt(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(i,16))),this.offset+=4;break}default:throw new lt(n)}}throw new lt(this.offset)}consumeLiteral(e){let t=0;for(let i of e){if(this.text[this.offset+t]!==i)throw new lt(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if("-"===this.text[this.offset]&&this.offset++,"0"===this.text[this.offset])this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new lt(this.offset);if("."===this.text[this.offset]){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new lt(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if("e"===this.text[this.offset]||"E"===this.text[this.offset]){if(this.offset++,("+"===this.text[this.offset]||"-"===this.text[this.offset])&&this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new lt(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(" "!==e&&" "!==e&&"\n"!==e&&"\r"!==e)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let i of Object.keys(this.propertyOrder))(i===e||i.startsWith(t))&&delete this.propertyOrder[i]}};function ls(e,t,i){let s;try{s=JSON.parse(e)}catch(r){let s=r instanceof Error?r.message:String(r),n=le(s,e,t,i);if(!n){let s=0;try{new li(e).collect()}catch(e){e instanceof lt&&(s=e.offset)}n=o7(e,s,t,i)}throw new o9(`Invalid JSON: ${s}`,n.line,n.column)}if("object"!=typeof s||null===s||Array.isArray(s))throw new o9("JSON value must have an object root",t,i);return{value:s,propertyOrder:new li(e).collect()}}(0,I.K)(ls,"parseOrderedJsonObject");var ln=(0,I.K)(e=>({shape:"normal"===e.type?"actor":"hollow"===e.type?"actor-hollow":"awesome"===e.type?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),lr=(0,I.K)(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),la=(0,I.K)(e=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),lo=(0,I.K)(e=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),ll=(0,I.K)(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),lc=(0,I.K)(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:2,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),lh=(0,I.K)((e,t,i,s)=>{let n={};for(let t of e.getActors().values())n[t.id]=ln(t);for(let t of e.getUseCases().values())n[t.id]=lr(t);for(let t of e.getNotes().values())n[t.id]=la(t);for(let t of e.getJsonNodes().values())n[t.id]=lo(t);let r={};for(let t of e.getSystemBoundaries().values())r[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:t.type,labelType:t.labelType}};let a={};for(let t of e.getClassDefs().values())a[t.id]={styles:[...t.styles]};let o=e.getDirection();return{version:1,diagramType:"usecase",source:t,header:{keyword:"usecase",direction:"TD"===o?"TB":o,span:i},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:n,edges:[...e.getRelationships().map(ll),...[...e.getNotes().values()].map(lc)],groups:r,classDefs:a,statements:s}},"buildUsecaseGraphAST"),lu=(0,I.K)(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),ld=(0,I.K)(e=>void 0===e?"":` (label "${e}")`,"labelSuffix"),lp=(0,I.K)(e=>e.generated?e.label:void 0,"generatedFrom"),lf=(0,I.K)((e,t)=>{for(let i of t)e.includes(i)||e.push(i)},"pushUnique"),lm=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{(0,I.K)(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,i,s){this.metadataAssignments.push({target:e,targetLocation:t,metadata:i,statement:s})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,i){this.styleAssignments.push({target:e,location:t,styles:i})}setDirection(e){this.directions.push("TD"===e?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,i=new Map,s=new Map,n=new Map;for(let e of this.relationshipDrafts)this.recordFirst(n,e.source.id,e.source.location.span[0]),this.recordFirst(n,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(n,e.id,e.location.span[0]);for(let e of[...this.elements.map(e=>({offset:e.location.span[0],type:"element",value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:"boundary",value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:"json",value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:"edge",value:e}))].sort((e,t)=>e.offset-t.offset))"element"===e.type?this.collectElement(e.value,t,i):"boundary"===e.type?this.collectBoundary(e.value,t,s):"json"===e.type?this.registerUnique(t,e.value.id,"json",e.value.location,!1):this.registerUnique(t,e.value.explicitId,"edge",e.value.explicitIdLocation,!1);this.materializeElements(i,n),this.materializeBoundaries(s,n),this.materializeJson(n);let r=this.materializeRelationships(t,i,n);this.reorderElements(i,n),this.applyMetadataAssignments(t,i,s,r),this.validateAndRefreshElements(i),this.refreshBoundaries(s,i),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,r),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let a=lh(this,this.source,e,this.statements);return this.model.ast=a,this.db.commit(this.model),a}collectElement(e,t,i){let s=t.get(e.id),n=lp({generated:e.generated,label:e.label.text});s&&s.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${s.kind} and ${e.kind}`,e.location,s.location,n,lp(s)),s&&(s.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,s.location,n,lp(s));let r=i.get(e.id);if(!r){let s={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(s,e.metadata),i.set(e.id,s),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,lf(r.classes,e.classes),this.applyDeclarationMetadata(r,e.metadata)}collectBoundary(e,t,i){let s=t.get(e.id),n=lp({generated:e.generated,label:e.label.text});s&&"boundary"!==s.kind&&this.conflict(`ID '${e.id}' is declared as both ${s.kind} and boundary`,e.location,s.location,n,lp(s)),s&&(s.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,s.location,n,lp(s));let r=i.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),lf(r.classes,e.classes);return}i.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let i of[...e.values()].sort((e,i)=>(t.get(e.id)??0)-(t.get(i.id)??0)))this.setElementModel(i)}materializeBoundaries(e,t){for(let i of[...e.values()].sort((e,i)=>(t.get(e.id)??0)-(t.get(i.id)??0)))this.model.systemBoundaries.set(i.id,{id:i.id,label:i.label.text,labelType:i.label.type,type:i.type??"rect",members:[],classes:[...i.classes],styles:[...i.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,i)=>(e.get(t.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,i){let s=new Map,n=0;for(let r of this.relationshipDrafts){let a=this.resolveEndpoint(r.source,e,t,i),o=this.resolveEndpoint(r.target,e,t,i);this.validateRelationship(r,a,o,e);let l=r.explicitId??`edge-${n++}`,c={id:l,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(c),s.set(l,{draft:r,relationship:c})}return this.model.relationshipCounter=n,s}resolveEndpoint(e,t,i,s){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${lu(e.location)}`);let n=t.get(e.id);return n?n.kind:(i.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(s,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){let i=new Map(this.model.actors),s=new Map(this.model.useCases);for(let n of(this.model.actors.clear(),this.model.useCases.clear(),[...e.values()].sort((e,i)=>(t.get(e.id)??0)-(t.get(i.id)??0)))){i.has(n.id)||s.has(n.id)||this.setElementModel(n);let e=i.get(n.id)??this.model.actors.get(n.id),t=s.get(n.id)??this.model.useCases.get(n.id);e?this.model.actors.set(n.id,e):t&&this.model.useCases.set(n.id,t)}}applyMetadataAssignments(e,t,i,s){for(let n of this.metadataAssignments){let r=e.get(n.target);if(!r){let e=this.inferMetadataKind(n.metadata);throw Error(`Metadata target '${n.target}' is unresolved${e?` (metadata implies ${e})`:""} at ${lu(n.targetLocation)}`)}if("actor"===r.kind||"usecase"===r.kind)this.applyStandaloneElementMetadata(t.get(n.target),n.metadata);else if("boundary"===r.kind){let e=i.get(n.target);for(let t of n.metadata.properties)("type"!==t.key||"rect"!==t.value&&"package"!==t.value)&&this.invalidMetadata(n.target,r.kind,t),e.type=t.value}else if("edge"===r.kind){let e=s.get(n.target);if(!e)throw Error(`Metadata target '${n.target}' is not an explicit edge at ${lu(n.targetLocation)}`);for(let t of(n.statement.kind="edgeMetadata",n.statement.edges=[{id:n.target,span:n.statement.span,idSpan:n.targetLocation.span,...n.statement.metadata?{metadata:n.statement.metadata}:{}}],delete n.statement.nodes,n.metadata.properties))"animate"===t.key&&"boolean"==typeof t.value?e.relationship.animate=t.value:"animation"===t.key&&("fast"===t.value||"slow"===t.value)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(n.target,r.kind,t)}else for(let e of n.metadata.properties)this.invalidMetadata(n.target,r.kind,e)}for(let{relationship:e}of s.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let i of t.properties)"actor"===e.kind?this.applyActorProperty(e,i,!0):"business"===i.key&&"boolean"==typeof i.value?e.business=i.value:this.invalidMetadata(e.id,e.kind,i)}applyDeclarationMetadata(e,t){if(t)for(let i of t.properties)"actor"===e.kind?this.applyActorProperty(e,i,!1):"business"===i.key&&"boolean"==typeof i.value?(void 0!==e.business&&e.business!==i.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,i.location,e.location),e.business=i.value):this.invalidMetadata(e.id,e.kind,i)}applyActorProperty(e,t,i){"type"===t.key&&("normal"===t.value||"hollow"===t.value||"awesome"===t.value)?(i||void 0===e.actorType||e.actorType===t.value||this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):"icon"===t.key&&"string"==typeof t.value?(i||void 0===e.icon||e.icon===t.value||this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):"business"===t.key&&"boolean"==typeof t.value?(i||void 0===e.business||e.business===t.value||this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?"icon":t.actorType??"normal";if("actor"===t.kind){if(t.icon&&t.actorType&&"normal"!==t.actorType)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${lu(t.location)}`);if(t.business&&("icon"===e||"awesome"===e))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${lu(t.location)}`)}else if((t.shape??"ellipse")==="rect"&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${lu(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let i=e.get(t.parentId);if(!i)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${lu(t.parentLocation??t.location)}`);i.members.includes(t.id)||i.members.push(t.id)}for(let i of t.values())if(i.parentId&&!e.has(i.parentId))throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${lu(i.parentLocation??i.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??"rect",e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let i of this.noteDrafts){let s=e.get(i.target);if(!s)throw Error(`Note target '${i.target}' is unresolved at ${lu(i.targetLocation)}`);"actor"!==s.kind&&"usecase"!==s.kind&&this.conflict(`Note target '${i.target}' must be an actor or use case, not ${s.kind}`,i.targetLocation,s.location);let n=`note-${t++}`;this.model.notes.set(n,{id:n,target:i.target,label:i.label.text,labelType:i.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let i of this.classAssignments)for(let s of i.targets)lf(this.getStylable(s.id,e,t,s.location).classes,i.classes);for(let i of this.styleAssignments)this.getStylable(i.target,e,t,i.location).styles.push(...i.styles)}getStylable(e,t,i,s){let n=t.get(e)?.kind,r="actor"===n?this.model.actors.get(e):"usecase"===n?this.model.useCases.get(e):"boundary"===n?this.model.systemBoundaries.get(e):"json"===n?this.model.jsonNodes.get(e):"edge"===n?i.get(e)?.relationship:void 0;if(!r)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${lu(s)}`);return r}validateRelationship(e,t,i,s){let n=(0,I.K)(e=>"actor"===e||"usecase"===e||"json"===e,"allowed");if(n(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,s.get(e.source.id).location),n(i)||this.conflict(`Relationship target '${e.target.id}' cannot be ${i}`,e.target.location,s.get(e.target.id).location),("include"===e.type||"extend"===e.type)&&("usecase"!==t||"usecase"!==i))throw Error(`${e.type} relationship requires use-case endpoints at ${lu(e.location)}`);if("generalization"===e.type&&("actor"!==t&&"usecase"!==t||t!==i))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${lu(e.location)}`);if("association"===e.type&&("json"===t||"json"===i)&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${lu(e.location)}`)}setElementModel(e){if("actor"===e.kind){let t=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let i of e.properties)if("icon"===i.key)t.clear(),t.add("actor");else if("animate"===i.key||"animation"===i.key)t.clear(),t.add("edge");else if("type"===i.key)t.clear(),"rect"===i.value||"package"===i.value?t.add("boundary"):("normal"===i.value||"hollow"===i.value||"awesome"===i.value)&&t.add("actor");else{if("business"!==i.key)return;t.delete("boundary"),t.delete("edge")}return 1===t.size?[...t][0]:void 0}invalidMetadata(e,t,i){throw Error(`Metadata property '${i.key}' is invalid for ${t} '${e}' at ${lu(i.location)}`)}registerUnique(e,t,i,s,n){let r=e.get(t);r&&this.conflict(`ID '${t}' is declared more than once (${r.kind} and ${i})`,s,r.location,void 0,lp(r)),e.set(t,{kind:i,location:s,generated:n})}recordFirst(e,t,i){let s=e.get(t);(void 0===s||i<s)&&e.set(t,i)}conflict(e,t,i,s,n){throw Error(`${e} at ${lu(t)}${ld(s)}; previous declaration at ${lu(i)}${ld(n)}`)}},lT=o8.getBaseCstVisitorConstructor(),lg=new class extends lT{constructor(){super(),this.builder=new lm(a$),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{(0,I.K)(this,"UsecaseVisitor")}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,"USECASE")[0],i=[];for(let t of this.nodes(e,"line"))i.push(this.visit(t));this.builder.setStatements(i),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){let t=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,"ACC_DESCR_LINE")[0],i=this.tokens(e,"ACC_DESCR_BLOCK")[0],s=t?t.image.slice(t.image.indexOf(":")+1).trim():i.image.slice(i.image.indexOf("{")+1,i.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(s),{kind:"accDescr",span:[0,0]}}actorStatement(e){let t=this.nodes(e,"actorItem"),i=t.map(e=>this.visit(e)),s=this.nodes(e,"relationTail")[0],n=i.map((e,i)=>this.actorOccurrence(t[i],e,!0));for(let e of i)this.builder.addElement(this.actorDraft(e));if(!s)return{kind:"node",span:[0,0],nodes:n};let r=this.visit(s);r.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(r.target));let a=this.relationshipDraft(i[0],r,this.nodeLocation(s));this.builder.addRelationship(a);let o=a.explicitId??`edge-${this.anonymousEdge++}`;return n.push(this.entityOccurrence(this.nodes(s.children,"entityName")[0],r.target,r.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:n,edges:[{id:o,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,"actorName")[0]),i=this.nodes(e,"metadata")[0],s=this.nodes(e,"stereotype")[0],n=this.nodes(e,"classSuffix")[0],r=n?this.visit(n):{classes:[],spans:[]};return{...t,...i?{metadata:this.visit(i)}:{},...s?{stereotype:this.visit(s)}:{},classes:r.classes,classSpans:r.spans}}actorName(e){let t=this.tokens(e,"IDENTIFIER")[0],i=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(t){let i=this.nodes(e,"nodeLabel")[0],s=i?this.visit(i):this.tokenLabel(t);return{id:t.image,label:s,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let s=this.tokenLabel(i);return{id:this.generateId(s.text),label:s,location:this.tokenLocation(i),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,"actorItem"),i=t.map(e=>this.visit(e));for(let e of i)this.builder.addElement(this.actorDraft(e));return{kind:"node",span:[0,0],nodes:i.map((e,i)=>this.actorOccurrence(t[i],e,!0))}}entityStatement(e){let t=this.nodes(e,"entityName"),i=this.visit(t[0]),s=this.nodes(e,"relationTail")[0];if(!s)return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(t[0],i,!0)]};i.explicitDeclaration&&this.builder.addElement(this.entityDraft(i));let n=this.visit(s);n.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(n.target));let r={source:this.endpoint(i),target:this.endpoint(n.target),location:this.nodeLocation(s),...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow};this.builder.addRelationship(r);let a=r.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(t[0],i,i.explicitDeclaration),this.entityOccurrence(this.nodes(s.children,"entityName")[0],n.target,n.target.explicitDeclaration)],edges:[{id:a,span:[0,0],...r.explicitIdLocation?{idSpan:r.explicitIdLocation.span}:{},...r.label?{labelSpan:r.label.span}:{}}]}}entityName(e){let t=this.tokens(e,"IDENTIFIER")[0],i=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],s=this.nodes(e,"nodeLabel")[0],n=this.nodes(e,"useCaseMetadata")[0],r=this.nodes(e,"stereotype")[0],a=this.nodes(e,"classSuffix")[0],o=a?this.visit(a):{classes:[],spans:[]};if(t){let i=s?this.visit(s):this.tokenLabel(t),a=s?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:t.image,label:i,location:this.tokenLocation(t),generated:!1,...a?{shape:a}:{},...n?{metadata:this.visit(n)}:{},...r?{stereotype:this.visit(r)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(a||n||r)}}let l=this.tokenLabel(i);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(i),generated:!0,...n?{metadata:this.visit(n)}:{},...r?{stereotype:this.visit(r)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(n||r)}}nodeLabel(e){let t=this.allTokens(e);if(1===t.length&&("PLAIN_STRING"===t[0].tokenType.name||"MARKDOWN_STRING"===t[0].tokenType.name))return this.tokenLabel(t[0]);let i=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(i[0],i[1]),type:"text",span:i}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let t=this.tokens(e,"IDENTIFIER")[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:0,minlen:1};let t=this.tokens(e,"INCLUDE").length?"include":"extend",i=this.tokens(e,"include"===t?"INCLUDE":"EXTEND")[0];return{type:t,arrowType:0,label:{text:t,type:"text",span:this.tokenSpan(i)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>"COLON"!==e.tokenType.name),i=t[0],s=t[1],n="TRUE"===s.tokenType.name||"FALSE"!==s.tokenType.name&&this.decodePlain(s),r=[i.startOffset,(s.endOffset??s.startOffset)+1];return{key:this.decodePlain(i),value:n,span:r,keySpan:this.contentSpan(i),valueSpan:this.contentSpan(s),location:this.tokenLocation(i)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,"systemBoundaryName")[0]),i=this.nodes(e,"classSuffix")[0],s=i?this.visit(i):{classes:[],spans:[]};t.classes=s.classes,this.builder.addBoundary(t);let n=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let r=this.nodes(e,"systemBoundaryContent")[0],a=r?this.visit(r):[];this.parentBoundary=n;let o=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],c=l?this.visit(l):void 0,h={kind:"group",span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(o),classSpans:s.spans,...c?{metadata:c.properties.map(({key:e,span:t,keySpan:i,valueSpan:s})=>({key:e,span:t,keySpan:i,valueSpan:s}))}:{},...a.length?{children:a}:{}};return c&&this.builder.addMetadataAssignment(t.id,t.location,c,h),h}systemBoundaryName(e){let t=this.tokens(e,"IDENTIFIER")[0];if(t){let i=this.nodes(e,"nodeLabel")[0];return{id:t.image,label:i?this.visit(i):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let i=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],s=this.tokenLabel(i);return{id:this.generateId(s.text),label:s,location:this.tokenLocation(i),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,"actorDeclarationOnly")[0];if(t)return this.visit(t);let i=this.nodes(e,"entityName")[0],s=this.visit(i);return s.explicitDeclaration=!0,s.shape??="ellipse",this.builder.addElement(this.entityDraft(s)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(i,s,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),i=this.visit(this.nodes(e,"metadata")[0]),s={kind:"metadata",span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:i.properties.map(({key:e,span:t,keySpan:i,valueSpan:s})=>({key:e,span:t,keySpan:i,valueSpan:s}))};return this.builder.addMetadataAssignment(t.id,t.location,i,s),s}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],i=this.tokenLabel(t);return{id:"IDENTIFIER"===t.tokenType.name?t.image:this.generateId(i.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],i=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:i,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:i.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,"IDENTIFIER");return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,"JSON_DECLARATION_START")[0],i=this.tokens(e,"JSON_OBJECT_LITERAL")[0],s=/^json[\t ]+(\w+)/.exec(t.image),n=s[1],r=s[0].length-n.length,a={span:[t.startOffset+r,t.startOffset+r+n.length],line:t.startLine??1,column:(t.startColumn??1)+r},o=ls(i.image,i.startLine??1,i.startColumn??1),l=this.nodes(e,"classSuffix")[0],c=l?this.visit(l):{classes:[],spans:[]},h={id:n,value:o.value,propertyOrder:o.propertyOrder,location:a,classes:c.classes};return this.builder.addJson(h),{kind:"json",span:[0,0],nodes:[{id:n,span:a.span,idSpan:a.span,defines:!0,classSpans:c.spans}],classSpans:c.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>["TD","TB","BT","RL","LR"].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let t=this.tokens(e,"IDENTIFIER"),i=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(t.map(e=>e.image),i),{kind:"classDef",span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,"IDENTIFIER"),i=1;for(;i<t.length&&this.source.slice((t[i-1].endOffset??t[i-1].startOffset)+1,t[i].startOffset).includes(",");i++);let s=t.slice(0,i).map(e=>({id:e.image,location:this.tokenLocation(e)})),n=t.slice(i).map(e=>e.image);return this.builder.addClassAssignment(s,n),{kind:"classAssign",span:[0,0],ref:n[0],refSpan:this.tokenSpan(t[i]),nodes:s.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],i=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),i),{kind:"style",span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,"styleValue").map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),i=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(i[0],i[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(e=>e.image).join("")}forwardSolidOperator(e){let t=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:0,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,"BACKWARD_SOLID")[0],i=this.nodes(e,"edgeLabel")[0],s=i?this.tokens(e,"MARKERLESS_SOLID").at(-1):t;return{type:"association",arrowType:1,minlen:this.solidMinlen(s),...i?{label:this.visit(i)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,"edgeLabel")[0],i=this.allTokens(e);if(!t)return{type:"association",arrowType:2,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let s=i.at(-1),n="FORWARD_SOLID"===s.tokenType.name?0:"FORWARD_CIRCLE"===s.tokenType.name?3:"FORWARD_CROSS"===s.tokenType.name?4:2;return{type:"association",arrowType:n,label:this.visit(t),minlen:0===n||2===n?this.solidMinlen(s):1}}forwardCircleOperator(e){return{type:"association",arrowType:3,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:5,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:4,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:6,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,i){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:i,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,i){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...i?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:i,valueSpan:s})=>({key:e,span:t,keySpan:i,valueSpan:s}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,i){return this.actorOccurrence(e,t,i)}wrap(e,t){if("blank"===t.kind||"comment"===t.kind)return t;for(let i of(t.span=this.nodeSpan(e),t.edges??[]))i.span=t.span;return t}tokenLabel(e){let t="MARKDOWN_STRING"===e.tokenType.name?"markdown":"text",i="markdown"===t?2:+("PLAIN_STRING"===e.tokenType.name),s=this.tokenSpan(e,i);return{text:this.source.slice(s[0],s[1]),type:t,span:s}}decodePlain(e){return"PLAIN_STRING"===e.tokenType.name?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,"PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name))}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),i=t[0],s=t.at(-1);return{span:[i.startOffset,Math.min(this.source.length,(s.endOffset??s.startOffset+s.image.length-1)+1)],line:i.startLine??1,column:i.startColumn??1}}tokenLocation(e){let t="PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name);return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),i=t[0],s=t.at(-1);if(!i||!s)throw Error("Usecase CST node has no source token");return[i.startOffset,Math.min(this.source.length,(s.endOffset??s.startOffset+s.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>"children"in e)}tokens(e,t){return(e[t]??[]).filter(e=>"tokenTypeIdx"in e)}firstNode(e,...t){for(let i of t){let t=this.nodes(e,i)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(", ")}`)}allTokens(e){let t=[];for(let i of Object.values(e))for(let e of i)"tokenTypeIdx"in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},lE={parse:(0,I.K)(async e=>{a$.clear(),o8.input=[];try{an({diagramType:"usecase",lexer:o6,parser:o8,entry:(0,I.K)(()=>o8.start(),"entry"),visit:(0,I.K)(t=>lg.build(t,e),"visit")},e)}catch(i){a$.clear();let t=o8.errors[0];if(t){let{token:s}=t,n=Number.isFinite(s.startOffset)?s.startOffset:e.length,r="number"==typeof s.endOffset&&Number.isFinite(s.endOffset)?s.endOffset+1:n,a=s.startLine??e.slice(0,n).split(/\r\n|\r|\n/).length,o=Math.max(e.lastIndexOf("\n",n-1),e.lastIndexOf("\r",n-1)),l=s.startColumn??n-o,c=i instanceof Error?i.message:String(i);throw Error(`${c} at line ${a}, column ${l} [${n},${r})`)}throw i}},"parse")},ly=["point","circle","cross","extension"],lA={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},lL=(0,I.K)((e,t)=>{let[i,s]=[e,t].map(e=>e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${i}-${s}`},"usecaseDomId"),lS=(0,I.K)(e=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),lO=(0,I.K)((e,t)=>"markdown"!==t?e:(0,b.O6)(e).map(e=>e.map(e=>e.content).join(" ")).join("\n"),"getAccessibleLabel"),lb=(0,I.K)(e=>{let t=lO(e.label??e.id,e.labelType);if(lA[e.shape]){let i=e.actorType&&"normal"!==e.actorType?`${e.actorType} `:"",s=e.business?"business ":"",n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${s}${i}actor ${t}${n}`}if("note"===e.shape)return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${t}`;if("usecaseJsonTable"===e.shape){let i=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join("; ");return i?`${t}: ${i}`:t}let i=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${t}${i}`},"getUsecaseNodeAccessibleName"),lR=(0,I.K)(e=>`${e.boundaryType} system boundary ${lO(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),lk=(0,I.K)(e=>{if("note"===e.relationshipType)return"";let t="association"===e.relationshipType&&e.label?`association ${lO(e.label,e.labelType)}`:e.relationshipType;return`${t} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),lN=(0,I.K)(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),lv=(0,I.K)(e=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),lI=(0,I.K)((e,t)=>{for(let i of(e.diagramId=t,e.markers=[...ly],e.nodes))if(i.domId=lS(i.id),void 0!==i.label&&"text"===i.labelType&&(i.label=lN(i.label)),i.stereotype&&(i.stereotype=lN(i.stereotype)),i.isGroup||"usecaseJsonTable"!==i.shape||(i.jsonRows=i.jsonRows?.map(e=>({...e,key:lN(e.key),value:lN(e.value)}))),!i.isGroup&&("usecaseEllipse"===i.shape||"rect"===i.shape)&&i.stereotype){let e=i.label??lN(i.id);i.label=`\xab${lv(i.stereotype)}\xbb<br/>${"text"===i.labelType?lv(e):e}`,i.labelType="markdown",i.hasFoldedStereotype=!0,delete i.stereotype}for(let t of e.edges)void 0!==t.label&&"text"===t.labelType&&(t.label=lN(t.label));return e},"prepareUsecaseLayoutData"),lC=(0,I.K)((e,t,i)=>{for(let s of t.nodes){let n="string"==typeof s.domId?s.domId:lL(t.diagramId,s.id),r=e.select(`#${n}`),a=s.isGroup?"boundary":lA[s.shape]?"actor":"note"===s.shape?"note":"usecaseJsonTable"===s.shape?"json":"usecase",o=i.nodes.get(s.id)??s.id;if(r.attr("data-usecase-id",s.id).attr("data-usecase-kind",a).attr("role","img").attr("aria-label",o),!s.isGroup&&("usecaseEllipse"===s.shape||"rect"===s.shape)&&"hasFoldedStereotype"in s&&!0===s.hasFoldedStereotype){let e=r.node(),t=e?.querySelector(".nodeLabel"),i=t?.querySelector("p")??t,s=i?.firstChild;if(i&&s?.nodeType===3){let e=i.ownerDocument.createElement("span");e.className="usecase-stereotype",i.insertBefore(e,s),e.appendChild(s)}else e?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let s=new Map(t.edges.map(e=>[e.id,e]));e.selectAll('path[data-et="edge"]').each(function(){let e=s.get(this.getAttribute("data-id")??"");if(!e)return;let n=(0,as.Ltv)(this);n.attr("id",lL(t.diagramId,e.id)).attr("data-usecase-id",e.id).attr("data-usecase-kind",e.internal?"note-connector":"relationship"),e.internal?n.attr("aria-hidden","true"):n.attr("role","img").attr("aria-label",i.edges.get(e.id)??e.id)})},"annotateUsecaseElements"),l_=(0,I.K)((e,t)=>{e.style("--mermaid-usecase-actor-font-size",`${t.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",t.actorFontFamily).style("--mermaid-usecase-actor-font-weight",t.actorFontWeight).style("--mermaid-usecase-font-size",`${t.usecaseFontSize}px`).style("--mermaid-usecase-font-family",t.usecaseFontFamily).style("--mermaid-usecase-font-weight",t.usecaseFontWeight)},"applyUsecaseFonts"),lx=(0,I.K)(async(e,t,i,s)=>{v.R.info("Drawing usecase diagram (unified)",t);let{layout:n}=(0,N.D7)(),r=s.db,a=r.getData(),o=new Map(a.nodes.map(e=>[e.id,lO(e.label??e.id,e.labelType)])),l={nodes:new Map(a.nodes.map(e=>[e.id,e.isGroup?lR(e):lb("note"===e.shape?{...e,noteTargetLabel:o.get(e.noteTarget??"")}:e)])),edges:new Map(a.edges.map(e=>[e.id,lk({...e,sourceLabel:o.get(e.source)??e.sourceLabel,targetLabel:o.get(e.target)??e.targetLabel})]))},c=(0,L.A)(t,a.config.securityLevel);a.layoutAlgorithm=(0,O.q7)(n),lI(a,t),l_(c,a),await (0,O.XX)(a,c),lC(c,a,l);let h=a.diagramPadding;k._K.insertTitle(c,"usecaseDiagramTitleText",0,r.getDiagramTitle?.()??""),(0,S.P)(c,h,"usecaseDiagram",a.useMaxWidth),l_(c,a)},"draw"),lU=(0,I.K)(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),lM=(0,I.K)(e=>{let{theme:t,bkgColorArray:i,borderColorArray:s}=e;if(!(0,R.P1)(t,s))return"";let n=(0,N.zj)().usecase?.colorScheme==="rotate",r=(0,R.rq)(e.look),a="handDrawn"===r,o=(0,R.Ic)(i),l="";for(let e=0;e<(0,R.Hu)(s);e++){let t=s[e],c=o?`fill: ${i[e%i.length]};`:"",h=`[data-look="${r}"][data-color-id="color-${e}"]`;l+=`
58
-
59
- & ${h}.system-boundary rect.boundary-body,
60
- & ${h}.system-boundary rect.boundary-tab,
61
- & ${h}.system-boundary .boundary-body path,
62
- & ${h}.system-boundary .boundary-tab path {
63
- stroke: ${t};
64
- ${c}
65
- }
66
- `,n&&(l+=`
67
-
68
- /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
69
- the business variant.
70
-
71
- Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
72
- the body as a *pair* of paths, an outline stroked in the border colour and a hachure
73
- fill stroked in the background colour, with no class to tell them apart. Stroking
74
- both repaints the fill lines as border colour and the shape collapses into a solid
75
- block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
76
- theme's uniform colours, exactly as handDrawn flowchart nodes do. */
77
- & ${h}.usecase-element ellipse,
78
- & ${h}.usecase-element rect {
79
- stroke: ${t};
80
- ${c}
81
- }
82
-
83
- /* The business marker is a single classed path, so it can be reached safely by name --
84
- without it the marker keeps the uniform border beside a palette-coloured body. No
85
- \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
86
- & ${h}.usecase-element .usecase-business-marker {
87
- stroke: ${t};
88
- }
89
-
90
- /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
91
- group, never on its children, so the hollow variant's own \`fill="none"\` keeps
92
- winning and a hollow actor stays hollow. Same reason as above for not descending
93
- into the handDrawn paths. */
94
- & ${h}.usecase-actor .usecase-actor-shape,
95
- & ${h}.usecase-actor .usecase-actor-hollow,
96
- & ${h}.usecase-actor .usecase-actor-awesome,
97
- & ${h}.usecase-actor .usecase-actor-icon {
98
- stroke: ${t};
99
- ${c}
100
- }
101
- ${a?"":`
102
- /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
103
- ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
104
- and a value set directly on the child always beats one inherited from the parent,
105
- whatever the parent rule's specificity. So name the children too.
106
-
107
- Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
108
- outline path plus a hachure fill path stroked in the fill colour, indistinguishable
109
- in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
110
- \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
111
- & ${h}.usecase-actor .usecase-actor-glyph path,
112
- & ${h}.usecase-actor .usecase-actor-glyph circle {
113
- stroke: ${t};
114
- }
115
- `}
116
- `)}return l},"genColor"),lw={parser:lE,db:a$,renderer:{draw:lx},styles:(0,I.K)(e=>{let t=lU(e),i="handDrawn"===(0,R.rq)(e.look);return`
117
- ${lM(e)}
118
- & .usecase-actor {
119
- color: ${e.actorTextColor??e.primaryTextColor};
120
- }
121
-
122
- & .usecase-actor-shape,
123
- & .usecase-actor-hollow,
124
- & .usecase-actor-awesome,
125
- & .usecase-actor-icon {
126
- fill: ${t.actorBkg};
127
- stroke: ${t.actorBorder};
128
- stroke-width: 2px;
129
- }
130
- ${i?"":`
131
- /* The rule above colours the glyph group and lets its children inherit, which the neo
132
- look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
133
- the glyph's own paths, and a value set directly on a child always beats one inherited
134
- from its parent, whatever the parent rule's specificity. Since neo is the default look,
135
- without this every actor renders in the node border colour rather than the actor
136
- colour the rule above asks for.
137
-
138
- \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
139
- would otherwise be one attribute plus one class plus one element, leaving the winner to
140
- depend on which stylesheet is concatenated last.
141
-
142
- Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
143
- & .node.usecase-actor .usecase-actor-glyph path,
144
- & .node.usecase-actor .usecase-actor-glyph circle {
145
- stroke: ${t.actorBorder};
146
- }
147
- `}
148
- & .usecase-actor .nodeLabel,
149
- & .actor-label {
150
- color: ${e.actorTextColor??e.primaryTextColor};
151
- fill: ${e.actorTextColor??e.primaryTextColor};
152
- font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
153
- font-size: var(--mermaid-usecase-actor-font-size, 14px);
154
- font-weight: var(--mermaid-usecase-actor-font-weight, normal);
155
- }
156
-
157
- & .usecase-element ellipse,
158
- & .usecase-element rect,
159
- & .usecase-business ellipse,
160
- & .usecase-business rect {
161
- fill: ${t.bkg};
162
- stroke: ${t.border};
163
- stroke-width: 2px;
164
- }
165
- ${i?"":`
166
- /* The same interception the actor glyph hits, one element down: neo ships
167
- \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
168
- \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
169
- border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
170
- equivalent neo rule and is already correct; restating it here costs nothing and means
171
- the two forms cannot drift apart again.
172
-
173
- Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
174
- tie with it -- on a tie the later stylesheet would win, which is how neo took this in
175
- the first place. Skipped under handDrawn, where roughjs draws paths and neither element
176
- exists. */
177
- & [data-look="${(0,R.rq)(e.look)}"].node.usecase-element ellipse,
178
- & [data-look="${(0,R.rq)(e.look)}"].node.usecase-element rect {
179
- fill: ${t.bkg};
180
- stroke: ${t.border};
181
- }
182
-
183
- /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
184
- way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
185
- & [data-look="${(0,R.rq)(e.look)}"].node.usecase-element .usecase-business-marker {
186
- stroke: ${t.border};
187
- }
188
- `}
189
- & .usecase-element .nodeLabel,
190
- & .usecase-label {
191
- color: ${e.primaryTextColor};
192
- fill: ${e.primaryTextColor};
193
- font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
194
- font-size: var(--mermaid-usecase-font-size, 12px);
195
- font-weight: var(--mermaid-usecase-font-weight, normal);
196
- }
197
-
198
- & .usecase-stereotype,
199
- & .usecase-business-marker {
200
- color: ${e.primaryTextColor};
201
- fill: ${e.primaryTextColor};
202
- stroke: ${t.border};
203
- }
204
-
205
- & .system-boundary rect.boundary-body,
206
- & .system-boundary rect.boundary-tab,
207
- & .system-boundary-package-tab {
208
- fill: ${t.boundaryBkg};
209
- stroke: ${t.boundaryBorder};
210
- stroke-width: 1px;
211
- }
212
-
213
- & .system-boundary-title text {
214
- fill: ${e.titleColor??e.primaryTextColor};
215
- }
216
-
217
- /* Only the span, never the <p> inside it: the renderer puts a user-supplied
218
- 'color' on the span, and that has to stay inheritable by its children. */
219
- & .system-boundary-title span {
220
- color: ${e.titleColor??e.primaryTextColor};
221
- }
222
-
223
- & .usecase-note {
224
- fill: ${e.noteBkgColor};
225
- stroke: ${e.noteBorderColor};
226
- color: ${e.noteTextColor};
227
- }
228
-
229
- & .usecase-note .nodeLabel {
230
- color: ${e.noteTextColor};
231
- fill: ${e.noteTextColor};
232
- }
233
-
234
- & .usecase-json-table,
235
- & .usecase-json-table rect,
236
- & .usecase-json-cell {
237
- fill: ${e.mainBkg};
238
- stroke: ${e.nodeBorder??e.primaryColor};
239
- }
240
-
241
- & .usecase-json-title,
242
- & .usecase-json-key,
243
- & .usecase-json-value {
244
- color: ${e.primaryTextColor};
245
- fill: ${e.primaryTextColor};
246
- }
247
-
248
- & .relationship {
249
- fill: none;
250
- stroke: ${e.lineColor};
251
- }
252
-
253
- & .relationship-include,
254
- & .relationship-extend,
255
- & .relationship-note {
256
- stroke-dasharray: 3;
257
- }
258
-
259
- /* Include and extend are both dashed, which is a weak distinction at small sizes. The
260
- tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
261
- & .relationship-include {
262
- stroke: ${t.includeLine};
263
- }
264
-
265
- & .relationship-extend {
266
- stroke: ${t.extendLine};
267
- }
268
-
269
- & .relationship.edge-animation-fast,
270
- & .relationship.edge-animation-slow {
271
- stroke-linecap: round;
272
- }
273
-
274
- & .edgeLabel,
275
- & .edgeLabel p {
276
- background-color: ${e.edgeLabelBackground};
277
- }
278
-
279
- & .labelBkg {
280
- background-color: ${e.edgeLabelBackground};
281
- padding: 0 2px;
282
- }
283
-
284
- & .edgeLabel .label rect {
285
- fill: ${e.edgeLabelBackground};
286
- }
287
-
288
- & .relationship-label,
289
- & .edgeLabel {
290
- color: ${e.primaryTextColor};
291
- fill: ${e.primaryTextColor};
292
- font-family: ${e.fontFamily};
293
- font-size: 10px;
294
- font-weight: normal;
295
- }
296
-
297
- & .marker,
298
- & .marker.point,
299
- & .marker.circle,
300
- & .marker.cross {
301
- fill: ${e.lineColor};
302
- stroke: ${e.lineColor};
303
- }
304
-
305
- & .marker.extension {
306
- fill: ${e.mainBkg};
307
- stroke: ${e.lineColor};
308
- }
309
- `},"getStyles")}}}]);