@bkm016/basalt 0.1.1 → 0.1.3
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.
- package/README.md +16 -22
- package/chunk-06hdzq5n.js +2 -0
- package/chunk-09rj27b2.js +2 -0
- package/{chunk-qnr1f5pj.js → chunk-0y7ne3d0.js} +2 -2
- package/{chunk-vgvq3q12.js → chunk-10xzzn07.js} +2 -2
- package/{chunk-6qertm2t.js → chunk-1qpces5a.js} +1 -1
- package/{chunk-nt2gntad.js → chunk-1zdwrgd4.js} +1 -1
- package/{chunk-sh74qzvt.js → chunk-27gntzs5.js} +4 -4
- package/{chunk-1v7st27a.js → chunk-2esbgxps.js} +14 -14
- package/{chunk-exnn1867.js → chunk-362g64pd.js} +1 -1
- package/{chunk-1aspj1hn.js → chunk-3cjsd292.js} +2 -2
- package/chunk-5c9j8qe4.js +478 -0
- package/{chunk-8dxzqwq3.js → chunk-5j1krv9v.js} +1 -1
- package/{chunk-vkkj4awb.js → chunk-6hssbcgj.js} +1 -1
- package/{chunk-1b7gbe8g.js → chunk-75m78j7x.js} +2 -2
- package/{chunk-kfq8wyd3.js → chunk-8296hw9m.js} +1 -1
- package/{chunk-szat3vp4.js → chunk-8d46jtbj.js} +2 -2
- package/{chunk-qczbfccb.js → chunk-8tjad3r0.js} +4 -4
- package/{chunk-agntrqs9.js → chunk-97rzj7f6.js} +1 -1
- package/{chunk-k7w7ac9q.js → chunk-981f9dw8.js} +8 -8
- package/{chunk-xysny0ve.js → chunk-aefadsy6.js} +2 -2
- package/{chunk-jhd54p1b.js → chunk-bannb9xm.js} +1 -1
- package/{chunk-0qqb6v41.js → chunk-bxn5kmpz.js} +120 -120
- package/{chunk-a3tqx584.js → chunk-c7x1zq39.js} +1 -1
- package/{chunk-rv06x0kn.js → chunk-cjc90f84.js} +1 -1
- package/{chunk-x3dnb9sz.js → chunk-d2j735sd.js} +2 -2
- package/{chunk-yskm0hsy.js → chunk-d8gtbw9g.js} +1 -1
- package/{chunk-rm3kcxq9.js → chunk-fjtvjrkg.js} +13 -13
- package/{chunk-h6sw8fbt.js → chunk-fm0k0qtz.js} +1 -1
- package/{chunk-1yzt0qm0.js → chunk-fw2bpqmw.js} +1 -1
- package/{chunk-45cz26ap.js → chunk-gp7y0fja.js} +13 -13
- package/{chunk-2bb01ddq.js → chunk-gzxnene8.js} +1 -1
- package/{chunk-a8nyk4k9.js → chunk-hwr56pfj.js} +1 -1
- package/{chunk-0hbjv3y6.js → chunk-jwdb0ccj.js} +3 -3
- package/{chunk-kf8hq21a.js → chunk-k23t7vhs.js} +5 -5
- package/{chunk-bhqyxyap.js → chunk-k506w58v.js} +1 -1
- package/{chunk-44ek81ad.js → chunk-k6w6y71k.js} +2 -2
- package/chunk-m40gxwq4.js +5 -0
- package/chunk-m8vkwdgr.js +5 -0
- package/{chunk-f7egr55n.js → chunk-mvfsxdx6.js} +13 -13
- package/{chunk-pvncysbb.js → chunk-nbb9trwz.js} +1 -1
- package/{chunk-0szjy61m.js → chunk-pbcy6zdt.js} +1 -1
- package/chunk-pmqtkqsf.js +2 -0
- package/{chunk-hat3s3pr.js → chunk-pxsrqrd0.js} +1 -1
- package/{chunk-xsbxykr4.js → chunk-qe0teyn1.js} +1 -1
- package/{chunk-2zqny2sy.js → chunk-r7fpkb49.js} +1 -1
- package/{chunk-3m7qwfm3.js → chunk-rtzqqngy.js} +3 -3
- package/{chunk-6e49xsf5.js → chunk-shadcb9z.js} +2 -2
- package/{chunk-cv5wsd9m.js → chunk-t6zs4kw0.js} +2 -2
- package/{chunk-hcn9cf6v.js → chunk-v258nxcz.js} +1 -1
- package/{chunk-a6r4z44b.js → chunk-vk1gxk1t.js} +1 -1
- package/{chunk-s37s3k24.js → chunk-x1xss1d7.js} +2 -2
- package/{chunk-dakrpbe6.js → chunk-x4874m8e.js} +2 -2
- package/{chunk-wx7kdf0b.js → chunk-xfvvh1s5.js} +1 -1
- package/{chunk-0yytz0r1.js → chunk-y0m980k3.js} +5 -5
- package/{chunk-dhm42y04.js → chunk-y58ygzn9.js} +3 -3
- package/{chunk-2wkaw73s.js → chunk-y648fzx0.js} +5 -5
- package/{chunk-32at88hc.js → chunk-y7nma9rk.js} +1 -1
- package/{chunk-pmc3y1z8.js → chunk-ykens1hy.js} +1 -1
- package/{chunk-q8zx3kt6.js → chunk-z55bmysw.js} +1 -1
- package/{chunk-qx0m82rw.js → chunk-zmsgwr3s.js} +1 -1
- package/{chunk-501zkf9b.js → chunk-ztsjgssj.js} +1 -1
- package/compiled.js +5 -5
- package/package.json +1 -1
- package/ui-test-worker.js +63 -63
- package/web/{chunk-b4wbk7vc.js → chunk-0xc2c540.js} +3 -3
- package/web/{chunk-dt462hk9.js → chunk-0z0jycs8.js} +1 -1
- package/web/chunk-166qe5j6.js +2 -0
- package/web/chunk-1c95wfvq.js +1 -0
- package/web/{chunk-qnaqf0cr.js → chunk-23c1df7e.js} +1 -1
- package/web/{chunk-jrcyc9s9.js → chunk-24h1rfje.js} +1 -1
- package/web/{chunk-fscafg24.js → chunk-2hd1pe9w.js} +5 -5
- package/web/chunk-329rtxa9.js +1 -0
- package/web/{chunk-9yakxvjb.js → chunk-33qwz9bc.js} +2 -2
- package/web/{chunk-qd8bxxdj.js → chunk-3qjnwsph.js} +1 -1
- package/web/{chunk-p3b9crsa.js → chunk-47q4hmfp.js} +2 -2
- package/web/{chunk-y49fhfda.js → chunk-4fzj0azw.js} +1 -1
- package/web/{chunk-22a4ety5.js → chunk-5b2nw6j1.js} +1 -1
- package/web/{chunk-bgnnrpna.js → chunk-5hmfk69r.js} +4 -4
- package/web/{chunk-tqmwd9qp.js → chunk-5qqw2e0t.js} +1 -1
- package/web/{chunk-3jhyzmnf.js → chunk-61jahh35.js} +3 -3
- package/web/chunk-6gxf3vsg.js +1 -0
- package/web/{chunk-qefasa1j.js → chunk-6parf7sy.js} +1 -1
- package/web/{chunk-2m12wyrb.js → chunk-7520nrbb.js} +1 -1
- package/web/{chunk-9p12mgs6.js → chunk-7ba8vrfc.js} +1 -1
- package/web/{chunk-fm2ybfj5.js → chunk-7qxhk1kz.js} +4 -4
- package/web/{chunk-w880psmw.js → chunk-7v5rxabp.js} +1 -1
- package/web/{chunk-kdyjnwdx.js → chunk-7xk0ntav.js} +2 -2
- package/web/{chunk-q0p5xqe1.js → chunk-7yc083xj.js} +4 -4
- package/web/{chunk-b1pe46zz.js → chunk-89fkdgbp.js} +1 -1
- package/web/{chunk-v28fx2nd.js → chunk-8qgpfxkz.js} +1 -1
- package/web/{chunk-2ps6mepk.js → chunk-90xqeczk.js} +3 -3
- package/web/{chunk-fz06t6km.js → chunk-97b62pvb.js} +1 -1
- package/web/{chunk-a1z5qx1r.js → chunk-9a3q0jsh.js} +3 -3
- package/web/{chunk-xjxv8dg8.js → chunk-9bgey148.js} +4 -4
- package/web/{chunk-70qwwwak.js → chunk-9xh96b33.js} +1 -1
- package/web/{chunk-e6jxqbv7.js → chunk-a5sg33w2.js} +1 -1
- package/web/chunk-a91vxtx4.js +1 -0
- package/web/{chunk-pf2ab8p8.js → chunk-acybsx44.js} +1 -1
- package/web/chunk-agec7jj4.js +1 -0
- package/web/{chunk-e53wfgb8.js → chunk-axkyft9f.js} +1 -1
- package/web/{chunk-bc78qf1m.js → chunk-b0a8nbj0.js} +5 -5
- package/web/chunk-c516cghj.js +1 -0
- package/web/chunk-cqp1d4p0.js +1 -0
- package/web/{chunk-05w4fyzc.js → chunk-cwtdnacf.js} +1 -1
- package/web/chunk-dg1vas6z.js +8 -0
- package/web/{chunk-0mrkjnte.js → chunk-ds7srg4p.js} +1 -1
- package/web/{chunk-bjkc94mv.js → chunk-ep37qp12.js} +1 -1
- package/web/{chunk-90kp4pnz.js → chunk-eqsd8zta.js} +1 -1
- package/web/{chunk-ss1bcb0n.js → chunk-es28k2t7.js} +2 -2
- package/web/chunk-fc0nx23g.js +1 -0
- package/web/chunk-fhnypcrm.js +1139 -0
- package/web/{chunk-2scce33n.js → chunk-fv60p68p.js} +1 -1
- package/web/{chunk-rpmpttbk.js → chunk-g46f421r.js} +1 -1
- package/web/{chunk-2msj52w6.js → chunk-h18tnrf2.js} +1 -1
- package/web/{chunk-a5x2zveg.js → chunk-h288yd5w.js} +1 -1
- package/web/{chunk-8p4tc9f4.js → chunk-hszjc2ny.js} +3 -3
- package/web/{chunk-4ks96e4r.js → chunk-j0bwwc1g.js} +1 -1
- package/web/{chunk-9dxjafp2.js → chunk-jqa39f8t.js} +2 -2
- package/web/chunk-jvbbrnpa.js +1 -0
- package/web/{chunk-wptv8atc.js → chunk-jzfd7cyh.js} +1 -1
- package/web/chunk-ka9ak8wr.js +1 -0
- package/web/{chunk-9an7cjd9.js → chunk-mb4qx9hy.js} +2 -2
- package/web/chunk-mnjd59jk.js +1 -0
- package/web/{chunk-xbty0rv7.js → chunk-mwj9tpkz.js} +1 -1
- package/web/{chunk-taynqrgq.js → chunk-n8gfjj9a.js} +2 -2
- package/web/{chunk-20q90epj.js → chunk-n8sky2q6.js} +1 -1
- package/web/chunk-ng0nbfhh.js +1 -0
- package/web/chunk-nz9nxk48.js +1 -0
- package/web/{chunk-0vt9fg48.js → chunk-p9hsd3rn.js} +2 -2
- package/web/chunk-phw908hn.js +1 -0
- package/web/chunk-pjmmma1k.js +1 -0
- package/web/chunk-q7yn4m3t.js +1 -0
- package/web/chunk-qh15dxav.css +1 -0
- package/web/chunk-qnhqexe0.js +1 -0
- package/web/{chunk-bj90t5gh.js → chunk-rcx1aee5.js} +4 -4
- package/web/chunk-rjqj6ffe.js +1 -0
- package/web/{chunk-g4azyef7.js → chunk-rks7ksv3.js} +1 -1
- package/web/{chunk-q5ke7a33.js → chunk-sb1cjpq8.js} +1 -1
- package/web/{chunk-e32y85kx.js → chunk-sgvp8vge.js} +1 -1
- package/web/chunk-sjjwte12.js +1 -0
- package/web/{chunk-xrxne80b.js → chunk-sn9ecfvy.js} +1 -1
- package/web/{chunk-z7dcbxws.js → chunk-t7bwsdbr.js} +1 -1
- package/web/{chunk-fk0dh93x.js → chunk-tse9gvyq.js} +5 -5
- package/web/{chunk-a3verqw9.js → chunk-tx8240k4.js} +5 -5
- package/web/{chunk-dzwxgqgm.js → chunk-vd6y2pcm.js} +2 -2
- package/web/{chunk-5vw9rs4r.js → chunk-vpa55vje.js} +3 -3
- package/web/{chunk-y0m8hrwz.js → chunk-vymqrpm3.js} +77 -77
- package/web/{chunk-tmvakq7n.js → chunk-w7snhcyg.js} +4 -4
- package/web/{chunk-qh7265qw.js → chunk-wdtnhpd6.js} +2 -2
- package/web/{chunk-3ee04tmm.js → chunk-wmvd6j0b.js} +5 -5
- package/web/{chunk-yd46jhqv.js → chunk-xnq41dgs.js} +1 -1
- package/web/{chunk-45fzdcgz.js → chunk-xvsmtetz.js} +5 -5
- package/web/{chunk-ca682sm6.js → chunk-y3ajqthy.js} +14 -14
- package/web/{chunk-f26smjjf.js → chunk-yd1ez3wd.js} +1 -1
- package/web/chunk-yfbxtg5p.js +1 -0
- package/web/{chunk-4v8en1yw.js → chunk-ywp4s71k.js} +1 -1
- package/web/{chunk-gqw3f02j.js → chunk-z4x331rx.js} +5 -5
- package/web/{chunk-jwzd9tzk.js → chunk-z6bpamwq.js} +2 -2
- package/web/{chunk-hev4hq89.js → chunk-zmdnxn6m.js} +2 -2
- package/web/{icon-yx2p2pye.svg → icon-1wgy7kzy.svg} +13 -13
- package/web/icon.svg +13 -13
- package/web/index.html +2 -2
- package/web/install.sh +0 -0
- package/web/sw.js +9 -0
- package/worker.js +1 -1
- package/chunk-09vr609h.js +0 -2
- package/chunk-58vz2qsq.js +0 -2
- package/chunk-c25s4w6a.js +0 -5
- package/chunk-t057xfrt.js +0 -5
- package/chunk-wjd9fr23.js +0 -2
- package/chunk-zef13k3h.js +0 -471
- package/web/chunk-2pver6r4.js +0 -1
- package/web/chunk-37ajk6zg.js +0 -2
- package/web/chunk-4wkm9fda.js +0 -1
- package/web/chunk-amzgyy1k.js +0 -1
- package/web/chunk-cff5hcm8.js +0 -8
- package/web/chunk-esp1mmgr.js +0 -1
- package/web/chunk-ew3cgdtd.js +0 -1
- package/web/chunk-gjq1pxw3.js +0 -1
- package/web/chunk-h5ejbf6e.js +0 -1
- package/web/chunk-jjh5jvva.js +0 -1
- package/web/chunk-k5btcvbg.js +0 -1
- package/web/chunk-kpvgecwy.js +0 -1
- package/web/chunk-kq40ss39.js +0 -1
- package/web/chunk-q7dsnvpf.js +0 -1
- package/web/chunk-rg426vkf.js +0 -1
- package/web/chunk-ry9256r7.js +0 -1
- package/web/chunk-scpwc9ev.js +0 -1
- package/web/chunk-ssy07dd2.js +0 -1
- package/web/chunk-tgpbhzn9.js +0 -1
- package/web/chunk-vt40e1kp.js +0 -1136
- package/web/chunk-w53rba6g.js +0 -1
- package/web/chunk-w86n42dy.js +0 -1
- package/web/chunk-wtawdeej.css +0 -1
- package/web/chunk-zde7mj43.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e,r,D,b,O,C,S,E,T,A,I,L,s,p,N,ti,
|
|
1
|
+
import{e,r,D,b,O,C,S,E,T,A,I,L,s,p,N,ti,ce,ae,ie,ft,ge,ye}from"./chunk-vymqrpm3.js";import{he}from"./chunk-es28k2t7.js";import{se}from"./chunk-zmdnxn6m.js";function tt(t){if(console&&console.error)console.error(`Error: ${t}`)}function gt(t){if(console&&console.warn)console.warn(`Warning: ${t}`)}function At(t){let n=new Date().getTime(),i=t();return{time:new Date().getTime()-n,value:i}}function St(t){function n(){}n.prototype=t;let i=new n;function a(){return typeof i.bar}return a(),a(),t;(0,eval)(t)}function Gr(t){if(Wr(t))return t.LABEL;else return t.name}function Wr(t){return typeof t.LABEL==="string"&&t.LABEL!==""}class Ne{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),this.definition.forEach((n)=>{n.accept(t)})}}class W extends Ne{constructor(t){super([]);this.idx=1,Object.assign(this,xe(t))}set definition(t){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(t){t.visit(this)}}class Te extends Ne{constructor(t){super(t.definition);this.orgText="",Object.assign(this,xe(t))}}class j extends Ne{constructor(t){super(t.definition);this.ignoreAmbiguities=!1,Object.assign(this,xe(t))}}class K extends Ne{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class Z extends Ne{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class Q extends Ne{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class G extends Ne{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class q extends Ne{constructor(t){super(t.definition);this.idx=1,Object.assign(this,xe(t))}}class J extends Ne{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition);this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,xe(t))}}class F{constructor(t){this.idx=1,Object.assign(this,xe(t))}accept(t){t.visit(this)}}function Wt(t){return t.map(st)}function st(t){function n(i){return i.map(st)}if(t instanceof W){let i={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(typeof t.label==="string")i.label=t.label;return i}else if(t instanceof j)return{type:"Alternative",definition:n(t.definition)};else if(t instanceof K)return{type:"Option",idx:t.idx,definition:n(t.definition)};else if(t instanceof Z)return{type:"RepetitionMandatory",idx:t.idx,definition:n(t.definition)};else if(t instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:st(new F({terminalType:t.separator})),definition:n(t.definition)};else if(t instanceof q)return{type:"RepetitionWithSeparator",idx:t.idx,separator:st(new F({terminalType:t.separator})),definition:n(t.definition)};else if(t instanceof G)return{type:"Repetition",idx:t.idx,definition:n(t.definition)};else if(t instanceof J)return{type:"Alternation",idx:t.idx,definition:n(t.definition)};else if(t instanceof F){let i={type:"Terminal",name:t.terminalType.name,label:Gr(t.terminalType),idx:t.idx};if(typeof t.label==="string")i.terminalLabel=t.label;let a=t.terminalType.PATTERN;if(t.terminalType.PATTERN)i.pattern=a instanceof RegExp?a.source:a;return i}else if(t instanceof Te)return{type:"Rule",name:t.name,orgText:t.orgText,definition:n(t.definition)};else throw Error("non exhaustive match")}function xe(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0))}class Ae{visit(t){let n=t;switch(n.constructor){case W:return this.visitNonTerminal(n);case j:return this.visitAlternative(n);case K:return this.visitOption(n);case Z:return this.visitRepetitionMandatory(n);case Q:return this.visitRepetitionMandatoryWithSeparator(n);case q:return this.visitRepetitionWithSeparator(n);case G:return this.visitRepetition(n);case J:return this.visitAlternation(n);case F:return this.visitTerminal(n);case Te:return this.visitRule(n);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}}function vs(t){return t instanceof j||t instanceof K||t instanceof G||t instanceof Z||t instanceof Q||t instanceof q||t instanceof F||t instanceof Te}function je(t,n=[]){if(t instanceof K||t instanceof G||t instanceof q)return!0;if(t instanceof J)return t.definition.some((a)=>je(a,n));else if(t instanceof W&&n.includes(t))return!1;else if(t instanceof Ne){if(t instanceof W)n.push(t);return t.definition.every((a)=>je(a,n))}else return!1}function Ms(t){return t instanceof J}function Se(t){if(t instanceof W)return"SUBRULE";else if(t instanceof K)return"OPTION";else if(t instanceof J)return"OR";else if(t instanceof Z)return"AT_LEAST_ONE";else if(t instanceof Q)return"AT_LEAST_ONE_SEP";else if(t instanceof q)return"MANY_SEP";else if(t instanceof G)return"MANY";else if(t instanceof F)return"CONSUME";else throw Error("non exhaustive match")}class $e{walk(t,n=[]){t.definition.forEach((i,a)=>{let o=t.definition.slice(a+1);if(i instanceof W)this.walkProdRef(i,o,n);else if(i instanceof F)this.walkTerminal(i,o,n);else if(i instanceof j)this.walkFlat(i,o,n);else if(i instanceof K)this.walkOption(i,o,n);else if(i instanceof Z)this.walkAtLeastOne(i,o,n);else if(i instanceof Q)this.walkAtLeastOneSep(i,o,n);else if(i instanceof q)this.walkManySep(i,o,n);else if(i instanceof G)this.walkMany(i,o,n);else if(i instanceof J)this.walkOr(i,o,n);else throw Error("non exhaustive match")})}walkTerminal(t,n,i){}walkProdRef(t,n,i){}walkFlat(t,n,i){let a=n.concat(i);this.walk(t,a)}walkOption(t,n,i){let a=n.concat(i);this.walk(t,a)}walkAtLeastOne(t,n,i){let a=[new K({definition:t.definition})].concat(n,i);this.walk(t,a)}walkAtLeastOneSep(t,n,i){let a=Nn(t,n,i);this.walk(t,a)}walkMany(t,n,i){let a=[new K({definition:t.definition})].concat(n,i);this.walk(t,a)}walkManySep(t,n,i){let a=Nn(t,n,i);this.walk(t,a)}walkOr(t,n,i){let a=n.concat(i);t.definition.forEach((o)=>{let l=new j({definition:[o]});this.walk(l,a)})}}function Nn(t,n,i){return[new K({definition:[new F({terminalType:t.separator})].concat(t.definition)})].concat(n,i)}function Ke(t){if(t instanceof W)return Ke(t.referencedRule);else if(t instanceof F)return Vr(t);else if(vs(t))return jr(t);else if(Ms(t))return Kr(t);else throw Error("non exhaustive match")}function jr(t){let n=[],i=t.definition,a=0,o=i.length>a,l,h=!0;while(o&&h)l=i[a],h=je(l),n=n.concat(Ke(l)),a=a+1,o=i.length>a;return[...new Set(n)]}function Kr(t){let n=t.definition.map((i)=>Ke(i));return[...new Set(n.flat())]}function Vr(t){return[t.terminalType]}var jt="_~IN~_";class In extends $e{constructor(t){super();this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,n,i){}walkProdRef(t,n,i){let a=zr(t.referencedRule,t.idx)+this.topProd.name,o=n.concat(i),l=new j({definition:o}),h=Ke(l);this.follows[a]=h}}function kn(t){let n={};return t.forEach((i)=>{let a=new In(i).startWalking();Object.assign(n,a)}),n}function zr(t,n){return t.name+n+jt}function v(t){return t.charCodeAt(0)}function Kt(t,n){if(Array.isArray(t))t.forEach(function(i){n.push(i)});else n.push(t)}function nt(t,n){if(t[n]===!0)throw"duplicate flag "+n;let i=t[n];t[n]=!0}function Ve(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function Rt(){throw Error("Internal Error - Should never get here!")}function ws(t){return t.type==="Character"}var yt=[];for(let t=v("0");t<=v("9");t++)yt.push(t);var Ot=[v("_")].concat(yt);for(let t=v("a");t<=v("z");t++)Ot.push(t);for(let t=v("A");t<=v("Z");t++)Ot.push(t);var Us=[v(" "),v("\f"),v(`
|
|
2
2
|
`),v("\r"),v("\t"),v("\v"),v("\t"),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v("\u2028"),v("\u2029"),v(" "),v(" "),v(" "),v("\uFEFF")];var Hr=/[0-9a-fA-F]/,Vt=/[0-9]/,Xr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");let n=this.disjunction();this.consumeChar("/");let i={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(i,"global");break;case"i":nt(i,"ignoreCase");break;case"m":nt(i,"multiLine");break;case"u":nt(i,"unicode");break;case"y":nt(i,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:i,value:n,loc:this.loc(0)}}disjunction(){let t=[],n=this.idx;t.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(n)}}alternative(){let t=[],n=this.idx;while(this.isTerm())t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(n)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let n;switch(this.popChar()){case"=":n="Lookahead";break;case"!":n="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":n="Lookbehind";break;case"!":n="NegativeLookbehind"}break}}Ve(n);let i=this.disjunction();return this.consumeChar(")"),{type:n,value:i,loc:this.loc(t)}}return Rt()}quantifier(t=!1){let n=void 0,i=this.idx;switch(this.popChar()){case"*":n={atLeast:0,atMost:1/0};break;case"+":n={atLeast:1,atMost:1/0};break;case"?":n={atLeast:0,atMost:1};break;case"{":let a=this.integerIncludingZero();switch(this.popChar()){case"}":n={atLeast:a,atMost:a};break;case",":let o;if(this.isDigit())o=this.integerIncludingZero(),n={atLeast:a,atMost:o};else n={atLeast:a,atMost:1/0};this.consumeChar("}");break}if(t===!0&&n===void 0)return;Ve(n);break}if(t===!0&&n===void 0)return;if(Ve(n)){if(this.peekChar(0)==="?")this.consumeChar("?"),n.greedy=!1;else n.greedy=!0;return n.type="Quantifier",n.loc=this.loc(i),n}}atom(){let t,n=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group();break}if(t===void 0&&this.isPatternCharacter())t=this.patternCharacter();if(Ve(t)){if(t.loc=this.loc(n),this.isQuantifier())t.quantifier=this.quantifier();return t}return Rt()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[v(`
|
|
3
3
|
`),v("\r"),v("\u2028"),v("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let t,n=!1;switch(this.popChar()){case"d":t=yt;break;case"D":t=yt,n=!0;break;case"s":t=Us;break;case"S":t=Us,n=!0;break;case"w":t=Ot;break;case"W":t=Ot,n=!0;break}if(Ve(t))return{type:"Set",value:t,complement:n};return Rt()}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=v("\f");break;case"n":t=v(`
|
|
4
4
|
`);break;case"r":t=v("\r");break;case"t":t=v("\t");break;case"v":t=v("\v");break}if(Ve(t))return{type:"Character",value:t};return Rt()}controlLetterEscapeAtom(){this.consumeChar("c");let t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:v("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let t=this.popChar();return{type:"Character",value:v(t)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
@@ -50,14 +50,14 @@ a boolean 2nd argument is no longer supported`);this.config=Object.assign({},It,
|
|
|
50
50
|
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
51
51
|
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{St(this)})})}tokenize(t,n=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let a=this.lexerDefinitionErrors.map((o)=>o.message).join(`-----------------------
|
|
52
52
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
53
|
-
`+a)}return this.tokenizeInternal(t,n)}tokenizeInternal(t,n){let i,a,o,l,h,u,c,d,f,m,R,y,U,P,M,x=t,_=x.length,g=0,w=0,te=this.hasCustom?0:Math.floor(t.length/10),de=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let
|
|
54
|
-
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(t,Hn))i.CATEGORIES=t[Hn];if(Pe([i]),Object.hasOwn(t,Xn))i.LABEL=t[Xn];if(Object.hasOwn(t,Yn))i.GROUP=t[Yn];if(Object.hasOwn(t,Jn))i.POP_MODE=t[Jn];if(Object.hasOwn(t,qn))i.PUSH_MODE=t[qn];if(Object.hasOwn(t,Zn))i.LONGER_ALT=t[Zn];if(Object.hasOwn(t,Qn))i.LINE_BREAKS=t[Qn];if(Object.hasOwn(t,ei))i.START_CHARS_HINT=t[ei];return i}var
|
|
53
|
+
`+a)}return this.tokenizeInternal(t,n)}tokenizeInternal(t,n){let i,a,o,l,h,u,c,d,f,m,R,y,U,P,M,x=t,_=x.length,g=0,w=0,te=this.hasCustom?0:Math.floor(t.length/10),de=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let ne=0;ne<this.cachedGroupKeys.length;ne++)et[this.cachedGroupKeys[ne]]=[];let Br=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],mt=[],Et=[],yn=[];Object.freeze(yn);let Tt=!1,$r=(ne)=>{if(Et.length===1&&ne.tokenType.PUSH_MODE===void 0){let Le=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ne);pt.push({offset:ne.startOffset,line:ne.startLine,column:ne.startColumn,length:ne.image.length,message:Le})}else{Et.pop();let Le=Et.at(-1);We=this.patternIdxToConfig[Le],mt=this.charCodeToPatternIdxToConfig[Le],Cs=We.length;let bs=this.canModeBeOptimized[Le]&&this.config.safeMode===!1;if(mt&&bs)Tt=!0;else Tt=!1}};function On(ne){Et.push(ne),mt=this.charCodeToPatternIdxToConfig[ne],We=this.patternIdxToConfig[ne],Cs=We.length;let Le=this.canModeBeOptimized[ne]&&this.config.safeMode===!1;if(mt&&Le)Tt=!0;else Tt=!1}On.call(this,n);let Oe,Ln=this.config.recoveryEnabled;while(g<_){u=null,f=-1;let ne=x.charCodeAt(g),Le;if(Tt){let le=ve(ne),Ee=mt[le];Le=Ee!==void 0?Ee:yn}else Le=We;let bs=Le.length;for(i=0;i<bs;i++){Oe=Le[i];let le=Oe.pattern;switch(c=null,Oe.matchType){case Zt:if(ne===Oe.short)f=1,u=le;break;case Nt:if(M=le.exec(x,g,de,et),M!==null){if(u=M[0],f=u.length,M.payload!==void 0)c=M.payload}else u=null;break;case es:{let Ee=Oe.asciiClass;if(Ee[ne]!==1){le.lastIndex=0;break}let fe=g+1;while(Ee[x.charCodeAt(fe)]===1)fe++;f=fe-g,le.lastIndex=fe;break}case Qt:le.lastIndex=g,f=this.matchLength(le,t,g);break}if(f!==-1){if(h=Oe.longerAlt,h!==void 0){u=t.substring(g,g+f);let Ee=h.length;for(o=0;o<Ee;o++){let fe=We[h[o]],we=fe.pattern;if(d=null,fe.matchType===Nt)if(M=we.exec(x,g,de,et),M!==null){if(l=M[0],M.payload!==void 0)d=M.payload}else l=null;else we.lastIndex=g,l=this.match(we,t,g);if(l&&l.length>u.length){u=l,f=l.length,c=d,Oe=fe;break}}}break}}if(f!==-1){if(m=Oe.group,m!==void 0)if(u=u!==null?u:t.substring(g,g+f),R=Oe.tokenTypeIdx,y=this.createTokenInstance(u,g,R,Oe.tokenType,Me,_e,f),this.handlePayload(y,c),m===!1)w=this.addToken(de,w,y);else et[m].push(y);if(Br===!0&&Oe.canLineTerminator===!0){let le=0,Ee,fe;ks.lastIndex=0;do if(u=u!==null?u:t.substring(g,g+f),Ee=ks.test(u),Ee===!0)fe=ks.lastIndex-1,le++;while(Ee===!0);if(le!==0)Me=Me+le,_e=f-fe,this.updateTokenEndLineColumnLocation(y,m,fe,le,Me,_e,f);else _e=this.computeNewColumn(_e,f)}else _e=this.computeNewColumn(_e,f);g=g+f,this.handleModes(Oe,$r,On,y)}else{let le=g,Ee=Me,fe=_e,we=Ln===!1;while(we===!1&&g<_){g++;for(a=0;a<Cs;a++){let _s=We[a],xs=_s.pattern;switch(_s.matchType){case Zt:if(x.charCodeAt(g)===_s.short)we=!0;break;case Nt:we=xs.exec(x,g,de,et)!==null;break;case es:case Qt:xs.lastIndex=g,we=xs.exec(t)!==null;break}if(we===!0)break}}if(U=g-le,_e=this.computeNewColumn(_e,U),P=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(x,le,U,Ee,fe,Et.at(-1)),pt.push({offset:le,line:Ee,column:fe,length:U,message:P}),Ln===!1)break}}if(!this.hasCustom)de.length=w;return{tokens:de,groups:et,errors:pt}}handleModes(t,n,i,a){if(t.pop===!0){let o=t.push;if(n(a),o!==void 0)i.call(this,o)}else if(t.push!==void 0)i.call(this,t.push)}updateTokenEndLineColumnLocation(t,n,i,a,o,l,h){let u,c;if(n!==void 0){if(u=i===h-1,c=u?-1:0,!(a===1&&u===!0))t.endLine=o+c,t.endColumn=l-1+-c}}computeNewColumn(t,n){return t+n}createOffsetOnlyToken(t,n,i,a){return{image:t,startOffset:n,tokenTypeIdx:i,tokenType:a}}createStartOnlyToken(t,n,i,a,o,l){return{image:t,startOffset:n,startLine:o,startColumn:l,tokenTypeIdx:i,tokenType:a}}createFullToken(t,n,i,a,o,l,h){return{image:t,startOffset:n,endOffset:n+h-1,startLine:o,endLine:o,startColumn:l,endColumn:l+h-1,tokenTypeIdx:i,tokenType:a}}addTokenUsingPush(t,n,i){return t.push(i),n}addTokenUsingMemberAccess(t,n,i){return t[n]=i,n++,n}handlePayloadNoCustom(t,n){}handlePayloadWithCustom(t,n){if(n!==null)t.payload=n}match(t,n,i){if(t.test(n)===!0)return n.substring(i,t.lastIndex);return null}matchLength(t,n,i){if(t.test(n)===!0)return t.lastIndex-i;return-1}}z.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";z.NA=/NOT_APPLICABLE/;function Ye(t){if(Gs(t))return t.LABEL;else return t.name}function Gs(t){return typeof t.LABEL==="string"&&t.LABEL!==""}var Oa="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function k(t){return La(t)}function La(t){let n=t.pattern,i={};if(i.name=t.name,n!==void 0)i.PATTERN=n;if(Object.hasOwn(t,Oa))throw`The parent property is no longer supported.
|
|
54
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(t,Hn))i.CATEGORIES=t[Hn];if(Pe([i]),Object.hasOwn(t,Xn))i.LABEL=t[Xn];if(Object.hasOwn(t,Yn))i.GROUP=t[Yn];if(Object.hasOwn(t,Jn))i.POP_MODE=t[Jn];if(Object.hasOwn(t,qn))i.PUSH_MODE=t[qn];if(Object.hasOwn(t,Zn))i.LONGER_ALT=t[Zn];if(Object.hasOwn(t,Qn))i.LINE_BREAKS=t[Qn];if(Object.hasOwn(t,ei))i.START_CHARS_HINT=t[ei];return i}var Re=k({name:"EOF",pattern:z.NA});Pe([Re]);function qe(t,n,i,a,o,l,h,u){return{image:n,startOffset:i,endOffset:a,startLine:o,endLine:l,startColumn:h,endColumn:u,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function kt(t,n){return Ue(t,n)}var ts={buildMismatchTokenMessage({expected:t,actual:n,previous:i,ruleName:a}){return`Expecting ${Gs(t)?`--> ${Ye(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${n.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:n}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:n,previous:i,customUserDescription:a,ruleName:o}){let u=`
|
|
55
55
|
but found: '`+n[0].image+"'";if(a)return"Expecting: "+a+u;else return`Expecting: one of these possible Token sequences:
|
|
56
56
|
${t.reduce((R,y)=>R.concat(y),[]).map((R)=>`[${R.map((y)=>Ye(y)).join(", ")}]`).map((R,y)=>` ${y+1}. ${R}`).join(`
|
|
57
57
|
`)}`+u},buildEarlyExitMessage({expectedIterationPaths:t,actual:n,customUserDescription:i,ruleName:a}){let h=`
|
|
58
58
|
but found: '`+n[0].image+"'";if(i)return"Expecting: "+i+h;else return`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
59
59
|
<${t.map((d)=>`[${d.map((f)=>Ye(f)).join(",")}]`).join(" ,")}>`+h}};Object.freeze(ts);var si={buildRuleNotFoundError(t,n){return"Invalid grammar, reference to a rule which is not defined: ->"+n.nonTerminalName+`<-
|
|
60
|
-
inside top level rule: ->`+t.name+"<-"}},Ce={buildDuplicateFoundError(t,n){function i(f){if(f instanceof F)return f.terminalType.name;else if(f instanceof W)return f.nonTerminalName;else return""}let a=t.name,o=n[0],l=o.idx,h=
|
|
60
|
+
inside top level rule: ->`+t.name+"<-"}},Ce={buildDuplicateFoundError(t,n){function i(f){if(f instanceof F)return f.terminalType.name;else if(f instanceof W)return f.nonTerminalName;else return""}let a=t.name,o=n[0],l=o.idx,h=Se(o),u=i(o),c=l>0,d=`->${h}${c?l:""}<- ${u?`with argument: ->${u}<-`:""}
|
|
61
61
|
appears more than once (${n.length} times) in the top level rule: ->${a}<-.
|
|
62
62
|
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
63
63
|
`;return d=d.replace(/[ \t]+/g," "),d=d.replace(/\s\s+/g,`
|
|
@@ -74,7 +74,7 @@ For Further details.`},buildAlternationAmbiguityError(t){let n=t.alternation.idx
|
|
|
74
74
|
Only the last alternative may be empty.
|
|
75
75
|
`;else{let o=t.prefixPath.map((l)=>Ye(l)).join(", ");a+=`<${o}> may appears as a prefix path in all these alternatives.
|
|
76
76
|
`}return a+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
77
|
-
For Further details.`,a},buildEmptyRepetitionError(t){let n=
|
|
77
|
+
For Further details.`,a},buildEmptyRepetitionError(t){let n=Se(t.repetition);if(t.repetition.idx!==0)n+=t.repetition.idx;return`The repetition <${n}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
|
|
78
78
|
This could lead to an infinite loop.`},buildTokenNameError(t){return"deprecated"},buildEmptyAlternationError(t){return`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
|
|
79
79
|
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(t){return`An Alternation cannot have more than 256 alternatives:
|
|
80
80
|
<OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
|
|
@@ -83,39 +83,39 @@ rule: <${n}> can be invoked from itself (directly or indirectly)
|
|
|
83
83
|
without consuming any Tokens. The grammar path that causes this is:
|
|
84
84
|
${a}
|
|
85
85
|
To fix this refactor your grammar to remove the left recursion.
|
|
86
|
-
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let n;if(t.topLevelRule instanceof Ae)n=t.topLevelRule.name;else n=t.topLevelRule;return`Duplicate definition, rule: ->${n}<- is already defined in the grammar: ->${t.grammarName}<-`}};function ni(t,n){let i=new ii(t,n);return i.resolveRefs(),i.errors}class ii extends Se{constructor(t,n){super();this.nameToTopRule=t,this.errMsgProvider=n,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((t)=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let n=this.nameToTopRule[t.nonTerminalName];if(!n){let i=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:i,type:ne.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}else t.referencedRule=n}}class ri extends $e{constructor(t,n){super();this.topProd=t,this.path=n,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,n=[]){if(!this.found)super.walk(t,n)}walkProdRef(t,n,i){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let a=n.concat(i);this.updateExpectedNext(),this.walk(t.referencedRule,a)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ri{constructor(t,n){super(t,n);this.path=n,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,n,i){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let a=n.concat(i),o=new j({definition:a});this.possibleTokTypes=Ke(o),this.found=!0}}}class Ct extends $e{constructor(t,n){super();this.topRule=t,this.occurrence=n,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends Ct{walkMany(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkMany(t,n,i)}}class ss extends Ct{walkManySep(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkManySep(t,n,i)}}class Ks extends Ct{walkAtLeastOne(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkAtLeastOne(t,n,i)}}class ns extends Ct{walkAtLeastOneSep(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkAtLeastOneSep(t,n,i)}}function is(t,n,i=[]){i=[...i];let a=[],o=0;function l(u){return u.concat(t.slice(o+1))}function h(u){let c=is(l(u),n,i);return a.concat(c)}while(i.length<n&&o<t.length){let u=t[o];if(u instanceof j)return h(u.definition);else if(u instanceof W)return h(u.definition);else if(u instanceof K)a=h(u.definition);else if(u instanceof Z){let c=u.definition.concat([new G({definition:u.definition})]);return h(c)}else if(u instanceof Q){let c=[new j({definition:u.definition}),new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})];return h(c)}else if(u instanceof q){let c=u.definition.concat([new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})]);a=h(c)}else if(u instanceof G){let c=u.definition.concat([new G({definition:u.definition})]);a=h(c)}else if(u instanceof J)return u.definition.forEach((c)=>{if(c.definition.length!==0)a=h(c.definition)}),a;else if(u instanceof F)i.push(u.terminalType);else throw Error("non exhaustive match");o++}return a.push({partialPath:i,suffixDef:t.slice(o)}),a}function ai(t,n,i,a){let l=["EXIT_NONE_TERMINAL"],h="EXIT_ALTERNATIVE",u=!1,c=n.length,d=c-a-1,f=[],m=[];m.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let R=m.pop();if(R==="EXIT_ALTERNATIVE"){if(u&&m.at(-1).idx<=d)m.pop();continue}let{def:y,idx:U,ruleStack:P,occurrenceStack:M}=R;if(y.length===0)continue;let x=y[0];if(x==="EXIT_NONE_TERMINAL"){let _={idx:U,def:y.slice(1),ruleStack:P.slice(0,-1),occurrenceStack:M.slice(0,-1)};m.push(_)}else if(x instanceof F)if(U<c-1){let _=U+1,g=n[_];if(i(g,x.terminalType)){let w={idx:_,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(w)}}else if(U===c-1)f.push({nextTokenType:x.terminalType,nextTokenOccurrence:x.idx,ruleStack:P,occurrenceStack:M}),u=!0;else throw Error("non exhaustive match");else if(x instanceof W){let _=[...P];_.push(x.nonTerminalName);let g=[...M];g.push(x.idx);let w={idx:U,def:x.definition.concat(l,y.slice(1)),ruleStack:_,occurrenceStack:g};m.push(w)}else if(x instanceof K){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g={idx:U,def:x.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M};m.push(g)}else if(x instanceof Z){let _=new G({definition:x.definition,idx:x.idx}),g=x.definition.concat([_],y.slice(1)),w={idx:U,def:g,ruleStack:P,occurrenceStack:M};m.push(w)}else if(x instanceof Q){let _=new F({terminalType:x.separator}),g=new G({definition:[_].concat(x.definition),idx:x.idx}),w=x.definition.concat([g],y.slice(1)),te={idx:U,def:w,ruleStack:P,occurrenceStack:M};m.push(te)}else if(x instanceof q){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g=new F({terminalType:x.separator}),w=new G({definition:[g].concat(x.definition),idx:x.idx}),te=x.definition.concat([w],y.slice(1)),de={idx:U,def:te,ruleStack:P,occurrenceStack:M};m.push(de)}else if(x instanceof G){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g=new G({definition:x.definition,idx:x.idx}),w=x.definition.concat([g],y.slice(1)),te={idx:U,def:w,ruleStack:P,occurrenceStack:M};m.push(te)}else if(x instanceof J)for(let _=x.definition.length-1;_>=0;_--){let g=x.definition[_],w={idx:U,def:g.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M};m.push(w),m.push("EXIT_ALTERNATIVE")}else if(x instanceof j)m.push({idx:U,def:x.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M});else if(x instanceof Ae)m.push(Na(x,U,P,M));else throw Error("non exhaustive match")}return f}function Na(t,n,i,a){let o=[...i];o.push(t.name);let l=[...a];return l.push(1),{idx:n,def:t.definition,ruleStack:o,occurrenceStack:l}}var H;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(H||(H={}));function rs(t){if(t instanceof K||t==="Option")return H.OPTION;else if(t instanceof G||t==="Repetition")return H.REPETITION;else if(t instanceof Z||t==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(t instanceof Q||t==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(t instanceof q||t==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(t instanceof J||t==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function li(t,n,i,a,o,l){let h=bt(t,n,i),u=mi(h)?at:Ue;return l(h,a,u,o)}function ci(t,n,i,a,o,l){let h=_t(t,n,o,i),u=mi(h)?at:Ue;return l(h[0],u,a)}function hi(t,n,i,a){let o=t.length,l=t.every((h)=>h.every((u)=>u.length===1));if(n)return function(h){let u=h.map((c)=>c.GATE);for(let c=0;c<o;c++){let d=t[c],f=d.length,m=u[c];if(m!==void 0&&m.call(this)===!1)continue;e:for(let R=0;R<f;R++){let y=d[R],U=y.length;for(let P=0;P<U;P++){let M=this.LA_FAST(P+1);if(i(M,y[P])===!1)continue e}return c}}return};else if(l&&!a){let u=t.map((c)=>c.flat()).reduce((c,d,f)=>(d.forEach((m)=>{if(!(m.tokenTypeIdx in c))c[m.tokenTypeIdx]=f;m.categoryMatches.forEach((R)=>{if(!Object.hasOwn(c,R))c[R]=f})}),c),{});return function(){let c=this.LA_FAST(1);return u[c.tokenTypeIdx]}}else return function(){for(let h=0;h<o;h++){let u=t[h],c=u.length;e:for(let d=0;d<c;d++){let f=u[d],m=f.length;for(let R=0;R<m;R++){let y=this.LA_FAST(R+1);if(i(y,f[R])===!1)continue e}return h}}return}}function ui(t,n,i){let a=t.every((l)=>l.length===1),o=t.length;if(a&&!i){let l=t.flat();if(l.length===1&&l[0].categoryMatches.length===0){let u=l[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===u}}else{let h=l.reduce((u,c,d)=>(u[c.tokenTypeIdx]=!0,c.categoryMatches.forEach((f)=>{u[f]=!0}),u),[]);return function(){let u=this.LA_FAST(1);return h[u.tokenTypeIdx]===!0}}}else return function(){e:for(let l=0;l<o;l++){let h=t[l],u=h.length;for(let c=0;c<u;c++){let d=this.LA_FAST(c+1);if(n(d,h[c])===!1)continue e}return!0}return!1}}class di extends $e{constructor(t,n,i){super();this.topProd=t,this.targetOccurrence=n,this.targetProdType=i}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,n,i,a){if(t.idx===this.targetOccurrence&&this.targetProdType===n)return this.restDef=i.concat(a),!0;return!1}walkOption(t,n,i){if(!this.checkIsTarget(t,H.OPTION,n,i))super.walkOption(t,n,i)}walkAtLeastOne(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_MANDATORY,n,i))super.walkOption(t,n,i)}walkAtLeastOneSep(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_MANDATORY_WITH_SEPARATOR,n,i))super.walkOption(t,n,i)}walkMany(t,n,i){if(!this.checkIsTarget(t,H.REPETITION,n,i))super.walkOption(t,n,i)}walkManySep(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_WITH_SEPARATOR,n,i))super.walkOption(t,n,i)}}class zs extends Se{constructor(t,n,i){super();this.targetOccurrence=t,this.targetProdType=n,this.targetRef=i,this.result=[]}checkIsTarget(t,n){if(t.idx===this.targetOccurrence&&this.targetProdType===n&&(this.targetRef===void 0||t===this.targetRef))this.result=t.definition}visitOption(t){this.checkIsTarget(t,H.OPTION)}visitRepetition(t){this.checkIsTarget(t,H.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,H.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,H.ALTERNATION)}}function oi(t){let n=Array(t);for(let i=0;i<t;i++)n[i]=[];return n}function Vs(t){let n=[""];for(let i=0;i<t.length;i++){let a=t[i],o=[];for(let l=0;l<n.length;l++){let h=n[l];o.push(h+"_"+a.tokenTypeIdx);for(let u=0;u<a.categoryMatches.length;u++){let c="_"+a.categoryMatches[u];o.push(h+c)}}n=o}return n}function Ia(t,n,i){for(let a=0;a<t.length;a++){if(a===i)continue;let o=t[a];for(let l=0;l<n.length;l++){let h=n[l];if(o[h]===!0)return!1}}return!0}function pi(t,n){let i=t.map((h)=>is([h],1)),a=oi(i.length),o=i.map((h)=>{let u={};return h.forEach((c)=>{Vs(c.partialPath).forEach((f)=>{u[f]=!0})}),u}),l=i;for(let h=1;h<=n;h++){let u=l;l=oi(u.length);for(let c=0;c<u.length;c++){let d=u[c];for(let f=0;f<d.length;f++){let m=d[f].partialPath,R=d[f].suffixDef,y=Vs(m);if(Ia(o,y,c)||R.length===0||m.length===n){let P=a[c];if(as(P,m)===!1){P.push(m);for(let M=0;M<y.length;M++){let x=y[M];o[c][x]=!0}}}else{let P=is(R,h+1,m);l[c]=l[c].concat(P),P.forEach((M)=>{Vs(M.partialPath).forEach((_)=>{o[c][_]=!0})})}}}}return a}function bt(t,n,i,a){let o=new zs(t,H.ALTERNATION,a);return n.accept(o),pi(o.result,i)}function _t(t,n,i,a){let o=new zs(t,i);n.accept(o);let l=o.result,u=new di(n,t,i).startWalking(),c=new j({definition:l}),d=new j({definition:u});return pi([c,d],a)}function as(t,n){e:for(let i=0;i<t.length;i++){let a=t[i];if(a.length!==n.length)continue;for(let o=0;o<a.length;o++){let l=n[o],h=a[o];if((l===h||h.categoryMatchesMap[l.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function fi(t,n){return t.length<n.length&&t.every((i,a)=>{let o=n[a];return i===o||o.categoryMatchesMap[i.tokenTypeIdx]})}function mi(t){return t.every((n)=>n.every((i)=>i.every((a)=>a.categoryMatches.length===0)))}function Ei(t){return t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}).map((i)=>Object.assign({type:ne.CUSTOM_LOOKAHEAD_VALIDATION},i))}function Ti(t,n,i,a){let o=t.flatMap((c)=>ka(c,i)),l=Ma(t,n,i),h=t.flatMap((c)=>_a(c,i)),u=t.flatMap((c)=>ba(c,t,a,i));return o.concat(l,h,u)}function ka(t,n){let i=new Ai;t.accept(i);let a=i.allProductions,o=Object.groupBy(a,Ca),l=Object.fromEntries(Object.entries(o).filter(([u,c])=>c.length>1));return Object.values(l).map((u)=>{let c=u[0],d=n.buildDuplicateFoundError(t,u),f=Re(c),m={message:d,type:ne.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:f,occurrence:c.idx},R=gi(c);if(R)m.parameter=R;return m})}function Ca(t){return`${Re(t)}_#_${t.idx}_#_${gi(t)}`}function gi(t){if(t instanceof F)return t.terminalType.name;else if(t instanceof W)return t.nonTerminalName;else return""}class Ai extends Se{constructor(){super(...arguments);this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function ba(t,n,i,a){let o=[];if(n.reduce((h,u)=>{if(u.name===t.name)return h+1;return h},0)>1){let h=a.buildDuplicateRuleNameError({topLevelRule:t,grammarName:i});o.push({message:h,type:ne.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}function Si(t,n,i){let a=[],o;if(!n.includes(t))o=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${i}<-as it is not defined in any of the super grammars `,a.push({message:o,type:ne.INVALID_RULE_OVERRIDE,ruleName:t});return a}function Hs(t,n,i,a=[]){let o=[],l=os(n.definition);if(l.length===0)return[];else{let h=t.name;if(l.includes(t))o.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:a}),type:ne.LEFT_RECURSION,ruleName:h});let c=a.concat([t]),f=l.filter((m)=>!c.includes(m)).flatMap((m)=>{let R=[...a];return R.push(m),Hs(t,m,i,R)});return o.concat(f)}}function os(t){let n=[];if(t.length===0)return n;let i=t[0];if(i instanceof W)n.push(i.referencedRule);else if(i instanceof j||i instanceof K||i instanceof Z||i instanceof Q||i instanceof q||i instanceof G)n=n.concat(os(i.definition));else if(i instanceof J)n=i.definition.map((l)=>os(l.definition)).flat();else if(i instanceof F);else throw Error("non exhaustive match");let a=je(i),o=t.length>1;if(a&&o){let l=t.slice(1);return n.concat(os(l))}else return n}class ls extends Se{constructor(){super(...arguments);this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function Ri(t,n){let i=new ls;return t.accept(i),i.alternations.flatMap((l)=>l.definition.slice(0,-1).flatMap((u,c)=>{if(ai([u],[],Ue,1).length===0)return[{message:n.buildEmptyAlternationError({topLevelRule:t,alternation:l,emptyChoiceIdx:c}),type:ne.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:l.idx,alternative:c+1}];else return[]}))}function yi(t,n,i){let a=new ls;t.accept(a);let o=a.alternations;return o=o.filter((h)=>h.ignoreAmbiguities!==!0),o.flatMap((h)=>{let u=h.idx,c=h.maxLookahead||n,d=bt(u,t,c,h),f=xa(d,h,t,i),m=va(d,h,t,i);return f.concat(m)})}class Oi extends Se{constructor(){super(...arguments);this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function _a(t,n){let i=new ls;return t.accept(i),i.alternations.flatMap((l)=>{if(l.definition.length>255)return[{message:n.buildTooManyAlternativesError({topLevelRule:t,alternation:l}),type:ne.TOO_MANY_ALTS,ruleName:t.name,occurrence:l.idx}];else return[]})}function Li(t,n,i){let a=[];return t.forEach((o)=>{let l=new Oi;o.accept(l),l.allProductions.forEach((u)=>{let c=rs(u),d=u.maxLookahead||n,f=u.idx;if(_t(f,o,c,d)[0].flat().length===0){let y=i.buildEmptyRepetitionError({topLevelRule:o,repetition:u});a.push({message:y,type:ne.NO_NON_EMPTY_LOOKAHEAD,ruleName:o.name})}})}),a}function xa(t,n,i,a){let o=[];return t.reduce((u,c,d)=>{if(n.definition[d].ignoreAmbiguities===!0)return u;return c.forEach((f)=>{let m=[d];if(t.forEach((R,y)=>{if(d!==y&&as(R,f)&&n.definition[y].ignoreAmbiguities!==!0)m.push(y)}),m.length>1&&!as(o,f))o.push(f),u.push({alts:m,path:f})}),u},[]).map((u)=>{let c=u.alts.map((f)=>f+1);return{message:a.buildAlternationAmbiguityError({topLevelRule:i,alternation:n,ambiguityIndices:c,prefixPath:u.path}),type:ne.AMBIGUOUS_ALTS,ruleName:i.name,occurrence:n.idx,alternatives:u.alts}})}function va(t,n,i,a){let o=t.reduce((h,u,c)=>{let d=u.map((f)=>({idx:c,path:f}));return h.concat(d)},[]);return o.flatMap((h)=>{if(n.definition[h.idx].ignoreAmbiguities===!0)return[];let{idx:c,path:d}=h;return o.filter((R)=>n.definition[R.idx].ignoreAmbiguities!==!0&&R.idx<c&&fi(R.path,d)).map((R)=>{let y=[R.idx+1,c+1],U=n.idx===0?"":n.idx;return{message:a.buildAlternationPrefixAmbiguityError({topLevelRule:i,alternation:n,ambiguityIndices:y,prefixPath:R.path}),type:ne.AMBIGUOUS_PREFIX_ALTS,ruleName:i.name,occurrence:U,alternatives:y}})})}function Ma(t,n,i){let a=[],o=n.map((l)=>l.name);return t.forEach((l)=>{let h=l.name;if(o.includes(h)){let u=i.buildNamespaceConflictError(l);a.push({message:u,type:ne.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:h})}}),a}function Ni(t){let n=Object.assign({errMsgProvider:si},t),i={};return t.rules.forEach((a)=>{i[a.name]=a}),ni(i,n.errMsgProvider)}function Ii(t){var n;let i=(n=t.errMsgProvider)!==null&&n!==void 0?n:Ce;return Ti(t.rules,t.tokenTypes,i,t.grammarName)}var ki=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(ki);function Ge(t){return ki.includes(t.name)}class xt extends Error{constructor(t,n){super(t);if(this.token=n,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="MismatchedTokenException"}}class cs extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="NoViableAltException"}}class hs extends xt{constructor(t,n){super(t,n);this.name="NotAllInputParsedException"}}class us extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class Ci extends Error{constructor(t){super(t);this.name=Ys}}class qs{initRecoverable(t){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(t,"recoveryEnabled")?t.recoveryEnabled:Ee.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=wa}getTokenToInsert(t){let n=qe(t,"",-1,-1,-1,-1,-1,-1);return n.isInsertedInRecovery=!0,n}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,n,i,a){let o=this.findReSyncTokenType(),l=this.exportLexerState(),h=[],u=!1,c=this.LA_FAST(1),d=this.LA_FAST(1),f=()=>{let m=this.LA(0),R=this.errorMessageProvider.buildMismatchTokenMessage({expected:a,actual:c,previous:m,ruleName:this.getCurrRuleFullName()}),y=new ot(R,c,this.LA(0));y.resyncedTokens=h.slice(0,-1),this.SAVE_ERROR(y)};while(!u)if(this.tokenMatcher(d,a)){f();return}else if(i.call(this)){f(),t.apply(this,n);return}else if(this.tokenMatcher(d,o))u=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);this.importLexerState(l)}shouldInRepetitionRecoveryBeTried(t,n,i){if(i===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),t))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,n)))return!1;return!0}getNextPossibleTokenTypes(t){let n=t.ruleStack[0],a=this.getGAstProductions()[n];return new Ws(a,t).startWalking()}getFollowsForInRuleRecovery(t,n){let i=this.getCurrentGrammarPath(t,n);return this.getNextPossibleTokenTypes(i)}tryInRuleRecovery(t,n){if(this.canRecoverWithSingleTokenInsertion(t,n))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let i=this.SKIP_TOKEN();return this.consumeToken(),i}throw new Ci("sad sad panda")}canPerformInRuleRecovery(t,n){return this.canRecoverWithSingleTokenInsertion(t,n)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,n){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(n.length===0)return!1;let i=this.LA_FAST(1);return n.find((o)=>this.tokenMatcher(i,o))!==void 0}canRecoverWithSingleTokenDeletion(t){if(!this.canTokenTypeBeDeletedInRecovery(t))return!1;return this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){let n=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(n).includes(t)}findReSyncTokenType(){let t=this.flattenFollowSet(),n=this.LA_FAST(1),i=2;while(!0){let a=t.find((o)=>kt(n,o));if(a!==void 0)return a;n=this.LA(i),i++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let t=this.currRuleShortName,n=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:n,inRule:this.shortRuleNameToFullName(i)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK,i=this.RULE_STACK_IDX+1,a=Array(i);for(let o=0;o<i;o++)if(o===0)a[o]=Xs;else a[o]={ruleName:this.shortRuleNameToFullName(t[o]),idxInCallingRule:n[o],inRule:this.shortRuleNameToFullName(t[o-1])};return a}flattenFollowSet(){return this.buildFullFollowKeyStack().map((n)=>this.getFollowSetFromFollowKey(n)).flat()}getFollowSetFromFollowKey(t){if(t===Xs)return[ye];let n=t.ruleName+t.idxInCallingRule+jt+t.inRule;return this.resyncFollows[n]}addToResyncTokens(t,n){if(!this.tokenMatcher(t,ye))n.push(t);return n}reSyncTo(t){let n=[],i=this.LA_FAST(1);while(this.tokenMatcher(i,t)===!1)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,n);return n.slice(0,-1)}attemptInRepetitionRecovery(t,n,i,a,o,l,h){}getCurrentGrammarPath(t,n){let i=this.getHumanReadableRuleStack(),a=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:i,occurrenceStack:a,lastTok:t,lastTokOccurrence:n}}getHumanReadableRuleStack(){let t=this.RULE_STACK_IDX+1,n=Array(t);for(let i=0;i<t;i++)n[i]=this.shortRuleNameToFullName(this.RULE_STACK[i]);return n}}function wa(t,n,i,a,o,l,h){var u,c,d;let f=a|o,m=(u=(c=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&u!==void 0?u:c[d]=[],R=m[f];if(R===void 0){let M=this.getCurrRuleFullName(),x=this.getGAstProductions()[M];R=new l(x,o).startWalking(),m[f]=R}let y=R.token,U=R.occurrence,P=R.isEndOfRule;if(this.RULE_STACK_IDX===0&&P&&y===void 0)y=ye,U=1;if(y===void 0||U===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(y,U,h))this.tryInRepetitionRecovery(t,n,i,y)}var ds=256,ps=512,vt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(t){var n;this.maxLookahead=(n=t===null||t===void 0?void 0:t.maxLookahead)!==null&&n!==void 0?n:Ee.maxLookahead}validate(t){let n=this.validateNoLeftRecursion(t.rules);if(n.length===0){let i=this.validateEmptyOrAlternatives(t.rules),a=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...n,...i,...a,...o]}return n}validateNoLeftRecursion(t){return t.flatMap((n)=>Hs(n,n,Ce))}validateEmptyOrAlternatives(t){return t.flatMap((n)=>Ri(n,Ce))}validateAmbiguousAlternationAlternatives(t,n){return t.flatMap((i)=>yi(i,n,Ce))}validateSomeNonEmptyLookaheadPath(t,n){return Li(t,n,Ce)}buildLookaheadForAlternation(t){return li(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,hi)}buildLookaheadForOptional(t){return ci(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,rs(t.prodType),ui)}}class Js{initLooksAhead(t){this.dynamicTokensEnabled=Object.hasOwn(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Ee.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(t,"maxLookahead")?t.maxLookahead:Ee.maxLookahead,this.lookaheadStrategy=Object.hasOwn(t,"lookaheadStrategy")?t.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(t){t.forEach((n)=>{this.TRACE_INIT(`${n.name} Rule Lookahead`,()=>{let{alternation:i,repetition:a,option:o,repetitionMandatory:l,repetitionMandatoryWithSeparator:h,repetitionWithSeparator:u}=Ua(n);i.forEach((c)=>{let d=c.idx===0?"":c.idx;this.TRACE_INIT(`${Re(c)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:n,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[n.name],ds|c.idx,f)})}),a.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,vt,"Repetition",c.maxLookahead,Re(c))}),o.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,ps,"Option",c.maxLookahead,Re(c))}),l.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,Mt,"RepetitionMandatory",c.maxLookahead,Re(c))}),h.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,lt,"RepetitionMandatoryWithSeparator",c.maxLookahead,Re(c))}),u.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,wt,"RepetitionWithSeparator",c.maxLookahead,Re(c))})})})}computeLookaheadFunc(t,n,i,a,o,l){this.TRACE_INIT(`${l}${n===0?"":n}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:n,rule:t,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:a});this.setLaFuncCache(this.fullRuleNameToShort[t.name],i|n,h)})}setLaFuncCache(t,n,i){let a=this.lookAheadFuncsCache[t];if(a===void 0)a=[],this.lookAheadFuncsCache[t]=a;a[n]=i}}class bi extends Se{constructor(){super(...arguments);this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}}var ms=new bi;function Ua(t){ms.reset(),t.accept(ms);let n=ms.dslMethods;return ms.reset(),n}function Zs(t,n){if(t.startOffset===-1)t.startOffset=n.startOffset,t.endOffset=n.endOffset;else if(t.endOffset<n.endOffset===!0)t.endOffset=n.endOffset}function Qs(t,n){if(t.startOffset===-1)t.startOffset=n.startOffset,t.startColumn=n.startColumn,t.startLine=n.startLine,t.endOffset=n.endOffset,t.endColumn=n.endColumn,t.endLine=n.endLine;else if(t.endOffset<n.endOffset===!0)t.endOffset=n.endOffset,t.endColumn=n.endColumn,t.endLine=n.endLine}function _i(t,n,i){if(t.children[i]===void 0)t.children[i]=[n];else t.children[i].push(n)}function xi(t,n,i){if(t.children[n]===void 0)t.children[n]=[i];else t.children[n].push(i)}function en(t,n){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:n})}function Pa(t,n){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let l=i[o],h=t[l],u=h.length;for(let c=0;c<u;c++){let d=h[c];if(d.tokenTypeIdx===void 0)this[d.name](d.children,n)}}}function vi(t,n){let i=function(){};en(i,t+"BaseSemantics");let a={visit:function(o,l){if(Array.isArray(o))o=o[0];if(o===void 0)return;return this[o.name](o.children,l)},validateVisitor:function(){let o=Da(this,n);if(o.length!==0){let l=o.map((h)=>h.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
86
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let n;if(t.topLevelRule instanceof Te)n=t.topLevelRule.name;else n=t.topLevelRule;return`Duplicate definition, rule: ->${n}<- is already defined in the grammar: ->${t.grammarName}<-`}};function ni(t,n){let i=new ii(t,n);return i.resolveRefs(),i.errors}class ii extends Ae{constructor(t,n){super();this.nameToTopRule=t,this.errMsgProvider=n,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((t)=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){let n=this.nameToTopRule[t.nonTerminalName];if(!n){let i=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:i,type:re.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}else t.referencedRule=n}}class ri extends $e{constructor(t,n){super();this.topProd=t,this.path=n,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,n=[]){if(!this.found)super.walk(t,n)}walkProdRef(t,n,i){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){let a=n.concat(i);this.updateExpectedNext(),this.walk(t.referencedRule,a)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Ws extends ri{constructor(t,n){super(t,n);this.path=n,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,n,i){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){let a=n.concat(i),o=new j({definition:a});this.possibleTokTypes=Ke(o),this.found=!0}}}class Ct extends $e{constructor(t,n){super();this.topRule=t,this.occurrence=n,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class js extends Ct{walkMany(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkMany(t,n,i)}}class ss extends Ct{walkManySep(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkManySep(t,n,i)}}class Ks extends Ct{walkAtLeastOne(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkAtLeastOne(t,n,i)}}class ns extends Ct{walkAtLeastOneSep(t,n,i){if(t.idx===this.occurrence){let a=n.concat(i)[0];if(this.result.isEndOfRule=a===void 0,a instanceof F)this.result.token=a.terminalType,this.result.occurrence=a.idx}else super.walkAtLeastOneSep(t,n,i)}}function is(t,n,i=[]){i=[...i];let a=[],o=0;function l(u){return u.concat(t.slice(o+1))}function h(u){let c=is(l(u),n,i);return a.concat(c)}while(i.length<n&&o<t.length){let u=t[o];if(u instanceof j)return h(u.definition);else if(u instanceof W)return h(u.definition);else if(u instanceof K)a=h(u.definition);else if(u instanceof Z){let c=u.definition.concat([new G({definition:u.definition})]);return h(c)}else if(u instanceof Q){let c=[new j({definition:u.definition}),new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})];return h(c)}else if(u instanceof q){let c=u.definition.concat([new G({definition:[new F({terminalType:u.separator})].concat(u.definition)})]);a=h(c)}else if(u instanceof G){let c=u.definition.concat([new G({definition:u.definition})]);a=h(c)}else if(u instanceof J)return u.definition.forEach((c)=>{if(c.definition.length!==0)a=h(c.definition)}),a;else if(u instanceof F)i.push(u.terminalType);else throw Error("non exhaustive match");o++}return a.push({partialPath:i,suffixDef:t.slice(o)}),a}function ai(t,n,i,a){let l=["EXIT_NONE_TERMINAL"],h="EXIT_ALTERNATIVE",u=!1,c=n.length,d=c-a-1,f=[],m=[];m.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let R=m.pop();if(R==="EXIT_ALTERNATIVE"){if(u&&m.at(-1).idx<=d)m.pop();continue}let{def:y,idx:U,ruleStack:P,occurrenceStack:M}=R;if(y.length===0)continue;let x=y[0];if(x==="EXIT_NONE_TERMINAL"){let _={idx:U,def:y.slice(1),ruleStack:P.slice(0,-1),occurrenceStack:M.slice(0,-1)};m.push(_)}else if(x instanceof F)if(U<c-1){let _=U+1,g=n[_];if(i(g,x.terminalType)){let w={idx:_,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(w)}}else if(U===c-1)f.push({nextTokenType:x.terminalType,nextTokenOccurrence:x.idx,ruleStack:P,occurrenceStack:M}),u=!0;else throw Error("non exhaustive match");else if(x instanceof W){let _=[...P];_.push(x.nonTerminalName);let g=[...M];g.push(x.idx);let w={idx:U,def:x.definition.concat(l,y.slice(1)),ruleStack:_,occurrenceStack:g};m.push(w)}else if(x instanceof K){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g={idx:U,def:x.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M};m.push(g)}else if(x instanceof Z){let _=new G({definition:x.definition,idx:x.idx}),g=x.definition.concat([_],y.slice(1)),w={idx:U,def:g,ruleStack:P,occurrenceStack:M};m.push(w)}else if(x instanceof Q){let _=new F({terminalType:x.separator}),g=new G({definition:[_].concat(x.definition),idx:x.idx}),w=x.definition.concat([g],y.slice(1)),te={idx:U,def:w,ruleStack:P,occurrenceStack:M};m.push(te)}else if(x instanceof q){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g=new F({terminalType:x.separator}),w=new G({definition:[g].concat(x.definition),idx:x.idx}),te=x.definition.concat([w],y.slice(1)),de={idx:U,def:te,ruleStack:P,occurrenceStack:M};m.push(de)}else if(x instanceof G){let _={idx:U,def:y.slice(1),ruleStack:P,occurrenceStack:M};m.push(_),m.push("EXIT_ALTERNATIVE");let g=new G({definition:x.definition,idx:x.idx}),w=x.definition.concat([g],y.slice(1)),te={idx:U,def:w,ruleStack:P,occurrenceStack:M};m.push(te)}else if(x instanceof J)for(let _=x.definition.length-1;_>=0;_--){let g=x.definition[_],w={idx:U,def:g.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M};m.push(w),m.push("EXIT_ALTERNATIVE")}else if(x instanceof j)m.push({idx:U,def:x.definition.concat(y.slice(1)),ruleStack:P,occurrenceStack:M});else if(x instanceof Te)m.push(Na(x,U,P,M));else throw Error("non exhaustive match")}return f}function Na(t,n,i,a){let o=[...i];o.push(t.name);let l=[...a];return l.push(1),{idx:n,def:t.definition,ruleStack:o,occurrenceStack:l}}var H;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(H||(H={}));function rs(t){if(t instanceof K||t==="Option")return H.OPTION;else if(t instanceof G||t==="Repetition")return H.REPETITION;else if(t instanceof Z||t==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(t instanceof Q||t==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(t instanceof q||t==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(t instanceof J||t==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function li(t,n,i,a,o,l){let h=bt(t,n,i),u=mi(h)?at:Ue;return l(h,a,u,o)}function ci(t,n,i,a,o,l){let h=_t(t,n,o,i),u=mi(h)?at:Ue;return l(h[0],u,a)}function hi(t,n,i,a){let o=t.length,l=t.every((h)=>h.every((u)=>u.length===1));if(n)return function(h){let u=h.map((c)=>c.GATE);for(let c=0;c<o;c++){let d=t[c],f=d.length,m=u[c];if(m!==void 0&&m.call(this)===!1)continue;e:for(let R=0;R<f;R++){let y=d[R],U=y.length;for(let P=0;P<U;P++){let M=this.LA_FAST(P+1);if(i(M,y[P])===!1)continue e}return c}}return};else if(l&&!a){let u=t.map((c)=>c.flat()).reduce((c,d,f)=>(d.forEach((m)=>{if(!(m.tokenTypeIdx in c))c[m.tokenTypeIdx]=f;m.categoryMatches.forEach((R)=>{if(!Object.hasOwn(c,R))c[R]=f})}),c),{});return function(){let c=this.LA_FAST(1);return u[c.tokenTypeIdx]}}else return function(){for(let h=0;h<o;h++){let u=t[h],c=u.length;e:for(let d=0;d<c;d++){let f=u[d],m=f.length;for(let R=0;R<m;R++){let y=this.LA_FAST(R+1);if(i(y,f[R])===!1)continue e}return h}}return}}function ui(t,n,i){let a=t.every((l)=>l.length===1),o=t.length;if(a&&!i){let l=t.flat();if(l.length===1&&l[0].categoryMatches.length===0){let u=l[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===u}}else{let h=l.reduce((u,c,d)=>(u[c.tokenTypeIdx]=!0,c.categoryMatches.forEach((f)=>{u[f]=!0}),u),[]);return function(){let u=this.LA_FAST(1);return h[u.tokenTypeIdx]===!0}}}else return function(){e:for(let l=0;l<o;l++){let h=t[l],u=h.length;for(let c=0;c<u;c++){let d=this.LA_FAST(c+1);if(n(d,h[c])===!1)continue e}return!0}return!1}}class di extends $e{constructor(t,n,i){super();this.topProd=t,this.targetOccurrence=n,this.targetProdType=i}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,n,i,a){if(t.idx===this.targetOccurrence&&this.targetProdType===n)return this.restDef=i.concat(a),!0;return!1}walkOption(t,n,i){if(!this.checkIsTarget(t,H.OPTION,n,i))super.walkOption(t,n,i)}walkAtLeastOne(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_MANDATORY,n,i))super.walkOption(t,n,i)}walkAtLeastOneSep(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_MANDATORY_WITH_SEPARATOR,n,i))super.walkOption(t,n,i)}walkMany(t,n,i){if(!this.checkIsTarget(t,H.REPETITION,n,i))super.walkOption(t,n,i)}walkManySep(t,n,i){if(!this.checkIsTarget(t,H.REPETITION_WITH_SEPARATOR,n,i))super.walkOption(t,n,i)}}class zs extends Ae{constructor(t,n,i){super();this.targetOccurrence=t,this.targetProdType=n,this.targetRef=i,this.result=[]}checkIsTarget(t,n){if(t.idx===this.targetOccurrence&&this.targetProdType===n&&(this.targetRef===void 0||t===this.targetRef))this.result=t.definition}visitOption(t){this.checkIsTarget(t,H.OPTION)}visitRepetition(t){this.checkIsTarget(t,H.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,H.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,H.ALTERNATION)}}function oi(t){let n=Array(t);for(let i=0;i<t;i++)n[i]=[];return n}function Vs(t){let n=[""];for(let i=0;i<t.length;i++){let a=t[i],o=[];for(let l=0;l<n.length;l++){let h=n[l];o.push(h+"_"+a.tokenTypeIdx);for(let u=0;u<a.categoryMatches.length;u++){let c="_"+a.categoryMatches[u];o.push(h+c)}}n=o}return n}function Ia(t,n,i){for(let a=0;a<t.length;a++){if(a===i)continue;let o=t[a];for(let l=0;l<n.length;l++){let h=n[l];if(o[h]===!0)return!1}}return!0}function pi(t,n){let i=t.map((h)=>is([h],1)),a=oi(i.length),o=i.map((h)=>{let u={};return h.forEach((c)=>{Vs(c.partialPath).forEach((f)=>{u[f]=!0})}),u}),l=i;for(let h=1;h<=n;h++){let u=l;l=oi(u.length);for(let c=0;c<u.length;c++){let d=u[c];for(let f=0;f<d.length;f++){let m=d[f].partialPath,R=d[f].suffixDef,y=Vs(m);if(Ia(o,y,c)||R.length===0||m.length===n){let P=a[c];if(as(P,m)===!1){P.push(m);for(let M=0;M<y.length;M++){let x=y[M];o[c][x]=!0}}}else{let P=is(R,h+1,m);l[c]=l[c].concat(P),P.forEach((M)=>{Vs(M.partialPath).forEach((_)=>{o[c][_]=!0})})}}}}return a}function bt(t,n,i,a){let o=new zs(t,H.ALTERNATION,a);return n.accept(o),pi(o.result,i)}function _t(t,n,i,a){let o=new zs(t,i);n.accept(o);let l=o.result,u=new di(n,t,i).startWalking(),c=new j({definition:l}),d=new j({definition:u});return pi([c,d],a)}function as(t,n){e:for(let i=0;i<t.length;i++){let a=t[i];if(a.length!==n.length)continue;for(let o=0;o<a.length;o++){let l=n[o],h=a[o];if((l===h||h.categoryMatchesMap[l.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function fi(t,n){return t.length<n.length&&t.every((i,a)=>{let o=n[a];return i===o||o.categoryMatchesMap[i.tokenTypeIdx]})}function mi(t){return t.every((n)=>n.every((i)=>i.every((a)=>a.categoryMatches.length===0)))}function Ei(t){return t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}).map((i)=>Object.assign({type:re.CUSTOM_LOOKAHEAD_VALIDATION},i))}function Ti(t,n,i,a){let o=t.flatMap((c)=>ka(c,i)),l=Ma(t,n,i),h=t.flatMap((c)=>_a(c,i)),u=t.flatMap((c)=>ba(c,t,a,i));return o.concat(l,h,u)}function ka(t,n){let i=new Ai;t.accept(i);let a=i.allProductions,o=Object.groupBy(a,Ca),l=Object.fromEntries(Object.entries(o).filter(([u,c])=>c.length>1));return Object.values(l).map((u)=>{let c=u[0],d=n.buildDuplicateFoundError(t,u),f=Se(c),m={message:d,type:re.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:f,occurrence:c.idx},R=gi(c);if(R)m.parameter=R;return m})}function Ca(t){return`${Se(t)}_#_${t.idx}_#_${gi(t)}`}function gi(t){if(t instanceof F)return t.terminalType.name;else if(t instanceof W)return t.nonTerminalName;else return""}class Ai extends Ae{constructor(){super(...arguments);this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function ba(t,n,i,a){let o=[];if(n.reduce((h,u)=>{if(u.name===t.name)return h+1;return h},0)>1){let h=a.buildDuplicateRuleNameError({topLevelRule:t,grammarName:i});o.push({message:h,type:re.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}function Si(t,n,i){let a=[],o;if(!n.includes(t))o=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${i}<-as it is not defined in any of the super grammars `,a.push({message:o,type:re.INVALID_RULE_OVERRIDE,ruleName:t});return a}function Hs(t,n,i,a=[]){let o=[],l=os(n.definition);if(l.length===0)return[];else{let h=t.name;if(l.includes(t))o.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:a}),type:re.LEFT_RECURSION,ruleName:h});let c=a.concat([t]),f=l.filter((m)=>!c.includes(m)).flatMap((m)=>{let R=[...a];return R.push(m),Hs(t,m,i,R)});return o.concat(f)}}function os(t){let n=[];if(t.length===0)return n;let i=t[0];if(i instanceof W)n.push(i.referencedRule);else if(i instanceof j||i instanceof K||i instanceof Z||i instanceof Q||i instanceof q||i instanceof G)n=n.concat(os(i.definition));else if(i instanceof J)n=i.definition.map((l)=>os(l.definition)).flat();else if(i instanceof F);else throw Error("non exhaustive match");let a=je(i),o=t.length>1;if(a&&o){let l=t.slice(1);return n.concat(os(l))}else return n}class ls extends Ae{constructor(){super(...arguments);this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function Ri(t,n){let i=new ls;return t.accept(i),i.alternations.flatMap((l)=>l.definition.slice(0,-1).flatMap((u,c)=>{if(ai([u],[],Ue,1).length===0)return[{message:n.buildEmptyAlternationError({topLevelRule:t,alternation:l,emptyChoiceIdx:c}),type:re.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:l.idx,alternative:c+1}];else return[]}))}function yi(t,n,i){let a=new ls;t.accept(a);let o=a.alternations;return o=o.filter((h)=>h.ignoreAmbiguities!==!0),o.flatMap((h)=>{let u=h.idx,c=h.maxLookahead||n,d=bt(u,t,c,h),f=xa(d,h,t,i),m=va(d,h,t,i);return f.concat(m)})}class Oi extends Ae{constructor(){super(...arguments);this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function _a(t,n){let i=new ls;return t.accept(i),i.alternations.flatMap((l)=>{if(l.definition.length>255)return[{message:n.buildTooManyAlternativesError({topLevelRule:t,alternation:l}),type:re.TOO_MANY_ALTS,ruleName:t.name,occurrence:l.idx}];else return[]})}function Li(t,n,i){let a=[];return t.forEach((o)=>{let l=new Oi;o.accept(l),l.allProductions.forEach((u)=>{let c=rs(u),d=u.maxLookahead||n,f=u.idx;if(_t(f,o,c,d)[0].flat().length===0){let y=i.buildEmptyRepetitionError({topLevelRule:o,repetition:u});a.push({message:y,type:re.NO_NON_EMPTY_LOOKAHEAD,ruleName:o.name})}})}),a}function xa(t,n,i,a){let o=[];return t.reduce((u,c,d)=>{if(n.definition[d].ignoreAmbiguities===!0)return u;return c.forEach((f)=>{let m=[d];if(t.forEach((R,y)=>{if(d!==y&&as(R,f)&&n.definition[y].ignoreAmbiguities!==!0)m.push(y)}),m.length>1&&!as(o,f))o.push(f),u.push({alts:m,path:f})}),u},[]).map((u)=>{let c=u.alts.map((f)=>f+1);return{message:a.buildAlternationAmbiguityError({topLevelRule:i,alternation:n,ambiguityIndices:c,prefixPath:u.path}),type:re.AMBIGUOUS_ALTS,ruleName:i.name,occurrence:n.idx,alternatives:u.alts}})}function va(t,n,i,a){let o=t.reduce((h,u,c)=>{let d=u.map((f)=>({idx:c,path:f}));return h.concat(d)},[]);return o.flatMap((h)=>{if(n.definition[h.idx].ignoreAmbiguities===!0)return[];let{idx:c,path:d}=h;return o.filter((R)=>n.definition[R.idx].ignoreAmbiguities!==!0&&R.idx<c&&fi(R.path,d)).map((R)=>{let y=[R.idx+1,c+1],U=n.idx===0?"":n.idx;return{message:a.buildAlternationPrefixAmbiguityError({topLevelRule:i,alternation:n,ambiguityIndices:y,prefixPath:R.path}),type:re.AMBIGUOUS_PREFIX_ALTS,ruleName:i.name,occurrence:U,alternatives:y}})})}function Ma(t,n,i){let a=[],o=n.map((l)=>l.name);return t.forEach((l)=>{let h=l.name;if(o.includes(h)){let u=i.buildNamespaceConflictError(l);a.push({message:u,type:re.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:h})}}),a}function Ni(t){let n=Object.assign({errMsgProvider:si},t),i={};return t.rules.forEach((a)=>{i[a.name]=a}),ni(i,n.errMsgProvider)}function Ii(t){var n;let i=(n=t.errMsgProvider)!==null&&n!==void 0?n:Ce;return Ti(t.rules,t.tokenTypes,i,t.grammarName)}var ki=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(ki);function Ge(t){return ki.includes(t.name)}class xt extends Error{constructor(t,n){super(t);if(this.token=n,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="MismatchedTokenException"}}class cs extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="NoViableAltException"}}class hs extends xt{constructor(t,n){super(t,n);this.name="NotAllInputParsedException"}}class us extends xt{constructor(t,n,i){super(t,n);this.previousToken=i,this.name="EarlyExitException"}}var Xs={},Ys="InRuleRecoveryException";class Ci extends Error{constructor(t){super(t);this.name=Ys}}class qs{initRecoverable(t){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(t,"recoveryEnabled")?t.recoveryEnabled:me.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=wa}getTokenToInsert(t){let n=qe(t,"",-1,-1,-1,-1,-1,-1);return n.isInsertedInRecovery=!0,n}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,n,i,a){let o=this.findReSyncTokenType(),l=this.exportLexerState(),h=[],u=!1,c=this.LA_FAST(1),d=this.LA_FAST(1),f=()=>{let m=this.LA(0),R=this.errorMessageProvider.buildMismatchTokenMessage({expected:a,actual:c,previous:m,ruleName:this.getCurrRuleFullName()}),y=new ot(R,c,this.LA(0));y.resyncedTokens=h.slice(0,-1),this.SAVE_ERROR(y)};while(!u)if(this.tokenMatcher(d,a)){f();return}else if(i.call(this)){f(),t.apply(this,n);return}else if(this.tokenMatcher(d,o))u=!0;else d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);this.importLexerState(l)}shouldInRepetitionRecoveryBeTried(t,n,i){if(i===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),t))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,n)))return!1;return!0}getNextPossibleTokenTypes(t){let n=t.ruleStack[0],a=this.getGAstProductions()[n];return new Ws(a,t).startWalking()}getFollowsForInRuleRecovery(t,n){let i=this.getCurrentGrammarPath(t,n);return this.getNextPossibleTokenTypes(i)}tryInRuleRecovery(t,n){if(this.canRecoverWithSingleTokenInsertion(t,n))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){let i=this.SKIP_TOKEN();return this.consumeToken(),i}throw new Ci("sad sad panda")}canPerformInRuleRecovery(t,n){return this.canRecoverWithSingleTokenInsertion(t,n)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,n){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(n.length===0)return!1;let i=this.LA_FAST(1);return n.find((o)=>this.tokenMatcher(i,o))!==void 0}canRecoverWithSingleTokenDeletion(t){if(!this.canTokenTypeBeDeletedInRecovery(t))return!1;return this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){let n=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(n).includes(t)}findReSyncTokenType(){let t=this.flattenFollowSet(),n=this.LA_FAST(1),i=2;while(!0){let a=t.find((o)=>kt(n,o));if(a!==void 0)return a;n=this.LA(i),i++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Xs;let t=this.currRuleShortName,n=this.getLastExplicitRuleOccurrenceIndex(),i=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:n,inRule:this.shortRuleNameToFullName(i)}}buildFullFollowKeyStack(){let t=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK,i=this.RULE_STACK_IDX+1,a=Array(i);for(let o=0;o<i;o++)if(o===0)a[o]=Xs;else a[o]={ruleName:this.shortRuleNameToFullName(t[o]),idxInCallingRule:n[o],inRule:this.shortRuleNameToFullName(t[o-1])};return a}flattenFollowSet(){return this.buildFullFollowKeyStack().map((n)=>this.getFollowSetFromFollowKey(n)).flat()}getFollowSetFromFollowKey(t){if(t===Xs)return[Re];let n=t.ruleName+t.idxInCallingRule+jt+t.inRule;return this.resyncFollows[n]}addToResyncTokens(t,n){if(!this.tokenMatcher(t,Re))n.push(t);return n}reSyncTo(t){let n=[],i=this.LA_FAST(1);while(this.tokenMatcher(i,t)===!1)i=this.SKIP_TOKEN(),this.addToResyncTokens(i,n);return n.slice(0,-1)}attemptInRepetitionRecovery(t,n,i,a,o,l,h){}getCurrentGrammarPath(t,n){let i=this.getHumanReadableRuleStack(),a=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:i,occurrenceStack:a,lastTok:t,lastTokOccurrence:n}}getHumanReadableRuleStack(){let t=this.RULE_STACK_IDX+1,n=Array(t);for(let i=0;i<t;i++)n[i]=this.shortRuleNameToFullName(this.RULE_STACK[i]);return n}}function wa(t,n,i,a,o,l,h){var u,c,d;let f=a|o,m=(u=(c=this.firstAfterRepMap)[d=this.currRuleShortName])!==null&&u!==void 0?u:c[d]=[],R=m[f];if(R===void 0){let M=this.getCurrRuleFullName(),x=this.getGAstProductions()[M];R=new l(x,o).startWalking(),m[f]=R}let y=R.token,U=R.occurrence,P=R.isEndOfRule;if(this.RULE_STACK_IDX===0&&P&&y===void 0)y=Re,U=1;if(y===void 0||U===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(y,U,h))this.tryInRepetitionRecovery(t,n,i,y)}var ds=256,ps=512,vt=768,Mt=1024,wt=1280,lt=1536;class fs{constructor(t){var n;this.maxLookahead=(n=t===null||t===void 0?void 0:t.maxLookahead)!==null&&n!==void 0?n:me.maxLookahead}validate(t){let n=this.validateNoLeftRecursion(t.rules);if(n.length===0){let i=this.validateEmptyOrAlternatives(t.rules),a=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...n,...i,...a,...o]}return n}validateNoLeftRecursion(t){return t.flatMap((n)=>Hs(n,n,Ce))}validateEmptyOrAlternatives(t){return t.flatMap((n)=>Ri(n,Ce))}validateAmbiguousAlternationAlternatives(t,n){return t.flatMap((i)=>yi(i,n,Ce))}validateSomeNonEmptyLookaheadPath(t,n){return Li(t,n,Ce)}buildLookaheadForAlternation(t){return li(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,hi)}buildLookaheadForOptional(t){return ci(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,rs(t.prodType),ui)}}class Js{initLooksAhead(t){this.dynamicTokensEnabled=Object.hasOwn(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:me.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(t,"maxLookahead")?t.maxLookahead:me.maxLookahead,this.lookaheadStrategy=Object.hasOwn(t,"lookaheadStrategy")?t.lookaheadStrategy:new fs({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(t){t.forEach((n)=>{this.TRACE_INIT(`${n.name} Rule Lookahead`,()=>{let{alternation:i,repetition:a,option:o,repetitionMandatory:l,repetitionMandatoryWithSeparator:h,repetitionWithSeparator:u}=Ua(n);i.forEach((c)=>{let d=c.idx===0?"":c.idx;this.TRACE_INIT(`${Se(c)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:n,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[n.name],ds|c.idx,f)})}),a.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,vt,"Repetition",c.maxLookahead,Se(c))}),o.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,ps,"Option",c.maxLookahead,Se(c))}),l.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,Mt,"RepetitionMandatory",c.maxLookahead,Se(c))}),h.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,lt,"RepetitionMandatoryWithSeparator",c.maxLookahead,Se(c))}),u.forEach((c)=>{this.computeLookaheadFunc(n,c.idx,wt,"RepetitionWithSeparator",c.maxLookahead,Se(c))})})})}computeLookaheadFunc(t,n,i,a,o,l){this.TRACE_INIT(`${l}${n===0?"":n}`,()=>{let h=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:n,rule:t,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:a});this.setLaFuncCache(this.fullRuleNameToShort[t.name],i|n,h)})}setLaFuncCache(t,n,i){let a=this.lookAheadFuncsCache[t];if(a===void 0)a=[],this.lookAheadFuncsCache[t]=a;a[n]=i}}class bi extends Ae{constructor(){super(...arguments);this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}}var ms=new bi;function Ua(t){ms.reset(),t.accept(ms);let n=ms.dslMethods;return ms.reset(),n}function Zs(t,n){if(t.startOffset===-1)t.startOffset=n.startOffset,t.endOffset=n.endOffset;else if(t.endOffset<n.endOffset===!0)t.endOffset=n.endOffset}function Qs(t,n){if(t.startOffset===-1)t.startOffset=n.startOffset,t.startColumn=n.startColumn,t.startLine=n.startLine,t.endOffset=n.endOffset,t.endColumn=n.endColumn,t.endLine=n.endLine;else if(t.endOffset<n.endOffset===!0)t.endOffset=n.endOffset,t.endColumn=n.endColumn,t.endLine=n.endLine}function _i(t,n,i){if(t.children[i]===void 0)t.children[i]=[n];else t.children[i].push(n)}function xi(t,n,i){if(t.children[n]===void 0)t.children[n]=[i];else t.children[n].push(i)}function en(t,n){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:n})}function Pa(t,n){let i=Object.keys(t),a=i.length;for(let o=0;o<a;o++){let l=i[o],h=t[l],u=h.length;for(let c=0;c<u;c++){let d=h[c];if(d.tokenTypeIdx===void 0)this[d.name](d.children,n)}}}function vi(t,n){let i=function(){};en(i,t+"BaseSemantics");let a={visit:function(o,l){if(Array.isArray(o))o=o[0];if(o===void 0)return;return this[o.name](o.children,l)},validateVisitor:function(){let o=Da(this,n);if(o.length!==0){let l=o.map((h)=>h.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
87
87
|
${l.join(`
|
|
88
88
|
|
|
89
89
|
`).replace(/\n/g,`
|
|
90
|
-
`)}`)}}};return i.prototype=a,i.prototype.constructor=i,i._RULE_NAMES=n,i}function Mi(t,n,i){let a=function(){};en(a,t+"BaseSemanticsWithDefaults");let o=Object.create(i.prototype);return n.forEach((l)=>{o[l]=Pa}),a.prototype=o,a.prototype.constructor=a,a}var tn;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(tn||(tn={}));function Da(t,n){return Fa(t,n)}function Fa(t,n){return n.filter((o)=>typeof t[o]==="function"===!1).map((o)=>({msg:`Missing visitor method: <${o}> on ${t.constructor.name} CST Visitor.`,type:tn.MISSING_METHOD,methodName:o})).filter(Boolean)}class sn{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=Object.hasOwn(t,"nodeLocationTracking")?t.nodeLocationTracking:Ee.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Qs,this.setNodeLocationFromNode=Qs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular;else if(/onlyOffset/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Zs,this.setNodeLocationFromNode=Zs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular;else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(t){let n=this.LA_FAST(1);t.location={startOffset:n.startOffset,startLine:n.startLine,startColumn:n.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(t){let n={name:t,children:Object.create(null)};this.setInitialNodeLocation(n),this.CST_STACK.push(n)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let n=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=n.startOffset===!0)i.endOffset=n.endOffset,i.endLine=n.endLine,i.endColumn=n.endColumn;else i.startOffset=-1,i.startLine=-1,i.startColumn=-1}cstPostRuleOnlyOffset(t){let n=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=n.startOffset===!0)i.endOffset=n.endOffset;else i.startOffset=-1}cstPostTerminal(t,n){let i=this.CST_STACK[this.CST_STACK.length-1];_i(i,n,t),this.setNodeLocationFromToken(i.location,n)}cstPostNonTerminal(t,n){let i=this.CST_STACK[this.CST_STACK.length-1];xi(i,n,t),this.setNodeLocationFromNode(i.location,t.location)}get currCSTNode(){let t=this;return t.CST_STACK[t.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let t=vi(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let t=Mi(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class nn{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){if(this.currIdx<=this.tokVectorLength-2)return this.consumeToken(),this.LA_FAST(1);else return De}LA_FAST(t){let n=this.currIdx+t;return this.tokVector[n]}LA(t){let n=this.currIdx+t;if(n<0||this.tokVectorLength<=n)return De;else return this.tokVector[n]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class rn{ACTION(t){return t.call(this)}consume(t,n,i){return this.consumeInternal(n,t,i)}subrule(t,n,i){return this.subruleInternal(n,t,i)}option(t,n){return this.optionInternal(n,t)}or(t,n){return this.orInternal(n,t)}many(t,n){return this.manyInternal(t,n)}atLeastOne(t,n){return this.atLeastOneInternal(t,n)}CONSUME(t,n){return this.consumeInternal(t,0,n)}CONSUME1(t,n){return this.consumeInternal(t,1,n)}CONSUME2(t,n){return this.consumeInternal(t,2,n)}CONSUME3(t,n){return this.consumeInternal(t,3,n)}CONSUME4(t,n){return this.consumeInternal(t,4,n)}CONSUME5(t,n){return this.consumeInternal(t,5,n)}CONSUME6(t,n){return this.consumeInternal(t,6,n)}CONSUME7(t,n){return this.consumeInternal(t,7,n)}CONSUME8(t,n){return this.consumeInternal(t,8,n)}CONSUME9(t,n){return this.consumeInternal(t,9,n)}SUBRULE(t,n){return this.subruleInternal(t,0,n)}SUBRULE1(t,n){return this.subruleInternal(t,1,n)}SUBRULE2(t,n){return this.subruleInternal(t,2,n)}SUBRULE3(t,n){return this.subruleInternal(t,3,n)}SUBRULE4(t,n){return this.subruleInternal(t,4,n)}SUBRULE5(t,n){return this.subruleInternal(t,5,n)}SUBRULE6(t,n){return this.subruleInternal(t,6,n)}SUBRULE7(t,n){return this.subruleInternal(t,7,n)}SUBRULE8(t,n){return this.subruleInternal(t,8,n)}SUBRULE9(t,n){return this.subruleInternal(t,9,n)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,n,i=ct){if(this.definedRulesNames.includes(t)){let l={message:Ce.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:ne.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(l)}this.definedRulesNames.push(t);let a=this.defineRule(t,n,i);return this[t]=a,a}OVERRIDE_RULE(t,n,i=ct){let a=Si(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(a);let o=this.defineRule(t,n,i);return this[t]=o,o}BACKTRACK(t,n){var i;let a=(i=t.coreRule)!==null&&i!==void 0?i:t;return function(){this.isBackTrackingStack.push(1);let o=this.saveRecogState();try{return a.apply(this,n),!0}catch(l){if(Ge(l))return!1;else throw l}finally{this.reloadRecogState(o),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Wt(Object.values(this.gastProductionsCache))}}class an{initRecognizerEngine(t,n){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=at,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(n,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
90
|
+
`)}`)}}};return i.prototype=a,i.prototype.constructor=i,i._RULE_NAMES=n,i}function Mi(t,n,i){let a=function(){};en(a,t+"BaseSemanticsWithDefaults");let o=Object.create(i.prototype);return n.forEach((l)=>{o[l]=Pa}),a.prototype=o,a.prototype.constructor=a,a}var tn;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(tn||(tn={}));function Da(t,n){return Fa(t,n)}function Fa(t,n){return n.filter((o)=>typeof t[o]==="function"===!1).map((o)=>({msg:`Missing visitor method: <${o}> on ${t.constructor.name} CST Visitor.`,type:tn.MISSING_METHOD,methodName:o})).filter(Boolean)}class sn{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=Object.hasOwn(t,"nodeLocationTracking")?t.nodeLocationTracking:me.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Qs,this.setNodeLocationFromNode=Qs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular;else if(/onlyOffset/i.test(this.nodeLocationTracking))if(this.recoveryEnabled)this.setNodeLocationFromToken=Zs,this.setNodeLocationFromNode=Zs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery;else this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular;else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(t){let n=this.LA_FAST(1);t.location={startOffset:n.startOffset,startLine:n.startLine,startColumn:n.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(t){let n={name:t,children:Object.create(null)};this.setInitialNodeLocation(n),this.CST_STACK.push(n)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){let n=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=n.startOffset===!0)i.endOffset=n.endOffset,i.endLine=n.endLine,i.endColumn=n.endColumn;else i.startOffset=-1,i.startLine=-1,i.startColumn=-1}cstPostRuleOnlyOffset(t){let n=this.LA(0),i=t.location;if(i.startOffset!==-1&&i.startOffset<=n.startOffset===!0)i.endOffset=n.endOffset;else i.startOffset=-1}cstPostTerminal(t,n){let i=this.CST_STACK[this.CST_STACK.length-1];_i(i,n,t),this.setNodeLocationFromToken(i.location,n)}cstPostNonTerminal(t,n){let i=this.CST_STACK[this.CST_STACK.length-1];xi(i,n,t),this.setNodeLocationFromNode(i.location,t.location)}get currCSTNode(){let t=this;return t.CST_STACK[t.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let t=vi(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let t=Mi(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class nn{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){if(this.currIdx<=this.tokVectorLength-2)return this.consumeToken(),this.LA_FAST(1);else return De}LA_FAST(t){let n=this.currIdx+t;return this.tokVector[n]}LA(t){let n=this.currIdx+t;if(n<0||this.tokVectorLength<=n)return De;else return this.tokVector[n]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class rn{ACTION(t){return t.call(this)}consume(t,n,i){return this.consumeInternal(n,t,i)}subrule(t,n,i){return this.subruleInternal(n,t,i)}option(t,n){return this.optionInternal(n,t)}or(t,n){return this.orInternal(n,t)}many(t,n){return this.manyInternal(t,n)}atLeastOne(t,n){return this.atLeastOneInternal(t,n)}CONSUME(t,n){return this.consumeInternal(t,0,n)}CONSUME1(t,n){return this.consumeInternal(t,1,n)}CONSUME2(t,n){return this.consumeInternal(t,2,n)}CONSUME3(t,n){return this.consumeInternal(t,3,n)}CONSUME4(t,n){return this.consumeInternal(t,4,n)}CONSUME5(t,n){return this.consumeInternal(t,5,n)}CONSUME6(t,n){return this.consumeInternal(t,6,n)}CONSUME7(t,n){return this.consumeInternal(t,7,n)}CONSUME8(t,n){return this.consumeInternal(t,8,n)}CONSUME9(t,n){return this.consumeInternal(t,9,n)}SUBRULE(t,n){return this.subruleInternal(t,0,n)}SUBRULE1(t,n){return this.subruleInternal(t,1,n)}SUBRULE2(t,n){return this.subruleInternal(t,2,n)}SUBRULE3(t,n){return this.subruleInternal(t,3,n)}SUBRULE4(t,n){return this.subruleInternal(t,4,n)}SUBRULE5(t,n){return this.subruleInternal(t,5,n)}SUBRULE6(t,n){return this.subruleInternal(t,6,n)}SUBRULE7(t,n){return this.subruleInternal(t,7,n)}SUBRULE8(t,n){return this.subruleInternal(t,8,n)}SUBRULE9(t,n){return this.subruleInternal(t,9,n)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,n,i=ct){if(this.definedRulesNames.includes(t)){let l={message:Ce.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:re.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(l)}this.definedRulesNames.push(t);let a=this.defineRule(t,n,i);return this[t]=a,a}OVERRIDE_RULE(t,n,i=ct){let a=Si(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(a);let o=this.defineRule(t,n,i);return this[t]=o,o}BACKTRACK(t,n){var i;let a=(i=t.coreRule)!==null&&i!==void 0?i:t;return function(){this.isBackTrackingStack.push(1);let o=this.saveRecogState();try{return a.apply(this,n),!0}catch(l){if(Ge(l))return!1;else throw l}finally{this.reloadRecogState(o),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Wt(Object.values(this.gastProductionsCache))}}class an{initRecognizerEngine(t,n){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=at,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(n,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
91
91
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
92
92
|
For Further details.`);if(Array.isArray(t)){if(t.length===0)throw Error(`A Token Vocabulary cannot be empty.
|
|
93
93
|
Note that the first argument for the parser constructor
|
|
94
94
|
is no longer a Token vector (since v4.0).`);if(typeof t[0].startOffset==="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
95
95
|
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
96
|
-
For Further details.`)}if(Array.isArray(t))this.tokensMap=t.reduce((o,l)=>(o[l.name]=l,o),{});else if(Object.hasOwn(t,"modes")&&Object.values(t.modes).flat().every(zn)){let o=Object.values(t.modes).flat(),l=[...new Set(o)];this.tokensMap=l.reduce((h,u)=>(h[u.name]=u,h),{})}else if(typeof t==="object"&&t!==null)this.tokensMap=Object.assign({},t);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=
|
|
97
|
-
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let a=Object.hasOwn(i,"resyncEnabled")?i.resyncEnabled:ct.resyncEnabled,o=Object.hasOwn(i,"recoveryValueFunc")?i.recoveryValueFunc:ct.recoveryValueFunc,l=this.ruleShortNameIdx++;this.shortRuleNameToFull[l]=t,this.fullRuleNameToShort[t]=l;let h;if(this.outputCst===!0)h=function(...f){try{this.ruleInvocationStateUpdate(l,t,this.subruleIdx),n.apply(this,f);let m=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(m),m}catch(m){return this.invokeRuleCatch(m,a,o)}finally{this.ruleFinallyStateUpdate()}};else h=function(...f){try{return this.ruleInvocationStateUpdate(l,t,this.subruleIdx),n.apply(this,f)}catch(m){return this.invokeRuleCatch(m,a,o)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...f){this.onBeforeParse(t);try{return h.apply(this,f)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:n,coreRule:h})}invokeRuleCatch(t,n,i){let a=this.RULE_STACK_IDX===0,o=n&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(t)){let l=t;if(o){let h=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(h))if(l.resyncedTokens=this.reSyncTo(h),this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];return u.recoveredNode=!0,u}else return i(t);else{if(this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];u.recoveredNode=!0,l.partialCstResult=u}throw l}}else if(a)return this.moveToTerminatedState(),i(t);else throw l}else throw t}optionInternal(t,n){let i=ps|n;return this.optionInternalLogic(t,n,i)}optionInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof t!=="function"){o=t.DEF;let l=t.GATE;if(l!==void 0){let h=a;a=()=>l.call(this)&&h.call(this)}}else o=t;if(a.call(this)===!0)return o.call(this);return}atLeastOneInternal(t,n){let i=Mt|t;return this.atLeastOneInternalLogic(t,n,i)}atLeastOneInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof n!=="function"){o=n.DEF;let l=n.GATE;if(l!==void 0){let h=a;a=()=>l.call(this)&&h.call(this)}}else o=n;if(a.call(this)===!0){let l=this.doSingleRepetition(o);while(a.call(this)===!0&&l===!0)l=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY,n.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,n],a,Mt,t,Ks)}atLeastOneSepFirstInternal(t,n){let i=lt|t;this.atLeastOneSepFirstInternalLogic(t,n,i)}atLeastOneSepFirstInternalLogic(t,n,i){let{DEF:a,SEP:o}=n;if(this.currRuleLookaheadFuncs[i].call(this)===!0){a.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),o);while(this.tokenMatcher(this.LA_FAST(1),o)===!0)this.CONSUME(o),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,h,a,ns],h,lt,t,ns)}else throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY_WITH_SEPARATOR,n.ERR_MSG)}manyInternal(t,n){let i=vt|t;return this.manyInternalLogic(t,n,i)}manyInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof n!=="function"){o=n.DEF;let h=n.GATE;if(h!==void 0){let u=a;a=()=>h.call(this)&&u.call(this)}}else o=n;let l=!0;while(a.call(this)===!0&&l===!0)l=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[t,n],a,vt,t,js,l)}manySepFirstInternal(t,n){let i=wt|t;this.manySepFirstInternalLogic(t,n,i)}manySepFirstInternalLogic(t,n,i){let{DEF:a,SEP:o}=n;if(this.currRuleLookaheadFuncs[i].call(this)===!0){a.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),o);while(this.tokenMatcher(this.LA_FAST(1),o)===!0)this.CONSUME(o),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,h,a,ss],h,wt,t,ss)}}repetitionSepSecondInternal(t,n,i,a,o){while(i())this.CONSUME(n),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,n,i,a,o],i,lt,t,o)}doSingleRepetition(t){let n=this.getLexerPosition();return t.call(this),this.getLexerPosition()>n}orInternal(t,n){let i=ds|n,a=Array.isArray(t)?t:t.DEF,l=this.currRuleLookaheadFuncs[i].call(this,a);if(l!==void 0)return a[l].ALT.call(this);this.raiseNoAltException(n,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName];this.cstFinallyStateUpdate()}subruleInternal(t,n,i){let a;try{let o=i!==void 0?i.ARGS:void 0;return this.subruleIdx=n,a=t.coreRule.apply(this,o),this.cstPostNonTerminal(a,i!==void 0&&i.LABEL!==void 0?i.LABEL:t.ruleName),a}catch(o){throw this.subruleInternalError(o,i,t.ruleName)}}subruleInternalError(t,n,i){if(Ge(t)&&t.partialCstResult!==void 0)this.cstPostNonTerminal(t.partialCstResult,n!==void 0&&n.LABEL!==void 0?n.LABEL:i),delete t.partialCstResult;throw t}consumeInternal(t,n,i){let a;try{let o=this.LA_FAST(1);if(this.tokenMatcher(o,t)===!0)this.consumeToken(),a=o;else this.consumeInternalError(t,o,i)}catch(o){a=this.consumeInternalRecovery(t,n,o)}return this.cstPostTerminal(i!==void 0&&i.LABEL!==void 0?i.LABEL:t.name,a),a}consumeInternalError(t,n,i){let a,o=this.LA(0);if(i!==void 0&&i.ERR_MSG)a=i.ERR_MSG;else a=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:n,previous:o,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ot(a,n,o))}consumeInternalRecovery(t,n,i){if(this.recoveryEnabled&&i.name==="MismatchedTokenException"&&!this.isBackTracking()){let a=this.getFollowsForInRuleRecovery(t,n);try{return this.tryInRuleRecovery(t,a)}catch(o){if(o.name===Ys)throw i;else throw o}}else throw i}saveRecogState(){let t=this.errors,n=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:n,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);let n=t.RULE_STACK;for(let i=0;i<n.length;i++)this.RULE_STACK[i]=n[i];if(this.RULE_STACK_IDX=n.length-1,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]}ruleInvocationStateUpdate(t,n,i){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=i,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[t],this.cstInvocationStateUpdate(n)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),
|
|
96
|
+
For Further details.`)}if(Array.isArray(t))this.tokensMap=t.reduce((o,l)=>(o[l.name]=l,o),{});else if(Object.hasOwn(t,"modes")&&Object.values(t.modes).flat().every(zn)){let o=Object.values(t.modes).flat(),l=[...new Set(o)];this.tokensMap=l.reduce((h,u)=>(h[u.name]=u,h),{})}else if(typeof t==="object"&&t!==null)this.tokensMap=Object.assign({},t);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Re;let a=(Object.hasOwn(t,"modes")?Object.values(t.modes).flat():Object.values(t)).every((o)=>{var l;return((l=o.categoryMatches)===null||l===void 0?void 0:l.length)==0});this.tokenMatcher=a?at:Ue,Pe(Object.values(this.tokensMap))}defineRule(t,n,i){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
97
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let a=Object.hasOwn(i,"resyncEnabled")?i.resyncEnabled:ct.resyncEnabled,o=Object.hasOwn(i,"recoveryValueFunc")?i.recoveryValueFunc:ct.recoveryValueFunc,l=this.ruleShortNameIdx++;this.shortRuleNameToFull[l]=t,this.fullRuleNameToShort[t]=l;let h;if(this.outputCst===!0)h=function(...f){try{this.ruleInvocationStateUpdate(l,t,this.subruleIdx),n.apply(this,f);let m=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(m),m}catch(m){return this.invokeRuleCatch(m,a,o)}finally{this.ruleFinallyStateUpdate()}};else h=function(...f){try{return this.ruleInvocationStateUpdate(l,t,this.subruleIdx),n.apply(this,f)}catch(m){return this.invokeRuleCatch(m,a,o)}finally{this.ruleFinallyStateUpdate()}};return Object.assign(function(...f){this.onBeforeParse(t);try{return h.apply(this,f)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:n,coreRule:h})}invokeRuleCatch(t,n,i){let a=this.RULE_STACK_IDX===0,o=n&&!this.isBackTracking()&&this.recoveryEnabled;if(Ge(t)){let l=t;if(o){let h=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(h))if(l.resyncedTokens=this.reSyncTo(h),this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];return u.recoveredNode=!0,u}else return i(t);else{if(this.outputCst){let u=this.CST_STACK[this.CST_STACK.length-1];u.recoveredNode=!0,l.partialCstResult=u}throw l}}else if(a)return this.moveToTerminatedState(),i(t);else throw l}else throw t}optionInternal(t,n){let i=ps|n;return this.optionInternalLogic(t,n,i)}optionInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof t!=="function"){o=t.DEF;let l=t.GATE;if(l!==void 0){let h=a;a=()=>l.call(this)&&h.call(this)}}else o=t;if(a.call(this)===!0)return o.call(this);return}atLeastOneInternal(t,n){let i=Mt|t;return this.atLeastOneInternalLogic(t,n,i)}atLeastOneInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof n!=="function"){o=n.DEF;let l=n.GATE;if(l!==void 0){let h=a;a=()=>l.call(this)&&h.call(this)}}else o=n;if(a.call(this)===!0){let l=this.doSingleRepetition(o);while(a.call(this)===!0&&l===!0)l=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY,n.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,n],a,Mt,t,Ks)}atLeastOneSepFirstInternal(t,n){let i=lt|t;this.atLeastOneSepFirstInternalLogic(t,n,i)}atLeastOneSepFirstInternalLogic(t,n,i){let{DEF:a,SEP:o}=n;if(this.currRuleLookaheadFuncs[i].call(this)===!0){a.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),o);while(this.tokenMatcher(this.LA_FAST(1),o)===!0)this.CONSUME(o),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,h,a,ns],h,lt,t,ns)}else throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY_WITH_SEPARATOR,n.ERR_MSG)}manyInternal(t,n){let i=vt|t;return this.manyInternalLogic(t,n,i)}manyInternalLogic(t,n,i){let a=this.currRuleLookaheadFuncs[i],o;if(typeof n!=="function"){o=n.DEF;let h=n.GATE;if(h!==void 0){let u=a;a=()=>h.call(this)&&u.call(this)}}else o=n;let l=!0;while(a.call(this)===!0&&l===!0)l=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[t,n],a,vt,t,js,l)}manySepFirstInternal(t,n){let i=wt|t;this.manySepFirstInternalLogic(t,n,i)}manySepFirstInternalLogic(t,n,i){let{DEF:a,SEP:o}=n;if(this.currRuleLookaheadFuncs[i].call(this)===!0){a.call(this);let h=()=>this.tokenMatcher(this.LA_FAST(1),o);while(this.tokenMatcher(this.LA_FAST(1),o)===!0)this.CONSUME(o),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,h,a,ss],h,wt,t,ss)}}repetitionSepSecondInternal(t,n,i,a,o){while(i())this.CONSUME(n),a.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,n,i,a,o],i,lt,t,o)}doSingleRepetition(t){let n=this.getLexerPosition();return t.call(this),this.getLexerPosition()>n}orInternal(t,n){let i=ds|n,a=Array.isArray(t)?t:t.DEF,l=this.currRuleLookaheadFuncs[i].call(this,a);if(l!==void 0)return a[l].ALT.call(this);this.raiseNoAltException(n,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName];this.cstFinallyStateUpdate()}subruleInternal(t,n,i){let a;try{let o=i!==void 0?i.ARGS:void 0;return this.subruleIdx=n,a=t.coreRule.apply(this,o),this.cstPostNonTerminal(a,i!==void 0&&i.LABEL!==void 0?i.LABEL:t.ruleName),a}catch(o){throw this.subruleInternalError(o,i,t.ruleName)}}subruleInternalError(t,n,i){if(Ge(t)&&t.partialCstResult!==void 0)this.cstPostNonTerminal(t.partialCstResult,n!==void 0&&n.LABEL!==void 0?n.LABEL:i),delete t.partialCstResult;throw t}consumeInternal(t,n,i){let a;try{let o=this.LA_FAST(1);if(this.tokenMatcher(o,t)===!0)this.consumeToken(),a=o;else this.consumeInternalError(t,o,i)}catch(o){a=this.consumeInternalRecovery(t,n,o)}return this.cstPostTerminal(i!==void 0&&i.LABEL!==void 0?i.LABEL:t.name,a),a}consumeInternalError(t,n,i){let a,o=this.LA(0);if(i!==void 0&&i.ERR_MSG)a=i.ERR_MSG;else a=this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:n,previous:o,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ot(a,n,o))}consumeInternalRecovery(t,n,i){if(this.recoveryEnabled&&i.name==="MismatchedTokenException"&&!this.isBackTracking()){let a=this.getFollowsForInRuleRecovery(t,n);try{return this.tryInRuleRecovery(t,a)}catch(o){if(o.name===Ys)throw i;else throw o}}else throw i}saveRecogState(){let t=this.errors,n=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:n,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);let n=t.RULE_STACK;for(let i=0;i<n.length;i++)this.RULE_STACK[i]=n[i];if(this.RULE_STACK_IDX=n.length-1,this.RULE_STACK_IDX>=0)this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]}ruleInvocationStateUpdate(t,n,i){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=i,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[t],this.cstInvocationStateUpdate(n)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Re)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(t){for(let n=0;n<this.maxLookahead+1;n++)this.tokVector.push(De)}onAfterParse(t){if(this.isAtEndOfInput()===!1){let n=this.LA(1),i=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:n,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new hs(i,n))}while(this.tokVector.at(-1)===De)this.tokVector.pop()}}class on{initErrorHandler(t){this._errors=[],this.errorMessageProvider=Object.hasOwn(t,"errorMessageProvider")?t.errorMessageProvider:me.errorMessageProvider}SAVE_ERROR(t){if(Ge(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(t),t;else throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(t){this._errors=t}raiseEarlyExitException(t,n,i){let a=this.getCurrRuleFullName(),o=this.getGAstProductions()[a],h=_t(t,o,n,this.maxLookahead)[0],u=[];for(let d=1;d<=this.maxLookahead;d++)u.push(this.LA(d));let c=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:h,actual:u,previous:this.LA(0),customUserDescription:i,ruleName:a});throw this.SAVE_ERROR(new us(c,this.LA(1),this.LA(0)))}raiseNoAltException(t,n){let i=this.getCurrRuleFullName(),a=this.getGAstProductions()[i],o=bt(t,a,this.maxLookahead),l=[];for(let c=1;c<=this.maxLookahead;c++)l.push(this.LA(c));let h=this.LA(0),u=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:o,actual:l,previous:h,customUserDescription:n,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new cs(u,this.LA(1),h))}}var Ts={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Ts);var wi=!0,Ui=255,Di=k({name:"RECORDING_PHASE_TOKEN",pattern:z.NA});Pe([Di]);var Fi=qe(Di,`This IToken indicates the Parser is in Recording Phase
|
|
98
98
|
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Fi);var Ba={name:`This CSTNode indicates the Parser is in Recording Phase
|
|
99
|
-
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class ln{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let n=t>0?t:"";this[`CONSUME${n}`]=function(i,a){return this.consumeInternalRecord(i,t,a)},this[`SUBRULE${n}`]=function(i,a){return this.subruleInternalRecord(i,t,a)},this[`OPTION${n}`]=function(i){return this.optionInternalRecord(i,t)},this[`OR${n}`]=function(i){return this.orInternalRecord(i,t)},this[`MANY${n}`]=function(i){this.manyInternalRecord(t,i)},this[`MANY_SEP${n}`]=function(i){this.manySepFirstInternalRecord(t,i)},this[`AT_LEAST_ONE${n}`]=function(i){this.atLeastOneInternalRecord(t,i)},this[`AT_LEAST_ONE_SEP${n}`]=function(i){this.atLeastOneSepFirstInternalRecord(t,i)}}this.consume=function(t,n,i){return this.consumeInternalRecord(n,t,i)},this.subrule=function(t,n,i){return this.subruleInternalRecord(n,t,i)},this.option=function(t,n){return this.optionInternalRecord(n,t)},this.or=function(t,n){return this.orInternalRecord(n,t)},this.many=function(t,n){this.manyInternalRecord(t,n)},this.atLeastOne=function(t,n){this.atLeastOneInternalRecord(t,n)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let t=this;for(let n=0;n<10;n++){let i=n>0?n:"";delete t[`CONSUME${i}`],delete t[`SUBRULE${i}`],delete t[`OPTION${i}`],delete t[`OR${i}`],delete t[`MANY${i}`],delete t[`MANY_SEP${i}`],delete t[`AT_LEAST_ONE${i}`],delete t[`AT_LEAST_ONE_SEP${i}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,n){return()=>!0}LA_RECORD(t){return De}topLevelRuleRecord(t,n){try{let i=new
|
|
99
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class ln{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){let n=t>0?t:"";this[`CONSUME${n}`]=function(i,a){return this.consumeInternalRecord(i,t,a)},this[`SUBRULE${n}`]=function(i,a){return this.subruleInternalRecord(i,t,a)},this[`OPTION${n}`]=function(i){return this.optionInternalRecord(i,t)},this[`OR${n}`]=function(i){return this.orInternalRecord(i,t)},this[`MANY${n}`]=function(i){this.manyInternalRecord(t,i)},this[`MANY_SEP${n}`]=function(i){this.manySepFirstInternalRecord(t,i)},this[`AT_LEAST_ONE${n}`]=function(i){this.atLeastOneInternalRecord(t,i)},this[`AT_LEAST_ONE_SEP${n}`]=function(i){this.atLeastOneSepFirstInternalRecord(t,i)}}this.consume=function(t,n,i){return this.consumeInternalRecord(n,t,i)},this.subrule=function(t,n,i){return this.subruleInternalRecord(n,t,i)},this.option=function(t,n){return this.optionInternalRecord(n,t)},this.or=function(t,n){return this.orInternalRecord(n,t)},this.many=function(t,n){this.manyInternalRecord(t,n)},this.atLeastOne=function(t,n){this.atLeastOneInternalRecord(t,n)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let t=this;for(let n=0;n<10;n++){let i=n>0?n:"";delete t[`CONSUME${i}`],delete t[`SUBRULE${i}`],delete t[`OPTION${i}`],delete t[`OR${i}`],delete t[`MANY${i}`],delete t[`MANY_SEP${i}`],delete t[`AT_LEAST_ONE${i}`],delete t[`AT_LEAST_ONE_SEP${i}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,n){return()=>!0}LA_RECORD(t){return De}topLevelRuleRecord(t,n){try{let i=new Te({definition:[],name:t});return i.name=t,this.recordingProdStack.push(i),n.call(this),this.recordingProdStack.pop(),i}catch(i){if(i.KNOWN_RECORDER_ERROR!==!0)try{i.message=i.message+`
|
|
100
100
|
This error was thrown during the "grammar recording phase" For more info see:
|
|
101
101
|
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(a){throw i}throw i}}optionInternalRecord(t,n){return Ut.call(this,K,t,n)}atLeastOneInternalRecord(t,n){Ut.call(this,Z,n,t)}atLeastOneSepFirstInternalRecord(t,n){Ut.call(this,Q,n,t,wi)}manyInternalRecord(t,n){Ut.call(this,G,n,t)}manySepFirstInternalRecord(t,n){Ut.call(this,q,n,t,wi)}orInternalRecord(t,n){return $a.call(this,t,n)}subruleInternalRecord(t,n,i){if(Es(n),!t||!Object.hasOwn(t,"ruleName")){let h=Error(`<SUBRULE${Pi(n)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
|
|
102
102
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw h.KNOWN_RECORDER_ERROR=!0,h}let a=this.recordingProdStack.at(-1),o=t.ruleName,l=new W({idx:n,nonTerminalName:o,label:i===null||i===void 0?void 0:i.LABEL,referencedRule:void 0});return a.definition.push(l),this.outputCst?Ba:Ts}consumeInternalRecord(t,n,i){if(Es(n),!Bs(t)){let l=Error(`<CONSUME${Pi(n)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
|
|
103
103
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw l.KNOWN_RECORDER_ERROR=!0,l}let a=this.recordingProdStack.at(-1),o=new F({idx:n,terminalType:t,label:i===null||i===void 0?void 0:i.LABEL});return a.definition.push(o),Fi}}function Ut(t,n,i,a=!1){Es(i);let o=this.recordingProdStack.at(-1),l=typeof n==="function"?n:n.DEF,h=new t({definition:[],idx:i});if(a)h.separator=n.SEP;if(Object.hasOwn(n,"MAX_LOOKAHEAD"))h.maxLookahead=n.MAX_LOOKAHEAD;return this.recordingProdStack.push(h),l.call(this),o.definition.push(h),this.recordingProdStack.pop(),Ts}function $a(t,n){Es(n);let i=this.recordingProdStack.at(-1),a=Array.isArray(t)===!1,o=a===!1?t:t.DEF,l=new J({definition:[],idx:n,ignoreAmbiguities:a&&t.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(t,"MAX_LOOKAHEAD"))l.maxLookahead=t.MAX_LOOKAHEAD;let h=o.some((u)=>typeof u.GATE==="function");return l.hasPredicates=h,i.definition.push(l),o.forEach((u)=>{let c=new j({definition:[]});if(l.definition.push(c),Object.hasOwn(u,"IGNORE_AMBIGUITIES"))c.ignoreAmbiguities=u.IGNORE_AMBIGUITIES;else if(Object.hasOwn(u,"GATE"))c.ignoreAmbiguities=!0;this.recordingProdStack.push(c),u.ALT.call(this),this.recordingProdStack.pop()}),Ts}function Pi(t){return t===0?"":`${t}`}function Es(t){if(t<0||t>Ui){let n=Error(`Invalid DSL Method idx value: <${t}>
|
|
104
|
-
Idx value must be a none negative value smaller than ${Ui+1}`);throw n.KNOWN_RECORDER_ERROR=!0,n}}class cn{initPerformanceTracer(t){if(Object.hasOwn(t,"traceInitPerf")){let n=t.traceInitPerf,i=typeof n==="number";this.traceInitMaxIdent=i?n:1/0,this.traceInitPerf=i?n>0:n}else this.traceInitMaxIdent=0,this.traceInitPerf=
|
|
104
|
+
Idx value must be a none negative value smaller than ${Ui+1}`);throw n.KNOWN_RECORDER_ERROR=!0,n}}class cn{initPerformanceTracer(t){if(Object.hasOwn(t,"traceInitPerf")){let n=t.traceInitPerf,i=typeof n==="number";this.traceInitMaxIdent=i?n:1/0,this.traceInitPerf=i?n>0:n}else this.traceInitMaxIdent=0,this.traceInitPerf=me.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,n){if(this.traceInitPerf===!0){this.traceInitIndent++;let i=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${i}--> <${t}>`);let{time:a,value:o}=At(n),l=a>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)l(`${i}<-- <${t}> time: ${a}ms`);return this.traceInitIndent--,o}else return n()}}function Bi(t,n){n.forEach((i)=>{let a=i.prototype;Object.getOwnPropertyNames(a).forEach((o)=>{if(o==="constructor")return;let l=Object.getOwnPropertyDescriptor(a,o);if(l&&(l.get||l.set))Object.defineProperty(t.prototype,o,l);else t.prototype[o]=i.prototype[o]})})}var De=qe(Re,"",-1,-1,-1,-1,-1,-1);Object.freeze(De);var me=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ts,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ct=Object.freeze({recoveryValueFunc:()=>{return},resyncEnabled:!0}),re;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(re||(re={}));class Pt{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;let n=this.className;this.TRACE_INIT("toFastProps",()=>{St(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach((a)=>{let l=this[a].originalGrammarAction,h;this.TRACE_INIT(`${a} Rule`,()=>{h=this.topLevelRuleRecord(a,l)}),this.gastProductionsCache[a]=h})}finally{this.disableRecording()}});let i=[];if(this.TRACE_INIT("Grammar Resolving",()=>{i=Ni({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(i)}),this.TRACE_INIT("Grammar Validations",()=>{if(i.length===0&&this.skipValidations===!1){let a=Ii({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:Ce,grammarName:n}),o=Ei({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(a,o)}}),this.definitionErrors.length===0){if(this.recoveryEnabled)this.TRACE_INIT("computeAllProdsFollows",()=>{let a=kn(Object.values(this.gastProductionsCache));this.resyncFollows=a});this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var a,o;(o=(a=this.lookaheadStrategy).initialize)===null||o===void 0||o.call(a,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})}if(!Pt.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw t=this.definitionErrors.map((a)=>a.message),Error(`Parser Definition Errors detected:
|
|
105
105
|
${t.join(`
|
|
106
106
|
-------------------------------
|
|
107
107
|
`)}`)})}constructor(t,n){this.definitionErrors=[],this.selfAnalysisDone=!1;let i=this;if(i.initErrorHandler(n),i.initLexerAdapter(),i.initLooksAhead(n),i.initRecognizerEngine(t,n),i.initRecoverable(n),i.initTreeBuilder(n),i.initGastRecorder(n),i.initPerformanceTracer(n),Object.hasOwn(n,"ignoredIssues"))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
108
108
|
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
109
109
|
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
110
|
-
For further details.`);this.skipValidations=Object.hasOwn(n,"skipValidations")?n.skipValidations:
|
|
110
|
+
For further details.`);this.skipValidations=Object.hasOwn(n,"skipValidations")?n.skipValidations:me.skipValidations}}Pt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Bi(Pt,[qs,Js,sn,nn,an,rn,on,ln,cn]);class gs extends Pt{constructor(t,n=me){let i=Object.assign({},n);i.outputCst=!0;super(t,i)}}var ut=e((t)=>t!==void 0&&t>=0,"isKnownLocation");function Xi(t,n){let i=t.lexer.tokenize(n);if(i.errors.length>0){let o=i.errors[0],l=ut(o.offset)?o.offset:n.length,h=l+(ut(o.length)?o.length:0);throw Error(`Error lexing ${t.diagramType} diagram: ${o.message} at line ${o.line??1}, column ${o.column??1} [${l},${h})`)}t.parser.input=i.tokens;let a=t.entry();if(t.parser.errors.length>0)throw Error(`Error parsing ${t.diagramType} diagram: ${t.parser.errors[0].message}`);t.visit(a)}e(Xi,"runChevrotainParse");var X={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Wa="LR",ja=D.usecase,Tn=e(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Wa,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(ja)}),"createModel"),Ka=e((t)=>{if(!(t.actors instanceof Map)||!(t.useCases instanceof Map)||!(t.systemBoundaries instanceof Map)||!Array.isArray(t.relationships)||!(t.notes instanceof Map)||!(t.jsonNodes instanceof Map)||!(t.classDefs instanceof Map)||!(t.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(t.direction)||!Number.isSafeInteger(t.relationshipCounter)||t.relationshipCounter<0||!Number.isSafeInteger(t.noteCounter)||t.noteCounter<0||typeof t.accTitle!=="string"||typeof t.accDescription!=="string"||!t.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),B=Tn(),Va=e(()=>structuredClone(B.config),"getConfig"),za=e(()=>B.ast,"getAST"),Ha=e((t)=>{let n=structuredClone(t);Ka(n);let i=E(),a=A();try{S(n.accTitle),T(n.accDescription),B=n}catch(o){throw S(i),T(a),o}},"commit"),Xa=e(()=>{B=Tn(),C()},"clear"),Ya=e(()=>B.actors,"getActors"),qa=e((t)=>B.actors.get(t),"getActor"),Ja=e(()=>B.useCases,"getUseCases"),Za=e((t)=>B.useCases.get(t),"getUseCase"),Qa=e(()=>B.systemBoundaries,"getSystemBoundaries"),eo=e((t)=>B.systemBoundaries.get(t),"getSystemBoundary"),to=e(()=>B.relationships,"getRelationships"),so=e(()=>B.notes,"getNotes"),no=e((t)=>B.notes.get(t),"getNote"),io=e(()=>B.jsonNodes,"getJsonNodes"),ro=e((t)=>B.jsonNodes.get(t),"getJsonNode"),ao=e(()=>B.classDefs,"getClassDefs"),oo=e((t)=>B.classDefs.get(t),"getClassDef"),Yi=e(()=>B.direction,"getDirection"),Je=e((t)=>{let n=new Map;for(let i of["default",...t]){let a=B.classDefs.get(i);if(!a)continue;for(let o of a.styles){let l=o.trim(),h=l.indexOf(":"),u=(h===-1?l:l.slice(0,h)).trim();if(u)n.set(u,l)}}return[...n.values()]},"getCompiledStyles"),lo=e((t)=>t.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),$i=e((t)=>typeof t==="string"?t:t===null?"null":String(t),"displayJsonScalar"),co=e((t,n,i=(a)=>a)=>{let a=[],o=e((h,u,c)=>{a.push({key:i(h),accessibleKey:i(u),value:i(c)})},"append"),l=e((h,u,c)=>{if(Array.isArray(h)){if(h.length===0){o(u,u,"[]");return}if(h.every((f)=>f===null||["string","number","boolean"].includes(typeof f))){for(let[f,m]of h.entries())o(f===0?u:"",u,$i(m));return}for(let[f,m]of h.entries())l(m,`${u}[${f}]`,`${c}/${f}`);return}if(h!==null&&typeof h==="object"){let d=h,f=n[c]??Object.keys(d);if(f.length===0){o(u,u,"{}");return}for(let m of f){let R=u?`${u}.${m}`:m;l(d[m],R,`${c}/${lo(m)}`)}return}o(u,u,$i(h))},"visit");return l(t,"",""),a},"flattenJsonRows"),ho=e((t)=>{switch(t.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),uo=e((t)=>{if(t.shape==="ellipse")return t.business?"usecaseBusiness":"usecaseEllipse";return t.shape},"useCaseShape"),po=e((t)=>{switch(t){case X.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case X.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case X.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case X.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case X.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case X.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case X.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),fo=e((t)=>{switch(t.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:t.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...po(t.arrowType),pattern:"solid",...t.label?{label:t.label}:{},...t.labelType?{labelType:t.labelType}:{}}}},"relationshipVisuals"),mo=e((t)=>t.animate||t.animation?[`edge-animation-${t.animation??"fast"}`]:[],"animationClasses"),Dt=e((...t)=>t.filter((n)=>Boolean(n)).join(" "),"classNames"),Eo=e(()=>{let t=s(),n={...B.config,...t.usecase},i=e((c)=>O(c,t),"sanitize"),a=e((c)=>i(B.actors.get(c)?.label??B.useCases.get(c)?.label??B.jsonNodes.get(c)?.id??B.notes.get(c)?.label??c),"endpointLabel"),o=[],l=[],h=0,u=0;for(let c of B.actors.values())o.push({id:c.id,label:i(c.label),labelType:c.labelType,shape:ho(c),isGroup:!1,padding:10,look:t.look,colorIndex:h++,cssClasses:Dt("default","usecase-actor",`usecase-actor-${c.type}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),actorType:c.type,business:c.business,...c.icon?{icon:c.icon}:{},...c.stereotype?{stereotype:i(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of B.useCases.values())o.push({id:c.id,label:i(c.label),labelType:c.labelType,shape:uo(c),isGroup:!1,padding:c.shape==="ellipse"?20:10,look:t.look,colorIndex:h++,cssClasses:Dt("default","usecase-element",`usecase-${c.shape}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),business:c.business,...c.stereotype?{stereotype:i(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of B.notes.values())o.push({id:c.id,label:i(c.label),labelType:c.labelType,shape:"note",isGroup:!1,padding:10,look:t.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:c.target,noteTargetLabel:i(B.actors.get(c.target)?.label??B.useCases.get(c.target)?.label??B.jsonNodes.get(c.target)?.id??c.target)});for(let c of B.jsonNodes.values())o.push({id:c.id,label:i(c.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:t.look,cssClasses:Dt("default","usecase-json-table",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),jsonRows:co(c.value,c.propertyOrder,i)});for(let c of B.systemBoundaries.values())o.push({id:c.id,label:i(c.label),labelType:c.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:t.look,colorIndex:u++,cssClasses:Dt("default","system-boundary",`system-boundary-${c.type}`,...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Je(c.classes),boundaryType:c.type});for(let c of B.relationships){let{label:d,...f}=fo(c);l.push({id:c.id,start:c.source,end:c.target,source:c.source,target:c.target,sourceLabel:a(c.source),targetLabel:a(c.target),type:"edge",relationshipType:c.type,internal:!1,...f,...d!==void 0?{label:i(d)}:{},labelpos:"c",classes:Dt("default","relationship",`relationship-${c.type}`,...c.classes,...mo(c)),style:[...c.styles],cssCompiledStyles:Je(c.classes),animate:c.animate,...c.animation?{animation:c.animation}:{},look:t.look,thickness:"normal",minlen:c.minlen,isUserDefinedId:c.explicitId})}for(let c of B.notes.values())l.push({id:`${c.id}-edge`,start:c.id,end:c.target,source:c.id,target:c.target,type:"edge",relationshipType:"note",sourceLabel:a(c.id),targetLabel:a(c.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:t.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let c of o){if(c.wrappingWidth??=n.wrappingWidth,!c.isGroup&&!c.shape.startsWith("usecaseActor"))c.minWidth??=n.minNodeWidth;if(c.shape==="usecaseEllipse"||c.shape==="usecaseBusiness")c.spreadPorts=!0}return{nodes:o,edges:l,config:t,type:"usecase",layoutAlgorithm:"dagre",direction:Yi(),nodeSpacing:n.nodeSpacing,rankSpacing:n.rankSpacing,actorFontSize:n.actorFontSize,actorFontFamily:n.actorFontFamily,actorFontWeight:n.actorFontWeight,usecaseFontSize:n.usecaseFontSize,usecaseFontFamily:n.usecaseFontFamily,usecaseFontWeight:n.usecaseFontWeight,diagramPadding:n.diagramPadding,useMaxWidth:n.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ns={getConfig:Va,createModel:Tn,commit:Ha,getAST:za,clear:Xa,setDiagramTitle:I,getDiagramTitle:L,setAccTitle:S,getAccTitle:E,setAccDescription:T,getAccDescription:A,getActors:Ya,getActor:qa,getUseCases:Ja,getUseCase:Za,getSystemBoundaries:Qa,getSystemBoundary:eo,getRelationships:to,getNotes:so,getNote:no,getJsonNodes:io,getJsonNode:ro,getClassDefs:ao,getClassDef:oo,getDirection:Yi,getData:Eo};function Qe(t,n,i){let a=[i];return a.index=n,a.input=t,a}e(Qe,"customMatch");var To=e((t,n)=>{if(t[n]!=='"'||t[n+1]!=="`")return null;for(let i=n+2;i<t.length-1;i++)if(t[i]==="`"&&t[i+1]==='"')return Qe(t,n,t.slice(n,i+2));return null},"matchMarkdownString"),go=e((t,n)=>{if(t[n]!=="%"||t[n+1]!=="%")return null;for(let a=n-1;a>=0;a--){let o=t[a];if(o===`
|
|
111
111
|
`||o==="\r")break;if(o!==" "&&o!=="\t")return null}let i=n+2;while(i<t.length&&t[i]!==`
|
|
112
112
|
`&&t[i]!=="\r")i++;return Qe(t,n,t.slice(n,i))},"matchComment"),qi=e((t,n)=>{for(let i=n-1;i>=0;i--){let a=t[i];if(a===`
|
|
113
|
-
`||a==="\r")return!0;if(a!==" "&&a!=="\t")return!1}return!0},"isIndentedLineStart"),Ji=e((t,n,i)=>{if(!qi(t,n))return null;let a=i.exec(t.slice(n));return a?Qe(t,n,a[0]):null},"matchAccessibilityLine"),Ao=e((t,n)=>{if(!qi(t,n))return null;let i=/^accDescr[\t ]*{/.exec(t.slice(n));if(!i)return null;let a=t.indexOf("}",n+i[0].length);return a===-1?null:Qe(t,n,t.slice(n,a+1))},"matchAccDescrBlock"),So=e((t,n)=>{if(t[n]!=="{")return null;let i=0,a=!1,o=!1;for(let l=n;l<t.length;l++){let h=t[l];if(a){if(o)o=!1;else if(h==="\\")o=!0;else if(h==='"')a=!1;continue}if(h==='"')a=!0;else if(h==="{")i++;else if(h==="}"&&--i===0)return Qe(t,n,t.slice(n,l+1))}return null},"matchJsonObject"),Ro=e((t,n)=>{let i=t.indexOf(">>",n);if(i===-1||/[\n\r]/.test(t.slice(n,i)))return null;let a=t.slice(n,i);return a.trim()?Qe(t,n,a):null},"matchStereotypeText"),re=k({name:"LABEL_TEXT",pattern:z.NA}),dt=k({name:"WORD",pattern:z.NA,categories:re}),gn=k({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:re}),Y=k({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),yo=k({name:"HWS",pattern:/[\t ]+/,group:z.SKIPPED}),Be=k({name:"MARKDOWN_STRING",pattern:To,start_chars_hint:['"'],line_breaks:!0}),Oo=k({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=k({name:"COMMENT",pattern:go,start_chars_hint:["%"],line_breaks:!1}),Fe=k({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Zi=k({name:"ACC_DESCR_BLOCK",pattern:Ao,start_chars_hint:["a"],line_breaks:!0}),Lo=/^accTitle[\t ]*:[^\n\r]*/,No=/^accDescr[\t ]*:[^\n\r]*/,Qi=k({name:"ACC_TITLE_LINE",pattern:e((t,n)=>Ji(t,n,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=k({name:"ACC_DESCR_LINE",pattern:e((t,n)=>Ji(t,n,No),"pattern"),start_chars_hint:["a"],line_breaks:!1}),tr=k({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=k({name:"JSON_OBJECT_LITERAL",pattern:So,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),sr=k({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=e((t,n)=>k({name:t,pattern:n,longer_alt:Y,categories:dt}),"keyword"),nr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),ir=ee("SYSTEM_BOUNDARY",/systemBoundary/),rr=ee("END",/end/),ar=ee("DIRECTION",/direction/),or=ee("TD",/TD/),lr=ee("TB",/TB/),cr=ee("BT",/BT/),hr=ee("LR",/LR/),ur=ee("RL",/RL/),dr=ee("NOTE",/note/),pr=ee("FOR",/for/),Io=ee("JSON",/json/),fr=ee("CLASS_DEF",/classDef/),mr=ee("CLASS",/class/),Er=ee("STYLE",/style/),Tr=ee("INCLUDE",/include/i),gr=ee("EXTEND",/extend/i),Ar=ee("TRUE",/true/),Sr=ee("FALSE",/false/),Rr=k({name:"GENERALIZATION",pattern:/--\|>/}),yr=k({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),Or=k({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=k({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=k({name:"STEREOTYPE_TEXT",pattern:Ro,line_breaks:!1}),Lr=k({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Nr=k({name:"CLASS_SEPARATOR",pattern:/:::/}),As=k({name:"FORWARD_SOLID",pattern:/--+>/}),Ir=k({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=k({name:"FORWARD_CIRCLE",pattern:/--o/}),kr=k({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=k({name:"FORWARD_CROSS",pattern:/--x/}),Cr=k({name:"BACKWARD_CROSS",pattern:/x--/}),Ie=k({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=k({name:"METADATA_START",pattern:/@{/}),ys=k({name:"AT",pattern:/@/,categories:re}),br=k({name:"LBRACE",pattern:/{/}),fn=k({name:"RBRACE",pattern:/}/}),Os=k({name:"LBRACKET",pattern:/\[/}),Ls=k({name:"RBRACKET",pattern:/]/}),Ft=k({name:"LPAREN",pattern:/\(/}),Bt=k({name:"RPAREN",pattern:/\)/}),be=k({name:"COMMA",pattern:/,/,categories:re}),$t=k({name:"COLON",pattern:/:/,categories:re}),_r=k({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:re}),ke=k({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=k({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:re}),xr=k({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:re}),vr=k({name:"DASH",pattern:/-/,categories:re}),Mr=k({name:"DOT",pattern:/\./,categories:re}),wr=k({name:"PERCENT",pattern:/%/,categories:re}),Ur=k({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:re}),ko=k({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:re}),Co=k({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:re}),Pr=[re,dt,yo,Be,Oo,un,Fe,Zi,Qi,er,tr,nr,dn,ir,rr,ar,or,lr,cr,hr,ur,dr,pr,Io,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Or,Nr,As,Ir,Ss,kr,Rs,Cr,Ie,pn,ys,br,fn,Os,Ls,Ft,Bt,be,$t,_r,ke,mn,Y,gn,xr,vr,Mr,wr,Ur,ko,Co],bo={defaultMode:"defaultMode",modes:{defaultMode:[...Pr],jsonBody:[An,sr],stereotype:[Sn,Rn,Lr]}},_o=[...Pr,An,sr,Sn,Rn,Lr],xo=new z(bo),Gi=e((t)=>kt(t,re)||t.tokenType===ke||t.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{e(this,"UsecaseParser")}constructor(){super(_o,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(nr),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:e(()=>this.isStatementStart(),"GATE"),ALT:e(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:e(()=>this.isMetadataAssignment(),"GATE"),ALT:e(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:e(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:e(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:e(()=>this.CONSUME(Fe),"ALT")},{ALT:e(()=>this.CONSUME(ye),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Qi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:e(()=>this.CONSUME(er),"ALT")},{ALT:e(()=>this.CONSUME(Zi),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:e(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:e(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:e(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===ys,"GATE"),DEF:e(()=>{this.CONSUME(Y),this.CONSUME(ys)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:e(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Ie),this.OPTION({GATE:e(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Ie,Ss,Rs]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:e(()=>this.CONSUME(As),"ALT")},{ALT:e(()=>this.CONSUME2(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Ss),"ALT")},{ALT:e(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Cr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(re)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:e(()=>{this.CONSUME(yr),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME(Tr),"ALT")},{ALT:e(()=>this.CONSUME(gr),"ALT")}])},"ALT")},{ALT:e(()=>this.CONSUME(Rr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(be)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME2(Y),"ALT")},{ALT:e(()=>this.CONSUME2(ke),"ALT")},{ALT:e(()=>this.CONSUME(Ar),"ALT")},{ALT:e(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:e(()=>{this.CONSUME(be),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:e(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(be)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(ir),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(rr),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:e(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(dr),this.CONSUME(pr),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(Or),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Nr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)})}),this.RULE("jsonStatement",()=>{this.CONSUME(tr),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(ar),this.OR([{ALT:e(()=>this.CONSUME(or),"ALT")},{ALT:e(()=>this.CONSUME(lr),"ALT")},{ALT:e(()=>this.CONSUME(cr),"ALT")},{ALT:e(()=>this.CONSUME(hr),"ALT")},{ALT:e(()=>this.CONSUME(ur),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(fr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(mr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(be),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Er),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>{this.CONSUME(Ie),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(gn),"ALT")},{ALT:e(()=>this.CONSUME(_r),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>this.CONSUME(xr),"ALT")},{ALT:e(()=>this.CONSUME(vr),"ALT")},{ALT:e(()=>this.CONSUME(Mr),"ALT")},{ALT:e(()=>this.CONSUME(wr),"ALT")},{ALT:e(()=>this.CONSUME(Ur),"ALT")},{ALT:e(()=>this.CONSUME($t),"ALT")},{ALT:e(()=>this.CONSUME(Ft),"ALT")},{ALT:e(()=>this.CONSUME(Bt),"ALT")},{ALT:e(()=>this.CONSUME(Os),"ALT")},{ALT:e(()=>this.CONSUME(Ls),"ALT")},{ALT:e(()=>this.CONSUME(br),"ALT")},{ALT:e(()=>this.CONSUME(fn),"ALT")},{ALT:e(()=>this.CONSUME(ys),"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let t=this.LA(1).tokenType;return(t===Y||t===ke||t===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let t=this.LA(1).tokenType;return t!==ye&&t!==Fe&&t!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(t){if(!Gi(this.LA(1)))return!1;for(let n=2;;n++){let i=this.LA(n);if(t.includes(i.tokenType))return!0;if(!Gi(i))return!1}}},Gt=new Mo,Wi=class extends Error{constructor(t,n,i){super(`${t} (line ${n}, column ${i})`);this.line=n,this.column=i,this.name="UsecaseJsonError"}static{e(this,"UsecaseJsonError")}},En=e((t,n,i,a)=>{let o=i,l=a,h=Math.min(Math.max(n,0),t.length);for(let u=0;u<h;u++){let c=t[u];if(c==="\r")o++,l=1;else if(c===`
|
|
113
|
+
`||a==="\r")return!0;if(a!==" "&&a!=="\t")return!1}return!0},"isIndentedLineStart"),Ji=e((t,n,i)=>{if(!qi(t,n))return null;let a=i.exec(t.slice(n));return a?Qe(t,n,a[0]):null},"matchAccessibilityLine"),Ao=e((t,n)=>{if(!qi(t,n))return null;let i=/^accDescr[\t ]*{/.exec(t.slice(n));if(!i)return null;let a=t.indexOf("}",n+i[0].length);return a===-1?null:Qe(t,n,t.slice(n,a+1))},"matchAccDescrBlock"),So=e((t,n)=>{if(t[n]!=="{")return null;let i=0,a=!1,o=!1;for(let l=n;l<t.length;l++){let h=t[l];if(a){if(o)o=!1;else if(h==="\\")o=!0;else if(h==='"')a=!1;continue}if(h==='"')a=!0;else if(h==="{")i++;else if(h==="}"&&--i===0)return Qe(t,n,t.slice(n,l+1))}return null},"matchJsonObject"),Ro=e((t,n)=>{let i=t.indexOf(">>",n);if(i===-1||/[\n\r]/.test(t.slice(n,i)))return null;let a=t.slice(n,i);return a.trim()?Qe(t,n,a):null},"matchStereotypeText"),oe=k({name:"LABEL_TEXT",pattern:z.NA}),dt=k({name:"WORD",pattern:z.NA,categories:oe}),gn=k({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:oe}),Y=k({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),yo=k({name:"HWS",pattern:/[\t ]+/,group:z.SKIPPED}),Be=k({name:"MARKDOWN_STRING",pattern:To,start_chars_hint:['"'],line_breaks:!0}),Oo=k({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=k({name:"COMMENT",pattern:go,start_chars_hint:["%"],line_breaks:!1}),Fe=k({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Zi=k({name:"ACC_DESCR_BLOCK",pattern:Ao,start_chars_hint:["a"],line_breaks:!0}),Lo=/^accTitle[\t ]*:[^\n\r]*/,No=/^accDescr[\t ]*:[^\n\r]*/,Qi=k({name:"ACC_TITLE_LINE",pattern:e((t,n)=>Ji(t,n,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=k({name:"ACC_DESCR_LINE",pattern:e((t,n)=>Ji(t,n,No),"pattern"),start_chars_hint:["a"],line_breaks:!1}),tr=k({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=k({name:"JSON_OBJECT_LITERAL",pattern:So,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),sr=k({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=e((t,n)=>k({name:t,pattern:n,longer_alt:Y,categories:dt}),"keyword"),nr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),ir=ee("SYSTEM_BOUNDARY",/systemBoundary/),rr=ee("END",/end/),ar=ee("DIRECTION",/direction/),or=ee("TD",/TD/),lr=ee("TB",/TB/),cr=ee("BT",/BT/),hr=ee("LR",/LR/),ur=ee("RL",/RL/),dr=ee("NOTE",/note/),pr=ee("FOR",/for/),Io=ee("JSON",/json/),fr=ee("CLASS_DEF",/classDef/),mr=ee("CLASS",/class/),Er=ee("STYLE",/style/),Tr=ee("INCLUDE",/include/i),gr=ee("EXTEND",/extend/i),Ar=ee("TRUE",/true/),Sr=ee("FALSE",/false/),Rr=k({name:"GENERALIZATION",pattern:/--\|>/}),yr=k({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),Or=k({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=k({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=k({name:"STEREOTYPE_TEXT",pattern:Ro,line_breaks:!1}),Lr=k({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Nr=k({name:"CLASS_SEPARATOR",pattern:/:::/}),As=k({name:"FORWARD_SOLID",pattern:/--+>/}),Ir=k({name:"BACKWARD_SOLID",pattern:/<--+/}),Ss=k({name:"FORWARD_CIRCLE",pattern:/--o/}),kr=k({name:"BACKWARD_CIRCLE",pattern:/o--/}),Rs=k({name:"FORWARD_CROSS",pattern:/--x/}),Cr=k({name:"BACKWARD_CROSS",pattern:/x--/}),Ie=k({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=k({name:"METADATA_START",pattern:/@{/}),ys=k({name:"AT",pattern:/@/,categories:oe}),br=k({name:"LBRACE",pattern:/{/}),fn=k({name:"RBRACE",pattern:/}/}),Os=k({name:"LBRACKET",pattern:/\[/}),Ls=k({name:"RBRACKET",pattern:/]/}),Ft=k({name:"LPAREN",pattern:/\(/}),Bt=k({name:"RPAREN",pattern:/\)/}),be=k({name:"COMMA",pattern:/,/,categories:oe}),$t=k({name:"COLON",pattern:/:/,categories:oe}),_r=k({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:oe}),ke=k({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=k({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:oe}),xr=k({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:oe}),vr=k({name:"DASH",pattern:/-/,categories:oe}),Mr=k({name:"DOT",pattern:/\./,categories:oe}),wr=k({name:"PERCENT",pattern:/%/,categories:oe}),Ur=k({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:oe}),ko=k({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:oe}),Co=k({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:oe}),Pr=[oe,dt,yo,Be,Oo,un,Fe,Zi,Qi,er,tr,nr,dn,ir,rr,ar,or,lr,cr,hr,ur,dr,pr,Io,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Or,Nr,As,Ir,Ss,kr,Rs,Cr,Ie,pn,ys,br,fn,Os,Ls,Ft,Bt,be,$t,_r,ke,mn,Y,gn,xr,vr,Mr,wr,Ur,ko,Co],bo={defaultMode:"defaultMode",modes:{defaultMode:[...Pr],jsonBody:[An,sr],stereotype:[Sn,Rn,Lr]}},_o=[...Pr,An,sr,Sn,Rn,Lr],xo=new z(bo),Gi=e((t)=>kt(t,oe)||t.tokenType===ke||t.tokenType===Be,"isLabelToken"),vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Mo=class extends gs{static{e(this,"UsecaseParser")}constructor(){super(_o,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(nr),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:e(()=>this.isStatementStart(),"GATE"),ALT:e(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:e(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:e(()=>this.isMetadataAssignment(),"GATE"),ALT:e(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:e(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:e(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:e(()=>this.CONSUME(Fe),"ALT")},{ALT:e(()=>this.CONSUME(Re),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Fe)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Qi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:e(()=>this.CONSUME(er),"ALT")},{ALT:e(()=>this.CONSUME(Zi),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:e(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:e(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(oe)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:e(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===ys,"GATE"),DEF:e(()=>{this.CONSUME(Y),this.CONSUME(ys)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:e(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(As)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:e(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Ie),this.OPTION({GATE:e(()=>this.LA(0).image==="--"&&this.hasLabeledRight([As,Ie,Ss,Rs]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:e(()=>this.CONSUME(As),"ALT")},{ALT:e(()=>this.CONSUME2(Ie),"ALT")},{ALT:e(()=>this.CONSUME(Ss),"ALT")},{ALT:e(()=>this.CONSUME(Rs),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Rs)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Cr),this.OPTION({GATE:e(()=>this.hasLabeledRight([Ie]),"GATE"),DEF:e(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Ie)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")},{ALT:e(()=>this.AT_LEAST_ONE(()=>this.CONSUME(oe)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:e(()=>{this.CONSUME(yr),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME(Tr),"ALT")},{ALT:e(()=>this.CONSUME(gr),"ALT")}])},"ALT")},{ALT:e(()=>this.CONSUME(Rr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(Fe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(be)),this.MANY3(()=>this.CONSUME2(Fe))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")}]),this.CONSUME($t),this.OR2([{ALT:e(()=>this.CONSUME2(Y),"ALT")},{ALT:e(()=>this.CONSUME2(ke),"ALT")},{ALT:e(()=>this.CONSUME(Ar),"ALT")},{ALT:e(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:e(()=>{this.CONSUME(be),this.MANY(()=>this.CONSUME(Fe))},"ALT")},{ALT:e(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Fe)),this.OPTION(()=>this.CONSUME2(be)),this.MANY2(()=>this.CONSUME3(Fe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(ir),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(rr),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:e(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:e(()=>{this.CONSUME(Ft),this.SUBRULE(this.nodeLabel),this.CONSUME(Bt)},"ALT")},{ALT:e(()=>{this.CONSUME(Os),this.SUBRULE2(this.nodeLabel),this.CONSUME(Ls)},"ALT")}])})},"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:e(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:e(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:e(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:e(()=>this.CONSUME(Y),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(Be),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(dr),this.CONSUME(pr),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(Or),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Nr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)})}),this.RULE("jsonStatement",()=>{this.CONSUME(tr),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(ar),this.OR([{ALT:e(()=>this.CONSUME(or),"ALT")},{ALT:e(()=>this.CONSUME(lr),"ALT")},{ALT:e(()=>this.CONSUME(cr),"ALT")},{ALT:e(()=>this.CONSUME(hr),"ALT")},{ALT:e(()=>this.CONSUME(ur),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(fr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(mr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(be),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(be),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Er),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(be),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>{this.CONSUME(Ie),this.CONSUME2(dt)},"ALT")}]),this.CONSUME($t),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:e(()=>this.CONSUME(dt),"ALT")},{ALT:e(()=>this.CONSUME(ke),"ALT")},{ALT:e(()=>this.CONSUME(gn),"ALT")},{ALT:e(()=>this.CONSUME(_r),"ALT")},{ALT:e(()=>this.CONSUME(mn),"ALT")},{ALT:e(()=>this.CONSUME(xr),"ALT")},{ALT:e(()=>this.CONSUME(vr),"ALT")},{ALT:e(()=>this.CONSUME(Mr),"ALT")},{ALT:e(()=>this.CONSUME(wr),"ALT")},{ALT:e(()=>this.CONSUME(Ur),"ALT")},{ALT:e(()=>this.CONSUME($t),"ALT")},{ALT:e(()=>this.CONSUME(Ft),"ALT")},{ALT:e(()=>this.CONSUME(Bt),"ALT")},{ALT:e(()=>this.CONSUME(Os),"ALT")},{ALT:e(()=>this.CONSUME(Ls),"ALT")},{ALT:e(()=>this.CONSUME(br),"ALT")},{ALT:e(()=>this.CONSUME(fn),"ALT")},{ALT:e(()=>this.CONSUME(ys),"ALT")},{ALT:e(()=>this.CONSUME(Ie),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let t=this.LA(1).tokenType;return(t===Y||t===ke||t===Be)&&this.LA(2).tokenType===pn}isStatementStart(){let t=this.LA(1).tokenType;return t!==Re&&t!==Fe&&t!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(t){if(!Gi(this.LA(1)))return!1;for(let n=2;;n++){let i=this.LA(n);if(t.includes(i.tokenType))return!0;if(!Gi(i))return!1}}},Gt=new Mo,Wi=class extends Error{constructor(t,n,i){super(`${t} (line ${n}, column ${i})`);this.line=n,this.column=i,this.name="UsecaseJsonError"}static{e(this,"UsecaseJsonError")}},En=e((t,n,i,a)=>{let o=i,l=a,h=Math.min(Math.max(n,0),t.length);for(let u=0;u<h;u++){let c=t[u];if(c==="\r")o++,l=1;else if(c===`
|
|
114
114
|
`){if(u===0||t[u-1]!=="\r")o++,l=1}else l++}return{line:o,column:l}},"locationAtOffset"),wo=e((t,n,i,a)=>{let o=/\bposition (\d+)\b/u.exec(t);if(o)return En(n,Number.parseInt(o[1],10),i,a);let l=/\bline (\d+) column (\d+)\b/u.exec(t);if(l){let h=Number.parseInt(l[1],10),u=Number.parseInt(l[2],10);return{line:i+h-1,column:h===1?a+u-1:u}}if(/unexpected end|end of json input/iu.test(t))return En(n,n.length,i,a);return},"locationFromErrorMessage"),ue=class extends Error{constructor(t){super("Invalid JSON token");this.offset=t}static{e(this,"JsonWalkError")}},ji=class{constructor(t){this.text=t,this.offset=0,this.propertyOrder={}}static{e(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new ue(this.offset);return this.propertyOrder}collectValue(t){this.skipWhitespace();let n=this.text[this.offset];if(n==="{")this.collectObject(t);else if(n==="[")this.collectArray(t);else if(n==='"')this.readString(!1);else if(n==="t")this.consumeLiteral("true");else if(n==="f")this.consumeLiteral("false");else if(n==="n")this.consumeLiteral("null");else if(n==="-"||n>="0"&&n<="9")this.consumeNumber();else throw new ue(this.offset)}collectObject(t){this.offset++;let n=[],i=new Set;if(this.propertyOrder[t]=n,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}while(this.offset<this.text.length){if(this.text[this.offset]!=='"')throw new ue(this.offset);let a=this.readString(!0),o=`${t}/${a.replaceAll("~","~0").replaceAll("/","~1")}`;if(i.has(a))this.deletePointerSubtree(o);else i.add(a),n.push(a);if(this.skipWhitespace(),this.text[this.offset]!==":")throw new ue(this.offset);if(this.offset++,this.collectValue(o),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new ue(this.offset);this.offset++,this.skipWhitespace()}throw new ue(this.offset)}collectArray(t){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let n=0;while(this.offset<this.text.length){if(this.collectValue(`${t}/${n}`),n++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new ue(this.offset);this.offset++,this.skipWhitespace()}throw new ue(this.offset)}readString(t){this.offset++;let n="";while(this.offset<this.text.length){let i=this.offset,a=this.text[this.offset++];if(a==='"')return n;if(a.charCodeAt(0)<32)throw new ue(i);if(a!=="\\"){if(t)n+=a;continue}let o=this.offset,l=this.text[this.offset++];switch(l){case'"':case"\\":case"/":if(t)n+=l;break;case"b":if(t)n+="\b";break;case"f":if(t)n+="\f";break;case"n":if(t)n+=`
|
|
115
115
|
`;break;case"r":if(t)n+="\r";break;case"t":if(t)n+="\t";break;case"u":{let h=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(h))throw new ue(this.offset);if(t)n+=String.fromCharCode(Number.parseInt(h,16));this.offset+=4;break}default:throw new ue(o)}}throw new ue(this.offset)}consumeLiteral(t){let n=0;for(let i of t){if(this.text[this.offset+n]!==i)throw new ue(this.offset+n);n++}this.offset+=t.length}consumeNumber(){if(this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++;else throw new ue(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ue(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,this.text[this.offset]==="+"||this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ue(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}}skipWhitespace(){while(this.offset<this.text.length){let t=this.text[this.offset];if(t!==" "&&t!=="\t"&&t!==`
|
|
116
116
|
`&&t!=="\r")return;this.offset++}}deletePointerSubtree(t){let n=`${t}/`;for(let i of Object.keys(this.propertyOrder))if(i===t||i.startsWith(n))delete this.propertyOrder[i]}};function Dr(t,n,i){let a;try{a=JSON.parse(t)}catch(o){let l=o instanceof Error?o.message:String(o),h=wo(l,t,n,i);if(!h){let u=0;try{new ji(t).collect()}catch(c){if(c instanceof ue)u=c.offset}h=En(t,u,n,i)}throw new Wi(`Invalid JSON: ${l}`,h.line,h.column)}if(typeof a!=="object"||a===null||Array.isArray(a))throw new Wi("JSON value must have an object root",n,i);return{value:a,propertyOrder:new ji(t).collect()}}e(Dr,"parseOrderedJsonObject");var Uo=e((t)=>({shape:t.type==="normal"?"actor":t.type==="hollow"?"actor-hollow":t.type==="awesome"?"actor-awesome":"actor-icon",...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"actor",actorType:t.type,business:t.business,labelType:t.labelType,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"actorNode"),Po=e((t)=>({shape:t.shape,...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"usecase",useCaseShape:t.shape,business:t.business,labelType:t.labelType,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"useCaseNode"),Do=e((t)=>({label:t.label,shape:"note",attrs:{kind:"note",target:t.target,labelType:t.labelType}}),"noteNode"),Fo=e((t)=>({label:t.id,shape:"json-table",...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"json",value:t.value,propertyOrder:t.propertyOrder,labelType:"text"}}),"jsonNode"),Bo=e((t)=>({id:t.id,source:t.source,target:t.target,...t.label?{label:t.label}:{},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{relationshipType:t.type,arrowType:t.arrowType,minlen:t.minlen,explicitId:t.explicitId,animate:t.animate,...t.animation?{animation:t.animation}:{},...t.labelType?{labelType:t.labelType}:{}}}),"relationshipEdge"),$o=e((t)=>({id:`${t.id}-edge`,source:t.id,target:t.target,attrs:{relationshipType:"note",arrowType:X.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Go=e((t,n,i,a)=>{let o={};for(let c of t.getActors().values())o[c.id]=Uo(c);for(let c of t.getUseCases().values())o[c.id]=Po(c);for(let c of t.getNotes().values())o[c.id]=Do(c);for(let c of t.getJsonNodes().values())o[c.id]=Fo(c);let l={};for(let c of t.getSystemBoundaries().values())l[c.id]={...c.label===c.id?{}:{title:c.label},nodes:[...c.members],...c.classes.length?{classes:[...c.classes]}:{},...c.styles.length?{styles:[...c.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:c.type,labelType:c.labelType}};let h={};for(let c of t.getClassDefs().values())h[c.id]={styles:[...c.styles]};let u=t.getDirection();return{version:1,diagramType:"usecase",source:n,header:{keyword:"usecase",direction:u==="TD"?"TB":u,span:i},...t.getAccTitle()?{accTitle:t.getAccTitle()}:{},...t.getAccDescription()?{accDescr:t.getAccDescription()}:{},nodes:o,edges:[...t.getRelationships().map(Bo),...[...t.getNotes().values()].map($o)],groups:l,classDefs:h,statements:a}},"buildUsecaseGraphAST"),pe=e((t)=>`line ${t.line}, column ${t.column} [${t.span[0]},${t.span[1]})`,"locationText"),Ki=e((t)=>t===void 0?"":` (label "${t}")`,"labelSuffix"),Ze=e((t)=>t.generated?t.label:void 0,"generatedFrom"),hn=e((t,n)=>{for(let i of n)if(!t.includes(i))t.push(i)},"pushUnique"),Wo=class{constructor(t){this.db=t,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=t.createModel()}static{e(this,"UsecaseModelBuilder")}reset(t){this.model=this.db.createModel(),this.source=t,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(t){this.elements.push(t)}addBoundary(t){this.boundaries.push(t)}addJson(t){this.jsonDrafts.push(t)}addRelationship(t){this.relationshipDrafts.push(t)}addNote(t){this.noteDrafts.push(t)}addMetadataAssignment(t,n,i,a){this.metadataAssignments.push({target:t,targetLocation:n,metadata:i,statement:a})}addClassDef(t,n){this.classDefinitions.push({ids:t,styles:n})}addClassAssignment(t,n){this.classAssignments.push({targets:t,classes:n})}addStyleAssignment(t,n,i){this.styleAssignments.push({target:t,location:n,styles:i})}setDirection(t){this.directions.push(t==="TD"?"TB":t)}setAccTitle(t){this.model.accTitle=t}setAccDescription(t){this.model.accDescription=t}setStatements(t){this.statements=t}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(t){let n=new Map,i=new Map,a=new Map,o=new Map;for(let c of this.relationshipDrafts)this.recordFirst(o,c.source.id,c.source.location.span[0]),this.recordFirst(o,c.target.id,c.target.location.span[0]);for(let c of this.elements)this.recordFirst(o,c.id,c.location.span[0]);for(let c of this.boundaries)this.recordFirst(o,c.id,c.location.span[0]);for(let c of this.jsonDrafts)this.recordFirst(o,c.id,c.location.span[0]);let l=[...this.elements.map((c)=>({offset:c.location.span[0],type:"element",value:c})),...this.boundaries.map((c)=>({offset:c.location.span[0],type:"boundary",value:c})),...this.jsonDrafts.map((c)=>({offset:c.location.span[0],type:"json",value:c})),...this.relationshipDrafts.filter((c)=>c.explicitId).map((c)=>({offset:c.explicitIdLocation.span[0],type:"edge",value:c}))].sort((c,d)=>c.offset-d.offset);for(let c of l)if(c.type==="element")this.collectElement(c.value,n,i);else if(c.type==="boundary")this.collectBoundary(c.value,n,a);else if(c.type==="json")this.registerUnique(n,c.value.id,"json",c.value.location,!1);else this.registerUnique(n,c.value.explicitId,"edge",c.value.explicitIdLocation,!1);this.materializeElements(i,o),this.materializeBoundaries(a,o),this.materializeJson(o);let h=this.materializeRelationships(n,i,o);this.reorderElements(i,o),this.applyMetadataAssignments(n,i,a,h),this.validateAndRefreshElements(i),this.refreshBoundaries(a,i),this.materializeNotes(n),this.applyClassDefinitions(),this.applyClassesAndStyles(n,h),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...n].map(([c,d])=>[c,d.kind]));let u=Go(this,this.source,t,this.statements);return this.model.ast=u,this.db.commit(this.model),u}collectElement(t,n,i){let a=n.get(t.id),o=Ze({generated:t.generated,label:t.label.text});if(a&&a.kind!==t.kind)this.conflict(`ID '${t.id}' is declared as both ${a.kind} and ${t.kind}`,t.location,a.location,o,Ze(a));if(a&&(a.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,a.location,o,Ze(a));let l=i.get(t.id);if(!l){let h={kind:t.kind,id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],...t.parentId?{parentId:t.parentId,parentLocation:t.parentLocation}:{},...t.shape?{shape:t.shape}:{},...t.stereotype?{stereotype:t.stereotype,stereotypeLocation:t.location}:{}};this.applyDeclarationMetadata(h,t.metadata),i.set(t.id,h),n.set(t.id,{kind:t.kind,location:t.location,generated:t.generated,label:t.label.text});return}if(l.label.text!==t.label.text||l.label.type!==t.label.type)this.conflict(`ID '${t.id}' has conflicting labels`,t.location,l.location);if(t.shape&&l.shape&&t.shape!==l.shape)this.conflict(`Use case '${t.id}' has conflicting shapes`,t.location,l.location);if(t.parentId&&l.parentId&&t.parentId!==l.parentId)this.conflict(`Element '${t.id}' belongs to more than one system boundary`,t.parentLocation??t.location,l.parentLocation??l.location);if(t.stereotype&&l.stereotype&&t.stereotype!==l.stereotype)this.conflict(`Element '${t.id}' has conflicting stereotypes`,t.location,l.stereotypeLocation??l.location);l.shape??=t.shape,l.parentId??=t.parentId,l.parentLocation??=t.parentLocation,l.stereotype??=t.stereotype,l.stereotypeLocation??=t.stereotype?t.location:void 0,hn(l.classes,t.classes),this.applyDeclarationMetadata(l,t.metadata)}collectBoundary(t,n,i){let a=n.get(t.id),o=Ze({generated:t.generated,label:t.label.text});if(a&&a.kind!=="boundary")this.conflict(`ID '${t.id}' is declared as both ${a.kind} and boundary`,t.location,a.location,o,Ze(a));if(a&&(a.generated||t.generated))this.conflict(`Generated ID '${t.id}' collides with another declaration`,t.location,a.location,o,Ze(a));let l=i.get(t.id);if(l){if(l.label.text!==t.label.text||l.label.type!==t.label.type)this.conflict(`Boundary '${t.id}' has conflicting titles`,t.location,l.location);hn(l.classes,t.classes);return}i.set(t.id,{id:t.id,label:t.label,location:t.location,generated:t.generated,classes:[...t.classes],styles:[],members:[]}),n.set(t.id,{kind:"boundary",location:t.location,generated:t.generated,label:t.label.text})}materializeElements(t,n){for(let i of[...t.values()].sort((a,o)=>(n.get(a.id)??0)-(n.get(o.id)??0)))this.setElementModel(i)}materializeBoundaries(t,n){for(let i of[...t.values()].sort((a,o)=>(n.get(a.id)??0)-(n.get(o.id)??0)))this.model.systemBoundaries.set(i.id,{id:i.id,label:i.label.text,labelType:i.label.type,type:i.type??"rect",members:[],classes:[...i.classes],styles:[...i.styles]})}materializeJson(t){for(let n of[...this.jsonDrafts].sort((i,a)=>(t.get(i.id)??0)-(t.get(a.id)??0)))this.model.jsonNodes.set(n.id,{id:n.id,value:n.value,propertyOrder:n.propertyOrder,classes:[...n.classes],styles:[]})}materializeRelationships(t,n,i){let a=new Map,o=0;for(let l of this.relationshipDrafts){let h=this.resolveEndpoint(l.source,t,n,i),u=this.resolveEndpoint(l.target,t,n,i);this.validateRelationship(l,h,u,t);let c=l.explicitId??`edge-${o++}`,d={id:c,explicitId:Boolean(l.explicitId),source:l.source.id,target:l.target.id,type:l.type,arrowType:l.arrowType,...l.label?{label:l.label.text,labelType:l.label.type}:{},minlen:l.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),a.set(c,{draft:l,relationship:d})}return this.model.relationshipCounter=o,a}resolveEndpoint(t,n,i,a){if(t.classesOnReference&&!t.declaration)throw Error(`Relationship endpoint '${t.id}' uses ::: without declaring the node at ${pe(t.location)}`);let o=n.get(t.id);if(o)return o.kind;return i.set(t.id,{kind:"usecase",id:t.id,label:t.label,location:t.location,generated:t.generated,shape:"ellipse",classes:[]}),n.set(t.id,{kind:"usecase",location:t.location,generated:t.generated,label:t.label.text}),this.recordFirst(a,t.id,t.location.span[0]),"usecase"}reorderElements(t,n){let i=new Map(this.model.actors),a=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let o of[...t.values()].sort((l,h)=>(n.get(l.id)??0)-(n.get(h.id)??0))){if(!i.has(o.id)&&!a.has(o.id))this.setElementModel(o);let l=i.get(o.id)??this.model.actors.get(o.id),h=a.get(o.id)??this.model.useCases.get(o.id);if(l)this.model.actors.set(o.id,l);else if(h)this.model.useCases.set(o.id,h)}}applyMetadataAssignments(t,n,i,a){for(let o of this.metadataAssignments){let l=t.get(o.target);if(!l){let h=this.inferMetadataKind(o.metadata);throw Error(`Metadata target '${o.target}' is unresolved${h?` (metadata implies ${h})`:""} at ${pe(o.targetLocation)}`)}if(l.kind==="actor"||l.kind==="usecase")this.applyStandaloneElementMetadata(n.get(o.target),o.metadata);else if(l.kind==="boundary"){let h=i.get(o.target);for(let u of o.metadata.properties){if(u.key!=="type"||u.value!=="rect"&&u.value!=="package")this.invalidMetadata(o.target,l.kind,u);h.type=u.value}}else if(l.kind==="edge"){let h=a.get(o.target);if(!h)throw Error(`Metadata target '${o.target}' is not an explicit edge at ${pe(o.targetLocation)}`);o.statement.kind="edgeMetadata",o.statement.edges=[{id:o.target,span:o.statement.span,idSpan:o.targetLocation.span,...o.statement.metadata?{metadata:o.statement.metadata}:{}}],delete o.statement.nodes;for(let u of o.metadata.properties)if(u.key==="animate"&&typeof u.value==="boolean")h.relationship.animate=u.value;else if(u.key==="animation"&&(u.value==="fast"||u.value==="slow"))h.relationship.animation=u.value,h.relationship.animate=!0;else this.invalidMetadata(o.target,l.kind,u)}else for(let h of o.metadata.properties)this.invalidMetadata(o.target,l.kind,h)}for(let{relationship:o}of a.values())if(o.animation)o.animate=!0}applyStandaloneElementMetadata(t,n){for(let i of n.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!0);else if(i.key==="business"&&typeof i.value==="boolean")t.business=i.value;else this.invalidMetadata(t.id,t.kind,i)}applyDeclarationMetadata(t,n){if(!n)return;for(let i of n.properties)if(t.kind==="actor")this.applyActorProperty(t,i,!1);else if(i.key==="business"&&typeof i.value==="boolean"){if(t.business!==void 0&&t.business!==i.value)this.conflict(`Use case '${t.id}' has conflicting business metadata`,i.location,t.location);t.business=i.value}else this.invalidMetadata(t.id,t.kind,i)}applyActorProperty(t,n,i){if(n.key==="type"&&(n.value==="normal"||n.value==="hollow"||n.value==="awesome")){if(!i&&t.actorType!==void 0&&t.actorType!==n.value)this.conflict(`Actor '${t.id}' has conflicting type metadata`,n.location,t.location);t.actorType=n.value}else if(n.key==="icon"&&typeof n.value==="string"){if(!i&&t.icon!==void 0&&t.icon!==n.value)this.conflict(`Actor '${t.id}' has conflicting icon metadata`,n.location,t.location);t.icon=n.value}else if(n.key==="business"&&typeof n.value==="boolean"){if(!i&&t.business!==void 0&&t.business!==n.value)this.conflict(`Actor '${t.id}' has conflicting business metadata`,n.location,t.location);t.business=n.value}else this.invalidMetadata(t.id,t.kind,n)}validateAndRefreshElements(t){for(let n of t.values()){let i=n.icon?"icon":n.actorType??"normal";if(n.kind==="actor"){if(n.icon&&n.actorType&&n.actorType!=="normal")throw Error(`Actor '${n.id}' cannot combine icon with type '${n.actorType}' at ${pe(n.location)}`);if(n.business&&(i==="icon"||i==="awesome"))throw Error(`Business actor '${n.id}' must use normal or hollow geometry at ${pe(n.location)}`)}else if((n.shape??"ellipse")==="rect"&&n.business)throw Error(`Rectangular use case '${n.id}' cannot be a business use case at ${pe(n.location)}`);this.setElementModel(n)}}refreshBoundaries(t,n){for(let i of t.values())i.members.length=0;for(let i of[...this.elements].sort((a,o)=>a.location.span[0]-o.location.span[0])){if(!i.parentId)continue;let a=t.get(i.parentId);if(!a)throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${pe(i.parentLocation??i.location)}`);if(!a.members.includes(i.id))a.members.push(i.id)}for(let i of n.values())if(i.parentId&&!t.has(i.parentId))throw Error(`Parent boundary '${i.parentId}' for '${i.id}' is unresolved at ${pe(i.parentLocation??i.location)}`);for(let i of t.values()){let a=this.model.systemBoundaries.get(i.id);a.type=i.type??"rect",a.members=[...i.members],a.classes=[...i.classes],a.styles=[...i.styles]}}materializeNotes(t){let n=0;for(let i of this.noteDrafts){let a=t.get(i.target);if(!a)throw Error(`Note target '${i.target}' is unresolved at ${pe(i.targetLocation)}`);if(a.kind!=="actor"&&a.kind!=="usecase")this.conflict(`Note target '${i.target}' must be an actor or use case, not ${a.kind}`,i.targetLocation,a.location);let o=`note-${n++}`;this.model.notes.set(o,{id:o,target:i.target,label:i.label.text,labelType:i.label.type})}this.model.noteCounter=n}applyClassDefinitions(){for(let t of this.classDefinitions)for(let n of t.ids)this.model.classDefs.set(n,{id:n,styles:[...t.styles]})}applyClassesAndStyles(t,n){for(let i of this.classAssignments)for(let a of i.targets)hn(this.getStylable(a.id,t,n,a.location).classes,i.classes);for(let i of this.styleAssignments)this.getStylable(i.target,t,n,i.location).styles.push(...i.styles)}getStylable(t,n,i,a){let o=n.get(t)?.kind,l=o==="actor"?this.model.actors.get(t):o==="usecase"?this.model.useCases.get(t):o==="boundary"?this.model.systemBoundaries.get(t):o==="json"?this.model.jsonNodes.get(t):o==="edge"?i.get(t)?.relationship:void 0;if(!l)throw Error(`Class/style target '${t}' is unresolved or anonymous at ${pe(a)}`);return l}validateRelationship(t,n,i,a){let o=e((l)=>l==="actor"||l==="usecase"||l==="json","allowed");if(!o(n))this.conflict(`Relationship source '${t.source.id}' cannot be ${n}`,t.source.location,a.get(t.source.id).location);if(!o(i))this.conflict(`Relationship target '${t.target.id}' cannot be ${i}`,t.target.location,a.get(t.target.id).location);if((t.type==="include"||t.type==="extend")&&(n!=="usecase"||i!=="usecase"))throw Error(`${t.type} relationship requires use-case endpoints at ${pe(t.location)}`);if(t.type==="generalization"&&(n!=="actor"&&n!=="usecase"||n!==i))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${pe(t.location)}`);if(t.type==="association"&&(n==="json"||i==="json")&&![0,1,2].includes(t.arrowType))throw Error(`JSON relationship '${t.source.id}' to '${t.target.id}' permits only point, reversed-point, or markerless solid association at ${pe(t.location)}`)}setElementModel(t){if(t.kind==="actor"){let n=t.icon?"icon":t.actorType??"normal";this.model.useCases.delete(t.id),this.model.actors.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,type:n,...t.icon?{icon:t.icon}:{},business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.actors.get(t.id)?.styles??[]})}else this.model.actors.delete(t.id),this.model.useCases.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,shape:t.shape??"ellipse",business:t.business??!1,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{},classes:[...t.classes],styles:this.model.useCases.get(t.id)?.styles??[]})}inferMetadataKind(t){let n=new Set(["actor","usecase","boundary","edge"]);for(let i of t.properties)if(i.key==="icon")n.clear(),n.add("actor");else if(i.key==="animate"||i.key==="animation")n.clear(),n.add("edge");else if(i.key==="type"){if(n.clear(),i.value==="rect"||i.value==="package")n.add("boundary");else if(i.value==="normal"||i.value==="hollow"||i.value==="awesome")n.add("actor")}else if(i.key==="business")n.delete("boundary"),n.delete("edge");else return;return n.size===1?[...n][0]:void 0}invalidMetadata(t,n,i){throw Error(`Metadata property '${i.key}' is invalid for ${n} '${t}' at ${pe(i.location)}`)}registerUnique(t,n,i,a,o){let l=t.get(n);if(l)this.conflict(`ID '${n}' is declared more than once (${l.kind} and ${i})`,a,l.location,void 0,Ze(l));t.set(n,{kind:i,location:a,generated:o})}recordFirst(t,n,i){let a=t.get(n);if(a===void 0||i<a)t.set(n,i)}conflict(t,n,i,a,o){throw Error(`${t} at ${pe(n)}${Ki(a)}; previous declaration at ${pe(i)}${Ki(o)}`)}},jo=Gt.getBaseCstVisitorConstructor(),Ko=class extends jo{constructor(){super();this.builder=new Wo(Ns),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{e(this,"UsecaseVisitor")}build(t,n){this.source=n,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(n),this.visit(t)}start(t){let n=this.tokens(t,"USECASE")[0],i=[];for(let a of this.nodes(t,"line"))i.push(this.visit(a));this.builder.setStatements(i),this.builder.finalize(this.tokenSpan(n))}line(t){let n=this.firstNode(t,"blankLine","commentLine","statement");return this.wrap(n,this.visit(n))}statement(t){return this.visit(this.firstNode(t,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(t){return}blankLine(t){return{kind:"blank",span:this.tokenSpan(this.tokens(t,"NEWLINE")[0])}}commentLine(t){return{kind:"comment",span:this.tokenSpan(this.tokens(t,"COMMENT")[0])}}accTitleStatement(t){let n=this.tokens(t,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(n.slice(n.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(t){let n=this.tokens(t,"ACC_DESCR_LINE")[0],i=this.tokens(t,"ACC_DESCR_BLOCK")[0],a=n?n.image.slice(n.image.indexOf(":")+1).trim():i.image.slice(i.image.indexOf("{")+1,i.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(a),{kind:"accDescr",span:[0,0]}}actorStatement(t){let n=this.nodes(t,"actorItem"),i=n.map((c)=>this.visit(c)),a=this.nodes(t,"relationTail")[0],o=i.map((c,d)=>this.actorOccurrence(n[d],c,!0));for(let c of i)this.builder.addElement(this.actorDraft(c));if(!a)return{kind:"node",span:[0,0],nodes:o};let l=this.visit(a);if(l.target.explicitDeclaration)this.builder.addElement(this.entityDraft(l.target));let h=this.relationshipDraft(i[0],l,this.nodeLocation(a));this.builder.addRelationship(h);let u=h.explicitId??`edge-${this.anonymousEdge++}`;return o.push(this.entityOccurrence(this.nodes(a.children,"entityName")[0],l.target,l.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:o,edges:[{id:u,span:[0,0],...h.explicitIdLocation?{idSpan:h.explicitIdLocation.span}:{},...h.label?{labelSpan:h.label.span}:{}}]}}actorItem(t){let n=this.visit(this.nodes(t,"actorName")[0]),i=this.nodes(t,"metadata")[0],a=this.nodes(t,"stereotype")[0],o=this.nodes(t,"classSuffix")[0],l=o?this.visit(o):{classes:[],spans:[]};return{...n,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:l.classes,classSpans:l.spans}}actorName(t){let n=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0];if(n){let o=this.nodes(t,"nodeLabel")[0],l=o?this.visit(o):this.tokenLabel(n);return{id:n.image,label:l,location:this.tokenLocation(n),generated:!1,classes:[],classSpans:[]}}let a=this.tokenLabel(i);return{id:this.generateId(a.text),label:a,location:this.tokenLocation(i),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(t){let n=this.nodes(t,"actorItem"),i=n.map((a)=>this.visit(a));for(let a of i)this.builder.addElement(this.actorDraft(a));return{kind:"node",span:[0,0],nodes:i.map((a,o)=>this.actorOccurrence(n[o],a,!0))}}entityStatement(t){let n=this.nodes(t,"entityName"),i=this.visit(n[0]),a=this.nodes(t,"relationTail")[0];if(!a)return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n[0],i,!0)]};if(i.explicitDeclaration)this.builder.addElement(this.entityDraft(i));let o=this.visit(a);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let l={source:this.endpoint(i),target:this.endpoint(o.target),location:this.nodeLocation(a),...o.explicitId?{explicitId:o.explicitId,explicitIdLocation:o.explicitIdLocation}:{},...o.arrow};this.builder.addRelationship(l);let h=l.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(n[0],i,i.explicitDeclaration),this.entityOccurrence(this.nodes(a.children,"entityName")[0],o.target,o.target.explicitDeclaration)],edges:[{id:h,span:[0,0],...l.explicitIdLocation?{idSpan:l.explicitIdLocation.span}:{},...l.label?{labelSpan:l.label.span}:{}}]}}entityName(t){let n=this.tokens(t,"IDENTIFIER")[0],i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],a=this.nodes(t,"nodeLabel")[0],o=this.nodes(t,"useCaseMetadata")[0],l=this.nodes(t,"stereotype")[0],h=this.nodes(t,"classSuffix")[0],u=h?this.visit(h):{classes:[],spans:[]};if(n){let d=a?this.visit(a):this.tokenLabel(n),f=a?this.tokens(t,"LBRACKET").length?"rect":"ellipse":void 0;return{id:n.image,label:d,location:this.tokenLocation(n),generated:!1,...f?{shape:f}:{},...o?{metadata:this.visit(o)}:{},...l?{stereotype:this.visit(l)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(f||o||l)}}let c=this.tokenLabel(i);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(i),generated:!0,...o?{metadata:this.visit(o)}:{},...l?{stereotype:this.visit(l)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(o||l)}}nodeLabel(t){let n=this.allTokens(t);if(n.length===1&&(n[0].tokenType.name==="PLAIN_STRING"||n[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(n[0]);let i=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return{text:this.source.slice(i[0],i[1]),type:"text",span:i}}useCaseMetadata(t){return this.visit(this.nodes(t,"metadata")[0])}relationTail(t){let n=this.tokens(t,"IDENTIFIER")[0];return{...n?{explicitId:n.image,explicitIdLocation:this.tokenLocation(n)}:{},arrow:this.visit(this.nodes(t,"arrow")[0]),target:this.visit(this.nodes(t,"entityName")[0])}}arrow(t){return this.visit(this.firstNode(t,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(t){return this.nodeLabel(t)}semanticRelation(t){if(this.tokens(t,"GENERALIZATION").length)return{type:"generalization",arrowType:X.SOLID_ARROW,minlen:1};let n=this.tokens(t,"INCLUDE").length?"include":"extend",i=this.tokens(t,n==="include"?"INCLUDE":"EXTEND")[0];return{type:n,arrowType:X.SOLID_ARROW,label:{text:n,type:"text",span:this.tokenSpan(i)},minlen:1}}metadata(t){return{properties:this.nodes(t,"metadataProperty").map((n)=>this.visit(n)),location:this.ctxLocation(t)}}metadataProperty(t){let n=this.allTokens(t).filter((h)=>h.tokenType.name!=="COLON"),i=n[0],a=n[1],o=a.tokenType.name==="TRUE"?!0:a.tokenType.name==="FALSE"?!1:this.decodePlain(a),l=[i.startOffset,(a.endOffset??a.startOffset)+1];return{key:this.decodePlain(i),value:o,span:l,keySpan:this.contentSpan(i),valueSpan:this.contentSpan(a),location:this.tokenLocation(i)}}metadataSeparator(t){return}systemBoundaryStatement(t){let n=this.visit(this.nodes(t,"systemBoundaryName")[0]),i=this.nodes(t,"classSuffix")[0],a=i?this.visit(i):{classes:[],spans:[]};n.classes=a.classes,this.builder.addBoundary(n);let o=this.parentBoundary;this.parentBoundary={id:n.id,location:n.location};let l=this.nodes(t,"systemBoundaryContent")[0],h=l?this.visit(l):[];this.parentBoundary=o;let u=this.tokens(t,"END")[0],c=this.nodes(t,"metadata")[0],d=c?this.visit(c):void 0,f={kind:"group",span:[0,0],group:n.id,idSpan:n.location.span,titleSpan:n.label.span,endSpan:this.tokenSpan(u),classSpans:a.spans,...d?{metadata:d.properties.map(({key:m,span:R,keySpan:y,valueSpan:U})=>({key:m,span:R,keySpan:y,valueSpan:U}))}:{},...h.length?{children:h}:{}};if(d)this.builder.addMetadataAssignment(n.id,n.location,d,f);return f}systemBoundaryName(t){let n=this.tokens(t,"IDENTIFIER")[0];if(n){let o=this.nodes(t,"nodeLabel")[0];return{id:n.image,label:o?this.visit(o):this.tokenLabel(n),location:this.tokenLocation(n),generated:!1,classes:[]}}let i=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],a=this.tokenLabel(i);return{id:this.generateId(a.text),label:a,location:this.tokenLocation(i),generated:!0,classes:[]}}systemBoundaryContent(t){return[...this.nodes(t,"blankLine"),...this.nodes(t,"commentLine"),...this.nodes(t,"boundaryElement")].sort((i,a)=>(i.location?.startOffset??0)-(a.location?.startOffset??0)).map((i)=>this.wrap(i,this.visit(i)))}boundaryElement(t){let n=this.nodes(t,"actorDeclarationOnly")[0];if(n)return this.visit(n);let i=this.nodes(t,"entityName")[0],a=this.visit(i);return a.explicitDeclaration=!0,a.shape??="ellipse",this.builder.addElement(this.entityDraft(a)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(i,a,!0)]}}metadataAssignmentStatement(t){let n=this.visit(this.nodes(t,"metadataAssignmentTarget")[0]),i=this.visit(this.nodes(t,"metadata")[0]),a={kind:"metadata",span:[0,0],nodes:[{id:n.id,span:n.location.span,idSpan:n.location.span}],metadata:i.properties.map(({key:o,span:l,keySpan:h,valueSpan:u})=>({key:o,span:l,keySpan:h,valueSpan:u}))};return this.builder.addMetadataAssignment(n.id,n.location,i,a),a}metadataAssignmentTarget(t){let n=this.allTokens(t)[0],i=this.tokenLabel(n);return{id:n.tokenType.name==="IDENTIFIER"?n.image:this.generateId(i.text),location:this.tokenLocation(n)}}noteStatement(t){let n=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"nodeLabel")[0]);return this.builder.addNote({target:n.image,targetLocation:this.tokenLocation(n),label:i,location:this.ctxLocation(t)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:i.span,nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}stereotype(t){let n=this.tokens(t,"STEREOTYPE_TEXT")[0];return{value:n.image.trim(),span:this.tokenSpan(n)}}classSuffix(t){let n=this.tokens(t,"IDENTIFIER");return{classes:n.map((i)=>i.image),spans:n.map((i)=>this.tokenSpan(i))}}jsonStatement(t){let n=this.tokens(t,"JSON_DECLARATION_START")[0],i=this.tokens(t,"JSON_OBJECT_LITERAL")[0],a=/^json[\t ]+(\w+)/.exec(n.image),o=a[1],l=a[0].length-o.length,h={span:[n.startOffset+l,n.startOffset+l+o.length],line:n.startLine??1,column:(n.startColumn??1)+l},u=Dr(i.image,i.startLine??1,i.startColumn??1),c=this.nodes(t,"classSuffix")[0],d=c?this.visit(c):{classes:[],spans:[]},f={id:o,value:u.value,propertyOrder:u.propertyOrder,location:h,classes:d.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:o,span:h.span,idSpan:h.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(t){let n=this.allTokens(t).find((i)=>["TD","TB","BT","RL","LR"].includes(i.tokenType.name));return this.builder.setDirection(n.image),{kind:"direction",span:[0,0]}}classDefStatement(t){let n=this.tokens(t,"IDENTIFIER"),i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addClassDef(n.map((a)=>a.image),i),{kind:"classDef",span:[0,0],ref:n[0].image,refSpan:this.tokenSpan(n[0])}}classStatement(t){let n=this.tokens(t,"IDENTIFIER"),i=1;for(;i<n.length;i++)if(!this.source.slice((n[i-1].endOffset??n[i-1].startOffset)+1,n[i].startOffset).includes(","))break;let a=n.slice(0,i).map((l)=>({id:l.image,location:this.tokenLocation(l)})),o=n.slice(i).map((l)=>l.image);return this.builder.addClassAssignment(a,o),{kind:"classAssign",span:[0,0],ref:o[0],refSpan:this.tokenSpan(n[i]),nodes:a.map(({id:l,location:h})=>({id:l,span:h.span,idSpan:h.span}))}}styleStatement(t){let n=this.tokens(t,"IDENTIFIER")[0],i=this.visit(this.nodes(t,"styles")[0]);return this.builder.addStyleAssignment(n.image,this.tokenLocation(n),i),{kind:"style",span:[0,0],nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}styles(t){return this.nodes(t,"styleValue").map((n)=>this.visit(n))}styleValue(t){let n=this.allTokens(t),i=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return this.source.slice(i[0],i[1]).replaceAll("\\,",",")}styleComponent(t){return this.allTokens(t).map((n)=>n.image).join("")}forwardSolidOperator(t){let n=this.tokens(t,"FORWARD_SOLID")[0];return{type:"association",arrowType:X.SOLID_ARROW,minlen:this.solidMinlen(n)}}backwardSolidOperator(t){let n=this.tokens(t,"BACKWARD_SOLID")[0],i=this.nodes(t,"edgeLabel")[0],a=i?this.tokens(t,"MARKERLESS_SOLID").at(-1):n;return{type:"association",arrowType:X.BACK_ARROW,minlen:this.solidMinlen(a),...i?{label:this.visit(i)}:{}}}markerlessSolidOperator(t){let n=this.nodes(t,"edgeLabel")[0],i=this.allTokens(t);if(!n)return{type:"association",arrowType:X.LINE_SOLID,minlen:this.solidMinlen(this.tokens(t,"MARKERLESS_SOLID")[0])};let a=i.at(-1),o=a.tokenType.name==="FORWARD_SOLID"?X.SOLID_ARROW:a.tokenType.name==="FORWARD_CIRCLE"?X.CIRCLE_ARROW:a.tokenType.name==="FORWARD_CROSS"?X.CROSS_ARROW:X.LINE_SOLID;return{type:"association",arrowType:o,label:this.visit(n),minlen:o===X.SOLID_ARROW||o===X.LINE_SOLID?this.solidMinlen(a):1}}forwardCircleOperator(t){return{type:"association",arrowType:X.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(t){let n=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:X.CIRCLE_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}forwardCrossOperator(t){return{type:"association",arrowType:X.CROSS_ARROW,minlen:1}}backwardCrossOperator(t){let n=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:X.CROSS_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}actorDraft(t){return{id:t.id,kind:"actor",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}entityDraft(t){return{id:t.id,kind:"usecase",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.shape?{shape:t.shape}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}endpoint(t,n=t.explicitDeclaration??!0){return{id:t.id,label:t.label,location:t.location,generated:t.generated,declaration:n,classesOnReference:t.classes.length>0}}relationshipDraft(t,n,i){return{source:this.endpoint(t,!0),target:this.endpoint(n.target),location:i,...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow}}actorOccurrence(t,n,i){return{id:n.id,span:this.nodeSpan(t),idSpan:n.location.span,labelSpan:n.label.span,...i?{defines:!0}:{},...n.stereotype?{stereotypeSpan:n.stereotype.span}:{},...n.metadata?{metadata:n.metadata.properties.map(({key:a,span:o,keySpan:l,valueSpan:h})=>({key:a,span:o,keySpan:l,valueSpan:h}))}:{},...n.classSpans.length?{classSpans:n.classSpans}:{}}}entityOccurrence(t,n,i){return this.actorOccurrence(t,n,i)}wrap(t,n){if(n.kind==="blank"||n.kind==="comment")return n;n.span=this.nodeSpan(t);for(let i of n.edges??[])i.span=n.span;return n}tokenLabel(t){let n=t.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",i=n==="markdown"?2:t.tokenType.name==="PLAIN_STRING"?1:0,a=this.tokenSpan(t,i);return{text:this.source.slice(a[0],a[1]),type:n,span:a}}decodePlain(t){return t.tokenType.name==="PLAIN_STRING"?t.image.slice(1,-1):t.image}contentSpan(t){return this.tokenSpan(t,t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(t){return t.replace(/\W/g,"_")}solidMinlen(t){return Math.max(1,(t.image.match(/-/g)?.length??2)-1)}nodeLocation(t){let n=this.allTokens(t.children)[0];return{span:this.nodeSpan(t),line:n.startLine??1,column:n.startColumn??1}}ctxLocation(t){let n=this.allTokens(t).filter((o)=>o.tokenType.name!=="NEWLINE"&&o.tokenType.name!=="EOF"),i=n[0],a=n.at(-1);return{span:[i.startOffset,Math.min(this.source.length,(a.endOffset??a.startOffset+a.image.length-1)+1)],line:i.startLine??1,column:i.startColumn??1}}tokenLocation(t){let n=t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(t,n),line:t.startLine??1,column:(t.startColumn??1)+n}}nodeSpan(t){let n=this.allTokens(t.children).filter((o)=>o.tokenType.name!=="NEWLINE"&&o.tokenType.name!=="EOF"),i=n[0],a=n.at(-1);if(!i||!a)throw Error("Usecase CST node has no source token");return[i.startOffset,Math.min(this.source.length,(a.endOffset??a.startOffset+a.image.length-1)+1)]}tokenSpan(t,n=0){return[t.startOffset+n,Math.min(this.source.length,(t.endOffset??t.startOffset+t.image.length-1)+1-n)]}nodes(t,n){return(t[n]??[]).filter((i)=>("children"in i))}tokens(t,n){return(t[n]??[]).filter((i)=>("tokenTypeIdx"in i))}firstNode(t,...n){for(let i of n){let a=this.nodes(t,i)[0];if(a)return a}throw Error(`Usecase CST is missing one of: ${n.join(", ")}`)}allTokens(t){let n=[];for(let i of Object.values(t))for(let a of i)if("tokenTypeIdx"in a)n.push(a);else n.push(...this.allTokens(a.children));return n.sort((i,a)=>i.startOffset-a.startOffset)}},Vo=new Ko,zo={parse:e(async(t)=>{Ns.clear(),Gt.input=[];try{Xi({diagramType:"usecase",lexer:xo,parser:Gt,entry:e(()=>Gt.start(),"entry"),visit:e((n)=>Vo.build(n,t),"visit")},t)}catch(n){Ns.clear();let i=Gt.errors[0];if(i){let{token:a}=i,o=ut(a.startOffset)?a.startOffset:t.length,l=ut(a.endOffset)?a.endOffset+1:o,h=ut(a.startLine)?a.startLine:t.slice(0,o).split(/\r\n|\r|\n/).length,u=Math.max(t.lastIndexOf(`
|
|
117
117
|
`,o-1),t.lastIndexOf("\r",o-1)),c=ut(a.startColumn)?a.startColumn:o-u,d=n instanceof Error?n.message:String(n);throw Error(`${d} at line ${h}, column ${c} [${o},${l})`)}throw n}},"parse")},Ho=["point","circle","cross","extension"],Fr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Vi=e((t,n)=>{let[i,a]=[t,n].map((o)=>o.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${i}-${a}`},"usecaseDomId"),Xo=e((t)=>`usecase-${t.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=e((t,n)=>{if(n!=="markdown")return t;return ti(t).map((i)=>i.map((a)=>a.content).join(" ")).join(`
|
|
118
|
-
`)},"getAccessibleLabel"),Yo=e((t)=>{let n=Is(t.label??t.id,t.labelType);if(Fr[t.shape]){let a=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",o=t.business?"business ":"",l=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${o}${a}actor ${n}${l}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${n}`;if(t.shape==="usecaseJsonTable"){let a=(t.jsonRows??[]).map((o)=>`${o.accessibleKey}: ${o.value}`).join("; ");return a?`${n}: ${a}`:n}let i=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${n}${i}`},"getUsecaseNodeAccessibleName"),qo=e((t)=>`${t.boundaryType} system boundary ${Is(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=e((t)=>{if(t.relationshipType==="note")return"";return`${t.relationshipType==="association"&&t.label?`association ${Is(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=e((t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=e((t)=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=e((t,n)=>{t.diagramId=n,t.markers=[...Ho];for(let i of t.nodes){let a=i;if(a.domId=Xo(i.id),i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);if(i.stereotype)i.stereotype=ht(i.stereotype);if(!i.isGroup&&i.shape==="usecaseJsonTable")i.jsonRows=i.jsonRows?.map((o)=>({...o,key:ht(o.key),value:ht(o.value)}));if(!i.isGroup&&(i.shape==="usecaseEllipse"||i.shape==="rect")&&i.stereotype){let o=i.label??ht(i.id);i.label=`«${zi(i.stereotype)}»<br/>${i.labelType==="text"?zi(o):o}`,i.labelType="markdown",a.hasFoldedStereotype=!0,delete i.stereotype}}for(let i of t.edges)if(i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);return t},"prepareUsecaseLayoutData"),Qo=e((t,n,i)=>{for(let o of n.nodes){let l=typeof o.domId==="string"?o.domId:Vi(n.diagramId,o.id),h=t.select(`#${l}`),u=o.isGroup?"boundary":Fr[o.shape]?"actor":o.shape==="note"?"note":o.shape==="usecaseJsonTable"?"json":"usecase",c=i.nodes.get(o.id)??o.id;if(h.attr("data-usecase-id",o.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!o.isGroup&&(o.shape==="usecaseEllipse"||o.shape==="rect")&&"hasFoldedStereotype"in o&&o.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,R=m?.firstChild;if(m&&R?.nodeType===3){let y=m.ownerDocument.createElement("span");y.className="usecase-stereotype",m.insertBefore(y,R),y.appendChild(R)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let a=new Map(n.edges.map((o)=>[o.id,o]));t.selectAll('path[data-et="edge"]').each(function(){let o=a.get(this.getAttribute("data-id")??"");if(!o)return;let l=p(this);if(l.attr("id",Vi(n.diagramId,o.id)).attr("data-usecase-id",o.id).attr("data-usecase-kind",o.internal?"note-connector":"relationship"),o.internal)l.attr("aria-hidden","true");else l.attr("role","img").attr("aria-label",i.edges.get(o.id)??o.id)})},"annotateUsecaseElements"),Hi=e((t,n)=>{t.style("--mermaid-usecase-actor-font-size",`${n.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",n.actorFontFamily).style("--mermaid-usecase-actor-font-weight",n.actorFontWeight).style("--mermaid-usecase-font-size",`${n.usecaseFontSize}px`).style("--mermaid-usecase-font-family",n.usecaseFontFamily).style("--mermaid-usecase-font-weight",n.usecaseFontWeight)},"applyUsecaseFonts"),el=e(async(t,n,i,a)=>{r.info("Drawing usecase diagram (unified)",n);let{layout:o}=s(),l=a.db,h=l.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=
|
|
118
|
+
`)},"getAccessibleLabel"),Yo=e((t)=>{let n=Is(t.label??t.id,t.labelType);if(Fr[t.shape]){let a=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",o=t.business?"business ":"",l=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${o}${a}actor ${n}${l}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${n}`;if(t.shape==="usecaseJsonTable"){let a=(t.jsonRows??[]).map((o)=>`${o.accessibleKey}: ${o.value}`).join("; ");return a?`${n}: ${a}`:n}let i=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${n}${i}`},"getUsecaseNodeAccessibleName"),qo=e((t)=>`${t.boundaryType} system boundary ${Is(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=e((t)=>{if(t.relationshipType==="note")return"";return`${t.relationshipType==="association"&&t.label?`association ${Is(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=e((t)=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=e((t)=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=e((t,n)=>{t.diagramId=n,t.markers=[...Ho];for(let i of t.nodes){let a=i;if(a.domId=Xo(i.id),i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);if(i.stereotype)i.stereotype=ht(i.stereotype);if(!i.isGroup&&i.shape==="usecaseJsonTable")i.jsonRows=i.jsonRows?.map((o)=>({...o,key:ht(o.key),value:ht(o.value)}));if(!i.isGroup&&(i.shape==="usecaseEllipse"||i.shape==="rect")&&i.stereotype){let o=i.label??ht(i.id);i.label=`«${zi(i.stereotype)}»<br/>${i.labelType==="text"?zi(o):o}`,i.labelType="markdown",a.hasFoldedStereotype=!0,delete i.stereotype}}for(let i of t.edges)if(i.label!==void 0&&i.labelType==="text")i.label=ht(i.label);return t},"prepareUsecaseLayoutData"),Qo=e((t,n,i)=>{for(let o of n.nodes){let l=typeof o.domId==="string"?o.domId:Vi(n.diagramId,o.id),h=t.select(`#${l}`),u=o.isGroup?"boundary":Fr[o.shape]?"actor":o.shape==="note"?"note":o.shape==="usecaseJsonTable"?"json":"usecase",c=i.nodes.get(o.id)??o.id;if(h.attr("data-usecase-id",o.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!o.isGroup&&(o.shape==="usecaseEllipse"||o.shape==="rect")&&"hasFoldedStereotype"in o&&o.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,R=m?.firstChild;if(m&&R?.nodeType===3){let y=m.ownerDocument.createElement("span");y.className="usecase-stereotype",m.insertBefore(y,R),y.appendChild(R)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let a=new Map(n.edges.map((o)=>[o.id,o]));t.selectAll('path[data-et="edge"]').each(function(){let o=a.get(this.getAttribute("data-id")??"");if(!o)return;let l=p(this);if(l.attr("id",Vi(n.diagramId,o.id)).attr("data-usecase-id",o.id).attr("data-usecase-kind",o.internal?"note-connector":"relationship"),o.internal)l.attr("aria-hidden","true");else l.attr("role","img").attr("aria-label",i.edges.get(o.id)??o.id)})},"annotateUsecaseElements"),Hi=e((t,n)=>{t.style("--mermaid-usecase-actor-font-size",`${n.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",n.actorFontFamily).style("--mermaid-usecase-actor-font-weight",n.actorFontWeight).style("--mermaid-usecase-font-size",`${n.usecaseFontSize}px`).style("--mermaid-usecase-font-family",n.usecaseFontFamily).style("--mermaid-usecase-font-weight",n.usecaseFontWeight)},"applyUsecaseFonts"),el=e(async(t,n,i,a)=>{r.info("Drawing usecase diagram (unified)",n);let{layout:o}=s(),l=a.db,h=l.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=he(n,h.config.securityLevel);h.layoutAlgorithm=ye(o),Zo(h,n),Hi(d,h),await ge(h,d),Qo(d,h,c);let f=h.diagramPadding;N.insertTitle(d,"usecaseDiagramTitleText",0,l.getDiagramTitle?.()??""),se(d,f,"usecaseDiagram",h.useMaxWidth),Hi(d,h)},"draw"),tl={draw:el},sl=e((t)=>({actorBkg:t.usecaseActorBkg??t.actorBkg??t.mainBkg,actorBorder:t.usecaseActorBorder??t.actorBorder??t.primaryColor,bkg:t.usecaseBkg??t.mainBkg,border:t.usecaseBorder??t.nodeBorder??t.primaryColor,boundaryBkg:t.usecaseBoundaryBkg??t.clusterBkg,boundaryBorder:t.usecaseBoundaryBorder??t.clusterBorder,includeLine:t.usecaseIncludeLine??t.lineColor,extendLine:t.usecaseExtendLine??t.lineColor}),"roleColors"),nl=e((t)=>{let{theme:n,bkgColorArray:i,borderColorArray:a}=t;if(!ae(n,a))return"";let o=b().usecase?.colorScheme==="rotate",l=ie(t.look),h=l==="handDrawn",u=ce(i),c="";for(let d=0;d<ft(a);d++){let f=a[d],m=u?`fill: ${i[d%i.length]};`:"",R=`[data-look="${l}"][data-color-id="color-${d}"]`;if(c+=`
|
|
119
119
|
|
|
120
120
|
& ${R}.system-boundary rect.boundary-body,
|
|
121
121
|
& ${R}.system-boundary rect.boundary-tab,
|