import{r as e,j as t,aa as o,$ as n}from"./vendor-react-O8XH9yVn.js";import{c as s}from"./recharts-BU7auunF.js";const a={xs:"text-[9px] px-1 py-0.5 gap-0.5",sm:"text-[10px] px-1.5 py-0.5 gap-1",md:"text-xs px-2 py-1 gap-1.5"},r={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3"};function c({hash:c,copyValue:i,prefixLength:l=8,suffixLength:p=6,full:u=!1,className:d,size:x="md"}){const[h,m]=e.useState(!1),[w,f]=e.useState(!1),y=e.useRef(null),b=i??c,g=r[x],v=u||c.length<=l+p+3?c:`${c.slice(0,l)}…${c.slice(-p)}`,j=e.useCallback(e=>{e.preventDefault(),e.stopPropagation(),y.current&&clearTimeout(y.current),function(e){var t;if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&(null==(t=navigator.clipboard)?void 0:t.writeText))return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const{scrollX:t,scrollY:o}=window,n=document.createElement("textarea");n.value=e,n.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",n.setAttribute("readonly",""),document.body.appendChild(n),n.focus({preventScroll:!0}),n.select(),n.setSelectionRange(0,e.length);const s=document.execCommand("copy");return document.body.removeChild(n),window.scrollTo(t,o),s}catch(o){return!1}}(b),m(!0),y.current=setTimeout(()=>m(!1),2e3)},[b]);return t.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),className:s("inline-flex items-center font-mono rounded transition-all duration-200","bg-white/[0.04] hover:bg-white/[0.08]","border border-white/[0.06] hover:border-white/[0.12]","cursor-pointer select-none",a[x],d),title:`Click to copy: ${b}`,"aria-label":`Copy hash ${b}`,children:[t.jsx("span",{className:s("transition-colors duration-200",h?"text-accent-success":"text-text-secondary"),children:v}),t.jsx("span",{className:s("flex items-center justify-center transition-all duration-200","xs"===x?"w-2.5 h-2.5":"sm"===x?"w-3 h-3":"w-3.5 h-3.5"),children:h?t.jsx(o,{className:s("text-accent-success",g)}):t.jsx(n,{className:s("transition-opacity duration-200",w?"opacity-70":"opacity-40",g)})})]})}export{c as H};
