import{g as e,c as t}from"./lowlight-CnBVKQlU.js";import{v as s}from"./unist-util-visit-BGZk_7Z4.js";import{t as i}from"./hast-util-to-text-BqqhDKvp.js";const r={};function a(a){const n=a||r,l=n.aliases,o=n.detect||!1,g=n.languages||e,c=n.plainText,h=n.prefix,u=n.subset;let p="hljs";const f=t(g);if(l&&f.registerAlias(l),h){const e=h.indexOf("-");p=-1===e?h:h.slice(0,e)}return function(e,t){s(e,"element",function(e,s,r){if("code"!==e.tagName||!r||"element"!==r.type||"pre"!==r.tagName)return;const a=function(e){const t=e.properties.className;let s,i=-1;if(!Array.isArray(t))return;for(;++i<t.length;){const e=String(t[i]);if("no-highlight"===e||"nohighlight"===e)return!1;s||"lang-"!==e.slice(0,5)||(s=e.slice(5)),s||"language-"!==e.slice(0,9)||(s=e.slice(9))}return s}(e);if(!1===a||!a&&!o||a&&c&&c.includes(a))return;Array.isArray(e.properties.className)||(e.properties.className=[]),e.properties.className.includes(p)||e.properties.className.unshift(p);const n=i(e,{whitespace:"pre"});let l;try{l=a?f.highlight(a,n,{prefix:h}):f.highlightAuto(n,{prefix:h,subset:u})}catch(g){const s=g;if(a&&/Unknown language/.test(s.message))return void t.message("Cannot highlight as `"+a+"`, it’s not registered",{ancestors:[r,e],cause:s,place:e.position,ruleId:"missing-language",source:"rehype-highlight"});throw s}!a&&l.data&&l.data.language&&e.properties.className.push("language-"+l.data.language),l.children.length>0&&(e.children=l.children)})}}export{a as r};
