const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DLt9osMF.js","assets/index-dNe6i2rS.js","assets/vendor-react-wBh_31cN.js","assets/vendor-redux-CJZrIb6x.js","assets/vendor-router-D1GqFWiT.js","assets/vendor-utils-OeoE2qq_.js","assets/vendor-icons-BUUmD6ht.js","assets/vendor-radix-BRyWS4bQ.js","assets/vendor-grid-CeFlDWv4.js","assets/vendor-grid-DkFmqkxk.css","assets/index-CUZPX9ww.css","assets/vendor-markdown-DYw41Xyj.js","assets/vendor-markdown-BQZvoph5.css"])))=>i.map(i=>d[i]);
import{d,c as b}from"./index-dNe6i2rS.js";import{r as h,j as t}from"./vendor-react-wBh_31cN.js";import{a6 as _,aj as j}from"./vendor-icons-BUUmD6ht.js";const v={py:"python",shell:"bash",sh:"bash"},f=["python","json","bash","sql","scala"];let u=null;function y(){return u||(u=b(async()=>{const{createHighlighter:e}=await import("./index-DLt9osMF.js");return{createHighlighter:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(({createHighlighter:e})=>e({themes:["github-light","github-dark"],langs:[...f]}))),u}function C(e,r){const[o,s]=h.useState(null);return h.useEffect(()=>{if(!r||!e){s(null);return}const n=v[r]??r;if(!f.includes(n)){s(null);return}let a=!1;return y().then(l=>{if(a)return;const i=l.codeToHtml(e,{lang:n,themes:{light:"github-light",dark:"github-dark"},defaultColor:"light"});s(i)}).catch(()=>{a||s(null)}),()=>{a=!0}},[e,r]),o}function E({className:e,content:r,copyButton:o,title:s,wrapLongLines:n,language:a,children:l,...i}){const[m,p]=h.useState(!1),c=r??(typeof l=="string"?l:""),x=C(c,a);if(!r&&!s&&!o)return t.jsx("code",{"data-slot":"code",className:d("rounded-sm bg-muted px-1.5 py-0.5 font-mono text-xs",e),...i,children:l});const g=()=>{navigator.clipboard.writeText(c).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)})};return t.jsxs("div",{"data-slot":"code-block",className:d("rounded-md border bg-muted text-sm",e),children:[(s||o)&&t.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-1.5",children:[s&&t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),o&&t.jsxs("button",{type:"button",className:"ml-auto inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",onClick:g,children:[m?t.jsx(_,{className:"size-3.5"}):t.jsx(j,{className:"size-3.5"}),m?"Copied":"Copy"]})]}),x?t.jsx("div",{className:d("[&_pre]:overflow-x-auto [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-xs [&_pre]:!bg-transparent","[&_code]:!bg-transparent",n&&"[&_pre]:whitespace-pre-wrap [&_pre]:break-all"),dangerouslySetInnerHTML:{__html:x}}):t.jsx("pre",{className:d("overflow-x-auto p-3 font-mono text-xs",n&&"whitespace-pre-wrap break-all"),children:t.jsx("code",{...i,children:c})})]})}export{E as C};
