Viewing File: /usr/local/cpanel/base/frontend/jupiter/koality/_nuxt/1ErNjCdW.js
import{s as B,a as Tt,b as Et,c as Be,z as Lt,h as Pt}from"./DmaBc2ES.js";import{s as et,f as xt,h as Gt}from"./D7qtAg9b.js";import"./EJiqiqZX.js";import"./88opOQSr.js";import"./iik6CYzq.js";const $t=/[ \t\n\f\r]/g;function ke(n){return typeof n=="object"?n.type==="text"?Me(n.value):!1:Me(n)}function Me(n){return n.replace($t,"")===""}const Bt=/^>|^->|<!--|-->|--!>|<!-$/g,Mt=[">"],Ot=["<",">"];function jt(n,e,t,s){return s.settings.bogusComments?"<?"+B(n.value,Object.assign({},s.settings.characterReferences,{subset:Mt}))+">":"<!--"+n.value.replace(Bt,r)+"-->";function r(i){return B(i,Object.assign({},s.settings.characterReferences,{subset:Ot}))}}function Wt(n,e,t,s){return"<!"+(s.settings.upperDoctype?"DOCTYPE":"doctype")+(s.settings.tightDoctype?"":" ")+"html>"}const C=nt(1),tt=nt(-1),Dt=[];function nt(n){return e;function e(t,s,r){const i=t?t.children:Dt;let a=(s||0)+n,c=i[a];if(!r)for(;c&&ke(c);)a+=n,c=i[a];return c}}const Ft={}.hasOwnProperty;function st(n){return e;function e(t,s,r){return Ft.call(n,t.tagName)&&n[t.tagName](t,s,r)}}const Ie=st({body:qt,caption:fe,colgroup:fe,dd:Vt,dt:Kt,head:fe,html:zt,li:Ut,optgroup:Jt,option:Qt,p:Ht,rp:Oe,rt:Oe,tbody:Xt,td:je,tfoot:Zt,th:je,thead:Yt,tr:en});function fe(n,e,t){const s=C(t,e,!0);return!s||s.type!=="comment"&&!(s.type==="text"&&ke(s.value.charAt(0)))}function zt(n,e,t){const s=C(t,e);return!s||s.type!=="comment"}function qt(n,e,t){const s=C(t,e);return!s||s.type!=="comment"}function Ht(n,e,t){const s=C(t,e);return s?s.type==="element"&&(s.tagName==="address"||s.tagName==="article"||s.tagName==="aside"||s.tagName==="blockquote"||s.tagName==="details"||s.tagName==="div"||s.tagName==="dl"||s.tagName==="fieldset"||s.tagName==="figcaption"||s.tagName==="figure"||s.tagName==="footer"||s.tagName==="form"||s.tagName==="h1"||s.tagName==="h2"||s.tagName==="h3"||s.tagName==="h4"||s.tagName==="h5"||s.tagName==="h6"||s.tagName==="header"||s.tagName==="hgroup"||s.tagName==="hr"||s.tagName==="main"||s.tagName==="menu"||s.tagName==="nav"||s.tagName==="ol"||s.tagName==="p"||s.tagName==="pre"||s.tagName==="section"||s.tagName==="table"||s.tagName==="ul"):!t||!(t.type==="element"&&(t.tagName==="a"||t.tagName==="audio"||t.tagName==="del"||t.tagName==="ins"||t.tagName==="map"||t.tagName==="noscript"||t.tagName==="video"))}function Ut(n,e,t){const s=C(t,e);return!s||s.type==="element"&&s.tagName==="li"}function Kt(n,e,t){const s=C(t,e);return!!(s&&s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd"))}function Vt(n,e,t){const s=C(t,e);return!s||s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd")}function Oe(n,e,t){const s=C(t,e);return!s||s.type==="element"&&(s.tagName==="rp"||s.tagName==="rt")}function Jt(n,e,t){const s=C(t,e);return!s||s.type==="element"&&s.tagName==="optgroup"}function Qt(n,e,t){const s=C(t,e);return!s||s.type==="element"&&(s.tagName==="option"||s.tagName==="optgroup")}function Yt(n,e,t){const s=C(t,e);return!!(s&&s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot"))}function Xt(n,e,t){const s=C(t,e);return!s||s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot")}function Zt(n,e,t){return!C(t,e)}function en(n,e,t){const s=C(t,e);return!s||s.type==="element"&&s.tagName==="tr"}function je(n,e,t){const s=C(t,e);return!s||s.type==="element"&&(s.tagName==="td"||s.tagName==="th")}const tn=st({body:rn,colgroup:on,head:sn,html:nn,tbody:an});function nn(n){const e=C(n,-1);return!e||e.type!=="comment"}function sn(n){const e=new Set;for(const s of n.children)if(s.type==="element"&&(s.tagName==="base"||s.tagName==="title")){if(e.has(s.tagName))return!1;e.add(s.tagName)}const t=n.children[0];return!t||t.type==="element"}function rn(n){const e=C(n,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&ke(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function on(n,e,t){const s=tt(t,e),r=C(n,-1,!0);return t&&s&&s.type==="element"&&s.tagName==="colgroup"&&Ie(s,t.children.indexOf(s),t)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function an(n,e,t){const s=tt(t,e),r=C(n,-1);return t&&s&&s.type==="element"&&(s.tagName==="thead"||s.tagName==="tbody")&&Ie(s,t.children.indexOf(s),t)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}const K={name:[[`
\f\r &/=>`.split(""),`
\f\r "&'/=>\``.split("")],[`\0
\f\r "&'/<=>`.split(""),`\0
\f\r "&'/<=>\``.split("")]],unquoted:[[`
\f\r &>`.split(""),`\0
\f\r "&'<=>\``.split("")],[`\0
\f\r "&'<=>\``.split(""),`\0
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function cn(n,e,t,s){const r=s.schema,i=r.space==="svg"?!1:s.settings.omitOptionalTags;let a=r.space==="svg"?s.settings.closeEmptyElements:s.settings.voids.includes(n.tagName.toLowerCase());const c=[];let o;r.space==="html"&&n.tagName==="svg"&&(s.schema=et);const l=ln(s,n.properties),h=s.all(r.space==="html"&&n.tagName==="template"?n.content:n);return s.schema=r,h&&(a=!1),(l||!i||!tn(n,e,t))&&(c.push("<",n.tagName,l?" "+l:""),a&&(r.space==="svg"||s.settings.closeSelfClosing)&&(o=l.charAt(l.length-1),(!s.settings.tightSelfClosing||o==="/"||o&&o!=='"'&&o!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(h),!a&&(!i||!Ie(n,e,t))&&c.push("</"+n.tagName+">"),c.join("")}function ln(n,e){const t=[];let s=-1,r;if(e){for(r in e)if(e[r]!==null&&e[r]!==void 0){const i=hn(n,r,e[r]);i&&t.push(i)}}for(;++s<t.length;){const i=n.settings.tightAttributes?t[s].charAt(t[s].length-1):void 0;s!==t.length-1&&i!=='"'&&i!=="'"&&(t[s]+=" ")}return t.join("")}function hn(n,e,t){const s=xt(n.schema,e),r=n.settings.allowParseErrors&&n.schema.space==="html"?0:1,i=n.settings.allowDangerousCharacters?0:1;let a=n.quote,c;if(s.overloadedBoolean&&(t===s.attribute||t==="")?t=!0:(s.boolean||s.overloadedBoolean)&&(typeof t!="string"||t===s.attribute||t==="")&&(t=!!t),t==null||t===!1||typeof t=="number"&&Number.isNaN(t))return"";const o=B(s.attribute,Object.assign({},n.settings.characterReferences,{subset:K.name[r][i]}));return t===!0||(t=Array.isArray(t)?(s.commaSeparated?Tt:Et)(t,{padLeft:!n.settings.tightCommaSeparatedLists}):String(t),n.settings.collapseEmptyAttributes&&!t)?o:(n.settings.preferUnquoted&&(c=B(t,Object.assign({},n.settings.characterReferences,{attribute:!0,subset:K.unquoted[r][i]}))),c!==t&&(n.settings.quoteSmart&&Be(t,a)>Be(t,n.alternative)&&(a=n.alternative),c=a+B(t,Object.assign({},n.settings.characterReferences,{subset:(a==="'"?K.single:K.double)[r][i],attribute:!0}))+a),o+(c&&"="+c))}const un=["<","&"];function rt(n,e,t,s){return t&&t.type==="element"&&(t.tagName==="script"||t.tagName==="style")?n.value:B(n.value,Object.assign({},s.settings.characterReferences,{subset:un}))}function fn(n,e,t,s){return s.settings.allowDangerousHtml?n.value:rt(n,e,t,s)}function dn(n,e,t,s){return s.all(n)}const pn=Lt("type",{invalid:mn,unknown:gn,handlers:{comment:jt,doctype:Wt,element:cn,raw:fn,root:dn,text:rt}});function mn(n){throw new Error("Expected node, not `"+n+"`")}function gn(n){const e=n;throw new Error("Cannot compile unknown node `"+e.type+"`")}const _n={},yn={},bn=[];function Sn(n,e){const t=e||_n,s=t.quote||'"',r=s==='"'?"'":'"';if(s!=='"'&&s!=="'")throw new Error("Invalid quote `"+s+"`, expected `'` or `\"`");return{one:Cn,all:wn,settings:{omitOptionalTags:t.omitOptionalTags||!1,allowParseErrors:t.allowParseErrors||!1,allowDangerousCharacters:t.allowDangerousCharacters||!1,quoteSmart:t.quoteSmart||!1,preferUnquoted:t.preferUnquoted||!1,tightAttributes:t.tightAttributes||!1,upperDoctype:t.upperDoctype||!1,tightDoctype:t.tightDoctype||!1,bogusComments:t.bogusComments||!1,tightCommaSeparatedLists:t.tightCommaSeparatedLists||!1,tightSelfClosing:t.tightSelfClosing||!1,collapseEmptyAttributes:t.collapseEmptyAttributes||!1,allowDangerousHtml:t.allowDangerousHtml||!1,voids:t.voids||Pt,characterReferences:t.characterReferences||yn,closeSelfClosing:t.closeSelfClosing||!1,closeEmptyElements:t.closeEmptyElements||!1},schema:t.space==="svg"?et:Gt,quote:s,alternative:r}.one(Array.isArray(n)?{type:"root",children:n}:n,void 0,void 0)}function Cn(n,e,t){return pn(n,e,t,this)}function wn(n){const e=[],t=n&&n.children||bn;let s=-1;for(;++s<t.length;)e[s]=this.one(t[s],s,n);return e.join("")}let w=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Rn(n){return ve(n)}function ve(n){return Array.isArray(n)?Nn(n):n instanceof RegExp?n:typeof n=="object"?kn(n):n}function Nn(n){let e=[];for(let t=0,s=n.length;t<s;t++)e[t]=ve(n[t]);return e}function kn(n){let e={};for(let t in n)e[t]=ve(n[t]);return e}function it(n,...e){return e.forEach(t=>{for(let s in t)n[s]=t[s]}),n}function ot(n){const e=~n.lastIndexOf("/")||~n.lastIndexOf("\\");return e===0?n:~e===n.length-1?ot(n.substring(0,n.length-1)):n.substr(~e+1)}var de=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,V=class{static hasCaptures(n){return n===null?!1:(de.lastIndex=0,de.test(n))}static replaceCaptures(n,e,t){return n.replace(de,(s,r,i,a)=>{let c=t[parseInt(r||i,10)];if(c){let o=e.substring(c.start,c.end);for(;o[0]===".";)o=o.substring(1);switch(a){case"downcase":return o.toLowerCase();case"upcase":return o.toUpperCase();default:return o}}else return s})}};function at(n,e){return n<e?-1:n>e?1:0}function ct(n,e){if(n===null&&e===null)return 0;if(!n)return-1;if(!e)return 1;let t=n.length,s=e.length;if(t===s){for(let r=0;r<t;r++){let i=at(n[r],e[r]);if(i!==0)return i}return 0}return t-s}function We(n){return!!(/^#[0-9a-f]{6}$/i.test(n)||/^#[0-9a-f]{8}$/i.test(n)||/^#[0-9a-f]{3}$/i.test(n)||/^#[0-9a-f]{4}$/i.test(n))}function lt(n){return n.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var ht=class{constructor(n){this.fn=n}cache=new Map;get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.fn(n);return this.cache.set(n,e),e}},Y=class{constructor(n,e,t){this._colorMap=n,this._defaults=e,this._root=t}static createFromRawTheme(n,e){return this.createFromParsedTheme(An(n),e)}static createFromParsedTheme(n,e){return En(n,e)}_cachedMatchRoot=new ht(n=>this._root.match(n));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(n){if(n===null)return this._defaults;const e=n.scopeName,s=this._cachedMatchRoot.get(e).find(r=>In(n.parent,r.parentScopes));return s?new ut(s.fontStyle,s.foreground,s.background):null}},pe=class J{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const s of t)e=new J(e,s);return e}static from(...e){let t=null;for(let s=0;s<e.length;s++)t=new J(t,e[s]);return t}push(e){return new J(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let s=this;for(;s&&s!==e;)t.push(s.scopeName),s=s.parent;return s===e?t.reverse():void 0}};function In(n,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let s=e[t],r=!1;if(s===">"){if(t===e.length-1)return!1;s=e[++t],r=!0}for(;n&&!vn(n.scopeName,s);){if(r)return!1;n=n.parent}if(!n)return!1;n=n.parent}return!0}function vn(n,e){return e===n||n.startsWith(e)&&n[e.length]==="."}var ut=class{constructor(n,e,t){this.fontStyle=n,this.foregroundId=e,this.backgroundId=t}};function An(n){if(!n)return[];if(!n.settings||!Array.isArray(n.settings))return[];let e=n.settings,t=[],s=0;for(let r=0,i=e.length;r<i;r++){let a=e[r];if(!a.settings)continue;let c;if(typeof a.scope=="string"){let u=a.scope;u=u.replace(/^[,]+/,""),u=u.replace(/[,]+$/,""),c=u.split(",")}else Array.isArray(a.scope)?c=a.scope:c=[""];let o=-1;if(typeof a.settings.fontStyle=="string"){o=0;let u=a.settings.fontStyle.split(" ");for(let d=0,p=u.length;d<p;d++)switch(u[d]){case"italic":o=o|1;break;case"bold":o=o|2;break;case"underline":o=o|4;break;case"strikethrough":o=o|8;break}}let l=null;typeof a.settings.foreground=="string"&&We(a.settings.foreground)&&(l=a.settings.foreground);let h=null;typeof a.settings.background=="string"&&We(a.settings.background)&&(h=a.settings.background);for(let u=0,d=c.length;u<d;u++){let f=c[u].trim().split(" "),b=f[f.length-1],_=null;f.length>1&&(_=f.slice(0,f.length-1),_.reverse()),t[s++]=new Tn(b,_,r,o,l,h)}}return t}var Tn=class{constructor(n,e,t,s,r,i){this.scope=n,this.parentScopes=e,this.index=t,this.fontStyle=s,this.foreground=r,this.background=i}},N=(n=>(n[n.NotSet=-1]="NotSet",n[n.None=0]="None",n[n.Italic=1]="Italic",n[n.Bold=2]="Bold",n[n.Underline=4]="Underline",n[n.Strikethrough=8]="Strikethrough",n))(N||{});function En(n,e){n.sort((o,l)=>{let h=at(o.scope,l.scope);return h!==0||(h=ct(o.parentScopes,l.parentScopes),h!==0)?h:o.index-l.index});let t=0,s="#000000",r="#ffffff";for(;n.length>=1&&n[0].scope==="";){let o=n.shift();o.fontStyle!==-1&&(t=o.fontStyle),o.foreground!==null&&(s=o.foreground),o.background!==null&&(r=o.background)}let i=new Ln(e),a=new ut(t,i.getId(s),i.getId(r)),c=new xn(new _e(0,null,-1,0,0),[]);for(let o=0,l=n.length;o<l;o++){let h=n[o];c.insert(0,h.scope,h.parentScopes,h.fontStyle,i.getId(h.foreground),i.getId(h.background))}return new Y(i,a,c)}var Ln=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(n){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(n)){this._isFrozen=!0;for(let e=0,t=n.length;e<t;e++)this._color2id[n[e]]=e,this._id2color[e]=n[e]}else this._isFrozen=!1}getId(n){if(n===null)return 0;n=n.toUpperCase();let e=this._color2id[n];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${n}`);return e=++this._lastColorId,this._color2id[n]=e,this._id2color[e]=n,e}getColorMap(){return this._id2color.slice(0)}},Pn=Object.freeze([]),_e=class ft{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,t,s,r,i){this.scopeDepth=e,this.parentScopes=t||Pn,this.fontStyle=s,this.foreground=r,this.background=i}clone(){return new ft(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let s=0,r=e.length;s<r;s++)t[s]=e[s].clone();return t}acceptOverwrite(e,t,s,r){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),s!==0&&(this.foreground=s),r!==0&&(this.background=r)}},xn=class ye{constructor(e,t=[],s={}){this._mainRule=e,this._children=s,this._rulesWithParentScopes=t}_rulesWithParentScopes;static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let s=0,r=0;for(;e.parentScopes[s]===">"&&s++,t.parentScopes[r]===">"&&r++,!(s>=e.parentScopes.length||r>=t.parentScopes.length);){const i=t.parentScopes[r].length-e.parentScopes[s].length;if(i!==0)return i;s++,r++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let s=e.indexOf("."),r,i;if(s===-1?(r=e,i=""):(r=e.substring(0,s),i=e.substring(s+1)),this._children.hasOwnProperty(r))return this._children[r].match(i)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(ye._cmpBySpecificity),t}insert(e,t,s,r,i,a){if(t===""){this._doInsertHere(e,s,r,i,a);return}let c=t.indexOf("."),o,l;c===-1?(o=t,l=""):(o=t.substring(0,c),l=t.substring(c+1));let h;this._children.hasOwnProperty(o)?h=this._children[o]:(h=new ye(this._mainRule.clone(),_e.cloneArr(this._rulesWithParentScopes)),this._children[o]=h),h.insert(e+1,l,s,r,i,a)}_doInsertHere(e,t,s,r,i){if(t===null){this._mainRule.acceptOverwrite(e,s,r,i);return}for(let a=0,c=this._rulesWithParentScopes.length;a<c;a++){let o=this._rulesWithParentScopes[a];if(ct(o.parentScopes,t)===0){o.acceptOverwrite(e,s,r,i);return}}s===-1&&(s=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),i===0&&(i=this._mainRule.background),this._rulesWithParentScopes.push(new _e(e,t,s,r,i))}},M=class I{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=I.getLanguageId(e),s=I.getTokenType(e),r=I.getFontStyle(e),i=I.getForeground(e),a=I.getBackground(e);console.log({languageId:t,tokenType:s,fontStyle:r,foreground:i,background:a})}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,t,s,r,i,a,c){let o=I.getLanguageId(e),l=I.getTokenType(e),h=I.containsBalancedBrackets(e)?1:0,u=I.getFontStyle(e),d=I.getForeground(e),p=I.getBackground(e);return t!==0&&(o=t),s!==8&&(l=s),r!==null&&(h=r?1:0),i!==-1&&(u=i),a!==0&&(d=a),c!==0&&(p=c),(o<<0|l<<8|h<<10|u<<11|d<<15|p<<24)>>>0}};function X(n,e){const t=[],s=Gn(n);let r=s.next();for(;r!==null;){let o=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":o=1;break;case"L":o=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=s.next()}let l=a();if(t.push({matcher:l,priority:o}),r!==",")break;r=s.next()}return t;function i(){if(r==="-"){r=s.next();const o=i();return l=>!!o&&!o(l)}if(r==="("){r=s.next();const o=c();return r===")"&&(r=s.next()),o}if(De(r)){const o=[];do o.push(r),r=s.next();while(De(r));return l=>e(o,l)}return null}function a(){const o=[];let l=i();for(;l;)o.push(l),l=i();return h=>o.every(u=>u(h))}function c(){const o=[];let l=a();for(;l&&(o.push(l),r==="|"||r===",");){do r=s.next();while(r==="|"||r===",");l=a()}return h=>o.some(u=>u(h))}}function De(n){return!!n&&!!n.match(/[\w\.:]+/)}function Gn(n){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(n);return{next:()=>{if(!t)return null;const s=t[0];return t=e.exec(n),s}}}function dt(n){typeof n.dispose=="function"&&n.dispose()}var F=class{constructor(n){this.scopeName=n}toKey(){return this.scopeName}},$n=class{constructor(n,e){this.scopeName=n,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},Bn=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(n){const e=n.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(n))}},Mn=class{constructor(n,e){this.repo=n,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new F(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const n=this.Q;this.Q=[];const e=new Bn;for(const t of n)On(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof F){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function On(n,e,t,s){const r=t.lookup(n.scopeName);if(!r){if(n.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const i=t.lookup(e);n instanceof F?Q({baseGrammar:i,selfGrammar:r},s):be(n.ruleName,{baseGrammar:i,selfGrammar:r,repository:r.repository},s);const a=t.injections(n.scopeName);if(a)for(const c of a)s.add(new F(c))}function be(n,e,t){if(e.repository&&e.repository[n]){const s=e.repository[n];Z([s],e,t)}}function Q(n,e){n.selfGrammar.patterns&&Array.isArray(n.selfGrammar.patterns)&&Z(n.selfGrammar.patterns,{...n,repository:n.selfGrammar.repository},e),n.selfGrammar.injections&&Z(Object.values(n.selfGrammar.injections),{...n,repository:n.selfGrammar.repository},e)}function Z(n,e,t){for(const s of n){if(t.visitedRule.has(s))continue;t.visitedRule.add(s);const r=s.repository?it({},e.repository,s.repository):e.repository;Array.isArray(s.patterns)&&Z(s.patterns,{...e,repository:r},t);const i=s.include;if(!i)continue;const a=pt(i);switch(a.kind){case 0:Q({...e,selfGrammar:e.baseGrammar},t);break;case 1:Q(e,t);break;case 2:be(a.ruleName,{...e,repository:r},t);break;case 3:case 4:const c=a.scopeName===e.selfGrammar.scopeName?e.selfGrammar:a.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(c){const o={baseGrammar:e.baseGrammar,selfGrammar:c,repository:r};a.kind===4?be(a.ruleName,o,t):Q(o,t)}else a.kind===4?t.add(new $n(a.scopeName,a.ruleName)):t.add(new F(a.scopeName));break}}}var jn=class{kind=0},Wn=class{kind=1},Dn=class{constructor(n){this.ruleName=n}kind=2},Fn=class{constructor(n){this.scopeName=n}kind=3},zn=class{constructor(n,e){this.scopeName=n,this.ruleName=e}kind=4};function pt(n){if(n==="$base")return new jn;if(n==="$self")return new Wn;const e=n.indexOf("#");if(e===-1)return new Fn(n);if(e===0)return new Dn(n.substring(1));{const t=n.substring(0,e),s=n.substring(e+1);return new zn(t,s)}}var qn=/\\(\d+)/,Fe=/\\(\d+)/g,Hn=-1,mt=-2;var U=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(n,e,t,s){this.$location=n,this.id=e,this._name=t||null,this._nameIsCapturing=V.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=V.hasCaptures(this._contentName)}get debugName(){const n=this.$location?`${ot(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${n}`}getName(n,e){return!this._nameIsCapturing||this._name===null||n===null||e===null?this._name:V.replaceCaptures(this._name,n,e)}getContentName(n,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:V.replaceCaptures(this._contentName,n,e)}},Un=class extends U{retokenizeCapturedWithRuleId;constructor(n,e,t,s,r){super(n,e,t,s),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(n,e){throw new Error("Not supported!")}compile(n,e){throw new Error("Not supported!")}compileAG(n,e,t,s){throw new Error("Not supported!")}},Kn=class extends U{_match;captures;_cachedCompiledPatterns;constructor(n,e,t,s,r){super(n,e,t,null),this._match=new z(s,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(n,e){e.push(this._match)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,s){return this._getCachedCompiledPatterns(n).compileAG(n,t,s)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new q,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ze=class extends U{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,s,r){super(n,e,t,s),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(n,e){for(const t of this.patterns)n.getRule(t).collectPatterns(n,e)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,s){return this._getCachedCompiledPatterns(n).compileAG(n,t,s)}_getCachedCompiledPatterns(n){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new q,this.collectPatterns(n,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Se=class extends U{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(n,e,t,s,r,i,a,c,o,l){super(n,e,t,s),this._begin=new z(r,this.id),this.beginCaptures=i,this._end=new z(a||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=c,this.applyEndPatternLast=o||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(n,e){return this._end.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n,e).compile(n)}compileAG(n,e,t,s){return this._getCachedCompiledPatterns(n,e).compileAG(n,t,s)}_getCachedCompiledPatterns(n,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new q;for(const t of this.patterns)n.getRule(t).collectPatterns(n,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},ee=class extends U{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(n,e,t,s,r,i,a,c,o){super(n,e,t,s),this._begin=new z(r,this.id),this.beginCaptures=i,this.whileCaptures=c,this._while=new z(a,mt),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=o.patterns,this.hasMissingPatterns=o.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(n,e){return this._while.resolveBackReferences(n,e)}collectPatterns(n,e){e.push(this._begin)}compile(n,e){return this._getCachedCompiledPatterns(n).compile(n)}compileAG(n,e,t,s){return this._getCachedCompiledPatterns(n).compileAG(n,t,s)}_getCachedCompiledPatterns(n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new q;for(const e of this.patterns)n.getRule(e).collectPatterns(n,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(n,e){return this._getCachedCompiledWhilePatterns(n,e).compile(n)}compileWhileAG(n,e,t,s){return this._getCachedCompiledWhilePatterns(n,e).compileAG(n,t,s)}_getCachedCompiledWhilePatterns(n,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new q,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||""),this._cachedCompiledWhilePatterns}},gt=class R{static createCaptureRule(e,t,s,r,i){return e.registerRule(a=>new Un(t,a,s,r,i))}static getCompiledRuleId(e,t,s){return e.id||t.registerRule(r=>{if(e.id=r,e.match)return new Kn(e.$vscodeTextmateLocation,e.id,e.name,e.match,R._compileCaptures(e.captures,t,s));if(typeof e.begin>"u"){e.repository&&(s=it({},s,e.repository));let i=e.patterns;return typeof i>"u"&&e.include&&(i=[{include:e.include}]),new ze(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,R._compilePatterns(i,t,s))}return e.while?new ee(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,t,s),e.while,R._compileCaptures(e.whileCaptures||e.captures,t,s),R._compilePatterns(e.patterns,t,s)):new Se(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,t,s),e.end,R._compileCaptures(e.endCaptures||e.captures,t,s),e.applyEndPatternLast,R._compilePatterns(e.patterns,t,s))}),e.id}static _compileCaptures(e,t,s){let r=[];if(e){let i=0;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const c=parseInt(a,10);c>i&&(i=c)}for(let a=0;a<=i;a++)r[a]=null;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const c=parseInt(a,10);let o=0;e[a].patterns&&(o=R.getCompiledRuleId(e[a],t,s)),r[c]=R.createCaptureRule(t,e[a].$vscodeTextmateLocation,e[a].name,e[a].contentName,o)}}return r}static _compilePatterns(e,t,s){let r=[];if(e)for(let i=0,a=e.length;i<a;i++){const c=e[i];let o=-1;if(c.include){const l=pt(c.include);switch(l.kind){case 0:case 1:o=R.getCompiledRuleId(s[c.include],t,s);break;case 2:let h=s[l.ruleName];h&&(o=R.getCompiledRuleId(h,t,s));break;case 3:case 4:const u=l.scopeName,d=l.kind===4?l.ruleName:null,p=t.getExternalGrammar(u,s);if(p)if(d){let f=p.repository[d];f&&(o=R.getCompiledRuleId(f,t,p.repository))}else o=R.getCompiledRuleId(p.repository.$self,t,p.repository);break}}else o=R.getCompiledRuleId(c,t,s);if(o!==-1){const l=t.getRule(o);let h=!1;if((l instanceof ze||l instanceof Se||l instanceof ee)&&l.hasMissingPatterns&&l.patterns.length===0&&(h=!0),h)continue;r.push(o)}}return{patterns:r,hasMissingPatterns:(e?e.length:0)!==r.length}}},z=class _t{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,t){if(e&&typeof e=="string"){const s=e.length;let r=0,i=[],a=!1;for(let c=0;c<s;c++)if(e.charAt(c)==="\\"&&c+1<s){const l=e.charAt(c+1);l==="z"?(i.push(e.substring(r,c)),i.push("$(?!\\n)(?<!\\n)"),r=c+2):(l==="A"||l==="G")&&(a=!0),c++}this.hasAnchor=a,r===0?this.source=e:(i.push(e.substring(r,s)),this.source=i.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=qn.test(this.source):this.hasBackReferences=!1}clone(){return new _t(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let s=t.map(r=>e.substring(r.start,r.end));return Fe.lastIndex=0,this.source.replace(Fe,(r,i)=>lt(s[parseInt(i,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],s=[],r=[],i,a,c,o;for(i=0,a=this.source.length;i<a;i++)c=this.source.charAt(i),e[i]=c,t[i]=c,s[i]=c,r[i]=c,c==="\\"&&i+1<a&&(o=this.source.charAt(i+1),o==="A"?(e[i+1]="",t[i+1]="",s[i+1]="A",r[i+1]="A"):o==="G"?(e[i+1]="",t[i+1]="G",s[i+1]="",r[i+1]="G"):(e[i+1]=o,t[i+1]=o,s[i+1]=o,r[i+1]=o),i++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:s.join(""),A1_G1:r.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},q=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(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(n){this._items.push(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}unshift(n){this._items.unshift(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}length(){return this._items.length}setSource(n,e){this._items[n].source!==e&&(this._disposeCaches(),this._items[n].setSource(e))}compile(n){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new qe(n,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(n,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G0):this.compile(n)}_resolveAnchors(n,e,t){let s=this._items.map(r=>r.resolveAnchors(e,t));return new qe(n,s,this._items.map(r=>r.ruleId))}},qe=class{constructor(n,e,t){this.regExps=e,this.rules=t,this.scanner=n.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const n=[];for(let e=0,t=this.rules.length;e<t;e++)n.push(" - "+this.rules[e]+": "+this.regExps[e]);return n.join(`
`)}findNextMatchSync(n,e,t){const s=this.scanner.findNextMatchSync(n,e,t);return s?{ruleId:this.rules[s.index],captureIndices:s.captureIndices}:null}},me=class{constructor(n,e){this.languageId=n,this.tokenType=e}},Vn=class Ce{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,t){this._defaultAttributes=new me(e,8),this._embeddedLanguagesMatcher=new Jn(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?Ce._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new me(0,0);_getBasicScopeAttributes=new ht(e=>{const t=this._scopeToLanguage(e),s=this._toStandardTokenType(e);return new me(t,s)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(Ce.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Jn=class{values;scopesRegExp;constructor(n){if(n.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(n);const e=n.map(([t,s])=>lt(t));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(n){if(!this.scopesRegExp)return;const e=n.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},He=class{constructor(n,e){this.stack=n,this.stoppedEarly=e}};function yt(n,e,t,s,r,i,a,c){const o=e.content.length;let l=!1,h=-1;if(a){const p=Qn(n,e,t,s,r,i);r=p.stack,s=p.linePos,t=p.isFirstLine,h=p.anchorPosition}const u=Date.now();for(;!l;){if(c!==0&&Date.now()-u>c)return new He(r,!0);d()}return new He(r,!1);function d(){const p=Yn(n,e,t,s,r,h);if(!p){i.produce(r,o),l=!0;return}const f=p.captureIndices,b=p.matchedRuleId,_=f&&f.length>0?f[0].end>s:!1;if(b===Hn){const g=r.getRule(n);i.produce(r,f[0].start),r=r.withContentNameScopesList(r.nameScopesList),W(n,e,t,r,i,g.endCaptures,f),i.produce(r,f[0].end);const m=r;if(r=r.parent,h=m.getAnchorPos(),!_&&m.getEnterPos()===s){r=m,i.produce(r,o),l=!0;return}}else{const g=n.getRule(b);i.produce(r,f[0].start);const m=r,y=g.getName(e.content,f),k=r.contentNameScopesList.pushAttributed(y,n);if(r=r.push(b,s,h,f[0].end===o,null,k,k),g instanceof Se){const S=g;W(n,e,t,r,i,S.beginCaptures,f),i.produce(r,f[0].end),h=f[0].end;const T=S.getContentName(e.content,f),L=k.pushAttributed(T,n);if(r=r.withContentNameScopesList(L),S.endHasBackReferences&&(r=r.withEndRule(S.getEndWithResolvedBackReferences(e.content,f))),!_&&m.hasSameRuleAs(r)){r=r.pop(),i.produce(r,o),l=!0;return}}else if(g instanceof ee){const S=g;W(n,e,t,r,i,S.beginCaptures,f),i.produce(r,f[0].end),h=f[0].end;const T=S.getContentName(e.content,f),L=k.pushAttributed(T,n);if(r=r.withContentNameScopesList(L),S.whileHasBackReferences&&(r=r.withEndRule(S.getWhileWithResolvedBackReferences(e.content,f))),!_&&m.hasSameRuleAs(r)){r=r.pop(),i.produce(r,o),l=!0;return}}else if(W(n,e,t,r,i,g.captures,f),i.produce(r,f[0].end),r=r.pop(),!_){r=r.safePop(),i.produce(r,o),l=!0;return}}f[0].end>s&&(s=f[0].end,t=!1)}}function Qn(n,e,t,s,r,i){let a=r.beginRuleCapturedEOL?0:-1;const c=[];for(let o=r;o;o=o.pop()){const l=o.getRule(n);l instanceof ee&&c.push({rule:l,stack:o})}for(let o=c.pop();o;o=c.pop()){const{ruleScanner:l,findOptions:h}=es(o.rule,n,o.stack.endRule,t,s===a),u=l.findNextMatchSync(e,s,h);if(u){if(u.ruleId!==mt){r=o.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(i.produce(o.stack,u.captureIndices[0].start),W(n,e,t,o.stack,i,o.rule.whileCaptures,u.captureIndices),i.produce(o.stack,u.captureIndices[0].end),a=u.captureIndices[0].end,u.captureIndices[0].end>s&&(s=u.captureIndices[0].end,t=!1))}else{r=o.stack.pop();break}}return{stack:r,linePos:s,anchorPosition:a,isFirstLine:t}}function Yn(n,e,t,s,r,i){const a=Xn(n,e,t,s,r,i),c=n.getInjections();if(c.length===0)return a;const o=Zn(c,n,e,t,s,r,i);if(!o)return a;if(!a)return o;const l=a.captureIndices[0].start,h=o.captureIndices[0].start;return h<l||o.priorityMatch&&h===l?o:a}function Xn(n,e,t,s,r,i){const a=r.getRule(n),{ruleScanner:c,findOptions:o}=bt(a,n,r.endRule,t,s===i),l=c.findNextMatchSync(e,s,o);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function Zn(n,e,t,s,r,i,a){let c=Number.MAX_VALUE,o=null,l,h=0;const u=i.contentNameScopesList.getScopeNames();for(let d=0,p=n.length;d<p;d++){const f=n[d];if(!f.matcher(u))continue;const b=e.getRule(f.ruleId),{ruleScanner:_,findOptions:g}=bt(b,e,null,s,r===a),m=_.findNextMatchSync(t,r,g);if(!m)continue;const y=m.captureIndices[0].start;if(!(y>=c)&&(c=y,o=m.captureIndices,l=m.ruleId,h=f.priority,c===r))break}return o?{priorityMatch:h===-1,captureIndices:o,matchedRuleId:l}:null}function bt(n,e,t,s,r){return{ruleScanner:n.compileAG(e,t,s,r),findOptions:0}}function es(n,e,t,s,r){return{ruleScanner:n.compileWhileAG(e,t,s,r),findOptions:0}}function W(n,e,t,s,r,i,a){if(i.length===0)return;const c=e.content,o=Math.min(i.length,a.length),l=[],h=a[0].end;for(let u=0;u<o;u++){const d=i[u];if(d===null)continue;const p=a[u];if(p.length===0)continue;if(p.start>h)break;for(;l.length>0&&l[l.length-1].endPos<=p.start;)r.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?r.produceFromScopes(l[l.length-1].scopes,p.start):r.produce(s,p.start),d.retokenizeCapturedWithRuleId){const b=d.getName(c,a),_=s.contentNameScopesList.pushAttributed(b,n),g=d.getContentName(c,a),m=_.pushAttributed(g,n),y=s.push(d.retokenizeCapturedWithRuleId,p.start,-1,!1,null,_,m),k=n.createOnigString(c.substring(0,p.end));yt(n,k,t&&p.start===0,p.start,y,r,!1,0),dt(k);continue}const f=d.getName(c,a);if(f!==null){const _=(l.length>0?l[l.length-1].scopes:s.contentNameScopesList).pushAttributed(f,n);l.push(new ts(_,p.end))}}for(;l.length>0;)r.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var ts=class{scopes;endPos;constructor(n,e){this.scopes=n,this.endPos=e}};function ns(n,e,t,s,r,i,a,c){return new rs(n,e,t,s,r,i,a,c)}function Ue(n,e,t,s,r){const i=X(e,te),a=gt.getCompiledRuleId(t,s,r.repository);for(const c of i)n.push({debugSelector:e,matcher:c.matcher,ruleId:a,grammar:r,priority:c.priority})}function te(n,e){if(e.length<n.length)return!1;let t=0;return n.every(s=>{for(let r=t;r<e.length;r++)if(ss(e[r],s))return t=r+1,!0;return!1})}function ss(n,e){if(!n)return!1;if(n===e)return!0;const t=e.length;return n.length>t&&n.substr(0,t)===e&&n[t]==="."}var rs=class{constructor(n,e,t,s,r,i,a,c){if(this._rootScopeName=n,this.balancedBracketSelectors=i,this._onigLib=c,this._basicScopeAttributesProvider=new Vn(t,s),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=Ke(e,null),this._injections=null,this._tokenTypeMatchers=[],r)for(const o of Object.keys(r)){const l=X(o,te);for(const h of l)this._tokenTypeMatchers.push({matcher:h.matcher,type:r[o]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const n of this._ruleId2desc)n&&n.dispose()}createOnigScanner(n){return this._onigLib.createOnigScanner(n)}createOnigString(n){return this._onigLib.createOnigString(n)}getMetadataForScope(n){return this._basicScopeAttributesProvider.getBasicScopeAttributes(n)}_collectInjections(){const n={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},e=[],t=this._rootScopeName,s=n.lookup(t);if(s){const r=s.injections;if(r)for(let a in r)Ue(e,a,r[a],this,s);const i=this._grammarRepository.injections(t);i&&i.forEach(a=>{const c=this.getExternalGrammar(a);if(c){const o=c.injectionSelector;o&&Ue(e,o,c,this,c)}})}return e.sort((r,i)=>r.priority-i.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(n){const e=++this._lastRuleId,t=n(e);return this._ruleId2desc[e]=t,t}getRule(n){return this._ruleId2desc[n]}getExternalGrammar(n,e){if(this._includedGrammars[n])return this._includedGrammars[n];if(this._grammarRepository){const t=this._grammarRepository.lookup(n);if(t)return this._includedGrammars[n]=Ke(t,e&&e.$base),this._includedGrammars[n]}}tokenizeLine(n,e,t=0){const s=this._tokenize(n,e,!1,t);return{tokens:s.lineTokens.getResult(s.ruleStack,s.lineLength),ruleStack:s.ruleStack,stoppedEarly:s.stoppedEarly}}tokenizeLine2(n,e,t=0){const s=this._tokenize(n,e,!0,t);return{tokens:s.lineTokens.getBinaryResult(s.ruleStack,s.lineLength),ruleStack:s.ruleStack,stoppedEarly:s.stoppedEarly}}_tokenize(n,e,t,s){this._rootId===-1&&(this._rootId=gt.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!e||e===we.NULL){r=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),h=this.themeProvider.getDefaults(),u=M.set(0,l.languageId,l.tokenType,null,h.fontStyle,h.foregroundId,h.backgroundId),d=this.getRule(this._rootId).getName(null,null);let p;d?p=D.createRootAndLookUpScopeName(d,u,this):p=D.createRoot("unknown",u),e=new we(null,this._rootId,-1,-1,!1,null,p,p)}else r=!1,e.reset();n=n+`
`;const i=this.createOnigString(n),a=i.content.length,c=new os(t,n,this._tokenTypeMatchers,this.balancedBracketSelectors),o=yt(this,i,r,0,e,c,!0,s);return dt(i),{lineLength:a,lineTokens:c,ruleStack:o.stack,stoppedEarly:o.stoppedEarly}}};function Ke(n,e){return n=Rn(n),n.repository=n.repository||{},n.repository.$self={$vscodeTextmateLocation:n.$vscodeTextmateLocation,patterns:n.patterns,name:n.scopeName},n.repository.$base=e||n.repository.$self,n}var D=class v{constructor(e,t,s){this.parent=e,this.scopePath=t,this.tokenAttributes=s}static fromExtension(e,t){let s=e,r=e?.scopePath??null;for(const i of t)r=pe.push(r,i.scopeNames),s=new v(s,r,i.encodedTokenAttributes);return s}static createRoot(e,t){return new v(null,new pe(null,e),t)}static createRootAndLookUpScopeName(e,t,s){const r=s.getMetadataForScope(e),i=new pe(null,e),a=s.themeProvider.themeMatch(i),c=v.mergeAttributes(t,r,a);return new v(null,i,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return v.equals(this,e)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,s){let r=-1,i=0,a=0;return s!==null&&(r=s.fontStyle,i=s.foregroundId,a=s.backgroundId),M.set(e,t.languageId,t.tokenType,null,r,i,a)}pushAttributed(e,t){if(e===null)return this;if(e.indexOf(" ")===-1)return v._pushAttributed(this,e,t);const s=e.split(/ /g);let r=this;for(const i of s)r=v._pushAttributed(r,i,t);return r}static _pushAttributed(e,t,s){const r=s.getMetadataForScope(t),i=e.scopePath.push(t),a=s.themeProvider.themeMatch(i),c=v.mergeAttributes(e.tokenAttributes,r,a);return new v(e,i,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const t=[];let s=this;for(;s&&s!==e;)t.push({encodedTokenAttributes:s.tokenAttributes,scopeNames:s.scopePath.getExtensionIfDefined(s.parent?.scopePath??null)}),s=s.parent;return s===e?t.reverse():void 0}},we=class P{constructor(e,t,s,r,i,a,c,o){this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=i,this.endRule=a,this.nameScopesList=c,this.contentNameScopesList=o,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=s,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new P(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:P._equals(this,e)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?D.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){P._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,t,s,r,i,a,c){return new P(this,e,t,s,r,i,a,c)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,t){return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new P(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){return{ruleId: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,t){const s=D.fromExtension(e?.nameScopesList??null,t.nameScopesList);return new P(e,t.ruleId,t.enterPos??-1,t.anchorPos??-1,t.beginRuleCapturedEOL,t.endRule,s,D.fromExtension(s,t.contentNameScopesList))}},is=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(n,e){this.balancedBracketScopes=n.flatMap(t=>t==="*"?(this.allowAny=!0,[]):X(t,te).map(s=>s.matcher)),this.unbalancedBracketScopes=e.flatMap(t=>X(t,te).map(s=>s.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(n){for(const e of this.unbalancedBracketScopes)if(e(n))return!1;for(const e of this.balancedBracketScopes)if(e(n))return!0;return this.allowAny}},os=class{constructor(n,e,t,s){this.balancedBracketSelectors=s,this._emitBinaryTokens=n,this._tokenTypeOverrides=t,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(n,e){this.produceFromScopes(n.contentNameScopesList,e)}produceFromScopes(n,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let s=n?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const i=n?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(i)&&(s=M.set(s,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(i))}if(r&&(s=M.set(s,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===s){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(s),this._lastTokenEndIndex=e;return}const t=n?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:t}),this._lastTokenEndIndex=e}getResult(n,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(n,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(n,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(n,e),this._binaryTokens[this._binaryTokens.length-2]=0);const t=new Uint32Array(this._binaryTokens.length);for(let s=0,r=this._binaryTokens.length;s<r;s++)t[s]=this._binaryTokens[s];return t}},as=class{constructor(n,e){this._onigLib=e,this._theme=n}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const n of this._grammars.values())n.dispose()}setTheme(n){this._theme=n}getColorMap(){return this._theme.getColorMap()}addGrammar(n,e){this._rawGrammars.set(n.scopeName,n),e&&this._injectionGrammars.set(n.scopeName,e)}lookup(n){return this._rawGrammars.get(n)}injections(n){return this._injectionGrammars.get(n)}getDefaults(){return this._theme.getDefaults()}themeMatch(n){return this._theme.match(n)}grammarForScopeName(n,e,t,s,r){if(!this._grammars.has(n)){let i=this._rawGrammars.get(n);if(!i)return null;this._grammars.set(n,ns(n,i,e,t,s,r,this,this._onigLib))}return this._grammars.get(n)}},cs=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new as(Y.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Y.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,s){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:s})}loadGrammarWithConfiguration(e,t,s){return this._loadGrammar(e,t,s.embeddedLanguages,s.tokenTypes,new is(s.balancedBracketSelectors||[],s.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,s,r,i){const a=new Mn(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(c=>this._loadSingleGrammar(c.scopeName)),a.processQueue();return this._grammarForScopeName(e,t,s,r,i)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const t=this._options.loadGrammar(e);if(t){const s=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,s)}}addGrammar(e,t=[],s=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,s,r)}_grammarForScopeName(e,t=0,s=null,r=null,i=null){return this._syncRegistry.grammarForScopeName(e,t,s,r,i)}},Re=we.NULL;function ne(n,e){const t=typeof n=="string"?{}:{...n.colorReplacements},s=typeof n=="string"?n:n.name;for(const[r,i]of Object.entries(e?.colorReplacements||{}))typeof i=="string"?t[r]=i:r===s&&Object.assign(t,i);return t}function E(n,e){return n&&(e?.[n?.toLowerCase()]||n)}function ls(n){return Array.isArray(n)?n:[n]}async function St(n){return Promise.resolve(typeof n=="function"?n():n).then(e=>e.default||e)}function Ae(n){return!n||["plaintext","txt","text","plain"].includes(n)}function hs(n){return n==="ansi"||Ae(n)}function Te(n){return n==="none"}function us(n){return Te(n)}function Ct(n,e){if(!e)return n;n.properties||={},n.properties.class||=[],typeof n.properties.class=="string"&&(n.properties.class=n.properties.class.split(/\s+/g)),Array.isArray(n.properties.class)||(n.properties.class=[]);const t=Array.isArray(e)?e:e.split(/\s+/g);for(const s of t)s&&!n.properties.class.includes(s)&&n.properties.class.push(s);return n}function ce(n,e=!1){const t=n.split(/(\r?\n)/g);let s=0;const r=[];for(let i=0;i<t.length;i+=2){const a=e?t[i]+(t[i+1]||""):t[i];r.push([a,s]),s+=t[i].length,s+=t[i+1]?.length||0}return r}function fs(n){const e=ce(n,!0).map(([r])=>r);function t(r){if(r===n.length)return{line:e.length-1,character:e[e.length-1].length};let i=r,a=0;for(const c of e){if(i<c.length)break;i-=c.length,a++}return{line:a,character:i}}function s(r,i){let a=0;for(let c=0;c<r;c++)a+=e[c].length;return a+=i,a}return{lines:e,indexToPos:t,posToIndex:s}}const Ee="light-dark()",ds=["color","background-color"];function ps(n,e){let t=0;const s=[];for(const r of e)r>t&&s.push({...n,content:n.content.slice(t,r),offset:n.offset+t}),t=r;return t<n.content.length&&s.push({...n,content:n.content.slice(t),offset:n.offset+t}),s}function ms(n,e){const t=Array.from(e instanceof Set?e:new Set(e)).sort((s,r)=>s-r);return t.length?n.map(s=>s.flatMap(r=>{const i=t.filter(a=>r.offset<a&&a<r.offset+r.content.length).map(a=>a-r.offset).sort((a,c)=>a-c);return i.length?ps(r,i):r})):n}function gs(n,e,t,s,r="css-vars"){const i={content:n.content,explanation:n.explanation,offset:n.offset},a=e.map(h=>se(n.variants[h])),c=new Set(a.flatMap(h=>Object.keys(h))),o={},l=(h,u)=>{const d=u==="color"?"":u==="background-color"?"-bg":`-${u}`;return t+e[h]+(u==="color"?"":d)};return a.forEach((h,u)=>{for(const d of c){const p=h[d]||"inherit";if(u===0&&s&&ds.includes(d))if(s===Ee&&a.length>1){const f=e.findIndex(m=>m==="light"),b=e.findIndex(m=>m==="dark");if(f===-1||b===-1)throw new w('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const _=a[f][d]||"inherit",g=a[b][d]||"inherit";o[d]=`light-dark(${_}, ${g})`,r==="css-vars"&&(o[l(u,d)]=p)}else o[d]=p;else r==="css-vars"&&(o[l(u,d)]=p)}}),i.htmlStyle=o,i}function se(n){const e={};if(n.color&&(e.color=n.color),n.bgColor&&(e["background-color"]=n.bgColor),n.fontStyle){n.fontStyle&N.Italic&&(e["font-style"]="italic"),n.fontStyle&N.Bold&&(e["font-weight"]="bold");const t=[];n.fontStyle&N.Underline&&t.push("underline"),n.fontStyle&N.Strikethrough&&t.push("line-through"),t.length&&(e["text-decoration"]=t.join(" "))}return e}function Ne(n){return typeof n=="string"?n:Object.entries(n).map(([e,t])=>`${e}:${t}`).join(";")}const wt=new WeakMap;function le(n,e){wt.set(n,e)}function H(n){return wt.get(n)}class O{_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,t){return new O(Object.fromEntries(ls(t).map(s=>[s,Re])),e)}constructor(...e){if(e.length===2){const[t,s]=e;this.lang=s,this._stacks=t}else{const[t,s,r]=e;this.lang=s,this._stacks={[r]:t}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return _s(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function _s(n){const e=[],t=new Set;function s(r){if(t.has(r))return;t.add(r);const i=r?.nameScopesList?.scopeName;i&&e.push(i),r.parent&&s(r.parent)}return s(n),e}function ys(n,e){if(!(n instanceof O))throw new w("Invalid grammar state");return n.getInternalStack(e)}function bs(){const n=new WeakMap;function e(t){if(!n.has(t.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>t.source.length)throw new w(`Invalid decoration offset: ${a}. Code length: ${t.source.length}`);return{...r.indexToPos(a),offset:a}}else{const c=r.lines[a.line];if(c===void 0)throw new w(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${r.lines.length}`);let o=a.character;if(o<0&&(o=c.length+o),o<0||o>c.length)throw new w(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${c.length}`);return{...a,character:o,offset:r.posToIndex(a.line,o)}}};const r=fs(t.source),i=(t.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));Ss(i),n.set(t.meta,{decorations:i,converter:r,source:t.source})}return n.get(t.meta)}return{name:"shiki:decorations",tokens(t){if(!this.options.decorations?.length)return;const r=e(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]);return ms(t,r)},code(t){if(!this.options.decorations?.length)return;const s=e(this),r=Array.from(t.children).filter(h=>h.type==="element"&&h.tagName==="span");if(r.length!==s.converter.lines.length)throw new w(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${s.converter.lines.length}). Failed to apply decorations.`);function i(h,u,d,p){const f=r[h];let b="",_=-1,g=-1;if(u===0&&(_=0),d===0&&(g=0),d===Number.POSITIVE_INFINITY&&(g=f.children.length),_===-1||g===-1)for(let y=0;y<f.children.length;y++)b+=Rt(f.children[y]),_===-1&&b.length===u&&(_=y+1),g===-1&&b.length===d&&(g=y+1);if(_===-1)throw new w(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(g===-1)throw new w(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);const m=f.children.slice(_,g);if(!p.alwaysWrap&&m.length===f.children.length)c(f,p,"line");else if(!p.alwaysWrap&&m.length===1&&m[0].type==="element")c(m[0],p,"token");else{const y={type:"element",tagName:"span",properties:{},children:m};c(y,p,"wrapper"),f.children.splice(_,m.length,y)}}function a(h,u){r[h]=c(r[h],u,"line")}function c(h,u,d){const p=u.properties||{},f=u.transform||(b=>b);return h.tagName=u.tagName||"span",h.properties={...h.properties,...p,class:h.properties.class},u.properties?.class&&Ct(h,u.properties.class),h=f(h,d)||h,h}const o=[],l=s.decorations.sort((h,u)=>u.start.offset-h.start.offset||h.end.offset-u.end.offset);for(const h of l){const{start:u,end:d}=h;if(u.line===d.line)i(u.line,u.character,d.character,h);else if(u.line<d.line){i(u.line,u.character,Number.POSITIVE_INFINITY,h);for(let p=u.line+1;p<d.line;p++)o.unshift(()=>a(p,h));i(d.line,0,d.character,h)}}o.forEach(h=>h())}}}function Ss(n){for(let e=0;e<n.length;e++){const t=n[e];if(t.start.offset>t.end.offset)throw new w(`Invalid decoration range: ${JSON.stringify(t.start)} - ${JSON.stringify(t.end)}`);for(let s=e+1;s<n.length;s++){const r=n[s],i=t.start.offset<=r.start.offset&&r.start.offset<t.end.offset,a=t.start.offset<r.end.offset&&r.end.offset<=t.end.offset,c=r.start.offset<=t.start.offset&&t.start.offset<r.end.offset,o=r.start.offset<t.end.offset&&t.end.offset<=r.end.offset;if(i||a||c||o){if(i&&a||c&&o||c&&t.start.offset===t.end.offset||a&&r.start.offset===r.end.offset)continue;throw new w(`Decorations ${JSON.stringify(t.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function Rt(n){return n.type==="text"?n.value:n.type==="element"?n.children.map(Rt).join(""):""}const Cs=[bs()];function re(n){const e=ws(n.transformers||[]);return[...e.pre,...e.normal,...e.post,...Cs]}function ws(n){const e=[],t=[],s=[];for(const r of n)switch(r.enforce){case"pre":e.push(r);break;case"post":t.push(r);break;default:s.push(r)}return{pre:e,post:t,normal:s}}var x=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],ge={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Rs(n,e){const t=n.indexOf("\x1B",e);if(t!==-1&&n[t+1]==="["){const s=n.indexOf("m",t);if(s!==-1)return{sequence:n.substring(t+2,s).split(";"),startPosition:t,position:s+1}}return{position:n.length}}function Ve(n){const e=n.shift();if(e==="2"){const t=n.splice(0,3).map(s=>Number.parseInt(s));return t.length!==3||t.some(s=>Number.isNaN(s))?void 0:{type:"rgb",rgb:t}}else if(e==="5"){const t=n.shift();if(t)return{type:"table",index:Number(t)}}}function Ns(n){const e=[];for(;n.length>0;){const t=n.shift();if(!t)continue;const s=Number.parseInt(t);if(!Number.isNaN(s))if(s===0)e.push({type:"resetAll"});else if(s<=9)ge[s]&&e.push({type:"setDecoration",value:ge[s]});else if(s<=29){const r=ge[s-20];r&&(e.push({type:"resetDecoration",value:r}),r==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(s<=37)e.push({type:"setForegroundColor",value:{type:"named",name:x[s-30]}});else if(s===38){const r=Ve(n);r&&e.push({type:"setForegroundColor",value:r})}else if(s===39)e.push({type:"resetForegroundColor"});else if(s<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:x[s-40]}});else if(s===48){const r=Ve(n);r&&e.push({type:"setBackgroundColor",value:r})}else s===49?e.push({type:"resetBackgroundColor"}):s===53?e.push({type:"setDecoration",value:"overline"}):s===55?e.push({type:"resetDecoration",value:"overline"}):s>=90&&s<=97?e.push({type:"setForegroundColor",value:{type:"named",name:x[s-90+8]}}):s>=100&&s<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:x[s-100+8]}})}return e}function ks(){let n=null,e=null,t=new Set;return{parse(s){const r=[];let i=0;do{const a=Rs(s,i),c=a.sequence?s.substring(i,a.startPosition):s.substring(i);if(c.length>0&&r.push({value:c,foreground:n,background:e,decorations:new Set(t)}),a.sequence){const o=Ns(a.sequence);for(const l of o)l.type==="resetAll"?(n=null,e=null,t.clear()):l.type==="resetForegroundColor"?n=null:l.type==="resetBackgroundColor"?e=null:l.type==="resetDecoration"&&t.delete(l.value);for(const l of o)l.type==="setForegroundColor"?n=l.value:l.type==="setBackgroundColor"?e=l.value:l.type==="setDecoration"&&t.add(l.value)}i=a.position}while(i<s.length);return r}}}var Is={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function vs(n=Is){function e(c){return n[c]}function t(c){return`#${c.map(o=>Math.max(0,Math.min(o,255)).toString(16).padStart(2,"0")).join("")}`}let s;function r(){if(s)return s;s=[];for(let l=0;l<x.length;l++)s.push(e(x[l]));let c=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let h=0;h<6;h++)for(let u=0;u<6;u++)s.push(t([c[l],c[h],c[u]]));let o=8;for(let l=0;l<24;l++,o+=10)s.push(t([o,o,o]));return s}function i(c){return r()[c]}function a(c){switch(c.type){case"named":return e(c.name);case"rgb":return t(c.rgb);case"table":return i(c.index)}}return{value:a}}function As(n,e,t){const s=ne(n,t),r=ce(e),i=vs(Object.fromEntries(x.map(c=>[c,n.colors?.[`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`]]))),a=ks();return r.map(c=>a.parse(c[0]).map(o=>{let l,h;o.decorations.has("reverse")?(l=o.background?i.value(o.background):n.bg,h=o.foreground?i.value(o.foreground):n.fg):(l=o.foreground?i.value(o.foreground):n.fg,h=o.background?i.value(o.background):void 0),l=E(l,s),h=E(h,s),o.decorations.has("dim")&&(l=Ts(l));let u=N.None;return o.decorations.has("bold")&&(u|=N.Bold),o.decorations.has("italic")&&(u|=N.Italic),o.decorations.has("underline")&&(u|=N.Underline),o.decorations.has("strikethrough")&&(u|=N.Strikethrough),{content:o.value,offset:c[1],color:l,bgColor:h,fontStyle:u}}))}function Ts(n){const e=n.match(/#([0-9a-f]{3})([0-9a-f]{3})?([0-9a-f]{2})?/);if(e)if(e[3]){const s=Math.round(Number.parseInt(e[3],16)/2).toString(16).padStart(2,"0");return`#${e[1]}${e[2]}${s}`}else return e[2]?`#${e[1]}${e[2]}80`:`#${Array.from(e[1]).map(s=>`${s}${s}`).join("")}80`;const t=n.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return t?`var(${t[1]}-dim)`:n}function Le(n,e,t={}){const{lang:s="text",theme:r=n.getLoadedThemes()[0]}=t;if(Ae(s)||Te(r))return ce(e).map(o=>[{content:o[0],offset:o[1]}]);const{theme:i,colorMap:a}=n.setTheme(r);if(s==="ansi")return As(i,e,t);const c=n.getLanguage(s);if(t.grammarState){if(t.grammarState.lang!==c.name)throw new w(`Grammar state language "${t.grammarState.lang}" does not match highlight language "${c.name}"`);if(!t.grammarState.themes.includes(i.name))throw new w(`Grammar state themes "${t.grammarState.themes}" do not contain highlight theme "${i.name}"`)}return Ls(e,c,i,a,t)}function Es(...n){if(n.length===2)return H(n[1]);const[e,t,s={}]=n,{lang:r="text",theme:i=e.getLoadedThemes()[0]}=s;if(Ae(r)||Te(i))throw new w("Plain language does not have grammar state");if(r==="ansi")throw new w("ANSI language does not have grammar state");const{theme:a,colorMap:c}=e.setTheme(i),o=e.getLanguage(r);return new O(ie(t,o,a,c,s).stateStack,o.name,a.name)}function Ls(n,e,t,s,r){const i=ie(n,e,t,s,r),a=new O(ie(n,e,t,s,r).stateStack,e.name,t.name);return le(i.tokens,a),i.tokens}function ie(n,e,t,s,r){const i=ne(t,r),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:c=500}=r,o=ce(n);let l=r.grammarState?ys(r.grammarState,t.name)??Re:r.grammarContextCode!=null?ie(r.grammarContextCode,e,t,s,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Re,h=[];const u=[];for(let d=0,p=o.length;d<p;d++){const[f,b]=o[d];if(f===""){h=[],u.push([]);continue}if(a>0&&f.length>=a){h=[],u.push([{content:f,offset:b,color:"",fontStyle:0}]);continue}let _,g,m;r.includeExplanation&&(_=e.tokenizeLine(f,l,c),g=_.tokens,m=0);const y=e.tokenizeLine2(f,l,c),k=y.tokens.length/2;for(let S=0;S<k;S++){const T=y.tokens[2*S],L=S+1<k?y.tokens[2*S+2]:f.length;if(T===L)continue;const xe=y.tokens[2*S+1],vt=E(s[M.getForeground(xe)],i),At=M.getFontStyle(xe),he={content:f.substring(T,L),offset:b+T,color:vt,fontStyle:At};if(r.includeExplanation){const Ge=[];if(r.includeExplanation!=="scopeName")for(const A of t.settings){let G;switch(typeof A.scope){case"string":G=A.scope.split(/,/).map(ue=>ue.trim());break;case"object":G=A.scope;break;default:continue}Ge.push({settings:A,selectors:G.map(ue=>ue.split(/ /))})}he.explanation=[];let $e=0;for(;T+$e<L;){const A=g[m],G=f.substring(A.startIndex,A.endIndex);$e+=G.length,he.explanation.push({content:G,scopes:r.includeExplanation==="scopeName"?Ps(A.scopes):xs(Ge,A.scopes)}),m+=1}}h.push(he)}u.push(h),h=[],l=y.ruleStack}return{tokens:u,stateStack:l}}function Ps(n){return n.map(e=>({scopeName:e}))}function xs(n,e){const t=[];for(let s=0,r=e.length;s<r;s++){const i=e[s];t[s]={scopeName:i,themeMatches:$s(n,i,e.slice(0,s))}}return t}function Je(n,e){return n===e||e.substring(0,n.length)===n&&e[n.length]==="."}function Gs(n,e,t){if(!Je(n[n.length-1],e))return!1;let s=n.length-2,r=t.length-1;for(;s>=0&&r>=0;)Je(n[s],t[r])&&(s-=1),r-=1;return s===-1}function $s(n,e,t){const s=[];for(const{selectors:r,settings:i}of n)for(const a of r)if(Gs(a,e,t)){s.push(i);break}return s}function Nt(n,e,t){const s=Object.entries(t.themes).filter(o=>o[1]).map(o=>({color:o[0],theme:o[1]})),r=s.map(o=>{const l=Le(n,e,{...t,theme:o.theme}),h=H(l),u=typeof o.theme=="string"?o.theme:o.theme.name;return{tokens:l,state:h,theme:u}}),i=Bs(...r.map(o=>o.tokens)),a=i[0].map((o,l)=>o.map((h,u)=>{const d={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in t&&t.includeExplanation&&(d.explanation=h.explanation),i.forEach((p,f)=>{const{content:b,explanation:_,offset:g,...m}=p[l][u];d.variants[s[f].color]=m}),d})),c=r[0].state?new O(Object.fromEntries(r.map(o=>[o.theme,o.state?.getInternalStack(o.theme)])),r[0].state.lang):void 0;return c&&le(a,c),a}function Bs(...n){const e=n.map(()=>[]),t=n.length;for(let s=0;s<n[0].length;s++){const r=n.map(o=>o[s]),i=e.map(()=>[]);e.forEach((o,l)=>o.push(i[l]));const a=r.map(()=>0),c=r.map(o=>o[0]);for(;c.every(o=>o);){const o=Math.min(...c.map(l=>l.content.length));for(let l=0;l<t;l++){const h=c[l];h.content.length===o?(i[l].push(h),a[l]+=1,c[l]=r[l][a[l]]):(i[l].push({...h,content:h.content.slice(0,o)}),c[l]={...h,content:h.content.slice(o),offset:h.offset+o})}}}return e}function oe(n,e,t){let s,r,i,a,c,o;if("themes"in t){const{defaultColor:l="light",cssVariablePrefix:h="--shiki-",colorsRendering:u="css-vars"}=t,d=Object.entries(t.themes).filter(g=>g[1]).map(g=>({color:g[0],theme:g[1]})).sort((g,m)=>g.color===l?-1:m.color===l?1:0);if(d.length===0)throw new w("`themes` option must not be empty");const p=Nt(n,e,t);if(o=H(p),l&&Ee!==l&&!d.find(g=>g.color===l))throw new w(`\`themes\` option must contain the defaultColor key \`${l}\``);const f=d.map(g=>n.getTheme(g.theme)),b=d.map(g=>g.color);i=p.map(g=>g.map(m=>gs(m,b,h,l,u))),o&&le(i,o);const _=d.map(g=>ne(g.theme,t));r=Qe(d,f,_,h,l,"fg",u),s=Qe(d,f,_,h,l,"bg",u),a=`shiki-themes ${f.map(g=>g.name).join(" ")}`,c=l?void 0:[r,s].join(";")}else if("theme"in t){const l=ne(t.theme,t);i=Le(n,e,t);const h=n.getTheme(t.theme);s=E(h.bg,l),r=E(h.fg,l),a=h.name,o=H(i)}else throw new w("Invalid options, either `theme` or `themes` must be provided");return{tokens:i,fg:r,bg:s,themeName:a,rootStyle:c,grammarState:o}}function Qe(n,e,t,s,r,i,a){return n.map((c,o)=>{const l=E(e[o][i],t[o])||"inherit",h=`${s+c.color}${i==="bg"?"-bg":""}:${l}`;if(o===0&&r){if(r===Ee&&n.length>1){const u=n.findIndex(b=>b.color==="light"),d=n.findIndex(b=>b.color==="dark");if(u===-1||d===-1)throw new w('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const p=E(e[u][i],t[u])||"inherit",f=E(e[d][i],t[d])||"inherit";return`light-dark(${p}, ${f});${h}`}return l}return a==="css-vars"?h:null}).filter(c=>!!c).join(";")}function ae(n,e,t,s={meta:{},options:t,codeToHast:(r,i)=>ae(n,r,i),codeToTokens:(r,i)=>oe(n,r,i)}){let r=e;for(const f of re(t))r=f.preprocess?.call(s,r,t)||r;let{tokens:i,fg:a,bg:c,themeName:o,rootStyle:l,grammarState:h}=oe(n,r,t);const{mergeWhitespaces:u=!0,mergeSameStyleTokens:d=!1}=t;u===!0?i=Os(i):u==="never"&&(i=js(i)),d&&(i=Ws(i));const p={...s,get source(){return r}};for(const f of re(t))i=f.tokens?.call(p,i)||i;return Ms(i,{...t,fg:a,bg:c,themeName:o,rootStyle:l},p,h)}function Ms(n,e,t,s=H(n)){const r=re(e),i=[],a={type:"root",children:[]},{structure:c="classic",tabindex:o="0"}=e;let l={type:"element",tagName:"pre",properties:{class:`shiki ${e.themeName||""}`,style:e.rootStyle||`background-color:${e.bg};color:${e.fg}`,...o!==!1&&o!=null?{tabindex:o.toString()}:{},...Object.fromEntries(Array.from(Object.entries(e.meta||{})).filter(([f])=>!f.startsWith("_")))},children:[]},h={type:"element",tagName:"code",properties:{},children:i};const u=[],d={...t,structure:c,addClassToHast:Ct,get source(){return t.source},get tokens(){return n},get options(){return e},get root(){return a},get pre(){return l},get code(){return h},get lines(){return u}};if(n.forEach((f,b)=>{b&&(c==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&i.push({type:"text",value:`
`}));let _={type:"element",tagName:"span",properties:{class:"line"},children:[]},g=0;for(const m of f){let y={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]};const k=Ne(m.htmlStyle||se(m));k&&(y.properties.style=k);for(const S of r)y=S?.span?.call(d,y,b+1,g,_,m)||y;c==="inline"?a.children.push(y):c==="classic"&&_.children.push(y),g+=m.content.length}if(c==="classic"){for(const m of r)_=m?.line?.call(d,_,b+1)||_;u.push(_),i.push(_)}}),c==="classic"){for(const f of r)h=f?.code?.call(d,h)||h;l.children.push(h);for(const f of r)l=f?.pre?.call(d,l)||l;a.children.push(l)}let p=a;for(const f of r)p=f?.root?.call(d,p)||p;return s&&le(p,s),p}function Os(n){return n.map(e=>{const t=[];let s="",r=0;return e.forEach((i,a)=>{const o=!(i.fontStyle&&(i.fontStyle&N.Underline||i.fontStyle&N.Strikethrough));o&&i.content.match(/^\s+$/)&&e[a+1]?(r||(r=i.offset),s+=i.content):s?(o?t.push({...i,offset:r,content:s+i.content}):t.push({content:s,offset:r},i),r=0,s=""):t.push(i)}),t})}function js(n){return n.map(e=>e.flatMap(t=>{if(t.content.match(/^\s+$/))return t;const s=t.content.match(/^(\s*)(.*?)(\s*)$/);if(!s)return t;const[,r,i,a]=s;if(!r&&!a)return t;const c=[{...t,offset:t.offset+r.length,content:i}];return r&&c.unshift({content:r,offset:t.offset}),a&&c.push({content:a,offset:t.offset+r.length+i.length}),c}))}function Ws(n){return n.map(e=>{const t=[];for(const s of e){if(t.length===0){t.push({...s});continue}const r=t[t.length-1],i=Ne(r.htmlStyle||se(r)),a=Ne(s.htmlStyle||se(s)),c=r.fontStyle&&(r.fontStyle&N.Underline||r.fontStyle&N.Strikethrough),o=s.fontStyle&&(s.fontStyle&N.Underline||s.fontStyle&N.Strikethrough);!c&&!o&&i===a?r.content+=s.content:t.push({...s})}return t})}const Ds=Sn;function Fs(n,e,t){const s={meta:{},options:t,codeToHast:(i,a)=>ae(n,i,a),codeToTokens:(i,a)=>oe(n,i,a)};let r=Ds(ae(n,e,t,s));for(const i of re(t))r=i.postprocess?.call(s,r,t)||r;return r}const Ye={light:"#333333",dark:"#bbbbbb"},Xe={light:"#fffffe",dark:"#1e1e1e"},Ze="__shiki_resolved";function Pe(n){if(n?.[Ze])return n;const e={...n};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:t,fg:s}=e;if(!t||!s){const c=e.settings?e.settings.find(o=>!o.name&&!o.scope):void 0;c?.settings?.foreground&&(s=c.settings.foreground),c?.settings?.background&&(t=c.settings.background),!s&&e?.colors?.["editor.foreground"]&&(s=e.colors["editor.foreground"]),!t&&e?.colors?.["editor.background"]&&(t=e.colors["editor.background"]),s||(s=e.type==="light"?Ye.light:Ye.dark),t||(t=e.type==="light"?Xe.light:Xe.dark),e.fg=s,e.bg=t}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let r=0;const i=new Map;function a(c){if(i.has(c))return i.get(c);r+=1;const o=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${o}`]?a(c):(i.set(c,o),o)}e.settings=e.settings.map(c=>{const o=c.settings?.foreground&&!c.settings.foreground.startsWith("#"),l=c.settings?.background&&!c.settings.background.startsWith("#");if(!o&&!l)return c;const h={...c,settings:{...c.settings}};if(o){const u=a(c.settings.foreground);e.colorReplacements[u]=c.settings.foreground,h.settings.foreground=u}if(l){const u=a(c.settings.background);e.colorReplacements[u]=c.settings.background,h.settings.background=u}return h});for(const c of Object.keys(e.colors||{}))if((c==="editor.foreground"||c==="editor.background"||c.startsWith("terminal.ansi"))&&!e.colors[c]?.startsWith("#")){const o=a(e.colors[c]);e.colorReplacements[o]=e.colors[c],e.colors[c]=o}return Object.defineProperty(e,Ze,{enumerable:!1,writable:!1,value:!0}),e}async function kt(n){return Array.from(new Set((await Promise.all(n.filter(e=>!hs(e)).map(async e=>await St(e).then(t=>Array.isArray(t)?t:[t])))).flat()))}async function It(n){return(await Promise.all(n.map(async t=>us(t)?null:Pe(await St(t))))).filter(t=>!!t)}let zs=3;function qs(n,e=3){e>zs||console.trace(`[SHIKI DEPRECATE]: ${n}`)}class $ extends Error{constructor(e){super(e),this.name="ShikiError"}}class Hs extends cs{constructor(e,t,s,r={}){super(e),this._resolver=e,this._themes=t,this._langs=s,this._alias=r,this._themes.map(i=>this.loadTheme(i)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=Pe(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Y.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){if(this._alias[e]){const t=new Set([e]);for(;this._alias[e];){if(e=this._alias[e],t.has(e))throw new $(`Circular alias \`${Array.from(t).join(" -> ")} -> ${e}\``);t.add(e)}}return this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(i=>i.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const s={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,s);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(i=>{this._alias[i]=e.name}),this._loadedLanguagesCache=null,t.size)for(const i of t)this._resolvedGrammars.delete(i.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(i.scopeName),this._syncRegistry?._grammars?.delete(i.scopeName),this.loadLanguage(this._langMap.get(i.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const r of e)this.resolveEmbeddedLanguages(r);const t=Array.from(this._langGraph.entries()),s=t.filter(([r,i])=>!i);if(s.length){const r=t.filter(([i,a])=>a&&a.embeddedLangs?.some(c=>s.map(([o])=>o).includes(c))).filter(i=>!s.includes(i));throw new $(`Missing languages ${s.map(([i])=>`\`${i}\``).join(", ")}, required by ${r.map(([i])=>`\`${i}\``).join(", ")}`)}for(const[r,i]of t)this._resolver.addLanguage(i);for(const[r,i]of t)this.loadLanguage(i)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){if(this._langMap.set(e.name,e),this._langGraph.set(e.name,e),e.embeddedLangs)for(const t of e.embeddedLangs)this._langGraph.set(t,this._langMap.get(t))}}class Us{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:s=>e.createScanner(s),createOnigString:s=>e.createString(s)},t.forEach(s=>this.addLanguage(s))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let s=[];for(let r=1;r<=t.length;r++){const i=t.slice(0,r).join(".");s=[...s,...this._injections.get(i)||[]]}return s}}let j=0;function Ks(n){j+=1,n.warnings!==!1&&j>=10&&j%10===0&&console.warn(`[Shiki] ${j} 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(!n.engine)throw new $("`engine` option is required for synchronous mode");const t=(n.langs||[]).flat(1),s=(n.themes||[]).flat(1).map(Pe),r=new Us(n.engine,t),i=new Hs(r,s,t,n.langAlias);let a;function c(m){_();const y=i.getGrammar(typeof m=="string"?m:m.name);if(!y)throw new $(`Language \`${m}\` not found, you may need to load it first`);return y}function o(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();const y=i.getTheme(m);if(!y)throw new $(`Theme \`${m}\` not found, you may need to load it first`);return y}function l(m){_();const y=o(m);a!==m&&(i.setTheme(y),a=m);const k=i.getColorMap();return{theme:y,colorMap:k}}function h(){return _(),i.getLoadedThemes()}function u(){return _(),i.getLoadedLanguages()}function d(...m){_(),i.loadLanguages(m.flat(1))}async function p(...m){return d(await kt(m))}function f(...m){_();for(const y of m.flat(1))i.loadTheme(y)}async function b(...m){return _(),f(await It(m))}function _(){if(e)throw new $("Shiki instance has been disposed")}function g(){e||(e=!0,i.dispose(),j-=1)}return{setTheme:l,getTheme:o,getLanguage:c,getLoadedThemes:h,getLoadedLanguages:u,loadLanguage:p,loadLanguageSync:d,loadTheme:b,loadThemeSync:f,dispose:g,[Symbol.dispose]:g}}async function Vs(n){n.engine||qs("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,t,s]=await Promise.all([It(n.themes||[]),kt(n.langs||[]),n.engine]);return Ks({...n,themes:e,langs:t,engine:s})}async function nr(n){const e=await Vs(n);return{getLastGrammarState:(...t)=>Es(e,...t),codeToTokensBase:(t,s)=>Le(e,t,s),codeToTokensWithThemes:(t,s)=>Nt(e,t,s),codeToTokens:(t,s)=>oe(e,t,s),codeToHast:(t,s)=>ae(e,t,s),codeToHtml:(t,s)=>Fs(e,t,s),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}export{w as ShikiError,Ct as addClassToHast,E as applyColorReplacements,ae as codeToHast,Fs as codeToHtml,oe as codeToTokens,Le as codeToTokensBase,Nt as codeToTokensWithThemes,nr as createHighlighterCore,fs as createPositionConverter,Vs as createShikiInternal,Ks as createShikiInternalSync,gs as flatTokenVariants,se as getTokenStyleObject,Ds as hastToHtml,Te as isNoneTheme,Ae as isPlainLang,hs as isSpecialLang,us as isSpecialTheme,St as normalizeGetter,Pe as normalizeTheme,ne as resolveColorReplacements,ce as splitLines,ps as splitToken,ms as splitTokens,Ne as stringifyTokenStyle,ls as toArray,As as tokenizeAnsiWithTheme,Ls as tokenizeWithTheme,Ms as tokensToHast,bs as transformerDecorations,qs as warnDeprecated};
Back to Directory
File Manager