diff --git "a/assets/PaperDetailView-BFo8-uNc.js" "b/assets/PaperDetailView-BFo8-uNc.js" new file mode 100644--- /dev/null +++ "b/assets/PaperDetailView-BFo8-uNc.js" @@ -0,0 +1,29 @@ +import{c as St,h as ua,r as m,j as e,P as xs,k as Ne,l as bs,m as Me,n as De,o as js,p as Pt,C as ye,q as Ze,s as he,g as pe,X as vs,t as _e,v as ma,w as ys,x as ha,y as pa,z as fa,A as ga,B as xa,D as rs,E as ba,F as ja,G as va,H as ya,I as _a,f as tt,R as Rt,b as je,J as _s,d as ks,K as ka,M as wa,N as Na,O as ws,Q as Ca,e as Ea,S as Sa,a as Pa,T as Ra,L as be,U as Ia,V as Aa,W as $a,Y as Fa,Z as La,_ as Ta,$ as Ua}from"./index-Bdeu4ZbY.js";import{u as ne}from"./useQuery-CXrtjYNE.js";import{I as V,S as Da,a as Ma,T as Ba,M as Ha}from"./components-CodqKVbU.js";import{C as qa,E as za}from"./ExternalSourceEvalBadge-BY-8wTby.js";import{L as Ve,a as Ka}from"./LatexTitle-BLvFRaRv.js";import{c as Oa}from"./transform-DM2KXtqg.js";import{f as Ga,D as Qa}from"./latexPlainText-ChVkH0gY.js";import{a as Va}from"./usePapers-BWJQj99Y.js";import{S as Le}from"./skeleton-Bf6osK-d.js";import{A as Ja,a as Xa}from"./alert-DAtfj5Qi.js";import{B}from"./button-D8rWuzYP.js";import{u as Ns}from"./index-DOJymiM1.js";import{I as te}from"./textarea-C_-Nl7Gf.js";import{D as oe,a as le,b as ce,c as de,d as ue,e as me}from"./dialog-BYFtQ2bp.js";import{u as fe}from"./useMutation-CuQVkpZO.js";import{S as It,P as st,L as re,a as Wa}from"./SignInToEditDialog-CbILBZte.js";import{S as et,a as ns}from"./searchable-select-CGmU5Bn4.js";import{L as ie}from"./loader-circle-SQEd4A58.js";import{B as Cs,D as Ya,c as Za,g as er,s as tr,a as sr,b as ar,d as rr,i as nr,e as ir}from"./codexAddEvals-eelZXtCt.js";import{G as is}from"./github-BAh-vlAV.js";import{M as or,r as lr}from"./index-DF1MKRXL.js";import"./useBaseQuery-By7ztmuW.js";import"./hover-card-DtbRIYvY.js";import"./katex.min-BSBacQyE.js";import"./useInfiniteQuery-BArEQEIg.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 os=St("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 Es=St("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"}]]);/** + * @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 at=St("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);function cr(s){return s!=null&&s.can_directly_edit_catalog?"direct":"pending"}function dr(s){return(s??[]).filter(a=>!!(a.dataset_slug&&a.task_slug))}function ur(s,a,n="https://paperswithcode.co"){return a.map(d=>{const r=encodeURIComponent(d.evaluation_id),o=`${n}/api/v1/papers/${encodeURIComponent(s)}/leaderboard-badge.svg?eval=${r}&live=1`,l=new URLSearchParams({task:d.task_slug,eval:d.evaluation_id}),f=`${n}/benchmark/${encodeURIComponent(d.dataset_slug)}?${l.toString()}`;return`[![${`Papers with Code: ${d.best_rank===1?"SOTA":`#${d.best_rank}`} on ${d.dataset_name}`}](${o})](${f})`}).join(` +`)}function mr(s,a=!0){return ne({queryKey:["evaluations","paper",s],queryFn:()=>{if(!s)throw new Error("Paper ID is required");return ua(s)},enabled:a&&!!s,staleTime:0,refetchOnMount:"always"})}const Ss=s=>s.replace(/v\d+$/,""),hr={models:"https://huggingface.co/",datasets:"https://huggingface.co/datasets/",spaces:"https://huggingface.co/spaces/"},ft=(s,a)=>{const n=(s[a]||[]).length;return n<100?{count:n,isLimited:!1}:{count:n,isLimited:!0}},gt=(s,a)=>{const n=s[a];return Array.isArray(n)?n.map(d=>{if(typeof d=="string")return d;if(d&&typeof d=="object"){const r=d;return r.id||r.repoId||null}return null}).filter(d=>!!d).map(d=>`${hr[a]}${d}`):[]},pr=async s=>{try{return(await fetch(`https://huggingface.co/api/papers/${Ss(s)}`)).ok}catch{return!1}},fr=async s=>{const a=Ss(s),[n,d]=await Promise.all([fetch(`https://huggingface.co/api/arxiv/${a}/repos`).then(async f=>f.ok?f.json():(console.warn(`Failed to fetch repos for arXiv:${a}, status: ${f.status}`),null)).catch(f=>(console.warn(`Failed to fetch repos for arXiv:${a}:`,f),null)),pr(a)]);if(!n)return{models:0,datasets:0,spaces:0,modelUrls:[],datasetUrls:[],spaceUrls:[],isLimited:!1,paperExists:d};const r=ft(n,"models"),o=ft(n,"datasets"),l=ft(n,"spaces");return{models:r.count,datasets:o.count,spaces:l.count,modelUrls:gt(n,"models"),datasetUrls:gt(n,"datasets"),spaceUrls:gt(n,"spaces"),isLimited:r.isLimited||o.isLimited||l.isLimited,paperExists:d}},gr=s=>ne({queryKey:["huggingface-repos",s],queryFn:()=>fr(s),enabled:!!s,staleTime:10*60*1e3,retry:1});function xr(){const[s,a]=m.useState(!1),[n,d]=m.useState(!1),[r,o]=m.useState(!1),[l,f]=m.useState(!1),[u,t]=m.useState(!1),[N,j]=m.useState(!1),[E,k]=m.useState(!1),[P,h]=m.useState(!1);return{isEditingTasks:s,openTasksDialog:()=>a(!0),closeTasksDialog:()=>a(!1),setIsEditingTasks:a,isEditingMethods:n,openMethodsDialog:()=>d(!0),closeMethodsDialog:()=>d(!1),setIsEditingMethods:d,isEditingRepositories:r,openRepositoriesDialog:()=>o(!0),closeRepositoriesDialog:()=>o(!1),setIsEditingRepositories:o,isEditingProjectPages:l,openProjectPagesDialog:()=>f(!0),closeProjectPagesDialog:()=>f(!1),setIsEditingProjectPages:f,isEditingEvaluations:u,openEvaluationsDialog:()=>t(!0),closeEvaluationsDialog:()=>t(!1),setIsEditingEvaluations:t,isEditingSourceUrl:N,openSourceUrlDialog:()=>j(!0),closeSourceUrlDialog:()=>j(!1),setIsEditingSourceUrl:j,isEditingHfArtifacts:E,setIsEditingHfArtifacts:k,isEditingOrganizations:P,setIsEditingOrganizations:h}}var rt="Checkbox",[br]=Pt(rt),[jr,At]=br(rt);function vr(s){const{__scopeCheckbox:a,checked:n,children:d,defaultChecked:r,disabled:o,form:l,name:f,onCheckedChange:u,required:t,value:N="on",internal_do_not_use_render:j}=s,[E,k]=bs({prop:n,defaultProp:r??!1,onChange:u,caller:rt}),[P,h]=m.useState(null),[U,T]=m.useState(null),F=m.useRef(!1),R=P?!!l||!!P.closest("form"):!0,D={checked:E,disabled:o,setChecked:k,control:P,setControl:h,name:f,form:l,value:N,hasConsumerStoppedPropagationRef:F,required:t,defaultChecked:ve(r)?!1:r,isFormControl:R,bubbleInput:U,setBubbleInput:T};return e.jsx(jr,{scope:a,...D,children:yr(j)?j(D):d})}var Ps="CheckboxTrigger",Rs=m.forwardRef(({__scopeCheckbox:s,onKeyDown:a,onClick:n,...d},r)=>{const{control:o,value:l,disabled:f,checked:u,required:t,setControl:N,setChecked:j,hasConsumerStoppedPropagationRef:E,isFormControl:k,bubbleInput:P}=At(Ps,s),h=Me(r,N),U=m.useRef(u);return m.useEffect(()=>{const T=o==null?void 0:o.form;if(T){const F=()=>j(U.current);return T.addEventListener("reset",F),()=>T.removeEventListener("reset",F)}},[o,j]),e.jsx(Ne.button,{type:"button",role:"checkbox","aria-checked":ve(u)?"mixed":u,"aria-required":t,"data-state":Ls(u),"data-disabled":f?"":void 0,disabled:f,value:l,...d,ref:h,onKeyDown:De(a,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:De(n,T=>{j(F=>ve(F)?!0:!F),P&&k&&(E.current=T.isPropagationStopped(),E.current||T.stopPropagation())})})});Rs.displayName=Ps;var $t=m.forwardRef((s,a)=>{const{__scopeCheckbox:n,name:d,checked:r,defaultChecked:o,required:l,disabled:f,value:u,onCheckedChange:t,form:N,...j}=s;return e.jsx(vr,{__scopeCheckbox:n,checked:r,defaultChecked:o,disabled:f,required:l,onCheckedChange:t,name:d,form:N,value:u,internal_do_not_use_render:({isFormControl:E})=>e.jsxs(e.Fragment,{children:[e.jsx(Rs,{...j,ref:a,__scopeCheckbox:n}),E&&e.jsx(Fs,{__scopeCheckbox:n})]})})});$t.displayName=rt;var Is="CheckboxIndicator",As=m.forwardRef((s,a)=>{const{__scopeCheckbox:n,forceMount:d,...r}=s,o=At(Is,n);return e.jsx(xs,{present:d||ve(o.checked)||o.checked===!0,children:e.jsx(Ne.span,{"data-state":Ls(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{pointerEvents:"none",...s.style}})})});As.displayName=Is;var $s="CheckboxBubbleInput",Fs=m.forwardRef(({__scopeCheckbox:s,...a},n)=>{const{control:d,hasConsumerStoppedPropagationRef:r,checked:o,defaultChecked:l,required:f,disabled:u,name:t,value:N,form:j,bubbleInput:E,setBubbleInput:k}=At($s,s),P=Me(n,k),h=Ns(o),U=js(d);m.useEffect(()=>{const F=E;if(!F)return;const R=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(R,"checked").set,c=!r.current;if(h!==o&&y){const p=new Event("click",{bubbles:c});F.indeterminate=ve(o),y.call(F,ve(o)?!1:o),F.dispatchEvent(p)}},[E,h,o,r]);const T=m.useRef(ve(o)?!1:o);return e.jsx(Ne.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??T.current,required:f,disabled:u,name:t,value:N,form:j,...a,tabIndex:-1,ref:P,style:{...a.style,...U,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Fs.displayName=$s;function yr(s){return typeof s=="function"}function ve(s){return s==="indeterminate"}function Ls(s){return ve(s)?"indeterminate":s?"checked":"unchecked"}const nt=m.forwardRef(({className:s,style:a,...n},d)=>e.jsx($t,{ref:d,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",s),style:{border:"1px solid #000",...a},...n,children:e.jsx(As,{className:Ze("flex items-center justify-center text-current"),children:e.jsx(ye,{className:"h-4 w-4"})})}));nt.displayName=$t.displayName;function _r(s,a,n){if(!s)return s;const d=r=>r.paper_id!==a||r.paper_title===n?r:{...r,paper_title:n};if(Array.isArray(s)){const r=s.map(d);return r.some((l,f)=>l!==s[f])?r:s}if(Array.isArray(s.results)){const r=s.results.map(d);return r.some((l,f)=>l!==s.results[f])?{...s,results:r}:s}return s}function Re(s,a,n){new Set([...n,a.id,a.arxiv_id].filter(l=>!!l)).forEach(l=>{s.setQueryData(["paper",l],a),s.setQueryData(["paper-arxiv",l],a)}),s.invalidateQueries({queryKey:["papers"],refetchType:"none"}),s.invalidateQueries({queryKey:["papers-infinite"],refetchType:"none"}),s.invalidateQueries({queryKey:["task-papers-infinite"],refetchType:"none"});const r=String(a.id),o=l=>_r(l,r,a.title);s.setQueriesData({queryKey:["evaluations"]},o),s.setQueriesData({queryKey:["dataset-evals"]},o),s.invalidateQueries({queryKey:["evaluations"],refetchType:"none"}),s.invalidateQueries({queryKey:["dataset-evals"],refetchType:"none"})}function ke({isAuthor:s=!1}){const a=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:a?"Test-only: this change stays on staging.":"Your changes will be reviewed by an admin."}),e.jsx("p",{className:"mt-1 leading-snug",children:a?"This exercises staging-local pending behavior and is not queued for production review.":s?"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 we=({before:s,after:a})=>e.jsxs("details",{className:"rounded-md border bg-muted/30 p-3 text-xs",children:[e.jsx("summary",{className:"cursor-pointer font-medium",children:"Review before / after diff"}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Before"}),e.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap",children:JSON.stringify(s,null,2)})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"After"}),e.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap",children:JSON.stringify(a,null,2)})]})]})]}),kr=250,wr=100;function Nr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialTaskIds:r,initialTasks:o,onSuccess:l,submitMode:f="direct",isAuthor:u=!1}){const[t,N]=m.useState(r),[j,E]=m.useState(!1),[k,P]=m.useState(""),[h,U]=m.useState(""),[T,F]=m.useState(new Map),R=he(),{toast:D}=pe(),y=m.useRef(!1);m.useEffect(()=>{if(!s){y.current=!1;return}if(y.current)return;y.current=!0,N(r),P(""),U("");const x=new Map;(o||[]).forEach(A=>{const L=parseInt(A.id);Number.isNaN(L)||x.set(L,A)}),F(x)},[s,r,o]),m.useEffect(()=>{const x=window.setTimeout(()=>{U(k.trim())},kr);return()=>window.clearTimeout(x)},[k]);const{data:c,isFetching:p}=ne({queryKey:["tasks-search",h],queryFn:()=>ys({page_size:wr,...h?{q:h}:{}}),enabled:s});m.useEffect(()=>{var x;(x=c==null?void 0:c.results)!=null&&x.length&&F(A=>{const L=new Map(A);return c.results.forEach(M=>{const S=parseInt(M.id);Number.isNaN(S)||L.set(S,M)}),L})},[c]);const w=m.useMemo(()=>{const x=(c==null?void 0:c.results)||[],A=new Set,L=[];return t.forEach(M=>{if(A.has(M))return;const S=T.get(M);S&&(L.push(S),A.add(M))}),x.forEach(M=>{const S=parseInt(M.id);Number.isNaN(S)||A.has(S)||(L.push(M),A.add(S))}),L},[c,t,T]),$=fe({mutationFn:async({paperId:x,taskIds:A})=>f==="pending"?(await _e({paper_id:parseInt(x),edit_type:"tasks",proposed_payload:{task_ids:A}}),null):ma(x,A),onMutate:async({taskIds:x})=>{if(f==="pending")return{snapshots:[]};const A=x.map(S=>T.get(S)).filter(S=>!!S).map(S=>({id:S.id,name:S.name,slug:S.slug})).sort((S,Y)=>S.name.localeCompare(Y.name)),L=Array.from(new Set([n,d].filter(S=>!!S)));await Promise.all(L.flatMap(S=>[R.cancelQueries({queryKey:["paper",S]}),R.cancelQueries({queryKey:["paper-arxiv",S]})]));const M=[];return L.forEach(S=>{["paper","paper-arxiv"].forEach(Y=>{const W=[Y,S],g=R.getQueryData(W);M.push({key:W,data:g}),g&&R.setQueryData(W,{...g,tasks:A})})}),D({title:"Tasks updated",description:`Saved ${x.length} task${x.length===1?"":"s"} for this paper.`}),l==null||l(),a(!1),{snapshots:M}},onSuccess:x=>{if(f==="pending"){D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed task changes shortly."}),l==null||l(),a(!1);return}x&&Re(R,x,[n,d])},onError:(x,A,L)=>{var Y,W;(Y=L==null?void 0:L.snapshots)==null||Y.forEach(({key:g,data:C})=>{R.setQueryData(g,C)});const M=x;let S=M.message||(f==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper tasks.");if(M.response)try{const g=JSON.parse(M.response);typeof(g==null?void 0:g.detail)=="string"?S=g.detail:Array.isArray(g==null?void 0:g.detail)&&((W=g.detail[0])!=null&&W.msg)&&(S=g.detail[0].msg)}catch{S=M.response}D({title:f==="pending"?"Could not submit edit":"Could not save tasks",description:S,variant:"destructive"})}}),q=()=>{f==="direct"&&r.some(x=>!t.includes(x))&&!window.confirm("Remove one or more task links from this paper?")||$.mutate({paperId:n,taskIds:t})},K=m.useMemo(()=>{if(t.length!==r.length)return!0;const x=new Set(r);return t.some(A=>!x.has(A))},[t,r]),G=(x,A)=>{N(L=>A?L.includes(x)?L:[...L,x]:L.filter(M=>M!==x))},X=()=>P("");return e.jsxs(oe,{open:s,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Tasks"}),e.jsx(ue,{children:"Select the tasks that this paper addresses. You can select multiple tasks."})]}),f==="pending"&&e.jsx(ke,{isAuthor:u}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(et,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(te,{type:"text",placeholder:"Search tasks...",value:k,onChange:x=>P(x.target.value),className:"pl-9 pr-9"}),k&&e.jsx("button",{type:"button",onClick:X,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(vs,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:w.length>0?e.jsx("div",{className:"space-y-2",children:w.map(x=>{const A=parseInt(x.id),L=t.includes(A);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(nt,{id:`task-${x.id}`,checked:L,onCheckedChange:M=>G(A,M===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`task-${x.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[x.name,x.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[x.description.substring(0,100),x.description.length>100?"...":""]})]})]},x.id)})}):p?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ie,{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(et,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:h?`No tasks found matching "${h}"`:"No tasks available"})]})}),e.jsx(we,{before:r,after:t}),e.jsxs(me,{children:[e.jsx(B,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new task"}),e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:q,disabled:$.isPending||!K,children:$.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),f==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),f==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(It,{open:j,onOpenChange:E,paperId:n,kind:"task"})]})}const Cr=250,Er=100;function Sr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialMethodIds:r,initialMethods:o,onSuccess:l,submitMode:f="direct",isAuthor:u=!1}){const[t,N]=m.useState(r),[j,E]=m.useState(!1),[k,P]=m.useState(""),[h,U]=m.useState(""),[T,F]=m.useState(new Map),R=he(),{toast:D}=pe(),y=m.useRef(!1);m.useEffect(()=>{if(!s){y.current=!1;return}if(y.current)return;y.current=!0,N(r),P(""),U("");const x=new Map;(o||[]).forEach(A=>{const L=parseInt(A.id);Number.isNaN(L)||x.set(L,A)}),F(x)},[s,r,o]),m.useEffect(()=>{const x=window.setTimeout(()=>{U(k.trim())},Cr);return()=>window.clearTimeout(x)},[k]);const{data:c,isFetching:p}=ne({queryKey:["methods-search",h],queryFn:()=>pa({page_size:Er,...h?{q:h}:{}}),enabled:s});m.useEffect(()=>{var x;(x=c==null?void 0:c.results)!=null&&x.length&&F(A=>{const L=new Map(A);return c.results.forEach(M=>{const S=parseInt(M.id);Number.isNaN(S)||L.set(S,M)}),L})},[c]);const w=m.useMemo(()=>{const x=(c==null?void 0:c.results)||[],A=new Set,L=[];return t.forEach(M=>{if(A.has(M))return;const S=T.get(M);S&&(L.push(S),A.add(M))}),x.forEach(M=>{const S=parseInt(M.id);Number.isNaN(S)||A.has(S)||(L.push(M),A.add(S))}),L},[c,t,T]),$=fe({mutationFn:async({paperId:x,methodIds:A})=>f==="pending"?(await _e({paper_id:parseInt(x),edit_type:"methods",proposed_payload:{method_ids:A}}),null):ha(x,A),onSuccess:x=>{if(f==="pending"){D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed method changes shortly."}),l==null||l(),a(!1);return}x&&Re(R,x,[n,d]),D({title:"Methods updated",description:`Saved ${t.length} method${t.length===1?"":"s"} for this paper.`}),l==null||l(),a(!1)},onError:x=>{var M;const A=x;let L=A.message||(f==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper methods.");if(A.response)try{const S=JSON.parse(A.response);typeof(S==null?void 0:S.detail)=="string"?L=S.detail:Array.isArray(S==null?void 0:S.detail)&&((M=S.detail[0])!=null&&M.msg)&&(L=S.detail[0].msg)}catch{L=A.response}D({title:f==="pending"?"Could not submit edit":"Could not save methods",description:L,variant:"destructive"})}}),q=()=>{f==="direct"&&r.some(x=>!t.includes(x))&&!window.confirm("Remove one or more method links from this paper?")||$.mutate({paperId:n,methodIds:t})},K=m.useMemo(()=>{if(t.length!==r.length)return!0;const x=new Set(r);return t.some(A=>!x.has(A))},[t,r]),G=(x,A)=>{N(L=>A?L.includes(x)?L:[...L,x]:L.filter(M=>M!==x))},X=()=>P("");return e.jsxs(oe,{open:s,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Methods"}),e.jsx(ue,{children:"Select the methods and techniques used in this paper. You can select multiple methods."})]}),f==="pending"&&e.jsx(ke,{isAuthor:u}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(et,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(te,{type:"text",placeholder:"Search methods...",value:k,onChange:x=>P(x.target.value),className:"pl-9 pr-9"}),k&&e.jsx("button",{type:"button",onClick:X,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(vs,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[400px]",children:w.length>0?e.jsx("div",{className:"space-y-2",children:w.map(x=>{const A=parseInt(x.id),L=t.includes(A);return e.jsxs("div",{className:"flex items-center space-x-2 p-2 hover:bg-muted/50 rounded-md",children:[e.jsx(nt,{id:`method-${x.id}`,checked:L,onCheckedChange:M=>G(A,M===!0),className:"!border !border-black data-[state=checked]:!bg-black data-[state=checked]:!text-white"}),e.jsxs("label",{htmlFor:`method-${x.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer flex-1",children:[x.name,x.full_name&&x.full_name!==x.name&&e.jsx("span",{className:"block text-xs text-muted-foreground font-normal",children:x.full_name}),x.description&&e.jsxs("span",{className:"block text-xs text-muted-foreground font-normal mt-1",children:[x.description.substring(0,100),x.description.length>100?"...":""]})]})]},x.id)})}):p?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ie,{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(et,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:h?`No methods found matching "${h}"`:"No methods available"})]})}),e.jsx(we,{before:r,after:t}),e.jsxs(me,{children:[e.jsx(B,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new method"}),e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:q,disabled:$.isPending||!K,children:$.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),f==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),f==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(It,{open:j,onOpenChange:E,paperId:n,kind:"method"})]})}function Ue(s){const a=s.trim();if(!a)return null;let n=a;!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`https://${n}`);try{const d=new URL(n);if(d.hostname.toLowerCase()!=="github.com")return null;const r=d.pathname.split("/").filter(Boolean);if(r.length<2)return null;const o=r[0].toLowerCase();let l=r[1].toLowerCase();return l.endsWith(".git")&&(l=l.slice(0,-4)),`https://github.com/${o}/${l}`}catch{return null}}function ls(s,a){const n=Ue(s),d=Ue(a);return n&&d?n===d:s.trim()===a.trim()}function Pr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialRepositories:r,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[u,t]=m.useState(r),[N,j]=m.useState(""),E=he(),{toast:k}=pe(),P=m.useRef(!1);m.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(r),j(""))},[s,r]);const h=fe({mutationFn:async({paperId:p,repositories:w})=>l==="pending"?(await _e({paper_id:parseInt(p),edit_type:"repositories",proposed_payload:{repositories:w}}),null):fa(p,w),onSuccess:p=>{if(l==="pending"){k({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed repository changes shortly."}),o==null||o(),a(!1),j("");return}p&&Re(E,p,[n,d]),o==null||o(),a(!1),j("")},onError:p=>{var q;const w=p;let $=w.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update paper repositories.");if(w.response)try{const K=JSON.parse(w.response);typeof(K==null?void 0:K.detail)=="string"?$=K.detail:Array.isArray(K==null?void 0:K.detail)&&((q=K.detail[0])!=null&&q.msg)&&($=K.detail[0].msg)}catch{$=w.response}k({title:l==="pending"?"Could not submit edit":"Could not save repositories",description:$,variant:"destructive"})}}),U=p=>{const w=[];for(const $ of p){const q=w.find(K=>ls(K.url,$.url));if(q)q.is_official=q.is_official||$.is_official;else{const K=Ue($.url);w.push({url:K??$.url.trim(),is_official:$.is_official})}}return w},T=()=>{const p=N.trim(),w=p?[...u,{url:p,is_official:!1}]:u;return p&&u.some($=>ls($.url,p))?(alert("This repository URL is already added"),null):U(w)},F=()=>{const p=T();p!==null&&p.length!==u.length&&(t(p),j(""))},R=p=>{t(u.filter(w=>w.url!==p))},D=p=>{t(u.map(w=>w.url===p?{...w,is_official:!w.is_official}:w))},y=()=>{const p=T();p!==null&&(l==="direct"&&r.some(w=>!p.some($=>$.url===w.url))&&!window.confirm("Remove one or more repositories from this paper?")||h.mutate({paperId:n,repositories:p}))},c=m.useMemo(()=>{const p=N.trim(),w=p?[...u,{url:p,is_official:!1}]:u;if(w.length!==r.length)return!0;const $=U(r),q=U(w);if(q.length!==$.length)return!0;const K=new Map($.map(G=>[Ue(G.url)??G.url.trim(),!!G.is_official]));return q.some(G=>{const X=Ue(G.url)??G.url.trim(),x=K.get(X);return x===void 0||x!==!!G.is_official})},[u,N,r]);return e.jsx(oe,{open:s,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Repositories"}),e.jsx(ue,{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(ke,{isAuthor:f}),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(te,{type:"url",placeholder:"https://github.com/owner/repo",value:N,onChange:p=>j(p.target.value),onKeyPress:p=>{p.key==="Enter"&&(p.preventDefault(),F())},className:"flex-1"}),e.jsxs(B,{onClick:F,size:"sm",disabled:!N.trim(),children:[e.jsx(st,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:u.length>0?e.jsx("div",{className:"space-y-2",children:u.map((p,w)=>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(is,{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:p.url}),p.is_official&&e.jsx(Cs,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(B,{variant:p.is_official?"default":"outline",size:"sm",onClick:()=>D(p.url),className:"h-8 px-2 text-xs",title:p.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Es,{className:`w-3.5 h-3.5 mr-1 ${p.is_official?"fill-current":""}`}),p.is_official?"Official":"Mark official"]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>R(p.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(at,{className:"w-4 h-4"})})]})]},w))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(is,{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.jsx(we,{before:r,after:u}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:y,disabled:h.isPending||!c,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Rr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialProjectPages:r,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[u,t]=m.useState(r),[N,j]=m.useState(""),E=he(),{toast:k}=pe(),P=m.useRef(!1);m.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(r),j(""))},[s,r]);const h=fe({mutationFn:async({paperId:c,projectPages:p})=>l==="pending"?(await _e({paper_id:parseInt(c),edit_type:"project_pages",proposed_payload:{project_pages:p}}),null):ga(c,p),onSuccess:c=>{if(l==="pending"){k({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed project page changes shortly."}),o==null||o(),a(!1),j("");return}c&&Re(E,c,[n,d]),o==null||o(),a(!1),j("")},onError:c=>{var $;const p=c;let w=p.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update project pages.");if(p.response)try{const q=JSON.parse(p.response);typeof(q==null?void 0:q.detail)=="string"?w=q.detail:Array.isArray(q==null?void 0:q.detail)&&(($=q.detail[0])!=null&&$.msg)&&(w=q.detail[0].msg)}catch{w=p.response}k({title:l==="pending"?"Could not submit edit":"Could not save project pages",description:w,variant:"destructive"})}}),U=()=>{const c=N.trim();return c?u.some(p=>p.url===c)?(alert("This project page URL is already added"),null):[...u,{url:c,is_official:!1}]:u},T=()=>{const c=U();c!==null&&c.length!==u.length&&(t(c),j(""))},F=c=>{t(u.filter(p=>p.url!==c))},R=c=>{t(u.map(p=>p.url===c?{...p,is_official:!p.is_official}:p))},D=()=>{const c=U();c!==null&&(l==="direct"&&r.some(p=>!c.some(w=>w.url===p.url))&&!window.confirm("Remove one or more project pages from this paper?")||h.mutate({paperId:n,projectPages:c}))},y=m.useMemo(()=>{const c=N.trim(),p=c?[...u,{url:c,is_official:!1}]:u;if(p.length!==r.length)return!0;const w=new Map(r.map($=>[$.url.trim(),!!$.is_official]));return p.some($=>{const q=w.get($.url.trim());return q===void 0||q!==!!$.is_official})},[u,N,r]);return e.jsx(oe,{open:s,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[600px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Paper Project Pages"}),e.jsx(ue,{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(ke,{isAuthor:f}),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(te,{type:"url",placeholder:"https://example.com/project",value:N,onChange:c=>j(c.target.value),onKeyPress:c=>{c.key==="Enter"&&(c.preventDefault(),T())},className:"flex-1"}),e.jsxs(B,{onClick:T,size:"sm",disabled:!N.trim(),children:[e.jsx(st,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:u.length>0?e.jsx("div",{className:"space-y-2",children:u.map((c,p)=>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(os,{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:c.url}),c.is_official&&e.jsx(Cs,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(B,{variant:c.is_official?"default":"outline",size:"sm",onClick:()=>R(c.url),className:"h-8 px-2 text-xs",title:c.is_official?"Click to unmark as official (created by paper authors)":"Click to mark as official (created by paper authors)",children:[e.jsx(Es,{className:`w-3.5 h-3.5 mr-1 ${c.is_official?"fill-current":""}`}),c.is_official?"Official":"Mark official"]}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>F(c.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove project page",children:e.jsx(at,{className:"w-4 h-4"})})]})]},p))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(os,{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.jsx(we,{before:r,after:u}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:D,disabled:h.isPending||!y,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}function Ir({open:s,onOpenChange:a,paperId:n,arxivId:d,initialUrl:r,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[u,t]=m.useState(r),N=he(),{toast:j}=pe(),E=m.useRef(!1);m.useEffect(()=>{if(!s){E.current=!1;return}E.current||(E.current=!0,t(r))},[s,r]);const k=fe({mutationFn:async({paperId:F,sourceUrl:R})=>l==="pending"?(await _e({paper_id:parseInt(F),edit_type:"source_url",proposed_payload:{source_url:R}}),null):xa(F,R),onSuccess:F=>{if(l==="pending"){j({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed source URL change shortly."}),o==null||o(),a(!1);return}F&&Re(N,F,[n,d]),o==null||o(),a(!1)},onError:F=>{var y;const R=F;let D=R.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");if(R.response)try{const c=JSON.parse(R.response);typeof(c==null?void 0:c.detail)=="string"?D=c.detail:Array.isArray(c==null?void 0:c.detail)&&((y=c.detail[0])!=null&&y.msg)&&(D=c.detail[0].msg)}catch{D=R.response}j({title:l==="pending"?"Could not submit edit":"Could not save source URL",description:D,variant:"destructive"})}}),P=u.trim(),h=/^https?:\/\//i.test(P),U=P!==(r||"").trim(),T=()=>{h&&k.mutate({paperId:n,sourceUrl:P})};return e.jsx(oe,{open:s,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Source URL"}),e.jsxs(ue,{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(ke,{isAuthor:f}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Source URL"}),e.jsx(te,{type:"url",placeholder:"https://example.com/paper",value:u,onChange:F=>t(F.target.value),onKeyPress:F=>{F.key==="Enter"&&h&&U&&(F.preventDefault(),T())}}),!h&&P.length>0&&e.jsx("p",{className:"text-xs text-destructive",children:"URL must start with http:// or https://"})]}),e.jsx(we,{before:r,after:u}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:T,disabled:k.isPending||!h||!U,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const xt=100;function Ar(s){return(s??[]).some(a=>a.slug==="coding-agents"||a.name.trim().toLowerCase()==="coding agents")}function cs(s){const a=parseInt(s.task_id,10),n=parseInt(s.dataset_id,10);return!(!Number.isFinite(a)||!Number.isFinite(n)||!s.metric_name.trim()||!s.metric_value.trim())}function $r(s){return s.map(a=>{const n=a.best_metric||Object.keys(a.metrics)[0],d=a.metrics[n];return{id:a.id,task_id:a.task_id,dataset_id:a.dataset_id,model_name:a.model_name||"",harness:a.harness||"",metric_name:n||"",metric_value:String(d||""),best_rank:a.best_rank?String(a.best_rank):"",num_parameters:a.num_parameters!=null?String(a.num_parameters):"",hf_model_url:a.hf_model_url||"",is_open:a.is_open!==!1,operation:"unchanged"}})}function Fr(s){const a=new Map;return s.forEach(n=>{n.task_id&&n.task_name&&a.set(n.task_id,{id:n.task_id,name:n.task_name,slug:n.task_slug,level:0})}),a}function Lr(s){const a=new Map;return s.forEach(n=>{n.dataset_id&&n.dataset_name&&a.set(n.dataset_id,{id:n.dataset_id,name:n.dataset_name,slug:n.dataset_slug})}),a}function ds(s,a){return`${s}:${a}`}function Je(s){const a=s.trim();if(a==="")return null;const n=Number(a);return!Number.isFinite(n)||n<0?null:Math.trunc(n)}function Xe(s){const a=s.trim();return a===""?null:a}function Tr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialEvaluations:r,paperTasks:o,onSuccess:l,submitMode:f="direct",isAdmin:u=!1,isAuthor:t=!1}){const N=Ar(o),[j,E]=m.useState([]),[k,P]=m.useState(null),[h,U]=m.useState(new Map),[T,F]=m.useState(new Map),R=he(),{toast:D}=pe(),y=m.useRef(!1),c=m.useRef(!1);m.useEffect(()=>{if(!s){y.current=!1,c.current=!1;return}y.current||c.current||r.length!==0&&(y.current=!0,E($r(r)),U(Fr(r)),F(Lr(r)))},[s,r]);const p=m.useMemo(()=>Array.from(new Set(j.map(g=>g.task_id).filter(g=>g&&g!==""))),[j]),w=m.useMemo(()=>{const g=new Set;return j.forEach(C=>{C.task_id&&C.dataset_id&&g.add(ds(C.task_id,C.dataset_id))}),Array.from(g)},[j]),$=ne({queryKey:["datasets-by-tasks-for-eval-edit",p,s],queryFn:async()=>{const g={};return await Promise.all(p.map(async C=>{try{const I=await rs({task_id:parseInt(C),page_size:xt});g[C]=I.results}catch(I){console.error(`Error fetching datasets for task ${C}:`,I),g[C]=[]}})),g},enabled:s&&p.length>0});m.useEffect(()=>{$.data&&F(g=>{const C=new Map(g);return Object.values($.data).forEach(I=>{I.forEach(b=>{C.set(b.id,b)})}),C})},[$.data]);const q=ne({queryKey:["leaderboard-metrics-for-eval-edit",w,s],queryFn:async()=>{const g={};return await Promise.all(w.map(async C=>{const[I,b]=C.split(":");try{g[C]=await ja(b,I)}catch(_){console.error(`Error fetching metrics for leaderboard ${C}:`,_),g[C]=[]}})),g},enabled:s&&w.length>0}),K=async g=>{const C=await ys({page_size:xt,...g?{q:g}:{}});return U(I=>{const b=new Map(I);return C.results.forEach(_=>b.set(_.id,_)),b}),C.results.map(I=>{var b;return{value:I.id,label:I.name,description:(b=I.description)==null?void 0:b.slice(0,100)}})},G=g=>async C=>{const I=await rs({task_id:parseInt(g),page_size:xt,...C?{q:C}:{}});return F(b=>{const _=new Map(b);return I.results.forEach(O=>_.set(O.id,O)),_}),I.results.map(b=>({value:b.id,label:b.name,description:b.full_name}))},X=(g,C)=>{if(!g||!C)return!1;const I=T.get(C);return!!(I!=null&&I.supports_harness)},x=(g,C,I)=>{var O;if(!g||!C)return[];const _=(((O=q.data)==null?void 0:O[ds(g,C)])||[]).map(H=>({value:H.metric_name,label:H.metric_name,description:H.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return I&&!_.some(H=>H.value===I)&&_.unshift({value:I,label:`${I} (legacy)`,description:void 0}),_},A=fe({mutationFn:async({paperId:g,evaluations:C})=>{if(f==="pending"){const b=[];for(const _ of C){if(_.operation==="delete"&&_.id){b.push({op:"delete",evaluation_id:parseInt(_.id)});continue}const O=X(_.task_id,_.dataset_id);if(_.operation==="create"){if(!cs(_))continue;const H=Je(_.num_parameters),Z={task_id:parseInt(_.task_id),dataset_id:parseInt(_.dataset_id),metrics:{[_.metric_name]:_.metric_value},best_metric:_.metric_name},Ce=Xe(_.hf_model_url);_.model_name&&(Z.model_name=_.model_name),O&&_.harness&&(Z.harness=_.harness),_.best_rank&&(Z.best_rank=parseInt(_.best_rank)),H!=null&&(Z.num_parameters=H),Ce!=null&&(Z.hf_model_url=Ce),Z.is_open=_.is_open,b.push({op:"create",data:Z})}else if(_.operation==="update"&&_.id){const H={task_id:parseInt(_.task_id),dataset_id:parseInt(_.dataset_id),model_name:_.model_name||void 0,harness:O&&_.harness||null,metrics:{[_.metric_name]:_.metric_value},best_metric:_.metric_name,best_rank:_.best_rank?parseInt(_.best_rank):void 0,num_parameters:Je(_.num_parameters),hf_model_url:Xe(_.hf_model_url),is_open:_.is_open};b.push({op:"update",evaluation_id:parseInt(_.id),data:H})}}return b.length===0?{submitted:!1}:(await _e({paper_id:parseInt(g),edit_type:"evaluations",proposed_payload:{operations:b}}),{submitted:!0})}const I=[];for(const b of C)if(b.operation==="delete"&&b.id)I.push({operation:"delete",evaluation_id:parseInt(b.id)});else if(b.operation==="create"){if(!cs(b))continue;const _=X(b.task_id,b.dataset_id),O=Je(b.num_parameters);I.push({operation:"create",payload:{paper_id:parseInt(g),task_id:parseInt(b.task_id),dataset_id:parseInt(b.dataset_id),model_name:b.model_name||void 0,harness:_&&b.harness||void 0,metrics:{[b.metric_name]:b.metric_value},best_metric:b.metric_name,best_rank:b.best_rank?parseInt(b.best_rank):void 0,num_parameters:O??void 0,hf_model_url:Xe(b.hf_model_url)??void 0,is_open:b.is_open}})}else if(b.operation==="update"&&b.id){const _=X(b.task_id,b.dataset_id);I.push({operation:"update",evaluation_id:parseInt(b.id),payload:{task_id:parseInt(b.task_id),dataset_id:parseInt(b.dataset_id),model_name:b.model_name||void 0,harness:_&&b.harness||null,metrics:{[b.metric_name]:b.metric_value},best_metric:b.metric_name,best_rank:b.best_rank?parseInt(b.best_rank):void 0,num_parameters:Je(b.num_parameters),hf_model_url:Xe(b.hf_model_url),is_open:b.is_open,harness_set:!0,num_parameters_set:!0,hf_model_url_set:!0}})}if(!u&&I.length>50)throw new Error("Contributor evaluation batches are limited to 50 operations; contact an admin.");return I.length>0&&await ba(parseInt(g),I),{submitted:I.length>0}},onSuccess:g=>{if(f==="pending"){g!=null&&g.submitted?D({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed evaluation changes shortly."}):D({title:"No changes to submit",description:"Your evaluation list matches the existing data."}),l==null||l(),a(!1);return}R.invalidateQueries({queryKey:["paper-arxiv",d]}),R.invalidateQueries({queryKey:["evaluations","paper",n]}),l==null||l(),a(!1)},onError:g=>{var b;const C=g;let I=C.message||(f==="pending"?"Failed to submit your edit. Please try again.":"Failed to update evaluations.");if(C.response)try{const _=JSON.parse(C.response);typeof(_==null?void 0:_.detail)=="string"?I=_.detail:Array.isArray(_==null?void 0:_.detail)&&((b=_.detail[0])!=null&&b.msg)&&(I=_.detail[0].msg)}catch{I=C.response}D({title:f==="pending"?"Could not submit edit":"Could not save evaluations",description:I,variant:"destructive"})}}),L=()=>{c.current=!0,E([...j,{task_id:"",dataset_id:"",model_name:"",harness:"",metric_name:"",metric_value:"",best_rank:"",num_parameters:"",hf_model_url:"",is_open:!0,operation:"create"}])},M=g=>{if(c.current=!0,j[g].id){if(!window.confirm("Delete this evaluation? You will be asked to sign in again if your session is older than 15 minutes."))return;E(j.map((I,b)=>b===g?{...I,operation:"delete"}:I))}else E(j.filter((I,b)=>b!==g))},S=(g,C,I)=>{c.current=!0,E(j.map((b,_)=>{if(_!==g)return b;const O={...b,[C]:I};return C==="task_id"&&(O.dataset_id="",O.metric_name="",O.harness=""),C==="dataset_id"&&(O.metric_name="",I&&!X(O.task_id,I)&&(O.harness="")),b.operation==="unchanged"&&(O.operation="update"),O}))},Y=(g,C)=>{c.current=!0,E(j.map((I,b)=>{if(b!==g)return I;const _={...I,is_open:C};return I.operation==="unchanged"&&(_.operation="update"),_}))},W=()=>{const g=j.filter(C=>C.operation!=="delete"||C.id);A.mutate({paperId:n,evaluations:g})};return e.jsxs(oe,{open:s,onOpenChange:a,children:[e.jsxs(le,{className:"max-w-6xl max-h-[800px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Evaluation Results"}),e.jsx(ue,{children:"Add, edit, or remove evaluation results for this paper. Each row represents a benchmark result."})]}),f==="pending"&&e.jsx(ke,{isAuthor:t}),e.jsxs("div",{className:"py-4 overflow-y-auto max-h-[600px]",children:[j.filter(g=>g.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 ${N?"min-w-[140px]":"min-w-[240px]"}`,children:"Model"}),N&&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:j.map((g,C)=>{if(g.operation==="delete")return null;const I=h.get(g.task_id),b=T.get(g.dataset_id),_=x(g.task_id,g.dataset_id,g.metric_name),O=!!(g.task_id&&g.dataset_id)&&q.isFetching;return e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("td",{className:"py-2 px-2",children:e.jsx(ns,{value:g.task_id,onChange:H=>S(C,"task_id",H),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:I?{value:I.id,label:I.name}:null,queryKey:["eval-edit-task-search"],queryFn:K,enabled:s})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(ns,{value:g.dataset_id,onChange:H=>S(C,"dataset_id",H),placeholder:g.task_id?"Select dataset":"Select task first",searchPlaceholder:"Search datasets...",emptyMessage:g.task_id?"No datasets found for this task.":"Select a task first.",disabled:!g.task_id,selectedOption:b?{value:b.id,label:b.name}:null,queryKey:["eval-edit-dataset-search",g.task_id],queryFn:G(g.task_id),enabled:s&&!!g.task_id})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(te,{type:"text",className:"w-full text-sm",placeholder:"Model name",value:g.model_name,onChange:H=>S(C,"model_name",H.target.value)})}),N&&e.jsx("td",{className:"py-2 px-2",children:X(g.task_id,g.dataset_id)?e.jsx(te,{type:"text",className:"w-full text-sm",placeholder:"Claude Code, Terminus, ...",value:g.harness,onChange:H=>S(C,"harness",H.target.value)}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not supported"})}),e.jsx("td",{className:"py-2 px-2",children:!g.task_id||!g.dataset_id?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Select task + dataset"}):O?e.jsxs("span",{className:"inline-flex items-center text-xs text-muted-foreground",children:[e.jsx(ie,{className:"mr-1 h-3 w-3 animate-spin"}),"Loading metrics..."]}):_.length>0?e.jsxs("select",{className:"w-full rounded-md border border-border bg-background px-2 py-1 text-sm",value:g.metric_name,onChange:H=>S(C,"metric_name",H.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),_.map(H=>e.jsx("option",{value:H.value,children:H.label},H.value))]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No configured metrics"})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(te,{type:"text",className:"w-full text-sm",placeholder:"44.9",value:g.metric_value,onChange:H=>S(C,"metric_value",H.target.value)})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(te,{type:"number",min:0,step:1,className:"w-full text-sm",placeholder:"e.g. 7000000000",value:g.num_parameters,onChange:H=>S(C,"num_parameters",H.target.value),title:"Raw model parameter count (e.g. 7000000000 for a 7B model). Leave blank if unknown."})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(te,{type:"url",className:"w-full text-sm",placeholder:"https://huggingface.co/org/model",value:g.hf_model_url,onChange:H=>S(C,"hf_model_url",H.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:g.is_open,onChange:H=>Y(C,H.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(B,{variant:"ghost",size:"sm",onClick:()=>M(C),className:"h-8 w-8 p-0 text-destructive hover:text-destructive",title:"Delete row",children:e.jsx(at,{className:"w-4 h-4"})})})]},C)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ya,{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(B,{variant:"outline",size:"sm",onClick:L,className:"flex items-center space-x-2",children:[e.jsx(st,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsx(we,{before:r,after:j}),e.jsxs(me,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 sm:mr-auto",children:[e.jsx(B,{variant:"ghost",onClick:()=>P("benchmark"),children:"Suggest a new benchmark"}),e.jsx(B,{variant:"ghost",onClick:()=>P("metric"),children:"Suggest a new metric"})]}),e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:W,disabled:A.isPending,children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),f==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),f==="pending"?"Submit for review":"Save Changes"]})})]})]}),e.jsx(It,{open:k!==null,onOpenChange:g=>{g||P(null)},paperId:n,kind:k??"benchmark"})]})}const bt=[{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 us(s){return s.map(a=>a.trim()).filter(Boolean)}function jt(s,a){const n=us(s).sort(),d=us(a).sort();return n.length!==d.length?!1:n.every((r,o)=>r===d[o])}function Ur(s,a){return jt(s.hf_models,a.hf_models)&&jt(s.hf_datasets,a.hf_datasets)&&jt(s.hf_spaces,a.hf_spaces)}function Dr({open:s,onOpenChange:a,paperId:n,arxivId:d,initialArtifacts:r,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[u,t]=m.useState(r),[N,j]=m.useState({hf_models:"",hf_datasets:"",hf_spaces:""}),E=he(),{toast:k}=pe(),P=m.useRef(!1);m.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(r),j({hf_models:"",hf_datasets:"",hf_spaces:""}))},[s,r]);const h=fe({mutationFn:async({paperId:y,artifacts:c})=>l==="pending"?(await _e({paper_id:parseInt(y),edit_type:"hf_artifacts",proposed_payload:c}),null):va(y,c),onSuccess:y=>{if(l==="pending"){k({title:"Edit submitted for review",description:"Thanks! An admin will review your proposed Hugging Face artifact changes shortly."}),o==null||o(),a(!1),j({hf_models:"",hf_datasets:"",hf_spaces:""});return}y&&Re(E,y,[n,d]),o==null||o(),a(!1),j({hf_models:"",hf_datasets:"",hf_spaces:""})},onError:y=>{var w;const c=y;let p=c.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update Hugging Face artifacts.");if(c.response)try{const $=JSON.parse(c.response);typeof($==null?void 0:$.detail)=="string"?p=$.detail:Array.isArray($==null?void 0:$.detail)&&((w=$.detail[0])!=null&&w.msg)&&(p=$.detail[0].msg)}catch{p=c.response}k({title:l==="pending"?"Could not submit edit":"Could not save Hugging Face artifacts",description:p,variant:"destructive"})}}),U=()=>{const y={hf_models:[...u.hf_models],hf_datasets:[...u.hf_datasets],hf_spaces:[...u.hf_spaces]};for(const{key:c}of bt){const p=N[c].trim();if(p){if(y[c].some(w=>w.trim()===p))return alert(`This ${c.replace("hf_","")} URL is already added`),null;y[c]=[...y[c],p]}}return y},T=y=>{const c=N[y].trim();if(c){if(u[y].some(p=>p.trim()===c)){alert(`This ${y.replace("hf_","")} URL is already added`);return}t(p=>({...p,[y]:[...p[y],c]})),j(p=>({...p,[y]:""}))}},F=(y,c)=>{t(p=>({...p,[y]:p[y].filter(w=>w!==c)}))},R=()=>{const y=U();if(y===null)return;const c=Object.keys(r).some(p=>r[p].some(w=>!y[p].includes(w)));l==="direct"&&c&&!window.confirm("Remove one or more Hugging Face artifact links?")||h.mutate({paperId:n,artifacts:y})},D=m.useMemo(()=>{const y={hf_models:[...u.hf_models],hf_datasets:[...u.hf_datasets],hf_spaces:[...u.hf_spaces]};for(const{key:c}of bt){const p=N[c].trim();if(p){if(y[c].some(w=>w.trim()===p))return!1;y[c]=[...y[c],p]}}return!Ur(y,r)},[u,N,r]);return e.jsx(oe,{open:s,onOpenChange:a,children:e.jsxs(le,{className:"max-w-2xl max-h-[700px]",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit Hugging Face Artifacts"}),e.jsx(ue,{children:"Add or remove linked Hugging Face models, datasets, and Spaces for this paper."})]}),l==="pending"&&e.jsx(ke,{isAuthor:f}),e.jsx("div",{className:"space-y-6 py-2 overflow-y-auto max-h-[460px]",children:bt.map(({key:y,label:c,placeholder:p})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:c}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(te,{type:"url",placeholder:p,value:N[y],onChange:w=>j($=>({...$,[y]:w.target.value})),onKeyPress:w=>{w.key==="Enter"&&(w.preventDefault(),T(y))},className:"flex-1"}),e.jsxs(B,{onClick:()=>T(y),size:"sm",disabled:!N[y].trim(),children:[e.jsx(st,{className:"w-4 h-4 mr-1"}),"Add"]})]}),u[y].length>0?e.jsx("div",{className:"space-y-2",children:u[y].map(w=>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:w}),e.jsx(B,{variant:"ghost",size:"sm",onClick:()=>F(y,w),className:"h-8 px-2 text-destructive hover:text-destructive",title:`Remove ${c.toLowerCase()} URL`,children:e.jsx(at,{className:"w-4 h-4"})})]},w))}):e.jsxs("div",{className:"text-xs text-muted-foreground",children:["No ",c.toLowerCase()," linked yet."]})]},y))}),e.jsx(we,{before:r,after:u}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:R,disabled:h.isPending||!D,children:h.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4 mr-2 animate-spin"}),l==="pending"?"Submitting...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),l==="pending"?"Submit for review":"Save Changes"]})})]})]})})}const Mr=({open:s,onOpenChange:a,paperId:n,initialOrganizationIds:d,submitMode:r,isAuthor:o})=>{var j;const[l,f]=m.useState(d),u=he();m.useEffect(()=>{s&&f(d)},[d,s]);const t=ne({queryKey:["organizations","curation"],queryFn:()=>_a(!1),enabled:s}),N=fe({mutationFn:async()=>{d.some(k=>!l.includes(k))&&!window.confirm("Remove one or more organizations from this paper? Destructive edits may require a fresh sign-in.")||(r==="pending"?await _e({paper_id:Number(n),edit_type:"organizations",proposed_payload:{organization_ids:l}}):await ya(n,l))},onSuccess:()=>{u.invalidateQueries({queryKey:["paper-arxiv"]}),a(!1)}});return e.jsx(oe,{open:s,onOpenChange:a,children:e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Edit organizations"}),e.jsx(ue,{children:"Associate existing organizations with this paper. Organization creation remains admin-only."})]}),r==="pending"&&e.jsx(ke,{isAuthor:o}),e.jsx("div",{className:"max-h-80 space-y-2 overflow-auto",children:(j=t.data)==null?void 0:j.results.map(E=>{const k=Number(E.id);return e.jsxs("label",{className:"flex items-center gap-2 rounded border p-2",children:[e.jsx("input",{type:"checkbox",checked:l.includes(k),onChange:P=>f(h=>P.target.checked?[...h,k]:h.filter(U=>U!==k))}),E.name]},E.id)})}),e.jsx(we,{before:d,after:l}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(B,{onClick:()=>N.mutate(),disabled:N.isPending,children:r==="pending"?"Submit test edit":"Save changes"})]})]})})},Pe=["my-bookmark-ids"];function Br(){var d,r;const{user:s}=tt(),a=ne({queryKey:Pe,queryFn:()=>je.getMyBookmarkIds(),enabled:!!s,staleTime:60*1e3,refetchOnWindowFocus:!1}),n=Rt.useMemo(()=>{var o;return new Set(((o=a.data)==null?void 0:o.paper_ids)??[])},[(d=a.data)==null?void 0:d.paper_ids]);return{ids:((r=a.data)==null?void 0:r.paper_ids)??[],idSet:n,isLoading:a.isLoading,isError:a.isError}}function Hr(){const{user:s}=tt(),a=he(),n=fe({mutationFn:async({paperId:r,isBookmarked:o})=>{o?await je.removeBookmark(r):await je.addBookmark(r)},onMutate:async({paperId:r,isBookmarked:o})=>{await a.cancelQueries({queryKey:Pe});const l=a.getQueryData(Pe),f=typeof r=="string"?Number(r):r,u=(l==null?void 0:l.paper_ids)??[],t=o?u.filter(N=>N!==f):[f,...u.filter(N=>N!==f)];return a.setQueryData(Pe,{paper_ids:t}),{previous:l}},onError:(r,o,l)=>{l!=null&&l.previous&&a.setQueryData(Pe,l.previous)},onSettled:()=>{a.invalidateQueries({queryKey:Pe}),a.invalidateQueries({queryKey:["my-bookmarks"]})}});return{toggle:Rt.useCallback((r,o)=>{if(!s){if(_s())return;const l=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=ks(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(l)}`);return}n.mutate({paperId:r,isBookmarked:o})},[n,s]),isPending:n.isPending}}const qr=({paperId:s})=>{const{user:a}=tt(),{idSet:n}=Br(),{toggle:d,isPending:r}=Hr();if(_s())return null;const o=Number(s),l=!!a&&n.has(o),f=()=>{Number.isFinite(o)&&d(o,l)},u=a&&l?"Saved":"Save",t=a?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:f,disabled:r,"aria-pressed":l,"aria-label":t,title:t,children:[e.jsx(V,{name:"bookmark",size:12}),u]})};function We({children:s,showEdit:a=!1,onEdit:n,editAriaLabel:d}){return a?e.jsxs("span",{className:"action-btn-composite",children:[s,e.jsx("button",{type:"button",className:"action-btn-segment action-btn-edit",onClick:n,"aria-label":d,children:"edit"})]}):s}const zr={"add-evals":{trigger:"add evals",running:"adding evals…",complete:"add evals ✓",title:"Add evaluations with Codex",description:s=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s add-evals skill for “",s,"”. 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:rr,get:ar,cancel:sr},"enrich-paper":{trigger:"enrich paper",running:"enriching…",complete:"enriched ✓",title:"Enrich paper with Codex",description:s=>e.jsxs(e.Fragment,{children:["Codex will run the repository’s enrich-paper skill for “",s,"”. 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:tr,get:er,cancel:Za}};function Kr({report:s}){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(or,{remarkPlugins:[lr],components:{a:({children:a,...n})=>e.jsx("a",{...n,className:"break-all underline underline-offset-2",target:"_blank",rel:"noreferrer",children:a}),p:({children:a})=>e.jsx("p",{className:"mb-3 break-words last:mb-0",children:a}),ul:({children:a})=>e.jsx("ul",{className:"mb-3 list-disc space-y-1 pl-5 last:mb-0",children:a}),ol:({children:a})=>e.jsx("ol",{className:"mb-3 list-decimal space-y-1 pl-5 last:mb-0",children:a}),h1:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),h2:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),h3:({children:a})=>e.jsx("h3",{className:"mb-2 font-semibold",children:a}),code:({children:a})=>e.jsx("code",{className:"break-all rounded bg-background/80 px-1 py-0.5 font-mono text-xs",children:a}),pre:({children:a})=>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:a})},children:s})})}function Ts({kind:s,paperId:a,paperTitle:n,triggerClassName:d,onComplete:r}){const o=zr[s],[l,f]=m.useState(!1),[u,t]=m.useState(null),[N,j]=m.useState(!1),[E,k]=m.useState(null),P=m.useRef(null),h=(u==null?void 0:u.status)==="queued"||(u==null?void 0:u.status)==="dispatching"||(u==null?void 0:u.status)==="running",U=u==null?void 0:u.id;m.useEffect(()=>{if(!h||!U)return;let D=!1;const y=window.setInterval(async()=>{try{const c=await o.get(U);D||(t(c),k(null))}catch(c){D||k(c instanceof Error?c.message:"Could not check job status.")}},2e3);return()=>{D=!0,window.clearInterval(y)}},[h,o,U]),m.useEffect(()=>{(u==null?void 0:u.status)!=="completed"||P.current===u.id||(P.current=u.id,r())},[u,r]);const T=async()=>{j(!0),k(null);try{t(await o.start(a))}catch(D){k(D instanceof Error?D.message:"Could not start Codex.")}finally{j(!1)}},F=()=>{t(null),k(null),P.current=null},R=async()=>{if(u){k(null);try{t(await o.cancel(u.id))}catch(D){k(D instanceof Error?D.message:"Could not cancel Codex.")}}};return e.jsxs(oe,{open:l,onOpenChange:f,children:[e.jsx("button",{type:"button",className:d,onClick:()=>f(!0),children:h?o.running:(u==null?void 0:u.status)==="completed"?o.complete:o.trigger}),e.jsxs(le,{className:"max-h-[90vh] w-[calc(100vw-2rem)] min-w-0 max-w-2xl overflow-hidden",children:[e.jsxs(ce,{className:"min-w-0",children:[e.jsx(de,{children:o.title}),e.jsx(ue,{children:o.description(n)})]}),u?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: ",u.status]}),u.hf_job_url&&e.jsx("a",{className:"text-sm underline",href:u.hf_job_url,target:"_blank",rel:"noreferrer",children:"View Hugging Face Job"}),h&&e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3 text-sm",children:[u.status==="queued"?"This job is queued and will start after the current Codex job finishes.":o.progress," ","This can take several minutes; you can close this window and return."]}),u.report&&e.jsx(Kr,{report:u.report}),u.error&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:u.error})]}):e.jsx("div",{className:"rounded-md border bg-muted/40 p-3 text-sm text-muted-foreground",children:o.notice}),E&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:E}),e.jsxs(me,{children:[e.jsx(B,{variant:"outline",onClick:()=>f(!1),children:h?"Close":"Cancel"}),h&&e.jsx(B,{variant:"outline",onClick:()=>void R(),children:"Cancel job"}),!u&&e.jsx(B,{onClick:T,disabled:N,children:N?"Starting…":o.action}),u&&!h&&e.jsx(B,{variant:"outline",onClick:F,children:"Run again"})]})]})]})}function Or(s){return e.jsx(Ts,{...s,kind:"add-evals",triggerClassName:"edit-link"})}function Gr(s){return e.jsx(Ts,{...s,kind:"enrich-paper",triggerClassName:"action-btn"})}var Ft="Radio",[Qr,Us]=Pt(Ft),[Vr,Jr]=Qr(Ft),Ds=m.forwardRef((s,a)=>{const{__scopeRadio:n,name:d,checked:r=!1,required:o,disabled:l,value:f="on",onCheck:u,form:t,...N}=s,[j,E]=m.useState(null),k=Me(a,U=>E(U)),P=m.useRef(!1),h=j?t||!!j.closest("form"):!0;return e.jsxs(Vr,{scope:n,checked:r,disabled:l,children:[e.jsx(Ne.button,{type:"button",role:"radio","aria-checked":r,"data-state":qs(r),"data-disabled":l?"":void 0,disabled:l,value:f,...N,ref:k,onClick:De(s.onClick,U=>{r||u==null||u(),h&&(P.current=U.isPropagationStopped(),P.current||U.stopPropagation())})}),h&&e.jsx(Hs,{control:j,bubbles:!P.current,name:d,value:f,checked:r,required:o,disabled:l,form:t,style:{transform:"translateX(-100%)"}})]})});Ds.displayName=Ft;var Ms="RadioIndicator",Bs=m.forwardRef((s,a)=>{const{__scopeRadio:n,forceMount:d,...r}=s,o=Jr(Ms,n);return e.jsx(xs,{present:d||o.checked,children:e.jsx(Ne.span,{"data-state":qs(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:a})})});Bs.displayName=Ms;var Xr="RadioBubbleInput",Hs=m.forwardRef(({__scopeRadio:s,control:a,checked:n,bubbles:d=!0,...r},o)=>{const l=m.useRef(null),f=Me(l,o),u=Ns(n),t=js(a);return m.useEffect(()=>{const N=l.current;if(!N)return;const j=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(j,"checked").set;if(u!==n&&k){const P=new Event("click",{bubbles:d});k.call(N,n),N.dispatchEvent(P)}},[u,n,d]),e.jsx(Ne.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:f,style:{...r.style,...t,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Hs.displayName=Xr;function qs(s){return s?"checked":"unchecked"}var Wr=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],it="RadioGroup",[Yr]=Pt(it,[ws,Us]),zs=ws(),Ks=Us(),[Zr,en]=Yr(it),Os=m.forwardRef((s,a)=>{const{__scopeRadioGroup:n,name:d,defaultValue:r,value:o,required:l=!1,disabled:f=!1,orientation:u,dir:t,loop:N=!0,onValueChange:j,...E}=s,k=zs(n),P=ka(t),[h,U]=bs({prop:o,defaultProp:r??null,onChange:j,caller:it});return e.jsx(Zr,{scope:n,name:d,required:l,disabled:f,value:h,onValueChange:U,children:e.jsx(wa,{asChild:!0,...k,orientation:u,dir:P,loop:N,children:e.jsx(Ne.div,{role:"radiogroup","aria-required":l,"aria-orientation":u,"data-disabled":f?"":void 0,dir:P,...E,ref:a})})})});Os.displayName=it;var Gs="RadioGroupItem",Qs=m.forwardRef((s,a)=>{const{__scopeRadioGroup:n,disabled:d,...r}=s,o=en(Gs,n),l=o.disabled||d,f=zs(n),u=Ks(n),t=m.useRef(null),N=Me(a,t),j=o.value===r.value,E=m.useRef(!1);return m.useEffect(()=>{const k=h=>{Wr.includes(h.key)&&(E.current=!0)},P=()=>E.current=!1;return document.addEventListener("keydown",k),document.addEventListener("keyup",P),()=>{document.removeEventListener("keydown",k),document.removeEventListener("keyup",P)}},[]),e.jsx(Na,{asChild:!0,...f,focusable:!l,active:j,children:e.jsx(Ds,{disabled:l,required:o.required,checked:j,...u,...r,name:o.name,ref:N,onCheck:()=>o.onValueChange(r.value),onKeyDown:De(k=>{k.key==="Enter"&&k.preventDefault()}),onFocus:De(r.onFocus,()=>{var k;E.current&&((k=t.current)==null||k.click())})})})});Qs.displayName=Gs;var tn="RadioGroupIndicator",Vs=m.forwardRef((s,a)=>{const{__scopeRadioGroup:n,...d}=s,r=Ks(n);return e.jsx(Bs,{...r,...d,ref:a})});Vs.displayName=tn;var Js=Os,Xs=Qs,sn=Vs;const Ct=m.forwardRef(({className:s,...a},n)=>e.jsx(Js,{className:Ze("grid gap-2",s),...a,ref:n}));Ct.displayName=Js.displayName;const Te=m.forwardRef(({className:s,...a},n)=>e.jsx(Xs,{ref:n,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",s),...a,children:e.jsx(sn,{className:"flex items-center justify-center",children:e.jsx(Ca,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Te.displayName=Xs.displayName;const an={model:"Model",dataset:"Dataset",space:"Space",github:"GitHub"},Et=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function vt(s){return"'"+s.replace(/'/g,`'"'"'`)+"'"}function yt(s,a){try{const n=new URL(s);if(n.hostname!=="huggingface.co")return null;const d=n.pathname.split("/").filter(Boolean),r=a==="model"?[]:[`${a}s`];if(r.length&&d[0]!==r[0])return null;const o=d.slice(r.length,r.length+2);if(o.length!==2||o.some(u=>!Et.test(u)))return null;const l=o.join("/"),f=a==="model"?"":`${a}s/`;return{id:`${a}:${l}`,kind:a,label:l,url:`https://huggingface.co/${f}${l}`,source:`hf://${f}${l}/`,destination:`${a}s/${l}/`}}catch{return null}}function rn(s){try{const a=new URL(s);if(a.hostname!=="github.com"&&a.hostname!=="www.github.com")return null;const n=a.pathname.split("/").filter(Boolean);if(n.length<2)return null;const d=n[0],r=n[1].replace(/\.git$/,"");if(!Et.test(d)||!Et.test(r))return null;const o=`${d}/${r}`;return{id:`github:${o}`,kind:"github",label:o,url:`https://github.com/${o}`,source:`https://github.com/${o}.git`,destination:`github/${o}/`}}catch{return null}}function nn({githubUrls:s,hfModelUrls:a,hfDatasetUrls:n,hfSpaceUrls:d}){const r=[...a.map(l=>yt(l,"model")),...n.map(l=>yt(l,"dataset")),...d.map(l=>yt(l,"space")),...s.map(rn)],o=new Set;return r.filter(l=>!l||o.has(l.id)?!1:(o.add(l.id),!0))}function on(s,a,n){const d=["# Requires the Hugging Face CLI: https://huggingface.co/docs/huggingface_hub/guides/cli",`HF_BUCKET=${vt(s.trim())}`];n.create&&d.push(`hf buckets create "$HF_BUCKET" --exist-ok${n.isPrivate?" --private":""}`);for(const o of a.filter(l=>l.kind!=="github"))d.push(`hf cp ${vt(o.source)} "hf://buckets/$HF_BUCKET/${o.destination}"`);const r=a.filter(o=>o.kind==="github");if(r.length){d.push('PWC_COPY_DIR="$(mktemp -d)"',`trap 'rm -rf "$PWC_COPY_DIR"' EXIT`);for(const o of r){const l=`$PWC_COPY_DIR/${o.destination.replace(/\/$/,"")}`;d.push(`git clone --depth 1 -- ${vt(o.source)} "${l}"`,`hf sync "${l}" "hf://buckets/$HF_BUCKET/${o.destination}" --exclude '.git/**'`)}}return d.join(` +`)}function ln(s){return`${(s.split(/[:|–—]/,1)[0]||s).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"")||"paper"}-artifacts`}function cn(s){const{toast:a}=pe(),n=m.useMemo(()=>nn(s),[s.githubUrls,s.hfDatasetUrls,s.hfModelUrls,s.hfSpaceUrls]),[d,r]=m.useState(!1),[o,l]=m.useState("new"),[f,u]=m.useState(""),[t,N]=m.useState("public"),[j,E]=m.useState(()=>new Set(n.map(R=>R.id))),k=n.filter(R=>j.has(R.id)),P=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/.test(f.trim()),h=on(f,k,{create:o==="new",isPrivate:t==="private"}),U=(R,D)=>{E(y=>{const c=new Set(y);return D?c.add(R):c.delete(R),c})},T=async()=>{try{await navigator.clipboard.writeText(h),a({title:"Bucket copy commands copied",description:"Run them in a terminal where the Hugging Face CLI is signed in."})}catch{a({title:"Copy failed",description:"Could not access the clipboard. Select and copy the commands manually.",variant:"destructive"})}},F=()=>{E(new Set(n.map(R=>R.id))),!f&&s.suggestedBucketId&&u(s.suggestedBucketId),r(!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:F,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:n.length?`${n.length} linked artifact${n.length===1?"":"s"}`:"No linked artifacts yet"})]}),e.jsx(oe,{open:d,onOpenChange:r,children:e.jsxs(le,{className:"max-h-[90vh] max-w-2xl overflow-y-auto",children:[e.jsxs(ce,{children:[e.jsxs(de,{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(ue,{children:"Keep your own copy of this paper's linked code and Hugging Face artifacts. Hub repositories use Xet's server-side copy; GitHub repositories are cloned into the same destination."})]}),n.length?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{children:"Choose your destination"}),e.jsxs(Ct,{value:o,onValueChange:R=>l(R),className:"grid grid-cols-2 gap-2",children:[e.jsxs(re,{className:"bucket-choice",children:[e.jsx(Te,{value:"new"}),"New bucket"]}),e.jsxs(re,{className:"bucket-choice",children:[e.jsx(Te,{value:"existing"}),"Existing bucket"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"bucket-id",children:"Bucket name"}),e.jsx(te,{id:"bucket-id",value:f,onChange:R=>u(R.target.value),placeholder:s.suggestedBucketId||"username/paper-artifacts","aria-invalid":f.length>0&&!P}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use the full Hugging Face bucket ID: namespace/name."})]}),o==="new"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{children:"Bucket visibility"}),e.jsxs(Ct,{value:t,onValueChange:R=>N(R),className:"flex gap-5",children:[e.jsxs(re,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Te,{value:"public"}),"Public"]}),e.jsxs(re,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Te,{value:"private"}),"Private"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{children:"Artifacts"}),e.jsx("div",{className:"bucket-artifact-list",children:n.map(R=>e.jsxs("div",{className:"bucket-artifact-row",children:[e.jsx(nt,{id:`bucket-artifact-${R.id}`,checked:j.has(R.id),onCheckedChange:D=>U(R.id,D===!0)}),e.jsxs(re,{htmlFor:`bucket-artifact-${R.id}`,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[e.jsx("span",{className:"bucket-artifact-kind",children:an[R.kind]}),e.jsx("span",{className:"bucket-artifact-name",children:R.label})]}),e.jsxs("a",{href:R.url,target:"_blank",rel:"noopener noreferrer",className:"bucket-artifact-open",children:[R.kind==="github"?"Open":"Web copy",e.jsx(V,{name:"external",size:10})]})]},R.id))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"“Web copy” opens the artifact's native Hugging Face page, where its Copy to bucket button is also available."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"bucket-copy-commands",children:"Copy workflow"}),e.jsx("pre",{id:"bucket-copy-commands",className:"bucket-copy-commands",children:P?h:"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(me,{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(B,{type:"button",onClick:T,disabled:!P||k.length===0,children:[e.jsx(V,{name:"copy",size:12}),"Copy commands"]})]})]})})]})}const dn={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"},Ye=360,_t=3,ms=3,un=["tldr","abstract","tasks","methods","results"];function mn(s){if(!s)return{section:null,resultsTaskSlug:null};const[a,n]=s.split("?",2);if(!un.includes(a))return{section:null,resultsTaskSlug:null};const d=a;return d!=="results"||!n?{section:d,resultsTaskSlug:null}:{section:d,resultsTaskSlug:new URLSearchParams(n).get("task")}}function hs(s){return`results-task-${s}`}function hn(s){return`#results?task=${encodeURIComponent(s)}`}function Fe({id:s,label:a,accent:n}){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})}),n]})}function ps(s){if(!s)return"—";try{return new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function fs(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function gs(s,a){try{const n=new URL(s),r=n.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return r?r.replace(/[-_]+/g," "):n.hostname.replace(/^www\./,"")}catch{return a}}const qn=()=>{var Jt,Xt,Wt,Yt,Zt,es,ts,ss,as;const{arxivId:s}=Ea(),a=s?Sa(s):"",n=Pa(),{toast:d}=pe(),{user:r}=tt(),o=(r==null?void 0:r.is_admin)??!1,l=!!r,f=cr(r),u=!0,{data:t,isLoading:N,error:j,refetch:E}=Va(a||"",!!a),[k,P]=m.useState(!1);m.useEffect(()=>{if(!s||s===a)return;const i=window.location.search+window.location.hash;n(`/paper/${a}${i}`,{replace:!0})},[a,n,s]),m.useEffect(()=>{if(t!=null&&t.title)return document.title=Ga(t.title),()=>{document.title=Qa}},[t==null?void 0:t.title]),m.useEffect(()=>{if(P(!1),!(t!=null&&t.id))return;const i=window.setTimeout(()=>P(!0),0);return()=>window.clearTimeout(i)},[t==null?void 0:t.id]);const{data:h,isLoading:U}=gr(k?t==null?void 0:t.arxiv_id:void 0),{data:T,isLoading:F,refetch:R}=mr(t==null?void 0:t.id,k&&!!(t!=null&&t.id));m.useEffect(()=>{const i=()=>{E(),R(),f==="direct"&&(t!=null&&t.id)&&(je.primePaperCurationState(t.id,!0).catch(()=>{}),je.primeEvaluationCurationState(t.id,!0).catch(()=>{})),d({title:"This section changed",description:"The latest state has been reloaded. Review the updated before / after diff before submitting again.",variant:"destructive"})};return window.addEventListener("pwc:catalog-conflict",i),()=>window.removeEventListener("pwc:catalog-conflict",i)},[f,t==null?void 0:t.id,E,R,d]);const{preferences:D}=Ra(),y=m.useMemo(()=>!T||!D.hide_closed_source_evals?T:T.filter(i=>i.is_open!==!1),[T,D.hide_closed_source_evals]),c=m.useMemo(()=>({models:(t==null?void 0:t.hf_models)??[],datasets:(t==null?void 0:t.hf_datasets)??[],spaces:(t==null?void 0:t.hf_spaces)??[]}),[t==null?void 0:t.hf_models,t==null?void 0:t.hf_datasets,t==null?void 0:t.hf_spaces]),p=m.useMemo(()=>{const i=(v,z,Q)=>{const ae=new Set,J=[];for(const se of[...v,...z??[]])ae.has(se)||(ae.add(se),J.push({href:se,label:gs(se,Q)}));return J};return{models:i(c.models,h==null?void 0:h.modelUrls,"Model"),datasets:i(c.datasets,h==null?void 0:h.datasetUrls,"Dataset"),spaces:i(c.spaces,h==null?void 0:h.spaceUrls,"Space")}},[c.models,c.datasets,c.spaces,h==null?void 0:h.modelUrls,h==null?void 0:h.datasetUrls,h==null?void 0:h.spaceUrls]),w=m.useMemo(()=>{if(!y)return[];const i=new Map;for(const v of y){const z=v.task_id,Q=i.get(z);Q?Q.rows.push(v):i.set(z,{taskId:z,taskName:v.task_name||"—",taskSlug:v.task_slug,rows:[v]})}return Array.from(i.values())},[y]),$=m.useMemo(()=>w.map(i=>i.taskSlug??"").join("|"),[w]),q=ne({queryKey:["paper-versions",t==null?void 0:t.arxiv_id],queryFn:async()=>{const i=t.arxiv_id.replace(/v\d+$/,""),v=await fetch(ks(`/api/v1/papers/arxiv/${i}/versions`));return v.ok?await v.json():[]},enabled:k&&!!(t!=null&&t.arxiv_id),staleTime:10*60*1e3}),K=ne({queryKey:["related-papers",t==null?void 0:t.id],queryFn:()=>je.getRelatedPapers(t.arxiv_id||t.id,4),enabled:k&&!!(t!=null&&t.id),staleTime:10*60*1e3}),[G,X]=m.useState(!1),[x,A]=m.useState(!1),[L,M]=m.useState(!1),S=m.useRef(!1);m.useEffect(()=>{S.current=!1},[a]),m.useEffect(()=>{let i=0;const v=(Q=!1,ae=!1)=>{const{section:J,resultsTaskSlug:se}=mn(window.location.hash.slice(1));if(!J||!t||J==="tldr"&&!t.tldr||J==="results"&&(!k||F)||!Q&&S.current)return;let Se=null;if(J==="results"&&se){if(Se=document.getElementById(hs(se)),!Se){if(w.find(da=>da.taskSlug===se))return;Se=document.getElementById("results")}}else Se=document.getElementById(J);if(!Se)return;const ca=Se;i=window.requestAnimationFrame(()=>{S.current=!0,ca.scrollIntoView({block:"start",behavior:ae?"smooth":"auto"})})};v();const z=()=>{S.current=!1,v(!0,!0)};return window.addEventListener("hashchange",z),()=>{window.removeEventListener("hashchange",z),i&&window.cancelAnimationFrame(i)}},[t,t==null?void 0:t.tldr,k,F,$,w]);const{isEditingTasks:Y,setIsEditingTasks:W,isEditingMethods:g,setIsEditingMethods:C,isEditingRepositories:I,setIsEditingRepositories:b,isEditingProjectPages:_,setIsEditingProjectPages:O,isEditingEvaluations:H,setIsEditingEvaluations:Z,isEditingSourceUrl:Ce,setIsEditingSourceUrl:Be,isEditingHfArtifacts:ot,setIsEditingHfArtifacts:He,isEditingOrganizations:lt,setIsEditingOrganizations:qe}=xr();m.useEffect(()=>{f!=="direct"||!(t!=null&&t.id)||((Y||g||I||_||Ce||ot||lt)&&je.primePaperCurationState(t.id).catch(()=>{}),H&&je.primeEvaluationCurationState(t.id).catch(()=>{}))},[f,H,ot,g,lt,_,I,Ce,Y,t==null?void 0:t.id]);const[ct,Lt]=m.useState(null);m.useEffect(()=>{var z;if(!r||!t)return;const i=sessionStorage.getItem("pwc:fresh-auth-edit");if(!i)return;sessionStorage.removeItem("pwc:fresh-auth-edit");const v={tasks:()=>W(!0),methods:()=>C(!0),repositories:()=>b(!0),project_pages:()=>O(!0),evaluations:()=>Z(!0),hf_artifacts:()=>He(!0),organizations:()=>qe(!0),source_url:()=>Be(!0)};(z=v[i])==null||z.call(v)},[t,Z,He,qe,C,O,b,Be,W,r]);const ge=m.useMemo(()=>{if(!r||!(t!=null&&t.author_links))return!1;const i=r.username.toLowerCase();return t.author_links.some(v=>!!v.hf_username&&v.hf_username.toLowerCase()===i)},[r,t==null?void 0:t.author_links]),ee=i=>{if(!l){Lt(i);return}switch(i){case"tasks":W(!0);return;case"methods":C(!0);return;case"results":Z(!0);return;case"repositories":b(!0);return;case"project-pages":O(!0);return;case"hf-artifacts":He(!0);return;case"organizations":qe(!0);return;case"source-url":Be(!0);return}},[Tt,dt]=m.useState("idle"),[Ut,Dt]=m.useState(null),[Mt,Bt]=m.useState(null),Ws=async()=>{if(a){dt("indexing"),Dt(null),Bt(null);try{await Ua(a),d({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>E(),1200),dt("idle")}catch(i){const v=i;let z=v.message||"Failed to index paper";if(v.response)try{z=JSON.parse(v.response).detail||z}catch{z=v.response}Dt(z),(v.status===429||v.status===503)&&Bt("Try again later after arXiv has lifted the temporary limit."),dt("idle")}}},{citationDisplay:Ys,citationCopy:Ht}=m.useMemo(()=>{if(!t)return{citationDisplay:"",citationCopy:""};const i=`${t.title.slice(0,60)}${t.title.length>60?"…":""}`,v=`${t.authors[0]||""}${t.authors.length>1?" et al.":""}`,z=t.authors.join(" and "),Q=(t.published||"").slice(0,4)||"—",ae=(J,se)=>t.arxiv_id?`@article{${t.arxiv_id.replace(".","")}, + title={{${J}}}, + author=${se}, + year={{${Q}}}, + eprint={{${t.arxiv_id}}}, + archivePrefix={{arXiv}} +}`:`@misc{paper${t.id}, + title={{${J}}}, + author=${se}, + year={{${Q}}}, + url={{${t.source_url||t.url_abs||""}}} +}`;return{citationDisplay:ae(i,`{{${v}}}`),citationCopy:ae(t.title,`{${z}}`)}},[t]),qt=m.useMemo(()=>dr(t==null?void 0:t.leaderboard_ranks),[t==null?void 0:t.leaderboard_ranks]),[Zs,zt]=m.useState(!1),ea=async()=>{if(Ht)try{await navigator.clipboard.writeText(Ht),zt(!0),d({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>zt(!1),1500)}catch{d({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",variant:"destructive"})}},ta=async()=>{if(!t)return;const i=t.arxiv_id||t.id,v=ur(i,qt);if(v)try{await navigator.clipboard.writeText(v),d({title:"PwC badges copied",description:"Each badge links to its highlighted leaderboard row."})}catch{d({title:"Copy failed",description:"Could not access the clipboard. Please try again.",variant:"destructive"})}};if(N)return e.jsxs("div",{className:"page",children:[e.jsx(Le,{className:"h-12 w-3/4 mb-4"}),e.jsx(Le,{className:"h-6 w-1/3 mb-8"}),e.jsx(Le,{className:"h-64 w-full"})]});if(j||!t)return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(be,{to:"/papers",children:"Papers"}),e.jsx("span",{className:"sep",children:"/"}),e.jsxs("span",{style:{color:"var(--ink)"},children:["arXiv:",a]})]}),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:",a]})," in the database. You can index it from arXiv right now."]}),Ut&&e.jsx(Ja,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(Xa,{children:[e.jsx("div",{children:Ut}),Mt&&e.jsx("div",{className:"mt-2",children:Mt})]})}),e.jsxs("div",{className:"action-row",children:[o&&e.jsxs("button",{className:"action-btn",onClick:Ws,disabled:Tt==="indexing",children:[e.jsx(V,{name:"sparkle",size:12}),Tt==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(B,{variant:"outline",onClick:()=>n("/papers"),children:"Browse Papers"})]})]});const Kt=q.data||[],Ie=Oa(t.repositories),xe=[...t.repositories??[]].sort((i,v)=>{const z=i.is_official?1:0,Q=v.is_official?1:0;return z!==Q?Q-z:(v.num_stars||0)-(i.num_stars||0)}),sa=L?xe:xe.slice(0,_t),ut={models:[...new Set([...c.models,...(h==null?void 0:h.modelUrls)??[]])],datasets:[...new Set([...c.datasets,...(h==null?void 0:h.datasetUrls)??[]])],spaces:[...new Set([...c.spaces,...(h==null?void 0:h.spaceUrls)??[]])]},mt=((Jt=t.arxiv_id)==null?void 0:Jt.replace(/v\d+$/,""))??null,ht=t.arxiv_id?{isLoading:U,paperHref:`https://huggingface.co/papers/${mt}`,rows:[{label:"Models",href:wt(`https://huggingface.co/models?other=arxiv:${t.arxiv_id}`,c.models),count:Nt(c.models,h==null?void 0:h.modelUrls,h==null?void 0:h.models),isLimited:h==null?void 0:h.isLimited,links:p.models},{label:"Datasets",href:wt(`https://huggingface.co/datasets?other=arxiv:${t.arxiv_id}`,c.datasets),count:Nt(c.datasets,h==null?void 0:h.datasetUrls,h==null?void 0:h.datasets),isLimited:h==null?void 0:h.isLimited,links:p.datasets},{label:"Spaces",href:wt(`https://huggingface.co/papers/${mt}`,c.spaces),count:Nt(c.spaces,h==null?void 0:h.spaceUrls,h==null?void 0:h.spaces),isLimited:h==null?void 0:h.isLimited,links:p.spaces}],footer:`Cite arxiv.org/abs/${mt} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:kt(c.models),count:c.models.length,links:p.models},{label:"Datasets",href:kt(c.datasets),count:c.datasets.length,links:p.datasets},{label:"Spaces",href:kt(c.spaces),count:c.spaces.length,links:p.spaces}],footer:null},Ot=t.tldr||null,Gt=t.num_pages||null,Ee=t.abstract||"",aa=Ee.length>Ye?Ee.slice(0,Ye)+"…":Ee,ra=G||Ee.length<=Ye?Ee:aa,ze=(t.methods||[]).filter(i=>i.source_paper_id===t.id),Ke=t.introduced_benchmarks||[],Ae=t.introduced_frameworks||[],na=ze.length>0||Ke.length>0||Ae.length>0,Qt=t.arxiv_id?`arXiv:${t.arxiv_id}`:"External resource",ia=t.source==="external"?"Source page":"arXiv page",$e=((Xt=t.project_pages)==null?void 0:Xt.filter(i=>i.url))??[],oa=(()=>{const i=[];return ze.length>0&&i.push(ze.length===1?"this method":"these methods"),Ke.length>0&&i.push(Ke.length===1?"this benchmark":"these benchmarks"),Ae.length>0&&i.push(Ae.length===1?"this framework":"these frameworks"),i.length===0?"":i.length===1?i[0]:i.join(" and ")})(),Oe=t.predecessor_papers||[],Ge=t.successor_papers||[],la=Oe.length>0||Ge.length>0,Qe=12,pt=t.authors.map((i,v)=>{var z,Q,ae,J;return{name:i,id:((Q=(z=t.author_links)==null?void 0:z[v])==null?void 0:Q.id)??null,hf_username:((J=(ae=t.author_links)==null?void 0:ae[v])==null?void 0:J.hf_username)??null}}),Vt=x||pt.length<=Qe?pt:pt.slice(0,Qe);return e.jsxs("div",{className:"page",children:[e.jsxs("div",{className:"breadcrumb",children:[e.jsx(be,{to:"/",children:"Trending"}),e.jsx("span",{className:"sep",children:"/"}),e.jsx("span",{children:Qt})]}),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.jsx("h1",{className:"detail-title",children:e.jsx(Ve,{title:t.title})}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:Qt}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",ps(t.published)]}),Gt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Gt," pages"]})]}),t.citation_count!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.citation_count.toLocaleString()," citations"]})]}),(t.proceeding||t.conference_slug)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),t.conference_slug?e.jsx("a",{href:`/conferences/${t.conference_slug}`,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent-text)"},children:(t.proceeding||t.conference_name||"").replace(/\s+\d{1,2}$/,"")}):e.jsx("span",{children:t.proceeding.replace(/\s+\d{1,2}$/,"")})]}),Kt.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("select",{className:"version-select",value:t.version,onChange:i=>{const v=i.target.value;t.arxiv_id&&n(`/paper/${t.arxiv_id.replace(/v\d+$/,"")}${v?`?version=${v}`:""}`)},children:Kt.map(i=>e.jsxs("option",{value:i.version,children:[i.version," — ",ps(i.published)]},i.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[Vt.map((i,v)=>e.jsxs(Rt.Fragment,{children:[i.id?e.jsx(be,{to:`/authors/${i.id}`,children:i.name}):i.hf_username?e.jsx("a",{href:`https://huggingface.co/${i.hf_username}`,target:"_blank",rel:"noopener noreferrer",title:`@${i.hf_username} on Hugging Face`,children:i.name}):e.jsx("a",{children:i.name}),vQe&&e.jsx("button",{className:"show-more-authors",onClick:()=>A(i=>!i),style:{marginLeft:8,background:"none",border:"none",cursor:"pointer",color:"var(--accent-text)",fontFamily:"var(--mono)",fontSize:12},children:x?"show fewer":`+${t.authors.length-Qe} more`})]}),e.jsxs("div",{className:"action-row",children:[t.url_pdf&&e.jsxs("a",{className:"action-btn",href:t.url_pdf,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"pdf",size:12})," View PDF"]}),t.url_abs&&e.jsx(We,{showEdit:t.source==="external"&&u,onEdit:()=>ee("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:t.source==="external"&&u?"action-btn-segment action-btn-main":"action-btn",href:t.url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"external",size:12})," ",ia]})}),ht.paperHref&&(h==null?void 0:h.paperExists)&&e.jsxs("a",{className:"bm-action-btn",href:ht.paperHref,target:"_blank",rel:"noopener noreferrer","aria-label":"View on Hugging Face",children:["View on ",e.jsx("span",{"aria-hidden":"true",children:"🤗"})]}),Ie.githubUrl&&e.jsx(We,{showEdit:u,onEdit:()=>ee("repositories"),editAriaLabel:"Edit code repositories",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ie.githubUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"github",size:12})," Code",Ie.github!=null&&e.jsxs("span",{style:{opacity:.7,marginLeft:4},children:["· ",fs(Ie.github)," ★"]})]})}),Ie.githubUrl?null:e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>ee("repositories"),title:"Add GitHub repository",children:[e.jsx(V,{name:"github",size:12})," Add code"]}),$e.length===1?e.jsx(We,{showEdit:u,onEdit:()=>ee("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:$e[0].url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"globe",size:12})," Project page"]})}):null,$e.length>1?e.jsx(We,{showEdit:u,onEdit:()=>ee("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs(Ia,{children:[e.jsx(Aa,{asChild:!0,children:e.jsxs("button",{type:"button",className:"action-btn-segment action-btn-main",children:[e.jsx(V,{name:"globe",size:12})," Project page"]})}),e.jsx($a,{align:"start",className:"project-page-menu",children:$e.map((i,v)=>e.jsx(Fa,{asChild:!0,children:e.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",children:gs(i.url,`Project page ${v+1}`)})},i.url))})]})}):null,$e.length===0&&l?e.jsxs("button",{type:"button",className:"action-btn",onClick:()=>ee("project-pages"),title:"Add project page",children:[e.jsx(V,{name:"globe",size:12})," Add project page"]}):null,t.conference_url_abs&&e.jsxs("a",{className:"action-btn",href:t.conference_url_abs,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"external",size:12})," Conference"]}),(t.organizations||[]).map(i=>e.jsxs(be,{to:`/orgs/${i.slug}`,className:"action-btn",title:i.name,"aria-label":i.name,children:[i.logo_url&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:16,width:16,borderRadius:3,overflow:"hidden"},children:e.jsx("img",{src:i.logo_url,alt:"",style:{height:"150%",width:"150%",objectFit:"contain"},onError:v=>{v.currentTarget.style.display="none"}})}),i.name]},i.id)),e.jsx("button",{type:"button",className:"action-btn",onClick:()=>ee("organizations"),children:"Edit organizations"}),o&&nr()&&e.jsx(Gr,{paperId:t.id,paperTitle:t.title,onComplete:()=>void E()}),e.jsx(qr,{paperId:t.id})]}),t.leaderboard_ranks&&t.leaderboard_ranks.length>0&&e.jsx(Da,{wrap:!0,paperHref:`/paper/${t.arxiv_id||t.id}`,ranks:t.leaderboard_ranks.filter(i=>i.best_rank>=1&&i.best_rank<=3).map(i=>({name:i.dataset_name,slug:i.dataset_slug||null,rank:i.best_rank}))})]}),e.jsx("div",{className:"detail-hero-thumb detail-thumb-wrap",children:e.jsx(Ma,{paperId:t.arxiv_id||t.id,title:t.title,thumbnailUrl:La(t.thumbnail_url),priority:!0})})]}),na&&e.jsxs("div",{className:`introduced-banner${Ae.length>0?" introduced-banner--framework":""}`,children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[ze.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/methods/${i.slug||i.id}`),children:[i.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${i.id}`)),Ke.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/benchmark/${i.slug||i.id}`),children:[i.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${i.id}`)),Ae.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>n(`/frameworks#framework-${i.slug}`),children:[i.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`framework-${i.slug}`))]}),e.jsxs("span",{className:"introduced-note",children:["This paper is the canonical source for ",oa,"."]})]}),la&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[Ge.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Ge.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:Ge.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>n(`/paper/${i.route_identifier}`),children:[e.jsx(Ve,{title:i.title}),e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${i.id}`))})]}),Oe.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Oe.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:Oe.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>n(`/paper/${i.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),e.jsx(Ve,{title:i.title})]},`predecessor-${i.id}`))})]})]}),Ot&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{id:"tldr",label:"TL;DR · AI-generated"}),e.jsx("div",{className:"tldr-box",children:Ot})]}),e.jsx(Fe,{id:"abstract",label:"Abstract"}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(Ka,{text:ra})}),Ee.length>Ye&&e.jsx("div",{className:"read-full",onClick:()=>X(i=>!i),children:G?"− collapse abstract":"+ read full abstract"}),e.jsx(Fe,{id:"tasks",label:"Tasks",accent:e.jsxs("span",{className:"accent",children:[((Wt=t.tasks)==null?void 0:Wt.length)||0," tagged",e.jsx("button",{type:"button",onClick:()=>ee("tasks"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{className:"paper-tags",style:{marginBottom:8},children:(t.tasks||[]).map(i=>e.jsx(Ba,{slug:i.slug||"",label:i.name},i.id))}),e.jsx(Fe,{id:"methods",label:"Methods",accent:e.jsxs("span",{className:"accent",children:[((Yt=t.methods)==null?void 0:Yt.length)||0," used",e.jsx("button",{type:"button",onClick:()=>ee("methods"),className:"edit-link",children:"edit"})]})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:(t.methods||[]).map(i=>e.jsx(Ha,{method:i},i.id))}),e.jsx(Fe,{id:"results",label:"Results",accent:e.jsxs("span",{className:"accent",children:[(y==null?void 0:y.length)||0," benchmarks",qt.length>0&&e.jsxs("button",{type:"button",className:"edit-link results-badge-copy",onClick:ta,title:"Copy live leaderboard badges for your repository README",children:[e.jsx(V,{name:"copy",size:10})," Copy PwC badge"]}),o&&ir()&&e.jsx(Or,{paperId:t.id,paperTitle:t.title,onComplete:()=>void R()}),e.jsx("button",{type:"button",onClick:()=>ee("results"),className:"edit-link",children:"edit"})]})}),F?e.jsx(Le,{className:"h-32 w-full"}):w.length>0?w.map(i=>e.jsxs("div",{className:i.taskSlug?"paper-section-anchor":void 0,id:i.taskSlug?hs(i.taskSlug):void 0,children:[e.jsxs("div",{className:"section-rule",children:[e.jsx("span",{children:i.taskSlug?e.jsxs(e.Fragment,{children:[e.jsx(be,{to:`/tasks/${i.taskSlug}`,children:i.taskName}),e.jsx("a",{href:hn(i.taskSlug),className:"section-anchor-link results-task-permalink","aria-label":`Permalink to ${i.taskName} results on this paper`,title:"Link to this task's results",children:"#"})]}):i.taskName}),e.jsxs("span",{className:"accent",children:[i.rows.length," ",i.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:i.rows.map(v=>{var z;return e.jsxs("tr",{children:[e.jsx("td",{className:"benchmark",children:v.dataset_slug?e.jsx(be,{to:`/benchmark/${v.dataset_slug}`,children:v.dataset_name||"—"}):v.dataset_name||"—"}),e.jsxs("td",{className:"model",title:v.model_name||void 0,children:[v.hf_model_url?e.jsx("a",{href:v.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"model-hf-link",title:`Open ${v.model_name||"model"} on Hugging Face`,children:v.model_name||"—"}):v.model_name||"—",v.is_open===!1&&e.jsx(qa,{}),(v.external??v.is_external)&&e.jsx(za,{sourceUrl:v.source_url||v.external_source_url||v.result_url})]}),e.jsx("td",{className:"metric",children:v.best_metric}),e.jsx("td",{className:"value",children:Ta((z=v.metrics)==null?void 0:z[v.best_metric||""])}),e.jsx("td",{className:"rank",children:v.best_rank!=null?`#${v.best_rank}`:"—"}),e.jsx("td",{className:"compare",children:v.dataset_slug&&e.jsx(be,{to:`/benchmark/${v.dataset_slug}?${[v.task_slug?`task=${encodeURIComponent(v.task_slug)}`:"",`eval=${encodeURIComponent(v.id)}`].filter(Boolean).join("&")}`,children:"Compare →"})})]},v.id)})})]})]},i.taskId)):e.jsx("p",{style:{fontFamily:"var(--mono)",fontSize:12,color:"var(--ink-faint)"},children:"No benchmark results recorded yet."})]}),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:[xe.length," repo",xe.length===1?"":"s",e.jsx("button",{type:"button",onClick:()=>ee("repositories"),className:"edit-link",children:"edit"})]})]}),sa.map(i=>e.jsxs("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"code-line",style:{textDecoration:"none"},children:[e.jsxs("span",{className:"code-line-repo",children:[e.jsx(V,{name:"github",size:12}),e.jsxs("span",{className:"code-line-repo-name",children:[i.owner,"/",i.name]}),i.is_official&&e.jsx("span",{className:"code-line-official",children:"· Official"})]}),e.jsxs("span",{className:"code-line-stars",children:["★ ",fs(i.num_stars)]})]},i.id)),xe.length===0&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:11,color:"var(--ink-faint)",padding:"6px 0"},children:"No GitHub repositories linked yet."}),xe.length>_t&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>M(i=>!i),children:L?"− show top 3":`+ show ${xe.length-_t} more repos`})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 flex justify-end",children:e.jsx(B,{size:"sm",variant:"outline",onClick:()=>ee("hf-artifacts"),children:"Edit Hugging Face links"})}),e.jsx(pn,{viewer:ht})]}),e.jsx(cn,{githubUrls:xe.map(i=>i.url),hfModelUrls:ut.models,hfDatasetUrls:ut.datasets,hfSpaceUrls:ut.spaces,suggestedBucketId:r?`${r.username}/${ln(t.title)}`:void 0}),K.isLoading&&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…"})]}),!K.isLoading&&(((Zt=K.data)==null?void 0:Zt.length)??0)>0&&e.jsxs("div",{className:"sidebar-card",children:[e.jsx("div",{className:"sidebar-card-title",children:"Related papers"}),K.data.map(i=>e.jsxs(be,{to:`/paper/${i.arxiv_id||i.id}`,target:"_blank",rel:"noopener noreferrer",className:"related-paper",style:{textDecoration:"none",color:"inherit"},children:[e.jsx("div",{className:"related-title",children:e.jsx(Ve,{title:i.title})}),e.jsxs("div",{className:"related-meta",children:[e.jsx("span",{children:i.arxiv_id?`arXiv:${i.arxiv_id}`:"External resource"}),i.citation_count!=null&&e.jsxs("span",{children:[i.citation_count.toLocaleString()," cites"]})]})]},i.id))]}),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:ea,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(V,{name:"copy",size:11}),Zs?"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:Ys})]})]})]}),e.jsx(Nr,{open:Y,onOpenChange:W,paperId:t.id,arxivId:a,initialTaskIds:((es=t.tasks)==null?void 0:es.map(i=>parseInt(i.id)))||[],initialTasks:t.tasks||[],submitMode:f,isAuthor:ge}),e.jsx(Sr,{open:g,onOpenChange:C,paperId:t.id,arxivId:a,initialMethodIds:((ts=t.methods)==null?void 0:ts.map(i=>parseInt(i.id)))||[],initialMethods:t.methods||[],submitMode:f,isAuthor:ge}),e.jsx(Pr,{open:I,onOpenChange:b,paperId:t.id,arxivId:a,initialRepositories:((ss=t.repositories)==null?void 0:ss.map(i=>({url:i.url,is_official:i.is_official||!1})))||[],submitMode:f,isAuthor:ge}),e.jsx(Rr,{open:_,onOpenChange:O,paperId:t.id,arxivId:a,initialProjectPages:((as=t.project_pages)==null?void 0:as.map(i=>({url:i.url,is_official:i.is_official||!1})))||[],submitMode:f,isAuthor:ge}),e.jsx(Tr,{open:H,onOpenChange:Z,paperId:t.id,arxivId:a,initialEvaluations:T||[],paperTasks:t.tasks||[],submitMode:f,isAdmin:o,isAuthor:ge}),e.jsx(Ir,{open:Ce,onOpenChange:Be,paperId:t.id,arxivId:a,initialUrl:t.source_url??t.url_abs??"",submitMode:f,isAuthor:ge}),e.jsx(Dr,{open:ot,onOpenChange:He,paperId:t.id,arxivId:a,initialArtifacts:{hf_models:c.models,hf_datasets:c.datasets,hf_spaces:c.spaces},submitMode:f,isAuthor:ge}),e.jsx(Mr,{open:lt,onOpenChange:qe,paperId:t.id,initialOrganizationIds:(t.organizations||[]).map(i=>Number(i.id)),submitMode:f,isAuthor:ge}),e.jsx(Wa,{open:ct!==null,onOpenChange:i=>{i||Lt(null)},sectionLabel:ct?dn[ct]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})},pn=({viewer:s})=>e.jsxs("div",{className:"sidebar-card",children:[e.jsx("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"})}),s.isLoading?e.jsx(Le,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[s.rows.map(a=>e.jsx(fn,{...a},a.label)),s.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:s.footer})]})]}),fn=({label:s,href:a,count:n,isLimited:d,links:r})=>{const[o,l]=m.useState(!1),f=((r==null?void 0:r.length)??0)>0,u=((r==null?void 0:r.length)??0)>ms,t=o?r:r==null?void 0:r.slice(0,ms),N=n!=null?`${n}${d?"+":""}`:"—",j=n?e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"hf-artifact-count",children:N}):e.jsx("span",{className:"hf-artifact-count hf-artifact-count--empty",children:N});return e.jsxs("div",{className:"hf-artifact-row",children:[e.jsxs("div",{className:"hf-artifact-row-header",children:[e.jsx("span",{children:s}),j]}),f&&e.jsxs("div",{className:"hf-artifact-links",children:[t.map(E=>e.jsx("a",{href:E.href,target:"_blank",rel:"noopener noreferrer",children:E.label},E.href)),u&&e.jsx("button",{type:"button",className:"hf-artifact-toggle","aria-expanded":o,onClick:()=>l(E=>!E),children:o?"Show fewer":`View all ${r.length}`})]})]})};function kt(s){return s[0]??"https://huggingface.co"}function wt(s,a){return a[0]??s}function Nt(s,a,n){if(n==null&&s.length===0&&!(a!=null&&a.length))return;const d=new Set([...s,...a??[]]);return Math.max(n??0,d.size)}export{qn as default};