import{j as e}from"./jsx-runtime.D_zvdyIk.js";import{r as c}from"./index.BIRwh3HZ.js";import{u as f}from"./useTranslation.Dg7DwAC5.js";import{I as u}from"./iconify.pctX9hd_.js";import{c as l}from"./utils.BZbvJs_N.js";const x=2e3;function p(){const[r,t]=c.useState(!1),s=c.useRef(void 0);c.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const a=c.useCallback(async o=>{try{await navigator.clipboard.writeText(o),t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),x)}catch{console.warn("Clipboard write failed — clipboard API may not be available in this context")}},[]);return{copied:r,copy:a}}function h({className:r}){const t=c.useId();return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",className:r,children:[e.jsx("title",{children:"Copied"}),e.jsx("mask",{id:t,children:e.jsxs("g",{fill:"none",stroke:"#fff",strokeDasharray:"24",strokeDashoffset:"24",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",children:[e.jsx("path",{d:"M2 13.5l4 4l10.75 -10.75",children:e.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",dur:"0.4s",values:"24;0"})}),e.jsx("path",{stroke:"#000",strokeWidth:"6",d:"M7.5 13.5l4 4l10.75 -10.75",children:e.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.4s",dur:"0.4s",values:"24;0"})}),e.jsx("path",{d:"M7.5 13.5l4 4l10.75 -10.75",children:e.jsx("animate",{fill:"freeze",attributeName:"stroke-dashoffset",begin:"0.4s",dur:"0.4s",values:"24;0"})})]})}),e.jsx("rect",{width:"24",height:"24",fill:"currentColor",mask:`url(#${t})`})]})}function N({text:r,className:t,showLabel:s}){const{copied:a,copy:o}=p(),{t:i}=f(),n=i(a?"common.copied":"common.copy");return e.jsxs("button",{type:"button",onClick:()=>o(r),className:l("flex items-center justify-center rounded-md text-muted-foreground transition-colors","hover:bg-accent hover:text-accent-foreground active:scale-95",s?"gap-2 px-3 py-1.5":"h-8 w-8",a&&"text-primary",t),"aria-label":n,title:n,children:[a?e.jsx(h,{}):e.jsx(u,{icon:"ri:file-copy-line",className:"size-4"}),s&&e.jsx("span",{className:"text-sm",children:n})]})}function b({onClose:r,onFullscreen:t}){const{t:s}=f(),a=!!(r||t);return e.jsxs("div",{className:l("flex gap-2",a&&"group"),children:[e.jsx(d,{color:"bg-[#ff5f56]",onClick:r,"aria-label":s("common.close"),icon:r?e.jsx(u,{icon:"mingcute:close-fill",className:"text-black"}):null}),e.jsx(d,{color:"bg-[#ffbd2e]",icon:null}),e.jsx(d,{color:"bg-[#27c93f]",onClick:t,"aria-label":s("code.fullscreen"),icon:t?e.jsx(u,{icon:"mingcute:fullscreen-2-fill",className:"text-black"}):null})]})}function d({color:r,onClick:t,"aria-label":s,icon:a}){const o=l("relative size-3 rounded-full",r);return t?e.jsx("button",{type:"button",onClick:t,className:l(o,"cursor-default"),"aria-label":s,children:e.jsx("span",{className:"absolute inset-0 flex items-center justify-center p-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:a})}):e.jsx("span",{className:o,children:a&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:a})})}function w({language:r,title:t,url:s,linkText:a,className:o,children:i,onClose:n,onFullscreen:m}){return e.jsxs("div",{className:l("flex shrink-0 flex-col border border-border border-b-0 bg-muted/50 backdrop-blur-sm","rounded-t-xl shadow-md","dark:bg-muted/30",o),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between pr-2 pl-4",children:[e.jsxs("div",{className:"flex items-center gap-3 py-2",children:[e.jsx(b,{onClose:n,onFullscreen:m}),e.jsx("span",{className:"font-medium font-mono text-muted-foreground text-xs uppercase tracking-wider",children:r})]}),i&&e.jsx("div",{className:"ml-auto flex items-center py-1",children:i})]}),(t||s)&&e.jsxs("div",{className:"code-block-title",children:[t&&e.jsx("span",{children:t}),s&&e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:a||s})]})]})}export{N as C,w as M};
