import{j as e}from"./index-BqbeBO4X.js";import{b as t,c as o}from"./recharts-bmHCCfxU.js";import{a as n,C as s}from"./map-pin-VIncItJf.js";function r({hash:r,prefixLength:a=8,suffixLength:i=6,full:c=!1,className:l,size:p="md"}){const[d,u]=t.useState(!1),[x,m]=t.useState(!1),h=t.useRef(null),w=t.useCallback(e=>{e.preventDefault(),e.stopPropagation(),h.current&&clearTimeout(h.current),function(e){if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const t=window.scrollX,o=window.scrollY,n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",n.style.opacity="0",n.style.pointerEvents="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(t){return!1}}(r),u(!0),h.current=setTimeout(()=>u(!1),2e3)},[r]),y=c||r.length<=a+i+3?r:`${r.slice(0,a)}…${r.slice(-i)}`,f={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"}[p];return e.jsxs("button",{type:"button",onClick:w,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),className:o("inline-flex items-center font-mono rounded-md transition-all duration-200","bg-bg-subtle/80 hover:bg-bg-elevated border border-border-subtle hover:border-border-strong","cursor-pointer select-none",f,l),title:`Click to copy: ${r}`,"aria-label":`Copy hash ${r}`,children:[e.jsx("span",{className:o("transition-colors duration-200",d?"text-accent-success":"text-text-secondary"),children:y}),e.jsx("span",{className:o("flex items-center justify-center transition-all duration-200","xs"===p?"w-2.5 h-2.5":"sm"===p?"w-3 h-3":"w-3.5 h-3.5"),children:d?e.jsx(n,{className:o("text-accent-success","xs"===p?"w-2 h-2":"sm"===p?"w-2.5 h-2.5":"w-3 h-3")}):e.jsx(s,{className:o("transition-opacity duration-200",x?"opacity-70":"opacity-40","xs"===p?"w-2 h-2":"sm"===p?"w-2.5 h-2.5":"w-3 h-3")})})]})}export{r as H};
