diff --git "a/assets/PaperDetailView-BUcA4fUm.js" "b/assets/PaperDetailView-BUcA4fUm.js" new file mode 100644--- /dev/null +++ "b/assets/PaperDetailView-BUcA4fUm.js" @@ -0,0 +1,39 @@ +import{e as Re,n as Rs,b as Xt,f as ie,g as As,r as m,j as e,C as ue,h as me,k as je,P as Qt,l as ke,m as Zt,o as Ae,p as Ie,q as Wt,s as vt,t as ze,X as wt,L as pe,v as Fs,w as Ts,R as Us,I as Ds,x as Yt,y as Bs,z as Hs,T as zs,A as ht,a as qe,B as Me,D as pt,E as Jt,F as Ms,u as qs,G as Os,d as Ks,J as Gs,K as Vs,M as Xs,N as Qs,O as Zs}from"./index-CHO6BifZ.js";import{I as Z,T as Ws,M as Ys,S as Js,a as ea}from"./components-3UksKq6q.js";import{L as He,a as ta}from"./LatexTitle-EdYTByCW.js";import{e as Oe,C as sa,E as aa}from"./ExternalSourceEvalBadge-SDadEwMl.js";import{p as Q}from"./papers-zliVU14z.js";import{s as ce}from"./safeExternalHref-CkBrsh84.js";import{p as ye}from"./paperQueryKeys-CcqbH5YG.js";import{u as de}from"./useQuery-CI2W4USA.js";import{b as ra}from"./usePapers-BHJL5_7G.js";import{f as na,D as ia}from"./latexPlainText-DI8YEXVe.js";import{s as oa}from"./transform-oJSA3unM.js";import{S as $e}from"./skeleton-CHCeQRAm.js";import{A as la,a as ca}from"./alert-C6vFz8dj.js";import{B as A}from"./button-Bmm0hLdC.js";import{D as ee,a as te,b as se,c as ae,d as re,e as oe}from"./dialog-LwkqsNwm.js";import{u as da}from"./useInfiniteQuery-Da2V8Hnw.js";import{p as ua}from"./paperEdits-Dey4bM8o.js";import{C as ma}from"./copy-ggRqgqgA.js";import{I as W}from"./input-B8uhKQeJ.js";import{S as At,a as Le}from"./searchable-select-Dn3wqVnS.js";import{u as he}from"./useMutation-CIjRFyTx.js";import{c as _e}from"./catalog-k8rPgyVS.js";import{s as fe}from"./submissions-Sd5Gn6zL.js";import{e as ha,r as pa,a as ve}from"./evaluationQueryInvalidation-CcFXnI9u.js";import{P as Fe,S as yt,L as le,a as fa}from"./SignInToEditDialog-BZ7oG2Fk.js";import{L as ne}from"./loader-circle-CkSk1xdi.js";import{T as Te,n as Ye,g as Ft}from"./github-MuSd6ciS.js";import{D as ga,c as xa,g as ba,s as ja,a as va,b as wa,d as ya,i as _a,e as ka}from"./codexAddEvals-B_AeGEV8.js";import{u as es}from"./index-CqTOwifR.js";import{B as ts}from"./badge-dx4Bq8Ds.js";import{G as Tt}from"./github-Dw4LNjUW.js";import{M as Na}from"./index-uM0VIG30.js";import{r as Ca}from"./index-CbdWqs74.js";import{S as Ut,s as Ea}from"./savedPapersAuth-DGFT96jK.js";import"./hover-card-ZLvvmDBQ.js";import"./popover-DCNDGa7R.js";import"./textarea-5B6QJFXu.js";/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sa=Re("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pa=Re("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dt=Re("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $a=Re("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ss=Re("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);function Ia(t){return t!=null&&t.can_directly_edit_catalog?"direct":"pending"}function La(t){return(t??[]).filter(s=>!!(s.dataset_slug&&s.task_slug))}function Ra(t,s,a="https://paperswithcode.co"){return s.map(r=>{const n=encodeURIComponent(r.evaluation_id),d=`${a}/api/v1/papers/${encodeURIComponent(t)}/leaderboard-badge.svg?eval=${n}&live=1`,l=`${a}/api/v1/papers/${encodeURIComponent(t)}/leaderboard-badge-link?eval=${n}`;return`[![${`Papers with Code: ${r.best_rank===1?"SOTA":`#${r.best_rank}`} on ${r.dataset_name}`}](${d})](${l})`}).join(` +`)}function Aa(t){const s=ce(t);if(!s)return!1;const a=new URL(s);return`${a.pathname}?${a.search}`.toLowerCase().includes(".pdf")||a.pathname.toLowerCase().includes("/pdf")}function Fa(t,s){if(t.source==="external")return(Aa(t.source_url)||!!ce(t.conference_url_pdf))&&t.id?`/pdf/${t.id}`:null;const a=(t.arxiv_id||s).replace(/v\d+$/i,"");return ce(t.url_pdf)&&a?`/pdf/${a}`:null}function Ta(t,s=!0){return de({queryKey:["evaluations","paper",t],queryFn:()=>{if(!t)throw new Error("Paper ID is required");return Oe.byPaper(t)},enabled:s&&!!t,staleTime:0,refetchOnMount:"always"})}const as=t=>t.replace(/v\d+$/,""),Ua={models:"https://huggingface.co/",datasets:"https://huggingface.co/datasets/",spaces:"https://huggingface.co/spaces/"},Je=(t,s)=>{const a=(t[s]||[]).length;return a<100?{count:a,isLimited:!1}:{count:a,isLimited:!0}},et=(t,s)=>{const a=t[s];return Array.isArray(a)?a.map(r=>{if(typeof r=="string")return r;if(r&&typeof r=="object"){const n=r;return n.id||n.repoId||null}return null}).filter(r=>!!r).map(r=>`${Ua[s]}${r}`):[]},Da=async t=>{try{return(await fetch(`https://huggingface.co/api/papers/${as(t)}`)).ok}catch{return!1}},Ba=async t=>{const s=as(t),[a,r]=await Promise.all([fetch(`https://huggingface.co/api/arxiv/${s}/repos`).then(async i=>i.ok?i.json():(console.warn(`Failed to fetch repos for arXiv:${s}, status: ${i.status}`),null)).catch(i=>(console.warn(`Failed to fetch repos for arXiv:${s}:`,i),null)),Da(s)]);if(!a)return{models:0,datasets:0,spaces:0,modelUrls:[],datasetUrls:[],spaceUrls:[],isLimited:!1,paperExists:r};const n=Je(a,"models"),d=Je(a,"datasets"),l=Je(a,"spaces");return{models:n.count,datasets:d.count,spaces:l.count,modelUrls:et(a,"models"),datasetUrls:et(a,"datasets"),spaceUrls:et(a,"spaces"),isLimited:n.isLimited||d.isLimited||l.isLimited,paperExists:r}},Ha=t=>de({queryKey:["huggingface-repos",t],queryFn:()=>Ba(t),enabled:!!t,staleTime:10*60*1e3,retry:1});function za(t,s){try{const a=new URL(t),r=a.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return(r==null?void 0:r.replace(/[-_]+/g," "))||a.hostname.replace(/^www\./,"")}catch{return s}}function tt(t,s,a){return[...new Set([...t,...s??[]])].map(r=>({href:r,label:za(r,a)}))}function st(t,s,a){if(a==null&&t.length===0&&!(s!=null&&s.length))return;const r=new Set([...t,...s??[]]);return Math.max(r.size,a??0)}function at(t){return t[0]??"https://huggingface.co"}function rt(t,s){return s[0]??t}function Ma(t){const s=`${t.title.slice(0,60)}${t.title.length>60?"…":""}`,a=`${t.authors[0]||""}${t.authors.length>1?" et al.":""}`,r=t.authors.join(" and "),n=(t.published||"").slice(0,4)||"—",d=(l,i)=>t.arxiv_id?`@article{${t.arxiv_id.replace(".","")}, + title={{${l}}}, + author=${i}, + year={{${n}}}, + eprint={{${t.arxiv_id}}}, + archivePrefix={{arXiv}} +}`:`@misc{paper${t.id}, + title={{${l}}}, + author=${i}, + year={{${n}}}, + url={{${t.source_url||t.url_abs||""}}} +}`;return{citationDisplay:d(s,`{{${a}}}`),citationCopy:d(t.title,`{${r}}`)}}function qa(t,s,a){var x,b,_,j;const r={models:t.hf_models??[],datasets:t.hf_datasets??[],spaces:t.hf_spaces??[]},n={models:tt(r.models,s==null?void 0:s.modelUrls,"Model"),datasets:tt(r.datasets,s==null?void 0:s.datasetUrls,"Dataset"),spaces:tt(r.spaces,s==null?void 0:s.spaceUrls,"Space")},d={models:n.models.map(({href:v})=>v),datasets:n.datasets.map(({href:v})=>v),spaces:n.spaces.map(({href:v})=>v)},l=((x=t.arxiv_id)==null?void 0:x.replace(/v\d+$/,""))??null,i=t.arxiv_id?{isLoading:a,paperHref:`https://huggingface.co/papers/${l}`,rows:[{label:"Models",href:rt(`https://huggingface.co/models?other=arxiv:${t.arxiv_id}`,r.models),count:st(r.models,s==null?void 0:s.modelUrls,s==null?void 0:s.models),isLimited:s==null?void 0:s.isLimited,links:n.models},{label:"Datasets",href:rt(`https://huggingface.co/datasets?other=arxiv:${t.arxiv_id}`,r.datasets),count:st(r.datasets,s==null?void 0:s.datasetUrls,s==null?void 0:s.datasets),isLimited:s==null?void 0:s.isLimited,links:n.datasets},{label:"Spaces",href:rt(`https://huggingface.co/papers/${l}`,r.spaces),count:st(r.spaces,s==null?void 0:s.spaceUrls,s==null?void 0:s.spaces),isLimited:s==null?void 0:s.isLimited,links:n.spaces}],footer:`Cite arxiv.org/abs/${l} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:at(r.models),count:r.models.length,links:n.models},{label:"Datasets",href:at(r.datasets),count:r.datasets.length,links:n.datasets},{label:"Spaces",href:at(r.spaces),count:r.spaces.length,links:n.spaces}],footer:null},c=(t.methods??[]).filter(({source_paper_id:v})=>v===t.id),p=t.introduced_benchmarks??[],f=t.introduced_frameworks??[],o=[c.length&&(c.length===1?"this method":"these methods"),p.length&&(p.length===1?"this benchmark":"these benchmarks"),f.length&&(f.length===1?"this framework":"these frameworks")].filter(v=>!!v);return{...Ma(t),allHfArtifactUrls:d,authorEntries:t.authors.map((v,C)=>{var P,I,S,y;return{name:v,id:((I=(P=t.author_links)==null?void 0:P[C])==null?void 0:I.id)??null,hf_username:((y=(S=t.author_links)==null?void 0:S[C])==null?void 0:y.hf_username)??null}}),copyableRanks:La(t.leaderboard_ranks),hasIntroducedItems:o.length>0,hasLineageItems:!!((b=t.predecessor_papers)!=null&&b.length||(_=t.successor_papers)!=null&&_.length),hfArtifactViewer:i,hfPaperExists:!!(s!=null&&s.paperExists),introducedBenchmarks:p,introducedFrameworks:f,introducedMethods:c,introducedSummary:o.join(" and "),numPages:t.num_pages||null,paperSourceLabel:t.arxiv_id?`arXiv:${t.arxiv_id}`:"External resource",predecessorPapers:t.predecessor_papers??[],projectPages:((j=t.project_pages)==null?void 0:j.filter(({url:v})=>v).map(v=>({...v,safeHref:ce(v.url)})))??[],repoSummary:oa(t.repositories),safeAbstractUrl:ce(t.url_abs),safeConferenceUrl:ce(t.conference_url_abs),safePdfUrl:ce(t.url_pdf),sourceActionLabel:t.source==="external"?"Source page":"arXiv page",successorPapers:t.successor_papers??[]}}const Oa=["tldr","abstract","tasks","methods","results"];function Ka(t){if(!t)return{section:null,resultsTaskSlug:null};const[s,a]=t.split("?",2);if(!Oa.includes(s))return{section:null,resultsTaskSlug:null};const r=s;return r!=="results"||!a?{section:r,resultsTaskSlug:null}:{section:r,resultsTaskSlug:new URLSearchParams(a).get("task")}}const rs=t=>`results-task-${t}`,Ga=t=>`#results?task=${encodeURIComponent(t)}`;function Va(t,s){return t&&!!s}function Xa({direct:t,paperId:s,refetchEvaluations:a,refetchPaper:r}){r(),a(),!(!t||!s)&&(Q.primeCurationState(s,!0).catch(()=>{}),Oe.primeCurationState(s,!0).catch(()=>{}))}function Qa(t,s){const a=t?Rs(t):"",r=Xt(),{toast:n}=ie(),{preferences:d}=As(),l=ra(a,!!a),i=l.data,[c,p]=m.useState(!1);m.useEffect(()=>{!t||t===a||r(`/paper/${a}${window.location.search}${window.location.hash}`,{replace:!0})},[a,r,t]),m.useEffect(()=>{if(i!=null&&i.title)return document.title=na(i.title),()=>{document.title=ia}},[i==null?void 0:i.title]),m.useEffect(()=>{if(p(!1),!(i!=null&&i.id))return;const S=window.setTimeout(()=>p(!0),0);return()=>window.clearTimeout(S)},[i==null?void 0:i.id]);const f=Va(c,i==null?void 0:i.id),o=Ha(c?i==null?void 0:i.arxiv_id:void 0),x=Ta(i==null?void 0:i.id,f),b=de({queryKey:[...ye.feeds.versions,i==null?void 0:i.arxiv_id],queryFn:()=>Q.versions(i.arxiv_id.replace(/v\d+$/,"")),enabled:f&&!!(i!=null&&i.arxiv_id),staleTime:10*60*1e3}),_=de({queryKey:[...ye.feeds.related,i==null?void 0:i.id],queryFn:()=>Q.related(i.arxiv_id||i.id,4),enabled:f,staleTime:10*60*1e3});m.useEffect(()=>{const S=()=>{Xa({direct:s==="direct",paperId:i==null?void 0:i.id,refetchEvaluations:x.refetch,refetchPaper:l.refetch}),n({title:"This section changed",description:"The latest state has been reloaded. Review your changes before submitting again.",variant:"destructive"})};return window.addEventListener("pwc:catalog-conflict",S),()=>window.removeEventListener("pwc:catalog-conflict",S)},[s,x.refetch,i==null?void 0:i.id,l.refetch,n]);const j=m.useMemo(()=>{const S=x.data;return!S||!d.hide_closed_source_evals?S:S.filter(y=>y.is_open!==!1)},[x.data,d.hide_closed_source_evals]),v=m.useMemo(()=>{if(!j)return[];const S=new Map;for(const y of j){const u=S.get(y.task_id);u?u.rows.push(y):S.set(y.task_id,{taskId:y.task_id,taskName:y.task_name||"—",taskSlug:y.task_slug,rows:[y]})}return[...S.values()]},[j]),C=m.useMemo(()=>v.map(({taskSlug:S})=>S??"").join("|"),[v]),P=m.useMemo(()=>i?qa(i,o.data,o.isLoading):null,[o.data,o.isLoading,i]),I=m.useRef(!1);return m.useEffect(()=>{I.current=!1},[a]),m.useEffect(()=>{let S=0;const y=(g=!1,E=!1)=>{const{section:F,resultsTaskSlug:M}=Ka(window.location.hash.slice(1));if(!F||!i||F==="tldr"&&!i.tldr||F==="results"&&(!f||x.isLoading)||!g&&I.current)return;let O=F==="results"&&M?document.getElementById(rs(M)):document.getElementById(F);if(!O&&F==="results"&&M){if(v.some(({taskSlug:K})=>K===M))return;O=document.getElementById("results")}O&&(S=window.requestAnimationFrame(()=>{I.current=!0,O.scrollIntoView({block:"start",behavior:E?"smooth":"auto"})}))};y();const u=()=>{I.current=!1,y(!0,!0)};return window.addEventListener("hashchange",u),()=>{window.removeEventListener("hashchange",u),S&&window.cancelAnimationFrame(S)}},[v,x.isLoading,i,C,f]),{arxivId:a,evaluations:x.data,evaluationsByTask:v,evaluationsLoading:x.isLoading,hfLoading:o.isLoading,hfRepos:o.data,paper:i,paperError:l.error,paperLoading:l.isLoading,presentation:P,refetchEvaluations:x.refetch,refetchPaper:l.refetch,relatedQuery:_,versions:b.data??[],visibleEvaluations:j}}const Za={tasks:"tasks",methods:"methods",evaluations:"results",repositories:"repositories",project_pages:"project-pages",hf_artifacts:"hf-artifacts",organizations:"organizations",source_url:"source-url",x_threads:"x-threads"};function Wa(t){return Za[t]??null}function Ya(){const[t,s]=m.useState(null),a=m.useCallback(n=>{s(n)},[]),r=m.useCallback((n,d)=>{s(l=>d?n:l===n?null:l)},[]);return{activeEditor:t,openEditor:a,setEditorOpen:r}}const Ja="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",er="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23D97757'%20d='m50.228%20170.321%2050.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0%20125.796l.583-3.759%205.12-3.434%207.324.648%2016.202%201.101%2024.304%201.685%2017.629%201.037%2026.118%202.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758%207-7.713%209.397.649%202.398.648%209.527%207.323%2020.35%2015.75L94.817%2091.9l3.889%203.24%201.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42%200%2082.05%201.426l4.472%203.888%206.61%2015.101%2010.694%2023.786%2016.591%2032.34%204.861%209.592%202.592%208.879.973%202.722h1.685v-1.556l1.36-18.211%202.528-22.36%202.463-28.776.843-8.1%204.018-9.722%207.971-5.25%206.222%202.981%205.12%207.324-.713%204.73-3.046%2019.768-5.962%2030.98-3.889%2020.739h2.268l2.593-2.593%2010.499-13.934%2017.628-22.036%207.778-8.749%209.073-9.657%205.833-4.601h11.018l8.1%2012.055-3.628%2012.443-11.342%2014.388-9.398%2012.184-13.48%2018.147-8.426%2014.518.778%201.166%202.01-.194%2030.46-6.481%2016.462-2.982%2019.637-3.37%208.88%204.148.971%204.213-3.5%208.62-20.998%205.184-24.628%204.926-36.682%208.685-.454.324.519.648%2016.526%201.555%207.065.389h17.304l32.21%202.398%208.426%205.574%205.055%206.805-.843%205.184-12.962%206.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666%2011.406%2021.387%2019.314%2026.767%2024.887%201.36%206.157-3.434%204.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73%206.935%2025.017%2037.59%201.296%2011.536-1.814%203.76-6.481%202.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194%2077.448-3.37%203.953-7.778%202.981-6.48-4.925-3.436-7.972%203.435-15.749%204.148-20.544%203.37-16.333%203.046-20.285%201.815-6.74-.13-.454-1.49.194-15.295%2020.999-23.267%2031.433-18.406%2019.702-4.407%201.75-7.648-3.954.713-7.064%204.277-6.286%2025.47-32.405%2015.36-20.092%209.917-11.6-.065-1.686h-.583L44.07%20198.125l-12.055%201.555-5.185-4.86.648-7.972%202.463-2.593%2020.35-13.999-.064.065Z'/%3e%3c/svg%3e",tr="data:image/svg+xml,%3csvg%20fill='%23111'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",sr="data:image/svg+xml,%3csvg%20fill='%23fff'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M8.086.457a6.105%206.105%200%20013.046-.415c1.333.153%202.521.72%203.564%201.7a.117.117%200%2000.107.029c1.408-.346%202.762-.224%204.061.366l.063.03.154.076c1.357.703%202.33%201.77%202.918%203.198.278.679.418%201.388.421%202.126a5.655%205.655%200%2001-.18%201.631.167.167%200%2000.04.155%205.982%205.982%200%20011.578%202.891c.385%201.901-.01%203.615-1.183%205.14l-.182.22a6.063%206.063%200%2001-2.934%201.851.162.162%200%2000-.108.102c-.255.736-.511%201.364-.987%201.992-1.199%201.582-2.962%202.462-4.948%202.451-1.583-.008-2.986-.587-4.21-1.736a.145.145%200%2000-.14-.032c-.518.167-1.04.191-1.604.185a5.924%205.924%200%2001-2.595-.622%206.058%206.058%200%2001-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74%207.74%200%2001-.495-1.283%206.11%206.11%200%2001-.017-3.064.166.166%200%2000.008-.074.115.115%200%2000-.037-.064%205.958%205.958%200%2001-1.38-2.202%205.196%205.196%200%2001-.333-1.589%206.915%206.915%200%2001.188-2.132c.45-1.484%201.309-2.648%202.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129%200%2000.087-.087A6.016%206.016%200%20015.635%202.31C6.315%201.464%207.132.846%208.086.457zm-.804%207.85a.848.848%200%2000-1.473.842l1.694%202.965-1.688%202.848a.849.849%200%20001.46.864l1.94-3.272a.849.849%200%2000.007-.854l-1.94-3.393zm5.446%206.24a.849.849%200%20000%201.695h4.848a.849.849%200%20000-1.696h-4.848z'%3e%3c/path%3e%3c/svg%3e",ar="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_light__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_light__st0{fill:%2326251e}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_light__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",rr="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='cursor_dark__Ebene_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20466.73%20532.09'%3e%3c!--Generator:%20Adobe%20Illustrator%2029.6.1,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%209)--%3e%3cdefs%3e%3cstyle%3e.cursor_dark__st0{fill:%23edecec}%3c/style%3e%3c/defs%3e%3cpath%20class='cursor_dark__st0'%20d='M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z'/%3e%3c/svg%3e",nr="data:image/svg+xml,%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23FDFCFC'/%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%23E6E5E6'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='%2317181C'/%3e%3c/svg%3e",ir="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='512'%20height='512'%3e%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='512'%20height='512'%20fill='%23131010'%3e%3c/rect%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20fill='%235A5858'%3e%3c/path%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'%20fill='white'%3e%3c/path%3e%3c/svg%3e%3cstyle%3e@media%20(prefers-color-scheme:%20light)%20{%20:root%20{%20filter:%20none;%20}%20}%20@media%20(prefers-color-scheme:%20dark)%20{%20:root%20{%20filter:%20none;%20}%20}%20%3c/style%3e%3c/svg%3e",ns=[{name:"Claude",light:Ja,dark:er},{name:"Codex",light:tr,dark:sr},{name:"Cursor",light:ar,dark:rr},{name:"OpenCode",light:nr,dark:ir}];function or(){return e.jsx("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1.5","aria-hidden":"true",children:ns.map(({name:t,light:s,dark:a})=>e.jsxs("span",{title:t,className:"inline-flex h-[18px] w-[18px]",children:[e.jsx("img",{src:s,alt:"",width:18,height:18,className:"h-full w-full object-contain dark:hidden"}),e.jsx("img",{src:a,alt:"",width:18,height:18,className:"hidden h-full w-full object-contain dark:block"})]},t))})}function lr(){return e.jsx("ul",{className:"flex flex-wrap gap-2","aria-label":"Supported coding agents",children:ns.map(({name:t,light:s,dark:a})=>e.jsxs("li",{className:"inline-flex items-center gap-2 rounded-full border px-3 py-1 text-sm",children:[e.jsx("img",{src:s,alt:"",width:18,height:18,className:"h-[18px] w-[18px] object-contain dark:hidden"}),e.jsx("img",{src:a,alt:"",width:18,height:18,className:"hidden h-[18px] w-[18px] object-contain dark:block"}),t]},t))})}function cr({paperId:t,isAdmin:s}){var x;const[a,r]=m.useState(!1),[n,d]=m.useState(!1),[l,i]=m.useState(!1),[c,p]=m.useState(()=>window.location.hash.startsWith("#edit")),f=da({queryKey:["paper-edit-history",t],queryFn:({pageParam:b})=>ua.history(t,b),initialPageParam:void 0,getNextPageParam:b=>b.next_cursor??void 0,enabled:s&&c}),o=`Help me edit https://paperswithcode.co/paper/${t} using the public pwc CLI from https://github.com/huggingface/pwc-cli. Install or update the CLI following its README, then run pwc skills add to load its instructions. Run pwc auth login --paper ${t}; I will authorize this paper in my browser. Export with pwc paper edit export ${t} --output edits.json, make explicit operations for the corrections I request, and preview before submitting. For organization changes, use an organizations operation with payload {"organization_ids": [existing organization IDs]}; this replaces the paper’s organization links and publishes directly. Use existing organizations, benchmark and metric definitions, preserve unrelated entries, and cite source URLs where available. Never print or copy credentials. Ask me what to change if I have not specified it.`;return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"action-btn",title:"Edit this paper page with Claude, Codex, Cursor, or OpenCode",onClick:()=>{r(!1),d(!1),i(!0)},children:["Edit with your agent",e.jsx(or,{})]}),s&&e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>p(!0),children:[e.jsx($a,{size:12})," View edit history"]}),e.jsx(ee,{open:l,onOpenChange:i,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit this paper with your agent"}),e.jsx(re,{children:"Spotted a missing code link, a wrong task, or a missing benchmark result? Your favorite coding agent can fix it for you."})]}),e.jsx(lr,{}),e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:"Copy the prompt below."}),e.jsx("li",{children:"Paste it into Claude Code, Codex, Cursor, OpenCode, or another coding agent, and tell it what to change."}),e.jsxs("li",{children:["The agent installs the ",e.jsx("a",{className:"underline",href:"https://github.com/huggingface/pwc-cli",target:"_blank",rel:"noreferrer",children:"pwc CLI"}),", asks you to authorize this paper with your Hugging Face account, and previews the edits before submitting them."]})]}),e.jsx("textarea",{"aria-label":"Paper edit prompt",readOnly:!0,value:o,className:"h-48 w-full resize-none rounded border bg-muted/40 p-3 font-mono text-xs",onFocus:b=>b.currentTarget.select()}),n&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"Could not copy automatically. Select the prompt above and copy it manually."}),e.jsxs(A,{className:"justify-self-end",onClick:async()=>{try{await navigator.clipboard.writeText(o),r(!0),d(!1)}catch{d(!0)}},children:[a?e.jsx(ue,{size:14}):e.jsx(ma,{size:14}),a?"Prompt copied":"Copy prompt"]})]})}),e.jsx(ee,{open:s&&c,onOpenChange:p,children:e.jsxs(te,{className:"max-h-[85vh] max-w-3xl overflow-y-auto",id:"edit-history",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Paper edit history"}),e.jsx(re,{children:"Published changes and their contributors."})]}),e.jsxs("div",{className:"space-y-3",children:[f.isLoading&&e.jsx("p",{children:"Loading edit history…"}),f.error&&e.jsx("p",{role:"alert",children:"Could not load edit history."}),f.data&&!f.data.pages[0].events.length&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No edits have been recorded here yet."}),(x=f.data)==null?void 0:x.pages.flatMap(b=>b.events).map(b=>e.jsxs("article",{id:`edit-${b.id}`,className:"rounded border p-3",children:[e.jsxs("p",{className:"text-sm",children:[b.actor_username?e.jsxs("a",{className:"underline",href:`https://huggingface.co/${encodeURIComponent(b.actor_username)}`,children:["@",b.actor_username]}):"Catalog administrator"," · ",new Date(b.created_at).toLocaleString()," · ",b.operation==="rollback"?"Reverted an edit":"Updated this paper"]}),e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer text-sm",children:"View changes"}),e.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap text-xs",children:JSON.stringify({before:b.before,after:b.after},null,2)})]})]},b.id)),f.hasNextPage&&e.jsx(A,{variant:"outline",disabled:f.isFetchingNextPage,onClick:()=>void f.fetchNextPage(),children:"Load older edits"})]})]})})]})}function dr(t){return t.map(s=>{const a=s.best_metric||Object.keys(s.metrics)[0]||"";return{id:s.id,task_id:s.task_id,dataset_id:s.dataset_id,model_name:s.model_name||"",harness:s.harness||"",metric_name:a,metric_value:String(s.metrics[a]??""),original_metrics:{...s.metrics},original_metric_name:a,best_rank:s.best_rank!=null?String(s.best_rank):"",num_parameters:s.num_parameters!=null?String(s.num_parameters):"",hf_model_url:s.hf_model_url||"",is_open:s.is_open!==!1,operation:"unchanged"}})}function ur(t,s){const a={...t.original_metrics},r=a[t.original_metric_name];return t.original_metric_name!==s&&delete a[t.original_metric_name],a[s]=r!=null&&t.metric_value===String(r)?r:t.metric_value,a}function mr(t){const s=t==null?void 0:t.trim();return s?Number(s):void 0}function Bt(t){const s=t.trim();return s?Number(s):null}function nt(t){return t.trim()||null}function it(t){return!!(t&&/^\d+$/.test(t.trim())&&Number.isSafeInteger(Number(t))&&Number(t)>0)}function is(t){const s=[];return t.forEach((a,r)=>{var l;if(!a.operation||a.operation==="unchanged")return;const n=(i,c)=>{s.push({rowIndex:r,field:i,message:c})};if(a.operation!=="create"&&!it(a.id)&&n("id","This result has no valid evaluation ID. Reload the paper before editing it."),a.operation==="delete")return;it(a.task_id)||n("task_id","Select a valid task."),it(a.dataset_id)||n("dataset_id","Select a valid dataset.");const d=a.metric_name.trim();d?d!==a.original_metric_name&&Object.prototype.hasOwnProperty.call(a.original_metrics,d)&&n("metric_name",`Cannot rename a metric to "${d}": this evaluation already has that score.`):n("metric_name","Select a metric."),(l=a.best_rank)!=null&&l.trim()&&!Number.isSafeInteger(Number(a.best_rank))&&n("best_rank","Enter a whole-number rank."),a.num_parameters.trim()&&(!Number.isSafeInteger(Number(a.num_parameters))||Number(a.num_parameters)<0)&&n("num_parameters","Enter a non-negative whole-number parameter count."),a.metric_value.trim()||n("metric_value","Enter a metric value.")}),s}function hr(t,s){const a=is(t);return a.length?{valid:!1,errors:a}:{valid:!0,operations:pr(t,s)}}function pr(t,s){const a=[];for(const r of t){if(r.operation==="delete"){a.push({kind:"delete",evaluationId:Number(r.id)});continue}if(r.operation!=="create"&&r.operation!=="update")continue;const n=r.metric_name.trim(),d=s(r.task_id,r.dataset_id),l={task_id:Number(r.task_id),dataset_id:Number(r.dataset_id),metrics:ur(r,n),best_metric:n,is_open:r.is_open},i=r.model_name.trim(),c=mr(r.best_rank);if(r.operation==="create"){const p=Bt(r.num_parameters),f=nt(r.hf_model_url);a.push({kind:"create",data:{...l,...i?{model_name:i}:{},...d&&r.harness.trim()?{harness:r.harness.trim()}:{},...c!==void 0?{best_rank:c}:{},...p!==null?{num_parameters:p}:{},...f!==null?{hf_model_url:f}:{}}});continue}a.push({kind:"update",evaluationId:Number(r.id),data:{...l,...i?{model_name:i}:{},harness:d?nt(r.harness):null,...c!==void 0?{best_rank:c}:{},num_parameters:Bt(r.num_parameters),hf_model_url:nt(r.hf_model_url)}})}return a}function fr(t,s){return s.map(a=>a.kind==="delete"?{operation:"delete",evaluation_id:a.evaluationId}:{operation:a.kind,...a.kind==="update"?{evaluation_id:a.evaluationId}:{},payload:a.kind==="create"?{paper_id:t,...a.data}:a.data})}function gr(t){return t.map(s=>s.kind==="delete"?{op:"delete",evaluation_id:s.evaluationId}:s.kind==="update"?{op:"update",evaluation_id:s.evaluationId,data:s.data}:{op:"create",data:s.data})}function ge({isAuthor:t=!1}){const s=typeof window<"u"&&window.location.hostname==="staging.paperswithcode.co";return e.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-100",children:[e.jsx("p",{className:"font-medium",children:s?"Test-only: this change stays on staging.":"Your changes will be reviewed by an admin."}),e.jsx("p",{className:"mt-1 leading-snug",children:s?"This exercises staging-local pending behavior and is not queued for production review.":t?"We can see this paper is yours. While we're in early access an admin still reviews each edit; this will become automatic for authors soon.":"Submissions are queued for review and don't change the paper page until an admin approves them."})]})}const ot=100;function xr(t){return(t??[]).some(s=>s.slug==="coding-agents"||s.name.trim().toLowerCase()==="coding agents")}function br(t){const s=new Map;return t.forEach(a=>{a.task_id&&a.task_name&&s.set(a.task_id,{id:a.task_id,name:a.task_name,slug:a.task_slug,level:0})}),s}function jr(t){const s=new Map;return t.forEach(a=>{a.dataset_id&&a.dataset_name&&s.set(a.dataset_id,{id:a.dataset_id,name:a.dataset_name,slug:a.dataset_slug})}),s}function Ht(t,s){return`${t}:${s}`}function vr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialEvaluations:n,paperTasks:d,onSuccess:l,submitMode:i="direct",isAdmin:c=!1,isAuthor:p=!1}){const f=m.useId(),o=xr(d),[x,b]=m.useState([]),[_,j]=m.useState(!1),v=_?is(x):[],[C,P]=m.useState(null),[I,S]=m.useState(new Map),[y,u]=m.useState(new Map),g=me(),{toast:E}=ie(),F=m.useRef(!1),M=m.useRef(!1);m.useEffect(()=>{if(!t){j(!1),F.current=!1,M.current=!1;return}F.current||M.current||n.length!==0&&(F.current=!0,b(dr(n)),S(br(n)),u(jr(n)))},[t,n]);const O=m.useMemo(()=>Array.from(new Set(x.map(w=>w.task_id).filter(w=>w&&w!==""))),[x]),K=m.useMemo(()=>{const w=new Set;return x.forEach(k=>{k.task_id&&k.dataset_id&&w.add(Ht(k.task_id,k.dataset_id))}),Array.from(w)},[x]),G=de({queryKey:["datasets-by-tasks-for-eval-edit",O,t],queryFn:async()=>{const w={};return await Promise.all(O.map(async k=>{try{const R=await _e.listDatasets({task_id:parseInt(k),page_size:ot});w[k]=R.results}catch(R){console.error(`Error fetching datasets for task ${k}:`,R),w[k]=[]}})),w},enabled:t&&O.length>0});m.useEffect(()=>{G.data&&u(w=>{const k=new Map(w);return Object.values(G.data).forEach(R=>{R.forEach(D=>{k.set(D.id,D)})}),k})},[G.data]);const h=de({queryKey:["leaderboard-metrics-for-eval-edit",K,t],queryFn:async()=>{const w={};return await Promise.all(K.map(async k=>{const[R,D]=k.split(":");try{w[k]=await _e.leaderboardMetrics(D,R)}catch(X){console.error(`Error fetching metrics for leaderboard ${k}:`,X),w[k]=[]}})),w},enabled:t&&K.length>0}),$=async w=>{const k=await _e.listTasks({page_size:ot,...w?{q:w}:{}});return S(R=>{const D=new Map(R);return k.results.forEach(X=>D.set(X.id,X)),D}),k.results.map(R=>{var D;return{value:R.id,label:R.name,description:(D=R.description)==null?void 0:D.slice(0,100)}})},L=w=>async k=>{const R=await _e.listDatasets({task_id:parseInt(w),page_size:ot,...k?{q:k}:{}});return u(D=>{const X=new Map(D);return R.results.forEach(V=>X.set(V.id,V)),X}),R.results.map(D=>({value:D.id,label:D.name,description:D.full_name}))},T=(w,k)=>{if(!w||!k)return!1;const R=y.get(k);return!!(R!=null&&R.supports_harness)},U=(w,k,R)=>{var V;if(!w||!k)return[];const X=(((V=h.data)==null?void 0:V[Ht(w,k)])||[]).map(B=>({value:B.metric_name,label:B.metric_name,description:B.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return R&&!X.some(B=>B.value===R)&&X.unshift({value:R,label:`${R} (legacy)`}),X},H=he({mutationFn:async({paperId:w,canonical:k})=>{if(!c&&i==="direct"&&k.length>50)throw new Error("Contributor evaluation batches are limited to 50 operations; contact an admin.");const R=Number.parseInt(w,10);if(i==="pending")await fe.submit({paper_id:R,edit_type:"evaluations",proposed_payload:{operations:gr(k)}});else{const D=ha(w,n,k,r);await Oe.batch(R,fr(R,k)),pa(g,D)}},onSuccess:()=>{if(i==="pending"){E({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed evaluation changes shortly."}),l==null||l(),s(!1);return}l==null||l(),s(!1)},onError:w=>{const k=je(w,i==="pending"?"Failed to submit your edit. Please try again.":"Failed to update evaluations.");E({title:i==="pending"?"Could not submit edit":"Could not save evaluations",description:k,variant:"destructive"})}}),z=()=>{M.current=!0,b([...x,{task_id:"",dataset_id:"",model_name:"",harness:"",metric_name:"",metric_value:"",original_metrics:{},original_metric_name:"",best_rank:"",num_parameters:"",hf_model_url:"",is_open:!0,operation:"create"}])},Y=w=>{if(M.current=!0,x[w].id){if(!window.confirm("Delete this evaluation? You will be asked to sign in again if your session is older than 15 minutes."))return;b(x.map((R,D)=>D===w?{...R,operation:"delete"}:R))}else b(x.filter((R,D)=>D!==w))},J=(w,k,R)=>{M.current=!0,b(x.map((D,X)=>{if(X!==w||D[k]===R)return D;const V={...D,[k]:R};return(k==="task_id"||k==="dataset_id")&&(V.original_metrics={},V.original_metric_name="",V.metric_value="",V.best_rank=""),k==="task_id"&&(V.dataset_id="",V.metric_name="",V.harness=""),k==="dataset_id"&&(V.metric_name="",R&&!T(V.task_id,R)&&(V.harness="")),D.operation==="unchanged"&&(V.operation="update"),V}))},Xe=(w,k)=>{M.current=!0,b(x.map((R,D)=>{if(D!==w)return R;const X={...R,is_open:k};return R.operation==="unchanged"&&(X.operation="update"),X}))},Ue=()=>{j(!0);const w=hr(x,T);if(w.valid){if(w.operations.length===0){E({title:"No changes to submit",description:"Your evaluation list matches the existing data."});return}H.mutate({paperId:a,canonical:w.operations})}},we=(w,k)=>{const R=v.find(D=>D.rowIndex===w&&D.field===k);return R?e.jsx("p",{id:`${f}-${w}-${k}-error`,className:"text-xs text-destructive",children:R.message}):null};return e.jsxs(ee,{open:t,onOpenChange:s,children:[e.jsxs(te,{className:"max-w-6xl max-h-[800px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Evaluation Results"}),e.jsx(re,{children:"Add, edit, or remove evaluation results for this paper. Each row represents a benchmark result."})]}),i==="pending"&&e.jsx(ge,{isAuthor:p}),v.length>0&&e.jsxs("div",{role:"alert",className:"text-sm text-destructive",children:["Fix the following errors before saving. No changes have been submitted.",e.jsx("ul",{children:v.map(w=>e.jsxs("li",{children:["Row ",x.slice(0,w.rowIndex+1).filter(k=>k.operation!=="delete").length,": ",w.message]},`${w.rowIndex}-${w.field}`))})]}),e.jsxs("div",{className:"py-4 overflow-y-auto max-h-[600px]",children:[x.filter(w=>w.operation!=="delete").length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[180px]",children:"Task"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[180px]",children:"Dataset"}),e.jsx("th",{className:`text-left py-2 px-2 font-medium text-sm ${o?"min-w-[140px]":"min-w-[240px]"}`,children:"Model"}),o&&e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[140px]",children:"Harness"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[140px]",children:"Metric"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm",children:"Value"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm",children:"Parameters"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm min-w-[200px]",children:"HF model URL"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm w-20",children:"Open source"}),e.jsx("th",{className:"text-left py-2 px-2 font-medium text-sm w-16",children:"Action"})]})}),e.jsx("tbody",{children:x.map((w,k)=>{if(w.operation==="delete")return null;const R=I.get(w.task_id),D=y.get(w.dataset_id),X=U(w.task_id,w.dataset_id,w.metric_name),V=!!(w.task_id&&w.dataset_id)&&h.isFetching;return e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"py-2 px-2",children:e.jsxs("div",{role:"group","aria-label":"Task","aria-describedby":`${f}-${k}-task_id-error`,children:[e.jsx(At,{value:w.task_id,onChange:B=>J(k,"task_id",B),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:R?{value:R.id,label:R.name}:null,queryKey:["eval-edit-task-search"],queryFn:$,enabled:t}),we(k,"task_id")]})}),e.jsx("td",{className:"py-2 px-2",children:e.jsxs("div",{role:"group","aria-label":"Dataset","aria-describedby":`${f}-${k}-dataset_id-error`,children:[e.jsx(At,{value:w.dataset_id,onChange:B=>J(k,"dataset_id",B),placeholder:w.task_id?"Select dataset":"Select task first",searchPlaceholder:"Search datasets...",emptyMessage:w.task_id?"No datasets found for this task.":"Select a task first.",disabled:!w.task_id,selectedOption:D?{value:D.id,label:D.name}:null,queryKey:["eval-edit-dataset-search",w.task_id],queryFn:L(w.task_id),enabled:t&&!!w.task_id}),we(k,"dataset_id")]})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(W,{type:"text",className:"w-full text-sm",placeholder:"Model name",value:w.model_name,onChange:B=>J(k,"model_name",B.target.value)})}),o&&e.jsx("td",{className:"py-2 px-2",children:T(w.task_id,w.dataset_id)?e.jsx(W,{type:"text",className:"w-full text-sm",placeholder:"Claude Code, Terminus, ...",value:w.harness,onChange:B=>J(k,"harness",B.target.value)}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not supported"})}),e.jsxs("td",{className:"py-2 px-2",children:[!w.task_id||!w.dataset_id?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select task + dataset"}):V?e.jsxs("span",{className:"inline-flex items-center text-xs text-muted-foreground",children:[e.jsx(ne,{className:"mr-1 h-3 w-3 animate-spin"}),"Loading metrics..."]}):X.length>0?e.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-sm",id:`${f}-${k}-metric_name`,"aria-invalid":v.some(B=>B.rowIndex===k&&B.field==="metric_name"),"aria-describedby":`${f}-${k}-metric_name-error`,value:w.metric_name,onChange:B=>J(k,"metric_name",B.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),X.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No configured metrics"}),we(k,"metric_name")]}),e.jsxs("td",{className:"py-2 px-2",children:[e.jsx(W,{type:"text",className:"w-full text-sm",placeholder:"44.9",id:`${f}-${k}-metric_value`,"aria-invalid":v.some(B=>B.rowIndex===k&&B.field==="metric_value"),"aria-describedby":`${f}-${k}-metric_value-error`,value:w.metric_value,onChange:B=>J(k,"metric_value",B.target.value)}),we(k,"metric_value")]}),e.jsxs("td",{className:"py-2 px-2",children:[e.jsx(W,{type:"number",min:0,step:1,className:"w-full text-sm",placeholder:"e.g. 7000000000",id:`${f}-${k}-num_parameters`,"aria-invalid":v.some(B=>B.rowIndex===k&&B.field==="num_parameters"),"aria-describedby":`${f}-${k}-num_parameters-error`,value:w.num_parameters,onChange:B=>J(k,"num_parameters",B.target.value),title:"Raw model parameter count (e.g. 7000000000 for a 7B model). Leave blank if unknown."}),we(k,"num_parameters")]}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(W,{type:"url",className:"w-full text-sm",placeholder:"https://huggingface.co/org/model",value:w.hf_model_url,onChange:B=>J(k,"hf_model_url",B.target.value),title:"Hugging Face model page for this row (must start with https://huggingface.co/). Leave blank if none."})}),e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 align-middle",checked:w.is_open,onChange:B=>Xe(k,B.target.checked),title:"Whether the evaluated model is open-source. Uncheck for closed-source models."})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>Y(k),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",title:w.id&&!c?"Only administrators can delete published results":"Remove row",disabled:!!w.id&&!c,children:e.jsx(Te,{className:"w-4 h-4"})})})]},k)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ga,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No evaluation results yet"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Row" below to add a new evaluation'})]}),e.jsx("div",{className:"mt-4",children:e.jsxs(A,{variant:"outline",size:"sm",onClick:z,className:"flex items-center space-x-2",children:[e.jsx(Fe,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsxs(oe,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 sm:mr-auto",children:[e.jsx(A,{variant:"ghost",onClick:()=>P("benchmark"),children:"Suggest a new benchmark"}),e.jsx(A,{variant:"ghost",onClick:()=>P("metric"),children:"Suggest a new metric"})]}),e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:Ue,disabled:H.isPending,children:H.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),i==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),i==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(yt,{open:C!==null,onOpenChange:w=>{w||P(null)},paperId:a,kind:C??"benchmark"})]})}const lt=[{key:"hf_models",label:"Models",placeholder:"https://huggingface.co/org/model"},{key:"hf_datasets",label:"Datasets",placeholder:"https://huggingface.co/datasets/org/data"},{key:"hf_spaces",label:"Spaces",placeholder:"https://huggingface.co/spaces/org/demo"}];function zt(t){return t.map(s=>s.trim()).filter(Boolean)}function ct(t,s){const a=zt(t).sort(),r=zt(s).sort();return a.length!==r.length?!1:a.every((n,d)=>n===r[d])}function wr(t,s){return ct(t.hf_models,s.hf_models)&&ct(t.hf_datasets,s.hf_datasets)&&ct(t.hf_spaces,s.hf_spaces)}function yr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialArtifacts:n,onSuccess:d,submitMode:l="direct",isAuthor:i=!1}){const[c,p]=m.useState(n),[f,o]=m.useState({hf_models:"",hf_datasets:"",hf_spaces:""}),x=me(),{toast:b}=ie(),_=m.useRef(!1);m.useEffect(()=>{if(!t){_.current=!1;return}_.current||(_.current=!0,p(n),o({hf_models:"",hf_datasets:"",hf_spaces:""}))},[t,n]);const j=he({mutationFn:async({paperId:y,artifacts:u})=>l==="pending"?(await fe.submit({paper_id:parseInt(y),edit_type:"hf_artifacts",proposed_payload:u}),null):Q.updateHfArtifacts(y,u),onSuccess:y=>{if(l==="pending"){b({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed Hugging Face artifact changes shortly."}),d==null||d(),s(!1),o({hf_models:"",hf_datasets:"",hf_spaces:""});return}y&&ve(x,y,[a,r]),d==null||d(),s(!1),o({hf_models:"",hf_datasets:"",hf_spaces:""})},onError:y=>{const u=je(y,l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update Hugging Face artifacts.");b({title:l==="pending"?"Could not submit edit":"Could not save Hugging Face artifacts",description:u,variant:"destructive"})}}),v=()=>{const y={hf_models:[...c.hf_models],hf_datasets:[...c.hf_datasets],hf_spaces:[...c.hf_spaces]};for(const{key:u}of lt){const g=f[u].trim();if(g){if(y[u].some(E=>E.trim()===g))return alert(`This ${u.replace("hf_","")} URL is already added`),null;y[u]=[...y[u],g]}}return y},C=y=>{const u=f[y].trim();if(u){if(c[y].some(g=>g.trim()===u)){alert(`This ${y.replace("hf_","")} URL is already added`);return}p(g=>({...g,[y]:[...g[y],u]})),o(g=>({...g,[y]:""}))}},P=(y,u)=>{p(g=>({...g,[y]:g[y].filter(E=>E!==u)}))},I=()=>{const y=v();if(y===null)return;const u=Object.keys(n).some(g=>n[g].some(E=>!y[g].includes(E)));l==="direct"&&u&&!window.confirm("Remove one or more Hugging Face artifact links?")||j.mutate({paperId:a,artifacts:y})},S=m.useMemo(()=>{const y={hf_models:[...c.hf_models],hf_datasets:[...c.hf_datasets],hf_spaces:[...c.hf_spaces]};for(const{key:u}of lt){const g=f[u].trim();if(g){if(y[u].some(E=>E.trim()===g))return!1;y[u]=[...y[u],g]}}return!wr(y,n)},[c,f,n]);return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{className:"max-w-2xl max-h-[700px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Hugging Face Artifacts"}),e.jsx(re,{children:"Add or remove linked Hugging Face models, datasets, and Spaces for this paper."})]}),l==="pending"&&e.jsx(ge,{isAuthor:i}),e.jsx("div",{className:"space-y-6 py-2 overflow-y-auto max-h-[460px]",children:lt.map(({key:y,label:u,placeholder:g})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:u}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(W,{type:"url",placeholder:g,value:f[y],onChange:E=>o(F=>({...F,[y]:E.target.value})),onKeyPress:E=>{E.key==="Enter"&&(E.preventDefault(),C(y))},className:"flex-1"}),e.jsxs(A,{onClick:()=>C(y),size:"sm",disabled:!f[y].trim(),children:[e.jsx(Fe,{className:"w-4 h-4 mr-1"}),"Add"]})]}),c[y].length>0?e.jsx("div",{className:"space-y-2",children:c[y].map(E=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate flex-1",children:E}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>P(y,E),className:"h-8 px-2 text-destructive hover:text-destructive",title:`Remove ${u.toLowerCase()} URL`,children:e.jsx(Te,{className:"w-4 h-4"})})]},E))}):e.jsxs("div",{className:"text-xs text-muted-foreground",children:["No ",u.toLowerCase()," linked yet."]})]},y))}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:I,disabled:j.isPending||!S,children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}var Ke="Checkbox",[_r]=vt(Ke),[kr,_t]=_r(Ke);function Nr(t){const{__scopeCheckbox:s,checked:a,children:r,defaultChecked:n,disabled:d,form:l,name:i,onCheckedChange:c,required:p,value:f="on",internal_do_not_use_render:o}=t,[x,b]=Zt({prop:a,defaultProp:n??!1,onChange:c,caller:Ke}),[_,j]=m.useState(null),[v,C]=m.useState(null),P=m.useRef(!1),I=_?!!l||!!_.closest("form"):!0,S={checked:x,disabled:d,setChecked:b,control:_,setControl:j,name:i,form:l,value:f,hasConsumerStoppedPropagationRef:P,required:p,defaultChecked:be(n)?!1:n,isFormControl:I,bubbleInput:v,setBubbleInput:C};return e.jsx(kr,{scope:s,...S,children:Cr(o)?o(S):r})}var os="CheckboxTrigger",ls=m.forwardRef(({__scopeCheckbox:t,onKeyDown:s,onClick:a,...r},n)=>{const{control:d,value:l,disabled:i,checked:c,required:p,setControl:f,setChecked:o,hasConsumerStoppedPropagationRef:x,isFormControl:b,bubbleInput:_}=_t(os,t),j=Ae(n,f),v=m.useRef(c);return m.useEffect(()=>{const C=d==null?void 0:d.form;if(C){const P=()=>o(v.current);return C.addEventListener("reset",P),()=>C.removeEventListener("reset",P)}},[d,o]),e.jsx(ke.button,{type:"button",role:"checkbox","aria-checked":be(c)?"mixed":c,"aria-required":p,"data-state":hs(c),"data-disabled":i?"":void 0,disabled:i,value:l,...r,ref:j,onKeyDown:Ie(s,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:Ie(a,C=>{o(P=>be(P)?!0:!P),_&&b&&(x.current=C.isPropagationStopped(),x.current||C.stopPropagation())})})});ls.displayName=os;var kt=m.forwardRef((t,s)=>{const{__scopeCheckbox:a,name:r,checked:n,defaultChecked:d,required:l,disabled:i,value:c,onCheckedChange:p,form:f,...o}=t;return e.jsx(Nr,{__scopeCheckbox:a,checked:n,defaultChecked:d,disabled:i,required:l,onCheckedChange:p,name:r,form:f,value:c,internal_do_not_use_render:({isFormControl:x})=>e.jsxs(e.Fragment,{children:[e.jsx(ls,{...o,ref:s,__scopeCheckbox:a}),x&&e.jsx(ms,{__scopeCheckbox:a})]})})});kt.displayName=Ke;var cs="CheckboxIndicator",ds=m.forwardRef((t,s)=>{const{__scopeCheckbox:a,forceMount:r,...n}=t,d=_t(cs,a);return e.jsx(Qt,{present:r||be(d.checked)||d.checked===!0,children:e.jsx(ke.span,{"data-state":hs(d.checked),"data-disabled":d.disabled?"":void 0,...n,ref:s,style:{pointerEvents:"none",...t.style}})})});ds.displayName=cs;var us="CheckboxBubbleInput",ms=m.forwardRef(({__scopeCheckbox:t,...s},a)=>{const{control:r,hasConsumerStoppedPropagationRef:n,checked:d,defaultChecked:l,required:i,disabled:c,name:p,value:f,form:o,bubbleInput:x,setBubbleInput:b}=_t(us,t),_=Ae(a,b),j=es(d),v=Wt(r);m.useEffect(()=>{const P=x;if(!P)return;const I=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(I,"checked").set,u=!n.current;if(j!==d&&y){const g=new Event("click",{bubbles:u});P.indeterminate=be(d),y.call(P,be(d)?!1:d),P.dispatchEvent(g)}},[x,j,d,n]);const C=m.useRef(be(d)?!1:d);return e.jsx(ke.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??C.current,required:i,disabled:c,name:p,value:f,form:o,...s,tabIndex:-1,ref:_,style:{...s.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ms.displayName=us;function Cr(t){return typeof t=="function"}function be(t){return t==="indeterminate"}function hs(t){return be(t)?"indeterminate":t?"checked":"unchecked"}const Ge=m.forwardRef(({className:t,style:s,...a},r)=>e.jsx(kt,{ref:r,className:ze("peer h-4 w-4 shrink-0 rounded-sm ring-offset-background data-[state=checked]:!bg-black data-[state=checked]:!text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),style:{border:"1px solid #000",...s},...a,children:e.jsx(ds,{className:ze("flex items-center justify-center text-current"),children:e.jsx(ue,{className:"h-4 w-4"})})}));Ge.displayName=kt.displayName;const Er=250,Sr=100;function Pr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialMethodIds:n,initialMethods:d,onSuccess:l,submitMode:i="direct",isAuthor:c=!1}){const[p,f]=m.useState(n),[o,x]=m.useState(!1),[b,_]=m.useState(""),[j,v]=m.useState(""),[C,P]=m.useState(new Map),I=me(),{toast:S}=ie(),y=m.useRef(!1);m.useEffect(()=>{if(!t){y.current=!1;return}if(y.current)return;y.current=!0,f(n),_(""),v("");const h=new Map;(d||[]).forEach($=>{const L=parseInt($.id);Number.isNaN(L)||h.set(L,$)}),P(h)},[t,n,d]),m.useEffect(()=>{const h=window.setTimeout(()=>{v(b.trim())},Er);return()=>window.clearTimeout(h)},[b]);const{data:u,isFetching:g}=de({queryKey:["methods-search",j],queryFn:()=>_e.listMethods({page_size:Sr,...j?{q:j}:{}}),enabled:t});m.useEffect(()=>{var h;(h=u==null?void 0:u.results)!=null&&h.length&&P($=>{const L=new Map($);return u.results.forEach(T=>{const U=parseInt(T.id);Number.isNaN(U)||L.set(U,T)}),L})},[u]);const E=m.useMemo(()=>{const h=(u==null?void 0:u.results)||[],$=new Set,L=[],T=(z,Y)=>{!Y||Number.isNaN(z)||$.has(z)||(L.push(Y),$.add(z))},U=()=>p.forEach(z=>T(z,C.get(z))),H=()=>h.forEach(z=>T(parseInt(z.id),z));return j?(H(),U()):(U(),H()),L},[u,p,C,j]),F=he({mutationFn:async({paperId:h,methodIds:$})=>i==="pending"?(await fe.submit({paper_id:parseInt(h),edit_type:"methods",proposed_payload:{method_ids:$}}),null):Q.updateMethods(h,$),onSuccess:h=>{if(i==="pending"){S({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed method changes shortly."}),l==null||l(),s(!1);return}h&&ve(I,h,[a,r]),S({title:"Methods updated",description:`Saved ${p.length} method${p.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1)},onError:h=>{const $=je(h,i==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper methods.");S({title:i==="pending"?"Could not submit edit":"Could not save methods",description:$,variant:"destructive"})}}),M=()=>{i==="direct"&&n.some(h=>!p.includes(h))&&!window.confirm("Remove one or more method links from this paper?")||F.mutate({paperId:a,methodIds:p})},O=m.useMemo(()=>{if(p.length!==n.length)return!0;const h=new Set(n);return p.some($=>!h.has($))},[p,n]),K=(h,$)=>{f(L=>$?L.includes(h)?L:[...L,h]:L.filter(T=>T!==h))},G=()=>_("");return e.jsxs(ee,{open:t,onOpenChange:s,children:[e.jsxs(te,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Paper Methods"}),e.jsx(re,{children:"Select the methods and techniques used in this paper. You can select multiple methods."})]}),i==="pending"&&e.jsx(ge,{isAuthor:c}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(W,{type:"text",placeholder:"Search methods...",value:b,onChange:h=>_(h.target.value),className:"pl-9 pr-9"}),b&&e.jsx("button",{type:"button",onClick:G,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(wt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(h=>{const $=parseInt(h.id),L=p.includes($);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(Ge,{id:`method-${h.id}`,checked:L,onCheckedChange:T=>K($,T===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`method-${h.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[h.name,h.full_name&&h.full_name!==h.name&&e.jsx("span",{className:"block text-xs text-muted-foreground font-normal",children:h.full_name}),h.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[h.description.substring(0,100),h.description.length>100?"...":""]})]})]},h.id)})}):g?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ne,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),e.jsx("p",{children:"Loading methods..."})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Le,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:j?`No methods found matching "${j}"`:"No methods available"})]})}),e.jsxs(oe,{children:[e.jsx(A,{variant:"ghost",className:"sm:mr-auto",onClick:()=>x(!0),children:"Suggest a new method"}),e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:M,disabled:F.isPending||!O,children:F.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),i==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),i==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(yt,{open:o,onOpenChange:x,paperId:a,kind:"method"})]})}const $r=({open:t,onOpenChange:s,paperId:a,initialOrganizationIds:r,submitMode:n,isAuthor:d})=>{var _;const[l,i]=m.useState(r),[c,p]=m.useState(""),f=me();m.useEffect(()=>{t&&(i(r),p(""))},[r,t]);const o=de({queryKey:["organizations","curation"],queryFn:()=>_e.organizations(!1),enabled:t}),x=m.useMemo(()=>{var C,P;const j=c.trim().toLocaleLowerCase();if(!j)return((C=o.data)==null?void 0:C.results)??[];const v=I=>I===j?0:I.startsWith(j)?1:I.split(/[^\p{L}\p{N}]+/u).some(S=>S.startsWith(j))?2:3;return(((P=o.data)==null?void 0:P.results)??[]).map(I=>({organization:I,name:I.name.toLocaleLowerCase()})).filter(({name:I})=>I.includes(j)).sort((I,S)=>v(I.name)-v(S.name)).map(({organization:I})=>I)},[(_=o.data)==null?void 0:_.results,c]),b=he({mutationFn:async()=>{if(!(r.some(v=>!l.includes(v))&&!window.confirm("Remove one or more organizations from this paper? Destructive edits may require a fresh sign-in.")))return n==="pending"?(await fe.submit({paper_id:Number(a),edit_type:"organizations",proposed_payload:{organization_ids:l}}),null):Q.updateOrganizations(a,l)},onSuccess:j=>{j!==void 0&&(j&&ve(f,j,[a]),s(!1))}});return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit organizations"}),e.jsx(re,{children:"Associate existing organizations with this paper. Organization creation remains admin-only."})]}),n==="pending"&&e.jsx(ge,{isAuthor:d}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(W,{type:"search","aria-label":"Search organizations",placeholder:"Search organizations...",value:c,onChange:j=>p(j.target.value),className:"pl-9 pr-9"}),c&&e.jsx("button",{type:"button",onClick:()=>p(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear organization search",children:e.jsx(wt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"max-h-80 space-y-2 overflow-auto",children:[x.map(j=>{const v=Number(j.id);return e.jsxs("label",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx("input",{type:"checkbox",checked:l.includes(v),onChange:C=>i(P=>C.target.checked?[...P,v]:P.filter(I=>I!==v))}),j.name]},j.id)}),!o.isLoading&&x.length===0&&e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:c.trim()?`No organizations found matching "${c.trim()}"`:"No organizations available"})]}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:()=>b.mutate(),disabled:b.isPending,children:n==="pending"?"Submit test edit":"Save changes"})]})]})})};function Ir({open:t,onOpenChange:s,paperId:a,arxivId:r,initialProjectPages:n,onSuccess:d,submitMode:l="direct",isAuthor:i=!1}){const[c,p]=m.useState(n),[f,o]=m.useState(""),x=me(),{toast:b}=ie(),_=m.useRef(!1);m.useEffect(()=>{if(!t){_.current=!1;return}_.current||(_.current=!0,p(n),o(""))},[t,n]);const j=he({mutationFn:async({paperId:u,projectPages:g})=>l==="pending"?(await fe.submit({paper_id:parseInt(u),edit_type:"project_pages",proposed_payload:{project_pages:g}}),null):Q.updateProjectPages(u,g),onSuccess:u=>{if(l==="pending"){b({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed project page changes shortly."}),d==null||d(),s(!1),o("");return}u&&ve(x,u,[a,r]),d==null||d(),s(!1),o("")},onError:u=>{const g=je(u,l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update project pages.");b({title:l==="pending"?"Could not submit edit":"Could not save project pages",description:g,variant:"destructive"})}}),v=()=>{const u=f.trim();return u?c.some(g=>g.url===u)?(alert("This project page URL is already added"),null):[...c,{url:u,is_official:!1}]:c},C=()=>{const u=v();u!==null&&u.length!==c.length&&(p(u),o(""))},P=u=>{p(c.filter(g=>g.url!==u))},I=u=>{p(c.map(g=>g.url===u?{...g,is_official:!g.is_official}:g))},S=()=>{const u=v();u!==null&&(l==="direct"&&n.some(g=>!u.some(E=>E.url===g.url))&&!window.confirm("Remove one or more project pages from this paper?")||j.mutate({paperId:a,projectPages:u}))},y=m.useMemo(()=>{const u=f.trim(),g=u?[...c,{url:u,is_official:!1}]:c;if(g.length!==n.length)return!0;const E=new Map(n.map(F=>[F.url.trim(),!!F.is_official]));return g.some(F=>{const M=E.get(F.url.trim());return M===void 0||M!==!!F.is_official})},[c,f,n]);return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Paper Project Pages"}),e.jsx(re,{children:"Add or remove project page URLs (e.g. authors' demo or landing pages) associated with this paper. Mark pages as official if they are created by the paper authors."})]}),l==="pending"&&e.jsx(ge,{isAuthor:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Add Project Page URL"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(W,{type:"url",placeholder:"https://example.com/project",value:f,onChange:u=>o(u.target.value),onKeyPress:u=>{u.key==="Enter"&&(u.preventDefault(),C())},className:"flex-1"}),e.jsxs(A,{onClick:C,size:"sm",disabled:!f.trim(),children:[e.jsx(Fe,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:c.length>0?e.jsx("div",{className:"space-y-2",children:c.map((u,g)=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:u.url}),u.is_official&&e.jsx(ts,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(A,{variant:u.is_official?"default":"outline",size:"sm",onClick:()=>I(u.url),className:"h-8 px-2 text-xs",title:u.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(ss,{className:`w-3.5 h-3.5 mr-1 ${u.is_official?"fill-current":""}`}),u.is_official?"Official":"Mark official"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>P(u.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove project page",children:e.jsx(Te,{className:"w-4 h-4"})})]})]},g))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Dt,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No project pages added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a project page URL above to get started"})]})}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:S,disabled:j.isPending||!y,children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Lr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialRepositories:n,onSuccess:d,submitMode:l="direct",isAuthor:i=!1}){const[c,p]=m.useState(n),[f,o]=m.useState(""),x=me(),{toast:b}=ie(),_=m.useRef(!1);m.useEffect(()=>{if(!t){_.current=!1;return}_.current||(_.current=!0,p(n),o(""))},[t,n]);const j=he({mutationFn:async({paperId:g,repositories:E})=>l==="pending"?(await fe.submit({paper_id:parseInt(g),edit_type:"repositories",proposed_payload:{repositories:E}}),null):Q.updateRepositories(g,E),onSuccess:g=>{if(l==="pending"){b({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed repository changes shortly."}),d==null||d(),s(!1),o("");return}g&&ve(x,g,[a,r]),d==null||d(),s(!1),o("")},onError:g=>{const E=je(g,l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper repositories.");b({title:l==="pending"?"Could not submit edit":"Could not save repositories",description:E,variant:"destructive"})}}),v=g=>{const E=[];for(const F of g){const M=E.find(O=>Ft(O.url,F.url));if(M)M.is_official=M.is_official||F.is_official;else{const O=Ye(F.url);E.push({url:O??F.url.trim(),is_official:F.is_official})}}return E},C=()=>{const g=f.trim(),E=g?[...c,{url:g,is_official:!1}]:c;return g&&c.some(F=>Ft(F.url,g))?(alert("This repository URL is already added"),null):v(E)},P=()=>{const g=C();g!==null&&g.length!==c.length&&(p(g),o(""))},I=g=>{p(c.filter(E=>E.url!==g))},S=g=>{p(c.map(E=>E.url===g?{...E,is_official:!E.is_official}:E))},y=()=>{const g=C();g!==null&&(l==="direct"&&n.some(E=>!g.some(F=>F.url===E.url))&&!window.confirm("Remove one or more repositories from this paper?")||j.mutate({paperId:a,repositories:g}))},u=m.useMemo(()=>{const g=f.trim(),E=g?[...c,{url:g,is_official:!1}]:c;if(E.length!==n.length)return!0;const F=v(n),M=v(E);if(M.length!==F.length)return!0;const O=new Map(F.map(K=>[Ye(K.url)??K.url.trim(),!!K.is_official]));return M.some(K=>{const G=Ye(K.url)??K.url.trim(),h=O.get(G);return h===void 0||h!==!!K.is_official})},[c,f,n]);return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Paper Repositories"}),e.jsx(re,{children:"Add or remove GitHub repository URLs associated with this paper. Mark repositories as official if they are created by the paper authors."})]}),l==="pending"&&e.jsx(ge,{isAuthor:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Add Repository URL"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(W,{type:"url",placeholder:"https://github.com/owner/repo",value:f,onChange:g=>o(g.target.value),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),P())},className:"flex-1"}),e.jsxs(A,{onClick:P,size:"sm",disabled:!f.trim(),children:[e.jsx(Fe,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:c.length>0?e.jsx("div",{className:"space-y-2",children:c.map((g,E)=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg hover:bg-muted/50 transition-colors",children:[e.jsx(Tt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-paper-blue truncate",children:g.url}),g.is_official&&e.jsx(ts,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(A,{variant:g.is_official?"default":"outline",size:"sm",onClick:()=>S(g.url),className:"h-8 px-2 text-xs",title:g.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(ss,{className:`w-3.5 h-3.5 mr-1 ${g.is_official?"fill-current":""}`}),g.is_official?"Official":"Mark official"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>I(g.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(Te,{className:"w-4 h-4"})})]})]},E))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Tt,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No repositories added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a repository URL above to get started"})]})}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:y,disabled:j.isPending||!u,children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Rr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialUrl:n,onSuccess:d,submitMode:l="direct",isAuthor:i=!1}){const[c,p]=m.useState(n),f=me(),{toast:o}=ie(),x=m.useRef(!1);m.useEffect(()=>{if(!t){x.current=!1;return}x.current||(x.current=!0,p(n))},[t,n]);const b=he({mutationFn:async({paperId:P,sourceUrl:I})=>l==="pending"?(await fe.submit({paper_id:parseInt(P),edit_type:"source_url",proposed_payload:{source_url:I}}),null):Q.updateSourceUrl(P,I),onSuccess:P=>{if(l==="pending"){o({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed source URL change shortly."}),d==null||d(),s(!1);return}P&&ve(f,P,[a,r]),d==null||d(),s(!1)},onError:P=>{const I=je(P,l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");o({title:l==="pending"?"Could not submit edit":"Could not save source URL",description:I,variant:"destructive"})}}),_=c.trim(),j=/^https?:\/\//i.test(_),v=_!==(n||"").trim(),C=()=>{j&&b.mutate({paperId:a,sourceUrl:_})};return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Source URL"}),e.jsxs(re,{children:["Update the canonical URL for this external paper. This is the page the ",'"Source page"'," button links to. ArXiv papers cannot edit this field."]})]}),l==="pending"&&e.jsx(ge,{isAuthor:i}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Source URL"}),e.jsx(W,{type:"url",placeholder:"https://example.com/paper",value:c,onChange:P=>p(P.target.value),onKeyPress:P=>{P.key==="Enter"&&j&&v&&(P.preventDefault(),C())}}),!j&&_.length>0&&e.jsx("p",{className:"text-xs text-destructive",children:"URL must start with http:// or https://"})]}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:C,disabled:b.isPending||!j||!v,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const Ar=250,Fr=100;function Tr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialTaskIds:n,initialTasks:d,onSuccess:l,submitMode:i="direct",isAuthor:c=!1}){const[p,f]=m.useState(n),[o,x]=m.useState(!1),[b,_]=m.useState(""),[j,v]=m.useState(""),[C,P]=m.useState(new Map),I=me(),{toast:S}=ie(),y=m.useRef(!1);m.useEffect(()=>{if(!t){y.current=!1;return}if(y.current)return;y.current=!0,f(n),_(""),v("");const h=new Map;(d||[]).forEach($=>{const L=parseInt($.id);Number.isNaN(L)||h.set(L,$)}),P(h)},[t,n,d]),m.useEffect(()=>{const h=window.setTimeout(()=>{v(b.trim())},Ar);return()=>window.clearTimeout(h)},[b]);const{data:u,isFetching:g}=de({queryKey:["tasks-search",j],queryFn:()=>_e.listTasks({page_size:Fr,...j?{q:j}:{}}),enabled:t});m.useEffect(()=>{var h;(h=u==null?void 0:u.results)!=null&&h.length&&P($=>{const L=new Map($);return u.results.forEach(T=>{const U=parseInt(T.id);Number.isNaN(U)||L.set(U,T)}),L})},[u]);const E=m.useMemo(()=>{const h=(u==null?void 0:u.results)||[],$=new Set,L=[],T=(z,Y)=>{!Y||Number.isNaN(z)||$.has(z)||(L.push(Y),$.add(z))},U=()=>p.forEach(z=>T(z,C.get(z))),H=()=>h.forEach(z=>T(parseInt(z.id),z));return j?(H(),U()):(U(),H()),L},[u,p,C,j]),F=he({mutationFn:async({paperId:h,taskIds:$})=>i==="pending"?(await fe.submit({paper_id:parseInt(h),edit_type:"tasks",proposed_payload:{task_ids:$}}),null):Q.updateTasks(h,$),onMutate:async({taskIds:h})=>{if(i==="pending")return{snapshots:[]};const $=h.map(U=>C.get(U)).filter(U=>!!U).map(U=>({id:U.id,name:U.name,slug:U.slug})).sort((U,H)=>U.name.localeCompare(H.name)),L=Array.from(new Set([a,r].filter(U=>!!U)));await Promise.all(L.flatMap(U=>[I.cancelQueries({queryKey:ye.detail(U)}),I.cancelQueries({queryKey:ye.arxiv(U)})]));const T=[];return L.forEach(U=>{[ye.detail(U),ye.arxiv(U)].forEach(H=>{const z=I.getQueryData(H);T.push({key:H,data:z}),z&&I.setQueryData(H,{...z,tasks:$})})}),S({title:"Tasks updated",description:`Saved ${h.length} task${h.length===1?"":"s"} for this paper.`}),l==null||l(),s(!1),{snapshots:T}},onSuccess:h=>{if(i==="pending"){S({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed task changes shortly."}),l==null||l(),s(!1);return}h&&ve(I,h,[a,r])},onError:(h,$,L)=>{var U;(U=L==null?void 0:L.snapshots)==null||U.forEach(({key:H,data:z})=>{I.setQueryData(H,z)});const T=je(h,i==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper tasks.");S({title:i==="pending"?"Could not submit edit":"Could not save tasks",description:T,variant:"destructive"})}}),M=()=>{i==="direct"&&n.some(h=>!p.includes(h))&&!window.confirm("Remove one or more task links from this paper?")||F.mutate({paperId:a,taskIds:p})},O=m.useMemo(()=>{if(p.length!==n.length)return!0;const h=new Set(n);return p.some($=>!h.has($))},[p,n]),K=(h,$)=>{f(L=>$?L.includes(h)?L:[...L,h]:L.filter(T=>T!==h))},G=()=>_("");return e.jsxs(ee,{open:t,onOpenChange:s,children:[e.jsxs(te,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit Paper Tasks"}),e.jsx(re,{children:"Select the tasks that this paper addresses. You can select multiple tasks."})]}),i==="pending"&&e.jsx(ge,{isAuthor:c}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Le,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(W,{type:"text",placeholder:"Search tasks...",value:b,onChange:h=>_(h.target.value),className:"pl-9 pr-9"}),b&&e.jsx("button",{type:"button",onClick:G,className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(wt,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:E.length>0?e.jsx("div",{className:"space-y-2",children:E.map(h=>{const $=parseInt(h.id),L=p.includes($);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(Ge,{id:`task-${h.id}`,checked:L,onCheckedChange:T=>K($,T===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`task-${h.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[h.name,h.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[h.description.substring(0,100),h.description.length>100?"...":""]})]})]},h.id)})}):g?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ne,{className:"w-8 h-8 mx-auto mb-2 animate-spin"}),e.jsx("p",{children:"Loading tasks..."})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Le,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:j?`No tasks found matching "${j}"`:"No tasks available"})]})}),e.jsxs(oe,{children:[e.jsx(A,{variant:"ghost",className:"sm:mr-auto",onClick:()=>x(!0),children:"Suggest a new task"}),e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:M,disabled:F.isPending||!O,children:F.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),i==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),i==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(yt,{open:o,onOpenChange:x,paperId:a,kind:"task"})]})}const Mt=10,Ur=/^https?:\/\/(?:www\.|mobile\.)?(?:x|twitter)\.com\/(?:[A-Za-z0-9_]{1,15}|i\/web|i)\/status(?:es)?\/(\d{1,25})(?:[/?#].*)?$/;function Ne(t){var s;return((s=Ur.exec(t.trim()))==null?void 0:s[1])??null}function Dr({open:t,onOpenChange:s,paperId:a,arxivId:r,initialUrls:n,submitMode:d="direct",isAuthor:l=!1}){const[i,c]=m.useState(n),[p,f]=m.useState(""),[o,x]=m.useState(null),b=me(),{toast:_}=ie(),j=m.useRef(!1);m.useEffect(()=>{if(!t){j.current=!1;return}j.current||(j.current=!0,c(n),f(""),x(null))},[t,n]);const v=he({mutationFn:async u=>d==="pending"?(await fe.submit({paper_id:parseInt(a),edit_type:"x_threads",proposed_payload:{x_threads:u}}),null):Q.updateXThreads(a,u),onSuccess:u=>{d==="pending"?_({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed X threads shortly."}):u&&ve(b,u,[a,r]),s(!1)},onError:u=>{_({title:d==="pending"?"Could not submit edit":"Could not save X threads",description:je(u,d==="pending"?"Failed to submit your edit. Please try again.":"Failed to update X threads."),variant:"destructive"})}}),C=()=>{const u=p.trim();if(!u)return i;const g=Ne(u);return g?i.some(E=>Ne(E)===g)?(x("This post is already listed."),null):i.length>=Mt?(x(`A paper can link at most ${Mt} X threads.`),null):[...i,u]:(x("Paste a post URL such as https://x.com/user/status/123…"),null)},P=()=>{const u=C();u!==null&&(c(u),f(""),x(null))},I=(u,g)=>{const E=[...i];[E[u],E[u+g]]=[E[u+g],E[u]],c(E)},S=()=>{const u=C();u!==null&&(d==="direct"&&n.some(g=>!u.some(E=>Ne(E)===Ne(g)))&&!window.confirm("Remove one or more X threads from this paper?")||v.mutate(u))},y=m.useMemo(()=>(p.trim()?[...i,p.trim()]:i).map(Ne).join()!==n.map(Ne).join(),[i,p,n]);return e.jsx(ee,{open:t,onOpenChange:s,children:e.jsxs(te,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Edit X threads"}),e.jsx(re,{children:"Link posts on X (formerly Twitter) in which the authors introduce this paper. A preview of each post is shown on the paper page."})]}),d==="pending"&&e.jsx(ge,{isAuthor:l}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",htmlFor:"x-thread-url",children:"Add X post URL"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(W,{id:"x-thread-url",type:"url",placeholder:"https://x.com/user/status/1234567890",value:p,onChange:u=>{f(u.target.value),x(null)},onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),P())},"aria-invalid":!!o,className:"flex-1"}),e.jsxs(A,{onClick:P,size:"sm",disabled:!p.trim(),children:[e.jsx(Fe,{className:"w-4 h-4 mr-1"}),"Add"]})]}),o&&e.jsx("p",{className:"text-xs text-destructive",children:o})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:i.length>0?e.jsx("div",{className:"space-y-2",children:i.map((u,g)=>e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"flex-1 min-w-0 truncate text-sm font-medium",children:u}),e.jsx(A,{variant:"ghost",size:"sm",className:"h-8 px-2",disabled:g===0,onClick:()=>I(g,-1),"aria-label":"Move up",children:e.jsx(Pa,{className:"w-4 h-4"})}),e.jsx(A,{variant:"ghost",size:"sm",className:"h-8 px-2",disabled:g===i.length-1,onClick:()=>I(g,1),"aria-label":"Move down",children:e.jsx(Sa,{className:"w-4 h-4"})}),e.jsx(A,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive",onClick:()=>c(i.filter(E=>E!==u)),"aria-label":"Remove X thread",children:e.jsx(Te,{className:"w-4 h-4"})})]},u))}):e.jsx("p",{className:"text-center py-8 text-sm text-muted-foreground",children:"No X threads linked yet"})}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(A,{onClick:S,disabled:v.isPending||!y,children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"w-4 h-4 mr-2 animate-spin"}),d==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-4 h-4 mr-2"}),d==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Br({activeEditor:t,arxivId:s,editSubmitMode:a,evaluations:r,isAdmin:n,isLinkedAuthor:d,onOpenChange:l,paper:i}){if(!t)return null;const c={open:!0,paperId:i.id,arxivId:s,submitMode:a,isAuthor:d},p=o=>x=>l(o,x);return{tasks:()=>{var o;return e.jsx(Tr,{...c,onOpenChange:p("tasks"),initialTaskIds:((o=i.tasks)==null?void 0:o.map(x=>Number(x.id)))??[],initialTasks:i.tasks??[]})},methods:()=>{var o;return e.jsx(Pr,{...c,onOpenChange:p("methods"),initialMethodIds:((o=i.methods)==null?void 0:o.map(x=>Number(x.id)))??[],initialMethods:i.methods??[]})},repositories:()=>{var o;return e.jsx(Lr,{...c,onOpenChange:p("repositories"),initialRepositories:((o=i.repositories)==null?void 0:o.map(({url:x,is_official:b})=>({url:x,is_official:!!b})))??[]})},"project-pages":()=>{var o;return e.jsx(Ir,{...c,onOpenChange:p("project-pages"),initialProjectPages:((o=i.project_pages)==null?void 0:o.map(({url:x,is_official:b})=>({url:x,is_official:!!b})))??[]})},results:()=>e.jsx(vr,{...c,onOpenChange:p("results"),initialEvaluations:r,paperTasks:i.tasks??[],isAdmin:n}),"source-url":()=>e.jsx(Rr,{...c,onOpenChange:p("source-url"),initialUrl:i.source_url??i.url_abs??""}),"hf-artifacts":()=>e.jsx(yr,{...c,onOpenChange:p("hf-artifacts"),initialArtifacts:{hf_models:i.hf_models??[],hf_datasets:i.hf_datasets??[],hf_spaces:i.hf_spaces??[]}}),"x-threads":()=>{var o;return e.jsx(Dr,{...c,onOpenChange:p("x-threads"),initialUrls:((o=i.x_threads)==null?void 0:o.map(({url:x})=>x))??[]})},organizations:()=>e.jsx($r,{open:!0,paperId:i.id,onOpenChange:p("organizations"),initialOrganizationIds:(i.organizations??[]).map(({id:o})=>Number(o)),submitMode:a,isAuthor:d})}[t]()}const Hr={"add-evals":{trigger:"add evals",running:"adding evals…",complete:"add evals ✓",title:"Add evaluations with Codex",description:t=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s add-evals skill for “",t,"”. It will import only paper-native results onto existing, metric-compatible leaderboards. Accepted rows are written directly to the live database."]}),notice:"Comparator rows, unknown benchmarks, and unconfigured metrics will be skipped. Jobs run one at a time in submission order.",progress:"Codex is researching the paper and validating results against the configured leaderboards.",action:"Run add-evals",start:ya,get:wa,cancel:va},"enrich-paper":{trigger:"enrich paper",running:"enriching…",complete:"enriched ✓",title:"Enrich paper with Codex",description:t=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s enrich-paper skill for “",t,"”. It will validate official code and project links, merge high-confidence taxonomy tags, and check the paper thumbnail. Accepted changes are written directly to the live database."]}),notice:"Uncertain URLs and missing taxonomy concepts will be reported rather than guessed. Jobs run one at a time in submission order.",progress:"Codex is validating artifacts, taxonomy tags, and thumbnail quality for this paper.",action:"Run enrich-paper",start:ja,get:ba,cancel:xa}};function zr({report:t}){return e.jsx("div",{className:"min-w-0 max-h-[50vh] overflow-y-auto overflow-x-hidden rounded-md border bg-muted/40 p-4 text-sm leading-relaxed",children:e.jsx(Na,{remarkPlugins:[Ca],components:{a:({children:s,...a})=>e.jsx("a",{...a,className:"break-all underline underline-offset-2",target:"_blank",rel:"noreferrer",children:s}),p:({children:s})=>e.jsx("p",{className:"mb-3 break-words last:mb-0",children:s}),ul:({children:s})=>e.jsx("ul",{className:"mb-3 list-disc space-y-1 pl-5 last:mb-0",children:s}),ol:({children:s})=>e.jsx("ol",{className:"mb-3 list-decimal space-y-1 pl-5 last:mb-0",children:s}),h1:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),h2:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),h3:({children:s})=>e.jsx("h3",{className:"mb-2 font-semibold",children:s}),code:({children:s})=>e.jsx("code",{className:"break-all rounded bg-background/80 px-1 py-0.5 font-mono text-xs",children:s}),pre:({children:s})=>e.jsx("pre",{className:"mb-3 max-w-full overflow-x-auto whitespace-pre-wrap break-words rounded bg-background/80 p-3 font-mono text-xs last:mb-0",children:s})},children:t})})}function ps({kind:t,paperId:s,paperTitle:a,triggerClassName:r,onComplete:n}){const d=Hr[t],[l,i]=m.useState(!1),[c,p]=m.useState(null),[f,o]=m.useState(!1),[x,b]=m.useState(null),_=m.useRef(null),j=(c==null?void 0:c.status)==="queued"||(c==null?void 0:c.status)==="dispatching"||(c==null?void 0:c.status)==="running",v=c==null?void 0:c.id;m.useEffect(()=>{if(!j||!v)return;let S=!1;const y=window.setInterval(async()=>{try{const u=await d.get(v);S||(p(u),b(null))}catch(u){S||b(u instanceof Error?u.message:"Could not check job status.")}},2e3);return()=>{S=!0,window.clearInterval(y)}},[j,d,v]),m.useEffect(()=>{(c==null?void 0:c.status)!=="completed"||_.current===c.id||(_.current=c.id,n())},[c,n]);const C=async()=>{o(!0),b(null);try{p(await d.start(s))}catch(S){b(S instanceof Error?S.message:"Could not start Codex.")}finally{o(!1)}},P=()=>{p(null),b(null),_.current=null},I=async()=>{if(c){b(null);try{p(await d.cancel(c.id))}catch(S){b(S instanceof Error?S.message:"Could not cancel Codex.")}}};return e.jsxs(ee,{open:l,onOpenChange:i,children:[e.jsx("button",{type:"button",className:r,onClick:()=>i(!0),children:j?d.running:(c==null?void 0:c.status)==="completed"?d.complete:d.trigger}),e.jsxs(te,{className:"max-h-[90vh] w-[calc(100vw-2rem)] min-w-0 max-w-2xl overflow-hidden",children:[e.jsxs(se,{className:"min-w-0",children:[e.jsx(ae,{children:d.title}),e.jsx(re,{children:d.description(a)})]}),c?e.jsxs("div",{className:"min-w-0 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"font-mono text-xs uppercase tracking-wide text-muted-foreground",children:["Status: ",c.status]}),c.hf_job_url&&e.jsx("a",{className:"text-sm underline",href:c.hf_job_url,target:"_blank",rel:"noreferrer",children:"View Hugging Face Job"}),j&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 text-sm",children:[c.status==="queued"?"This job is queued and will start after the current Codex job finishes.":d.progress," ","This can take several minutes; you can close this window and return."]}),c.report&&e.jsx(zr,{report:c.report}),c.error&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:c.error})]}):e.jsx("div",{className:"rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground",children:d.notice}),x&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:x}),e.jsxs(oe,{children:[e.jsx(A,{variant:"outline",onClick:()=>i(!1),children:j?"Close":"Cancel"}),j&&e.jsx(A,{variant:"outline",onClick:()=>void I(),children:"Cancel job"}),!c&&e.jsx(A,{onClick:C,disabled:f,children:f?"Starting…":d.action}),c&&!j&&e.jsx(A,{variant:"outline",onClick:P,children:"Run again"})]})]})]})}function Mr(t){return e.jsx(ps,{...t,kind:"add-evals",triggerClassName:"edit-link"})}function Se({accent:t,id:s,label:a}){return e.jsxs("div",{className:"section-rule paper-section-anchor",id:s,children:[e.jsx("span",{children:e.jsx("a",{href:`#${s}`,className:"section-anchor-link",children:a})}),t]})}function qr({canCopyBadge:t,canEdit:s,evaluationsByTask:a,evaluationsLoading:r,isAdmin:n,onCopyBadge:d,onEdit:l,onRefresh:i,paper:c,visibleEvaluationCount:p}){return e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"results",label:"Results",accent:e.jsxs("span",{className:"accent",children:[p," benchmarks",t&&e.jsxs("button",{type:"button",className:"edit-link results-badge-copy",onClick:d,title:"Copy live leaderboard badges for your repository README",children:[e.jsx(Z,{name:"copy",size:10})," Copy PwC badge"]}),n&&_a()&&e.jsx(Mr,{paperId:Number(c.id),paperTitle:c.title,onComplete:i}),s&&e.jsx("button",{type:"button",onClick:l,className:"edit-link",children:"edit"})]})}),r?e.jsx($e,{className:"h-32 w-full"}):a.length>0?a.map(f=>e.jsxs("div",{className:f.taskSlug?"paper-section-anchor":void 0,id:f.taskSlug?rs(f.taskSlug):void 0,children:[e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:f.taskSlug?e.jsxs(e.Fragment,{children:[e.jsx(pe,{to:`/tasks/${f.taskSlug}`,children:f.taskName}),e.jsx("a",{href:Ga(f.taskSlug),className:"section-anchor-link results-task-permalink","aria-label":`Permalink to ${f.taskName} results on this paper`,title:"Link to this task's results",children:"#"})]}):f.taskName}),e.jsxs("span",{className:"accent",children:[f.rows.length," ",f.rows.length===1?"result":"results"]})]}),e.jsxs("table",{className:"results-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"28%"}}),e.jsx("col",{style:{width:"28%"}}),e.jsx("col",{style:{width:"14%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"10%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Benchmark"}),e.jsx("th",{children:"Model"}),e.jsx("th",{children:"Metric"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Rank"}),e.jsx("th",{children:"Compare"})]})}),e.jsx("tbody",{children:f.rows.map(o=>{var x;return e.jsxs("tr",{children:[e.jsx("td",{className:"benchmark",children:o.dataset_slug?e.jsx(pe,{to:`/benchmark/${o.dataset_slug}`,children:o.dataset_name||"—"}):o.dataset_name||"—"}),e.jsxs("td",{className:"model",title:o.model_name||void 0,children:[o.hf_model_url?e.jsx("a",{href:o.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"model-hf-link",title:`Open ${o.model_name||"model"} on Hugging Face`,children:o.model_name||"—"}):o.model_name||"—",o.is_open===!1&&e.jsx(sa,{}),(o.external??o.is_external)&&e.jsx(aa,{sourceUrl:o.source_url||o.external_source_url||o.result_url})]}),e.jsx("td",{className:"metric",children:o.best_metric}),e.jsx("td",{className:"value",children:Fs((x=o.metrics)==null?void 0:x[o.best_metric||""])}),e.jsx("td",{className:"rank",children:o.best_rank!=null?`#${o.best_rank}`:"—"}),e.jsx("td",{className:"compare",children:o.dataset_slug&&e.jsx(pe,{to:`/benchmark/${o.dataset_slug}?${[o.task_slug?`task=${encodeURIComponent(o.task_slug)}`:"",`eval=${encodeURIComponent(o.id)}`].filter(Boolean).join("&")}`,children:"Compare →"})})]},o.id)})})]})]},f.taskId)):e.jsx("p",{style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-faint)"},children:"No benchmark results recorded yet."})]})}var Nt="Radio",[Or,fs]=vt(Nt),[Kr,Gr]=Or(Nt),gs=m.forwardRef((t,s)=>{const{__scopeRadio:a,name:r,checked:n=!1,required:d,disabled:l,value:i="on",onCheck:c,form:p,...f}=t,[o,x]=m.useState(null),b=Ae(s,v=>x(v)),_=m.useRef(!1),j=o?p||!!o.closest("form"):!0;return e.jsxs(Kr,{scope:a,checked:n,disabled:l,children:[e.jsx(ke.button,{type:"button",role:"radio","aria-checked":n,"data-state":vs(n),"data-disabled":l?"":void 0,disabled:l,value:i,...f,ref:b,onClick:Ie(t.onClick,v=>{n||c==null||c(),j&&(_.current=v.isPropagationStopped(),_.current||v.stopPropagation())})}),j&&e.jsx(js,{control:o,bubbles:!_.current,name:r,value:i,checked:n,required:d,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});gs.displayName=Nt;var xs="RadioIndicator",bs=m.forwardRef((t,s)=>{const{__scopeRadio:a,forceMount:r,...n}=t,d=Gr(xs,a);return e.jsx(Qt,{present:r||d.checked,children:e.jsx(ke.span,{"data-state":vs(d.checked),"data-disabled":d.disabled?"":void 0,...n,ref:s})})});bs.displayName=xs;var Vr="RadioBubbleInput",js=m.forwardRef(({__scopeRadio:t,control:s,checked:a,bubbles:r=!0,...n},d)=>{const l=m.useRef(null),i=Ae(l,d),c=es(a),p=Wt(s);return m.useEffect(()=>{const f=l.current;if(!f)return;const o=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(o,"checked").set;if(c!==a&&b){const _=new Event("click",{bubbles:r});b.call(f,a),f.dispatchEvent(_)}},[c,a,r]),e.jsx(ke.input,{type:"radio","aria-hidden":!0,defaultChecked:a,...n,tabIndex:-1,ref:i,style:{...n.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});js.displayName=Vr;function vs(t){return t?"checked":"unchecked"}var Xr=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ve="RadioGroup",[Qr]=vt(Ve,[Yt,fs]),ws=Yt(),ys=fs(),[Zr,Wr]=Qr(Ve),_s=m.forwardRef((t,s)=>{const{__scopeRadioGroup:a,name:r,defaultValue:n,value:d,required:l=!1,disabled:i=!1,orientation:c,dir:p,loop:f=!0,onValueChange:o,...x}=t,b=ws(a),_=Ts(p),[j,v]=Zt({prop:d,defaultProp:n??null,onChange:o,caller:Ve});return e.jsx(Zr,{scope:a,name:r,required:l,disabled:i,value:j,onValueChange:v,children:e.jsx(Us,{asChild:!0,...b,orientation:c,dir:_,loop:f,children:e.jsx(ke.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...x,ref:s})})})});_s.displayName=Ve;var ks="RadioGroupItem",Ns=m.forwardRef((t,s)=>{const{__scopeRadioGroup:a,disabled:r,...n}=t,d=Wr(ks,a),l=d.disabled||r,i=ws(a),c=ys(a),p=m.useRef(null),f=Ae(s,p),o=d.value===n.value,x=m.useRef(!1);return m.useEffect(()=>{const b=j=>{Xr.includes(j.key)&&(x.current=!0)},_=()=>x.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),e.jsx(Ds,{asChild:!0,...i,focusable:!l,active:o,children:e.jsx(gs,{disabled:l,required:d.required,checked:o,...c,...n,name:d.name,ref:f,onCheck:()=>d.onValueChange(n.value),onKeyDown:Ie(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:Ie(n.onFocus,()=>{var b;x.current&&((b=p.current)==null||b.click())})})})});Ns.displayName=ks;var Yr="RadioGroupIndicator",Cs=m.forwardRef((t,s)=>{const{__scopeRadioGroup:a,...r}=t,n=ys(a);return e.jsx(bs,{...n,...r,ref:s})});Cs.displayName=Yr;var Es=_s,Ss=Ns,Jr=Cs;const ft=m.forwardRef(({className:t,...s},a)=>e.jsx(Es,{className:ze("grid gap-2",t),...s,ref:a}));ft.displayName=Es.displayName;const Pe=m.forwardRef(({className:t,...s},a)=>e.jsx(Ss,{ref:a,className:ze("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(Jr,{className:"flex items-center justify-center",children:e.jsx(Bs,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Pe.displayName=Ss.displayName;const en={pdf:"PDF",model:"Model",dataset:"Dataset",space:"Space",github:"GitHub"},gt=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,tn=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/,sn=20,xt="copy_to_bucket";function an(t){const s=t.trim();if(!tn.test(s))return null;const[a,r]=s.split("/");return`https://huggingface.co/buckets/${encodeURIComponent(a)}/${encodeURIComponent(r)}`}function bt(t){return`pwc:bucket-copy:${t}`}function rn(t){if(typeof window>"u"||new URL(window.location.href).searchParams.get(xt)!==t)return null;try{const a=window.sessionStorage.getItem(bt(t));if(!a)return null;const r=JSON.parse(a);return r.paperId!==t||typeof r.bucketId!="string"||!["new","existing"].includes(r.destinationMode)||!["public","private"].includes(r.visibility)||!Array.isArray(r.selectedIds)||r.selectedIds.some(n=>typeof n!="string")?null:r}catch{return null}}function nn(t,s=sn){if(s<1)throw new Error("Bucket copy batch size must be positive");const a=[];for(let r=0;r!gt.test(c)))return null;const l=d.join("/"),i=s==="model"?"":`${s}s/`;return{id:`${s}:${l}`,kind:s,label:l,url:`https://huggingface.co/${i}${l}`,source:`hf://${i}${l}/`,destination:`${s}s/${l}/`,repoId:l}}catch{return null}}function on(t){try{const s=new URL(t);if(s.hostname!=="github.com"&&s.hostname!=="www.github.com")return null;const a=s.pathname.split("/").filter(Boolean);if(a.length<2)return null;const r=a[0],n=a[1].replace(/\.git$/,"");if(!gt.test(r)||!gt.test(n))return null;const d=`${r}/${n}`;return{id:`github:${d}`,kind:"github",label:d,url:`https://github.com/${d}`,source:`https://github.com/${d}.git`,destination:`github/${d}/`}}catch{return null}}function ln({githubUrls:t,hfModelUrls:s,hfDatasetUrls:a,hfSpaceUrls:r,paperId:n,pdfName:d,pdfUrl:l}){const i=[l?{id:"pdf",kind:"pdf",label:"Paper PDF",url:l,source:l,destination:`paper/${d||n}.pdf`}:null,...s.map(p=>dt(p,"model")),...a.map(p=>dt(p,"dataset")),...r.map(p=>dt(p,"space")),...t.map(on)],c=new Set;return i.filter(p=>!p||c.has(p.id)?!1:(c.add(p.id),!0))}function cn(t,s,a){const r=["# Requires the Hugging Face CLI: https://huggingface.co/docs/huggingface_hub/guides/cli",`HF_BUCKET=${Be(t.trim())}`];a.create&&r.push(`hf buckets create "$HF_BUCKET" --exist-ok${a.isPrivate?" --private":""}`);for(const l of s.filter(i=>i.kind!=="github"&&i.kind!=="pdf"))r.push(`hf cp ${Be(l.source)} "hf://buckets/$HF_BUCKET/${l.destination}"`);const n=s.find(l=>l.kind==="pdf");n&&r.push('PWC_PDF="$(mktemp)"',`trap 'rm -f "$PWC_PDF"' EXIT`,`curl --fail --location ${Be(n.source)} --output "$PWC_PDF"`,`hf cp "$PWC_PDF" "hf://buckets/$HF_BUCKET/${n.destination}"`);const d=s.filter(l=>l.kind==="github");if(d.length){r.push('PWC_COPY_DIR="$(mktemp -d)"',`trap 'rm -rf "$PWC_COPY_DIR"' EXIT`);for(const l of d){const i=`$PWC_COPY_DIR/${l.destination.replace(/\/$/,"")}`;r.push(`git clone --depth 1 -- ${Be(l.source)} "${i}"`,`hf sync "${i}" "hf://buckets/$HF_BUCKET/${l.destination}" --exclude '.git/**'`)}}return r.join(` +`)}function dn(t){return`${(t.split(/[:|–—]/,1)[0]||t).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"")||"paper"}-artifacts`}function un(t){const{toast:s}=ie(),a=m.useMemo(()=>ln({githubUrls:t.githubUrls,hfDatasetUrls:t.hfDatasetUrls,hfModelUrls:t.hfModelUrls,hfSpaceUrls:t.hfSpaceUrls,paperId:t.paperId,pdfName:t.pdfName,pdfUrl:t.pdfUrl}),[t.githubUrls,t.hfDatasetUrls,t.hfModelUrls,t.hfSpaceUrls,t.paperId,t.pdfName,t.pdfUrl]),r=m.useMemo(()=>rn(t.paperId),[t.paperId]),[n,d]=m.useState(!!r),[l,i]=m.useState((r==null?void 0:r.destinationMode)??"new"),[c,p]=m.useState((r==null?void 0:r.bucketId)??""),[f,o]=m.useState((r==null?void 0:r.visibility)??"public"),[x,b]=m.useState(()=>new Set((r==null?void 0:r.selectedIds)??a.map(h=>h.id))),[_,j]=m.useState(!1),[v,C]=m.useState(null),[P,I]=m.useState(!!r),S=a.filter(h=>x.has(h.id)),y=S.length===a.length,u=an(c),g=u!==null,E=cn(c,S,{create:l==="new",isPrivate:f==="private"}),F=(h,$)=>{b(L=>{const T=new Set(L);return $?T.add(h):T.delete(h),T})},M=async()=>{try{await navigator.clipboard.writeText(E),s({title:"Bucket copy commands copied",description:"Run them in a terminal where the Hugging Face CLI is signed in."})}catch{s({title:"Copy failed",description:"Could not access the clipboard. Select and copy the commands manually.",variant:"destructive"})}},O=m.useCallback(()=>{const h=Hs("/api/v1/auth/hf/login"),$=new URL(window.location.href);$.searchParams.set(xt,t.paperId),window.sessionStorage.setItem(bt(t.paperId),JSON.stringify({paperId:t.paperId,bucketId:c.trim(),destinationMode:l,visibility:f,selectedIds:Array.from(x)}));const L=new URLSearchParams({return_to:$.toString(),authorize_bucket:"true"});l==="new"&&L.set("bucket_create","true"),window.location.assign(`${h}?${L.toString()}`)},[c,l,t.paperId,x,f]),K=m.useCallback(async()=>{if(!t.isSignedIn){O();return}j(!0);let h=0,$=0;try{const L=S.filter(H=>H.kind!=="pdf"&&H.kind!=="github"&&!!H.repoId).map(H=>({kind:H.kind,repo_id:H.repoId})),T=nn(L);T.length||T.push([]);for(const[H,z]of T.entries()){C({current:H+1,total:T.length});const Y=await Q.copyToBucket(t.paperId,{bucket_id:c.trim(),create:H===0&&l==="new",private:f==="private",include_pdf:H===0&&S.some(J=>J.kind==="pdf"),artifacts:z});h+=Y.copied.length,$+=Y.errors.length}const U=S.filter(H=>H.kind==="github").length;s({title:$?"Bucket copy partially completed":"Copied to bucket",description:[`${h} item${h===1?"":"s"} copied.`,$?`${$} item${$===1?"":"s"} failed.`:"",U?"Use the generated commands below to copy GitHub repositories.":""].filter(Boolean).join(" "),variant:$?"destructive":void 0,action:u?e.jsx(zs,{altText:"Open destination bucket",asChild:!0,children:e.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:"Open bucket"})}):void 0}),!$&&!U&&d(!1)}catch(L){if(L instanceof ht&&L.code==="bucket_authorization_required"){O();return}s({title:h?"Bucket copy partially completed":"Bucket copy failed",description:h?`${h} item${h===1?"":"s"} copied before the request failed. You can retry or use the CLI commands below.`:L instanceof ht&&typeof L.detail=="string"?L.detail:"Hugging Face could not complete the copy. You can still use the CLI commands below.",variant:"destructive"})}finally{j(!1),C(null)}},[O,c,u,l,t.isSignedIn,t.paperId,S,s,f]);m.useEffect(()=>{if(!P||!t.isSignedIn)return;I(!1),window.sessionStorage.removeItem(bt(t.paperId));const h=new URL(window.location.href);h.searchParams.delete(xt),window.history.replaceState({},"",`${h.pathname}${h.search}${h.hash}`),K()},[K,t.isSignedIn,t.paperId,P]);const G=()=>{b(new Set(a.map(h=>h.id))),!c&&t.suggestedBucketId&&p(t.suggestedBucketId),d(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sidebar-card copy-to-bucket-card",children:[e.jsxs("button",{type:"button",className:"copy-to-bucket-trigger",onClick:G,children:[e.jsx("span",{className:"copy-to-bucket-arrow","aria-hidden":"true",children:"→"}),e.jsx("span",{className:"copy-to-bucket-title",children:"Copy to bucket"}),e.jsx("span",{className:"copy-to-bucket-new",children:"New"})]}),e.jsx("div",{className:"copy-to-bucket-meta",children:a.length?`${a.length} linked artifact${a.length===1?"":"s"}`:"No linked artifacts yet"})]}),e.jsx(ee,{open:n,onOpenChange:d,children:e.jsxs(te,{className:"max-h-[90vh] max-w-2xl grid-rows-[auto_minmax(0,1fr)_auto] overflow-hidden",children:[e.jsxs(se,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"copy-to-bucket-dialog-arrow","aria-hidden":"true",children:"→"}),"Copy to bucket"]}),e.jsx(re,{children:"Keep your own copy of this paper's PDF, linked code, and Hugging Face artifacts. Hub repositories use Xet's server-side copy; GitHub repositories use the generated CLI fallback."})]}),e.jsx("div",{className:"-mx-6 min-h-0 overflow-y-auto px-6",children:a.length?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Choose your destination"}),e.jsxs(ft,{value:l,onValueChange:h=>i(h),className:"grid grid-cols-2 gap-2",children:[e.jsxs(le,{className:"bucket-choice",children:[e.jsx(Pe,{value:"new"}),"New bucket"]}),e.jsxs(le,{className:"bucket-choice",children:[e.jsx(Pe,{value:"existing"}),"Existing bucket"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"bucket-id",children:"Bucket name"}),e.jsx(W,{id:"bucket-id",value:c,onChange:h=>p(h.target.value),placeholder:t.suggestedBucketId||"username/paper-artifacts","aria-invalid":c.length>0&&!g}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("p",{className:"text-muted-foreground",children:"Use the full Hugging Face bucket ID: namespace/name."}),u&&e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-1 underline underline-offset-4",children:["View bucket",e.jsx(Z,{name:"external",size:10})]})]})]}),l==="new"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{children:"Bucket visibility"}),e.jsxs(ft,{value:f,onValueChange:h=>o(h),className:"flex gap-5",children:[e.jsxs(le,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Pe,{value:"public"}),"Public"]}),e.jsxs(le,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Pe,{value:"private"}),"Private"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(le,{children:"Artifacts"}),e.jsx(A,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>b(y?new Set:new Set(a.map(h=>h.id))),children:y?"Deselect all":"Select all"})]}),e.jsx("div",{className:"bucket-artifact-list",children:a.map(h=>e.jsxs("div",{className:"bucket-artifact-row",children:[e.jsx(Ge,{id:`bucket-artifact-${h.id}`,checked:x.has(h.id),onCheckedChange:$=>F(h.id,$===!0)}),e.jsxs(le,{htmlFor:`bucket-artifact-${h.id}`,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[e.jsx("span",{className:"bucket-artifact-kind",children:en[h.kind]}),e.jsx("span",{className:"bucket-artifact-name",children:h.label})]}),e.jsxs("a",{href:ce(h.url)??void 0,target:"_blank",rel:"noopener noreferrer",className:"bucket-artifact-open",children:["Open",e.jsx(Z,{name:"external",size:10})]})]},h.id))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The PDF and Hugging Face artifacts can be copied directly. GitHub repositories require the CLI workflow below."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:"bucket-copy-commands",children:"CLI fallback"}),e.jsx("pre",{id:"bucket-copy-commands",className:"bucket-copy-commands h-[190px]",children:g?E:"Enter a bucket name above to prepare the copy commands."})]})]}):e.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:"This paper does not have a linked GitHub repository or Hugging Face artifact to copy yet."})}),e.jsxs(oe,{children:[e.jsx("a",{href:"https://huggingface.co/docs/huggingface_hub/en/guides/buckets",target:"_blank",rel:"noopener noreferrer",className:"mr-auto text-sm text-muted-foreground underline underline-offset-4",children:"About Hugging Face Buckets"}),e.jsxs(A,{type:"button",onClick:M,variant:"outline",disabled:!g||S.length===0,children:[e.jsx(Z,{name:"copy",size:12}),"Copy commands"]}),e.jsx(A,{type:"button",onClick:K,disabled:_||t.isSignedIn&&(!g||!S.some(h=>h.kind!=="github")),children:_?v&&v.total>1?`Copying ${v.current}/${v.total}…`:"Copying…":t.isSignedIn?"Copy now":"Sign in & copy"})]})]})})]})}function mn({isLoading:t,papers:s}){return t?e.jsxs("div",{className:"sidebar-card","aria-busy":"true",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),e.jsx("div",{className:"related-meta",children:"Finding related work…"})]}):s!=null&&s.length?e.jsxs("div",{className:"sidebar-card",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),s.map(a=>e.jsxs(pe,{to:`/paper/${a.arxiv_id||a.id}`,target:"_blank",rel:"noopener noreferrer",className:"related-paper",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("div",{className:"related-title",children:e.jsx(He,{title:a.title})}),e.jsxs("div",{className:"related-meta",children:[e.jsx("span",{children:a.arxiv_id?`arXiv:${a.arxiv_id}`:"External resource"}),a.citation_count!=null&&e.jsxs("span",{children:[a.citation_count.toLocaleString()," cites"]})]})]},a.id))]}):null}const hn=/(https?:\/\/[^\s]+)/g;function pn({size:t=12}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:e.jsx("path",{fill:"currentColor",d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})})}function qt(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function fn(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function gn({text:t}){return e.jsx("p",{className:"x-thread-text",children:t.split(hn).map((s,a)=>a%2===1?e.jsx("span",{className:"x-thread-link",children:s.replace(/^https?:\/\/(www\.)?/,"").replace(/\/$/,"")},a):e.jsx(m.Fragment,{children:s},a))})}function xn({thread:t}){const[s,a]=m.useState(!1);return!t.author_avatar_url||s?e.jsx("span",{className:"x-thread-avatar x-thread-avatar--fallback","aria-hidden":"true",children:t.author_name.charAt(0).toUpperCase()}):e.jsx("img",{className:"x-thread-avatar",src:t.author_avatar_url,alt:"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>a(!0)})}function bn({thread:t}){const[s,a]=m.useState(!1),r=ce(t.url);return r?e.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"x-thread",children:[e.jsxs("div",{className:"x-thread-header",children:[e.jsx(xn,{thread:t}),e.jsxs("span",{className:"x-thread-author",children:[e.jsx("span",{className:"x-thread-name",children:t.author_name}),e.jsxs("span",{className:"x-thread-handle",children:["@",t.author_handle]})]}),e.jsx("span",{className:"x-thread-logo",children:e.jsx(pn,{})})]}),e.jsx(gn,{text:t.text}),t.media_url&&!s&&e.jsxs("div",{className:"x-thread-media",children:[e.jsx("img",{src:t.media_url,alt:"",loading:"lazy",referrerPolicy:"no-referrer",onError:()=>a(!0)}),t.media_type==="video"&&e.jsx("span",{className:"x-thread-play","aria-label":"Video",children:"▶"})]}),e.jsxs("div",{className:"x-thread-meta",children:[t.posted_at&&e.jsx("time",{dateTime:t.posted_at,children:fn(t.posted_at)}),t.like_count!=null&&e.jsxs("span",{children:["♥ ",qt(t.like_count)]}),t.reply_count!=null&&t.reply_count>0&&e.jsxs("span",{children:[qt(t.reply_count)," ",t.reply_count===1?"reply":"replies"]}),e.jsx("span",{className:"x-thread-read",children:"Read on X →"})]})]}):null}function jn({onEdit:t,threads:s}){return e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[e.jsx("span",{children:"X threads"}),e.jsxs("span",{className:"badge",children:[s.length," post",s.length===1?"":"s",e.jsx("button",{type:"button",onClick:t,className:"edit-link",children:"edit"})]})]}),s.length>0?e.jsx("div",{className:"x-thread-list",children:s.map(a=>e.jsx(bn,{thread:a},a.tweet_id))}):e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No author threads linked yet."})]})}const ut=3,Ot=3;function vn(t){return t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function wn({allHfArtifactUrls:t,citationCopied:s,citationDisplay:a,hfArtifactViewer:r,onCopyCitation:n,onEditHfArtifacts:d,onEditRepositories:l,onEditXThreads:i,paper:c,relatedIsLoading:p,relatedPapers:f,user:o}){var v;const[x,b]=m.useState(!1),_=[...c.repositories??[]].sort((C,P)=>Number(P.is_official)-Number(C.is_official)||(P.num_stars||0)-(C.num_stars||0)),j=(x?_:_.slice(0,ut)).map(C=>({...C,safeHref:ce(C.url)}));return e.jsxs("aside",{className:"detail-sidebar",children:[e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[e.jsx("span",{children:"GitHub"}),e.jsxs("span",{className:"badge",children:[_.length," repo",_.length===1?"":"s",e.jsx("button",{type:"button",onClick:l,className:"edit-link",children:"edit"})]})]}),j.filter(({safeHref:C})=>C).map(C=>e.jsxs("a",{href:C.safeHref??void 0,target:"_blank",rel:"noopener noreferrer",className:"code-line",style:{textDecoration:"none"},children:[e.jsxs("span",{className:"code-line-repo",children:[e.jsx(Z,{name:"github",size:12}),e.jsxs("span",{className:"code-line-repo-name",children:[C.owner,"/",C.name]}),C.is_official&&e.jsx("span",{className:"code-line-official",children:"· Official"})]}),e.jsxs("span",{className:"code-line-stars",children:["★ ",vn(C.num_stars)]})]},C.id)),_.length===0&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No GitHub repositories linked yet."}),_.length>ut&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>b(C=>!C),children:x?"− show top 3":`+ show ${_.length-ut} more repos`})]}),e.jsx(yn,{viewer:r,onEdit:d}),e.jsx(jn,{threads:c.x_threads??[],onEdit:i}),e.jsx(un,{githubUrls:_.map(({url:C})=>C),hfModelUrls:t.models,hfDatasetUrls:t.datasets,hfSpaceUrls:t.spaces,paperId:c.id,pdfName:((v=c.arxiv_id)==null?void 0:v.replace("/","-"))||c.id,pdfUrl:c.url_pdf,isSignedIn:!!o,suggestedBucketId:o?`${o.username}/${dn(c.title)}`:void 0}),e.jsx(mn,{isLoading:p,papers:f}),e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[e.jsx("span",{children:"Citation"}),e.jsxs("button",{type:"button",className:"citation-copy-btn",onClick:n,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(Z,{name:"copy",size:11}),s?"Copied":"Copy"]})]}),e.jsx("pre",{style:{fontFamily:"var(--mono)",fontSize:10.5,lineHeight:1.5,color:"var(--ink-soft)",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:a})]})]})}function yn({onEdit:t,viewer:s}){return e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[s.paperHref?e.jsx("a",{href:s.paperHref,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:"🤗 Hugging Face"}):e.jsx("span",{children:"🤗 Hugging Face"}),e.jsx("button",{type:"button",onClick:t,className:"edit-link",children:"edit"})]}),s.isLoading?e.jsx($e,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[s.rows.map(a=>e.jsx(_n,{...a},a.label)),s.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:s.footer})]})]})}function _n({count:t,href:s,isLimited:a,label:r,links:n}){const[d,l]=m.useState(!1),i=((n==null?void 0:n.length)??0)>Ot,c=d?n:n==null?void 0:n.slice(0,Ot),p=t!=null?`${t}${a?"+":""}`:"—";return e.jsxs("div",{className:"hf-artifact-row",children:[e.jsxs("div",{className:"hf-artifact-row-header",children:[e.jsx("span",{children:r}),t?e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"hf-artifact-count",children:p}):e.jsx("span",{className:"hf-artifact-count hf-artifact-count--empty",children:p})]}),c!=null&&c.length?e.jsxs("div",{className:"hf-artifact-links",children:[c.map(f=>e.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",children:f.label},f.href)),i&&e.jsx("button",{type:"button",className:"hf-artifact-toggle","aria-expanded":d,onClick:()=>l(f=>!f),children:d?"Show fewer":`View all ${n.length}`})]}):null]})}const Kt=360;function kn({canEdit:t,onEditMethods:s,onEditTasks:a,paper:r}){var p,f;const[n,d]=m.useState(!1),l=r.abstract||"",i=l.length>Kt,c=n||!i?l:`${l.slice(0,Kt)}…`;return e.jsxs(e.Fragment,{children:[r.tldr&&e.jsxs(e.Fragment,{children:[e.jsx(Se,{id:"tldr",label:"TL;DR"}),e.jsx("div",{className:"tldr-box",children:r.tldr})]}),e.jsx(Se,{id:"abstract",label:"Abstract"}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(ta,{text:c})}),i&&e.jsx("button",{type:"button",className:"read-full",onClick:()=>d(o=>!o),children:n?"− collapse abstract":"+ read full abstract"}),e.jsx(Se,{id:"tasks",label:"Tasks",accent:e.jsxs("span",{className:"accent",children:[((p=r.tasks)==null?void 0:p.length)||0," tagged",t&&e.jsx("button",{type:"button",onClick:a,className:"edit-link",children:"edit"})]})}),e.jsx("div",{className:"paper-tags",style:{marginBottom:8},children:(r.tasks??[]).map(o=>e.jsx(Ws,{slug:o.slug||"",label:o.name},o.id))}),e.jsx(Se,{id:"methods",label:"Methods",accent:e.jsxs("span",{className:"accent",children:[((f=r.methods)==null?void 0:f.length)||0," used",t&&e.jsx("button",{type:"button",onClick:s,className:"edit-link",children:"edit"})]})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:(r.methods??[]).map(o=>e.jsx(Ys,{method:o},o.id))})]})}const Ce=["my-bookmark-ids"],jt="pwc:pending-bookmark";function Nn(t){window.sessionStorage.setItem(jt,JSON.stringify(t)),window.location.assign(Ea(!0))}function Cn(){var r,n;const{user:t}=qe(),s=de({queryKey:Ce,queryFn:()=>pt.getBookmarkIds(),enabled:!!t,staleTime:60*1e3,refetchOnWindowFocus:!1}),a=Me.useMemo(()=>{var d;return new Set(((d=s.data)==null?void 0:d.paper_ids)??[])},[(r=s.data)==null?void 0:r.paper_ids]);return{ids:((n=s.data)==null?void 0:n.paper_ids)??[],idSet:a,isLoading:s.isLoading,isError:s.isError}}function En(){const{user:t}=qe(),s=me(),a=he({mutationFn:async({paperId:n,isBookmarked:d})=>{d?await pt.removeBookmark(n):await pt.addBookmark(n)},onMutate:async({paperId:n,isBookmarked:d})=>{await s.cancelQueries({queryKey:Ce});const l=s.getQueryData(Ce),i=typeof n=="string"?Number(n):n,c=(l==null?void 0:l.paper_ids)??[],p=d?c.filter(f=>f!==i):[i,...c.filter(f=>f!==i)];return s.setQueryData(Ce,{paper_ids:p}),{previous:l}},onError:(n,d,l)=>{l!=null&&l.previous&&s.setQueryData(Ce,l.previous),n instanceof ht&&n.code==="saved_papers_bucket_authorization_required"&&Nn(d)},onSettled:()=>{s.invalidateQueries({queryKey:Ce}),s.invalidateQueries({queryKey:[...ye.feeds.saved]})}});return Me.useEffect(()=>{if(!t||a.isPending)return;const n=new URL(window.location.href);if(n.searchParams.get(Ut)!=="1")return;n.searchParams.delete(Ut),window.history.replaceState({},"",`${n.pathname}${n.search}${n.hash}`);const d=window.sessionStorage.getItem(jt);if(d){window.sessionStorage.removeItem(jt);try{const l=JSON.parse(d);(typeof l.paperId=="number"||typeof l.paperId=="string")&&typeof l.isBookmarked=="boolean"&&a.mutate(l)}catch{}}},[a,t]),{toggle:Me.useCallback((n,d)=>{if(!t){if(Jt())return;const l=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=Ms(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(l)}`);return}a.mutate({paperId:n,isBookmarked:d})},[a,t]),isPending:a.isPending}}const Sn=({paperId:t})=>{const{user:s}=qe(),{idSet:a}=Cn(),{toggle:r,isPending:n}=En();if(Jt())return null;const d=Number(t),l=!!s&&a.has(d),i=()=>{Number.isFinite(d)&&r(d,l)},c=s&&l?"Saved":"Save",p=s?l?"Remove from saved papers":"Save this paper":"Sign in with Hugging Face to save this paper";return e.jsxs("button",{type:"button",className:`action-btn${l?" is-saved":""}`,onClick:i,disabled:n,"aria-pressed":l,"aria-label":p,title:p,children:[e.jsx(Z,{name:"bookmark",size:12}),c]})};function mt({children:t,showEdit:s=!1,onEdit:a,editAriaLabel:r}){return s?e.jsxs("span",{className:"action-btn-composite",children:[t,e.jsx("button",{type:"button",className:"action-btn-segment action-btn-edit",onClick:a,"aria-label":r,children:"edit"})]}):t}function Pn(t){return e.jsx(ps,{...t,kind:"enrich-paper",triggerClassName:"action-btn"})}const $n={tasks:"tasks",methods:"methods",results:"evaluation results",repositories:"GitHub repositories","project-pages":"project pages","hf-artifacts":"Hugging Face artifacts",organizations:"organizations","source-url":"source URL","x-threads":"X threads"};function Gt(t){if(!t)return"—";try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function Vt(t,s){try{const a=new URL(t),n=a.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return n?n.replace(/[-_]+/g," "):a.hostname.replace(/^www\./,"")}catch{return s}}const pi=()=>{const{arxivId:t}=qs(),s=Xt(),{toast:a}=ie(),{user:r}=qe(),n=(r==null?void 0:r.is_admin)??!1,d=!!r,l=Ia(r),{arxivId:i,evaluations:c,evaluationsByTask:p,evaluationsLoading:f,paper:o,paperError:x,paperLoading:b,presentation:_,refetchEvaluations:j,refetchPaper:v,relatedQuery:C,versions:P,visibleEvaluations:I}=Qa(t,l),[S,y]=m.useState(!1),{activeEditor:u,openEditor:g,setEditorOpen:E}=Ya();m.useEffect(()=>{l!=="direct"||!(o!=null&&o.id)||(u&&u!=="results"&&Q.primeCurationState(o.id).catch(()=>{}),u==="results"&&Oe.primeCurationState(o.id).catch(()=>{}))},[u,l,o==null?void 0:o.id]);const[F,M]=m.useState(null),O=m.useRef(!1);m.useEffect(()=>{if(!r||!o||O.current)return;const N=sessionStorage.getItem("pwc:fresh-auth-edit");if(!N)return;O.current=!0;const q=Wa(N);if(!Q.freshAuthMutationDraft()){sessionStorage.removeItem("pwc:fresh-auth-edit"),q&&g(q);return}if(!window.confirm("You signed in again. Apply the saved destructive catalog edit now? The server will recheck the current catalog version before changing anything.")){a({title:"Edit kept locally",description:"Nothing was changed. Reload this paper when you are ready to confirm the saved edit."});return}Q.resumeFreshAuthMutation().then(()=>{a({title:"Edit applied",description:"The restored catalog edit was applied."}),window.location.reload()}).catch(Rt=>{a({variant:"destructive",title:"Could not apply the saved edit",description:Rt instanceof Error?Rt.message:"Please reload and review the edit again."})})},[g,o,a,r]);const K=m.useMemo(()=>{if(!r||!(o!=null&&o.author_links))return!1;const N=r.username.toLowerCase();return o.author_links.some(q=>!!q.hf_username&&q.hf_username.toLowerCase()===N)},[r,o==null?void 0:o.author_links]),G=N=>{if(!d){M(N);return}g(N)},[h,$]=m.useState("idle"),[L,T]=m.useState(null),[U,H]=m.useState(null),z=async()=>{if(i){$("indexing"),T(null),H(null);try{await Q.indexFromArxiv(i),a({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>v(),1200),$("idle")}catch(N){const q=N;let xe=q.message||"Failed to index paper";if(q.response)try{xe=JSON.parse(q.response).detail||xe}catch{xe=q.response}T(xe),(q.status===429||q.status===503)&&H("Try again later after arXiv has lifted the temporary limit."),$("idle")}}},Y=(_==null?void 0:_.citationCopy)??"",J=(_==null?void 0:_.copyableRanks)??[],[Xe,Ue]=m.useState(!1),we=async()=>{if(Y)try{await navigator.clipboard.writeText(Y),Ue(!0),a({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>Ue(!1),1500)}catch{a({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",variant:"destructive"})}},w=async()=>{if(!o)return;const N=o.arxiv_id||o.id,q=Ra(N,J);if(q)try{await navigator.clipboard.writeText(q),a({title:"PwC badges copied",description:"Each badge follows its current leaderboard result."})}catch{a({title:"Copy failed",description:"Could not access the clipboard. Please try again.",variant:"destructive"})}};if(b)return e.jsxs("div",{className:"page",children:[e.jsx($e,{className:"h-12 w-3/4 mb-4"}),e.jsx($e,{className:"h-6 w-1/3 mb-8"}),e.jsx($e,{className:"h-64 w-full"})]});if(x||!o)return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(pe,{to:"/papers",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsxs("span",{style:{color:"var(--ink)"},children:["arXiv:",i]})]}),e.jsx("h1",{className:"detail-title",children:"Paper not indexed yet"}),e.jsxs("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",marginTop:16,maxWidth:640},children:["We don't have ",e.jsxs("span",{style:{fontFamily:"var(--mono)"},children:["arXiv:",i]})," in the database. You can index it from arXiv right now."]}),L&&e.jsx(la,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(ca,{children:[e.jsx("div",{children:L}),U&&e.jsx("div",{className:"mt-2",children:U})]})}),e.jsxs("div",{className:"action-row",children:[n&&e.jsxs("button",{className:"action-btn",onClick:z,disabled:h==="indexing",children:[e.jsx(Z,{name:"sparkle",size:12}),h==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(A,{variant:"outline",onClick:()=>s("/papers"),children:"Browse Papers"})]})]});if(!_)return null;const{allHfArtifactUrls:k,authorEntries:R,citationDisplay:D,hasIntroducedItems:X,hasLineageItems:V,hfArtifactViewer:B,introducedBenchmarks:Ps,introducedFrameworks:Ct,introducedMethods:$s,introducedSummary:Is,numPages:Et,paperSourceLabel:St,predecessorPapers:Qe,projectPages:Ee,safeAbstractUrl:Pt,safeConferenceUrl:$t,safePdfUrl:It,sourceActionLabel:Ls,successorPapers:Ze}=_,De=12,We=Fa(o,i),Lt=S||R.length<=De?R:R.slice(0,De);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(pe,{to:"/",children:"Trending"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{children:St})]}),e.jsxs("div",{className:"detail-grid",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"detail-hero",children:[e.jsxs("div",{className:"detail-hero-main",children:[e.jsxs("h1",{className:"detail-title",children:[e.jsx(He,{title:o.title}),(o.organizations||[]).map(N=>e.jsx(pe,{to:`/orgs/${N.slug}`,className:`detail-title-org${N.logo_url?" detail-title-org--logo":""}`,title:N.name,"aria-label":N.name,children:N.logo_url?e.jsx("img",{src:N.logo_url,alt:"",onError:q=>{var xe;(xe=q.currentTarget.parentElement)==null||xe.classList.remove("detail-title-org--logo"),q.currentTarget.replaceWith(N.name)}}):N.name},N.id))]}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:St}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",Gt(o.published)]}),Et&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Et," pages"]})]}),o.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[o.citation_count.toLocaleString()," citations"]})]}),(o.proceeding||o.conference_slug)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),o.conference_slug?e.jsx("a",{href:`/conferences/${o.conference_slug}`,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:(o.proceeding||o.conference_name||"").replace(/\s+\d{1,2}$/,"")}):e.jsx("span",{children:o.proceeding.replace(/\s+\d{1,2}$/,"")})]}),P.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("select",{className:"version-select",value:o.version,onChange:N=>{const q=N.target.value;o.arxiv_id&&s(`/paper/${o.arxiv_id.replace(/v\d+$/,"")}${q?`?version=${q}`:""}`)},children:P.map(N=>e.jsxs("option",{value:N.version,children:[N.version," — ",Gt(N.published)]},N.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[Lt.map((N,q)=>e.jsxs(Me.Fragment,{children:[N.id?e.jsx(pe,{to:`/authors/${N.id}`,children:N.name}):N.hf_username?e.jsx("a",{href:`https://huggingface.co/${N.hf_username}`,target:"_blank",rel:"noopener noreferrer",title:`@${N.hf_username} on Hugging Face`,children:N.name}):e.jsx("a",{children:N.name}),qDe&&e.jsx("button",{className:"show-more-authors",onClick:()=>y(N=>!N),style:{marginLeft:8,background:"none",border:"none",cursor:"pointer",color:"var(--accent-text)",fontFamily:"var(--mono)",fontSize:12},children:S?"show fewer":`+${o.authors.length-De} more`})]}),e.jsxs("div",{className:"action-row",children:[We&&Os()&&(!Ks()||r!=null&&r.is_admin)?e.jsxs(pe,{className:"action-btn",to:We,onClick:()=>{const N=We.slice(5);sessionStorage.removeItem(`pwc:reader:session:${N}`),sessionStorage.removeItem(`pwc:reader:assistant-collapsed:${N}`),sessionStorage.removeItem(`pwc:reader:page:${N}`)},children:[e.jsx(Z,{name:"pdf",size:12})," Read paper",e.jsx("span",{className:"nav-new-badge","aria-hidden":"true",children:"New"})]}):It?e.jsxs("a",{className:"action-btn",href:It,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"pdf",size:12})," View PDF"]}):null,Pt&&e.jsx(mt,{showEdit:o.source==="external",onEdit:()=>G("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:o.source==="external"?"action-btn-segment action-btn-main":"action-btn",href:Pt,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"external",size:12})," ",Ls]})}),Ee.length===1?e.jsx(mt,{showEdit:!0,onEdit:()=>G("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ee[0].safeHref??void 0,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"globe",size:12})," Project page"]})}):null,Ee.length>1?e.jsx(mt,{showEdit:!0,onEdit:()=>G("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs(Gs,{children:[e.jsx(Vs,{asChild:!0,children:e.jsxs("button",{type:"button",className:"action-btn-segment action-btn-main",children:[e.jsx(Z,{name:"globe",size:12})," Project page"]})}),e.jsx(Xs,{align:"start",className:"project-page-menu",children:Ee.map((N,q)=>e.jsx(Qs,{asChild:!0,children:N.safeHref?e.jsx("a",{href:N.safeHref,target:"_blank",rel:"noopener noreferrer",children:Vt(N.url,`Project page ${q+1}`)}):e.jsx("span",{children:Vt(N.url,`Project page ${q+1}`)})},N.url))})]})}):null,Ee.length===0&&d?e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>G("project-pages"),title:"Add project page",children:[e.jsx(Z,{name:"globe",size:12})," Add project page"]}):null,$t&&e.jsxs("a",{className:"action-btn",href:$t,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Z,{name:"external",size:12})," Conference"]}),e.jsx("button",{type:"button",className:"action-btn",onClick:()=>G("organizations"),children:"Edit organizations"}),e.jsx(cr,{paperId:Number(o.id),isAdmin:n}),n&&ka()&&e.jsx(Pn,{paperId:Number(o.id),paperTitle:o.title,onComplete:()=>void v()}),e.jsx(Sn,{paperId:o.id})]}),o.leaderboard_ranks&&o.leaderboard_ranks.length>0&&e.jsx(Js,{wrap:!0,paperHref:`/paper/${o.arxiv_id||o.id}`,ranks:o.leaderboard_ranks.filter(N=>N.best_rank>=1&&N.best_rank<=3).map(N=>({name:N.dataset_name,slug:N.dataset_slug||null,rank:N.best_rank}))})]}),e.jsx("div",{className:"detail-hero-thumb detail-thumb-wrap",children:e.jsx(ea,{paperId:o.arxiv_id||o.id,title:o.title,thumbnailUrl:Zs(o.thumbnail_url),priority:!0})})]}),X&&e.jsxs("div",{className:`introduced-banner${Ct.length>0?" introduced-banner--framework":""}`,children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[$s.map(N=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>s(`/methods/${N.slug||N.id}`),children:[N.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${N.id}`)),Ps.map(N=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>s(`/benchmark/${N.slug||N.id}`),children:[N.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${N.id}`)),Ct.map(N=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>s(`/frameworks#framework-${N.slug}`),children:[N.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`framework-${N.slug}`))]}),e.jsxs("span",{className:"introduced-note",children:["This paper is the canonical source for ",Is,"."]})]}),V&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[Ze.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Ze.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:Ze.map(N=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>s(`/paper/${N.route_identifier}`),children:[e.jsx(He,{title:N.title}),e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${N.id}`))})]}),Qe.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Qe.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:Qe.map(N=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>s(`/paper/${N.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),e.jsx(He,{title:N.title})]},`predecessor-${N.id}`))})]})]}),e.jsx(kn,{canEdit:!0,onEditMethods:()=>G("methods"),onEditTasks:()=>G("tasks"),paper:o}),e.jsx(qr,{canCopyBadge:J.length>0,canEdit:!0,evaluationsByTask:p,evaluationsLoading:f,isAdmin:n,onCopyBadge:w,onEdit:()=>G("results"),onRefresh:()=>void j(),paper:o,visibleEvaluationCount:(I==null?void 0:I.length)??0})]}),e.jsx(wn,{allHfArtifactUrls:k,citationCopied:Xe,citationDisplay:D,hfArtifactViewer:B,onCopyCitation:we,onEditHfArtifacts:()=>G("hf-artifacts"),onEditRepositories:()=>G("repositories"),onEditXThreads:()=>G("x-threads"),paper:o,relatedIsLoading:C.isLoading,relatedPapers:C.data,user:r})]}),e.jsx(Br,{activeEditor:u,arxivId:i,editSubmitMode:l,evaluations:c??[],isAdmin:n,isLinkedAuthor:K,onOpenChange:E,paper:o}),e.jsx(fa,{open:F!==null,onOpenChange:N=>{N||M(null)},sectionLabel:F?$n[F]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})};export{pi as default};