@bkm016/basalt 0.1.9 → 0.1.10
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/{chunk-0xd9mnc2.js → chunk-0mjb3sm3.js} +2 -2
- package/{chunk-66h5qpc6.js → chunk-3mqf9ped.js} +89 -89
- package/compiled.js +1 -1
- package/package.json +1 -1
- package/ui-test-worker.js +1 -1
- package/web/chunk-045d3b5d.js +1 -0
- package/web/{chunk-ff1pmd3g.js → chunk-0770q5e1.js} +1 -1
- package/web/{chunk-2x4g9t37.js → chunk-18neka5g.js} +2 -2
- package/web/{chunk-w3w18stt.js → chunk-1ev0n3n4.js} +1 -1
- package/web/chunk-1ex3wgms.js +2 -0
- package/web/{chunk-7qkav30b.js → chunk-1qh7f5kr.js} +1 -1
- package/web/{chunk-rayf24gy.js → chunk-26ecc2xh.js} +8 -8
- package/web/{chunk-me7dza1c.js → chunk-2cz7tx8q.js} +1 -1
- package/web/{chunk-mdfksj61.js → chunk-32ty2xfn.js} +1 -1
- package/web/{chunk-ts6jsfdk.js → chunk-3eexx7y5.js} +1 -1
- package/web/{chunk-2dvbeqt0.js → chunk-46jnkghq.js} +1 -1
- package/web/chunk-4am8j3k3.js +1 -0
- package/web/{chunk-qz6r9v1z.js → chunk-5qvmefq2.js} +1 -1
- package/web/{chunk-9ctg0f30.js → chunk-5svqfj4g.js} +1 -1
- package/web/{chunk-qsqtwf34.js → chunk-5v5q13hz.js} +1 -1
- package/web/chunk-7np1jp3x.js +8 -0
- package/web/chunk-87e8d1hv.js +1 -0
- package/web/{chunk-kcjz03h5.js → chunk-88wd49xe.js} +2 -2
- package/web/{chunk-0pghpg4y.js → chunk-8h2x89tw.js} +1 -1
- package/web/chunk-8y2526ve.js +1 -0
- package/web/{chunk-8jcvdd5d.js → chunk-905vw286.js} +1 -1
- package/web/{chunk-2hrswh3d.js → chunk-918e5t4x.js} +1 -1
- package/web/chunk-96m2m3e8.js +1 -0
- package/web/{chunk-43g4wd7a.js → chunk-9f4zzqbx.js} +1 -1
- package/web/{chunk-dnv8dx72.js → chunk-a1n4468c.js} +1 -1
- package/web/{chunk-s37beysw.js → chunk-b46ws7rf.js} +1 -1
- package/web/{chunk-24jhbz82.js → chunk-bc3ajvfg.js} +1 -1
- package/web/{chunk-ket6g0yd.js → chunk-d5gshd1a.js} +1 -1
- package/web/{chunk-c6yacwbc.js → chunk-de40q05r.js} +1 -1
- package/web/chunk-dp0k5vhd.js +1 -0
- package/web/{chunk-5dr4tkem.js → chunk-dv1berk6.js} +3 -3
- package/web/{chunk-dwjmr0zj.js → chunk-eh7wp62z.js} +1 -1
- package/web/{chunk-ctzkqx2g.js → chunk-ehtmb6sn.js} +1 -1
- package/web/chunk-et1hytyv.js +1 -0
- package/web/chunk-f9m9seam.js +1 -0
- package/web/{chunk-3pd0qt83.js → chunk-fmmrthpa.js} +2 -2
- package/web/chunk-g2erm7k0.js +1 -0
- package/web/chunk-g3kbn0t2.js +1 -0
- package/web/{chunk-t893141g.js → chunk-g7dc4hrd.js} +1 -1
- package/web/{chunk-p9hfcamx.js → chunk-g7kz8f7q.js} +1 -1
- package/web/chunk-ght0t49g.js +1 -0
- package/web/{chunk-xa43ndfj.js → chunk-ghwm7bdj.js} +2 -2
- package/web/{chunk-8z0r0wtk.js → chunk-grm2208k.js} +1 -1
- package/web/{chunk-0zwc2rvh.js → chunk-gsw1tv96.js} +1 -1
- package/web/{chunk-tftc5v89.js → chunk-gw8x1g61.js} +1 -1
- package/web/chunk-gx340asc.js +1 -0
- package/web/{chunk-935mjq1c.js → chunk-h2txs73e.js} +1 -1
- package/web/chunk-h3tkacc7.js +1 -0
- package/web/{chunk-ewx42c11.js → chunk-h5ckjk48.js} +1 -1
- package/web/{chunk-nnyc889n.js → chunk-j37p0b13.js} +1 -1
- package/web/{chunk-fjb3ksfd.js → chunk-j89s11x8.js} +1 -1
- package/web/chunk-je78j3vr.js +1 -0
- package/web/{chunk-fpb2dd2d.js → chunk-jke2ev6m.js} +1 -1
- package/web/{chunk-98y92vmh.js → chunk-js6kb05s.js} +1 -1
- package/web/{chunk-30b33r2w.js → chunk-k0cg4n2k.js} +2 -2
- package/web/{chunk-b5h52neg.js → chunk-knm82fw9.js} +1 -1
- package/web/{chunk-vqmj6peg.js → chunk-kxdtg9dt.js} +1 -1
- package/web/{chunk-db3twjvk.js → chunk-m4fxd5d9.js} +5 -5
- package/web/chunk-m9xzt9p7.js +1 -0
- package/web/{chunk-xx11yv61.js → chunk-n4yzs2q0.js} +1 -1
- package/web/{chunk-zdyys4ar.js → chunk-nawxgz87.js} +2 -2
- package/web/chunk-ngt1j8py.js +1139 -0
- package/web/{chunk-3ak5dg10.js → chunk-p55vhns6.js} +1 -1
- package/web/{chunk-nvpp0ghj.js → chunk-pgwf37s2.js} +1 -1
- package/web/{chunk-af9evdza.js → chunk-q4bst4an.js} +1 -1
- package/web/{chunk-9fnr00kv.js → chunk-qdzy124b.js} +2 -2
- package/web/chunk-qe0bgeda.js +1 -0
- package/web/{chunk-60axh4sa.js → chunk-qy1zx2yw.js} +2 -2
- package/web/{chunk-sk1wkgjw.js → chunk-rag65pfs.js} +1 -1
- package/web/{chunk-5jdrev9p.js → chunk-rbqnre6q.js} +3 -3
- package/web/{chunk-ddyyc20r.js → chunk-rh3xb76f.js} +1 -1
- package/web/{chunk-wzd2a4k5.js → chunk-rwfmccmh.js} +1 -1
- package/web/{chunk-zb2bkr7f.js → chunk-rxvm70w5.js} +1 -1
- package/web/{chunk-z05x9cbm.js → chunk-sat7zyva.js} +1 -1
- package/web/{chunk-rrpn5r5w.js → chunk-sc63488q.js} +1 -1
- package/web/{chunk-v1exk5wd.js → chunk-sd3xat3r.js} +6 -6
- package/web/{chunk-4a6gdrbs.js → chunk-se4h6wx0.js} +1 -1
- package/web/{chunk-a0ryzdnp.js → chunk-sjkg40ay.js} +1 -1
- package/web/chunk-sk0hpa80.js +1 -0
- package/web/{chunk-spbs56wz.js → chunk-t5nvgz7z.js} +1 -1
- package/web/{chunk-veam6vk4.js → chunk-tfqarvdx.js} +30 -30
- package/web/{chunk-5a4mj3qz.js → chunk-tqze6d6b.js} +1 -1
- package/web/{chunk-8w7fyb3v.js → chunk-tt93zbn4.js} +7 -7
- package/web/chunk-tvcxrx6h.js +1 -0
- package/web/chunk-tzpnh70q.js +1 -0
- package/web/{chunk-79e08rk1.js → chunk-vasppf6b.js} +1 -1
- package/web/chunk-vb7g4xg6.js +1 -0
- package/web/{chunk-dz7g1gnv.js → chunk-w3zgfhjb.js} +1 -1
- package/web/{chunk-gn8kyz76.js → chunk-wrevb4ew.js} +1 -1
- package/web/{chunk-3ecrkvr3.js → chunk-wtvch4ad.js} +1 -1
- package/web/chunk-wzfe6jtq.js +1 -0
- package/web/{chunk-eadfxfkw.js → chunk-x5g1yy12.js} +1 -1
- package/web/{chunk-m9q5nr8f.js → chunk-x850q01z.js} +1 -1
- package/web/{chunk-a61zrp66.js → chunk-xk904wqv.js} +1 -1
- package/web/{chunk-3hr3ew9w.js → chunk-xtn305fd.js} +1 -1
- package/web/{chunk-3txxt0a7.js → chunk-yekaz74b.js} +1 -1
- package/web/{chunk-rasjtvsb.js → chunk-yppgejg7.js} +2 -2
- package/web/{chunk-66wb0p6e.js → chunk-z4bp6p32.js} +1 -1
- package/web/{chunk-5v2c0aqk.js → chunk-z5qn0xev.js} +1 -1
- package/web/{chunk-5baeh8q7.js → chunk-zms6mrqk.js} +4 -4
- package/web/{chunk-601k823s.js → chunk-zse05v6j.js} +2 -2
- package/web/{chunk-vsjpnwsr.js → chunk-zz1qkaar.js} +1 -1
- package/web/index.html +1 -1
- package/web/chunk-08sq3cwm.js +0 -1
- package/web/chunk-24fjnnee.js +0 -1
- package/web/chunk-2j2atyjw.js +0 -1
- package/web/chunk-3h3g3ca3.js +0 -1
- package/web/chunk-3pcrxg6m.js +0 -1
- package/web/chunk-814kkkmq.js +0 -8
- package/web/chunk-8w8atrdh.js +0 -1
- package/web/chunk-942g3eqn.js +0 -1
- package/web/chunk-avxk6jpc.js +0 -2
- package/web/chunk-fmthkpff.js +0 -1
- package/web/chunk-gv99c8zv.js +0 -1
- package/web/chunk-h0767tjv.js +0 -1
- package/web/chunk-hqynf99g.js +0 -1
- package/web/chunk-mbwwj216.js +0 -1
- package/web/chunk-n0wazxgz.js +0 -1
- package/web/chunk-nvt9tkt4.js +0 -1139
- package/web/chunk-ph1dgffm.js +0 -1
- package/web/chunk-rad2s9ha.js +0 -1
- package/web/chunk-s60s09mb.js +0 -1
- package/web/chunk-tfvcs2xx.js +0 -1
- package/web/chunk-wdq2tp9e.js +0 -1
- package/web/chunk-wkf5xfyr.js +0 -1
- package/web/chunk-y1qty77a.js +0 -1
- package/web/chunk-zgavhnt8.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aa,mi,Pn,Mr,fi,hi,mn}from"./chunk-nvt9tkt4.js";var S=class extends Error{constructor(t){super(t);this.name="ShikiError"}};function tn(t){return Ne(t)}function Ne(t){if(Array.isArray(t))return nn(t);if(t instanceof RegExp)return t;if(typeof t==="object")return rn(t);return t}function nn(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Ne(t[n]);return e}function rn(t){let e={};for(let n in t)e[n]=Ne(t[n]);return e}function Ve(t,...e){return e.forEach((n)=>{for(let r in n)t[r]=n[r]}),t}function Ye(t){let e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");if(e===0)return t;else if(~e===t.length-1)return Ye(t.substring(0,t.length-1));else return t.substr(~e+1)}var ye=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,J=class{static hasCaptures(t){if(t===null)return!1;return ye.lastIndex=0,ye.test(t)}static replaceCaptures(t,e,n){return t.replace(ye,(r,s,i,o)=>{let a=n[parseInt(s||i,10)];if(a){let c=e.substring(a.start,a.end);while(c[0]===".")c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Je(t,e){if(t<e)return-1;if(t>e)return 1;return 0}function Qe(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let i=Je(t[s],e[s]);if(i!==0)return i}return 0}return n-r}function Fe(t){if(/^#[0-9a-f]{6}$/i.test(t))return!0;if(/^#[0-9a-f]{8}$/i.test(t))return!0;if(/^#[0-9a-f]{3}$/i.test(t))return!0;if(/^#[0-9a-f]{4}$/i.test(t))return!0;return!1}function Xe(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Ze=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);let e=this.fn(t);return this.cache.set(t,e),e}},M=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(an(t),e)}static createFromParsedTheme(t,e){return ln(t,e)}_cachedMatchRoot=new Ze((t)=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;let e=t.scopeName,r=this._cachedMatchRoot.get(e).find((s)=>sn(t.parent,s.parentScopes));if(!r)return null;return new et(r.fontStyle,r.foreground,r.background)}},be=class t{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(let r of n)e=new t(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new t(n,e[r]);return n}push(e){return new t(this,e)}getSegments(){let e=this,n=[];while(e)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){if(this===e)return!0;if(this.parent===null)return!1;return this.parent.extends(e)}getExtensionIfDefined(e){let n=[],r=this;while(r&&r!==e)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function sn(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}while(t){if(on(t.scopeName,r))break;if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function on(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var et=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function an(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,i=e.length;s<i;s++){let o=e[s];if(!o.settings)continue;let a;if(typeof o.scope==="string"){let h=o.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else if(Array.isArray(o.scope))a=o.scope;else a=[""];let c=-1;if(typeof o.settings.fontStyle==="string"){c=0;let h=o.settings.fontStyle.split(" ");for(let d=0,f=h.length;d<f;d++)switch(h[d]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;if(typeof o.settings.foreground==="string"&&Fe(o.settings.foreground))l=o.settings.foreground;let u=null;if(typeof o.settings.background==="string"&&Fe(o.settings.background))u=o.settings.background;for(let h=0,d=a.length;h<d;h++){let m=a[h].trim().split(" "),y=m[m.length-1],_=null;if(m.length>1)_=m.slice(0,m.length-1),_.reverse();n[r++]=new cn(y,_,s,c,l,u)}}return n}var cn=class{constructor(t,e,n,r,s,i){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=i}},k=((t)=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(k||{});function ln(t,e){t.sort((c,l)=>{let u=Je(c.scope,l.scope);if(u!==0)return u;if(u=Qe(c.parentScopes,l.parentScopes),u!==0)return u;return c.index-l.index});let n=0,r="#000000",s="#ffffff";while(t.length>=1&&t[0].scope===""){let c=t.shift();if(c.fontStyle!==-1)n=c.fontStyle;if(c.foreground!==null)r=c.foreground;if(c.background!==null)s=c.background}let i=new un(e),o=new et(n,i.getId(r),i.getId(s)),a=new fn(new we(0,null,-1,0,0),[]);for(let c=0,l=t.length;c<l;c++){let u=t[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,i.getId(u.foreground),i.getId(u.background))}return new M(i,o,a)}var un=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},hn=Object.freeze([]),we=class t{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,i){this.scopeDepth=e,this.parentScopes=n||hn,this.fontStyle=r,this.foreground=s,this.background=i}clone(){return new t(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){if(this.scopeDepth>e)console.log("how did this happen?");else this.scopeDepth=e;if(n!==-1)this.fontStyle=n;if(r!==0)this.foreground=r;if(s!==0)this.background=s}},fn=class t{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;while(!0){if(e.parentScopes[r]===">")r++;if(n.parentScopes[s]===">")s++;if(r>=e.parentScopes.length||s>=n.parentScopes.length)break;let i=n.parentScopes[s].length-e.parentScopes[r].length;if(i!==0)return i;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,i;if(r===-1)s=e,i="";else s=e.substring(0,r),i=e.substring(r+1);if(this._children.hasOwnProperty(s))return this._children[s].match(i)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(t._cmpBySpecificity),n}insert(e,n,r,s,i,o){if(n===""){this._doInsertHere(e,r,s,i,o);return}let a=n.indexOf("."),c,l;if(a===-1)c=n,l="";else c=n.substring(0,a),l=n.substring(a+1);let u;if(this._children.hasOwnProperty(c))u=this._children[c];else u=new t(this._mainRule.clone(),we.cloneArr(this._rulesWithParentScopes)),this._children[c]=u;u.insert(e+1,l,r,s,i,o)}_doInsertHere(e,n,r,s,i){if(n===null){this._mainRule.acceptOverwrite(e,r,s,i);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let c=this._rulesWithParentScopes[o];if(Qe(c.parentScopes,n)===0){c.acceptOverwrite(e,r,s,i);return}}if(r===-1)r=this._mainRule.fontStyle;if(s===0)s=this._mainRule.foreground;if(i===0)i=this._mainRule.background;this._rulesWithParentScopes.push(new we(e,n,r,s,i))}},x=class t{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){let n=t.getLanguageId(e),r=t.getTokenType(e),s=t.getFontStyle(e),i=t.getForeground(e),o=t.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:i,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,i,o,a){let c=t.getLanguageId(e),l=t.getTokenType(e),u=t.containsBalancedBrackets(e)?1:0,h=t.getFontStyle(e),d=t.getForeground(e),f=t.getBackground(e);if(n!==0)c=n;if(r!==8)l=gn(r);if(s!==null)u=s?1:0;if(i!==-1)h=i;if(o!==0)d=o;if(a!==0)f=a;return(c<<0|l<<8|u<<10|h<<11|d<<15|f<<24)>>>0}};function dn(t){return t}function gn(t){return t}function X(t,e){let n=[],r=pn(t),s=r.next();while(s!==null){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=o();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function i(){if(s==="-"){s=r.next();let c=i();return(l)=>!!c&&!c(l)}if(s==="("){s=r.next();let c=a();if(s===")")s=r.next();return c}if(De(s)){let c=[];do c.push(s),s=r.next();while(De(s));return(l)=>e(c,l)}return null}function o(){let c=[],l=i();while(l)c.push(l),l=i();return(u)=>c.every((h)=>h(u))}function a(){let c=[],l=o();while(l){if(c.push(l),s==="|"||s===",")do s=r.next();while(s==="|"||s===",");else break;l=o()}return(u)=>c.some((h)=>h(u))}}function De(t){return!!t&&!!t.match(/[\w\.:]+/)}function pn(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;let r=n[0];return n=e.exec(t),r}}}function tt(t){if(typeof t.dispose==="function")t.dispose()}var j=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},_n=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},yn=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){let e=t.toKey();if(this._seenReferenceKeys.has(e))return;this._seenReferenceKeys.add(e),this._references.push(t)}},bn=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new j(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let t=this.Q;this.Q=[];let e=new yn;for(let n of t)Sn(n,this.initialScopeName,this.repo,e);for(let n of e.references)if(n instanceof j){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName))continue;if(this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Sn(t,e,n,r){let s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw Error(`No grammar provided for <${e}>`);return}let i=n.lookup(e);if(t instanceof j)Q({baseGrammar:i,selfGrammar:s},r);else Ce(t.ruleName,{baseGrammar:i,selfGrammar:s,repository:s.repository},r);let o=n.injections(t.scopeName);if(o)for(let a of o)r.add(new j(a))}function Ce(t,e,n){if(e.repository&&e.repository[t]){let r=e.repository[t];Z([r],e,n)}}function Q(t,e){if(t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns))Z(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e);if(t.selfGrammar.injections)Z(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Z(t,e,n){for(let r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let s=r.repository?Ve({},e.repository,r.repository):e.repository;if(Array.isArray(r.patterns))Z(r.patterns,{...e,repository:s},n);let i=r.include;if(!i)continue;let o=nt(i);switch(o.kind){case 0:Q({...e,selfGrammar:e.baseGrammar},n);break;case 1:Q(e,n);break;case 2:Ce(o.ruleName,{...e,repository:s},n);break;case 3:case 4:let a=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){let c={baseGrammar:e.baseGrammar,selfGrammar:a,repository:s};if(o.kind===4)Ce(o.ruleName,c,n);else Q(c,n)}else if(o.kind===4)n.add(new _n(o.scopeName,o.ruleName));else n.add(new j(o.scopeName));break}}}var wn=class{kind=0},Cn=class{kind=1},kn=class{constructor(t){this.ruleName=t}kind=2},Rn=class{constructor(t){this.scopeName=t}kind=3},Nn=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function nt(t){if(t==="$base")return new wn;else if(t==="$self")return new Cn;let e=t.indexOf("#");if(e===-1)return new Rn(t);else if(e===0)return new kn(t.substring(1));else{let n=t.substring(0,e),r=t.substring(e+1);return new Nn(n,r)}}var Tn=/\\(\d+)/,We=/\\(\d+)/g,Ss=Symbol("RuleId"),vn=-1,rt=-2;function st(t){return t}function it(t){return t}var W=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=J.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=J.hasCaptures(this._contentName)}get debugName(){let t=this.$location?`${Ye(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){if(!this._nameIsCapturing||this._name===null||t===null||e===null)return this._name;return J.replaceCaptures(this._name,t,e)}getContentName(t,e){if(!this._contentNameIsCapturing||this._contentName===null)return this._contentName;return J.replaceCaptures(this._contentName,t,e)}},An=class extends W{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r);this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw Error("Not supported!")}compile(t,e){throw Error("Not supported!")}compileAG(t,e,n,r){throw Error("Not supported!")}},En=class extends W{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null);this._match=new F(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new D,this.collectPatterns(t,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},He=class extends W{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r);this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}collectPatterns(t,e){for(let n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new D,this.collectPatterns(t,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},ke=class extends W{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,i,o,a,c,l){super(t,e,n,r);this._begin=new F(s,this.id),this.beginCaptures=i,this._end=new F(o?o:"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new D;for(let n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);if(this.applyEndPatternLast)this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end);else this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}if(this._end.hasBackReferences)if(this.applyEndPatternLast)this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e);else this._cachedCompiledPatterns.setSource(0,e);return this._cachedCompiledPatterns}},ee=class extends W{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,i,o,a,c){super(t,e,n,r);this._begin=new F(s,this.id),this.beginCaptures=i,this.whileCaptures=a,this._while=new F(o,rt),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null;if(this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new D;for(let e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){if(!this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns=new D,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while);if(this._while.hasBackReferences)this._cachedCompiledWhilePatterns.setSource(0,e?e:"");return this._cachedCompiledWhilePatterns}},ot=class t{static createCaptureRule(e,n,r,s,i){return e.registerRule((o)=>new An(n,o,r,s,i))}static getCompiledRuleId(e,n,r){if(!e.id)n.registerRule((s)=>{if(e.id=s,e.match)return new En(e.$vscodeTextmateLocation,e.id,e.name,e.match,t._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){if(e.repository)r=Ve({},r,e.repository);let i=e.patterns;if(typeof i>"u"&&e.include)i=[{include:e.include}];return new He(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,t._compilePatterns(i,n,r))}if(e.while)return new ee(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,t._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,t._compileCaptures(e.whileCaptures||e.captures,n,r),t._compilePatterns(e.patterns,n,r));return new ke(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,t._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,t._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,t._compilePatterns(e.patterns,n,r))});return e.id}static _compileCaptures(e,n,r){let s=[];if(e){let i=0;for(let o in e){if(o==="$vscodeTextmateLocation")continue;let a=parseInt(o,10);if(a>i)i=a}for(let o=0;o<=i;o++)s[o]=null;for(let o in e){if(o==="$vscodeTextmateLocation")continue;let a=parseInt(o,10),c=0;if(e[o].patterns)c=t.getCompiledRuleId(e[o],n,r);s[a]=t.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let i=0,o=e.length;i<o;i++){let a=e[i],c=-1;if(a.include){let l=nt(a.include);switch(l.kind){case 0:case 1:c=t.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];if(u)c=t.getCompiledRuleId(u,n,r);break;case 3:case 4:let h=l.scopeName,d=l.kind===4?l.ruleName:null,f=n.getExternalGrammar(h,r);if(f)if(d){let m=f.repository[d];if(m)c=t.getCompiledRuleId(m,n,f.repository)}else c=t.getCompiledRuleId(f.repository.$self,n,f.repository);break}}else c=t.getCompiledRuleId(a,n,r);if(c!==-1){let l=n.getRule(c),u=!1;if(l instanceof He||l instanceof ke||l instanceof ee){if(l.hasMissingPatterns&&l.patterns.length===0)u=!0}if(u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},F=class t{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e==="string"){let r=e.length,s=0,i=[],o=!1;for(let a=0;a<r;a++)if(e.charAt(a)==="\\"){if(a+1<r){let l=e.charAt(a+1);if(l==="z")i.push(e.substring(s,a)),i.push("$(?!\\n)(?<!\\n)"),s=a+2;else if(l==="A"||l==="G")o=!0;a++}}if(this.hasAnchor=o,s===0)this.source=e;else i.push(e.substring(s,r)),this.source=i.join("")}else this.hasAnchor=!1,this.source=e;if(this.hasAnchor)this._anchorCache=this._buildAnchorCache();else this._anchorCache=null;if(this.ruleId=n,typeof this.source==="string")this.hasBackReferences=Tn.test(this.source);else this.hasBackReferences=!1}clone(){return new t(this.source,this.ruleId)}setSource(e){if(this.source===e)return;if(this.source=e,this.hasAnchor)this._anchorCache=this._buildAnchorCache()}resolveBackReferences(e,n){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let r=n.map((s)=>e.substring(s.start,s.end));return We.lastIndex=0,this.source.replace(We,(s,i)=>Xe(r[parseInt(i,10)]||""))}_buildAnchorCache(){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],i,o,a,c;for(i=0,o=this.source.length;i<o;i++)if(a=this.source.charAt(i),e[i]=a,n[i]=a,r[i]=a,s[i]=a,a==="\\"){if(i+1<o){if(c=this.source.charAt(i+1),c==="A")e[i+1]="",n[i+1]="",r[i+1]="A",s[i+1]="A";else if(c==="G")e[i+1]="",n[i+1]="G",r[i+1]="",s[i+1]="G";else e[i+1]=c,n[i+1]=c,r[i+1]=c,s[i+1]=c;i++}}return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){if(!this.hasAnchor||!this._anchorCache||typeof this.source!=="string")return this.source;if(e)if(n)return this._anchorCache.A1_G1;else return this._anchorCache.A1_G0;else if(n)return this._anchorCache.A0_G1;else return this._anchorCache.A0_G0}},D=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){if(this._cached)this._cached.dispose(),this._cached=null;if(this._anchorCache.A0_G0)this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null;if(this._anchorCache.A0_G1)this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null;if(this._anchorCache.A1_G0)this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null;if(this._anchorCache.A1_G1)this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){if(this._items[t].source!==e)this._disposeCaches(),this._items[t].setSource(e)}compile(t){if(!this._cached){let e=this._items.map((n)=>n.source);this._cached=new qe(t,e,this._items.map((n)=>n.ruleId))}return this._cached}compileAG(t,e,n){if(!this._hasAnchors)return this.compile(t);else if(e)if(n){if(!this._anchorCache.A1_G1)this._anchorCache.A1_G1=this._resolveAnchors(t,e,n);return this._anchorCache.A1_G1}else{if(!this._anchorCache.A1_G0)this._anchorCache.A1_G0=this._resolveAnchors(t,e,n);return this._anchorCache.A1_G0}else if(n){if(!this._anchorCache.A0_G1)this._anchorCache.A0_G1=this._resolveAnchors(t,e,n);return this._anchorCache.A0_G1}else{if(!this._anchorCache.A0_G0)this._anchorCache.A0_G0=this._resolveAnchors(t,e,n);return this._anchorCache.A0_G0}}_resolveAnchors(t,e,n){let r=this._items.map((s)=>s.resolveAnchors(e,n));return new qe(t,r,this._items.map((s)=>s.ruleId))}},qe=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){if(typeof this.scanner.dispose==="function")this.scanner.dispose()}toString(){let t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
1
|
+
import{aa,mi,Pn,Mr,fi,hi,mn}from"./chunk-ngt1j8py.js";var S=class extends Error{constructor(t){super(t);this.name="ShikiError"}};function tn(t){return Ne(t)}function Ne(t){if(Array.isArray(t))return nn(t);if(t instanceof RegExp)return t;if(typeof t==="object")return rn(t);return t}function nn(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Ne(t[n]);return e}function rn(t){let e={};for(let n in t)e[n]=Ne(t[n]);return e}function Ve(t,...e){return e.forEach((n)=>{for(let r in n)t[r]=n[r]}),t}function Ye(t){let e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");if(e===0)return t;else if(~e===t.length-1)return Ye(t.substring(0,t.length-1));else return t.substr(~e+1)}var ye=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,J=class{static hasCaptures(t){if(t===null)return!1;return ye.lastIndex=0,ye.test(t)}static replaceCaptures(t,e,n){return t.replace(ye,(r,s,i,o)=>{let a=n[parseInt(s||i,10)];if(a){let c=e.substring(a.start,a.end);while(c[0]===".")c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function Je(t,e){if(t<e)return-1;if(t>e)return 1;return 0}function Qe(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let i=Je(t[s],e[s]);if(i!==0)return i}return 0}return n-r}function Fe(t){if(/^#[0-9a-f]{6}$/i.test(t))return!0;if(/^#[0-9a-f]{8}$/i.test(t))return!0;if(/^#[0-9a-f]{3}$/i.test(t))return!0;if(/^#[0-9a-f]{4}$/i.test(t))return!0;return!1}function Xe(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Ze=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);let e=this.fn(t);return this.cache.set(t,e),e}},M=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(an(t),e)}static createFromParsedTheme(t,e){return ln(t,e)}_cachedMatchRoot=new Ze((t)=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;let e=t.scopeName,r=this._cachedMatchRoot.get(e).find((s)=>sn(t.parent,s.parentScopes));if(!r)return null;return new et(r.fontStyle,r.foreground,r.background)}},be=class t{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(let r of n)e=new t(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new t(n,e[r]);return n}push(e){return new t(this,e)}getSegments(){let e=this,n=[];while(e)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){if(this===e)return!0;if(this.parent===null)return!1;return this.parent.extends(e)}getExtensionIfDefined(e){let n=[],r=this;while(r&&r!==e)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function sn(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}while(t){if(on(t.scopeName,r))break;if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function on(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var et=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function an(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,i=e.length;s<i;s++){let o=e[s];if(!o.settings)continue;let a;if(typeof o.scope==="string"){let h=o.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else if(Array.isArray(o.scope))a=o.scope;else a=[""];let c=-1;if(typeof o.settings.fontStyle==="string"){c=0;let h=o.settings.fontStyle.split(" ");for(let d=0,f=h.length;d<f;d++)switch(h[d]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;if(typeof o.settings.foreground==="string"&&Fe(o.settings.foreground))l=o.settings.foreground;let u=null;if(typeof o.settings.background==="string"&&Fe(o.settings.background))u=o.settings.background;for(let h=0,d=a.length;h<d;h++){let m=a[h].trim().split(" "),y=m[m.length-1],_=null;if(m.length>1)_=m.slice(0,m.length-1),_.reverse();n[r++]=new cn(y,_,s,c,l,u)}}return n}var cn=class{constructor(t,e,n,r,s,i){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=i}},k=((t)=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(k||{});function ln(t,e){t.sort((c,l)=>{let u=Je(c.scope,l.scope);if(u!==0)return u;if(u=Qe(c.parentScopes,l.parentScopes),u!==0)return u;return c.index-l.index});let n=0,r="#000000",s="#ffffff";while(t.length>=1&&t[0].scope===""){let c=t.shift();if(c.fontStyle!==-1)n=c.fontStyle;if(c.foreground!==null)r=c.foreground;if(c.background!==null)s=c.background}let i=new un(e),o=new et(n,i.getId(r),i.getId(s)),a=new fn(new we(0,null,-1,0,0),[]);for(let c=0,l=t.length;c<l;c++){let u=t[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,i.getId(u.foreground),i.getId(u.background))}return new M(i,o,a)}var un=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},hn=Object.freeze([]),we=class t{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,i){this.scopeDepth=e,this.parentScopes=n||hn,this.fontStyle=r,this.foreground=s,this.background=i}clone(){return new t(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){if(this.scopeDepth>e)console.log("how did this happen?");else this.scopeDepth=e;if(n!==-1)this.fontStyle=n;if(r!==0)this.foreground=r;if(s!==0)this.background=s}},fn=class t{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;while(!0){if(e.parentScopes[r]===">")r++;if(n.parentScopes[s]===">")s++;if(r>=e.parentScopes.length||s>=n.parentScopes.length)break;let i=n.parentScopes[s].length-e.parentScopes[r].length;if(i!==0)return i;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,i;if(r===-1)s=e,i="";else s=e.substring(0,r),i=e.substring(r+1);if(this._children.hasOwnProperty(s))return this._children[s].match(i)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(t._cmpBySpecificity),n}insert(e,n,r,s,i,o){if(n===""){this._doInsertHere(e,r,s,i,o);return}let a=n.indexOf("."),c,l;if(a===-1)c=n,l="";else c=n.substring(0,a),l=n.substring(a+1);let u;if(this._children.hasOwnProperty(c))u=this._children[c];else u=new t(this._mainRule.clone(),we.cloneArr(this._rulesWithParentScopes)),this._children[c]=u;u.insert(e+1,l,r,s,i,o)}_doInsertHere(e,n,r,s,i){if(n===null){this._mainRule.acceptOverwrite(e,r,s,i);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let c=this._rulesWithParentScopes[o];if(Qe(c.parentScopes,n)===0){c.acceptOverwrite(e,r,s,i);return}}if(r===-1)r=this._mainRule.fontStyle;if(s===0)s=this._mainRule.foreground;if(i===0)i=this._mainRule.background;this._rulesWithParentScopes.push(new we(e,n,r,s,i))}},x=class t{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){let n=t.getLanguageId(e),r=t.getTokenType(e),s=t.getFontStyle(e),i=t.getForeground(e),o=t.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:i,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,i,o,a){let c=t.getLanguageId(e),l=t.getTokenType(e),u=t.containsBalancedBrackets(e)?1:0,h=t.getFontStyle(e),d=t.getForeground(e),f=t.getBackground(e);if(n!==0)c=n;if(r!==8)l=gn(r);if(s!==null)u=s?1:0;if(i!==-1)h=i;if(o!==0)d=o;if(a!==0)f=a;return(c<<0|l<<8|u<<10|h<<11|d<<15|f<<24)>>>0}};function dn(t){return t}function gn(t){return t}function X(t,e){let n=[],r=pn(t),s=r.next();while(s!==null){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=o();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function i(){if(s==="-"){s=r.next();let c=i();return(l)=>!!c&&!c(l)}if(s==="("){s=r.next();let c=a();if(s===")")s=r.next();return c}if(De(s)){let c=[];do c.push(s),s=r.next();while(De(s));return(l)=>e(c,l)}return null}function o(){let c=[],l=i();while(l)c.push(l),l=i();return(u)=>c.every((h)=>h(u))}function a(){let c=[],l=o();while(l){if(c.push(l),s==="|"||s===",")do s=r.next();while(s==="|"||s===",");else break;l=o()}return(u)=>c.some((h)=>h(u))}}function De(t){return!!t&&!!t.match(/[\w\.:]+/)}function pn(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;let r=n[0];return n=e.exec(t),r}}}function tt(t){if(typeof t.dispose==="function")t.dispose()}var j=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},_n=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},yn=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){let e=t.toKey();if(this._seenReferenceKeys.has(e))return;this._seenReferenceKeys.add(e),this._references.push(t)}},bn=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new j(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let t=this.Q;this.Q=[];let e=new yn;for(let n of t)Sn(n,this.initialScopeName,this.repo,e);for(let n of e.references)if(n instanceof j){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName))continue;if(this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Sn(t,e,n,r){let s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw Error(`No grammar provided for <${e}>`);return}let i=n.lookup(e);if(t instanceof j)Q({baseGrammar:i,selfGrammar:s},r);else Ce(t.ruleName,{baseGrammar:i,selfGrammar:s,repository:s.repository},r);let o=n.injections(t.scopeName);if(o)for(let a of o)r.add(new j(a))}function Ce(t,e,n){if(e.repository&&e.repository[t]){let r=e.repository[t];Z([r],e,n)}}function Q(t,e){if(t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns))Z(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e);if(t.selfGrammar.injections)Z(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Z(t,e,n){for(let r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let s=r.repository?Ve({},e.repository,r.repository):e.repository;if(Array.isArray(r.patterns))Z(r.patterns,{...e,repository:s},n);let i=r.include;if(!i)continue;let o=nt(i);switch(o.kind){case 0:Q({...e,selfGrammar:e.baseGrammar},n);break;case 1:Q(e,n);break;case 2:Ce(o.ruleName,{...e,repository:s},n);break;case 3:case 4:let a=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){let c={baseGrammar:e.baseGrammar,selfGrammar:a,repository:s};if(o.kind===4)Ce(o.ruleName,c,n);else Q(c,n)}else if(o.kind===4)n.add(new _n(o.scopeName,o.ruleName));else n.add(new j(o.scopeName));break}}}var wn=class{kind=0},Cn=class{kind=1},kn=class{constructor(t){this.ruleName=t}kind=2},Rn=class{constructor(t){this.scopeName=t}kind=3},Nn=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function nt(t){if(t==="$base")return new wn;else if(t==="$self")return new Cn;let e=t.indexOf("#");if(e===-1)return new Rn(t);else if(e===0)return new kn(t.substring(1));else{let n=t.substring(0,e),r=t.substring(e+1);return new Nn(n,r)}}var Tn=/\\(\d+)/,We=/\\(\d+)/g,Ss=Symbol("RuleId"),vn=-1,rt=-2;function st(t){return t}function it(t){return t}var W=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=J.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=J.hasCaptures(this._contentName)}get debugName(){let t=this.$location?`${Ye(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){if(!this._nameIsCapturing||this._name===null||t===null||e===null)return this._name;return J.replaceCaptures(this._name,t,e)}getContentName(t,e){if(!this._contentNameIsCapturing||this._contentName===null)return this._contentName;return J.replaceCaptures(this._contentName,t,e)}},An=class extends W{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r);this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw Error("Not supported!")}compile(t,e){throw Error("Not supported!")}compileAG(t,e,n,r){throw Error("Not supported!")}},En=class extends W{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null);this._match=new F(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new D,this.collectPatterns(t,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},He=class extends W{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r);this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}collectPatterns(t,e){for(let n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns)this._cachedCompiledPatterns=new D,this.collectPatterns(t,this._cachedCompiledPatterns);return this._cachedCompiledPatterns}},ke=class extends W{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,i,o,a,c,l){super(t,e,n,r);this._begin=new F(s,this.id),this.beginCaptures=i,this._end=new F(o?o:"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new D;for(let n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);if(this.applyEndPatternLast)this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end);else this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}if(this._end.hasBackReferences)if(this.applyEndPatternLast)this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e);else this._cachedCompiledPatterns.setSource(0,e);return this._cachedCompiledPatterns}},ee=class extends W{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,i,o,a,c){super(t,e,n,r);this._begin=new F(s,this.id),this.beginCaptures=i,this.whileCaptures=a,this._while=new F(o,rt),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){if(this._cachedCompiledPatterns)this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null;if(this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new D;for(let e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){if(!this._cachedCompiledWhilePatterns)this._cachedCompiledWhilePatterns=new D,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while);if(this._while.hasBackReferences)this._cachedCompiledWhilePatterns.setSource(0,e?e:"");return this._cachedCompiledWhilePatterns}},ot=class t{static createCaptureRule(e,n,r,s,i){return e.registerRule((o)=>new An(n,o,r,s,i))}static getCompiledRuleId(e,n,r){if(!e.id)n.registerRule((s)=>{if(e.id=s,e.match)return new En(e.$vscodeTextmateLocation,e.id,e.name,e.match,t._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){if(e.repository)r=Ve({},r,e.repository);let i=e.patterns;if(typeof i>"u"&&e.include)i=[{include:e.include}];return new He(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,t._compilePatterns(i,n,r))}if(e.while)return new ee(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,t._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,t._compileCaptures(e.whileCaptures||e.captures,n,r),t._compilePatterns(e.patterns,n,r));return new ke(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,t._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,t._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,t._compilePatterns(e.patterns,n,r))});return e.id}static _compileCaptures(e,n,r){let s=[];if(e){let i=0;for(let o in e){if(o==="$vscodeTextmateLocation")continue;let a=parseInt(o,10);if(a>i)i=a}for(let o=0;o<=i;o++)s[o]=null;for(let o in e){if(o==="$vscodeTextmateLocation")continue;let a=parseInt(o,10),c=0;if(e[o].patterns)c=t.getCompiledRuleId(e[o],n,r);s[a]=t.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let i=0,o=e.length;i<o;i++){let a=e[i],c=-1;if(a.include){let l=nt(a.include);switch(l.kind){case 0:case 1:c=t.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];if(u)c=t.getCompiledRuleId(u,n,r);break;case 3:case 4:let h=l.scopeName,d=l.kind===4?l.ruleName:null,f=n.getExternalGrammar(h,r);if(f)if(d){let m=f.repository[d];if(m)c=t.getCompiledRuleId(m,n,f.repository)}else c=t.getCompiledRuleId(f.repository.$self,n,f.repository);break}}else c=t.getCompiledRuleId(a,n,r);if(c!==-1){let l=n.getRule(c),u=!1;if(l instanceof He||l instanceof ke||l instanceof ee){if(l.hasMissingPatterns&&l.patterns.length===0)u=!0}if(u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},F=class t{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e==="string"){let r=e.length,s=0,i=[],o=!1;for(let a=0;a<r;a++)if(e.charAt(a)==="\\"){if(a+1<r){let l=e.charAt(a+1);if(l==="z")i.push(e.substring(s,a)),i.push("$(?!\\n)(?<!\\n)"),s=a+2;else if(l==="A"||l==="G")o=!0;a++}}if(this.hasAnchor=o,s===0)this.source=e;else i.push(e.substring(s,r)),this.source=i.join("")}else this.hasAnchor=!1,this.source=e;if(this.hasAnchor)this._anchorCache=this._buildAnchorCache();else this._anchorCache=null;if(this.ruleId=n,typeof this.source==="string")this.hasBackReferences=Tn.test(this.source);else this.hasBackReferences=!1}clone(){return new t(this.source,this.ruleId)}setSource(e){if(this.source===e)return;if(this.source=e,this.hasAnchor)this._anchorCache=this._buildAnchorCache()}resolveBackReferences(e,n){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let r=n.map((s)=>e.substring(s.start,s.end));return We.lastIndex=0,this.source.replace(We,(s,i)=>Xe(r[parseInt(i,10)]||""))}_buildAnchorCache(){if(typeof this.source!=="string")throw Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],i,o,a,c;for(i=0,o=this.source.length;i<o;i++)if(a=this.source.charAt(i),e[i]=a,n[i]=a,r[i]=a,s[i]=a,a==="\\"){if(i+1<o){if(c=this.source.charAt(i+1),c==="A")e[i+1]="",n[i+1]="",r[i+1]="A",s[i+1]="A";else if(c==="G")e[i+1]="",n[i+1]="G",r[i+1]="",s[i+1]="G";else e[i+1]=c,n[i+1]=c,r[i+1]=c,s[i+1]=c;i++}}return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){if(!this.hasAnchor||!this._anchorCache||typeof this.source!=="string")return this.source;if(e)if(n)return this._anchorCache.A1_G1;else return this._anchorCache.A1_G0;else if(n)return this._anchorCache.A0_G1;else return this._anchorCache.A0_G0}},D=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){if(this._cached)this._cached.dispose(),this._cached=null;if(this._anchorCache.A0_G0)this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null;if(this._anchorCache.A0_G1)this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null;if(this._anchorCache.A1_G0)this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null;if(this._anchorCache.A1_G1)this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){if(this._items[t].source!==e)this._disposeCaches(),this._items[t].setSource(e)}compile(t){if(!this._cached){let e=this._items.map((n)=>n.source);this._cached=new qe(t,e,this._items.map((n)=>n.ruleId))}return this._cached}compileAG(t,e,n){if(!this._hasAnchors)return this.compile(t);else if(e)if(n){if(!this._anchorCache.A1_G1)this._anchorCache.A1_G1=this._resolveAnchors(t,e,n);return this._anchorCache.A1_G1}else{if(!this._anchorCache.A1_G0)this._anchorCache.A1_G0=this._resolveAnchors(t,e,n);return this._anchorCache.A1_G0}else if(n){if(!this._anchorCache.A0_G1)this._anchorCache.A0_G1=this._resolveAnchors(t,e,n);return this._anchorCache.A0_G1}else{if(!this._anchorCache.A0_G0)this._anchorCache.A0_G0=this._resolveAnchors(t,e,n);return this._anchorCache.A0_G0}}_resolveAnchors(t,e,n){let r=this._items.map((s)=>s.resolveAnchors(e,n));return new qe(t,r,this._items.map((s)=>s.ruleId))}},qe=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){if(typeof this.scanner.dispose==="function")this.scanner.dispose()}toString(){let t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
|
|
2
2
|
`)}findNextMatchSync(t,e,n){let r=this.scanner.findNextMatchSync(t,e,n);if(!r)return null;return{ruleId:this.rules[r.index],captureIndices:r.captureIndices}}},Se=class{constructor(t,e){this.languageId=t,this.tokenType=e}},xn=class t{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new Se(e,8),this._embeddedLanguagesMatcher=new In(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){if(e===null)return t._NULL_SCOPE_METADATA;return this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new Se(0,0);_getBasicScopeAttributes=new Ze((e)=>{let n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new Se(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){let n=e.match(t.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},In=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);let e=t.map(([n,r])=>Xe(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;let e=t.match(this.scopesRegExp);if(!e)return;return this.values.get(e[1])}},ws={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},at=!1,ze=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function ct(t,e,n,r,s,i,o,a){let c=e.content.length,l=!1,u=-1;if(o){let f=Ln(t,e,n,r,s,i);s=f.stack,r=f.linePos,n=f.isFirstLine,u=f.anchorPosition}let h=Date.now();while(!l){if(a!==0){if(Date.now()-h>a)return new ze(s,!0)}d()}return new ze(s,!1);function d(){let f=Gn(t,e,n,r,s,u);if(!f){i.produce(s,c),l=!0;return}let{captureIndices:m,matchedRuleId:y}=f,_=m&&m.length>0?m[0].end>r:!1;if(y===vn){let p=s.getRule(t);i.produce(s,m[0].start),s=s.withContentNameScopesList(s.nameScopesList),B(t,e,n,s,i,p.endCaptures,m),i.produce(s,m[0].end);let g=s;if(s=s.parent,u=g.getAnchorPos(),!_&&g.getEnterPos()===r){s=g,i.produce(s,c),l=!0;return}}else{let p=t.getRule(y);i.produce(s,m[0].start);let g=s,b=p.getName(e.content,m),C=s.contentNameScopesList.pushAttributed(b,t);if(s=s.push(y,r,u,m[0].end===c,null,C,C),p instanceof ke){let R=p;B(t,e,n,s,i,R.beginCaptures,m),i.produce(s,m[0].end),u=m[0].end;let N=R.getContentName(e.content,m),E=C.pushAttributed(N,t);if(s=s.withContentNameScopesList(E),R.endHasBackReferences)s=s.withEndRule(R.getEndWithResolvedBackReferences(e.content,m));if(!_&&g.hasSameRuleAs(s)){s=s.pop(),i.produce(s,c),l=!0;return}}else if(p instanceof ee){let R=p;B(t,e,n,s,i,R.beginCaptures,m),i.produce(s,m[0].end),u=m[0].end;let N=R.getContentName(e.content,m),E=C.pushAttributed(N,t);if(s=s.withContentNameScopesList(E),R.whileHasBackReferences)s=s.withEndRule(R.getWhileWithResolvedBackReferences(e.content,m));if(!_&&g.hasSameRuleAs(s)){s=s.pop(),i.produce(s,c),l=!0;return}}else if(B(t,e,n,s,i,p.captures,m),i.produce(s,m[0].end),s=s.pop(),!_){s=s.safePop(),i.produce(s,c),l=!0;return}}if(m[0].end>r)r=m[0].end,n=!1}}function Ln(t,e,n,r,s,i){let o=s.beginRuleCapturedEOL?0:-1,a=[];for(let c=s;c;c=c.pop()){let l=c.getRule(t);if(l instanceof ee)a.push({rule:l,stack:c})}for(let c=a.pop();c;c=a.pop()){let{ruleScanner:l,findOptions:u}=$n(c.rule,t,c.stack.endRule,n,r===o),h=l.findNextMatchSync(e,r,u);if(h){if(h.ruleId!==rt){s=c.stack.pop();break}if(h.captureIndices&&h.captureIndices.length){if(i.produce(c.stack,h.captureIndices[0].start),B(t,e,n,c.stack,i,c.rule.whileCaptures,h.captureIndices),i.produce(c.stack,h.captureIndices[0].end),o=h.captureIndices[0].end,h.captureIndices[0].end>r)r=h.captureIndices[0].end,n=!1}}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:o,isFirstLine:n}}function Gn(t,e,n,r,s,i){let o=Bn(t,e,n,r,s,i),a=t.getInjections();if(a.length===0)return o;let c=On(a,t,e,n,r,s,i);if(!c)return o;if(!o)return c;let l=o.captureIndices[0].start,u=c.captureIndices[0].start;if(u<l||c.priorityMatch&&u===l)return c;return o}function Bn(t,e,n,r,s,i){let o=s.getRule(t),{ruleScanner:a,findOptions:c}=lt(o,t,s.endRule,n,r===i),l=a.findNextMatchSync(e,r,c);if(l)return{captureIndices:l.captureIndices,matchedRuleId:l.ruleId};return null}function On(t,e,n,r,s,i,o){let a=Number.MAX_VALUE,c=null,l,u=0,h=i.contentNameScopesList.getScopeNames();for(let d=0,f=t.length;d<f;d++){let m=t[d];if(!m.matcher(h))continue;let y=e.getRule(m.ruleId),{ruleScanner:_,findOptions:p}=lt(y,e,null,r,s===o),g=_.findNextMatchSync(n,s,p);if(!g)continue;let b=g.captureIndices[0].start;if(b>=a)continue;if(a=b,c=g.captureIndices,l=g.ruleId,u=m.priority,a===s)break}if(c)return{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l};return null}function lt(t,e,n,r,s){if(at){let o=t.compile(e,n),a=ut(r,s);return{ruleScanner:o,findOptions:a}}return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function $n(t,e,n,r,s){if(at){let o=t.compileWhile(e,n),a=ut(r,s);return{ruleScanner:o,findOptions:a}}return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function ut(t,e){let n=0;if(!t)n|=1;if(!e)n|=4;return n}function B(t,e,n,r,s,i,o){if(i.length===0)return;let a=e.content,c=Math.min(i.length,o.length),l=[],u=o[0].end;for(let h=0;h<c;h++){let d=i[h];if(d===null)continue;let f=o[h];if(f.length===0)continue;if(f.start>u)break;while(l.length>0&&l[l.length-1].endPos<=f.start)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0)s.produceFromScopes(l[l.length-1].scopes,f.start);else s.produce(r,f.start);if(d.retokenizeCapturedWithRuleId){let y=d.getName(a,o),_=r.contentNameScopesList.pushAttributed(y,t),p=d.getContentName(a,o),g=_.pushAttributed(p,t),b=r.push(d.retokenizeCapturedWithRuleId,f.start,-1,!1,null,_,g),C=t.createOnigString(a.substring(0,f.end));ct(t,C,n&&f.start===0,f.start,b,s,!1,0),tt(C);continue}let m=d.getName(a,o);if(m!==null){let _=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(m,t);l.push(new Mn(_,f.end))}}while(l.length>0)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Mn=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function jn(t,e,n,r,s,i,o,a){return new Dn(t,e,n,r,s,i,o,a)}function Ue(t,e,n,r,s){let i=X(e,te),o=ot.getCompiledRuleId(n,r,s.repository);for(let a of i)t.push({debugSelector:e,matcher:a.matcher,ruleId:o,grammar:s,priority:a.priority})}function te(t,e){if(e.length<t.length)return!1;let n=0;return t.every((r)=>{for(let s=n;s<e.length;s++)if(Fn(e[s],r))return n=s+1,!0;return!1})}function Fn(t,e){if(!t)return!1;if(t===e)return!0;let n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var Dn=class{constructor(t,e,n,r,s,i,o,a){if(this._rootScopeName=t,this.balancedBracketSelectors=i,this._onigLib=a,this._basicScopeAttributesProvider=new xn(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=Ke(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(let c of Object.keys(s)){let l=X(c,te);for(let u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let t of this._ruleId2desc)if(t)t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){let t={lookup:(s)=>{if(s===this._rootScopeName)return this._grammar;return this.getExternalGrammar(s)},injections:(s)=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){let s=r.injections;if(s)for(let o in s)Ue(e,o,s[o],this,r);let i=this._grammarRepository.injections(n);if(i)i.forEach((o)=>{let a=this.getExternalGrammar(o);if(a){let c=a.injectionSelector;if(c)Ue(e,c,a,this,a)}})}return e.sort((s,i)=>s.priority-i.priority),e}getInjections(){if(this._injections===null)this._injections=this._collectInjections();return this._injections}registerRule(t){let e=++this._lastRuleId,n=t(st(e));return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[it(t)]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];else if(this._grammarRepository){let n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=Ke(n,e&&e.$base),this._includedGrammars[t]}return}tokenizeLine(t,e,n=0){let r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){let r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){if(this._rootId===-1)this._rootId=ot.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections();let s;if(!e||e===Re.NULL){s=!0;let l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=x.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),d=this.getRule(this._rootId).getName(null,null),f;if(d)f=O.createRootAndLookUpScopeName(d,h,this);else f=O.createRoot("unknown",h);e=new Re(null,this._rootId,-1,-1,!1,null,f,f)}else s=!1,e.reset();t=t+`
|
|
3
3
|
`;let i=this.createOnigString(t),o=i.content.length,a=new Hn(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=ct(this,i,s,0,e,a,!0,r);return tt(i),{lineLength:o,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Ke(t,e){return t=tn(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var O=class t{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(let i of n)s=be.push(s,i.scopeNames),r=new t(r,s,i.encodedTokenAttributes);return r}static createRoot(e,n){return new t(null,new be(null,e),n)}static createRootAndLookUpScopeName(e,n,r){let s=r.getMetadataForScope(e),i=new be(null,e),o=r.themeProvider.themeMatch(i),a=t.mergeAttributes(n,s,o);return new t(null,i,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return t.equals(this,e)}static equals(e,n){do{if(e===n)return!0;if(!e&&!n)return!0;if(!e||!n)return!1;if(e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,i=0,o=0;if(r!==null)s=r.fontStyle,i=r.foregroundId,o=r.backgroundId;return x.set(e,n.languageId,n.tokenType,null,s,i,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return t._pushAttributed(this,e,n);let r=e.split(/ /g),s=this;for(let i of r)s=t._pushAttributed(s,i,n);return s}static _pushAttributed(e,n,r){let s=r.getMetadataForScope(n),i=e.scopePath.push(n),o=r.themeProvider.themeMatch(i),a=t.mergeAttributes(e.tokenAttributes,s,o);return new t(e,i,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){let n=[],r=this;while(r&&r!==e)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},Re=class t{constructor(e,n,r,s,i,o,a,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=i,this.endRule=o,this.nameScopesList=a,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new t(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){if(e===null)return!1;return t._equals(this,e)}static _equals(e,n){if(e===n)return!0;if(!this._structuralEquals(e,n))return!1;return O.equals(e.contentNameScopesList,n.contentNameScopesList)}static _structuralEquals(e,n){do{if(e===n)return!0;if(!e&&!n)return!0;if(!e||!n)return!1;if(e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){while(e)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){t._reset(this)}pop(){return this.parent}safePop(){if(this.parent)return this.parent;return this}push(e,n,r,s,i,o,a){return new t(this,e,n,r,s,i,o,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){let e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){if(this.parent)n=this.parent._writeString(e,n);return e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){if(this.contentNameScopesList===e)return this;return this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){if(this.endRule===e)return this;return new t(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;while(n&&n._enterPos===e._enterPos){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:it(this.ruleId),beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){let r=O.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new t(e,st(n.ruleId),n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,O.fromExtension(r,n.contentNameScopesList))}},Wn=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap((n)=>{if(n==="*")return this.allowAny=!0,[];return X(n,te).map((r)=>r.matcher)}),this.unbalancedBracketScopes=e.flatMap((n)=>X(n,te).map((r)=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(let e of this.unbalancedBracketScopes)if(e(t))return!1;for(let e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},Hn=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways)s=!0;if(this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let i=t?.getScopeNames()??[];for(let o of this._tokenTypeOverrides)if(o.matcher(i))r=x.set(r,0,dn(o.type),null,-1,0,0);if(this.balancedBracketSelectors)s=this.balancedBracketSelectors.match(i)}if(s)r=x.set(r,0,8,s,-1,0,0);if(this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}let n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){if(this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1)this._tokens.pop();if(this._tokens.length===0)this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0;return this._tokens}getBinaryResult(t,e){if(this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1)this._binaryTokens.pop(),this._binaryTokens.pop();if(this._binaryTokens.length===0)this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0;let n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},qn=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){if(this._rawGrammars.set(t.scopeName,t),e)this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let i=this._rawGrammars.get(t);if(!i)return null;this._grammars.set(t,jn(t,i,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},ht=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new qn(M.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,e){this._syncRegistry.setTheme(M.createFromRawTheme(t,e))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,e,n){return this.loadGrammarWithConfiguration(t,e,{embeddedLanguages:n})}loadGrammarWithConfiguration(t,e,n){return this._loadGrammar(t,e,n.embeddedLanguages,n.tokenTypes,new Wn(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,e,n,r,s){let i=new bn(this._syncRegistry,t);while(i.Q.length>0)i.Q.map((o)=>this._loadSingleGrammar(o.scopeName)),i.processQueue();return this._grammarForScopeName(t,e,n,r,s)}_loadSingleGrammar(t){if(!this._ensureGrammarCache.has(t))this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0)}_doLoadSingleGrammar(t){let e=this._options.loadGrammar(t);if(e){let n=typeof this._options.getInjections==="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(e,n)}}addGrammar(t,e=[],n=0,r=null){return this._syncRegistry.addGrammar(t,e),this._grammarForScopeName(t.scopeName,n,r)}_grammarForScopeName(t,e=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(t,e,n,r,s)}},ne=Re.NULL;function q(t,e){let n=typeof t==="string"?{}:{...t.colorReplacements},r=typeof t==="string"?t:t.name;for(let[s,i]of Object.entries(e?.colorReplacements||{}))if(typeof i==="string")n[s]=i;else if(s===r)Object.assign(n,i);return n}function v(t,e){if(!t)return t;return e?.[t?.toLowerCase()]||t}function pt(t){return Array.isArray(t)?t:[t]}async function Te(t){return Promise.resolve(typeof t==="function"?t():t).then((e)=>e.default||e)}function z(t){return!t||["plaintext","txt","text","plain"].includes(t)}function _t(t){return t==="ansi"||z(t)}function U(t){return t==="none"}function yt(t){return U(t)}var zn=/(\r?\n)/g;function P(t,e=!1){if(t.length===0)return[["",0]];let n=t.split(zn),r=0,s=[];for(let i=0;i<n.length;i+=2){let o=e?n[i]+(n[i+1]||""):n[i];s.push([o,r]),r+=n[i].length,r+=n[i+1]?.length||0}return s}var ft={light:"#333333",dark:"#bbbbbb"},dt={light:"#fffffe",dark:"#1e1e1e"},mt="__shiki_resolved";function re(t){if(t?.[mt])return t;let e={...t};if(e.tokenColors&&!e.settings)e.settings=e.tokenColors,delete e.tokenColors;e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){let a=e.settings?e.settings.find((c)=>!c.name&&!c.scope):void 0;if(a?.settings?.foreground)r=a.settings.foreground;if(a?.settings?.background)n=a.settings.background;if(!r&&e?.colors?.["editor.foreground"])r=e.colors["editor.foreground"];if(!n&&e?.colors?.["editor.background"])n=e.colors["editor.background"];if(!r)r=e.type==="light"?ft.light:ft.dark;if(!n)n=e.type==="light"?dt.light:dt.dark;e.fg=r,e.bg=n}if(!(e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope))e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0,i=new Map;function o(a){if(i.has(a))return i.get(a);s+=1;let c=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;if(e.colorReplacements?.[`#${c}`])return o(a);return i.set(a,c),c}e.settings=e.settings.map((a)=>{let c=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),l=a.settings?.background&&!a.settings.background.startsWith("#");if(!c&&!l)return a;let u={...a,settings:{...a.settings}};if(c){let h=o(a.settings.foreground);e.colorReplacements[h]=a.settings.foreground,u.settings.foreground=h}if(l){let h=o(a.settings.background);e.colorReplacements[h]=a.settings.background,u.settings.background=h}return u});for(let a of Object.keys(e.colors||{}))if(a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi")){if(!e.colors[a]?.startsWith("#")){let c=o(e.colors[a]);e.colorReplacements[c]=e.colors[a],e.colors[a]=c}}return Object.defineProperty(e,mt,{enumerable:!1,writable:!1,value:!0}),e}async function bt(t){return[...new Set((await Promise.all(t.filter((e)=>!_t(e)).map(async(e)=>await Te(e).then((n)=>Array.isArray(n)?n:[n])))).flat())]}async function St(t){return(await Promise.all(t.map(async(e)=>yt(e)?null:re(await Te(e))))).filter((e)=>!!e)}function wt(t,e){if(!e)return t;if(e[t]){let n=new Set([t]);while(e[t]){if(t=e[t],n.has(t))throw new S(`Circular alias \`${[...n].join(" -> ")} -> ${t}\``);n.add(t)}}return t}var Un=class extends ht{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(t,e,n,r={}){super(t);this._resolver=t,this._themes=e,this._langs=n,this._alias=r,this._themes.map((s)=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(t){if(typeof t==="string")return this._resolvedThemes.get(t);else return this.loadTheme(t)}loadTheme(t){let e=re(t);if(e.name)this._resolvedThemes.set(e.name,e),this._loadedThemesCache=null;return e}getLoadedThemes(){if(!this._loadedThemesCache)this._loadedThemesCache=[...this._resolvedThemes.keys()];return this._loadedThemesCache}setTheme(t){let e=this._textmateThemeCache.get(t);if(!e)e=M.createFromRawTheme(t),this._textmateThemeCache.set(t,e);this._syncRegistry.setTheme(e)}getGrammar(t){return t=wt(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let e=new Set([...this._langMap.values()].filter((s)=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let n={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,n);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases)t.aliases.forEach((s)=>{this._alias[s]=t.name});if(this._loadedLanguagesCache=null,e.size)for(let s of e)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let e=[...this._langGraph.entries()],n=e.filter(([r,s])=>!s);if(n.length){let r=e.filter(([s,i])=>{if(!i)return!1;return(i.embeddedLanguages||i.embeddedLangs)?.some((o)=>n.map(([a])=>a).includes(o))}).filter((s)=>!n.includes(s));throw new S(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of e)this._resolver.addLanguage(s);for(let[r,s]of e)this.loadLanguage(s)}getLoadedLanguages(){if(!this._loadedLanguagesCache)this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])];return this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let e=t.embeddedLanguages??t.embeddedLangs;if(e)for(let n of e)this._langGraph.set(n,this._langMap.get(n))}},Kn=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,e){this._onigLib={createOnigScanner:(n)=>t.createScanner(n),createOnigString:(n)=>t.createString(n)},e.forEach((n)=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){if(this._langs.set(t.name,t),t.aliases)t.aliases.forEach((e)=>{this._langs.set(e,t)});if(this._scopeToLang.set(t.scopeName,t),t.injectTo)t.injectTo.forEach((e)=>{if(!this._injections.get(e))this._injections.set(e,[]);this._injections.get(e).push(t.scopeName)})}getInjections(t){let e=t.split("."),n=[];for(let r=1;r<=e.length;r++){let s=e.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}},H=0;function ve(t){if(H+=1,t.warnings!==!1&&H>=10&&H%10===0)console.warn(`[Shiki] ${H} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new S("`engine` option is required for synchronous mode");let n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(re),s=new Un(new Kn(t.engine,n),r,n,t.langAlias),i;function o(g){return wt(g,t.langAlias)}function a(g){_();let b=s.getGrammar(typeof g==="string"?g:g.name);if(!b)throw new S(`Language \`${g}\` not found, you may need to load it first`);return b}function c(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();let b=s.getTheme(g);if(!b)throw new S(`Theme \`${g}\` not found, you may need to load it first`);return b}function l(g){_();let b=c(g);if(i!==g)s.setTheme(b),i=g;return{theme:b,colorMap:s.getColorMap()}}function u(){return _(),s.getLoadedThemes()}function h(){return _(),s.getLoadedLanguages()}function d(...g){_(),s.loadLanguages(g.flat(1))}async function f(...g){return d(await bt(g))}function m(...g){_();for(let b of g.flat(1))s.loadTheme(b)}async function y(...g){return _(),m(await St(g))}function _(){if(e)throw new S("Shiki instance has been disposed")}function p(){if(e)return;e=!0,s.dispose(),H-=1}return{setTheme:l,getTheme:c,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:o,loadLanguage:f,loadLanguageSync:d,loadTheme:y,loadThemeSync:m,dispose:p,[Symbol.dispose]:p}}async function Ae(t){if(!t.engine)console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[e,n,r]=await Promise.all([St(t.themes||[]),bt(t.langs||[]),t.engine]);return ve({...t,themes:e,langs:n,engine:r})}var Ct=new WeakMap;function K(t,e){Ct.set(t,e)}function G(t){return Ct.get(t)}var se=class t{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new t(Object.fromEntries(pt(n).map((r)=>[r,ne])),e)}constructor(...e){if(e.length===2){let[n,r]=e;this.lang=r,this._stacks=n}else{let[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return Vn(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Vn(t){let e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);let i=s?.nameScopesList?.scopeName;if(i)e.push(i);if(s.parent)r(s.parent)}return r(t),e}function Yn(t,e){if(!(t instanceof se))throw new S("Invalid grammar state");return t.getInternalStack(e)}var Jn=/,/,Qn=/ /;function Ee(t,e,n={}){let{theme:r=t.getLoadedThemes()[0]}=n;if(z(t.resolveLangAlias(n.lang||"text"))||U(r))return P(e).map((a)=>[{content:a[0],offset:a[1]}]);let{theme:s,colorMap:i}=t.setTheme(r),o=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==o.name)throw new S(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${o.name}"`);if(!n.grammarState.themes.includes(s.name))throw new S(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Rt(e,o,s,i,n)}function kt(...t){if(t.length===2)return G(t[1]);let[e,n,r={}]=t,{lang:s="text",theme:i=e.getLoadedThemes()[0]}=r;if(z(s)||U(i))throw new S("Plain language does not have grammar state");if(s==="ansi")throw new S("ANSI language does not have grammar state");let{theme:o,colorMap:a}=e.setTheme(i),c=e.getLanguage(s);return new se(xe(n,c,o,a,r).stateStack,c.name,o.name)}function Rt(t,e,n,r,s){let i=xe(t,e,n,r,s),o=new se(i.stateStack,e.name,n.name);return K(i.tokens,o),i.tokens}function xe(t,e,n,r,s){let i=q(n,s),{tokenizeMaxLineLength:o=0,tokenizeTimeLimit:a=500,includeExplanation:c=!1}=s,l=P(t),u=s.grammarState?Yn(s.grammarState,n.name)??ne:s.grammarContextCode!=null?xe(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:ne,h=[],d=[];for(let f=0,m=l.length;f<m;f++){let[y,_]=l[f];if(y===""){h=[],d.push([]);continue}if(o>0&&y.length>=o){h=[],d.push([{content:y,offset:_,color:"",fontStyle:0}]);continue}let p,g,b;if(c&&c!=="tokenType")p=e.tokenizeLine(y,u,a),g=p.tokens,b=0;let C=e.tokenizeLine2(y,u,a),R=C.tokens.length/2;for(let N=0;N<R;N++){let E=C.tokens[2*N],ge=N+1<R?C.tokens[2*N+2]:y.length;if(E===ge)continue;let pe=C.tokens[2*N+1],Zt=v(r[x.getForeground(pe)],i),en=x.getFontStyle(pe),Y={content:y.substring(E,ge),offset:_+E,color:Zt,fontStyle:en};if(c==="tokenType")Y.type=x.getTokenType(pe);else if(c){let Me=[];if(c!=="scopeName")for(let T of n.settings){let L;switch(typeof T.scope){case"string":L=T.scope.split(Jn).map((_e)=>_e.trim());break;case"object":L=T.scope;break;default:continue}Me.push({settings:T,selectors:L.map((_e)=>_e.split(Qn))})}Y.explanation=[];let je=0;while(E+je<ge){let T=g[b],L=y.substring(T.startIndex,T.endIndex);je+=L.length,Y.explanation.push({content:L,scopes:c==="scopeName"?Xn(T.scopes):Zn(Me,T.scopes)}),b+=1}}h.push(Y)}d.push(h),h=[],u=C.ruleStack}return{tokens:d,stateStack:u}}function Xn(t){return t.map((e)=>({scopeName:e}))}function Zn(t,e){let n=[];for(let r=0,s=e.length;r<s;r++){let i=e[r];n[r]={scopeName:i,themeMatches:tr(t,i,e.slice(0,r))}}return n}function gt(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function er(t,e,n){if(!gt(t.at(-1),e))return!1;let r=t.length-2,s=n.length-1;while(r>=0&&s>=0){if(gt(t[r],n[s]))r-=1;s-=1}if(r===-1)return!0;return!1}function tr(t,e,n){let r=[];for(let{selectors:s,settings:i}of t)for(let o of s)if(er(o,e,n)){r.push(i);break}return r}function ie(t,e,n,r=Ee){let s=Object.entries(n.themes).filter((l)=>l[1]).map((l)=>({color:l[0],theme:l[1]})),i=s.map((l)=>{let u=r(t,e,{...n,theme:l.theme});return{tokens:u,state:G(u),theme:typeof l.theme==="string"?l.theme:l.theme.name}}),o=nr(...i.map((l)=>l.tokens)),a=o[0].map((l,u)=>l.map((h,d)=>{let f={content:h.content,variants:{},offset:h.offset};if("includeExplanation"in n&&n.includeExplanation)f.explanation=h.explanation;return o.forEach((m,y)=>{let{content:_,explanation:p,offset:g,...b}=m[u][d];f.variants[s[y].color]=b}),f})),c=i[0].state?new se(Object.fromEntries(i.map((l)=>[l.theme,l.state?.getInternalStack(l.theme)])),i[0].state.lang):void 0;if(c)K(a,c);return a}function nr(...t){let e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){let s=t.map((c)=>c[r]),i=e.map(()=>[]);e.forEach((c,l)=>c.push(i[l]));let o=s.map(()=>0),a=s.map((c)=>c[0]);while(a.every((c)=>c)){let c=Math.min(...a.map((l)=>l.content.length));for(let l=0;l<n;l++){let u=a[l];if(u.content.length===c)i[l].push(u),o[l]+=1,a[l]=s[l][o[l]];else i[l].push({...u,content:u.content.slice(0,c)}),a[l]={...u,content:u.content.slice(c),offset:u.offset+c}}}}return e}var Nt=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var Tt={}.hasOwnProperty;function vt(t,e){let n=e||{};function r(s,...i){let{invalid:o,handlers:a}=r;if(s&&Tt.call(s,t)){let c=String(s[t]);o=Tt.call(a,c)?a[c]:r.unknown}if(o)return o.call(this,s,...i)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var rr=/["&'<>`]/g,sr=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ir=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,or=/[|\\{}()[\]^$+*?.]/g,At=new WeakMap;function Et(t,e){if(t=t.replace(e.subset?ar(e.subset):rr,r),e.subset||e.escapeOnly)return t;return t.replace(sr,n).replace(ir,r);function n(s,i,o){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,o.charCodeAt(i+2),e)}function r(s,i,o){return e.format(s.charCodeAt(0),o.charCodeAt(i+1),e)}}function ar(t){let e=At.get(t);if(!e)e=cr(t),At.set(t,e);return e}function cr(t){let e=[],n=-1;while(++n<t.length)e.push(t[n].replace(or,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}var lr=/[\dA-Fa-f]/;function xt(t,e,n){let r="&#x"+t.toString(16).toUpperCase();return n&&e&&!lr.test(String.fromCharCode(e))?r:r+";"}var ur=/\d/;function It(t,e,n){let r="&#"+String(t);return n&&e&&!ur.test(String.fromCharCode(e))?r:r+";"}var Lt=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var oe={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"};var Pt=["cent","copy","divide","gt","lt","not","para","times"];var Gt={}.hasOwnProperty,Ie={},ae;for(ae in oe)if(Gt.call(oe,ae))Ie[oe[ae]]=ae;var hr=/[^\dA-Za-z]/;function Bt(t,e,n,r){let s=String.fromCharCode(t);if(Gt.call(Ie,s)){let i=Ie[s],o="&"+i;if(n&&Lt.includes(i)&&!Pt.includes(i)&&(!r||e&&e!==61&&hr.test(String.fromCharCode(e))))return o;return o+";"}return""}function Ot(t,e,n){let r=xt(t,e,n.omitOptionalSemicolons),s;if(n.useNamedReferences||n.useShortestReferences)s=Bt(t,e,n.omitOptionalSemicolons,n.attribute);if((n.useShortestReferences||!s)&&n.useShortestReferences){let i=It(t,e,n.omitOptionalSemicolons);if(i.length<r.length)r=i}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function A(t,e){return Et(t,Object.assign({format:Ot},e))}var fr=/^>|^->|<!--|-->|--!>|<!-$/g,dr=[">"],mr=["<",">"];function $t(t,e,n,r){return r.settings.bogusComments?"<?"+A(t.value,Object.assign({},r.settings.characterReferences,{subset:dr}))+">":"<!--"+t.value.replace(fr,s)+"-->";function s(i){return A(i,Object.assign({},r.settings.characterReferences,{subset:mr}))}}function Mt(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}var w=jt(1),Le=jt(-1),gr=[];function jt(t){return e;function e(n,r,s){let i=n?n.children:gr,o=(r||0)+t,a=i[o];if(!s)while(a&&mn(a))o+=t,a=i[o];return a}}var pr={}.hasOwnProperty;function ce(t){return e;function e(n,r,s){return pr.call(t,n.tagName)&&t[n.tagName](n,r,s)}}var V=ce({body:yr,caption:Pe,colgroup:Pe,dd:Cr,dt:wr,head:Pe,html:_r,li:Sr,optgroup:kr,option:Rr,p:br,rp:Ft,rt:Ft,tbody:Tr,td:Dt,tfoot:vr,th:Dt,thead:Nr,tr:Ar});function Pe(t,e,n){let r=w(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&mn(r.value.charAt(0)))}function _r(t,e,n){let r=w(n,e);return!r||r.type!=="comment"}function yr(t,e,n){let r=w(n,e);return!r||r.type!=="comment"}function br(t,e,n){let r=w(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function Sr(t,e,n){let r=w(n,e);return!r||r.type==="element"&&r.tagName==="li"}function wr(t,e,n){let r=w(n,e);return Boolean(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function Cr(t,e,n){let r=w(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Ft(t,e,n){let r=w(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function kr(t,e,n){let r=w(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function Rr(t,e,n){let r=w(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Nr(t,e,n){let r=w(n,e);return Boolean(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function Tr(t,e,n){let r=w(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function vr(t,e,n){return!w(n,e)}function Ar(t,e,n){let r=w(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Dt(t,e,n){let r=w(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var Wt=ce({body:Ir,colgroup:Lr,head:xr,html:Er,tbody:Pr});function Er(t){let e=w(t,-1);return!e||e.type!=="comment"}function xr(t){let e=new Set;for(let r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}let n=t.children[0];return!n||n.type==="element"}function Ir(t){let e=w(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&mn(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function Lr(t,e,n){let r=Le(n,e),s=w(t,-1,!0);if(n&&r&&r.type==="element"&&r.tagName==="colgroup"&&V(r,n.children.indexOf(r),n))return!1;return Boolean(s&&s.type==="element"&&s.tagName==="col")}function Pr(t,e,n){let r=Le(n,e),s=w(t,-1);if(n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&V(r,n.children.indexOf(r),n))return!1;return Boolean(s&&s.type==="element"&&s.tagName==="tr")}var le={name:[[`
|
|
4
4
|
\f\r &/=>`.split(""),`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,a,F}from"./chunk-
|
|
1
|
+
import{t,a,F}from"./chunk-tfqarvdx.js";var ue=t((e,i,o,h)=>{e.attr("class",o);let{width:r,height:n,x:w,y:x}=u(e,i);F(e,n,r,h);let c=m(w,x,r,n,i);e.attr("viewBox",c),a.debug(`viewBox configured: ${c} with padding: ${i}`)},"setupViewPortForSVG"),u=t((e,i)=>{let o=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:o.width+i*2,height:o.height+i*2,x:o.x,y:o.y}},"calculateDimensionsWithPadding"),m=t((e,i,o,h,r)=>`${e-r} ${i-r} ${o} ${h}`,"createViewBox");
|
|
2
2
|
export{ue};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{t,a,N,x,O,C,S,E,T,A,L,R,l,p,M,ci,pe,se,le,
|
|
2
|
-
`),v("\r"),v("\t"),v("\v"),v("\t"),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v("\u2028"),v("\u2029"),v(" "),v(" "),v(" "),v("\uFEFF")];var Hr=/[0-9a-fA-F]/,Vt=/[0-9]/,Xr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let s=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(n,"global");break;case"i":nt(n,"ignoreCase");break;case"m":nt(n,"multiLine");break;case"u":nt(n,"unicode");break;case"y":nt(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:s,loc:this.loc(0)}}disjunction(){let e=[],s=this.idx;e.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(s)}}alternative(){let e=[],s=this.idx;while(this.isTerm())e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ve(s);let n=this.disjunction();return this.consumeChar(")"),{type:s,value:n,loc:this.loc(e)}}return
|
|
3
|
-
`),v("\r"),v("\u2028"),v("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,s=!1;switch(this.popChar()){case"d":e=
|
|
4
|
-
`);break;case"r":e=v("\r");break;case"t":e=v("\t");break;case"v":e=v("\v");break}if(Ve(e))return{type:"Character",value:e};return
|
|
1
|
+
import{t,a,N,x,O,C,S,E,T,A,L,R,l,p,M,ci,pe,se,le,yt,ge,ye}from"./chunk-tfqarvdx.js";import{he}from"./chunk-sc63488q.js";import{ue}from"./chunk-1qh7f5kr.js";function tt(e){if(console&&console.error)console.error(`Error: ${e}`)}function Tt(e){if(console&&console.warn)console.warn(`Warning: ${e}`)}function gt(e){let s=new Date().getTime(),n=e();return{time:new Date().getTime()-s,value:n}}function At(e){function s(){}s.prototype=e;let n=new s;function i(){return typeof n.bar}return i(),i(),e;(0,eval)(e)}function Gr(e){if(Wr(e))return e.LABEL;else return e.name}function Wr(e){return typeof e.LABEL==="string"&&e.LABEL!==""}class Ne{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach((s)=>{s.accept(e)})}}class W extends Ne{constructor(e){super([]);this.idx=1,Object.assign(this,xe(e))}set definition(e){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(e){e.visit(this)}}class Te extends Ne{constructor(e){super(e.definition);this.orgText="",Object.assign(this,xe(e))}}class j extends Ne{constructor(e){super(e.definition);this.ignoreAmbiguities=!1,Object.assign(this,xe(e))}}class K extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class Z extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class Q extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class G extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class q extends Ne{constructor(e){super(e.definition);this.idx=1,Object.assign(this,xe(e))}}class J extends Ne{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,xe(e))}}class F{constructor(e){this.idx=1,Object.assign(this,xe(e))}accept(e){e.visit(this)}}function Wt(e){return e.map(st)}function st(e){function s(n){return n.map(st)}if(e instanceof W){let n={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(typeof e.label==="string")n.label=e.label;return n}else if(e instanceof j)return{type:"Alternative",definition:s(e.definition)};else if(e instanceof K)return{type:"Option",idx:e.idx,definition:s(e.definition)};else if(e instanceof Z)return{type:"RepetitionMandatory",idx:e.idx,definition:s(e.definition)};else if(e instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:st(new F({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof q)return{type:"RepetitionWithSeparator",idx:e.idx,separator:st(new F({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof G)return{type:"Repetition",idx:e.idx,definition:s(e.definition)};else if(e instanceof J)return{type:"Alternation",idx:e.idx,definition:s(e.definition)};else if(e instanceof F){let n={type:"Terminal",name:e.terminalType.name,label:Gr(e.terminalType),idx:e.idx};if(typeof e.label==="string")n.terminalLabel=e.label;let i=e.terminalType.PATTERN;if(e.terminalType.PATTERN)n.pattern=i instanceof RegExp?i.source:i;return n}else if(e instanceof Te)return{type:"Rule",name:e.name,orgText:e.orgText,definition:s(e.definition)};else throw Error("non exhaustive match")}function xe(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}class Ae{visit(e){let s=e;switch(s.constructor){case W:return this.visitNonTerminal(s);case j:return this.visitAlternative(s);case K:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case q:return this.visitRepetitionWithSeparator(s);case G:return this.visitRepetition(s);case J:return this.visitAlternation(s);case F:return this.visitTerminal(s);case Te:return this.visitRule(s);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 vs(e){return e instanceof j||e instanceof K||e instanceof G||e instanceof Z||e instanceof Q||e instanceof q||e instanceof F||e instanceof Te}function je(e,s=[]){if(e instanceof K||e instanceof G||e instanceof q)return!0;if(e instanceof J)return e.definition.some((i)=>je(i,s));else if(e instanceof W&&s.includes(e))return!1;else if(e instanceof Ne){if(e instanceof W)s.push(e);return e.definition.every((i)=>je(i,s))}else return!1}function Ms(e){return e instanceof J}function Se(e){if(e instanceof W)return"SUBRULE";else if(e instanceof K)return"OPTION";else if(e instanceof J)return"OR";else if(e instanceof Z)return"AT_LEAST_ONE";else if(e instanceof Q)return"AT_LEAST_ONE_SEP";else if(e instanceof q)return"MANY_SEP";else if(e instanceof G)return"MANY";else if(e instanceof F)return"CONSUME";else throw Error("non exhaustive match")}class $e{walk(e,s=[]){e.definition.forEach((n,i)=>{let r=e.definition.slice(i+1);if(n instanceof W)this.walkProdRef(n,r,s);else if(n instanceof F)this.walkTerminal(n,r,s);else if(n instanceof j)this.walkFlat(n,r,s);else if(n instanceof K)this.walkOption(n,r,s);else if(n instanceof Z)this.walkAtLeastOne(n,r,s);else if(n instanceof Q)this.walkAtLeastOneSep(n,r,s);else if(n instanceof q)this.walkManySep(n,r,s);else if(n instanceof G)this.walkMany(n,r,s);else if(n instanceof J)this.walkOr(n,r,s);else throw Error("non exhaustive match")})}walkTerminal(e,s,n){}walkProdRef(e,s,n){}walkFlat(e,s,n){let i=s.concat(n);this.walk(e,i)}walkOption(e,s,n){let i=s.concat(n);this.walk(e,i)}walkAtLeastOne(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkAtLeastOneSep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkMany(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkManySep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkOr(e,s,n){let i=s.concat(n);e.definition.forEach((r)=>{let o=new j({definition:[r]});this.walk(o,i)})}}function Nn(e,s,n){return[new K({definition:[new F({terminalType:e.separator})].concat(e.definition)})].concat(s,n)}function Ke(e){if(e instanceof W)return Ke(e.referencedRule);else if(e instanceof F)return Vr(e);else if(vs(e))return jr(e);else if(Ms(e))return Kr(e);else throw Error("non exhaustive match")}function jr(e){let s=[],n=e.definition,i=0,r=n.length>i,o,h=!0;while(r&&h)o=n[i],h=je(o),s=s.concat(Ke(o)),i=i+1,r=n.length>i;return[...new Set(s)]}function Kr(e){let s=e.definition.map((n)=>Ke(n));return[...new Set(s.flat())]}function Vr(e){return[e.terminalType]}var jt="_~IN~_";class In extends $e{constructor(e){super();this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,s,n){}walkProdRef(e,s,n){let i=zr(e.referencedRule,e.idx)+this.topProd.name,r=s.concat(n),o=new j({definition:r}),h=Ke(o);this.follows[i]=h}}function kn(e){let s={};return e.forEach((n)=>{let i=new In(n).startWalking();Object.assign(s,i)}),s}function zr(e,s){return e.name+s+jt}function v(e){return e.charCodeAt(0)}function Kt(e,s){if(Array.isArray(e))e.forEach(function(n){s.push(n)});else s.push(e)}function nt(e,s){if(e[s]===!0)throw"duplicate flag "+s;let n=e[s];e[s]=!0}function Ve(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function St(){throw Error("Internal Error - Should never get here!")}function ws(e){return e.type==="Character"}var Rt=[];for(let e=v("0");e<=v("9");e++)Rt.push(e);var Ot=[v("_")].concat(Rt);for(let e=v("a");e<=v("z");e++)Ot.push(e);for(let e=v("A");e<=v("Z");e++)Ot.push(e);var Us=[v(" "),v("\f"),v(`
|
|
2
|
+
`),v("\r"),v("\t"),v("\v"),v("\t"),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v(" "),v("\u2028"),v("\u2029"),v(" "),v(" "),v(" "),v("\uFEFF")];var Hr=/[0-9a-fA-F]/,Vt=/[0-9]/,Xr=/[1-9]/;class zt{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let s=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(n,"global");break;case"i":nt(n,"ignoreCase");break;case"m":nt(n,"multiLine");break;case"u":nt(n,"unicode");break;case"y":nt(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:s,loc:this.loc(0)}}disjunction(){let e=[],s=this.idx;e.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(s)}}alternative(){let e=[],s=this.idx;while(this.isTerm())e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ve(s);let n=this.disjunction();return this.consumeChar(")"),{type:s,value:n,loc:this.loc(e)}}return St()}quantifier(e=!1){let s=void 0,n=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:i,atMost:i};break;case",":let r;if(this.isDigit())r=this.integerIncludingZero(),s={atLeast:i,atMost:r};else s={atLeast:i,atMost:1/0};this.consumeChar("}");break}if(e===!0&&s===void 0)return;Ve(s);break}if(e===!0&&s===void 0)return;if(Ve(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(n),s}}atom(){let e,s=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();if(Ve(e)){if(e.loc=this.loc(s),this.isQuantifier())e.quantifier=this.quantifier();return e}return St()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[v(`
|
|
3
|
+
`),v("\r"),v("\u2028"),v("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,s=!1;switch(this.popChar()){case"d":e=Rt;break;case"D":e=Rt,s=!0;break;case"s":e=Us;break;case"S":e=Us,s=!0;break;case"w":e=Ot;break;case"W":e=Ot,s=!0;break}if(Ve(e))return{type:"Set",value:e,complement:s};return St()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=v("\f");break;case"n":e=v(`
|
|
4
|
+
`);break;case"r":e=v("\r");break;case"t":e=v("\t");break;case"v":e=v("\v");break}if(Ve(e))return{type:"Character",value:e};return St()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:v("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:v(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
|
|
5
5
|
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:v(e)}}}characterClass(){let e=[],s=!1;if(this.consumeChar("["),this.peekChar(0)==="^")this.consumeChar("^"),s=!0;while(this.isClassAtom()){let n=this.classAtom(),i=n.type==="Character";if(ws(n)&&this.isRangeDash()){this.consumeChar("-");let r=this.classAtom(),o=r.type==="Character";if(ws(r)){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else Kt(n.value,e),e.push(v("-")),Kt(r.value,e)}else Kt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:s,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
|
|
6
6
|
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:v("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let s=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:s};if(e)n.idx=this.groupIdx;return n}positiveInteger(){let e=this.popChar();if(Xr.test(e)===!1)throw Error("Expecting a positive integer");while(Vt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Vt.test(e)===!1)throw Error("Expecting an integer");while(Vt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
|
|
7
7
|
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:v(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return Vt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
|
|
@@ -42,13 +42,13 @@ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;s.
|
|
|
42
42
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;else if(s.issue===V.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
|
|
43
43
|
The problem is in the <${e.name}> Token Type
|
|
44
44
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;else throw Error("non exhaustive match")}function Gn(e){return e.map((n)=>{if(typeof n==="string")return n.charCodeAt(0);else return n})}function Fs(e,s,n){if(e[s]===void 0)e[s]=[n];else e[s].push(n)}var it=256,Jt=[];function ve(e){return e<it?e:Jt[e]}function Ea(){if(Jt.length===0){Jt=Array(65536);for(let e=0;e<65536;e++)Jt[e]=e>255?255+~~(e/255):e}}function Ue(e,s){let n=e.tokenTypeIdx;if(n===s.tokenTypeIdx)return!0;else return s.isParent===!0&&s.categoryMatchesMap[n]===!0}function at(e,s){return e.tokenTypeIdx===s.tokenTypeIdx}var Wn=1,Kn={};function Pe(e){let s=Ta(e);ga(s),Sa(s),Aa(s),s.forEach((n)=>{n.isParent=n.categoryMatches.length>0})}function Ta(e){let s=[...e],n=e,i=!0;while(i){n=n.map((o)=>o.CATEGORIES).flat().filter(Boolean);let r=n.filter((o)=>!s.includes(o));if(s=s.concat(r),r.length===0)i=!1;else n=r}return s}function ga(e){e.forEach((s)=>{if(!Bs(s))Kn[Wn]=s,s.tokenTypeIdx=Wn++;if(jn(s)&&!Array.isArray(s.CATEGORIES))s.CATEGORIES=[s.CATEGORIES];if(!jn(s))s.CATEGORIES=[];if(!Ra(s))s.categoryMatches=[];if(!ya(s))s.categoryMatchesMap={}})}function Aa(e){e.forEach((s)=>{s.categoryMatches=[],Object.keys(s.categoryMatchesMap).forEach((n)=>{s.categoryMatches.push(Kn[n].tokenTypeIdx)})})}function Sa(e){e.forEach((s)=>{Vn([],s)})}function Vn(e,s){e.forEach((n)=>{s.categoryMatchesMap[n.tokenTypeIdx]=!0}),s.CATEGORIES.forEach((n)=>{let i=e.concat(s);if(!i.includes(n))Vn(i,n)})}function Bs(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}function jn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"CATEGORIES")}function Ra(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatches")}function ya(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"categoryMatchesMap")}function zn(e){return Object.hasOwn(e!==null&&e!==void 0?e:{},"tokenTypeIdx")}var $s={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,s,n,i,r,o){return`unexpected character: ->${e.charAt(s)}<- at offset: ${s}, skipped ${n} characters.`}};var V;(function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(V||(V={}));var It={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
|
|
45
|
-
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(It);class z{constructor(e,s=It){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,r)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${o}--> <${i}>`);let{time:h,value:u}=
|
|
45
|
+
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:$s,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(It);class z{constructor(e,s=It){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,r)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${o}--> <${i}>`);let{time:h,value:u}=gt(r),c=h>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)c(`${o}<-- <${i}> time: ${h}ms`);return this.traceInitIndent--,u}else return r()},typeof s==="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
|
|
46
46
|
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},It,s);let n=this.config.traceInitPerf;if(n===!0)this.traceInitMaxIdent=1/0,this.traceInitPerf=!0;else if(typeof n==="number")this.traceInitMaxIdent=n,this.traceInitPerf=!0;this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,r=!0;if(this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===It.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Bn;else if(this.config.lineTerminatorCharacters===It.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
|
|
47
47
|
For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(s.safeMode&&s.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');if(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:rt};else r=!1,i=Object.assign({},e)}),this.config.skipValidations===!1)this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Pn(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Dn(i,this.trackStartLines,this.config.lineTerminatorCharacters))});i.modes=i.modes?i.modes:{},Object.entries(i.modes).forEach(([h,u])=>{i.modes[h]=u.filter((c)=>c!==void 0)});let o=Object.keys(i.modes);if(Object.entries(i.modes).forEach(([h,u])=>{this.TRACE_INIT(`Mode: <${h}> processing`,()=>{if(this.modes.push(h),this.config.skipValidations===!1)this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Un(u,o))});if(this.lexerDefinitionErrors.length===0){Pe(u);let c;this.TRACE_INIT("analyzeTokenTypes",()=>{c=wn(u,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:s.positionTracking,ensureOptimizations:s.ensureOptimizations,safeMode:s.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[h]=c.patternIdxToConfig,this.charCodeToPatternIdxToConfig[h]=c.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,c.emptyGroups),this.hasCustom=c.hasCustom||this.hasCustom,this.canModeBeOptimized[h]=c.canBeOptimized}})}),this.defaultMode=i.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let u=this.lexerDefinitionErrors.map((c)=>c.message).join(`-----------------------
|
|
48
48
|
`);throw Error(`Errors detected in definition of Lexer:
|
|
49
49
|
`+u)}this.lexerDefinitionWarning.forEach((h)=>{Tt(h.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(r)this.handleModes=()=>{};if(this.trackStartLines===!1)this.computeNewColumn=(h)=>h;if(this.trackEndLines===!1)this.updateTokenEndLineColumnLocation=()=>{};if(/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}"`);if(this.hasCustom)this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom;else this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let h=Object.entries(this.canModeBeOptimized).reduce((u,[c,d])=>{if(d===!1)u.push(c);return u},[]);if(s.ensureOptimizations&&h.length>0)throw Error(`Lexer Modes: < ${h.join(", ")} > cannot be optimized.
|
|
50
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",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{
|
|
51
|
+
Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{At(this)})})}tokenize(e,s=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let i=this.lexerDefinitionErrors.map((r)=>r.message).join(`-----------------------
|
|
52
52
|
`);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
|
|
53
53
|
`+i)}return this.tokenizeInternal(e,s)}tokenizeInternal(e,s){let n,i,r,o,h,u,c,d,f,m,y,I,P,D,w,_=e,b=_.length,g=0,U=0,te=this.hasCustom?0:Math.floor(e.length/10),ce=Array(te),pt=[],Me=this.trackStartLines?1:void 0,_e=this.trackStartLines?1:void 0,et={};for(let ne=0;ne<this.cachedGroupKeys.length;ne++)et[this.cachedGroupKeys[ne]]=[];let Br=this.trackStartLines,ks=this.config.lineTerminatorsPattern,Cs=0,We=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,$r=(ne)=>{if(mt.length===1&&ne.tokenType.PUSH_MODE===void 0){let Le=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(ne);pt.push({offset:ne.startOffset,line:ne.startLine,column:ne.startColumn,length:ne.image.length,message:Le})}else{mt.pop();let Le=mt.at(-1);We=this.patternIdxToConfig[Le],ft=this.charCodeToPatternIdxToConfig[Le],Cs=We.length;let bs=this.canModeBeOptimized[Le]&&this.config.safeMode===!1;if(ft&&bs)Et=!0;else Et=!1}};function On(ne){mt.push(ne),ft=this.charCodeToPatternIdxToConfig[ne],We=this.patternIdxToConfig[ne],Cs=We.length;let Le=this.canModeBeOptimized[ne]&&this.config.safeMode===!1;if(ft&&Le)Et=!0;else Et=!1}On.call(this,s);let Oe,Ln=this.config.recoveryEnabled;while(g<b){u=null,f=-1;let ne=_.charCodeAt(g),Le;if(Et){let ae=ve(ne),Ee=ft[ae];Le=Ee!==void 0?Ee:yn}else Le=We;let bs=Le.length;for(n=0;n<bs;n++){Oe=Le[n];let ae=Oe.pattern;switch(c=null,Oe.matchType){case Zt:if(ne===Oe.short)f=1,u=ae;break;case Nt:if(w=ae.exec(_,g,ce,et),w!==null){if(u=w[0],f=u.length,w.payload!==void 0)c=w.payload}else u=null;break;case es:{let Ee=Oe.asciiClass;if(Ee[ne]!==1){ae.lastIndex=0;break}let fe=g+1;while(Ee[_.charCodeAt(fe)]===1)fe++;f=fe-g,ae.lastIndex=fe;break}case Qt:ae.lastIndex=g,f=this.matchLength(ae,e,g);break}if(f!==-1){if(h=Oe.longerAlt,h!==void 0){u=e.substring(g,g+f);let Ee=h.length;for(r=0;r<Ee;r++){let fe=We[h[r]],we=fe.pattern;if(d=null,fe.matchType===Nt)if(w=we.exec(_,g,ce,et),w!==null){if(o=w[0],w.payload!==void 0)d=w.payload}else o=null;else we.lastIndex=g,o=this.match(we,e,g);if(o&&o.length>u.length){u=o,f=o.length,c=d,Oe=fe;break}}}break}}if(f!==-1){if(m=Oe.group,m!==void 0)if(u=u!==null?u:e.substring(g,g+f),y=Oe.tokenTypeIdx,I=this.createTokenInstance(u,g,y,Oe.tokenType,Me,_e,f),this.handlePayload(I,c),m===!1)U=this.addToken(ce,U,I);else et[m].push(I);if(Br===!0&&Oe.canLineTerminator===!0){let ae=0,Ee,fe;ks.lastIndex=0;do if(u=u!==null?u:e.substring(g,g+f),Ee=ks.test(u),Ee===!0)fe=ks.lastIndex-1,ae++;while(Ee===!0);if(ae!==0)Me=Me+ae,_e=f-fe,this.updateTokenEndLineColumnLocation(I,m,fe,ae,Me,_e,f);else _e=this.computeNewColumn(_e,f)}else _e=this.computeNewColumn(_e,f);g=g+f,this.handleModes(Oe,$r,On,I)}else{let ae=g,Ee=Me,fe=_e,we=Ln===!1;while(we===!1&&g<b){g++;for(i=0;i<Cs;i++){let _s=We[i],xs=_s.pattern;switch(_s.matchType){case Zt:if(_.charCodeAt(g)===_s.short)we=!0;break;case Nt:we=xs.exec(_,g,ce,et)!==null;break;case es:case Qt:xs.lastIndex=g,we=xs.exec(e)!==null;break}if(we===!0)break}}if(P=g-ae,_e=this.computeNewColumn(_e,P),D=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,ae,P,Ee,fe,mt.at(-1)),pt.push({offset:ae,line:Ee,column:fe,length:P,message:D}),Ln===!1)break}}if(!this.hasCustom)ce.length=U;return{tokens:ce,groups:et,errors:pt}}handleModes(e,s,n,i){if(e.pop===!0){let r=e.push;if(s(i),r!==void 0)n.call(this,r)}else if(e.push!==void 0)n.call(this,e.push)}updateTokenEndLineColumnLocation(e,s,n,i,r,o,h){let u,c;if(s!==void 0){if(u=n===h-1,c=u?-1:0,!(i===1&&u===!0))e.endLine=r+c,e.endColumn=o-1+-c}}computeNewColumn(e,s){return e+s}createOffsetOnlyToken(e,s,n,i){return{image:e,startOffset:s,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,s,n,i,r,o){return{image:e,startOffset:s,startLine:r,startColumn:o,tokenTypeIdx:n,tokenType:i}}createFullToken(e,s,n,i,r,o,h){return{image:e,startOffset:s,endOffset:s+h-1,startLine:r,endLine:r,startColumn:o,endColumn:o+h-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,s,n){return e.push(n),s}addTokenUsingMemberAccess(e,s,n){return e[s]=n,s++,s}handlePayloadNoCustom(e,s){}handlePayloadWithCustom(e,s){if(s!==null)e.payload=s}match(e,s,n){if(e.test(s)===!0)return s.substring(n,e.lastIndex);return null}matchLength(e,s,n){if(e.test(s)===!0)return e.lastIndex-n;return-1}}z.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";z.NA=/NOT_APPLICABLE/;function Ye(e){if(Gs(e))return e.LABEL;else return e.name}function Gs(e){return typeof e.LABEL==="string"&&e.LABEL!==""}var Oa="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function k(e){return La(e)}function La(e){let s=e.pattern,n={};if(n.name=e.name,s!==void 0)n.PATTERN=s;if(Object.hasOwn(e,Oa))throw`The parent property is no longer supported.
|
|
54
54
|
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(e,Hn))n.CATEGORIES=e[Hn];if(Pe([n]),Object.hasOwn(e,Xn))n.LABEL=e[Xn];if(Object.hasOwn(e,Yn))n.GROUP=e[Yn];if(Object.hasOwn(e,Jn))n.POP_MODE=e[Jn];if(Object.hasOwn(e,qn))n.PUSH_MODE=e[qn];if(Object.hasOwn(e,Zn))n.LONGER_ALT=e[Zn];if(Object.hasOwn(e,Qn))n.LINE_BREAKS=e[Qn];if(Object.hasOwn(e,ei))n.START_CHARS_HINT=e[ei];return n}var Re=k({name:"EOF",pattern:z.NA});Pe([Re]);function qe(e,s,n,i,r,o,h,u){return{image:s,startOffset:n,endOffset:i,startLine:r,endLine:o,startColumn:h,endColumn:u,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function kt(e,s){return Ue(e,s)}var ts={buildMismatchTokenMessage({expected:e,actual:s,previous:n,ruleName:i}){return`Expecting ${Gs(e)?`--> ${Ye(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${s.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:s}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:s,previous:n,customUserDescription:i,ruleName:r}){let u=`
|
|
@@ -101,7 +101,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
101
101
|
https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(i){throw n}throw n}}optionInternalRecord(e,s){return Ut.call(this,K,e,s)}atLeastOneInternalRecord(e,s){Ut.call(this,Z,s,e)}atLeastOneSepFirstInternalRecord(e,s){Ut.call(this,Q,s,e,wi)}manyInternalRecord(e,s){Ut.call(this,G,s,e)}manySepFirstInternalRecord(e,s){Ut.call(this,q,s,e,wi)}orInternalRecord(e,s){return $a.call(this,e,s)}subruleInternalRecord(e,s,n){if(Es(s),!e||!Object.hasOwn(e,"ruleName")){let h=Error(`<SUBRULE${Pi(s)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
|
|
102
102
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw h.KNOWN_RECORDER_ERROR=!0,h}let i=this.recordingProdStack.at(-1),r=e.ruleName,o=new W({idx:s,nonTerminalName:r,label:n===null||n===void 0?void 0:n.LABEL,referencedRule:void 0});return i.definition.push(o),this.outputCst?Ba:Ts}consumeInternalRecord(e,s,n){if(Es(s),!Bs(e)){let o=Error(`<CONSUME${Pi(s)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
|
|
103
103
|
inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let i=this.recordingProdStack.at(-1),r=new F({idx:s,terminalType:e,label:n===null||n===void 0?void 0:n.LABEL});return i.definition.push(r),Fi}}function Ut(e,s,n,i=!1){Es(n);let r=this.recordingProdStack.at(-1),o=typeof s==="function"?s:s.DEF,h=new e({definition:[],idx:n});if(i)h.separator=s.SEP;if(Object.hasOwn(s,"MAX_LOOKAHEAD"))h.maxLookahead=s.MAX_LOOKAHEAD;return this.recordingProdStack.push(h),o.call(this),r.definition.push(h),this.recordingProdStack.pop(),Ts}function $a(e,s){Es(s);let n=this.recordingProdStack.at(-1),i=Array.isArray(e)===!1,r=i===!1?e:e.DEF,o=new J({definition:[],idx:s,ignoreAmbiguities:i&&e.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(e,"MAX_LOOKAHEAD"))o.maxLookahead=e.MAX_LOOKAHEAD;let h=r.some((u)=>typeof u.GATE==="function");return o.hasPredicates=h,n.definition.push(o),r.forEach((u)=>{let c=new j({definition:[]});if(o.definition.push(c),Object.hasOwn(u,"IGNORE_AMBIGUITIES"))c.ignoreAmbiguities=u.IGNORE_AMBIGUITIES;else if(Object.hasOwn(u,"GATE"))c.ignoreAmbiguities=!0;this.recordingProdStack.push(c),u.ALT.call(this),this.recordingProdStack.pop()}),Ts}function Pi(e){return e===0?"":`${e}`}function Es(e){if(e<0||e>Ui){let s=Error(`Invalid DSL Method idx value: <${e}>
|
|
104
|
-
Idx value must be a none negative value smaller than ${Ui+1}`);throw s.KNOWN_RECORDER_ERROR=!0,s}}class cn{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let s=e.traceInitPerf,n=typeof s==="number";this.traceInitMaxIdent=n?s:1/0,this.traceInitPerf=n?s>0:s}else this.traceInitMaxIdent=0,this.traceInitPerf=me.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,s){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${n}--> <${e}>`);let{time:i,value:r}=
|
|
104
|
+
Idx value must be a none negative value smaller than ${Ui+1}`);throw s.KNOWN_RECORDER_ERROR=!0,s}}class cn{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let s=e.traceInitPerf,n=typeof s==="number";this.traceInitMaxIdent=n?s:1/0,this.traceInitPerf=n?s>0:s}else this.traceInitMaxIdent=0,this.traceInitPerf=me.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,s){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${n}--> <${e}>`);let{time:i,value:r}=gt(s),o=i>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)o(`${n}<-- <${e}> time: ${i}ms`);return this.traceInitIndent--,r}else return s()}}function Bi(e,s){s.forEach((n)=>{let i=n.prototype;Object.getOwnPropertyNames(i).forEach((r)=>{if(r==="constructor")return;let o=Object.getOwnPropertyDescriptor(i,r);if(o&&(o.get||o.set))Object.defineProperty(e.prototype,r,o);else e.prototype[r]=n.prototype[r]})})}var De=qe(Re,"",-1,-1,-1,-1,-1,-1);Object.freeze(De);var me=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ts,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ct=Object.freeze({recoveryValueFunc:()=>{return},resyncEnabled:!0}),ie;(function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(ie||(ie={}));class Pt{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let s=this.className;this.TRACE_INIT("toFastProps",()=>{At(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach((i)=>{let o=this[i].originalGrammarAction,h;this.TRACE_INIT(`${i} Rule`,()=>{h=this.topLevelRuleRecord(i,o)}),this.gastProductionsCache[i]=h})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Ni({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(n.length===0&&this.skipValidations===!1){let i=Ii({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:Ce,grammarName:s}),r=Ei({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:s});this.definitionErrors=this.definitionErrors.concat(i,r)}}),this.definitionErrors.length===0){if(this.recoveryEnabled)this.TRACE_INIT("computeAllProdsFollows",()=>{let i=kn(Object.values(this.gastProductionsCache));this.resyncFollows=i});this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,r;(r=(i=this.lookaheadStrategy).initialize)===null||r===void 0||r.call(i,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})}if(!Pt.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw e=this.definitionErrors.map((i)=>i.message),Error(`Parser Definition Errors detected:
|
|
105
105
|
${e.join(`
|
|
106
106
|
-------------------------------
|
|
107
107
|
`)}`)})}constructor(e,s){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(s),n.initLexerAdapter(),n.initLooksAhead(s),n.initRecognizerEngine(e,s),n.initRecoverable(s),n.initTreeBuilder(s),n.initGastRecorder(s),n.initPerformanceTracer(s),Object.hasOwn(s,"ignoredIssues"))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
|
|
@@ -115,7 +115,7 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
|
|
|
115
115
|
`;break;case"r":if(e)s+="\r";break;case"t":if(e)s+="\t";break;case"u":{let h=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(h))throw new oe(this.offset);if(e)s+=String.fromCharCode(Number.parseInt(h,16));this.offset+=4;break}default:throw new oe(r)}}throw new oe(this.offset)}consumeLiteral(e){let s=0;for(let n of e){if(this.text[this.offset+s]!==n)throw new oe(this.offset+s);s++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++;else throw new oe(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new oe(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,this.text[this.offset]==="+"||this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new oe(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}}skipWhitespace(){while(this.offset<this.text.length){let e=this.text[this.offset];if(e!==" "&&e!=="\t"&&e!==`
|
|
116
116
|
`&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){let s=`${e}/`;for(let n of Object.keys(this.propertyOrder))if(n===e||n.startsWith(s))delete this.propertyOrder[n]}};function Dr(e,s,n){let i;try{i=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),h=wo(o,e,s,n);if(!h){let u=0;try{new ji(e).collect()}catch(c){if(c instanceof oe)u=c.offset}h=En(e,u,s,n)}throw new Wi(`Invalid JSON: ${o}`,h.line,h.column)}if(typeof i!=="object"||i===null||Array.isArray(i))throw new Wi("JSON value must have an object root",s,n);return{value:i,propertyOrder:new ji(e).collect()}}t(Dr,"parseOrderedJsonObject");var Uo=t((e)=>({shape:e.type==="normal"?"actor":e.type==="hollow"?"actor-hollow":e.type==="awesome"?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),Po=t((e)=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),Do=t((e)=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),Fo=t((e)=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),Bo=t((e)=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),$o=t((e)=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:X.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Go=t((e,s,n,i)=>{let r={};for(let c of e.getActors().values())r[c.id]=Uo(c);for(let c of e.getUseCases().values())r[c.id]=Po(c);for(let c of e.getNotes().values())r[c.id]=Do(c);for(let c of e.getJsonNodes().values())r[c.id]=Fo(c);let o={};for(let c of e.getSystemBoundaries().values())o[c.id]={...c.label===c.id?{}:{title:c.label},nodes:[...c.members],...c.classes.length?{classes:[...c.classes]}:{},...c.styles.length?{styles:[...c.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:c.type,labelType:c.labelType}};let h={};for(let c of e.getClassDefs().values())h[c.id]={styles:[...c.styles]};let u=e.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:u==="TD"?"TB":u,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:r,edges:[...e.getRelationships().map(Bo),...[...e.getNotes().values()].map($o)],groups:o,classDefs:h,statements:i}},"buildUsecaseGraphAST"),de=t((e)=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),Ki=t((e)=>e===void 0?"":` (label "${e}")`,"labelSuffix"),Ze=t((e)=>e.generated?e.label:void 0,"generatedFrom"),hn=t((e,s)=>{for(let n of s)if(!e.includes(n))e.push(n)},"pushUnique"),Wo=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{t(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,s,n,i){this.metadataAssignments.push({target:e,targetLocation:s,metadata:n,statement:i})}addClassDef(e,s){this.classDefinitions.push({ids:e,styles:s})}addClassAssignment(e,s){this.classAssignments.push({targets:e,classes:s})}addStyleAssignment(e,s,n){this.styleAssignments.push({target:e,location:s,styles:n})}setDirection(e){this.directions.push(e==="TD"?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let s=new Map,n=new Map,i=new Map,r=new Map;for(let c of this.relationshipDrafts)this.recordFirst(r,c.source.id,c.source.location.span[0]),this.recordFirst(r,c.target.id,c.target.location.span[0]);for(let c of this.elements)this.recordFirst(r,c.id,c.location.span[0]);for(let c of this.boundaries)this.recordFirst(r,c.id,c.location.span[0]);for(let c of this.jsonDrafts)this.recordFirst(r,c.id,c.location.span[0]);let o=[...this.elements.map((c)=>({offset:c.location.span[0],type:"element",value:c})),...this.boundaries.map((c)=>({offset:c.location.span[0],type:"boundary",value:c})),...this.jsonDrafts.map((c)=>({offset:c.location.span[0],type:"json",value:c})),...this.relationshipDrafts.filter((c)=>c.explicitId).map((c)=>({offset:c.explicitIdLocation.span[0],type:"edge",value:c}))].sort((c,d)=>c.offset-d.offset);for(let c of o)if(c.type==="element")this.collectElement(c.value,s,n);else if(c.type==="boundary")this.collectBoundary(c.value,s,i);else if(c.type==="json")this.registerUnique(s,c.value.id,"json",c.value.location,!1);else this.registerUnique(s,c.value.explicitId,"edge",c.value.explicitIdLocation,!1);this.materializeElements(n,r),this.materializeBoundaries(i,r),this.materializeJson(r);let h=this.materializeRelationships(s,n,r);this.reorderElements(n,r),this.applyMetadataAssignments(s,n,i,h),this.validateAndRefreshElements(n),this.refreshBoundaries(i,n),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,h),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([c,d])=>[c,d.kind]));let u=Go(this,this.source,e,this.statements);return this.model.ast=u,this.db.commit(this.model),u}collectElement(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!==e.kind)this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(!o){let h={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(h,e.metadata),n.set(e.id,h),s.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`ID '${e.id}' has conflicting labels`,e.location,o.location);if(e.shape&&o.shape&&e.shape!==o.shape)this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,o.location);if(e.parentId&&o.parentId&&e.parentId!==o.parentId)this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,o.parentLocation??o.location);if(e.stereotype&&o.stereotype&&e.stereotype!==o.stereotype)this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,o.stereotypeLocation??o.location);o.shape??=e.shape,o.parentId??=e.parentId,o.parentLocation??=e.parentLocation,o.stereotype??=e.stereotype,o.stereotypeLocation??=e.stereotype?e.location:void 0,hn(o.classes,e.classes),this.applyDeclarationMetadata(o,e.metadata)}collectBoundary(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!=="boundary")this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(o){if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,o.location);hn(o.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:[]}),s.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.setElementModel(n)}materializeBoundaries(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let s of[...this.jsonDrafts].sort((n,i)=>(e.get(n.id)??0)-(e.get(i.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(e,s,n){let i=new Map,r=0;for(let o of this.relationshipDrafts){let h=this.resolveEndpoint(o.source,e,s,n),u=this.resolveEndpoint(o.target,e,s,n);this.validateRelationship(o,h,u,e);let c=o.explicitId??`edge-${r++}`,d={id:c,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),i.set(c,{draft:o,relationship:d})}return this.model.relationshipCounter=r,i}resolveEndpoint(e,s,n,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${de(e.location)}`);let r=s.get(e.id);if(r)return r.kind;return n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),s.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,s){let n=new Map(this.model.actors),i=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let r of[...e.values()].sort((o,h)=>(s.get(o.id)??0)-(s.get(h.id)??0))){if(!n.has(r.id)&&!i.has(r.id))this.setElementModel(r);let o=n.get(r.id)??this.model.actors.get(r.id),h=i.get(r.id)??this.model.useCases.get(r.id);if(o)this.model.actors.set(r.id,o);else if(h)this.model.useCases.set(r.id,h)}}applyMetadataAssignments(e,s,n,i){for(let r of this.metadataAssignments){let o=e.get(r.target);if(!o){let h=this.inferMetadataKind(r.metadata);throw Error(`Metadata target '${r.target}' is unresolved${h?` (metadata implies ${h})`:""} at ${de(r.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(r.target),r.metadata);else if(o.kind==="boundary"){let h=n.get(r.target);for(let u of r.metadata.properties){if(u.key!=="type"||u.value!=="rect"&&u.value!=="package")this.invalidMetadata(r.target,o.kind,u);h.type=u.value}}else if(o.kind==="edge"){let h=i.get(r.target);if(!h)throw Error(`Metadata target '${r.target}' is not an explicit edge at ${de(r.targetLocation)}`);r.statement.kind="edgeMetadata",r.statement.edges=[{id:r.target,span:r.statement.span,idSpan:r.targetLocation.span,...r.statement.metadata?{metadata:r.statement.metadata}:{}}],delete r.statement.nodes;for(let u of r.metadata.properties)if(u.key==="animate"&&typeof u.value==="boolean")h.relationship.animate=u.value;else if(u.key==="animation"&&(u.value==="fast"||u.value==="slow"))h.relationship.animation=u.value,h.relationship.animate=!0;else this.invalidMetadata(r.target,o.kind,u)}else for(let h of r.metadata.properties)this.invalidMetadata(r.target,o.kind,h)}for(let{relationship:r}of i.values())if(r.animation)r.animate=!0}applyStandaloneElementMetadata(e,s){for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!0);else if(n.key==="business"&&typeof n.value==="boolean")e.business=n.value;else this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,s){if(!s)return;for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!1);else if(n.key==="business"&&typeof n.value==="boolean"){if(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}else this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,s,n){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!n&&e.actorType!==void 0&&e.actorType!==s.value)this.conflict(`Actor '${e.id}' has conflicting type metadata`,s.location,e.location);e.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!n&&e.icon!==void 0&&e.icon!==s.value)this.conflict(`Actor '${e.id}' has conflicting icon metadata`,s.location,e.location);e.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!n&&e.business!==void 0&&e.business!==s.value)this.conflict(`Actor '${e.id}' has conflicting business metadata`,s.location,e.location);e.business=s.value}else this.invalidMetadata(e.id,e.kind,s)}validateAndRefreshElements(e){for(let s of e.values()){let n=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${de(s.location)}`);if(s.business&&(n==="icon"||n==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${de(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${de(s.location)}`);this.setElementModel(s)}}refreshBoundaries(e,s){for(let n of e.values())n.members.length=0;for(let n of[...this.elements].sort((i,r)=>i.location.span[0]-r.location.span[0])){if(!n.parentId)continue;let i=e.get(n.parentId);if(!i)throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${de(n.parentLocation??n.location)}`);if(!i.members.includes(n.id))i.members.push(n.id)}for(let n of s.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${de(n.parentLocation??n.location)}`);for(let n of e.values()){let 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 s=0;for(let n of this.noteDrafts){let i=e.get(n.target);if(!i)throw Error(`Note target '${n.target}' is unresolved at ${de(n.targetLocation)}`);if(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);let r=`note-${s++}`;this.model.notes.set(r,{id:r,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let e of this.classDefinitions)for(let s of e.ids)this.model.classDefs.set(s,{id:s,styles:[...e.styles]})}applyClassesAndStyles(e,s){for(let n of this.classAssignments)for(let i of n.targets)hn(this.getStylable(i.id,e,s,i.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,s,n.location).styles.push(...n.styles)}getStylable(e,s,n,i){let r=s.get(e)?.kind,o=r==="actor"?this.model.actors.get(e):r==="usecase"?this.model.useCases.get(e):r==="boundary"?this.model.systemBoundaries.get(e):r==="json"?this.model.jsonNodes.get(e):r==="edge"?n.get(e)?.relationship:void 0;if(!o)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${de(i)}`);return o}validateRelationship(e,s,n,i){let r=t((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!r(s))this.conflict(`Relationship source '${e.source.id}' cannot be ${s}`,e.source.location,i.get(e.source.id).location);if(!r(n))this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,i.get(e.target.id).location);if((e.type==="include"||e.type==="extend")&&(s!=="usecase"||n!=="usecase"))throw Error(`${e.type} relationship requires use-case endpoints at ${de(e.location)}`);if(e.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==n))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${de(e.location)}`);if(e.type==="association"&&(s==="json"||n==="json")&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${de(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let s=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:s,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let s=new Set(["actor","usecase","boundary","edge"]);for(let n of e.properties)if(n.key==="icon")s.clear(),s.add("actor");else if(n.key==="animate"||n.key==="animation")s.clear(),s.add("edge");else if(n.key==="type"){if(s.clear(),n.value==="rect"||n.value==="package")s.add("boundary");else if(n.value==="normal"||n.value==="hollow"||n.value==="awesome")s.add("actor")}else if(n.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(e,s,n){throw Error(`Metadata property '${n.key}' is invalid for ${s} '${e}' at ${de(n.location)}`)}registerUnique(e,s,n,i,r){let o=e.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${n})`,i,o.location,void 0,Ze(o));e.set(s,{kind:n,location:i,generated:r})}recordFirst(e,s,n){let i=e.get(s);if(i===void 0||n<i)e.set(s,n)}conflict(e,s,n,i,r){throw Error(`${e} at ${de(s)}${Ki(i)}; previous declaration at ${de(n)}${Ki(r)}`)}},jo=Gt.getBaseCstVisitorConstructor(),Ko=class extends jo{constructor(){super();this.builder=new Wo(Ns),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{t(this,"UsecaseVisitor")}build(e,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(e)}start(e){let s=this.tokens(e,"USECASE")[0],n=[];for(let i of this.nodes(e,"line"))n.push(this.visit(i));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(s))}line(e){let s=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){return}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){let s=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let s=this.tokens(e,"ACC_DESCR_LINE")[0],n=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=s?s.image.slice(s.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){let s=this.nodes(e,"actorItem"),n=s.map((c)=>this.visit(c)),i=this.nodes(e,"relationTail")[0],r=n.map((c,d)=>this.actorOccurrence(s[d],c,!0));for(let c of n)this.builder.addElement(this.actorDraft(c));if(!i)return{kind:"node",span:[0,0],nodes:r};let o=this.visit(i);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let h=this.relationshipDraft(n[0],o,this.nodeLocation(i));this.builder.addRelationship(h);let u=h.explicitId??`edge-${this.anonymousEdge++}`;return r.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:r,edges:[{id:u,span:[0,0],...h.explicitIdLocation?{idSpan:h.explicitIdLocation.span}:{},...h.label?{labelSpan:h.label.span}:{}}]}}actorItem(e){let s=this.visit(this.nodes(e,"actorName")[0]),n=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};return{...s,...n?{metadata:this.visit(n)}:{},...i?{stereotype:this.visit(i)}:{},classes:o.classes,classSpans:o.spans}}actorName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(s){let r=this.nodes(e,"nodeLabel")[0],o=r?this.visit(r):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let s=this.nodes(e,"actorItem"),n=s.map((i)=>this.visit(i));for(let i of n)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:n.map((i,r)=>this.actorOccurrence(s[r],i,!0))}}entityStatement(e){let s=this.nodes(e,"entityName"),n=this.visit(s[0]),i=this.nodes(e,"relationTail")[0];if(!i)return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],n,!0)]};if(n.explicitDeclaration)this.builder.addElement(this.entityDraft(n));let r=this.visit(i);if(r.target.explicitDeclaration)this.builder.addElement(this.entityDraft(r.target));let o={source:this.endpoint(n),target:this.endpoint(r.target),location:this.nodeLocation(i),...r.explicitId?{explicitId:r.explicitId,explicitIdLocation:r.explicitIdLocation}:{},...r.arrow};this.builder.addRelationship(o);let h=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],r.target,r.target.explicitDeclaration)],edges:[{id:h,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],r=this.nodes(e,"useCaseMetadata")[0],o=this.nodes(e,"stereotype")[0],h=this.nodes(e,"classSuffix")[0],u=h?this.visit(h):{classes:[],spans:[]};if(s){let d=i?this.visit(i):this.tokenLabel(s),f=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:d,location:this.tokenLocation(s),generated:!1,...f?{shape:f}:{},...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(f||r||o)}}let c=this.tokenLabel(n);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(n),generated:!0,...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:Boolean(r||o)}}nodeLabel(e){let s=this.allTokens(e);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let s=this.tokens(e,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},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:X.SOLID_ARROW,minlen:1};let s=this.tokens(e,"INCLUDE").length?"include":"extend",n=this.tokens(e,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:X.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(e)}}metadataProperty(e){let s=this.allTokens(e).filter((h)=>h.tokenType.name!=="COLON"),n=s[0],i=s[1],r=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),o=[n.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(n),value:r,span:o,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(i),location:this.tokenLocation(n)}}metadataSeparator(e){return}systemBoundaryStatement(e){let s=this.visit(this.nodes(e,"systemBoundaryName")[0]),n=this.nodes(e,"classSuffix")[0],i=n?this.visit(n):{classes:[],spans:[]};s.classes=i.classes,this.builder.addBoundary(s);let r=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(e,"systemBoundaryContent")[0],h=o?this.visit(o):[];this.parentBoundary=r;let u=this.tokens(e,"END")[0],c=this.nodes(e,"metadata")[0],d=c?this.visit(c):void 0,f={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(u),classSpans:i.spans,...d?{metadata:d.properties.map(({key:m,span:y,keySpan:I,valueSpan:P})=>({key:m,span:y,keySpan:I,valueSpan:P}))}:{},...h.length?{children:h}:{}};if(d)this.builder.addMetadataAssignment(s.id,s.location,d,f);return f}systemBoundaryName(e){let s=this.tokens(e,"IDENTIFIER")[0];if(s){let r=this.nodes(e,"nodeLabel")[0];return{id:s.image,label:r?this.visit(r):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((n,i)=>(n.location?.startOffset??0)-(i.location?.startOffset??0)).map((n)=>this.wrap(n,this.visit(n)))}boundaryElement(e){let s=this.nodes(e,"actorDeclarationOnly")[0];if(s)return this.visit(s);let n=this.nodes(e,"entityName")[0],i=this.visit(n);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,i,!0)]}}metadataAssignmentStatement(e){let s=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:n.properties.map(({key:r,span:o,keySpan:h,valueSpan:u})=>({key:r,span:o,keySpan:h,valueSpan:u}))};return this.builder.addMetadataAssignment(s.id,s.location,n,i),i}metadataAssignmentTarget(e){let s=this.allTokens(e)[0],n=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(n.text),location:this.tokenLocation(s)}}noteStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:n,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(e){let s=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(e){let s=this.tokens(e,"IDENTIFIER");return{classes:s.map((n)=>n.image),spans:s.map((n)=>this.tokenSpan(n))}}jsonStatement(e){let s=this.tokens(e,"JSON_DECLARATION_START")[0],n=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(s.image),r=i[1],o=i[0].length-r.length,h={span:[s.startOffset+o,s.startOffset+o+r.length],line:s.startLine??1,column:(s.startColumn??1)+o},u=Dr(n.image,n.startLine??1,n.startColumn??1),c=this.nodes(e,"classSuffix")[0],d=c?this.visit(c):{classes:[],spans:[]},f={id:r,value:u.value,propertyOrder:u.propertyOrder,location:h,classes:d.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:r,span:h.span,idSpan:h.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(e){let s=this.allTokens(e).find((n)=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(s.map((i)=>i.image),n),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=1;for(;n<s.length;n++)if(!this.source.slice((s[n-1].endOffset??s[n-1].startOffset)+1,s[n].startOffset).includes(","))break;let i=s.slice(0,n).map((o)=>({id:o.image,location:this.tokenLocation(o)})),r=s.slice(n).map((o)=>o.image);return this.builder.addClassAssignment(i,r),{kind:"classAssign",span:[0,0],ref:r[0],refSpan:this.tokenSpan(s[n]),nodes:i.map(({id:o,location:h})=>({id:o,span:h.span,idSpan:h.span}))}}styleStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),n),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(e){return this.nodes(e,"styleValue").map((s)=>this.visit(s))}styleValue(e){let s=this.allTokens(e),n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map((s)=>s.image).join("")}forwardSolidOperator(e){let s=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:X.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(e){let s=this.tokens(e,"BACKWARD_SOLID")[0],n=this.nodes(e,"edgeLabel")[0],i=n?this.tokens(e,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:X.BACK_ARROW,minlen:this.solidMinlen(i),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let s=this.nodes(e,"edgeLabel")[0],n=this.allTokens(e);if(!s)return{type:"association",arrowType:X.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=n.at(-1),r=i.tokenType.name==="FORWARD_SOLID"?X.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?X.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?X.CROSS_ARROW:X.LINE_SOLID;return{type:"association",arrowType:r,label:this.visit(s),minlen:r===X.SOLID_ARROW||r===X.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:X.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:X.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}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,s=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:s,classesOnReference:e.classes.length>0}}relationshipDraft(e,s,n){return{source:this.endpoint(e,!0),target:this.endpoint(s.target),location:n,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(e,s,n){return{id:s.id,span:this.nodeSpan(e),idSpan:s.location.span,labelSpan:s.label.span,...n?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:i,span:r,keySpan:o,valueSpan:h})=>({key:i,span:r,keySpan:o,valueSpan:h}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(e,s,n){return this.actorOccurrence(e,s,n)}wrap(e,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(e);for(let n of s.edges??[])n.span=s.span;return s}tokenLabel(e){let s=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=s==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(e,n);return{text:this.source.slice(i[0],i[1]),type:s,span:i}}decodePlain(e){return e.tokenType.name==="PLAIN_STRING"?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let s=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(e){let s=this.allTokens(e).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.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){let s=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,s),line:e.startLine??1,column:(e.startColumn??1)+s}}nodeSpan(e){let s=this.allTokens(e.children).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);if(!n||!i)throw 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,s=0){return[e.startOffset+s,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-s)]}nodes(e,s){return(e[s]??[]).filter((n)=>("children"in n))}tokens(e,s){return(e[s]??[]).filter((n)=>("tokenTypeIdx"in n))}firstNode(e,...s){for(let n of s){let i=this.nodes(e,n)[0];if(i)return i}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(e){let s=[];for(let n of Object.values(e))for(let i of n)if("tokenTypeIdx"in i)s.push(i);else s.push(...this.allTokens(i.children));return s.sort((n,i)=>n.startOffset-i.startOffset)}},Vo=new Ko,zo={parse:t(async(e)=>{Ns.clear(),Gt.input=[];try{Xi({diagramType:"usecase",lexer:xo,parser:Gt,entry:t(()=>Gt.start(),"entry"),visit:t((s)=>Vo.build(s,e),"visit")},e)}catch(s){Ns.clear();let n=Gt.errors[0];if(n){let{token:i}=n,r=ut(i.startOffset)?i.startOffset:e.length,o=ut(i.endOffset)?i.endOffset+1:r,h=ut(i.startLine)?i.startLine:e.slice(0,r).split(/\r\n|\r|\n/).length,u=Math.max(e.lastIndexOf(`
|
|
117
117
|
`,r-1),e.lastIndexOf("\r",r-1)),c=ut(i.startColumn)?i.startColumn:r-u,d=s instanceof Error?s.message:String(s);throw Error(`${d} at line ${h}, column ${c} [${r},${o})`)}throw s}},"parse")},Ho=["point","circle","cross","extension"],Fr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Vi=t((e,s)=>{let[n,i]=[e,s].map((r)=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${n}-${i}`},"usecaseDomId"),Xo=t((e)=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Is=t((e,s)=>{if(s!=="markdown")return e;return ci(e).map((n)=>n.map((i)=>i.content).join(" ")).join(`
|
|
118
|
-
`)},"getAccessibleLabel"),Yo=t((e)=>{let s=Is(e.label??e.id,e.labelType);if(Fr[e.shape]){let i=e.actorType&&e.actorType!=="normal"?`${e.actorType} `:"",r=e.business?"business ":"",o=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${r}${i}actor ${s}${o}`}if(e.shape==="note")return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${s}`;if(e.shape==="usecaseJsonTable"){let i=(e.jsonRows??[]).map((r)=>`${r.accessibleKey}: ${r.value}`).join("; ");return i?`${s}: ${i}`:s}let n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${s}${n}`},"getUsecaseNodeAccessibleName"),qo=t((e)=>`${e.boundaryType} system boundary ${Is(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=t((e)=>{if(e.relationshipType==="note")return"";return`${e.relationshipType==="association"&&e.label?`association ${Is(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=t((e)=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=t((e)=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=t((e,s)=>{e.diagramId=s,e.markers=[...Ho];for(let n of e.nodes){let i=n;if(i.domId=Xo(n.id),n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);if(n.stereotype)n.stereotype=ht(n.stereotype);if(!n.isGroup&&n.shape==="usecaseJsonTable")n.jsonRows=n.jsonRows?.map((r)=>({...r,key:ht(r.key),value:ht(r.value)}));if(!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){let r=n.label??ht(n.id);n.label=`«${zi(n.stereotype)}»<br/>${n.labelType==="text"?zi(r):r}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(let n of e.edges)if(n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);return e},"prepareUsecaseLayoutData"),Qo=t((e,s,n)=>{for(let r of s.nodes){let o=typeof r.domId==="string"?r.domId:Vi(s.diagramId,r.id),h=e.select(`#${o}`),u=r.isGroup?"boundary":Fr[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",c=n.nodes.get(r.id)??r.id;if(h.attr("data-usecase-id",r.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,y=m?.firstChild;if(m&&y?.nodeType===3){let I=m.ownerDocument.createElement("span");I.className="usecase-stereotype",m.insertBefore(I,y),I.appendChild(y)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(s.edges.map((r)=>[r.id,r]));e.selectAll('path[data-et="edge"]').each(function(){let r=i.get(this.getAttribute("data-id")??"");if(!r)return;let o=p(this);if(o.attr("id",Vi(s.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",n.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),Hi=t((e,s)=>{e.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=t(async(e,s,n,i)=>{a.info("Drawing usecase diagram (unified)",s);let{layout:r}=l(),o=i.db,h=o.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=he(s,h.config.securityLevel);h.layoutAlgorithm=ye(r),Zo(h,s),Hi(d,h),await ge(h,d),Qo(d,h,c);let f=h.diagramPadding;M.insertTitle(d,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),ue(d,f,"usecaseDiagram",h.useMaxWidth),Hi(d,h)},"draw"),tl={draw:el},sl=t((e)=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),nl=t((e)=>{let{theme:s,bkgColorArray:n,borderColorArray:i}=e;if(!se(s,i))return"";let r=x().usecase?.colorScheme==="rotate",o=le(e.look),h=o==="handDrawn",u=pe(n),c="";for(let d=0;d<
|
|
118
|
+
`)},"getAccessibleLabel"),Yo=t((e)=>{let s=Is(e.label??e.id,e.labelType);if(Fr[e.shape]){let i=e.actorType&&e.actorType!=="normal"?`${e.actorType} `:"",r=e.business?"business ":"",o=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${r}${i}actor ${s}${o}`}if(e.shape==="note")return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${s}`;if(e.shape==="usecaseJsonTable"){let i=(e.jsonRows??[]).map((r)=>`${r.accessibleKey}: ${r.value}`).join("; ");return i?`${s}: ${i}`:s}let n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${s}${n}`},"getUsecaseNodeAccessibleName"),qo=t((e)=>`${e.boundaryType} system boundary ${Is(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=t((e)=>{if(e.relationshipType==="note")return"";return`${e.relationshipType==="association"&&e.label?`association ${Is(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=t((e)=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"escapePlainLabel"),zi=t((e)=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=t((e,s)=>{e.diagramId=s,e.markers=[...Ho];for(let n of e.nodes){let i=n;if(i.domId=Xo(n.id),n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);if(n.stereotype)n.stereotype=ht(n.stereotype);if(!n.isGroup&&n.shape==="usecaseJsonTable")n.jsonRows=n.jsonRows?.map((r)=>({...r,key:ht(r.key),value:ht(r.value)}));if(!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){let r=n.label??ht(n.id);n.label=`«${zi(n.stereotype)}»<br/>${n.labelType==="text"?zi(r):r}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(let n of e.edges)if(n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);return e},"prepareUsecaseLayoutData"),Qo=t((e,s,n)=>{for(let r of s.nodes){let o=typeof r.domId==="string"?r.domId:Vi(s.diagramId,r.id),h=e.select(`#${o}`),u=r.isGroup?"boundary":Fr[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",c=n.nodes.get(r.id)??r.id;if(h.attr("data-usecase-id",r.id).attr("data-usecase-kind",u).attr("role","img").attr("aria-label",c),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let d=h.node(),f=d?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,y=m?.firstChild;if(m&&y?.nodeType===3){let I=m.ownerDocument.createElement("span");I.className="usecase-stereotype",m.insertBefore(I,y),I.appendChild(y)}else d?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(s.edges.map((r)=>[r.id,r]));e.selectAll('path[data-et="edge"]').each(function(){let r=i.get(this.getAttribute("data-id")??"");if(!r)return;let o=p(this);if(o.attr("id",Vi(s.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",n.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),Hi=t((e,s)=>{e.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=t(async(e,s,n,i)=>{a.info("Drawing usecase diagram (unified)",s);let{layout:r}=l(),o=i.db,h=o.getData(),u=new Map(h.nodes.map((m)=>[m.id,Is(m.label??m.id,m.labelType)])),c={nodes:new Map(h.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:u.get(m.noteTarget??"")}:m)])),edges:new Map(h.edges.map((m)=>[m.id,Jo({...m,sourceLabel:u.get(m.source)??m.sourceLabel,targetLabel:u.get(m.target)??m.targetLabel})]))},d=he(s,h.config.securityLevel);h.layoutAlgorithm=ye(r),Zo(h,s),Hi(d,h),await ge(h,d),Qo(d,h,c);let f=h.diagramPadding;M.insertTitle(d,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),ue(d,f,"usecaseDiagram",h.useMaxWidth),Hi(d,h)},"draw"),tl={draw:el},sl=t((e)=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),nl=t((e)=>{let{theme:s,bkgColorArray:n,borderColorArray:i}=e;if(!se(s,i))return"";let r=x().usecase?.colorScheme==="rotate",o=le(e.look),h=o==="handDrawn",u=pe(n),c="";for(let d=0;d<yt(i);d++){let f=i[d],m=u?`fill: ${n[d%n.length]};`:"",y=`[data-look="${o}"][data-color-id="color-${d}"]`;if(c+=`
|
|
119
119
|
|
|
120
120
|
& ${y}.system-boundary rect.boundary-body,
|
|
121
121
|
& ${y}.system-boundary rect.boundary-tab,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g,o,Y,i,r,e,n,y,Q}from"./chunk-
|
|
1
|
+
import{g,o,Y,i,r,e,n,y,Q}from"./chunk-ngt1j8py.js";import{Nn}from"./chunk-w3zgfhjb.js";import"./chunk-918e5t4x.js";var G={config:"自定义路径",env:"环境变量",system:"系统预装"};function L({connection:b}){let{Button:h,Input:P,Switch:v,SettingGroup:C,SettingRow:f,cn:x}=y(),B=Y(),[m,N]=r({}),[a,d]=r({}),[l,w]=r(null),[u,A]=r(!0),[k,R]=r(!1),[p,E]=r(!1),[I,c]=r(null),q=i(null),z=(a.executable??"")!==(m.executable??"")||Boolean(a.noSandbox)!==Boolean(m.noSandbox)||Boolean(a.ignoreCertErrors)!==Boolean(m.ignoreCertErrors),O=g(async(t)=>{R(!0);try{let s=await b.request("/api/plugins/browser/status",{signal:t});w(s)}catch(s){if(!t?.aborted)w({available:!1,error:s instanceof Error?s.message:"无法获取浏览器状态"})}finally{if(!t?.aborted)R(!1)}},[b]);o(()=>{let t=new AbortController;return q.current=t,Promise.all([b.request("/api/plugins/browser/settings",{signal:t.signal}),b.request("/api/plugins/browser/status",{signal:t.signal})]).then(([s,S])=>{if(!t.signal.aborted)N(s),d(s),w(S)}).catch((s)=>{if(!t.signal.aborted)c({type:"error",text:s instanceof Error?s.message:"读取浏览器设置失败"})}).finally(()=>{if(!t.signal.aborted)A(!1)}),()=>t.abort()},[b]);let D=async(t)=>{if(t?.preventDefault(),p||u)return;let s=new AbortController;E(!0),c(null);try{if(await b.request("/api/plugins/browser/settings",{method:"PATCH",signal:s.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),!s.signal.aborted)N(a),c({type:"success",text:"设置已保存,将在浏览器进程下次启动时生效。"}),await O(s.signal)}catch(S){if(!s.signal.aborted)c({type:"error",text:S instanceof Error?S.message:"保存设置失败"})}finally{if(!s.signal.aborted)E(!1)}},T=()=>{d(m),c(null)};return n("form",{id:B,onSubmit:D,className:"min-w-0 space-y-5",children:[e(C,{title:"运行环境",children:e(f,{title:n("span",{className:"flex items-center gap-2",children:[e("span",{className:x("size-2 shrink-0 rounded-full",l?.available?"bg-success":"bg-danger")}),l?l.available?"浏览器可用":"未检测到可用浏览器":"正在检测…"]}),description:l&&!l.available&&l.error?e("span",{className:"text-danger",children:l.error}):l?.available&&l.source?`来源:${G[l.source]??l.source}`:void 0,children:n(h,{type:"button",size:"sm",variant:"ghost",disabled:u||k,onClick:()=>void O(),className:"text-dim",children:[e(Q,{className:x("size-3.5",k&&"animate-spin")}),"重新检测"]})})}),n(C,{title:"启动参数",children:[e(f,{vertical:!0,title:"可执行文件路径",description:"留空时自动探测系统浏览器",children:n("div",{className:"flex gap-2",children:[e(P,{id:"browser-executable",disabled:u||p,value:a.executable??"",placeholder:"自动探测",onChange:(t)=>{d({...a,executable:t.target.value}),c(null)}}),a.executable&&e(h,{type:"button",variant:"ghost",size:"sm",disabled:u||p,onClick:()=>{d({...a,executable:""}),c(null)},className:"shrink-0",children:"清空"})]})}),e(f,{title:"禁用沙箱 (--no-sandbox)",description:"容器或 root 环境使用",children:e(v,{label:"禁用沙箱",disabled:u||p,checked:a.noSandbox??!1,onCheckedChange:(t)=>{d({...a,noSandbox:t}),c(null)}})}),e(f,{title:"忽略证书错误 (--ignore-certificate-errors)",description:"跳过自签名与证书有效性检查",children:e(v,{label:"忽略证书错误",disabled:u||p,checked:a.ignoreCertErrors??!1,onCheckedChange:(t)=>{d({...a,ignoreCertErrors:t}),c(null)}})})]}),e(Nn,{formID:B,notice:I,dirty:z,busy:u||p,saving:p,onReset:T})]})}export{L as default};
|