@kimicode/cli 1.0.37 → 1.0.40
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/LICENSE.md +12 -0
- package/README.md +429 -24
- package/bin/stt/requirements.txt +32 -0
- package/bin/stt/stt_server.py +619 -0
- package/bin/tts/requirements.txt +21 -0
- package/bin/tts/tts_server.py +404 -0
- package/cli-wrapper.cjs +4 -0
- package/llms.txt +88 -0
- package/package.json +30 -11
- package/web/dist/assets/AssistantsView-BiUiWjhF.js +1 -0
- package/web/dist/assets/AutomationView-Dcf_yNaI.js +1 -0
- package/web/dist/assets/ChannelConfigView-BLnxsMGm.js +8 -0
- package/web/dist/assets/ConnectorsView-CX3E6X6c.js +1 -0
- package/web/dist/assets/DesignSystemView--x-P-lpD.js +1 -0
- package/web/dist/assets/Drawer-CjAgqH3B.js +1 -0
- package/web/dist/assets/FileTreeView-Chb_fzTK.js +11 -0
- package/web/dist/assets/HookConfigView-EafYlWdN.js +1 -0
- package/web/dist/assets/InputArea-BbHslX7b.js +50 -0
- package/web/dist/assets/ModelsView-CGN5Nljr.js +1 -0
- package/web/dist/assets/PluginsView-CDiJgvI8.js +2 -0
- package/web/dist/assets/ProjectsView-C5Usmwqy.js +1 -0
- package/web/dist/assets/SessionGrid-Drxg0r_u.js +4 -0
- package/web/dist/assets/SettingsModal-Cmts6aBG.js +10 -0
- package/web/dist/assets/Skeleton-Dsk6B0U3.js +1 -0
- package/web/dist/assets/SkillsView-TEDR_3XX.js +1 -0
- package/web/dist/assets/TemplatesTab-DtN5Kdgh.js +1 -0
- package/web/dist/assets/ToolsView-VukZnIt1.js +1 -0
- package/web/dist/assets/VizCardsSkeleton-C_GaEfXd.js +1 -0
- package/web/dist/assets/abnfDiagram-YUKMZFIV-BIFw6B_N.js +1 -0
- package/web/dist/assets/arc-BZQ951h9.js +1 -0
- package/web/dist/assets/architectureDiagram-47P4ROYG-BP5qiXzf.js +36 -0
- package/web/dist/assets/blockDiagram-E7TT5TSB-DtRpcE7F.js +140 -0
- package/web/dist/assets/c4Diagram-CRA5TL53-Gdzn8UBh.js +38 -0
- package/web/dist/assets/channel-BND6_KSH.js +1 -0
- package/web/dist/assets/chunk-2Q5K7J3B-3U6HMlsm.js +1 -0
- package/web/dist/assets/chunk-5VM5RSS4-CYl9mwa-.js +15 -0
- package/web/dist/assets/chunk-7TKQ45FW-Dn6ktcY5.js +1 -0
- package/web/dist/assets/chunk-AW2ZBBNX-De0QX6p1.js +88 -0
- package/web/dist/assets/chunk-FVRAUYC3-CpXDfvz4.js +2 -0
- package/web/dist/assets/chunk-HTAEGDNF-D1KDvcDd.js +1 -0
- package/web/dist/assets/chunk-JWPE2WC7-umm4A-fq.js +1 -0
- package/web/dist/assets/chunk-KQW6MTUR-JYH94hpE.js +1 -0
- package/web/dist/assets/chunk-XXDRQBXY-CSlCFByc.js +1 -0
- package/web/dist/assets/classDiagram-v2-K4WV4PDN-DnFwS0qN.js +217 -0
- package/web/dist/assets/cose-bilkent-JH36ORCC-BxUTUyep.js +1 -0
- package/web/dist/assets/cynefin-EF2NZ3EQ-CiMvulJr.js +141 -0
- package/web/dist/assets/cynefinDiagram-3GCD6N5R-DuXFORdW.js +62 -0
- package/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
- package/web/dist/assets/dagre-W4DXFKR2-DzMZHXci.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-2UJZ2QOL-B6tO5G1v.js +200 -0
- package/web/dist/assets/diagram-OVF4WLC6-DRZt8tGc.js +24 -0
- package/web/dist/assets/diagram-PFPMY2P6-DGh6IecR.js +30 -0
- package/web/dist/assets/diagram-UMYRVEAY-BLbnt0yT.js +24 -0
- package/web/dist/assets/diagram-YEKJPTXX-C-S5DVhj.js +41 -0
- package/web/dist/assets/diagram-ZIFT7M5P-JrGHTWbo.js +3 -0
- package/web/dist/assets/ebnfDiagram-VR2GEFS7-DPXA-YOi.js +1 -0
- package/web/dist/assets/elk-IJKZMXRS-CINeWt2W.js +27 -0
- package/web/dist/assets/erDiagram-O2IAPWRE-PPaHmqA1.js +99 -0
- package/web/dist/assets/flowDiagram-OXPTDLAJ-t-u0QXEA.js +213 -0
- package/web/dist/assets/ganttDiagram-R7TSEDQI-Bw49ZD_b.js +292 -0
- package/web/dist/assets/gitGraphDiagram-XJZIOB7I-BAfOqeeg.js +106 -0
- package/web/dist/assets/graph-Bn3Yngep.js +1 -0
- package/web/dist/assets/{icons-f1hlMKvD.js → icons-Bm_ZzSAy.js} +384 -144
- package/web/dist/assets/index-CeeLdENM.js +677 -0
- package/web/dist/assets/index-Ceez9lYk.css +1 -0
- package/web/dist/assets/infoDiagram-5W2HQ5XZ-Bv4RBxYW.js +2 -0
- package/web/dist/assets/init-Gi6I4Gst.js +1 -0
- package/web/dist/assets/ishikawaDiagram-K3B6WC7H-DEpj0bRp.js +70 -0
- package/web/dist/assets/journeyDiagram-COXZFDF6-MJu84Iiz.js +139 -0
- package/web/dist/assets/kanban-definition-P3RFRI5V-mlYSRALK.js +89 -0
- package/web/dist/assets/linear-5j9gt8MV.js +1 -0
- package/web/dist/assets/{markdown-DEtuzEyz.js → markdown-BWXjRrSw.js} +8 -8
- package/web/dist/assets/mermaid.core-DLb6eAON.js +314 -0
- package/web/dist/assets/mindmap-definition-LZFPQGKD-C9v_57Ex.js +96 -0
- package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/web/dist/assets/{panels-Bn-2wCur.js → panels-BQOvnbWH.js} +1 -1
- package/web/dist/assets/pegDiagram-BGZESJAR-KQP26s3-.js +1 -0
- package/web/dist/assets/pieDiagram-CAPJLFHJ-DN3RQ_ih.js +39 -0
- package/web/dist/assets/profileChange-B7TaQ18u.js +1 -0
- package/web/dist/assets/quadrantDiagram-GDMTTRAM-BpL_ZL76.js +7 -0
- package/web/dist/assets/railroadDiagram-SM67HX2B-DZ-fPU85.js +1 -0
- package/web/dist/assets/{react-vendor-ClBKp0t-.js → react-vendor-C0HIWSpf.js} +1 -1
- package/web/dist/assets/requirementDiagram-X7JNWC4A-mKPGj64L.js +84 -0
- package/web/dist/assets/sankeyDiagram-UM26HJRW-Bs4xfjQP.js +40 -0
- package/web/dist/assets/sequenceDiagram-ZO4K6R2Y-BjUmzZaO.js +169 -0
- package/web/dist/assets/sizeCapture-INFHLROL-BXBM3j_Q.js +1 -0
- package/web/dist/assets/{state-xD58vmym.js → state-Kfon1nTr.js} +1 -1
- package/web/dist/assets/stateDiagram-v2-TBUQTH76-FGgFDGUU.js +291 -0
- package/web/dist/assets/sttLanguages-C7kVulzY.js +1 -0
- package/web/dist/assets/swimlanes-N4OXWK64-wkd_n4HU.js +1 -0
- package/web/dist/assets/swimlanesDiagram-K3J5GTZL-CKnwEuq_.js +8 -0
- package/web/dist/assets/timeline-definition-YOQAKGHF-DyBln1jw.js +120 -0
- package/web/dist/assets/usecaseDiagram-VIAY4XPW-Cqis3XHX.js +370 -0
- package/web/dist/assets/vennDiagram-BLWOH2XV-BaiFLOVS.js +34 -0
- package/web/dist/assets/wardleyDiagram-YMQ3BMBF-C4CzpJto.js +78 -0
- package/web/dist/assets/xychartDiagram-TAQBALBS-Dp1hfe3-.js +7 -0
- package/web/dist/figma-demo/product-1.jpg +0 -0
- package/web/dist/figma-demo/product-2.jpg +0 -0
- package/web/dist/figma-demo/trail-1.jpg +0 -0
- package/web/dist/figma-demo/trail-2.jpg +0 -0
- package/web/dist/figma-demo/trail-3.jpg +0 -0
- package/web/dist/fonts/OFL-Inter.txt +93 -0
- package/web/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/web/dist/icons/icon-180.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon-maskable-512.png +0 -0
- package/web/dist/index.html +39 -9
- package/web/dist/manifest.webmanifest +16 -0
- package/web/dist/assets/AssistantsView-OMdgsTIj.js +0 -1
- package/web/dist/assets/AutomationView-BPwjLbkL.js +0 -1
- package/web/dist/assets/ChannelConfigView-JDljUn42.js +0 -8
- package/web/dist/assets/ConnectorsView-AemNT1Ae.js +0 -1
- package/web/dist/assets/FileTreeView-DYx-0jFV.js +0 -11
- package/web/dist/assets/HookConfigView-CS1QqgPx.js +0 -1
- package/web/dist/assets/ModelsView-B3nHezvJ.js +0 -1
- package/web/dist/assets/PluginsView-C4Xc70ec.js +0 -1
- package/web/dist/assets/SessionGrid-C9-LeJH0.js +0 -47
- package/web/dist/assets/SettingsModal-CjWT1C66.js +0 -4
- package/web/dist/assets/SkillsView-DTZyXald.js +0 -1
- package/web/dist/assets/TemplatesTab-CE-CfCf2.js +0 -1
- package/web/dist/assets/ThreeScene-CMqkpyKO.js +0 -2863
- package/web/dist/assets/ThreeScene-DvOrMIoG.css +0 -1
- package/web/dist/assets/ToolsView-CrEHDTEO.js +0 -1
- package/web/dist/assets/index-BCHbHIbw.css +0 -1
- package/web/dist/assets/index-u1vYyqna.js +0 -592
- package/web/dist/assets/sttLanguages-BNRptAQA.js +0 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import{g as Ni}from"./chunk-XXDRQBXY-CSlCFByc.js";import{s as Ci}from"./chunk-KQW6MTUR-JYH94hpE.js";import{g as Zs,s as jt,a as Qs,b as Gt,x as bi,v as vi,_ as u,G as je,l as _i,c as en,r as Mi,t as xi,u as wi,j as Ui,D as Pi,R as Di,F as Fi,O as Bi,H as $i,M as ji,bx as Gi,k as Wi}from"./mermaid.core-DLb6eAON.js";import"./index-CeeLdENM.js";import"./markdown-BWXjRrSw.js";import"./icons-Bm_ZzSAy.js";import"./react-vendor-C0HIWSpf.js";import"./state-Kfon1nTr.js";import"./panels-BQOvnbWH.js";function Wt(s){console&&console.error&&console.error(`Error: ${s}`)}function tn(s){console&&console.warn&&console.warn(`Warning: ${s}`)}function sn(s){const e=new Date().getTime(),t=s();return{time:new Date().getTime()-e,value:t}}function nn(s){function e(){}e.prototype=s;const t=new e;function n(){return typeof t.bar}return n(),n(),s}function Ki(s){return Vi(s)?s.LABEL:s.name}function Vi(s){return typeof s.LABEL=="string"&&s.LABEL!==""}class te{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}}class K extends te{constructor(e){super([]),this.idx=1,Object.assign(this,ie(e))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class _e extends te{constructor(e){super(e.definition),this.orgText="",Object.assign(this,ie(e))}}class W extends te{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,ie(e))}}class G extends te{constructor(e){super(e.definition),this.idx=1,Object.assign(this,ie(e))}}class se extends te{constructor(e){super(e.definition),this.idx=1,Object.assign(this,ie(e))}}class ne extends te{constructor(e){super(e.definition),this.idx=1,Object.assign(this,ie(e))}}class x extends te{constructor(e){super(e.definition),this.idx=1,Object.assign(this,ie(e))}}class q extends te{constructor(e){super(e.definition),this.idx=1,Object.assign(this,ie(e))}}class Z extends te{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,ie(e))}}class k{constructor(e){this.idx=1,Object.assign(this,ie(e))}accept(e){e.visit(this)}}function zi(s){return s.map(at)}function at(s){function e(t){return t.map(at)}if(s instanceof K){const t={type:"NonTerminal",name:s.nonTerminalName,idx:s.idx};return typeof s.label=="string"&&(t.label=s.label),t}else{if(s instanceof W)return{type:"Alternative",definition:e(s.definition)};if(s instanceof G)return{type:"Option",idx:s.idx,definition:e(s.definition)};if(s instanceof se)return{type:"RepetitionMandatory",idx:s.idx,definition:e(s.definition)};if(s instanceof ne)return{type:"RepetitionMandatoryWithSeparator",idx:s.idx,separator:at(new k({terminalType:s.separator})),definition:e(s.definition)};if(s instanceof q)return{type:"RepetitionWithSeparator",idx:s.idx,separator:at(new k({terminalType:s.separator})),definition:e(s.definition)};if(s instanceof x)return{type:"Repetition",idx:s.idx,definition:e(s.definition)};if(s instanceof Z)return{type:"Alternation",idx:s.idx,definition:e(s.definition)};if(s instanceof k){const t={type:"Terminal",name:s.terminalType.name,label:Ki(s.terminalType),idx:s.idx};typeof s.label=="string"&&(t.terminalLabel=s.label);const n=s.terminalType.PATTERN;return s.terminalType.PATTERN&&(t.pattern=n instanceof RegExp?n.source:n),t}else{if(s instanceof _e)return{type:"Rule",name:s.name,orgText:s.orgText,definition:e(s.definition)};throw Error("non exhaustive match")}}}function ie(s){return Object.fromEntries(Object.entries(s).filter(([,e])=>e!==void 0))}class Me{visit(e){const t=e;switch(t.constructor){case K:return this.visitNonTerminal(t);case W:return this.visitAlternative(t);case G:return this.visitOption(t);case se:return this.visitRepetitionMandatory(t);case ne:return this.visitRepetitionMandatoryWithSeparator(t);case q:return this.visitRepetitionWithSeparator(t);case x:return this.visitRepetition(t);case Z:return this.visitAlternation(t);case k:return this.visitTerminal(t);case _e:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function Hi(s){return s instanceof W||s instanceof G||s instanceof x||s instanceof se||s instanceof ne||s instanceof q||s instanceof k||s instanceof _e}function Tt(s,e=[]){return s instanceof G||s instanceof x||s instanceof q?!0:s instanceof Z?s.definition.some(n=>Tt(n,e)):s instanceof K&&e.includes(s)?!1:s instanceof te?(s instanceof K&&e.push(s),s.definition.every(n=>Tt(n,e))):!1}function Xi(s){return s instanceof Z}function ee(s){if(s instanceof K)return"SUBRULE";if(s instanceof G)return"OPTION";if(s instanceof Z)return"OR";if(s instanceof se)return"AT_LEAST_ONE";if(s instanceof ne)return"AT_LEAST_ONE_SEP";if(s instanceof q)return"MANY_SEP";if(s instanceof x)return"MANY";if(s instanceof k)return"CONSUME";throw Error("non exhaustive match")}class kt{walk(e,t=[]){e.definition.forEach((n,i)=>{const a=e.definition.slice(i+1);if(n instanceof K)this.walkProdRef(n,a,t);else if(n instanceof k)this.walkTerminal(n,a,t);else if(n instanceof W)this.walkFlat(n,a,t);else if(n instanceof G)this.walkOption(n,a,t);else if(n instanceof se)this.walkAtLeastOne(n,a,t);else if(n instanceof ne)this.walkAtLeastOneSep(n,a,t);else if(n instanceof q)this.walkManySep(n,a,t);else if(n instanceof x)this.walkMany(n,a,t);else if(n instanceof Z)this.walkOr(n,a,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){const i=t.concat(n);this.walk(e,i)}walkOption(e,t,n){const i=t.concat(n);this.walk(e,i)}walkAtLeastOne(e,t,n){const i=[new G({definition:e.definition})].concat(t,n);this.walk(e,i)}walkAtLeastOneSep(e,t,n){const i=ys(e,t,n);this.walk(e,i)}walkMany(e,t,n){const i=[new G({definition:e.definition})].concat(t,n);this.walk(e,i)}walkManySep(e,t,n){const i=ys(e,t,n);this.walk(e,i)}walkOr(e,t,n){const i=t.concat(n);e.definition.forEach(a=>{const r=new W({definition:[a]});this.walk(r,i)})}}function ys(s,e,t){return[new G({definition:[new k({terminalType:s.separator})].concat(s.definition)})].concat(e,t)}function Je(s){if(s instanceof K)return Je(s.referencedRule);if(s instanceof k)return qi(s);if(Hi(s))return Yi(s);if(Xi(s))return Ji(s);throw Error("non exhaustive match")}function Yi(s){let e=[];const t=s.definition;let n=0,i=t.length>n,a,r=!0;for(;i&&r;)a=t[n],r=Tt(a),e=e.concat(Je(a)),n=n+1,i=t.length>n;return[...new Set(e)]}function Ji(s){const e=s.definition.map(t=>Je(t));return[...new Set(e.flat())]}function qi(s){return[s.terminalType]}const an="_~IN~_";class Zi extends kt{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){const i=ea(e.referencedRule,e.idx)+this.topProd.name,a=t.concat(n),r=new W({definition:a}),o=Je(r);this.follows[i]=o}}function Qi(s){const e={};return s.forEach(t=>{const n=new Zi(t).startWalking();Object.assign(e,n)}),e}function ea(s,e){return s.name+e+an}function y(s){return s.charCodeAt(0)}function Pt(s,e){Array.isArray(s)?s.forEach(function(t){e.push(t)}):e.push(s)}function Fe(s,e){if(s[e]===!0)throw"duplicate flag "+e;s[e],s[e]=!0}function Se(s){if(s===void 0)throw Error("Internal Error - Should never get here!");return!0}function ta(){throw Error("Internal Error - Should never get here!")}function Rs(s){return s.type==="Character"}const gt=[];for(let s=y("0");s<=y("9");s++)gt.push(s);const At=[y("_")].concat(gt);for(let s=y("a");s<=y("z");s++)At.push(s);for(let s=y("A");s<=y("Z");s++)At.push(s);const Os=[y(" "),y("\f"),y(`
|
|
2
|
+
`),y("\r"),y(" "),y("\v"),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y(" "),y("\u2028"),y("\u2029"),y(" "),y(" "),y(" "),y("\uFEFF")],sa=/[0-9a-fA-F]/,tt=/[0-9]/,na=/[1-9]/;class ia{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");const t=this.disjunction();this.consumeChar("/");const n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Fe(n,"global");break;case"i":Fe(n,"ignoreCase");break;case"m":Fe(n,"multiLine");break;case"u":Fe(n,"unicode");break;case"y":Fe(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:t,loc:this.loc(0)}}disjunction(){const e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){const e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}Se(t);const n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}return ta()}quantifier(e=!1){let t;const n=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":const i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":let a;this.isDigit()?(a=this.integerIncludingZero(),t={atLeast:i,atMost:a}):t={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;Se(t);break}if(!(e===!0&&t===void 0)&&Se(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t}atom(){let e;const t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Se(e))return e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[y(`
|
|
3
|
+
`),y("\r"),y("\u2028"),y("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=gt;break;case"D":e=gt,t=!0;break;case"s":e=Os;break;case"S":e=Os,t=!0;break;case"w":e=At;break;case"W":e=At,t=!0;break}if(Se(e))return{type:"Set",value:e,complement:t}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=y("\f");break;case"n":e=y(`
|
|
4
|
+
`);break;case"r":e=y("\r");break;case"t":e=y(" ");break;case"v":e=y("\v");break}if(Se(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:y("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:y(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
5
|
+
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:y(e)}}}characterClass(){const e=[];let t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){const n=this.classAtom();if(n.type,Rs(n)&&this.isRangeDash()){this.consumeChar("-");const i=this.classAtom();if(i.type,Rs(i)){if(i.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:i.value})}else Pt(n.value,e),e.push(y("-")),Pt(i.value,e)}else Pt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
6
|
+
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:y("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}const t=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(na.test(e)===!1)throw Error("Expecting a positive integer");for(;tt.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(tt.test(e)===!1)throw Error("Expecting an integer");for(;tt.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const e=this.popChar();switch(e){case`
|
|
7
|
+
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:y(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return tt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
8
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!"||this.peekChar(2)==="<"&&(this.peekChar(3)==="="||this.peekChar(3)==="!"));default:return!1}}isQuantifier(){const e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
|
|
9
|
+
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let i=0;i<e;i++){const a=this.popChar();if(sa.test(a)===!1)throw Error("Expecting a HexDecimal digits");t+=a}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class os{visitChildren(e){for(const t in e){const n=e[t];e.hasOwnProperty(t)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}let rt={};const aa=new ia;function qe(s){const e=s.toString();if(rt.hasOwnProperty(e))return rt[e];{const t=aa.pattern(e);return rt[e]=t,t}}function ra(){rt={}}const rn="Complement Sets are not supported for first char optimization",St=`Unable to use "first char" lexer optimizations:
|
|
10
|
+
`;function oa(s,e=!1){try{const t=qe(s);return Kt(t.value,{},t.flags.ignoreCase)}catch(t){if(t.message===rn)e&&tn(`${St} Unable to optimize: < ${s.toString()} >
|
|
11
|
+
Complement Sets cannot be automatically optimized.
|
|
12
|
+
This will disable the lexer's first char optimizations.
|
|
13
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";e&&(n=`
|
|
14
|
+
This will disable the lexer's first char optimizations.
|
|
15
|
+
See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Wt(`${St}
|
|
16
|
+
Failed parsing: < ${s.toString()} >
|
|
17
|
+
Using the @chevrotain/regexp-to-ast library
|
|
18
|
+
Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Kt(s,e,t){switch(s.type){case"Disjunction":for(let i=0;i<s.value.length;i++)Kt(s.value[i],e,t);break;case"Alternative":const n=s.value;for(let i=0;i<n.length;i++){const a=n[i];switch(a.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const r=a;switch(r.type){case"Character":st(r.value,e,t);break;case"Set":if(r.complement===!0)throw Error(rn);r.value.forEach(l=>{if(typeof l=="number")st(l,e,t);else{const h=l;if(t===!0)for(let d=h.from;d<=h.to;d++)st(d,e,t);else{for(let d=h.from;d<=h.to&&d<We;d++)st(d,e,t);if(h.to>=We){const d=h.from>=We?h.from:We,c=h.to,f=ue(d),p=ue(c);for(let A=f;A<=p;A++)e[A]=A}}}});break;case"Group":Kt(r.value,e,t);break;default:throw Error("Non Exhaustive Match")}const o=r.quantifier!==void 0&&r.quantifier.atLeast===0;if(r.type==="Group"&&Vt(r)===!1||r.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(e)}function st(s,e,t){const n=ue(s);e[n]=n,t===!0&&la(s,e)}function la(s,e){const t=String.fromCharCode(s),n=t.toUpperCase();if(n!==t){const i=ue(n.charCodeAt(0));e[i]=i}else{const i=t.toLowerCase();if(i!==t){const a=ue(i.charCodeAt(0));e[a]=a}}}function Ls(s,e){return s.value.find(t=>{if(typeof t=="number")return e.includes(t);{const n=t;return e.find(i=>n.from<=i&&i<=n.to)!==void 0}})}function Vt(s){const e=s.quantifier;return e&&e.atLeast===0?!0:s.value?Array.isArray(s.value)?s.value.every(Vt):Vt(s.value):!1}class ca extends os{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?Ls(e,this.targetCharCodes)===void 0&&(this.found=!0):Ls(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function ls(s,e){if(e instanceof RegExp){const t=qe(e),n=new ca(s);return n.visit(t),n.found}else{for(const t of e){const n=t.charCodeAt(0);if(s.includes(n))return!0}return!1}}const Te="PATTERN",Ge="defaultMode",nt="modes",zt=0,ot=1,Ht=2,Xt=3;function ha(s,e){e=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
|
|
19
|
+
`],tracer:(T,m)=>m()},e);const t=e.tracer;t("initCharCodeToOptimizedIndexMap",()=>{wa()});let n;t("Reject Lexer.NA",()=>{n=s.filter(T=>T[Te]!==F.NA)});let i=!1,a;t("Transform Patterns",()=>{i=!1,a=n.map(T=>{const m=T[Te];if(m instanceof RegExp){const E=m.source;return E.length===1&&E!=="^"&&E!=="$"&&E!=="."&&!m.ignoreCase?E:E.length===2&&E[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(E[1])?E[1]:Is(m)}else{if(typeof m=="function")return i=!0,{exec:m};if(typeof m=="object")return i=!0,m;if(typeof m=="string"){if(m.length===1)return m;{const E=m.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),v=new RegExp(E);return Is(v)}}else throw Error("non exhaustive match")}})});let r,o,l,h,d;t("misc mapping",()=>{r=n.map(T=>T.tokenTypeIdx),o=n.map(T=>{const m=T.GROUP;if(m!==F.SKIPPED){if(typeof m=="string")return m;if(m===void 0)return!1;throw Error("non exhaustive match")}}),l=n.map(T=>{const m=T.LONGER_ALT;if(m)return Array.isArray(m)?m.map(v=>n.indexOf(v)):[n.indexOf(m)]}),h=n.map(T=>T.PUSH_MODE),d=n.map(T=>Object.hasOwn(T,"POP_MODE"))});let c;t("Line Terminator Handling",()=>{const T=cn(e.lineTerminatorCharacters);c=n.map(m=>!1),e.positionTracking!=="onlyOffset"&&(c=n.map(m=>Object.hasOwn(m,"LINE_BREAKS")?!!m.LINE_BREAKS:ln(m,T)===!1&&ls(T,m.PATTERN)))});let f,p,A,R;t("Misc Mapping #2",()=>{f=n.map(on),p=a.map(_a),A=n.reduce((T,m)=>{const E=m.GROUP;return typeof E=="string"&&E!==F.SKIPPED&&(T[E]=[]),T},{}),R=a.map((T,m)=>{const E=o[m]===void 0&&l[m]===void 0?ua(n[m].PATTERN):void 0;return{pattern:a[m],asciiClass:E,longerAlt:l[m],canLineTerminator:c[m],matchType:E!==void 0?Xt:p[m]!==!1?zt:f[m]?ot:Ht,short:p[m],group:o[m],push:h[m],pop:d[m],tokenTypeIdx:r[m],tokenType:n[m]}})});let L=!0,g=[];return e.safeMode||t("First Char Optimization",()=>{g=n.reduce((T,m,E)=>{if(typeof m.PATTERN=="string"){const v=m.PATTERN.charCodeAt(0),Y=ue(v);Dt(T,Y,R[E])}else if(Array.isArray(m.START_CHARS_HINT)){let v;m.START_CHARS_HINT.forEach(Y=>{const he=typeof Y=="string"?Y.charCodeAt(0):Y,de=ue(he);v!==de&&(v=de,Dt(T,de,R[E]))})}else if(m.PATTERN instanceof RegExp)if(m.PATTERN.unicode)L=!1,e.ensureOptimizations&&Wt(`${St} Unable to analyze < ${m.PATTERN.toString()} > pattern.
|
|
20
|
+
The regexp unicode flag is not currently supported by the regexp-to-ast library.
|
|
21
|
+
This will disable the lexer's first char optimizations.
|
|
22
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const v=oa(m.PATTERN,e.ensureOptimizations);v.length===0&&(L=!1),v.forEach(Y=>{Dt(T,Y,R[E])})}else e.ensureOptimizations&&Wt(`${St} TokenType: <${m.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
|
|
23
|
+
This will disable the lexer's first char optimizations.
|
|
24
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),L=!1;return T},[])}),{emptyGroups:A,patternIdxToConfig:R,charCodeToPatternIdxToConfig:g,hasCustom:i,canBeOptimized:L}}function ua(s){var e,t;if(!(s instanceof RegExp)||s.flags!=="")return;let n;try{n=qe(s)}catch{return}if(n.value.value.length!==1||n.value.value[0].value.length!==1)return;let i=n.value.value[0].value[0],a;for(;i.type==="Group";){if(i.capturing||i.quantifier!==void 0&&a!==void 0||i.value.value.length!==1||i.value.value[0].value.length!==1)return;a=(e=i.quantifier)!==null&&e!==void 0?e:a,i=i.value.value[0].value[0]}if(i.type!=="Set"||i.complement||i.quantifier!==void 0&&a!==void 0||(a=(t=i.quantifier)!==null&&t!==void 0?t:a,(a==null?void 0:a.atLeast)!==1||a.atMost!==1/0||!a.greedy))return;const r=new Uint8Array(128);for(const o of i.value){const l=typeof o=="number"?o:o.from,h=typeof o=="number"?o:o.to;if(l<0||h>=r.length)return;r.fill(1,l,h+1)}return r}function da(s,e){let t=[];const n=pa(s);t=t.concat(n.errors);const i=ma(n.valid),a=i.valid;return t=t.concat(i.errors),t=t.concat(fa(a)),t=t.concat(Oa(a)),t=t.concat(La(a,e)),t=t.concat(Ia(a)),t}function fa(s){let e=[];const t=s.filter(n=>n[Te]instanceof RegExp);return e=e.concat(Ta(t)),e=e.concat(Sa(t)),e=e.concat(ya(t)),e=e.concat(Ra(t)),e=e.concat(ga(t)),e}function pa(s){const e=s.filter(i=>!Object.hasOwn(i,Te)),t=e.map(i=>({message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:b.MISSING_PATTERN,tokenTypes:[i]})),n=s.filter(i=>!e.includes(i));return{errors:t,valid:n}}function ma(s){const e=s.filter(i=>{const a=i[Te];return!(a instanceof RegExp)&&typeof a!="function"&&!Object.hasOwn(a,"exec")&&typeof a!="string"}),t=e.map(i=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:b.INVALID_PATTERN,tokenTypes:[i]})),n=s.filter(i=>!e.includes(i));return{errors:t,valid:n}}const Ea=/[^\\][$]/;function Ta(s){class e extends os{constructor(){super(...arguments),this.found=!1}visitEndAnchor(a){this.found=!0}}return s.filter(i=>{const a=i.PATTERN;try{const r=qe(a),o=new e;return o.visit(r),o.found}catch{return Ea.test(a.source)}}).map(i=>({message:`Unexpected RegExp Anchor Error:
|
|
25
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
|
|
26
|
+
See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:b.EOI_ANCHOR_FOUND,tokenTypes:[i]}))}function ga(s){return s.filter(n=>n.PATTERN.test("")).map(n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:b.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}const Aa=/[^\\[][\^]|^\^/;function Sa(s){class e extends os{constructor(){super(...arguments),this.found=!1}visitStartAnchor(a){this.found=!0}}return s.filter(i=>{const a=i.PATTERN;try{const r=qe(a),o=new e;return o.visit(r),o.found}catch{return Aa.test(a.source)}}).map(i=>({message:`Unexpected RegExp Anchor Error:
|
|
27
|
+
Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
|
|
28
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:b.SOI_ANCHOR_FOUND,tokenTypes:[i]}))}function ya(s){return s.filter(n=>{const i=n[Te];return i instanceof RegExp&&(i.multiline||i.global)}).map(n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:b.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}function Ra(s){const e=[];let t=s.map(a=>s.reduce((r,o)=>(a.PATTERN.source===o.PATTERN.source&&!e.includes(o)&&o.PATTERN!==F.NA&&(e.push(o),r.push(o)),r),[]));return t=t.filter(Boolean),t.filter(a=>a.length>1).map(a=>{const r=a.map(l=>l.name);return{message:`The same RegExp pattern ->${a[0].PATTERN}<-has been used in all of the following Token Types: ${r.join(", ")} <-`,type:b.DUPLICATE_PATTERNS_FOUND,tokenTypes:a}})}function Oa(s){return s.filter(n=>{if(!Object.hasOwn(n,"GROUP"))return!1;const i=n.GROUP;return i!==F.SKIPPED&&i!==F.NA&&typeof i!="string"}).map(n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:b.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}function La(s,e){return s.filter(i=>i.PUSH_MODE!==void 0&&!e.includes(i.PUSH_MODE)).map(i=>({message:`Token Type: ->${i.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${i.PUSH_MODE}<-which does not exist`,type:b.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}))}function Ia(s){const e=[],t=s.reduce((n,i,a)=>{const r=i.PATTERN;return r===F.NA||(typeof r=="string"?n.push({str:r,idx:a,tokenType:i}):r instanceof RegExp&&Na(r)&&n.push({str:r.source,idx:a,tokenType:i})),n},[]);return s.forEach((n,i)=>{t.forEach(({str:a,idx:r,tokenType:o})=>{if(i<r&&ka(a,n.PATTERN)){const l=`Token: ->${o.name}<- can never be matched.
|
|
29
|
+
Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
|
|
30
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:l,type:b.UNREACHABLE_PATTERN,tokenTypes:[n,o]})}})}),e}function ka(s,e){if(e instanceof RegExp){if(Ca(e))return!1;const t=e.exec(s);return t!==null&&t.index===0}else{if(typeof e=="function")return e(s,0,[],{});if(Object.hasOwn(e,"exec"))return e.exec(s,0,[],{});if(typeof e=="string")return e===s;throw Error("non exhaustive match")}}function Na(s){return[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find(t=>s.source.indexOf(t)!==-1)===void 0}function Ca(s){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(s.source)}function Is(s){const e=s.ignoreCase?"iy":"y";return new RegExp(`${s.source}`,e)}function ba(s,e,t){const n=[];return Object.hasOwn(s,Ge)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Ge+`> property in its definition
|
|
31
|
+
`,type:b.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(s,nt)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+nt+`> property in its definition
|
|
32
|
+
`,type:b.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(s,nt)&&Object.hasOwn(s,Ge)&&!Object.hasOwn(s.modes,s.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${Ge}: <${s.defaultMode}>which does not exist
|
|
33
|
+
`,type:b.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(s,nt)&&Object.keys(s.modes).forEach(i=>{const a=s.modes[i];a.forEach((r,o)=>{r===void 0?n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${i}> at index: <${o}>
|
|
34
|
+
`,type:b.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(r,"LONGER_ALT")&&(Array.isArray(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT]).forEach(h=>{h!==void 0&&!a.includes(h)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${h.name}> on token <${r.name}> outside of mode <${i}>
|
|
35
|
+
`,type:b.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),n}function va(s,e,t){const n=[];let i=!1;const r=Object.values(s.modes||{}).flat().filter(Boolean).filter(l=>l[Te]!==F.NA),o=cn(t);return e&&r.forEach(l=>{const h=ln(l,o);if(h!==!1){const c={message:xa(l,h),type:h.issue,tokenType:l};n.push(c)}else Object.hasOwn(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(i=!0):ls(o,l.PATTERN)&&(i=!0)}),e&&!i&&n.push({message:`Warning: No LINE_BREAKS Found.
|
|
36
|
+
This Lexer has been defined to track line and column information,
|
|
37
|
+
But none of the Token Types can be identified as matching a line terminator.
|
|
38
|
+
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
|
|
39
|
+
for details.`,type:b.NO_LINE_BREAKS_FLAGS}),n}function on(s){const e=s.PATTERN;if(e instanceof RegExp)return!1;if(typeof e=="function")return!0;if(Object.hasOwn(e,"exec"))return!0;if(typeof e=="string")return!1;throw Error("non exhaustive match")}function _a(s){return typeof s=="string"&&s.length===1?s.charCodeAt(0):!1}const Ma={test:function(s){const e=s.length;for(let t=this.lastIndex;t<e;t++){const n=s.charCodeAt(t);if(n===10)return this.lastIndex=t+1,!0;if(n===13)return s.charCodeAt(t+1)===10?this.lastIndex=t+2:this.lastIndex=t+1,!0}return!1},lastIndex:0};function ln(s,e){if(Object.hasOwn(s,"LINE_BREAKS"))return!1;if(s.PATTERN instanceof RegExp){try{ls(e,s.PATTERN)}catch(t){return{issue:b.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}else{if(typeof s.PATTERN=="string")return!1;if(on(s))return{issue:b.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function xa(s,e){if(e.issue===b.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
|
|
40
|
+
The problem is in the <${s.name}> Token Type
|
|
41
|
+
Root cause: ${e.errMsg}.
|
|
42
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===b.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
43
|
+
The problem is in the <${s.name}> Token Type
|
|
44
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function cn(s){return s.map(t=>typeof t=="string"?t.charCodeAt(0):t)}function Dt(s,e,t){s[e]===void 0?s[e]=[t]:s[e].push(t)}const We=256;let lt=[];function ue(s){return s<We?s:lt[s]}function wa(){if(lt.length===0){lt=new Array(65536);for(let s=0;s<65536;s++)lt[s]=s>255?255+~~(s/255):s}}function Ze(s,e){const t=s.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}function yt(s,e){return s.tokenTypeIdx===e.tokenTypeIdx}let ks=1;const hn={};function Qe(s){const e=Ua(s);Pa(e),Fa(e),Da(e),e.forEach(t=>{t.isParent=t.categoryMatches.length>0})}function Ua(s){let e=[...s],t=s,n=!0;for(;n;){t=t.map(a=>a.CATEGORIES).flat().filter(Boolean);const i=t.filter(a=>!e.includes(a));e=e.concat(i),i.length===0?n=!1:t=i}return e}function Pa(s){s.forEach(e=>{dn(e)||(hn[ks]=e,e.tokenTypeIdx=ks++),Ns(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Ns(e)||(e.CATEGORIES=[]),Ba(e)||(e.categoryMatches=[]),$a(e)||(e.categoryMatchesMap={})})}function Da(s){s.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(hn[t].tokenTypeIdx)})})}function Fa(s){s.forEach(e=>{un([],e)})}function un(s,e){s.forEach(t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),e.CATEGORIES.forEach(t=>{const n=s.concat(e);n.includes(t)||un(n,t)})}function dn(s){return Object.hasOwn(s??{},"tokenTypeIdx")}function Ns(s){return Object.hasOwn(s??{},"CATEGORIES")}function Ba(s){return Object.hasOwn(s??{},"categoryMatches")}function $a(s){return Object.hasOwn(s??{},"categoryMatchesMap")}function ja(s){return Object.hasOwn(s??{},"tokenTypeIdx")}const Ga={buildUnableToPopLexerModeMessage(s){return`Unable to pop Lexer Mode after encountering Token ->${s.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(s,e,t,n,i,a){return`unexpected character: ->${s.charAt(e)}<- at offset: ${e}, skipped ${t} characters.`}};var b;(function(s){s[s.MISSING_PATTERN=0]="MISSING_PATTERN",s[s.INVALID_PATTERN=1]="INVALID_PATTERN",s[s.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",s[s.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",s[s.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",s[s.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",s[s.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",s[s.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",s[s.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",s[s.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",s[s.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",s[s.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",s[s.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",s[s.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",s[s.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",s[s.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",s[s.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",s[s.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(b||(b={}));const Ke={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
45
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Ga,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Ke);class F{constructor(e,t=Ke){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,a)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;const r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${r}--> <${i}>`);const{time:o,value:l}=sn(a),h=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(`${r}<-- <${i}> time: ${o}ms`),this.traceInitIndent--,l}else return a()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
46
|
+
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Ke,t);const n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,a=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Ke.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Ma;else if(this.config.lineTerminatorCharacters===Ke.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
47
|
+
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?i={modes:{defaultMode:[...e]},defaultMode:Ge}:(a=!1,i=Object.assign({},e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(ba(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(va(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},Object.entries(i.modes).forEach(([o,l])=>{i.modes[o]=l.filter(h=>h!==void 0)});const r=Object.keys(i.modes);if(Object.entries(i.modes).forEach(([o,l])=>{this.TRACE_INIT(`Mode: <${o}> processing`,()=>{if(this.modes.push(o),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(da(l,r))}),this.lexerDefinitionErrors.length===0){Qe(l);let h;this.TRACE_INIT("analyzeTokenTypes",()=>{h=ha(l,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[o]=h.patternIdxToConfig,this.charCodeToPatternIdxToConfig[o]=h.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,h.emptyGroups),this.hasCustom=h.hasCustom||this.hasCustom,this.canModeBeOptimized[o]=h.canBeOptimized}})}),this.defaultMode=i.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){const l=this.lexerDefinitionErrors.map(h=>h.message).join(`-----------------------
|
|
48
|
+
`);throw new Error(`Errors detected in definition of Lexer:
|
|
49
|
+
`+l)}this.lexerDefinitionWarning.forEach(o=>{tn(o.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(a&&(this.handleModes=()=>{}),this.trackStartLines===!1&&(this.computeNewColumn=o=>o),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const o=Object.entries(this.canModeBeOptimized).reduce((l,[h,d])=>(d===!1&&l.push(h),l),[]);if(t.ensureOptimizations&&o.length>0)throw Error(`Lexer Modes: < ${o.join(", ")} > cannot be optimized.
|
|
50
|
+
Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
|
|
51
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{ra()}),this.TRACE_INIT("toFastProperties",()=>{nn(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0){const i=this.lexerDefinitionErrors.map(a=>a.message).join(`-----------------------
|
|
52
|
+
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
53
|
+
`+i)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,i,a,r,o,l,h,d,c,f,p,A,R,L,g;const T=e,m=T.length;let E=0,v=0;const Y=this.hasCustom?0:Math.floor(e.length/10),he=new Array(Y),de=[];let we=this.trackStartLines?1:void 0,Q=this.trackStartLines?1:void 0;const Ae={};for(let M=0;M<this.cachedGroupKeys.length;M++)Ae[this.cachedGroupKeys[M]]=[];const Ii=this.trackStartLines,_t=this.config.lineTerminatorsPattern;let Mt=0,fe=[],Ue=[];const Pe=[],gs=[];Object.freeze(gs);let De=!1;const ki=M=>{if(Pe.length===1&&M.tokenType.PUSH_MODE===void 0){const z=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(M);de.push({offset:M.startOffset,line:M.startLine,column:M.startColumn,length:M.image.length,message:z})}else{Pe.pop();const z=Pe.at(-1);fe=this.patternIdxToConfig[z],Ue=this.charCodeToPatternIdxToConfig[z],Mt=fe.length;const xt=this.canModeBeOptimized[z]&&this.config.safeMode===!1;Ue&&xt?De=!0:De=!1}};function As(M){Pe.push(M),Ue=this.charCodeToPatternIdxToConfig[M],fe=this.patternIdxToConfig[M],Mt=fe.length;const z=this.canModeBeOptimized[M]&&this.config.safeMode===!1;Ue&&z?De=!0:De=!1}As.call(this,t);let V;const Ss=this.config.recoveryEnabled;for(;E<m;){l=null,c=-1;const M=T.charCodeAt(E);let z;if(De){const U=ue(M),j=Ue[U];z=j!==void 0?j:gs}else z=fe;const xt=z.length;for(n=0;n<xt;n++){V=z[n];const U=V.pattern;switch(h=null,V.matchType){case zt:M===V.short&&(c=1,l=U);break;case ot:g=U.exec(T,E,he,Ae),g!==null?(l=g[0],c=l.length,g.payload!==void 0&&(h=g.payload)):l=null;break;case Xt:{const j=V.asciiClass;if(j[M]!==1){U.lastIndex=0;break}let B=E+1;for(;j[T.charCodeAt(B)]===1;)B++;c=B-E,U.lastIndex=B;break}case Ht:U.lastIndex=E,c=this.matchLength(U,e,E);break}if(c!==-1){if(o=V.longerAlt,o!==void 0){l=e.substring(E,E+c);const j=o.length;for(a=0;a<j;a++){const B=fe[o[a]],ae=B.pattern;if(d=null,B.matchType===ot?(g=ae.exec(T,E,he,Ae),g!==null?(r=g[0],g.payload!==void 0&&(d=g.payload)):r=null):(ae.lastIndex=E,r=this.match(ae,e,E)),r&&r.length>l.length){l=r,c=r.length,h=d,V=B;break}}}break}}if(c!==-1){if(f=V.group,f!==void 0&&(l=l!==null?l:e.substring(E,E+c),p=V.tokenTypeIdx,A=this.createTokenInstance(l,E,p,V.tokenType,we,Q,c),this.handlePayload(A,h),f===!1?v=this.addToken(he,v,A):Ae[f].push(A)),Ii===!0&&V.canLineTerminator===!0){let U=0,j,B;_t.lastIndex=0;do l=l!==null?l:e.substring(E,E+c),j=_t.test(l),j===!0&&(B=_t.lastIndex-1,U++);while(j===!0);U!==0?(we=we+U,Q=c-B,this.updateTokenEndLineColumnLocation(A,f,B,U,we,Q,c)):Q=this.computeNewColumn(Q,c)}else Q=this.computeNewColumn(Q,c);E=E+c,this.handleModes(V,ki,As,A)}else{const U=E,j=we,B=Q;let ae=Ss===!1;for(;ae===!1&&E<m;)for(E++,i=0;i<Mt;i++){const wt=fe[i],Ut=wt.pattern;switch(wt.matchType){case zt:T.charCodeAt(E)===wt.short&&(ae=!0);break;case ot:ae=Ut.exec(T,E,he,Ae)!==null;break;case Xt:case Ht:Ut.lastIndex=E,ae=Ut.exec(e)!==null;break}if(ae===!0)break}if(R=E-U,Q=this.computeNewColumn(Q,R),L=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(T,U,R,j,B,Pe.at(-1)),de.push({offset:U,line:j,column:B,length:R,message:L}),Ss===!1)break}}return this.hasCustom||(he.length=v),{tokens:he,groups:Ae,errors:de}}handleModes(e,t,n,i){if(e.pop===!0){const a=e.push;t(i),a!==void 0&&n.call(this,a)}else e.push!==void 0&&n.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,n,i,a,r,o){let l,h;t!==void 0&&(l=n===o-1,h=l?-1:0,i===1&&l===!0||(e.endLine=a+h,e.endColumn=r-1+-h))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,i){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,t,n,i,a,r){return{image:e,startOffset:t,startLine:a,startColumn:r,tokenTypeIdx:n,tokenType:i}}createFullToken(e,t,n,i,a,r,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:a,endLine:a,startColumn:r,endColumn:r+o-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchLength(e,t,n){return e.test(t)===!0?e.lastIndex-n:-1}}F.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.";F.NA=/NOT_APPLICABLE/;function Ye(s){return fn(s)?s.LABEL:s.name}function fn(s){return typeof s.LABEL=="string"&&s.LABEL!==""}const Wa="parent",Cs="categories",bs="label",vs="group",_s="push_mode",Ms="pop_mode",xs="longer_alt",ws="line_breaks",Us="start_chars_hint";function S(s){return Ka(s)}function Ka(s){const e=s.pattern,t={};if(t.name=s.name,e!==void 0&&(t.PATTERN=e),Object.hasOwn(s,Wa))throw`The parent property is no longer supported.
|
|
54
|
+
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return Object.hasOwn(s,Cs)&&(t.CATEGORIES=s[Cs]),Qe([t]),Object.hasOwn(s,bs)&&(t.LABEL=s[bs]),Object.hasOwn(s,vs)&&(t.GROUP=s[vs]),Object.hasOwn(s,Ms)&&(t.POP_MODE=s[Ms]),Object.hasOwn(s,_s)&&(t.PUSH_MODE=s[_s]),Object.hasOwn(s,xs)&&(t.LONGER_ALT=s[xs]),Object.hasOwn(s,ws)&&(t.LINE_BREAKS=s[ws]),Object.hasOwn(s,Us)&&(t.START_CHARS_HINT=s[Us]),t}const le=S({name:"EOF",pattern:F.NA});Qe([le]);function cs(s,e,t,n,i,a,r,o){return{image:e,startOffset:t,endOffset:n,startLine:i,endLine:a,startColumn:r,endColumn:o,tokenTypeIdx:s.tokenTypeIdx,tokenType:s}}function pn(s,e){return Ze(s,e)}const mn={buildMismatchTokenMessage({expected:s,actual:e,previous:t,ruleName:n}){return`Expecting ${fn(s)?`--> ${Ye(s)} <--`:`token of type --> ${s.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:s,ruleName:e}){return"Redundant input, expecting EOF but found: "+s.image},buildNoViableAltMessage({expectedPathsPerAlt:s,actual:e,previous:t,customUserDescription:n,ruleName:i}){const a="Expecting: ",o=`
|
|
55
|
+
but found: '`+e[0].image+"'";if(n)return a+n+o;{const c=`one of these possible Token sequences:
|
|
56
|
+
${s.reduce((f,p)=>f.concat(p),[]).map(f=>`[${f.map(p=>Ye(p)).join(", ")}]`).map((f,p)=>` ${p+1}. ${f}`).join(`
|
|
57
|
+
`)}`;return a+c+o}},buildEarlyExitMessage({expectedIterationPaths:s,actual:e,customUserDescription:t,ruleName:n}){const i="Expecting: ",r=`
|
|
58
|
+
but found: '`+e[0].image+"'";if(t)return i+t+r;{const l=`expecting at least one iteration which starts with one of these possible Token sequences::
|
|
59
|
+
<${s.map(h=>`[${h.map(d=>Ye(d)).join(",")}]`).join(" ,")}>`;return i+l+r}}};Object.freeze(mn);const Va={buildRuleNotFoundError(s,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
|
|
60
|
+
inside top level rule: ->`+s.name+"<-"}},Ee={buildDuplicateFoundError(s,e){function t(d){return d instanceof k?d.terminalType.name:d instanceof K?d.nonTerminalName:""}const n=s.name,i=e[0],a=i.idx,r=ee(i),o=t(i),l=a>0;let h=`->${r}${l?a:""}<- ${o?`with argument: ->${o}<-`:""}
|
|
61
|
+
appears more than once (${e.length} times) in the top level rule: ->${n}<-.
|
|
62
|
+
For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
|
|
63
|
+
`;return h=h.replace(/[ \t]+/g," "),h=h.replace(/\s\s+/g,`
|
|
64
|
+
`),h},buildNamespaceConflictError(s){return`Namespace conflict found in grammar.
|
|
65
|
+
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${s.name}>.
|
|
66
|
+
To resolve this make sure each Terminal and Non-Terminal names are unique
|
|
67
|
+
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
|
|
68
|
+
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(s){const e=s.prefixPath.map(i=>Ye(i)).join(", "),t=s.alternation.idx===0?"":s.alternation.idx;return`Ambiguous alternatives: <${s.ambiguityIndices.join(" ,")}> due to common lookahead prefix
|
|
69
|
+
in <OR${t}> inside <${s.topLevelRule.name}> Rule,
|
|
70
|
+
<${e}> may appears as a prefix path in all these alternatives.
|
|
71
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
|
|
72
|
+
For Further details.`},buildAlternationAmbiguityError(s){const e=s.alternation.idx===0?"":s.alternation.idx,t=s.prefixPath.length===0;let n=`Ambiguous Alternatives Detected: <${s.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${s.topLevelRule.name}> Rule,
|
|
73
|
+
`;if(t)n+=`These alternatives are all empty (match no tokens), making them indistinguishable.
|
|
74
|
+
Only the last alternative may be empty.
|
|
75
|
+
`;else{const i=s.prefixPath.map(a=>Ye(a)).join(", ");n+=`<${i}> may appears as a prefix path in all these alternatives.
|
|
76
|
+
`}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
|
|
77
|
+
For Further details.`,n},buildEmptyRepetitionError(s){let e=ee(s.repetition);return s.repetition.idx!==0&&(e+=s.repetition.idx),`The repetition <${e}> within Rule <${s.topLevelRule.name}> can never consume any tokens.
|
|
78
|
+
This could lead to an infinite loop.`},buildTokenNameError(s){return"deprecated"},buildEmptyAlternationError(s){return`Ambiguous empty alternative: <${s.emptyChoiceIdx+1}> in <OR${s.alternation.idx}> inside <${s.topLevelRule.name}> Rule.
|
|
79
|
+
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(s){return`An Alternation cannot have more than 256 alternatives:
|
|
80
|
+
<OR${s.alternation.idx}> inside <${s.topLevelRule.name}> Rule.
|
|
81
|
+
has ${s.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(s){const e=s.topLevelRule.name,t=s.leftRecursionPath.map(a=>a.name),n=`${e} --> ${t.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
|
|
82
|
+
rule: <${e}> can be invoked from itself (directly or indirectly)
|
|
83
|
+
without consuming any Tokens. The grammar path that causes this is:
|
|
84
|
+
${n}
|
|
85
|
+
To fix this refactor your grammar to remove the left recursion.
|
|
86
|
+
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(s){return"deprecated"},buildDuplicateRuleNameError(s){let e;return s.topLevelRule instanceof _e?e=s.topLevelRule.name:e=s.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${s.grammarName}<-`}};function za(s,e){const t=new Ha(s,e);return t.resolveRefs(),t.errors}class Ha extends Me{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{const n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:$.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Xa extends kt{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const i=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){this.ruleStack.length===0?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class Ya extends Xa{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const i=t.concat(n),a=new W({definition:i});this.possibleTokTypes=Je(a),this.found=!0}}}class Nt extends kt{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Ja extends Nt{walkMany(e,t,n){if(e.idx===this.occurrence){const i=t.concat(n)[0];this.result.isEndOfRule=i===void 0,i instanceof k&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,t,n)}}class Ps extends Nt{walkManySep(e,t,n){if(e.idx===this.occurrence){const i=t.concat(n)[0];this.result.isEndOfRule=i===void 0,i instanceof k&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,t,n)}}class qa extends Nt{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){const i=t.concat(n)[0];this.result.isEndOfRule=i===void 0,i instanceof k&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,t,n)}}class Ds extends Nt{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){const i=t.concat(n)[0];this.result.isEndOfRule=i===void 0,i instanceof k&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,t,n)}}function Yt(s,e,t=[]){t=[...t];let n=[],i=0;function a(o){return o.concat(s.slice(i+1))}function r(o){const l=Yt(a(o),e,t);return n.concat(l)}for(;t.length<e&&i<s.length;){const o=s[i];if(o instanceof W)return r(o.definition);if(o instanceof K)return r(o.definition);if(o instanceof G)n=r(o.definition);else if(o instanceof se){const l=o.definition.concat([new x({definition:o.definition})]);return r(l)}else if(o instanceof ne){const l=[new W({definition:o.definition}),new x({definition:[new k({terminalType:o.separator})].concat(o.definition)})];return r(l)}else if(o instanceof q){const l=o.definition.concat([new x({definition:[new k({terminalType:o.separator})].concat(o.definition)})]);n=r(l)}else if(o instanceof x){const l=o.definition.concat([new x({definition:o.definition})]);n=r(l)}else{if(o instanceof Z)return o.definition.forEach(l=>{l.definition.length!==0&&(n=r(l.definition))}),n;if(o instanceof k)t.push(o.terminalType);else throw Error("non exhaustive match")}i++}return n.push({partialPath:t,suffixDef:s.slice(i)}),n}function Za(s,e,t,n){const i="EXIT_NONE_TERMINAL",a=[i],r="EXIT_ALTERNATIVE";let o=!1;const l=e.length,h=l-n-1,d=[],c=[];for(c.push({idx:-1,def:s,ruleStack:[],occurrenceStack:[]});c.length!==0;){const f=c.pop();if(f===r){o&&c.at(-1).idx<=h&&c.pop();continue}const p=f.def,A=f.idx,R=f.ruleStack,L=f.occurrenceStack;if(p.length===0)continue;const g=p[0];if(g===i){const T={idx:A,def:p.slice(1),ruleStack:R.slice(0,-1),occurrenceStack:L.slice(0,-1)};c.push(T)}else if(g instanceof k)if(A<l-1){const T=A+1,m=e[T];if(t(m,g.terminalType)){const E={idx:T,def:p.slice(1),ruleStack:R,occurrenceStack:L};c.push(E)}}else if(A===l-1)d.push({nextTokenType:g.terminalType,nextTokenOccurrence:g.idx,ruleStack:R,occurrenceStack:L}),o=!0;else throw Error("non exhaustive match");else if(g instanceof K){const T=[...R];T.push(g.nonTerminalName);const m=[...L];m.push(g.idx);const E={idx:A,def:g.definition.concat(a,p.slice(1)),ruleStack:T,occurrenceStack:m};c.push(E)}else if(g instanceof G){const T={idx:A,def:p.slice(1),ruleStack:R,occurrenceStack:L};c.push(T),c.push(r);const m={idx:A,def:g.definition.concat(p.slice(1)),ruleStack:R,occurrenceStack:L};c.push(m)}else if(g instanceof se){const T=new x({definition:g.definition,idx:g.idx}),m=g.definition.concat([T],p.slice(1)),E={idx:A,def:m,ruleStack:R,occurrenceStack:L};c.push(E)}else if(g instanceof ne){const T=new k({terminalType:g.separator}),m=new x({definition:[T].concat(g.definition),idx:g.idx}),E=g.definition.concat([m],p.slice(1)),v={idx:A,def:E,ruleStack:R,occurrenceStack:L};c.push(v)}else if(g instanceof q){const T={idx:A,def:p.slice(1),ruleStack:R,occurrenceStack:L};c.push(T),c.push(r);const m=new k({terminalType:g.separator}),E=new x({definition:[m].concat(g.definition),idx:g.idx}),v=g.definition.concat([E],p.slice(1)),Y={idx:A,def:v,ruleStack:R,occurrenceStack:L};c.push(Y)}else if(g instanceof x){const T={idx:A,def:p.slice(1),ruleStack:R,occurrenceStack:L};c.push(T),c.push(r);const m=new x({definition:g.definition,idx:g.idx}),E=g.definition.concat([m],p.slice(1)),v={idx:A,def:E,ruleStack:R,occurrenceStack:L};c.push(v)}else if(g instanceof Z)for(let T=g.definition.length-1;T>=0;T--){const m=g.definition[T],E={idx:A,def:m.definition.concat(p.slice(1)),ruleStack:R,occurrenceStack:L};c.push(E),c.push(r)}else if(g instanceof W)c.push({idx:A,def:g.definition.concat(p.slice(1)),ruleStack:R,occurrenceStack:L});else if(g instanceof _e)c.push(Qa(g,A,R,L));else throw Error("non exhaustive match")}return d}function Qa(s,e,t,n){const i=[...t];i.push(s.name);const a=[...n];return a.push(1),{idx:e,def:s.definition,ruleStack:i,occurrenceStack:a}}var C;(function(s){s[s.OPTION=0]="OPTION",s[s.REPETITION=1]="REPETITION",s[s.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",s[s.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",s[s.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",s[s.ALTERNATION=5]="ALTERNATION"})(C||(C={}));function En(s){if(s instanceof G||s==="Option")return C.OPTION;if(s instanceof x||s==="Repetition")return C.REPETITION;if(s instanceof se||s==="RepetitionMandatory")return C.REPETITION_MANDATORY;if(s instanceof ne||s==="RepetitionMandatoryWithSeparator")return C.REPETITION_MANDATORY_WITH_SEPARATOR;if(s instanceof q||s==="RepetitionWithSeparator")return C.REPETITION_WITH_SEPARATOR;if(s instanceof Z||s==="Alternation")return C.ALTERNATION;throw Error("non exhaustive match")}function er(s,e,t,n,i,a){const r=hs(s,e,t),o=An(r)?yt:Ze;return a(r,n,o,i)}function tr(s,e,t,n,i,a){const r=us(s,e,i,t),o=An(r)?yt:Ze;return a(r[0],o,n)}function sr(s,e,t,n){const i=s.length,a=s.every(r=>r.every(o=>o.length===1));if(e)return function(r){const o=r.map(l=>l.GATE);for(let l=0;l<i;l++){const h=s[l],d=h.length,c=o[l];if(!(c!==void 0&&c.call(this)===!1))e:for(let f=0;f<d;f++){const p=h[f],A=p.length;for(let R=0;R<A;R++){const L=this.LA_FAST(R+1);if(t(L,p[R])===!1)continue e}return l}}};if(a&&!n){const o=s.map(l=>l.flat()).reduce((l,h,d)=>(h.forEach(c=>{c.tokenTypeIdx in l||(l[c.tokenTypeIdx]=d),c.categoryMatches.forEach(f=>{Object.hasOwn(l,f)||(l[f]=d)})}),l),{});return function(){const l=this.LA_FAST(1);return o[l.tokenTypeIdx]}}else return function(){for(let r=0;r<i;r++){const o=s[r],l=o.length;e:for(let h=0;h<l;h++){const d=o[h],c=d.length;for(let f=0;f<c;f++){const p=this.LA_FAST(f+1);if(t(p,d[f])===!1)continue e}return r}}}}function nr(s,e,t){const n=s.every(a=>a.length===1),i=s.length;if(n&&!t){const a=s.flat();if(a.length===1&&a[0].categoryMatches.length===0){const o=a[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===o}}else{const r=a.reduce((o,l,h)=>(o[l.tokenTypeIdx]=!0,l.categoryMatches.forEach(d=>{o[d]=!0}),o),[]);return function(){const o=this.LA_FAST(1);return r[o.tokenTypeIdx]===!0}}}else return function(){e:for(let a=0;a<i;a++){const r=s[a],o=r.length;for(let l=0;l<o;l++){const h=this.LA_FAST(l+1);if(e(h,r[l])===!1)continue e}return!0}return!1}}class ir extends kt{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,i){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(i),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,C.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,C.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,C.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,C.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,C.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}}class Tn extends Me{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,C.OPTION)}visitRepetition(e){this.checkIsTarget(e,C.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,C.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,C.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,C.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,C.ALTERNATION)}}function Fs(s){const e=new Array(s);for(let t=0;t<s;t++)e[t]=[];return e}function Ft(s){let e=[""];for(let t=0;t<s.length;t++){const n=s[t],i=[];for(let a=0;a<e.length;a++){const r=e[a];i.push(r+"_"+n.tokenTypeIdx);for(let o=0;o<n.categoryMatches.length;o++){const l="_"+n.categoryMatches[o];i.push(r+l)}}e=i}return e}function ar(s,e,t){for(let n=0;n<s.length;n++){if(n===t)continue;const i=s[n];for(let a=0;a<e.length;a++){const r=e[a];if(i[r]===!0)return!1}}return!0}function gn(s,e){const t=s.map(r=>Yt([r],1)),n=Fs(t.length),i=t.map(r=>{const o={};return r.forEach(l=>{Ft(l.partialPath).forEach(d=>{o[d]=!0})}),o});let a=t;for(let r=1;r<=e;r++){const o=a;a=Fs(o.length);for(let l=0;l<o.length;l++){const h=o[l];for(let d=0;d<h.length;d++){const c=h[d].partialPath,f=h[d].suffixDef,p=Ft(c);if(ar(i,p,l)||f.length===0||c.length===e){const R=n[l];if(Jt(R,c)===!1){R.push(c);for(let L=0;L<p.length;L++){const g=p[L];i[l][g]=!0}}}else{const R=Yt(f,r+1,c);a[l]=a[l].concat(R),R.forEach(L=>{Ft(L.partialPath).forEach(T=>{i[l][T]=!0})})}}}}return n}function hs(s,e,t,n){const i=new Tn(s,C.ALTERNATION,n);return e.accept(i),gn(i.result,t)}function us(s,e,t,n){const i=new Tn(s,t);e.accept(i);const a=i.result,o=new ir(e,s,t).startWalking(),l=new W({definition:a}),h=new W({definition:o});return gn([l,h],n)}function Jt(s,e){e:for(let t=0;t<s.length;t++){const n=s[t];if(n.length===e.length){for(let i=0;i<n.length;i++){const a=e[i],r=n[i];if((a===r||r.categoryMatchesMap[a.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function rr(s,e){return s.length<e.length&&s.every((t,n)=>{const i=e[n];return t===i||i.categoryMatchesMap[t.tokenTypeIdx]})}function An(s){return s.every(e=>e.every(t=>t.every(n=>n.categoryMatches.length===0)))}function or(s){return s.lookaheadStrategy.validate({rules:s.rules,tokenTypes:s.tokenTypes,grammarName:s.grammarName}).map(t=>Object.assign({type:$.CUSTOM_LOOKAHEAD_VALIDATION},t))}function lr(s,e,t,n){const i=s.flatMap(l=>cr(l,t)),a=yr(s,e,t),r=s.flatMap(l=>Tr(l,t)),o=s.flatMap(l=>dr(l,s,n,t));return i.concat(a,r,o)}function cr(s,e){const t=new ur;s.accept(t);const n=t.allProductions,i=Object.groupBy(n,hr),a=Object.fromEntries(Object.entries(i).filter(([o,l])=>l.length>1));return Object.values(a).map(o=>{const l=o[0],h=e.buildDuplicateFoundError(s,o),d=ee(l),c={message:h,type:$.DUPLICATE_PRODUCTIONS,ruleName:s.name,dslName:d,occurrence:l.idx},f=Sn(l);return f&&(c.parameter=f),c})}function hr(s){return`${ee(s)}_#_${s.idx}_#_${Sn(s)}`}function Sn(s){return s instanceof k?s.terminalType.name:s instanceof K?s.nonTerminalName:""}class ur extends Me{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}function dr(s,e,t,n){const i=[];if(e.reduce((r,o)=>o.name===s.name?r+1:r,0)>1){const r=n.buildDuplicateRuleNameError({topLevelRule:s,grammarName:t});i.push({message:r,type:$.DUPLICATE_RULE_NAME,ruleName:s.name})}return i}function fr(s,e,t){const n=[];let i;return e.includes(s)||(i=`Invalid rule override, rule: ->${s}<- cannot be overridden in the grammar: ->${t}<-as it is not defined in any of the super grammars `,n.push({message:i,type:$.INVALID_RULE_OVERRIDE,ruleName:s})),n}function yn(s,e,t,n=[]){const i=[],a=ct(e.definition);if(a.length===0)return[];{const r=s.name;a.includes(s)&&i.push({message:t.buildLeftRecursionError({topLevelRule:s,leftRecursionPath:n}),type:$.LEFT_RECURSION,ruleName:r});const l=n.concat([s]),d=a.filter(c=>!l.includes(c)).flatMap(c=>{const f=[...n];return f.push(c),yn(s,c,t,f)});return i.concat(d)}}function ct(s){let e=[];if(s.length===0)return e;const t=s[0];if(t instanceof K)e.push(t.referencedRule);else if(t instanceof W||t instanceof G||t instanceof se||t instanceof ne||t instanceof q||t instanceof x)e=e.concat(ct(t.definition));else if(t instanceof Z)e=t.definition.map(a=>ct(a.definition)).flat();else if(!(t instanceof k))throw Error("non exhaustive match");const n=Tt(t),i=s.length>1;if(n&&i){const a=s.slice(1);return e.concat(ct(a))}else return e}class ds extends Me{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function pr(s,e){const t=new ds;return s.accept(t),t.alternations.flatMap(a=>a.definition.slice(0,-1).flatMap((o,l)=>Za([o],[],Ze,1).length===0?[{message:e.buildEmptyAlternationError({topLevelRule:s,alternation:a,emptyChoiceIdx:l}),type:$.NONE_LAST_EMPTY_ALT,ruleName:s.name,occurrence:a.idx,alternative:l+1}]:[]))}function mr(s,e,t){const n=new ds;s.accept(n);let i=n.alternations;return i=i.filter(r=>r.ignoreAmbiguities!==!0),i.flatMap(r=>{const o=r.idx,l=r.maxLookahead||e,h=hs(o,s,l,r),d=Ar(h,r,s,t),c=Sr(h,r,s,t);return d.concat(c)})}class Er extends Me{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}function Tr(s,e){const t=new ds;return s.accept(t),t.alternations.flatMap(a=>a.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:s,alternation:a}),type:$.TOO_MANY_ALTS,ruleName:s.name,occurrence:a.idx}]:[])}function gr(s,e,t){const n=[];return s.forEach(i=>{const a=new Er;i.accept(a),a.allProductions.forEach(o=>{const l=En(o),h=o.maxLookahead||e,d=o.idx;if(us(d,i,l,h)[0].flat().length===0){const p=t.buildEmptyRepetitionError({topLevelRule:i,repetition:o});n.push({message:p,type:$.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),n}function Ar(s,e,t,n){const i=[];return s.reduce((o,l,h)=>(e.definition[h].ignoreAmbiguities===!0||l.forEach(d=>{const c=[h];s.forEach((f,p)=>{h!==p&&Jt(f,d)&&e.definition[p].ignoreAmbiguities!==!0&&c.push(p)}),c.length>1&&!Jt(i,d)&&(i.push(d),o.push({alts:c,path:d}))}),o),[]).map(o=>{const l=o.alts.map(d=>d+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:l,prefixPath:o.path}),type:$.AMBIGUOUS_ALTS,ruleName:t.name,occurrence:e.idx,alternatives:o.alts}})}function Sr(s,e,t,n){const i=s.reduce((r,o,l)=>{const h=o.map(d=>({idx:l,path:d}));return r.concat(h)},[]);return i.flatMap(r=>{if(e.definition[r.idx].ignoreAmbiguities===!0)return[];const l=r.idx,h=r.path;return i.filter(f=>e.definition[f.idx].ignoreAmbiguities!==!0&&f.idx<l&&rr(f.path,h)).map(f=>{const p=[f.idx+1,l+1],A=e.idx===0?"":e.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:p,prefixPath:f.path}),type:$.AMBIGUOUS_PREFIX_ALTS,ruleName:t.name,occurrence:A,alternatives:p}})})}function yr(s,e,t){const n=[],i=e.map(a=>a.name);return s.forEach(a=>{const r=a.name;if(i.includes(r)){const o=t.buildNamespaceConflictError(a);n.push({message:o,type:$.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:r})}}),n}function Rr(s){const e=Object.assign({errMsgProvider:Va},s),t={};return s.rules.forEach(n=>{t[n.name]=n}),za(t,e.errMsgProvider)}function Or(s){var e;const t=(e=s.errMsgProvider)!==null&&e!==void 0?e:Ee;return lr(s.rules,s.tokenTypes,t,s.grammarName)}const Rn="MismatchedTokenException",On="NoViableAltException",Ln="EarlyExitException",In="NotAllInputParsedException",kn=[Rn,On,Ln,In];Object.freeze(kn);function Rt(s){return kn.includes(s.name)}class Ct extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class Nn extends Ct{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Rn}}class Lr extends Ct{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=On}}class Ir extends Ct{constructor(e,t){super(e,t),this.name=In}}class kr extends Ct{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ln}}const Bt={},Cn="InRuleRecoveryException";class Nr extends Error{constructor(e){super(e),this.name=Cn}}class Cr{initRecoverable(e){this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:ce.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=br)}getTokenToInsert(e){const t=cs(e,"",-1,-1,-1,-1,-1,-1);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,i){const a=this.findReSyncTokenType(),r=this.exportLexerState(),o=[];let l=!1;const h=this.LA_FAST(1);let d=this.LA_FAST(1);const c=()=>{const f=this.LA(0),p=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:h,previous:f,ruleName:this.getCurrRuleFullName()}),A=new Nn(p,h,this.LA(0));A.resyncedTokens=o.slice(0,-1),this.SAVE_ERROR(A)};for(;!l;)if(this.tokenMatcher(d,i)){c();return}else if(n.call(this)){c(),e.apply(this,t);return}else this.tokenMatcher(d,a)?l=!0:(d=this.SKIP_TOKEN(),this.addToResyncTokens(d,o));this.importLexerState(r)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getNextPossibleTokenTypes(e){const t=e.ruleStack[0],i=this.getGAstProductions()[t];return new Ya(i,e).startWalking()}getFollowsForInRuleRecovery(e,t){const n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Nr("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||t.length===0)return!1;const n=this.LA_FAST(1);return t.find(a=>this.tokenMatcher(n,a))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){const t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){const e=this.flattenFollowSet();let t=this.LA_FAST(1),n=2;for(;;){const i=e.find(a=>pn(t,a));if(i!==void 0)return i;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Bt;const e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=new Array(n);for(let a=0;a<n;a++)a===0?i[a]=Bt:i[a]={ruleName:this.shortRuleNameToFullName(e[a]),idxInCallingRule:t[a],inRule:this.shortRuleNameToFullName(e[a-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map(t=>this.getFollowSetFromFollowKey(t)).flat()}getFollowSetFromFollowKey(e){if(e===Bt)return[le];const t=e.ruleName+e.idxInCallingRule+an+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,le)||t.push(e),t}reSyncTo(e){const t=[];let n=this.LA_FAST(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,n,i,a,r,o){}getCurrentGrammarPath(e,t){const n=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){const e=this.RULE_STACK_IDX+1,t=new Array(e);for(let n=0;n<e;n++)t[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return t}}function br(s,e,t,n,i,a,r){var o,l,h;const d=n|i,c=(o=(l=this.firstAfterRepMap)[h=this.currRuleShortName])!==null&&o!==void 0?o:l[h]=[];let f=c[d];if(f===void 0){const L=this.getCurrRuleFullName(),g=this.getGAstProductions()[L];f=new a(g,i).startWalking(),c[d]=f}let p=f.token,A=f.occurrence;const R=f.isEndOfRule;this.RULE_STACK_IDX===0&&R&&p===void 0&&(p=le,A=1),!(p===void 0||A===void 0)&&this.shouldInRepetitionRecoveryBeTried(p,A,r)&&this.tryInRepetitionRecovery(s,e,t,p)}const xe=8,bn=1<<xe,vn=2<<xe,qt=3<<xe,Zt=4<<xe,Qt=5<<xe,ht=6<<xe;class vr{constructor(e){var t;this.maxLookahead=(t=e==null?void 0:e.maxLookahead)!==null&&t!==void 0?t:ce.maxLookahead}validate(e){const t=this.validateNoLeftRecursion(e.rules);if(t.length===0){const n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),a=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...i,...a]}return t}validateNoLeftRecursion(e){return e.flatMap(t=>yn(t,t,Ee))}validateEmptyOrAlternatives(e){return e.flatMap(t=>pr(t,Ee))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(n=>mr(n,t,Ee))}validateSomeNonEmptyLookaheadPath(e,t){return gr(e,t,Ee)}buildLookaheadForAlternation(e){return er(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,sr)}buildLookaheadForOptional(e){return tr(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,En(e.prodType),nr)}}class _r{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ce.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:ce.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new vr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach(t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{const{alternation:n,repetition:i,option:a,repetitionMandatory:r,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:l}=xr(t);n.forEach(h=>{const d=h.idx===0?"":h.idx;this.TRACE_INIT(`${ee(h)}${d}`,()=>{const c=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:h.idx,rule:t,maxLookahead:h.maxLookahead||this.maxLookahead,hasPredicates:h.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[t.name],bn|h.idx,c)})}),i.forEach(h=>{this.computeLookaheadFunc(t,h.idx,qt,"Repetition",h.maxLookahead,ee(h))}),a.forEach(h=>{this.computeLookaheadFunc(t,h.idx,vn,"Option",h.maxLookahead,ee(h))}),r.forEach(h=>{this.computeLookaheadFunc(t,h.idx,Zt,"RepetitionMandatory",h.maxLookahead,ee(h))}),o.forEach(h=>{this.computeLookaheadFunc(t,h.idx,ht,"RepetitionMandatoryWithSeparator",h.maxLookahead,ee(h))}),l.forEach(h=>{this.computeLookaheadFunc(t,h.idx,Qt,"RepetitionWithSeparator",h.maxLookahead,ee(h))})})})}computeLookaheadFunc(e,t,n,i,a,r){this.TRACE_INIT(`${r}${t===0?"":t}`,()=>{const o=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:a||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|t,o)})}setLaFuncCache(e,t,n){let i=this.lookAheadFuncsCache[e];i===void 0&&(i=[],this.lookAheadFuncsCache[e]=i),i[t]=n}}class Mr extends Me{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}}const it=new Mr;function xr(s){it.reset(),s.accept(it);const e=it.dslMethods;return it.reset(),e}function Bs(s,e){s.startOffset===-1?(s.startOffset=e.startOffset,s.endOffset=e.endOffset):s.endOffset<e.endOffset&&(s.endOffset=e.endOffset)}function $s(s,e){s.startOffset===-1?(s.startOffset=e.startOffset,s.startColumn=e.startColumn,s.startLine=e.startLine,s.endOffset=e.endOffset,s.endColumn=e.endColumn,s.endLine=e.endLine):s.endOffset<e.endOffset&&(s.endOffset=e.endOffset,s.endColumn=e.endColumn,s.endLine=e.endLine)}function wr(s,e,t){s.children[t]===void 0?s.children[t]=[e]:s.children[t].push(e)}function Ur(s,e,t){s.children[e]===void 0?s.children[e]=[t]:s.children[e].push(t)}const Pr="name";function _n(s,e){Object.defineProperty(s,Pr,{enumerable:!1,configurable:!0,writable:!1,value:e})}function Dr(s,e){const t=Object.keys(s),n=t.length;for(let i=0;i<n;i++){const a=t[i],r=s[a],o=r.length;for(let l=0;l<o;l++){const h=r[l];h.tokenTypeIdx===void 0&&this[h.name](h.children,e)}}}function Fr(s,e){const t=function(){};_n(t,s+"BaseSemantics");const n={visit:function(i,a){if(Array.isArray(i)&&(i=i[0]),i!==void 0)return this[i.name](i.children,a)},validateVisitor:function(){const i=$r(this,e);if(i.length!==0){const a=i.map(r=>r.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
|
|
87
|
+
${a.join(`
|
|
88
|
+
|
|
89
|
+
`).replace(/\n/g,`
|
|
90
|
+
`)}`)}}};return t.prototype=n,t.prototype.constructor=t,t._RULE_NAMES=e,t}function Br(s,e,t){const n=function(){};_n(n,s+"BaseSemanticsWithDefaults");const i=Object.create(t.prototype);return e.forEach(a=>{i[a]=Dr}),n.prototype=i,n.prototype.constructor=n,n}var es;(function(s){s[s.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",s[s.MISSING_METHOD=1]="MISSING_METHOD"})(es||(es={}));function $r(s,e){return jr(s,e)}function jr(s,e){return e.filter(i=>typeof s[i]!="function").map(i=>({msg:`Missing visitor method: <${i}> on ${s.constructor.name} CST Visitor.`,type:es.MISSING_METHOD,methodName:i})).filter(Boolean)}class Gr{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,"nodeLocationTracking")?e.nodeLocationTracking:ce.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=$s,this.setNodeLocationFromNode=$s,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Bs,this.setNodeLocationFromNode=Bs,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(e){const t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(e){const t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){const t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=-1,n.startLine=-1,n.startColumn=-1)}cstPostRuleOnlyOffset(e){const t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=-1}cstPostTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];wr(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){const n=this.CST_STACK[this.CST_STACK.length-1];Ur(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}get currCSTNode(){const e=this;return e.CST_STACK[e.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){const e=Fr(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){const e=Br(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class Wr{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):ve}LA_FAST(e){const t=this.currIdx+e;return this.tokVector[t]}LA(e){const t=this.currIdx+e;return t<0||this.tokVectorLength<=t?ve:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class Kr{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=Lt){if(this.definedRulesNames.includes(e)){const r={message:Ee.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:$.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(r)}this.definedRulesNames.push(e);const i=this.defineRule(e,t,n);return this[e]=i,i}OVERRIDE_RULE(e,t,n=Lt){const i=fr(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);const a=this.defineRule(e,t,n);return this[e]=a,a}BACKTRACK(e,t){var n;const i=(n=e.coreRule)!==null&&n!==void 0?n:e;return function(){this.isBackTrackingStack.push(1);const a=this.saveRecogState();try{return i.apply(this,t),!0}catch(r){if(Rt(r))return!1;throw r}finally{this.reloadRecogState(a),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return zi(Object.values(this.gastProductionsCache))}}class Vr{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=yt,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
|
|
91
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
|
|
92
|
+
For Further details.`);if(Array.isArray(e)){if(e.length===0)throw Error(`A Token Vocabulary cannot be empty.
|
|
93
|
+
Note that the first argument for the parser constructor
|
|
94
|
+
is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
|
|
95
|
+
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
|
|
96
|
+
For Further details.`)}if(Array.isArray(e))this.tokensMap=e.reduce((a,r)=>(a[r.name]=r,a),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(ja)){const a=Object.values(e.modes).flat(),r=[...new Set(a)];this.tokensMap=r.reduce((o,l)=>(o[l.name]=l,o),{})}else if(typeof e=="object"&&e!==null)this.tokensMap=Object.assign({},e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=le;const i=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every(a=>{var r;return((r=a.categoryMatches)===null||r===void 0?void 0:r.length)==0});this.tokenMatcher=i?yt:Ze,Qe(Object.values(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
|
|
97
|
+
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const i=Object.hasOwn(n,"resyncEnabled")?n.resyncEnabled:Lt.resyncEnabled,a=Object.hasOwn(n,"recoveryValueFunc")?n.recoveryValueFunc:Lt.recoveryValueFunc,r=this.ruleShortNameIdx++;this.shortRuleNameToFull[r]=e,this.fullRuleNameToShort[e]=r;let o;return this.outputCst===!0?o=function(...c){try{this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,c);const f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,i,a)}finally{this.ruleFinallyStateUpdate()}}:o=function(...c){try{return this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,c)}catch(f){return this.invokeRuleCatch(f,i,a)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...c){this.onBeforeParse(e);try{return o.apply(this,c)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:o})}invokeRuleCatch(e,t,n){const i=this.RULE_STACK_IDX===0,a=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Rt(e)){const r=e;if(a){const o=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(o))if(r.resyncedTokens=this.reSyncTo(o),this.outputCst){const l=this.CST_STACK[this.CST_STACK.length-1];return l.recoveredNode=!0,l}else return n(e);else{if(this.outputCst){const l=this.CST_STACK[this.CST_STACK.length-1];l.recoveredNode=!0,r.partialCstResult=l}throw r}}else{if(i)return this.moveToTerminatedState(),n(e);throw r}}else throw e}optionInternal(e,t){const n=vn|t;return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let i=this.currRuleLookaheadFuncs[n],a;if(typeof e!="function"){a=e.DEF;const r=e.GATE;if(r!==void 0){const o=i;i=()=>r.call(this)&&o.call(this)}}else a=e;if(i.call(this)===!0)return a.call(this)}atLeastOneInternal(e,t){const n=Zt|e;return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let i=this.currRuleLookaheadFuncs[n],a;if(typeof t!="function"){a=t.DEF;const r=t.GATE;if(r!==void 0){const o=i;i=()=>r.call(this)&&o.call(this)}}else a=t;if(i.call(this)===!0){let r=this.doSingleRepetition(a);for(;i.call(this)===!0&&r===!0;)r=this.doSingleRepetition(a)}else throw this.raiseEarlyExitException(e,C.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],i,Zt,e,qa)}atLeastOneSepFirstInternal(e,t){const n=ht|e;this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){const i=t.DEF,a=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA_FAST(1),a);for(;this.tokenMatcher(this.LA_FAST(1),a)===!0;)this.CONSUME(a),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,a,o,i,Ds],o,ht,e,Ds)}else throw this.raiseEarlyExitException(e,C.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){const n=qt|e;return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let i=this.currRuleLookaheadFuncs[n],a;if(typeof t!="function"){a=t.DEF;const o=t.GATE;if(o!==void 0){const l=i;i=()=>o.call(this)&&l.call(this)}}else a=t;let r=!0;for(;i.call(this)===!0&&r===!0;)r=this.doSingleRepetition(a);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],i,qt,e,Ja,r)}manySepFirstInternal(e,t){const n=Qt|e;this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){const i=t.DEF,a=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){i.call(this);const o=()=>this.tokenMatcher(this.LA_FAST(1),a);for(;this.tokenMatcher(this.LA_FAST(1),a)===!0;)this.CONSUME(a),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,a,o,i,Ps],o,Qt,e,Ps)}}repetitionSepSecondInternal(e,t,n,i,a){for(;n();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,i,a],n,ht,e,a)}doSingleRepetition(e){const t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){const n=bn|t,i=Array.isArray(e)?e:e.DEF,r=this.currRuleLookaheadFuncs[n].call(this,i);if(r!==void 0)return i[r].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]),this.cstFinallyStateUpdate()}subruleInternal(e,t,n){let i;try{const a=n!==void 0?n.ARGS:void 0;return this.subruleIdx=t,i=e.coreRule.apply(this,a),this.cstPostNonTerminal(i,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),i}catch(a){throw this.subruleInternalError(a,n,e.ruleName)}}subruleInternalError(e,t,n){throw Rt(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let i;try{const a=this.LA_FAST(1);this.tokenMatcher(a,e)===!0?(this.consumeToken(),i=a):this.consumeInternalError(e,a,n)}catch(a){i=this.consumeInternalRecovery(e,t,a)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,i),i}consumeInternalError(e,t,n){let i;const a=this.LA(0);throw n!==void 0&&n.ERR_MSG?i=n.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:a,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Nn(i,t,a))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){const i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(a){throw a.name===Cn?n:a}}else throw n}saveRecogState(){const e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);const t=e.RULE_STACK;for(let n=0;n<t.length;n++)this.RULE_STACK[n]=t[n];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName])}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){const e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),le)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t<this.maxLookahead+1;t++)this.tokVector.push(ve)}onAfterParse(e){if(this.isAtEndOfInput()===!1){const t=this.LA(1),n=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Ir(n,t))}for(;this.tokVector.at(-1)===ve;)this.tokVector.pop()}}class zr{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:ce.errorMessageProvider}SAVE_ERROR(e){if(Rt(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){const i=this.getCurrRuleFullName(),a=this.getGAstProductions()[i],o=us(e,a,t,this.maxLookahead)[0],l=[];for(let d=1;d<=this.maxLookahead;d++)l.push(this.LA(d));const h=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:o,actual:l,previous:this.LA(0),customUserDescription:n,ruleName:i});throw this.SAVE_ERROR(new kr(h,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){const n=this.getCurrRuleFullName(),i=this.getGAstProductions()[n],a=hs(e,i,this.maxLookahead),r=[];for(let h=1;h<=this.maxLookahead;h++)r.push(this.LA(h));const o=this.LA(0),l=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:a,actual:r,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Lr(l,this.LA(1),o))}}const bt={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(bt);const js=!0,Gs=255,Mn=S({name:"RECORDING_PHASE_TOKEN",pattern:F.NA});Qe([Mn]);const xn=cs(Mn,`This IToken indicates the Parser is in Recording Phase
|
|
98
|
+
See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(xn);const Hr={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 Xr{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const t=e>0?e:"";this[`CONSUME${t}`]=function(n,i){return this.consumeInternalRecord(n,e,i)},this[`SUBRULE${t}`]=function(n,i){return this.subruleInternalRecord(n,e,i)},this[`OPTION${t}`]=function(n){return this.optionInternalRecord(n,e)},this[`OR${t}`]=function(n){return this.orInternalRecord(n,e)},this[`MANY${t}`]=function(n){this.manyInternalRecord(e,n)},this[`MANY_SEP${t}`]=function(n){this.manySepFirstInternalRecord(e,n)},this[`AT_LEAST_ONE${t}`]=function(n){this.atLeastOneInternalRecord(e,n)},this[`AT_LEAST_ONE_SEP${t}`]=function(n){this.atLeastOneSepFirstInternalRecord(e,n)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let t=0;t<10;t++){const n=t>0?t:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return ve}topLevelRuleRecord(e,t){try{const n=new _e({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
|
|
100
|
+
This error was thrown during the "grammar recording phase" For more info see:
|
|
101
|
+
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(e,t){return Be.call(this,G,e,t)}atLeastOneInternalRecord(e,t){Be.call(this,se,t,e)}atLeastOneSepFirstInternalRecord(e,t){Be.call(this,ne,t,e,js)}manyInternalRecord(e,t){Be.call(this,x,t,e)}manySepFirstInternalRecord(e,t){Be.call(this,q,t,e,js)}orInternalRecord(e,t){return Yr.call(this,e,t)}subruleInternalRecord(e,t,n){if(Ot(t),!e||!Object.hasOwn(e,"ruleName")){const o=new Error(`<SUBRULE${Ws(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|
102
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}const i=this.recordingProdStack.at(-1),a=e.ruleName,r=new K({idx:t,nonTerminalName:a,label:n==null?void 0:n.LABEL,referencedRule:void 0});return i.definition.push(r),this.outputCst?Hr:bt}consumeInternalRecord(e,t,n){if(Ot(t),!dn(e)){const r=new Error(`<CONSUME${Ws(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|
103
|
+
inside top level rule: <${this.recordingProdStack[0].name}>`);throw r.KNOWN_RECORDER_ERROR=!0,r}const i=this.recordingProdStack.at(-1),a=new k({idx:t,terminalType:e,label:n==null?void 0:n.LABEL});return i.definition.push(a),xn}}function Be(s,e,t,n=!1){Ot(t);const i=this.recordingProdStack.at(-1),a=typeof e=="function"?e:e.DEF,r=new s({definition:[],idx:t});return n&&(r.separator=e.SEP),Object.hasOwn(e,"MAX_LOOKAHEAD")&&(r.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(r),a.call(this),i.definition.push(r),this.recordingProdStack.pop(),bt}function Yr(s,e){Ot(e);const t=this.recordingProdStack.at(-1),n=Array.isArray(s)===!1,i=n===!1?s:s.DEF,a=new Z({definition:[],idx:e,ignoreAmbiguities:n&&s.IGNORE_AMBIGUITIES===!0});Object.hasOwn(s,"MAX_LOOKAHEAD")&&(a.maxLookahead=s.MAX_LOOKAHEAD);const r=i.some(o=>typeof o.GATE=="function");return a.hasPredicates=r,t.definition.push(a),i.forEach(o=>{const l=new W({definition:[]});a.definition.push(l),Object.hasOwn(o,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:Object.hasOwn(o,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),o.ALT.call(this),this.recordingProdStack.pop()}),bt}function Ws(s){return s===0?"":`${s}`}function Ot(s){if(s<0||s>Gs){const e=new Error(`Invalid DSL Method idx value: <${s}>
|
|
104
|
+
Idx value must be a none negative value smaller than ${Gs+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}class Jr{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){const t=e.traceInitPerf,n=typeof t=="number";this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ce.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);const{time:i,value:a}=sn(t),r=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&r(`${n}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,a}else return t()}}function qr(s,e){e.forEach(t=>{const n=t.prototype;Object.getOwnPropertyNames(n).forEach(i=>{if(i==="constructor")return;const a=Object.getOwnPropertyDescriptor(n,i);a&&(a.get||a.set)?Object.defineProperty(s.prototype,i,a):s.prototype[i]=t.prototype[i]})})}const ve=cs(le,"",-1,-1,-1,-1,-1,-1);Object.freeze(ve);const ce=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:mn,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Lt=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var $;(function(s){s[s.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",s[s.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",s[s.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",s[s.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",s[s.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",s[s.LEFT_RECURSION=5]="LEFT_RECURSION",s[s.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",s[s.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",s[s.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",s[s.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",s[s.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",s[s.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",s[s.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",s[s.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})($||($={}));class et{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const t=this.className;this.TRACE_INIT("toFastProps",()=>{nn(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach(i=>{const r=this[i].originalGrammarAction;let o;this.TRACE_INIT(`${i} Rule`,()=>{o=this.topLevelRuleRecord(i,r)}),this.gastProductionsCache[i]=o})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Rr({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(n.length===0&&this.skipValidations===!1){const i=Or({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:Ee,grammarName:t}),a=or({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(i,a)}}),this.definitionErrors.length===0&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const i=Qi(Object.values(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,a;(a=(i=this.lookaheadStrategy).initialize)===null||a===void 0||a.call(i,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!et.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw e=this.definitionErrors.map(i=>i.message),new Error(`Parser Definition Errors detected:
|
|
105
|
+
${e.join(`
|
|
106
|
+
-------------------------------
|
|
107
|
+
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initGastRecorder(t),n.initPerformanceTracer(t),Object.hasOwn(t,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
108
|
+
Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
|
|
109
|
+
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
|
|
110
|
+
For further details.`);this.skipValidations=Object.hasOwn(t,"skipValidations")?t.skipValidations:ce.skipValidations}}et.DEFER_DEFINITION_ERRORS_HANDLING=!1;qr(et,[Cr,_r,Gr,Wr,Vr,Kr,zr,Xr,Jr]);class Zr extends et{constructor(e,t=ce){const n=Object.assign({},t);n.outputCst=!0,super(e,n)}}var Re=u(s=>s!==void 0&&s>=0,"isKnownLocation");function wn(s,e){const t=s.lexer.tokenize(e);if(t.errors.length>0){const i=t.errors[0],a=Re(i.offset)?i.offset:e.length,r=a+(Re(i.length)?i.length:0);throw new Error(`Error lexing ${s.diagramType} diagram: ${i.message} at line ${i.line??1}, column ${i.column??1} [${a},${r})`)}s.parser.input=t.tokens;const n=s.entry();if(s.parser.errors.length>0)throw new Error(`Error parsing ${s.diagramType} diagram: ${s.parser.errors[0].message}`);s.visit(n)}u(wn,"runChevrotainParse");var I={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Qr="LR",eo=Di.usecase,fs=u(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Qr,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(eo)}),"createModel"),to=u(s=>{if(!(s.actors instanceof Map)||!(s.useCases instanceof Map)||!(s.systemBoundaries instanceof Map)||!Array.isArray(s.relationships)||!(s.notes instanceof Map)||!(s.jsonNodes instanceof Map)||!(s.classDefs instanceof Map)||!(s.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(s.direction)||!Number.isSafeInteger(s.relationshipCounter)||s.relationshipCounter<0||!Number.isSafeInteger(s.noteCounter)||s.noteCounter<0||typeof s.accTitle!="string"||typeof s.accDescription!="string"||!s.config)throw new Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),O=fs(),so=u(()=>structuredClone(O.config),"getConfig"),no=u(()=>O.ast,"getAST"),io=u(s=>{const e=structuredClone(s);to(e);const t=Qs(),n=Zs();try{Gt(e.accTitle),jt(e.accDescription),O=e}catch(i){throw Gt(t),jt(n),i}},"commit"),ao=u(()=>{O=fs(),Pi()},"clear"),ro=u(()=>O.actors,"getActors"),oo=u(s=>O.actors.get(s),"getActor"),lo=u(()=>O.useCases,"getUseCases"),co=u(s=>O.useCases.get(s),"getUseCase"),ho=u(()=>O.systemBoundaries,"getSystemBoundaries"),uo=u(s=>O.systemBoundaries.get(s),"getSystemBoundary"),fo=u(()=>O.relationships,"getRelationships"),po=u(()=>O.notes,"getNotes"),mo=u(s=>O.notes.get(s),"getNote"),Eo=u(()=>O.jsonNodes,"getJsonNodes"),To=u(s=>O.jsonNodes.get(s),"getJsonNode"),go=u(()=>O.classDefs,"getClassDefs"),Ao=u(s=>O.classDefs.get(s),"getClassDef"),Un=u(()=>O.direction,"getDirection"),pe=u(s=>{const e=new Map;for(const t of["default",...s]){const n=O.classDefs.get(t);if(n)for(const i of n.styles){const a=i.trim(),r=a.indexOf(":"),o=(r===-1?a:a.slice(0,r)).trim();o&&e.set(o,a)}}return[...e.values()]},"getCompiledStyles"),So=u(s=>s.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Ks=u(s=>typeof s=="string"?s:s===null?"null":String(s),"displayJsonScalar"),yo=u((s,e,t=n=>n)=>{const n=[],i=u((r,o,l)=>{n.push({key:t(r),accessibleKey:t(o),value:t(l)})},"append"),a=u((r,o,l)=>{if(Array.isArray(r)){if(r.length===0){i(o,o,"[]");return}if(r.every(d=>d===null||["string","number","boolean"].includes(typeof d))){for(const[d,c]of r.entries())i(d===0?o:"",o,Ks(c));return}for(const[d,c]of r.entries())a(c,`${o}[${d}]`,`${l}/${d}`);return}if(r!==null&&typeof r=="object"){const h=r,d=e[l]??Object.keys(h);if(d.length===0){i(o,o,"{}");return}for(const c of d){const f=o?`${o}.${c}`:c;a(h[c],f,`${l}/${So(c)}`)}return}i(o,o,Ks(r))},"visit");return a(s,"",""),n},"flattenJsonRows"),Ro=u(s=>{switch(s.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),Oo=u(s=>s.shape==="ellipse"?s.business?"usecaseBusiness":"usecaseEllipse":s.shape,"useCaseShape"),Lo=u(s=>{switch(s){case I.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case I.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case I.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case I.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case I.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case I.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case I.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),Io=u(s=>{switch(s.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:s.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...Lo(s.arrowType),pattern:"solid",...s.label?{label:s.label}:{},...s.labelType?{labelType:s.labelType}:{}}}},"relationshipVisuals"),ko=u(s=>s.animate||s.animation?[`edge-animation-${s.animation??"fast"}`]:[],"animationClasses"),$e=u((...s)=>s.filter(e=>!!e).join(" "),"classNames"),No=u(()=>{var l,h,d;const s=en(),e={...O.config,...s.usecase},t=u(c=>Ui(c,s),"sanitize"),n=u(c=>{var f,p,A,R;return t(((f=O.actors.get(c))==null?void 0:f.label)??((p=O.useCases.get(c))==null?void 0:p.label)??((A=O.jsonNodes.get(c))==null?void 0:A.id)??((R=O.notes.get(c))==null?void 0:R.label)??c)},"endpointLabel"),i=[],a=[];let r=0,o=0;for(const c of O.actors.values())i.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:Ro(c),isGroup:!1,padding:10,look:s.look,colorIndex:r++,cssClasses:$e("default","usecase-actor",`usecase-actor-${c.type}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:pe(c.classes),actorType:c.type,business:c.business,...c.icon?{icon:c.icon}:{},...c.stereotype?{stereotype:t(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(const c of O.useCases.values())i.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:Oo(c),isGroup:!1,padding:c.shape==="ellipse"?20:10,look:s.look,colorIndex:r++,cssClasses:$e("default","usecase-element",`usecase-${c.shape}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:pe(c.classes),business:c.business,...c.stereotype?{stereotype:t(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(const c of O.notes.values())i.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:"note",isGroup:!1,padding:10,look:s.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:pe([]),noteTarget:c.target,noteTargetLabel:t(((l=O.actors.get(c.target))==null?void 0:l.label)??((h=O.useCases.get(c.target))==null?void 0:h.label)??((d=O.jsonNodes.get(c.target))==null?void 0:d.id)??c.target)});for(const c of O.jsonNodes.values())i.push({id:c.id,label:t(c.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:s.look,cssClasses:$e("default","usecase-json-table",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:pe(c.classes),jsonRows:yo(c.value,c.propertyOrder,t)});for(const c of O.systemBoundaries.values())i.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:s.look,colorIndex:o++,cssClasses:$e("default","system-boundary",`system-boundary-${c.type}`,...c.classes),cssStyles:[...c.styles],cssCompiledStyles:pe(c.classes),boundaryType:c.type});for(const c of O.relationships){const{label:f,...p}=Io(c);a.push({id:c.id,start:c.source,end:c.target,source:c.source,target:c.target,sourceLabel:n(c.source),targetLabel:n(c.target),type:"edge",relationshipType:c.type,internal:!1,...p,...f!==void 0?{label:t(f)}:{},labelpos:"c",classes:$e("default","relationship",`relationship-${c.type}`,...c.classes,...ko(c)),style:[...c.styles],cssCompiledStyles:pe(c.classes),animate:c.animate,...c.animation?{animation:c.animation}:{},look:s.look,thickness:"normal",minlen:c.minlen,isUserDefinedId:c.explicitId})}for(const c of O.notes.values())a.push({id:`${c.id}-edge`,start:c.id,end:c.target,source:c.id,target:c.target,type:"edge",relationshipType:"note",sourceLabel:n(c.id),targetLabel:n(c.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:pe([]),animate:!1,look:s.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(const c of i)c.wrappingWidth??(c.wrappingWidth=e.wrappingWidth),!c.isGroup&&!c.shape.startsWith("usecaseActor")&&(c.minWidth??(c.minWidth=e.minNodeWidth)),(c.shape==="usecaseEllipse"||c.shape==="usecaseBusiness")&&(c.spreadPorts=!0);return{nodes:i,edges:a,config:s,type:"usecase",layoutAlgorithm:"dagre",direction:Un(),nodeSpacing:e.nodeSpacing,rankSpacing:e.rankSpacing,actorFontSize:e.actorFontSize,actorFontFamily:e.actorFontFamily,actorFontWeight:e.actorFontWeight,usecaseFontSize:e.usecaseFontSize,usecaseFontFamily:e.usecaseFontFamily,usecaseFontWeight:e.usecaseFontWeight,diagramPadding:e.diagramPadding,useMaxWidth:e.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),It={getConfig:so,createModel:fs,commit:io,getAST:no,clear:ao,setDiagramTitle:vi,getDiagramTitle:bi,setAccTitle:Gt,getAccTitle:Qs,setAccDescription:jt,getAccDescription:Zs,getActors:ro,getActor:oo,getUseCases:lo,getUseCase:co,getSystemBoundaries:ho,getSystemBoundary:uo,getRelationships:fo,getNotes:po,getNote:mo,getJsonNodes:Eo,getJsonNode:To,getClassDefs:go,getClassDef:Ao,getDirection:Un,getData:No};function ge(s,e,t){const n=[t];return n.index=e,n.input=s,n}u(ge,"customMatch");var Co=u((s,e)=>{if(s[e]!=='"'||s[e+1]!=="`")return null;for(let t=e+2;t<s.length-1;t++)if(s[t]==="`"&&s[t+1]==='"')return ge(s,e,s.slice(e,t+2));return null},"matchMarkdownString"),bo=u((s,e)=>{if(s[e]!=="%"||s[e+1]!=="%")return null;for(let n=e-1;n>=0;n--){const i=s[n];if(i===`
|
|
111
|
+
`||i==="\r")break;if(i!==" "&&i!==" ")return null}let t=e+2;for(;t<s.length&&s[t]!==`
|
|
112
|
+
`&&s[t]!=="\r";)t++;return ge(s,e,s.slice(e,t))},"matchComment"),Pn=u((s,e)=>{for(let t=e-1;t>=0;t--){const n=s[t];if(n===`
|
|
113
|
+
`||n==="\r")return!0;if(n!==" "&&n!==" ")return!1}return!0},"isIndentedLineStart"),Dn=u((s,e,t)=>{if(!Pn(s,e))return null;const n=t.exec(s.slice(e));return n?ge(s,e,n[0]):null},"matchAccessibilityLine"),vo=u((s,e)=>{if(!Pn(s,e))return null;const t=/^accDescr[\t ]*{/.exec(s.slice(e));if(!t)return null;const n=s.indexOf("}",e+t[0].length);return n===-1?null:ge(s,e,s.slice(e,n+1))},"matchAccDescrBlock"),_o=u((s,e)=>{if(s[e]!=="{")return null;let t=0,n=!1,i=!1;for(let a=e;a<s.length;a++){const r=s[a];if(n){i?i=!1:r==="\\"?i=!0:r==='"'&&(n=!1);continue}if(r==='"')n=!0;else if(r==="{")t++;else if(r==="}"&&--t===0)return ge(s,e,s.slice(e,a+1))}return null},"matchJsonObject"),Mo=u((s,e)=>{const t=s.indexOf(">>",e);if(t===-1||/[\n\r]/.test(s.slice(e,t)))return null;const n=s.slice(e,t);return n.trim()?ge(s,e,n):null},"matchStereotypeText"),w=S({name:"LABEL_TEXT",pattern:F.NA}),Oe=S({name:"WORD",pattern:F.NA,categories:w}),ps=S({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:w}),N=S({name:"IDENTIFIER",pattern:/\w+/,longer_alt:ps,categories:Oe}),xo=S({name:"HWS",pattern:/[\t ]+/,group:F.SKIPPED}),oe=S({name:"MARKDOWN_STRING",pattern:Co,start_chars_hint:['"'],line_breaks:!0}),wo=S({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),ts=S({name:"COMMENT",pattern:bo,start_chars_hint:["%"],line_breaks:!1}),re=S({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Fn=S({name:"ACC_DESCR_BLOCK",pattern:vo,start_chars_hint:["a"],line_breaks:!0}),Uo=/^accTitle[\t ]*:[^\n\r]*/,Po=/^accDescr[\t ]*:[^\n\r]*/,Bn=S({name:"ACC_TITLE_LINE",pattern:u((s,e)=>Dn(s,e,Uo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),$n=S({name:"ACC_DESCR_LINE",pattern:u((s,e)=>Dn(s,e,Po),"pattern"),start_chars_hint:["a"],line_breaks:!1}),jn=S({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),ms=S({name:"JSON_OBJECT_LITERAL",pattern:_o,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),Gn=S({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),_=u((s,e)=>S({name:s,pattern:e,longer_alt:N,categories:Oe}),"keyword"),Wn=_("USECASE",/usecase-beta/),ss=_("ACTOR",/actor/),Kn=_("SYSTEM_BOUNDARY",/systemBoundary/),Vn=_("END",/end/),zn=_("DIRECTION",/direction/),Hn=_("TD",/TD/),Xn=_("TB",/TB/),Yn=_("BT",/BT/),Jn=_("LR",/LR/),qn=_("RL",/RL/),Zn=_("NOTE",/note/),Qn=_("FOR",/for/),Do=_("JSON",/json/),ei=_("CLASS_DEF",/classDef/),ti=_("CLASS",/class/),si=_("STYLE",/style/),ni=_("INCLUDE",/include/i),ii=_("EXTEND",/extend/i),ai=_("TRUE",/true/),ri=_("FALSE",/false/),oi=S({name:"GENERALIZATION",pattern:/--\|>/}),li=S({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),ci=S({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Es=S({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Ts=S({name:"STEREOTYPE_TEXT",pattern:Mo,line_breaks:!1}),hi=S({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),ui=S({name:"CLASS_SEPARATOR",pattern:/:::/}),ut=S({name:"FORWARD_SOLID",pattern:/--+>/}),di=S({name:"BACKWARD_SOLID",pattern:/<--+/}),dt=S({name:"FORWARD_CIRCLE",pattern:/--o/}),fi=S({name:"BACKWARD_CIRCLE",pattern:/o--/}),ft=S({name:"FORWARD_CROSS",pattern:/--x/}),pi=S({name:"BACKWARD_CROSS",pattern:/x--/}),H=S({name:"MARKERLESS_SOLID",pattern:/--+/}),ns=S({name:"METADATA_START",pattern:/@{/}),pt=S({name:"AT",pattern:/@/,categories:w}),mi=S({name:"LBRACE",pattern:/{/}),is=S({name:"RBRACE",pattern:/}/}),mt=S({name:"LBRACKET",pattern:/\[/}),Et=S({name:"RBRACKET",pattern:/]/}),Ve=S({name:"LPAREN",pattern:/\(/}),ze=S({name:"RPAREN",pattern:/\)/}),J=S({name:"COMMA",pattern:/,/,categories:w}),He=S({name:"COLON",pattern:/:/,categories:w}),Ei=S({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:w}),X=S({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),as=S({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:w}),Ti=S({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:w}),gi=S({name:"DASH",pattern:/-/,categories:w}),Ai=S({name:"DOT",pattern:/\./,categories:w}),Si=S({name:"PERCENT",pattern:/%/,categories:w}),yi=S({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:w}),Fo=S({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:w}),Bo=S({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:w}),Ri=[w,Oe,xo,oe,wo,ts,re,Fn,Bn,$n,jn,Wn,ss,Kn,Vn,zn,Hn,Xn,Yn,Jn,qn,Zn,Qn,Do,ei,ti,si,ni,ii,ai,ri,oi,li,ci,ui,ut,di,dt,fi,ft,pi,H,ns,pt,mi,is,mt,Et,Ve,ze,J,He,Ei,X,as,N,ps,Ti,gi,Ai,Si,yi,Fo,Bo],$o={defaultMode:"defaultMode",modes:{defaultMode:[...Ri],jsonBody:[ms,Gn],stereotype:[Es,Ts,hi]}},jo=[...Ri,ms,Gn,Es,Ts,hi],Go=new F($o),Vs=u(s=>pn(s,w)||s.tokenType===X||s.tokenType===oe,"isLabelToken"),Wo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Le,Ko=(Le=class extends Zr{constructor(){super(jo,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(Wn),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:u(()=>this.isStatementStart(),"GATE"),ALT:u(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:u(()=>this.isMetadataAssignment(),"GATE"),ALT:u(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:u(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:u(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:u(()=>this.CONSUME(re),"ALT")},{ALT:u(()=>this.CONSUME(le),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(re)}),this.RULE("commentLine",()=>{this.CONSUME(ts),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Bn),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:u(()=>this.CONSUME($n),"ALT")},{ALT:u(()=>this.CONSUME(Fn),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(ss),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:u(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(J),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:u(()=>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:u(()=>{this.CONSUME(N),this.OPTION(()=>{this.CONSUME(Ve),this.SUBRULE(this.nodeLabel),this.CONSUME(ze)})},"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(ss),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(J),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:u(()=>{this.CONSUME(N),this.OPTION(()=>{this.OR2([{ALT:u(()=>{this.CONSUME(Ve),this.SUBRULE(this.nodeLabel),this.CONSUME(ze)},"ALT")},{ALT:u(()=>{this.CONSUME(mt),this.SUBRULE2(this.nodeLabel),this.CONSUME(Et)},"ALT")}])})},"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"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:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.AT_LEAST_ONE(()=>this.CONSUME(w)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:u(()=>this.LA(1).tokenType===N&&this.LA(2).tokenType===pt,"GATE"),DEF:u(()=>{this.CONSUME(N),this.CONSUME(pt)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(ut)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(di),this.OPTION({GATE:u(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([H]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(H)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(H),this.OPTION({GATE:u(()=>this.LA(0).image==="--"&&this.hasLabeledRight([ut,H,dt,ft]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:u(()=>this.CONSUME(ut),"ALT")},{ALT:u(()=>this.CONSUME2(H),"ALT")},{ALT:u(()=>this.CONSUME(dt),"ALT")},{ALT:u(()=>this.CONSUME(ft),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(dt)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(fi),this.OPTION({GATE:u(()=>this.hasLabeledRight([H]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(H)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(ft)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(pi),this.OPTION({GATE:u(()=>this.hasLabeledRight([H]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(H)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.AT_LEAST_ONE(()=>this.CONSUME(w)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:u(()=>{this.CONSUME(li),this.CONSUME(He),this.OR2([{ALT:u(()=>this.CONSUME(ni),"ALT")},{ALT:u(()=>this.CONSUME(ii),"ALT")}])},"ALT")},{ALT:u(()=>this.CONSUME(oi),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(ns),this.MANY(()=>this.CONSUME(re)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(J)),this.MANY3(()=>this.CONSUME2(re))}),this.CONSUME(is)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:u(()=>this.CONSUME(N),"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")}]),this.CONSUME(He),this.OR2([{ALT:u(()=>this.CONSUME2(N),"ALT")},{ALT:u(()=>this.CONSUME2(X),"ALT")},{ALT:u(()=>this.CONSUME(ai),"ALT")},{ALT:u(()=>this.CONSUME(ri),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:u(()=>{this.CONSUME(J),this.MANY(()=>this.CONSUME(re))},"ALT")},{ALT:u(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(re)),this.OPTION(()=>this.CONSUME2(J)),this.MANY2(()=>this.CONSUME3(re))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(Kn),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(Vn),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:u(()=>{this.CONSUME(N),this.OPTION(()=>{this.OR2([{ALT:u(()=>{this.CONSUME(Ve),this.SUBRULE(this.nodeLabel),this.CONSUME(ze)},"ALT")},{ALT:u(()=>{this.CONSUME(mt),this.SUBRULE2(this.nodeLabel),this.CONSUME(Et)},"ALT")}])})},"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:u(()=>{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:u(()=>this.CONSUME(N),"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(Zn),this.CONSUME(Qn),this.CONSUME(N),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(ci),this.CONSUME(Ts),this.CONSUME(Es)}),this.RULE("classSuffix",()=>{this.CONSUME(ui),this.CONSUME(N),this.MANY(()=>{this.CONSUME(J),this.CONSUME2(N)})}),this.RULE("jsonStatement",()=>{this.CONSUME(jn),this.CONSUME(ms),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(zn),this.OR([{ALT:u(()=>this.CONSUME(Hn),"ALT")},{ALT:u(()=>this.CONSUME(Xn),"ALT")},{ALT:u(()=>this.CONSUME(Yn),"ALT")},{ALT:u(()=>this.CONSUME(Jn),"ALT")},{ALT:u(()=>this.CONSUME(qn),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(ei),this.CONSUME(N),this.MANY(()=>{this.CONSUME(J),this.CONSUME2(N)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(ti),this.CONSUME(N),this.MANY(()=>{this.CONSUME(J),this.CONSUME2(N)}),this.CONSUME3(N),this.MANY2(()=>{this.CONSUME2(J),this.CONSUME4(N)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(si),this.CONSUME(N),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(J),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:u(()=>this.CONSUME(Oe),"ALT")},{ALT:u(()=>this.CONSUME(as),"ALT")},{ALT:u(()=>{this.CONSUME(H),this.CONSUME2(Oe)},"ALT")}]),this.CONSUME(He),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:u(()=>this.CONSUME(Oe),"ALT")},{ALT:u(()=>this.CONSUME(X),"ALT")},{ALT:u(()=>this.CONSUME(ps),"ALT")},{ALT:u(()=>this.CONSUME(Ei),"ALT")},{ALT:u(()=>this.CONSUME(as),"ALT")},{ALT:u(()=>this.CONSUME(Ti),"ALT")},{ALT:u(()=>this.CONSUME(gi),"ALT")},{ALT:u(()=>this.CONSUME(Ai),"ALT")},{ALT:u(()=>this.CONSUME(Si),"ALT")},{ALT:u(()=>this.CONSUME(yi),"ALT")},{ALT:u(()=>this.CONSUME(He),"ALT")},{ALT:u(()=>this.CONSUME(Ve),"ALT")},{ALT:u(()=>this.CONSUME(ze),"ALT")},{ALT:u(()=>this.CONSUME(mt),"ALT")},{ALT:u(()=>this.CONSUME(Et),"ALT")},{ALT:u(()=>this.CONSUME(mi),"ALT")},{ALT:u(()=>this.CONSUME(is),"ALT")},{ALT:u(()=>this.CONSUME(pt),"ALT")},{ALT:u(()=>this.CONSUME(H),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){const e=this.LA(1).tokenType;return(e===N||e===X||e===oe)&&this.LA(2).tokenType===ns}isStatementStart(){const e=this.LA(1).tokenType;return e!==le&&e!==re&&e!==ts}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===N&&Wo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Vs(this.LA(1)))return!1;for(let t=2;;t++){const n=this.LA(t);if(e.includes(n.tokenType))return!0;if(!Vs(n))return!1}}},u(Le,"UsecaseParser"),Le),Xe=new Ko,Ie,zs=(Ie=class extends Error{constructor(e,t,n){super(`${e} (line ${t}, column ${n})`),this.line=t,this.column=n,this.name="UsecaseJsonError"}},u(Ie,"UsecaseJsonError"),Ie),rs=u((s,e,t,n)=>{let i=t,a=n;const r=Math.min(Math.max(e,0),s.length);for(let o=0;o<r;o++){const l=s[o];l==="\r"?(i++,a=1):l===`
|
|
114
|
+
`?(o===0||s[o-1]!=="\r")&&(i++,a=1):a++}return{line:i,column:a}},"locationAtOffset"),Vo=u((s,e,t,n)=>{const i=/\bposition (\d+)\b/u.exec(s);if(i)return rs(e,Number.parseInt(i[1],10),t,n);const a=/\bline (\d+) column (\d+)\b/u.exec(s);if(a){const r=Number.parseInt(a[1],10),o=Number.parseInt(a[2],10);return{line:t+r-1,column:r===1?n+o-1:o}}if(/unexpected end|end of json input/iu.test(s))return rs(e,e.length,t,n)},"locationFromErrorMessage"),ke,P=(ke=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}},u(ke,"JsonWalkError"),ke),Ne,Hs=(Ne=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new P(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();const t=this.text[this.offset];if(t==="{")this.collectObject(e);else if(t==="[")this.collectArray(e);else if(t==='"')this.readString(!1);else if(t==="t")this.consumeLiteral("true");else if(t==="f")this.consumeLiteral("false");else if(t==="n")this.consumeLiteral("null");else if(t==="-"||t>="0"&&t<="9")this.consumeNumber();else throw new P(this.offset)}collectObject(e){this.offset++;const t=[],n=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!=='"')throw new P(this.offset);const i=this.readString(!0),a=`${e}/${i.replaceAll("~","~0").replaceAll("/","~1")}`;if(n.has(i)?this.deletePointerSubtree(a):(n.add(i),t.push(i)),this.skipWhitespace(),this.text[this.offset]!==":")throw new P(this.offset);if(this.offset++,this.collectValue(a),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new P(this.offset);this.offset++,this.skipWhitespace()}throw new P(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new P(this.offset);this.offset++,this.skipWhitespace()}throw new P(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){const n=this.offset,i=this.text[this.offset++];if(i==='"')return t;if(i.charCodeAt(0)<32)throw new P(n);if(i!=="\\"){e&&(t+=i);continue}const a=this.offset,r=this.text[this.offset++];switch(r){case'"':case"\\":case"/":e&&(t+=r);break;case"b":e&&(t+="\b");break;case"f":e&&(t+="\f");break;case"n":e&&(t+=`
|
|
115
|
+
`);break;case"r":e&&(t+="\r");break;case"t":e&&(t+=" ");break;case"u":{const o=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(o))throw new P(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(o,16))),this.offset+=4;break}default:throw new P(a)}}throw new P(this.offset)}consumeLiteral(e){let t=0;for(const n of e){if(this.text[this.offset+t]!==n)throw new P(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-"&&this.offset++,this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new P(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new P(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,(this.text[this.offset]==="+"||this.text[this.offset]==="-")&&this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new P(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){const e=this.text[this.offset];if(e!==" "&&e!==" "&&e!==`
|
|
116
|
+
`&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){const t=`${e}/`;for(const n of Object.keys(this.propertyOrder))(n===e||n.startsWith(t))&&delete this.propertyOrder[n]}},u(Ne,"PropertyOrderCollector"),Ne);function Oi(s,e,t){let n;try{n=JSON.parse(s)}catch(i){const a=i instanceof Error?i.message:String(i);let r=Vo(a,s,e,t);if(!r){let o=0;try{new Hs(s).collect()}catch(l){l instanceof P&&(o=l.offset)}r=rs(s,o,e,t)}throw new zs(`Invalid JSON: ${a}`,r.line,r.column)}if(typeof n!="object"||n===null||Array.isArray(n))throw new zs("JSON value must have an object root",e,t);return{value:n,propertyOrder:new Hs(s).collect()}}u(Oi,"parseOrderedJsonObject");var zo=u(s=>({shape:s.type==="normal"?"actor":s.type==="hollow"?"actor-hollow":s.type==="awesome"?"actor-awesome":"actor-icon",...s.label===s.id?{}:{label:s.label},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"actor",actorType:s.type,business:s.business,labelType:s.labelType,...s.icon?{icon:s.icon}:{},...s.stereotype?{stereotype:s.stereotype}:{},...s.parentId?{parentId:s.parentId}:{}}}),"actorNode"),Ho=u(s=>({shape:s.shape,...s.label===s.id?{}:{label:s.label},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"usecase",useCaseShape:s.shape,business:s.business,labelType:s.labelType,...s.stereotype?{stereotype:s.stereotype}:{},...s.parentId?{parentId:s.parentId}:{}}}),"useCaseNode"),Xo=u(s=>({label:s.label,shape:"note",attrs:{kind:"note",target:s.target,labelType:s.labelType}}),"noteNode"),Yo=u(s=>({label:s.id,shape:"json-table",...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"json",value:s.value,propertyOrder:s.propertyOrder,labelType:"text"}}),"jsonNode"),Jo=u(s=>({id:s.id,source:s.source,target:s.target,...s.label?{label:s.label}:{},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{relationshipType:s.type,arrowType:s.arrowType,minlen:s.minlen,explicitId:s.explicitId,animate:s.animate,...s.animation?{animation:s.animation}:{},...s.labelType?{labelType:s.labelType}:{}}}),"relationshipEdge"),qo=u(s=>({id:`${s.id}-edge`,source:s.id,target:s.target,attrs:{relationshipType:"note",arrowType:I.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Zo=u((s,e,t,n)=>{const i={};for(const l of s.getActors().values())i[l.id]=zo(l);for(const l of s.getUseCases().values())i[l.id]=Ho(l);for(const l of s.getNotes().values())i[l.id]=Xo(l);for(const l of s.getJsonNodes().values())i[l.id]=Yo(l);const a={};for(const l of s.getSystemBoundaries().values())a[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};const r={};for(const l of s.getClassDefs().values())r[l.id]={styles:[...l.styles]};const o=s.getDirection();return{version:1,diagramType:"usecase",source:e,header:{keyword:"usecase",direction:o==="TD"?"TB":o,span:t},...s.getAccTitle()?{accTitle:s.getAccTitle()}:{},...s.getAccDescription()?{accDescr:s.getAccDescription()}:{},nodes:i,edges:[...s.getRelationships().map(Jo),...[...s.getNotes().values()].map(qo)],groups:a,classDefs:r,statements:n}},"buildUsecaseGraphAST"),D=u(s=>`line ${s.line}, column ${s.column} [${s.span[0]},${s.span[1]})`,"locationText"),Xs=u(s=>s===void 0?"":` (label "${s}")`,"labelSuffix"),me=u(s=>s.generated?s.label:void 0,"generatedFrom"),$t=u((s,e)=>{for(const t of e)s.includes(t)||s.push(t)},"pushUnique"),Ce,Qo=(Ce=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,n,i){this.metadataAssignments.push({target:e,targetLocation:t,metadata:n,statement:i})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,n){this.styleAssignments.push({target:e,location:t,styles:n})}setDirection(e){this.directions.push(e==="TD"?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){const t=new Map,n=new Map,i=new Map,a=new Map;for(const h of this.relationshipDrafts)this.recordFirst(a,h.source.id,h.source.location.span[0]),this.recordFirst(a,h.target.id,h.target.location.span[0]);for(const h of this.elements)this.recordFirst(a,h.id,h.location.span[0]);for(const h of this.boundaries)this.recordFirst(a,h.id,h.location.span[0]);for(const h of this.jsonDrafts)this.recordFirst(a,h.id,h.location.span[0]);const r=[...this.elements.map(h=>({offset:h.location.span[0],type:"element",value:h})),...this.boundaries.map(h=>({offset:h.location.span[0],type:"boundary",value:h})),...this.jsonDrafts.map(h=>({offset:h.location.span[0],type:"json",value:h})),...this.relationshipDrafts.filter(h=>h.explicitId).map(h=>({offset:h.explicitIdLocation.span[0],type:"edge",value:h}))].sort((h,d)=>h.offset-d.offset);for(const h of r)h.type==="element"?this.collectElement(h.value,t,n):h.type==="boundary"?this.collectBoundary(h.value,t,i):h.type==="json"?this.registerUnique(t,h.value.id,"json",h.value.location,!1):this.registerUnique(t,h.value.explicitId,"edge",h.value.explicitIdLocation,!1);this.materializeElements(n,a),this.materializeBoundaries(i,a),this.materializeJson(a);const o=this.materializeRelationships(t,n,a);this.reorderElements(n,a),this.applyMetadataAssignments(t,n,i,o),this.validateAndRefreshElements(n),this.refreshBoundaries(i,n),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,o),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([h,d])=>[h,d.kind]));const l=Zo(this,this.source,e,this.statements);return this.model.ast=l,this.db.commit(this.model),l}collectElement(e,t,n){const i=t.get(e.id),a=me({generated:e.generated,label:e.label.text});i&&i.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,a,me(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,a,me(i));const r=n.get(e.id);if(!r){const o={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(o,e.metadata),n.set(e.id,o),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(r.label.text!==e.label.text||r.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,r.location),e.shape&&r.shape&&e.shape!==r.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,r.location),e.parentId&&r.parentId&&e.parentId!==r.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,r.parentLocation??r.location),e.stereotype&&r.stereotype&&e.stereotype!==r.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,r.stereotypeLocation??r.location),r.shape??(r.shape=e.shape),r.parentId??(r.parentId=e.parentId),r.parentLocation??(r.parentLocation=e.parentLocation),r.stereotype??(r.stereotype=e.stereotype),r.stereotypeLocation??(r.stereotypeLocation=e.stereotype?e.location:void 0),$t(r.classes,e.classes),this.applyDeclarationMetadata(r,e.metadata)}collectBoundary(e,t,n){const i=t.get(e.id),a=me({generated:e.generated,label:e.label.text});i&&i.kind!=="boundary"&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,a,me(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,a,me(i));const r=n.get(e.id);if(r){(r.label.text!==e.label.text||r.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,r.location),$t(r.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(const n of[...e.values()].sort((i,a)=>(t.get(i.id)??0)-(t.get(a.id)??0)))this.setElementModel(n)}materializeBoundaries(e,t){for(const n of[...e.values()].sort((i,a)=>(t.get(i.id)??0)-(t.get(a.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(const t of[...this.jsonDrafts].sort((n,i)=>(e.get(n.id)??0)-(e.get(i.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,n){const i=new Map;let a=0;for(const r of this.relationshipDrafts){const o=this.resolveEndpoint(r.source,e,t,n),l=this.resolveEndpoint(r.target,e,t,n);this.validateRelationship(r,o,l,e);const h=r.explicitId??`edge-${a++}`,d={id:h,explicitId:!!r.explicitId,source:r.source.id,target:r.target.id,type:r.type,arrowType:r.arrowType,...r.label?{label:r.label.text,labelType:r.label.type}:{},minlen:r.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),i.set(h,{draft:r,relationship:d})}return this.model.relationshipCounter=a,i}resolveEndpoint(e,t,n,i){if(e.classesOnReference&&!e.declaration)throw new Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${D(e.location)}`);const a=t.get(e.id);return a?a.kind:(n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),t.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(i,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){const n=new Map(this.model.actors),i=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(const a of[...e.values()].sort((r,o)=>(t.get(r.id)??0)-(t.get(o.id)??0))){!n.has(a.id)&&!i.has(a.id)&&this.setElementModel(a);const r=n.get(a.id)??this.model.actors.get(a.id),o=i.get(a.id)??this.model.useCases.get(a.id);r?this.model.actors.set(a.id,r):o&&this.model.useCases.set(a.id,o)}}applyMetadataAssignments(e,t,n,i){for(const a of this.metadataAssignments){const r=e.get(a.target);if(!r){const o=this.inferMetadataKind(a.metadata);throw new Error(`Metadata target '${a.target}' is unresolved${o?` (metadata implies ${o})`:""} at ${D(a.targetLocation)}`)}if(r.kind==="actor"||r.kind==="usecase")this.applyStandaloneElementMetadata(t.get(a.target),a.metadata);else if(r.kind==="boundary"){const o=n.get(a.target);for(const l of a.metadata.properties)(l.key!=="type"||l.value!=="rect"&&l.value!=="package")&&this.invalidMetadata(a.target,r.kind,l),o.type=l.value}else if(r.kind==="edge"){const o=i.get(a.target);if(!o)throw new Error(`Metadata target '${a.target}' is not an explicit edge at ${D(a.targetLocation)}`);a.statement.kind="edgeMetadata",a.statement.edges=[{id:a.target,span:a.statement.span,idSpan:a.targetLocation.span,...a.statement.metadata?{metadata:a.statement.metadata}:{}}],delete a.statement.nodes;for(const l of a.metadata.properties)l.key==="animate"&&typeof l.value=="boolean"?o.relationship.animate=l.value:l.key==="animation"&&(l.value==="fast"||l.value==="slow")?(o.relationship.animation=l.value,o.relationship.animate=!0):this.invalidMetadata(a.target,r.kind,l)}else for(const o of a.metadata.properties)this.invalidMetadata(a.target,r.kind,o)}for(const{relationship:a}of i.values())a.animation&&(a.animate=!0)}applyStandaloneElementMetadata(e,t){for(const n of t.properties)e.kind==="actor"?this.applyActorProperty(e,n,!0):n.key==="business"&&typeof n.value=="boolean"?e.business=n.value:this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,t){if(t)for(const n of t.properties)e.kind==="actor"?this.applyActorProperty(e,n,!1):n.key==="business"&&typeof n.value=="boolean"?(e.business!==void 0&&e.business!==n.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,t,n){t.key==="type"&&(t.value==="normal"||t.value==="hollow"||t.value==="awesome")?(!n&&e.actorType!==void 0&&e.actorType!==t.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):t.key==="icon"&&typeof t.value=="string"?(!n&&e.icon!==void 0&&e.icon!==t.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):t.key==="business"&&typeof t.value=="boolean"?(!n&&e.business!==void 0&&e.business!==t.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(const t of e.values()){const n=t.icon?"icon":t.actorType??"normal";if(t.kind==="actor"){if(t.icon&&t.actorType&&t.actorType!=="normal")throw new Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${D(t.location)}`);if(t.business&&(n==="icon"||n==="awesome"))throw new Error(`Business actor '${t.id}' must use normal or hollow geometry at ${D(t.location)}`)}else if((t.shape??"ellipse")==="rect"&&t.business)throw new Error(`Rectangular use case '${t.id}' cannot be a business use case at ${D(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(const n of e.values())n.members.length=0;for(const n of[...this.elements].sort((i,a)=>i.location.span[0]-a.location.span[0])){if(!n.parentId)continue;const i=e.get(n.parentId);if(!i)throw new Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${D(n.parentLocation??n.location)}`);i.members.includes(n.id)||i.members.push(n.id)}for(const n of t.values())if(n.parentId&&!e.has(n.parentId))throw new Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${D(n.parentLocation??n.location)}`);for(const n of e.values()){const i=this.model.systemBoundaries.get(n.id);i.type=n.type??"rect",i.members=[...n.members],i.classes=[...n.classes],i.styles=[...n.styles]}}materializeNotes(e){let t=0;for(const n of this.noteDrafts){const i=e.get(n.target);if(!i)throw new Error(`Note target '${n.target}' is unresolved at ${D(n.targetLocation)}`);i.kind!=="actor"&&i.kind!=="usecase"&&this.conflict(`Note target '${n.target}' must be an actor or use case, not ${i.kind}`,n.targetLocation,i.location);const a=`note-${t++}`;this.model.notes.set(a,{id:a,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(const e of this.classDefinitions)for(const t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(const n of this.classAssignments)for(const i of n.targets)$t(this.getStylable(i.id,e,t,i.location).classes,n.classes);for(const n of this.styleAssignments)this.getStylable(n.target,e,t,n.location).styles.push(...n.styles)}getStylable(e,t,n,i){var o,l;const a=(o=t.get(e))==null?void 0:o.kind,r=a==="actor"?this.model.actors.get(e):a==="usecase"?this.model.useCases.get(e):a==="boundary"?this.model.systemBoundaries.get(e):a==="json"?this.model.jsonNodes.get(e):a==="edge"?(l=n.get(e))==null?void 0:l.relationship:void 0;if(!r)throw new Error(`Class/style target '${e}' is unresolved or anonymous at ${D(i)}`);return r}validateRelationship(e,t,n,i){const a=u(r=>r==="actor"||r==="usecase"||r==="json","allowed");if(a(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,i.get(e.source.id).location),a(n)||this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,i.get(e.target.id).location),(e.type==="include"||e.type==="extend")&&(t!=="usecase"||n!=="usecase"))throw new Error(`${e.type} relationship requires use-case endpoints at ${D(e.location)}`);if(e.type==="generalization"&&(t!=="actor"&&t!=="usecase"||t!==n))throw new Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${D(e.location)}`);if(e.type==="association"&&(t==="json"||n==="json")&&![0,1,2].includes(e.arrowType))throw new Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${D(e.location)}`)}setElementModel(e){var t,n;if(e.kind==="actor"){const i=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:i,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:((t=this.model.actors.get(e.id))==null?void 0:t.styles)??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:((n=this.model.useCases.get(e.id))==null?void 0:n.styles)??[]})}inferMetadataKind(e){const t=new Set(["actor","usecase","boundary","edge"]);for(const n of e.properties)if(n.key==="icon")t.clear(),t.add("actor");else if(n.key==="animate"||n.key==="animation")t.clear(),t.add("edge");else if(n.key==="type")t.clear(),n.value==="rect"||n.value==="package"?t.add("boundary"):(n.value==="normal"||n.value==="hollow"||n.value==="awesome")&&t.add("actor");else if(n.key==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}invalidMetadata(e,t,n){throw new Error(`Metadata property '${n.key}' is invalid for ${t} '${e}' at ${D(n.location)}`)}registerUnique(e,t,n,i,a){const r=e.get(t);r&&this.conflict(`ID '${t}' is declared more than once (${r.kind} and ${n})`,i,r.location,void 0,me(r)),e.set(t,{kind:n,location:i,generated:a})}recordFirst(e,t,n){const i=e.get(t);(i===void 0||n<i)&&e.set(t,n)}conflict(e,t,n,i,a){throw new Error(`${e} at ${D(t)}${Xs(i)}; previous declaration at ${D(n)}${Xs(a)}`)}},u(Ce,"UsecaseModelBuilder"),Ce),el=Xe.getBaseCstVisitorConstructor(),be,tl=(be=class extends el{constructor(){super(),this.builder=new Qo(It),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){const t=this.tokens(e,"USECASE")[0],n=[];for(const i of this.nodes(e,"line"))n.push(this.visit(i));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(t))}line(e){const t=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){const t=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){const t=this.tokens(e,"ACC_DESCR_LINE")[0],n=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=t?t.image.slice(t.image.indexOf(":")+1).trim():n.image.slice(n.image.indexOf("{")+1,n.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){const t=this.nodes(e,"actorItem"),n=t.map(h=>this.visit(h)),i=this.nodes(e,"relationTail")[0],a=n.map((h,d)=>this.actorOccurrence(t[d],h,!0));for(const h of n)this.builder.addElement(this.actorDraft(h));if(!i)return{kind:"node",span:[0,0],nodes:a};const r=this.visit(i);r.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(r.target));const o=this.relationshipDraft(n[0],r,this.nodeLocation(i));this.builder.addRelationship(o);const l=o.explicitId??`edge-${this.anonymousEdge++}`;return a.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],r.target,r.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:a,edges:[{id:l,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}actorItem(e){const t=this.visit(this.nodes(e,"actorName")[0]),n=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],a=this.nodes(e,"classSuffix")[0],r=a?this.visit(a):{classes:[],spans:[]};return{...t,...n?{metadata:this.visit(n)}:{},...i?{stereotype:this.visit(i)}:{},classes:r.classes,classSpans:r.spans}}actorName(e){const t=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(t){const a=this.nodes(e,"nodeLabel")[0],r=a?this.visit(a):this.tokenLabel(t);return{id:t.image,label:r,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}const i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){const t=this.nodes(e,"actorItem"),n=t.map(i=>this.visit(i));for(const i of n)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:n.map((i,a)=>this.actorOccurrence(t[a],i,!0))}}entityStatement(e){const t=this.nodes(e,"entityName"),n=this.visit(t[0]),i=this.nodes(e,"relationTail")[0];if(!i)return n.explicitDeclaration=!0,n.shape??(n.shape="ellipse"),this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(t[0],n,!0)]};n.explicitDeclaration&&this.builder.addElement(this.entityDraft(n));const a=this.visit(i);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));const r={source:this.endpoint(n),target:this.endpoint(a.target),location:this.nodeLocation(i),...a.explicitId?{explicitId:a.explicitId,explicitIdLocation:a.explicitIdLocation}:{},...a.arrow};this.builder.addRelationship(r);const o=r.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(t[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],a.target,a.target.explicitDeclaration)],edges:[{id:o,span:[0,0],...r.explicitIdLocation?{idSpan:r.explicitIdLocation.span}:{},...r.label?{labelSpan:r.label.span}:{}}]}}entityName(e){const t=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],a=this.nodes(e,"useCaseMetadata")[0],r=this.nodes(e,"stereotype")[0],o=this.nodes(e,"classSuffix")[0],l=o?this.visit(o):{classes:[],spans:[]};if(t){const d=i?this.visit(i):this.tokenLabel(t),c=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:t.image,label:d,location:this.tokenLocation(t),generated:!1,...c?{shape:c}:{},...a?{metadata:this.visit(a)}:{},...r?{stereotype:this.visit(r)}:{},classes:l.classes,classSpans:l.spans,explicitDeclaration:!!(c||a||r)}}const h=this.tokenLabel(n);return{id:this.generateId(h.text),label:h,location:this.tokenLocation(n),generated:!0,...a?{metadata:this.visit(a)}:{},...r?{stereotype:this.visit(r)}:{},classes:l.classes,classSpans:l.spans,explicitDeclaration:!!(a||r)}}nodeLabel(e){const t=this.allTokens(e);if(t.length===1&&(t[0].tokenType.name==="PLAIN_STRING"||t[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(t[0]);const n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){const t=this.tokens(e,"IDENTIFIER")[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:I.SOLID_ARROW,minlen:1};const t=this.tokens(e,"INCLUDE").length?"include":"extend",n=this.tokens(e,t==="include"?"INCLUDE":"EXTEND")[0];return{type:t,arrowType:I.SOLID_ARROW,label:{text:t,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(t=>this.visit(t)),location:this.ctxLocation(e)}}metadataProperty(e){const t=this.allTokens(e).filter(o=>o.tokenType.name!=="COLON"),n=t[0],i=t[1],a=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),r=[n.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(n),value:a,span:r,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(i),location:this.tokenLocation(n)}}metadataSeparator(e){}systemBoundaryStatement(e){const t=this.visit(this.nodes(e,"systemBoundaryName")[0]),n=this.nodes(e,"classSuffix")[0],i=n?this.visit(n):{classes:[],spans:[]};t.classes=i.classes,this.builder.addBoundary(t);const a=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};const r=this.nodes(e,"systemBoundaryContent")[0],o=r?this.visit(r):[];this.parentBoundary=a;const l=this.tokens(e,"END")[0],h=this.nodes(e,"metadata")[0],d=h?this.visit(h):void 0,c={kind:"group",span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(l),classSpans:i.spans,...d?{metadata:d.properties.map(({key:f,span:p,keySpan:A,valueSpan:R})=>({key:f,span:p,keySpan:A,valueSpan:R}))}:{},...o.length?{children:o}:{}};return d&&this.builder.addMetadataAssignment(t.id,t.location,d,c),c}systemBoundaryName(e){const t=this.tokens(e,"IDENTIFIER")[0];if(t){const a=this.nodes(e,"nodeLabel")[0];return{id:t.image,label:a?this.visit(a):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}const n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((n,i)=>{var a,r;return(((a=n.location)==null?void 0:a.startOffset)??0)-(((r=i.location)==null?void 0:r.startOffset)??0)}).map(n=>this.wrap(n,this.visit(n)))}boundaryElement(e){const t=this.nodes(e,"actorDeclarationOnly")[0];if(t)return this.visit(t);const n=this.nodes(e,"entityName")[0],i=this.visit(n);return i.explicitDeclaration=!0,i.shape??(i.shape="ellipse"),this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,i,!0)]}}metadataAssignmentStatement(e){const t=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:n.properties.map(({key:a,span:r,keySpan:o,valueSpan:l})=>({key:a,span:r,keySpan:o,valueSpan:l}))};return this.builder.addMetadataAssignment(t.id,t.location,n,i),i}metadataAssignmentTarget(e){const t=this.allTokens(e)[0],n=this.tokenLabel(t);return{id:t.tokenType.name==="IDENTIFIER"?t.image:this.generateId(n.text),location:this.tokenLocation(t)}}noteStatement(e){const t=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:n,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){const t=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){const t=this.tokens(e,"IDENTIFIER");return{classes:t.map(n=>n.image),spans:t.map(n=>this.tokenSpan(n))}}jsonStatement(e){const t=this.tokens(e,"JSON_DECLARATION_START")[0],n=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(t.image),a=i[1],r=i[0].length-a.length,o={span:[t.startOffset+r,t.startOffset+r+a.length],line:t.startLine??1,column:(t.startColumn??1)+r},l=Oi(n.image,n.startLine??1,n.startColumn??1),h=this.nodes(e,"classSuffix")[0],d=h?this.visit(h):{classes:[],spans:[]},c={id:a,value:l.value,propertyOrder:l.propertyOrder,location:o,classes:d.classes};return this.builder.addJson(c),{kind:"json",span:[0,0],nodes:[{id:a,span:o.span,idSpan:o.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(e){const t=this.allTokens(e).find(n=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(t.image),{kind:"direction",span:[0,0]}}classDefStatement(e){const t=this.tokens(e,"IDENTIFIER"),n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(t.map(i=>i.image),n),{kind:"classDef",span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){const t=this.tokens(e,"IDENTIFIER");let n=1;for(;n<t.length&&this.source.slice((t[n-1].endOffset??t[n-1].startOffset)+1,t[n].startOffset).includes(",");n++);const i=t.slice(0,n).map(r=>({id:r.image,location:this.tokenLocation(r)})),a=t.slice(n).map(r=>r.image);return this.builder.addClassAssignment(i,a),{kind:"classAssign",span:[0,0],ref:a[0],refSpan:this.tokenSpan(t[n]),nodes:i.map(({id:r,location:o})=>({id:r,span:o.span,idSpan:o.span}))}}styleStatement(e){const t=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),n),{kind:"style",span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,"styleValue").map(t=>this.visit(t))}styleValue(e){const t=this.allTokens(e),n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(t=>t.image).join("")}forwardSolidOperator(e){const t=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:I.SOLID_ARROW,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){const t=this.tokens(e,"BACKWARD_SOLID")[0],n=this.nodes(e,"edgeLabel")[0],i=n?this.tokens(e,"MARKERLESS_SOLID").at(-1):t;return{type:"association",arrowType:I.BACK_ARROW,minlen:this.solidMinlen(i),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){const t=this.nodes(e,"edgeLabel")[0],n=this.allTokens(e);if(!t)return{type:"association",arrowType:I.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};const i=n.at(-1),a=i.tokenType.name==="FORWARD_SOLID"?I.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?I.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?I.CROSS_ARROW:I.LINE_SOLID;return{type:"association",arrowType:a,label:this.visit(t),minlen:a===I.SOLID_ARROW||a===I.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:I.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){const t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:I.CIRCLE_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:I.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){const t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:I.CROSS_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:"actor",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:"usecase",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,n){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:n,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,n){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...n?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:i,span:a,keySpan:r,valueSpan:o})=>({key:i,span:a,keySpan:r,valueSpan:o}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,n){return this.actorOccurrence(e,t,n)}wrap(e,t){if(t.kind==="blank"||t.kind==="comment")return t;t.span=this.nodeSpan(e);for(const n of t.edges??[])n.span=t.span;return t}tokenLabel(e){const t=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=t==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(e,n);return{text:this.source.slice(i[0],i[1]),type:t,span:i}}decodePlain(e){return e.tokenType.name==="PLAIN_STRING"?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){var t;return Math.max(1,(((t=e.image.match(/-/g))==null?void 0:t.length)??2)-1)}nodeLocation(e){const t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){const t=this.allTokens(e).filter(a=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),n=t[0],i=t.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){const t=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){const t=this.allTokens(e.children).filter(a=>a.tokenType.name!=="NEWLINE"&&a.tokenType.name!=="EOF"),n=t[0],i=t.at(-1);if(!n||!i)throw new Error("Usecase CST node has no source token");return[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(n=>"children"in n)}tokens(e,t){return(e[t]??[]).filter(n=>"tokenTypeIdx"in n)}firstNode(e,...t){for(const n of t){const i=this.nodes(e,n)[0];if(i)return i}throw new Error(`Usecase CST is missing one of: ${t.join(", ")}`)}allTokens(e){const t=[];for(const n of Object.values(e))for(const i of n)"tokenTypeIdx"in i?t.push(i):t.push(...this.allTokens(i.children));return t.sort((n,i)=>n.startOffset-i.startOffset)}},u(be,"UsecaseVisitor"),be),sl=new tl,nl={parse:u(async s=>{It.clear(),Xe.input=[];try{wn({diagramType:"usecase",lexer:Go,parser:Xe,entry:u(()=>Xe.start(),"entry"),visit:u(e=>sl.build(e,s),"visit")},s)}catch(e){It.clear();const t=Xe.errors[0];if(t){const{token:n}=t,i=Re(n.startOffset)?n.startOffset:s.length,a=Re(n.endOffset)?n.endOffset+1:i,r=Re(n.startLine)?n.startLine:s.slice(0,i).split(/\r\n|\r|\n/).length,o=Math.max(s.lastIndexOf(`
|
|
117
|
+
`,i-1),s.lastIndexOf("\r",i-1)),l=Re(n.startColumn)?n.startColumn:i-o,h=e instanceof Error?e.message:String(e);throw new Error(`${h} at line ${r}, column ${l} [${i},${a})`)}throw e}},"parse")},il=["point","circle","cross","extension"],Li={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Ys=u((s,e)=>{const[t,n]=[s,e].map(i=>i.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${t}-${n}`},"usecaseDomId"),al=u(s=>`usecase-${s.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),vt=u((s,e)=>e!=="markdown"?s:Gi(s).map(t=>t.map(n=>n.content).join(" ")).join(`
|
|
118
|
+
`),"getAccessibleLabel"),rl=u(s=>{const e=vt(s.label??s.id,s.labelType);if(Li[s.shape]){const n=s.actorType&&s.actorType!=="normal"?`${s.actorType} `:"",i=s.business?"business ":"",a=s.stereotype?`, stereotype ${s.stereotype}`:"";return`${i}${n}actor ${e}${a}`}if(s.shape==="note")return`Note for ${s.noteTargetLabel??s.noteTarget??""}: ${e}`;if(s.shape==="usecaseJsonTable"){const n=(s.jsonRows??[]).map(i=>`${i.accessibleKey}: ${i.value}`).join("; ");return n?`${e}: ${n}`:e}const t=s.stereotype?`, stereotype ${s.stereotype}`:"";return`${s.business?"business ":""}use case ${e}${t}`},"getUsecaseNodeAccessibleName"),ol=u(s=>`${s.boundaryType} system boundary ${vt(s.label??s.id,s.labelType)}`,"getUsecaseBoundaryAccessibleName"),ll=u(s=>s.relationshipType==="note"?"":`${s.relationshipType==="association"&&s.label?`association ${vt(s.label,s.labelType)}`:s.relationshipType} from ${s.sourceLabel} to ${s.targetLabel}`,"getUsecaseEdgeAccessibleName"),ye=u(s=>s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),Js=u(s=>s.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),cl=u((s,e)=>{var t;s.diagramId=e,s.markers=[...il];for(const n of s.nodes){const i=n;if(i.domId=al(n.id),n.label!==void 0&&n.labelType==="text"&&(n.label=ye(n.label)),n.stereotype&&(n.stereotype=ye(n.stereotype)),!n.isGroup&&n.shape==="usecaseJsonTable"&&(n.jsonRows=(t=n.jsonRows)==null?void 0:t.map(a=>({...a,key:ye(a.key),value:ye(a.value)}))),!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){const a=n.label??ye(n.id);n.label=`«${Js(n.stereotype)}»<br/>${n.labelType==="text"?Js(a):a}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(const n of s.edges)n.label!==void 0&&n.labelType==="text"&&(n.label=ye(n.label));return s},"prepareUsecaseLayoutData"),hl=u((s,e,t)=>{var i;for(const a of e.nodes){const r=typeof a.domId=="string"?a.domId:Ys(e.diagramId,a.id),o=s.select(`#${r}`),l=a.isGroup?"boundary":Li[a.shape]?"actor":a.shape==="note"?"note":a.shape==="usecaseJsonTable"?"json":"usecase",h=t.nodes.get(a.id)??a.id;if(o.attr("data-usecase-id",a.id).attr("data-usecase-kind",l).attr("role","img").attr("aria-label",h),!a.isGroup&&(a.shape==="usecaseEllipse"||a.shape==="rect")&&"hasFoldedStereotype"in a&&a.hasFoldedStereotype===!0){const d=o.node(),c=d==null?void 0:d.querySelector(".nodeLabel"),f=(c==null?void 0:c.querySelector("p"))??c,p=f==null?void 0:f.firstChild;if(f&&(p==null?void 0:p.nodeType)===3){const A=f.ownerDocument.createElement("span");A.className="usecase-stereotype",f.insertBefore(A,p),A.appendChild(p)}else(i=d==null?void 0:d.querySelector(".label tspan tspan, .label tspan"))==null||i.classList.add("usecase-stereotype")}}const n=new Map(e.edges.map(a=>[a.id,a]));s.selectAll('path[data-et="edge"]').each(function(){const a=n.get(this.getAttribute("data-id")??"");if(!a)return;const r=Wi(this);r.attr("id",Ys(e.diagramId,a.id)).attr("data-usecase-id",a.id).attr("data-usecase-kind",a.internal?"note-connector":"relationship"),a.internal?r.attr("aria-hidden","true"):r.attr("role","img").attr("aria-label",t.edges.get(a.id)??a.id)})},"annotateUsecaseElements"),qs=u((s,e)=>{s.style("--mermaid-usecase-actor-font-size",`${e.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",e.actorFontFamily).style("--mermaid-usecase-actor-font-weight",e.actorFontWeight).style("--mermaid-usecase-font-size",`${e.usecaseFontSize}px`).style("--mermaid-usecase-font-family",e.usecaseFontFamily).style("--mermaid-usecase-font-weight",e.usecaseFontWeight)},"applyUsecaseFonts"),ul=u(async(s,e,t,n)=>{var c;_i.info("Drawing usecase diagram (unified)",e);const{layout:i}=en(),a=n.db,r=a.getData(),o=new Map(r.nodes.map(f=>[f.id,vt(f.label??f.id,f.labelType)])),l={nodes:new Map(r.nodes.map(f=>[f.id,f.isGroup?ol(f):rl(f.shape==="note"?{...f,noteTargetLabel:o.get(f.noteTarget??"")}:f)])),edges:new Map(r.edges.map(f=>[f.id,ll({...f,sourceLabel:o.get(f.source)??f.sourceLabel,targetLabel:o.get(f.target)??f.targetLabel})]))},h=Ni(e,r.config.securityLevel);r.layoutAlgorithm=Mi(i),cl(r,e),qs(h,r),await xi(r,h),hl(h,r,l);const d=r.diagramPadding;wi.insertTitle(h,"usecaseDiagramTitleText",0,((c=a.getDiagramTitle)==null?void 0:c.call(a))??""),Ci(h,d,"usecaseDiagram",r.useMaxWidth),qs(h,r)},"draw"),dl={draw:ul},fl=u(s=>({actorBkg:s.usecaseActorBkg??s.actorBkg??s.mainBkg,actorBorder:s.usecaseActorBorder??s.actorBorder??s.primaryColor,bkg:s.usecaseBkg??s.mainBkg,border:s.usecaseBorder??s.nodeBorder??s.primaryColor,boundaryBkg:s.usecaseBoundaryBkg??s.clusterBkg,boundaryBorder:s.usecaseBoundaryBorder??s.clusterBorder,includeLine:s.usecaseIncludeLine??s.lineColor,extendLine:s.usecaseExtendLine??s.lineColor}),"roleColors"),pl=u(s=>{var h;const{theme:e,bkgColorArray:t,borderColorArray:n}=s;if(!Fi(e,n))return"";const i=((h=Bi().usecase)==null?void 0:h.colorScheme)==="rotate",a=je(s.look),r=a==="handDrawn",o=$i(t);let l="";for(let d=0;d<ji(n);d++){const c=n[d],f=o?`fill: ${t[d%t.length]};`:"",p=`[data-look="${a}"][data-color-id="color-${d}"]`;l+=`
|
|
119
|
+
|
|
120
|
+
& ${p}.system-boundary rect.boundary-body,
|
|
121
|
+
& ${p}.system-boundary rect.boundary-tab,
|
|
122
|
+
& ${p}.system-boundary .boundary-body path,
|
|
123
|
+
& ${p}.system-boundary .boundary-tab path {
|
|
124
|
+
stroke: ${c};
|
|
125
|
+
${f}
|
|
126
|
+
}
|
|
127
|
+
`,i&&(l+=`
|
|
128
|
+
|
|
129
|
+
/* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
|
|
130
|
+
the business variant.
|
|
131
|
+
|
|
132
|
+
Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
|
|
133
|
+
the body as a *pair* of paths, an outline stroked in the border colour and a hachure
|
|
134
|
+
fill stroked in the background colour, with no class to tell them apart. Stroking
|
|
135
|
+
both repaints the fill lines as border colour and the shape collapses into a solid
|
|
136
|
+
block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
|
|
137
|
+
theme's uniform colours, exactly as handDrawn flowchart nodes do. */
|
|
138
|
+
& ${p}.usecase-element ellipse,
|
|
139
|
+
& ${p}.usecase-element rect {
|
|
140
|
+
stroke: ${c};
|
|
141
|
+
${f}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* The business marker is a single classed path, so it can be reached safely by name --
|
|
145
|
+
without it the marker keeps the uniform border beside a palette-coloured body. No
|
|
146
|
+
\`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
|
|
147
|
+
& ${p}.usecase-element .usecase-business-marker {
|
|
148
|
+
stroke: ${c};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
|
|
152
|
+
group, never on its children, so the hollow variant's own \`fill="none"\` keeps
|
|
153
|
+
winning and a hollow actor stays hollow. Same reason as above for not descending
|
|
154
|
+
into the handDrawn paths. */
|
|
155
|
+
& ${p}.usecase-actor .usecase-actor-shape,
|
|
156
|
+
& ${p}.usecase-actor .usecase-actor-hollow,
|
|
157
|
+
& ${p}.usecase-actor .usecase-actor-awesome,
|
|
158
|
+
& ${p}.usecase-actor .usecase-actor-icon {
|
|
159
|
+
stroke: ${c};
|
|
160
|
+
${f}
|
|
161
|
+
}
|
|
162
|
+
${r?"":`
|
|
163
|
+
/* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
|
|
164
|
+
ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
|
|
165
|
+
and a value set directly on the child always beats one inherited from the parent,
|
|
166
|
+
whatever the parent rule's specificity. So name the children too.
|
|
167
|
+
|
|
168
|
+
Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
|
|
169
|
+
outline path plus a hachure fill path stroked in the fill colour, indistinguishable
|
|
170
|
+
in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
|
|
171
|
+
\`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
|
|
172
|
+
& ${p}.usecase-actor .usecase-actor-glyph path,
|
|
173
|
+
& ${p}.usecase-actor .usecase-actor-glyph circle {
|
|
174
|
+
stroke: ${c};
|
|
175
|
+
}
|
|
176
|
+
`}
|
|
177
|
+
`)}return l},"genColor"),ml=u(s=>{const e=fl(s),t=je(s.look)==="handDrawn";return`
|
|
178
|
+
${pl(s)}
|
|
179
|
+
& .usecase-actor {
|
|
180
|
+
color: ${s.actorTextColor??s.primaryTextColor};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
& .usecase-actor-shape,
|
|
184
|
+
& .usecase-actor-hollow,
|
|
185
|
+
& .usecase-actor-awesome,
|
|
186
|
+
& .usecase-actor-icon {
|
|
187
|
+
fill: ${e.actorBkg};
|
|
188
|
+
stroke: ${e.actorBorder};
|
|
189
|
+
stroke-width: 2px;
|
|
190
|
+
}
|
|
191
|
+
${t?"":`
|
|
192
|
+
/* The rule above colours the glyph group and lets its children inherit, which the neo
|
|
193
|
+
look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
|
|
194
|
+
the glyph's own paths, and a value set directly on a child always beats one inherited
|
|
195
|
+
from its parent, whatever the parent rule's specificity. Since neo is the default look,
|
|
196
|
+
without this every actor renders in the node border colour rather than the actor
|
|
197
|
+
colour the rule above asks for.
|
|
198
|
+
|
|
199
|
+
\`.node\` is in the selector to outrank that neo rule rather than tie with it: both
|
|
200
|
+
would otherwise be one attribute plus one class plus one element, leaving the winner to
|
|
201
|
+
depend on which stylesheet is concatenated last.
|
|
202
|
+
|
|
203
|
+
Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
|
|
204
|
+
& .node.usecase-actor .usecase-actor-glyph path,
|
|
205
|
+
& .node.usecase-actor .usecase-actor-glyph circle {
|
|
206
|
+
stroke: ${e.actorBorder};
|
|
207
|
+
}
|
|
208
|
+
`}
|
|
209
|
+
& .usecase-actor .nodeLabel,
|
|
210
|
+
& .actor-label {
|
|
211
|
+
color: ${s.actorTextColor??s.primaryTextColor};
|
|
212
|
+
fill: ${s.actorTextColor??s.primaryTextColor};
|
|
213
|
+
font-family: var(--mermaid-usecase-actor-font-family, ${s.fontFamily});
|
|
214
|
+
font-size: var(--mermaid-usecase-actor-font-size, 14px);
|
|
215
|
+
font-weight: var(--mermaid-usecase-actor-font-weight, normal);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
& .usecase-element ellipse,
|
|
219
|
+
& .usecase-element rect,
|
|
220
|
+
& .usecase-business ellipse,
|
|
221
|
+
& .usecase-business rect {
|
|
222
|
+
fill: ${e.bkg};
|
|
223
|
+
stroke: ${e.border};
|
|
224
|
+
stroke-width: 2px;
|
|
225
|
+
}
|
|
226
|
+
${t?"":`
|
|
227
|
+
/* The same interception the actor glyph hits, one element down: neo ships
|
|
228
|
+
\`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
|
|
229
|
+
\`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
|
|
230
|
+
border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
|
|
231
|
+
equivalent neo rule and is already correct; restating it here costs nothing and means
|
|
232
|
+
the two forms cannot drift apart again.
|
|
233
|
+
|
|
234
|
+
Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
|
|
235
|
+
tie with it -- on a tie the later stylesheet would win, which is how neo took this in
|
|
236
|
+
the first place. Skipped under handDrawn, where roughjs draws paths and neither element
|
|
237
|
+
exists. */
|
|
238
|
+
& [data-look="${je(s.look)}"].node.usecase-element ellipse,
|
|
239
|
+
& [data-look="${je(s.look)}"].node.usecase-element rect {
|
|
240
|
+
fill: ${e.bkg};
|
|
241
|
+
stroke: ${e.border};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
|
|
245
|
+
way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
|
|
246
|
+
& [data-look="${je(s.look)}"].node.usecase-element .usecase-business-marker {
|
|
247
|
+
stroke: ${e.border};
|
|
248
|
+
}
|
|
249
|
+
`}
|
|
250
|
+
& .usecase-element .nodeLabel,
|
|
251
|
+
& .usecase-label {
|
|
252
|
+
color: ${s.primaryTextColor};
|
|
253
|
+
fill: ${s.primaryTextColor};
|
|
254
|
+
font-family: var(--mermaid-usecase-font-family, ${s.fontFamily});
|
|
255
|
+
font-size: var(--mermaid-usecase-font-size, 12px);
|
|
256
|
+
font-weight: var(--mermaid-usecase-font-weight, normal);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
& .usecase-stereotype,
|
|
260
|
+
& .usecase-business-marker {
|
|
261
|
+
color: ${s.primaryTextColor};
|
|
262
|
+
fill: ${s.primaryTextColor};
|
|
263
|
+
stroke: ${e.border};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
& .system-boundary rect.boundary-body,
|
|
267
|
+
& .system-boundary rect.boundary-tab,
|
|
268
|
+
& .system-boundary-package-tab {
|
|
269
|
+
fill: ${e.boundaryBkg};
|
|
270
|
+
stroke: ${e.boundaryBorder};
|
|
271
|
+
stroke-width: 1px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
& .system-boundary-title text {
|
|
275
|
+
fill: ${s.titleColor??s.primaryTextColor};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Only the span, never the <p> inside it: the renderer puts a user-supplied
|
|
279
|
+
'color' on the span, and that has to stay inheritable by its children. */
|
|
280
|
+
& .system-boundary-title span {
|
|
281
|
+
color: ${s.titleColor??s.primaryTextColor};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
& .usecase-note {
|
|
285
|
+
fill: ${s.noteBkgColor};
|
|
286
|
+
stroke: ${s.noteBorderColor};
|
|
287
|
+
color: ${s.noteTextColor};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
& .usecase-note .nodeLabel {
|
|
291
|
+
color: ${s.noteTextColor};
|
|
292
|
+
fill: ${s.noteTextColor};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
& .usecase-json-table,
|
|
296
|
+
& .usecase-json-table rect,
|
|
297
|
+
& .usecase-json-cell {
|
|
298
|
+
fill: ${s.mainBkg};
|
|
299
|
+
stroke: ${s.nodeBorder??s.primaryColor};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
& .usecase-json-title,
|
|
303
|
+
& .usecase-json-key,
|
|
304
|
+
& .usecase-json-value {
|
|
305
|
+
color: ${s.primaryTextColor};
|
|
306
|
+
fill: ${s.primaryTextColor};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
& .relationship {
|
|
310
|
+
fill: none;
|
|
311
|
+
stroke: ${s.lineColor};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
& .relationship-include,
|
|
315
|
+
& .relationship-extend,
|
|
316
|
+
& .relationship-note {
|
|
317
|
+
stroke-dasharray: 3;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/* Include and extend are both dashed, which is a weak distinction at small sizes. The
|
|
321
|
+
tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
|
|
322
|
+
& .relationship-include {
|
|
323
|
+
stroke: ${e.includeLine};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
& .relationship-extend {
|
|
327
|
+
stroke: ${e.extendLine};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
& .relationship.edge-animation-fast,
|
|
331
|
+
& .relationship.edge-animation-slow {
|
|
332
|
+
stroke-linecap: round;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
& .edgeLabel,
|
|
336
|
+
& .edgeLabel p {
|
|
337
|
+
background-color: ${s.edgeLabelBackground};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
& .labelBkg {
|
|
341
|
+
background-color: ${s.edgeLabelBackground};
|
|
342
|
+
padding: 0 2px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
& .edgeLabel .label rect {
|
|
346
|
+
fill: ${s.edgeLabelBackground};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
& .relationship-label,
|
|
350
|
+
& .edgeLabel {
|
|
351
|
+
color: ${s.primaryTextColor};
|
|
352
|
+
fill: ${s.primaryTextColor};
|
|
353
|
+
font-family: ${s.fontFamily};
|
|
354
|
+
font-size: 10px;
|
|
355
|
+
font-weight: normal;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
& .marker,
|
|
359
|
+
& .marker.point,
|
|
360
|
+
& .marker.circle,
|
|
361
|
+
& .marker.cross {
|
|
362
|
+
fill: ${s.lineColor};
|
|
363
|
+
stroke: ${s.lineColor};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
& .marker.extension {
|
|
367
|
+
fill: ${s.mainBkg};
|
|
368
|
+
stroke: ${s.lineColor};
|
|
369
|
+
}
|
|
370
|
+
`},"getStyles"),El=ml,kl={parser:nl,db:It,renderer:dl,styles:El};export{kl as diagram};
|