/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@shikijs/monaco@4.0.2/dist/index.mjs
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{EncodedTokenMetadata,FontStyle,INITIAL}from"@shikijs/vscode-textmate";var TokenizerState=class e{constructor(e){this._ruleStack=e}get ruleStack(){return this._ruleStack}clone(){return new e(this._ruleStack)}equals(t){return!!(t&&t instanceof e&&t===this&&t._ruleStack===this._ruleStack)}};function normalizeColor(e){if(Array.isArray(e)&&(e=e[0]),e)return 3!==(e=(35===e.charCodeAt(0)?e.slice(1):e).toLowerCase()).length&&4!==e.length||(e=e.split("").map((e=>e+e)).join("")),e}function textmateThemeToMonacoTheme(e){let t="rules"in e?e.rules:void 0;if(!t){t=[];const o=e.settings||e.tokenColors;for(const{scope:e,settings:{foreground:n,background:r,fontStyle:i}={}}of o){if(!n&&!r&&!i)continue;const o=Array.isArray(e)?e:e?[e]:[],s=normalizeFontStyleString(i),a=normalizeColor(n),l=normalizeColor(r);t.push(...o.map((e=>({token:e,foreground:a,background:l,fontStyle:s}))))}}const o=Object.fromEntries(Object.entries(e.colors||{}).map((([e,t])=>[e,`#${normalizeColor(t)}`])));return{base:"light"===e.type?"vs":"vs-dark",inherit:!1,colors:o,rules:t}}function shikiToMonaco(e,t,o={}){const n=new Map,r=e.getLoadedThemes();for(const o of r){const r=textmateThemeToMonacoTheme(e.getTheme(o));n.set(o,r),t.editor.defineTheme(o,r)}const i=[],s=new Map,a=t.editor.setTheme.bind(t.editor);t.editor.setTheme=t=>{const o=e.setTheme(t),r=n.get(t);i.length=o.colorMap.length;for(let e=0;e<o.colorMap.length;e++)i[e]=o.colorMap[e];s.clear(),r?.rules.forEach((e=>{const t=normalizeColor(e.foreground);if(!t)return;const o=getColorStyleKey(t,normalizeFontStyleString(e.fontStyle));s.has(o)||s.set(o,e.token)})),a(t)};const l=t.editor.create;function c(e,t){const o=getColorStyleKey(e,normalizeFontStyleBits(t));return s.get(o)}t.editor.create=(e,o,n)=>(o?.theme&&t.editor.setTheme(o.theme),l(e,o,n)),t.editor.setTheme(r[0]);const{tokenizeMaxLineLength:u=2e4,tokenizeTimeLimit:h=500}=o,g=new Set(t.languages.getLanguages().map((e=>e.id)));for(const o of e.getLoadedLanguages())g.has(o)&&t.languages.setTokensProvider(o,{getInitialState:()=>new TokenizerState(INITIAL),tokenize(t,n){if(t.length>=u)return{endState:n,tokens:[{startIndex:0,scopes:""}]};const r=e.getLanguage(o).tokenizeLine2(t,n.ruleStack,h);r.stoppedEarly&&console.warn(`Time limit reached when tokenizing line: ${t.substring(0,100)}`);const s=r.tokens.length/2,a=[];for(let e=0;e<s;e++){const t=r.tokens[2*e],o=r.tokens[2*e+1],n=normalizeColor(i[EncodedTokenMetadata.getForeground(o)]||""),s=EncodedTokenMetadata.getFontStyle(o),l=n&&c(n,s)||"";a.push({startIndex:t,scopes:l})}return{endState:new TokenizerState(r.ruleStack),tokens:a}}})}function normalizeFontStyleBits(e){if(e<=FontStyle.None)return"";const t=[];return e&FontStyle.Italic&&t.push("italic"),e&FontStyle.Bold&&t.push("bold"),e&FontStyle.Underline&&t.push("underline"),e&FontStyle.Strikethrough&&t.push("strikethrough"),t.join(" ")}const VALID_FONT_STYLES=["italic","bold","underline","strikethrough"],VALID_FONT_ALIASES={"line-through":"strikethrough"};function normalizeFontStyleString(e){if(!e)return"";const t=new Set(e.split(/[\s,]+/).map((e=>e.trim().toLowerCase())).map((e=>VALID_FONT_ALIASES[e]||e)).filter(Boolean));return VALID_FONT_STYLES.filter((e=>t.has(e))).join(" ")}function getColorStyleKey(e,t){return t?`${e}|${t}`:e}export{shikiToMonaco,textmateThemeToMonacoTheme};
//# sourceMappingURL=/sm/64f535273765b82c579ea790d08efbcbc370842d3249278242e0b74a29757b14.map