1import{r as m,j as e,R as B}from"./vendor-react-DbFVZiS9.js";import{z as E,D as O,g as x,G as C,b as N,H as P,I as L,v as $,r as A,J as F,f,t as w,A as g,K as M,M as U,y as K}from"./index-B9etCNLl.js";import{S as V}from"./ShareButtons-iH7dSbFw.js";import{u as k}from"./vendor-i18n-k0TTF2pe.js";import"./vendor-query-qQWDno7u.js";function D(r){const a=m.useRef(null);return m.useEffect(()=>{const l=a.current;if(!l||typeof ResizeObserver>"u")return;const n=new ResizeObserver(t=>{var i;const s=(i=t[0])==null?void 0:i.contentRect.width;s&&l.style.setProperty("--card-scale",String(s/r))});return n.observe(l),()=>n.disconnect()},[r]),a}function Q({report:r,stars:a,isExporting:l,exportError:n,onExportPng:t}){const{t:s}=k(),i=D(1200),[p,o]=m.useState(!1),u=E(),[b,S]=m.useState(null),[y,R]=m.useState(null),v=async(c,d)=>{const h=await c();S(h?"copied":"failed"),R(null)},T=async()=>{const c=C(r),d=F(r.repository.owner,r.repository.name,r.refName,"summary","");if(!d)return!1;const h=await f(`[](${c})`);return h&&(u.showCopied("badge"),w(g.badgeMarkdownCopied,{provider:"github",placement:"report_utility"})),h},z=async()=>{const c=K(),d=await f(M(U(c,r.repository.owner,r.repository.name)));return d&&(u.showCopied("embed"),w(g.embedSnippetCopied,{provider:c,placement:"report_utility"})),d};return e.jsxs("section",{id:"share-showcase",className:"share-showcase","aria-label":s("reportCta.ariaLabel"),children:[e.jsxs("div",{className:"share-showcase-head",children:[e.jsx("strong",{children:s("reportCta.title")}),e.jsx("span",{children:s("reportCta.subtitle")})]}),e.jsxs("div",{className:"share-showcase-body",children:[e.jsxs("div",{className:"share-preview-col",children:[e.jsxs("details",{className:"share-preview",open:p,onToggle:c=>o(c.currentTarget.open),children:[e.jsx("summary",{children:s(p?"reportCta.hidePreview":"reportCta.showPreview")}),e.jsx("div",{className:"share-showcase-card",ref:i,children:e.jsx(_,{report:r,stars:a})})]}),e.jsx("p",{className:"share-theme-note",children:s("reportCta.darkThemeNote")})]}),e.jsxs("div",{className:"share-showcase-actions",children:[e.jsx("div",{className:"row-flex",children:e.jsxs("button",{className:"copybtn",type:"button",disabled:l,onClick:t,children:[e.jsx(O,{size:14}),s(l?"reportActions.exporting":"reportCta.exportPng")]})}),e.jsx(V,{url:C(r),text:s("share.reportText",{repo:`${r.repository.owner}/${r.repository.name}`,code:x(r.total.code)}),placement:"report"}),e.jsxs("div",{className:"row-flex",children:[e.jsxs("button",{className:"copybtn",type:"button",onClick:()=>void v(T),children:[e.jsx(N,{size:14}),u.copiedKey==="badge"?s("reportCta.copied"):s("reportCta.copyBadge")]}),e.jsxs("button",{className:"copybtn",type:"button",onClick:()=>void v(z),children:[e.jsx(N,{size:14}),u.copiedKey==="embed"?s("reportCta.copied"):s("reportCta.copyEmbed")]})]}),b?e.jsx("span",{className:"copy-feedback",role:"status",children:s(b==="copied"?"reportCta.copied":"reportCta.copyFailedShort")}):null,n?e.jsxs("div",{className:"export-error",role:"alert",children:[e.jsx("p",{children:n}),e.jsx("button",{className:"copybtn",type:"button",disabled:l,onClick:t,children:s("error.retry")})]}):null,y?e.jsx("textarea",{className:"manual-copy utility-manual-copy",readOnly:!0,value:y,"aria-label":s("reportCta.manualContentAria"),onFocus:c=>c.currentTarget.select()}):null]})]})]})}const _=B.forwardRef(function({report:a,stars:l},n){const{t}=k(),s=P(a).slice(0,6),i=a.languages.length>s.length,p=a.total.code+a.total.comments+a.total.blanks;return e.jsx("div",{className:"share-card",ref:n,children:e.jsxs("div",{className:"share-window",children:[e.jsxs("div",{className:"share-head",children:[e.jsxs("div",{className:"lights",children:[e.jsx("span",{className:"r"}),e.jsx("span",{className:"y"}),e.jsx("span",{className:"g"})]}),e.jsx("span",{children:t("shareCard.title")})]}),e.jsxs("div",{className:"share-body",children:[e.jsxs("div",{className:"share-kicker-row",children:[e.jsxs("div",{className:"share-kicker",children:[a.repository.owner,"/",a.repository.name]}),typeof l=="number"?e.jsx(L,{className:"share-stars",size:15,stars:l}):null]}),e.jsxs("div",{className:"share-ref",children:[a.refName," / ",a.commitSha.slice(0,12)]}),e.jsxs("div",{className:"share-total",children:[e.jsx("span",{children:t("shareCard.totalLoc")}),e.jsx("strong",{children:x(a.total.lines)})]}),e.jsxs("div",{className:"share-breakdown",children:[e.jsx(j,{color:"var(--accent)",label:t("shareCard.labelCode"),value:a.total.code}),e.jsx(j,{color:"var(--accent-2)",label:t("shareCard.labelComments"),value:a.total.comments}),e.jsx(j,{color:"var(--violet)",label:t("shareCard.labelBlanks"),value:a.total.blanks})]}),e.jsxs("div",{className:"share-ticker",children:[e.jsx("div",{className:"share-ticker-list",children:s.map(o=>e.jsxs("div",{className:"share-ticker-row",children:[e.jsx("span",{children:o.label}),e.jsx("i",{children:e.jsx("b",{style:{width:`${o.percent}%`,background:$(o.color,"matrix")}})}),e.jsx("em",{children:x(o.value)})]},o.label))}),i?e.jsx("div",{className:"share-ticker-note",children:t("shareCard.topLanguages")}):null]}),e.jsxs("div",{className:"share-foot",children:[e.jsx("span",{children:t("shareCard.percentCode",{percent:A(a.total.code,p)})}),e.jsx("span",{children:t("shareCard.generatedBy")})]})]})]})})});function j({color:r,label:a,value:l}){return e.jsxs("div",{className:"share-stat",children:[e.jsx("span",{style:{background:r}}),e.jsx("p",{children:a}),e.jsx("strong",{children:x(l)})]})}export{Q as ShareSection,_ as ShareTickerCard};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.