diff --git "a/assets/PaperDetailView-C8MLtf05.js" "b/assets/PaperDetailView-C8MLtf05.js" deleted file mode 100644--- "a/assets/PaperDetailView-C8MLtf05.js" +++ /dev/null @@ -1,29 +0,0 @@ -import{c as Et,h as da,r as u,j as e,P as gs,k as we,l as xs,m as De,n as Ue,o as bs,p as St,C as ye,q as Ye,s as he,g as pe,X as js,t as _e,v as ua,w as vs,x as ma,y as ha,z as pa,A as fa,B as ga,D as as,E as xa,F as ba,G as ja,H as va,I as ya,f as et,R as Pt,b as je,J as ys,d as _s,K as _a,M as ka,N as wa,O as ks,Q as Na,e as Ca,S as Ea,u as Sa,T as Pa,L as be,U as Ia,V as Ra,W as Aa,Y as $a,Z as Fa,_ as La,$ as Ta}from"./index-eBKbcCso.js";import{u as ne}from"./useQuery-DIrXGOA7.js";import{I as V,S as Ua,a as Da,T as Ma,M as Ba}from"./components-D8Z2f6Zw.js";import{C as Ha,E as qa}from"./ExternalSourceEvalBadge-CrNqFzv-.js";import{L as Qe,a as za}from"./LatexTitle-CqLY2qFp.js";import{c as Ka}from"./transform-DM1_5UAz.js";import{f as Oa,D as Ga}from"./latexPlainText-ChVkH0gY.js";import{a as Qa}from"./usePapers-B09ZSLzW.js";import{S as Fe}from"./skeleton-Cd-jfjiE.js";import{A as Va,a as Ja}from"./alert-BCeSLEYS.js";import{B as H}from"./button-DR_Fc3Hk.js";import{u as ws}from"./index-CIicyhwW.js";import{I as te}from"./textarea-DC0tTufA.js";import{D as oe,a as le,b as ce,c as de,d as ue,e as me}from"./dialog-DhCB6EKj.js";import{u as fe}from"./useMutation-CcYjkB_f.js";import{S as It,P as tt,L as re,a as Xa}from"./SignInToEditDialog-eRf-3xm2.js";import{S as Ze,a as rs}from"./searchable-select-DycSakxh.js";import{L as ie}from"./loader-circle-Bz-wpQwE.js";import{B as Ns,D as Wa,c as Ya,g as Za,s as er,a as tr,b as sr,d as ar,i as rr,e as nr}from"./codexAddEvals-DMs98_B2.js";import{G as ns}from"./github-CiEpogIF.js";import{M as ir,r as or}from"./index-LmPbjihc.js";import"./useBaseQuery-CZIeK7IO.js";import"./hover-card-CdeSv7Gc.js";import"./katex.min-BSBacQyE.js";import"./useInfiniteQuery-PtHXMuOU.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 is=Et("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 Cs=Et("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 st=Et("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 lr(s){return s!=null&&s.can_directly_edit_catalog?"direct":"pending"}function cr(s){return(s??[]).filter(a=>!!(a.dataset_slug&&a.task_slug))}function dr(s,a,r="https://paperswithcode.co"){return a.map(d=>{const n=encodeURIComponent(d.evaluation_id),o=`${r}/api/v1/papers/${encodeURIComponent(s)}/leaderboard-badge.svg?eval=${n}&live=1`,l=new URLSearchParams({task:d.task_slug,eval:d.evaluation_id}),f=`${r}/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 ur(s,a=!0){return ne({queryKey:["evaluations","paper",s],queryFn:()=>{if(!s)throw new Error("Paper ID is required");return da(s)},enabled:a&&!!s,staleTime:0,refetchOnMount:"always"})}const Es=s=>s.replace(/v\d+$/,""),mr={models:"https://huggingface.co/",datasets:"https://huggingface.co/datasets/",spaces:"https://huggingface.co/spaces/"},pt=(s,a)=>{const r=(s[a]||[]).length;return r<100?{count:r,isLimited:!1}:{count:r,isLimited:!0}},ft=(s,a)=>{const r=s[a];return Array.isArray(r)?r.map(d=>{if(typeof d=="string")return d;if(d&&typeof d=="object"){const n=d;return n.id||n.repoId||null}return null}).filter(d=>!!d).map(d=>`${mr[a]}${d}`):[]},hr=async s=>{try{return(await fetch(`https://huggingface.co/api/papers/${Es(s)}`)).ok}catch{return!1}},pr=async s=>{const a=Es(s),[r,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)),hr(a)]);if(!r)return{models:0,datasets:0,spaces:0,modelUrls:[],datasetUrls:[],spaceUrls:[],isLimited:!1,paperExists:d};const n=pt(r,"models"),o=pt(r,"datasets"),l=pt(r,"spaces");return{models:n.count,datasets:o.count,spaces:l.count,modelUrls:ft(r,"models"),datasetUrls:ft(r,"datasets"),spaceUrls:ft(r,"spaces"),isLimited:n.isLimited||o.isLimited||l.isLimited,paperExists:d}},fr=s=>ne({queryKey:["huggingface-repos",s],queryFn:()=>pr(s),enabled:!!s,staleTime:10*60*1e3,retry:1});function gr(){const[s,a]=u.useState(!1),[r,d]=u.useState(!1),[n,o]=u.useState(!1),[l,f]=u.useState(!1),[m,t]=u.useState(!1),[N,j]=u.useState(!1),[E,k]=u.useState(!1),[P,h]=u.useState(!1);return{isEditingTasks:s,openTasksDialog:()=>a(!0),closeTasksDialog:()=>a(!1),setIsEditingTasks:a,isEditingMethods:r,openMethodsDialog:()=>d(!0),closeMethodsDialog:()=>d(!1),setIsEditingMethods:d,isEditingRepositories:n,openRepositoriesDialog:()=>o(!0),closeRepositoriesDialog:()=>o(!1),setIsEditingRepositories:o,isEditingProjectPages:l,openProjectPagesDialog:()=>f(!0),closeProjectPagesDialog:()=>f(!1),setIsEditingProjectPages:f,isEditingEvaluations:m,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 at="Checkbox",[xr]=St(at),[br,Rt]=xr(at);function jr(s){const{__scopeCheckbox:a,checked:r,children:d,defaultChecked:n,disabled:o,form:l,name:f,onCheckedChange:m,required:t,value:N="on",internal_do_not_use_render:j}=s,[E,k]=xs({prop:r,defaultProp:n??!1,onChange:m,caller:at}),[P,h]=u.useState(null),[U,T]=u.useState(null),F=u.useRef(!1),I=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(n)?!1:n,isFormControl:I,bubbleInput:U,setBubbleInput:T};return e.jsx(br,{scope:a,...D,children:vr(j)?j(D):d})}var Ss="CheckboxTrigger",Ps=u.forwardRef(({__scopeCheckbox:s,onKeyDown:a,onClick:r,...d},n)=>{const{control:o,value:l,disabled:f,checked:m,required:t,setControl:N,setChecked:j,hasConsumerStoppedPropagationRef:E,isFormControl:k,bubbleInput:P}=Rt(Ss,s),h=De(n,N),U=u.useRef(m);return u.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(we.button,{type:"button",role:"checkbox","aria-checked":ve(m)?"mixed":m,"aria-required":t,"data-state":Fs(m),"data-disabled":f?"":void 0,disabled:f,value:l,...d,ref:h,onKeyDown:Ue(a,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Ue(r,T=>{j(F=>ve(F)?!0:!F),P&&k&&(E.current=T.isPropagationStopped(),E.current||T.stopPropagation())})})});Ps.displayName=Ss;var At=u.forwardRef((s,a)=>{const{__scopeCheckbox:r,name:d,checked:n,defaultChecked:o,required:l,disabled:f,value:m,onCheckedChange:t,form:N,...j}=s;return e.jsx(jr,{__scopeCheckbox:r,checked:n,defaultChecked:o,disabled:f,required:l,onCheckedChange:t,name:d,form:N,value:m,internal_do_not_use_render:({isFormControl:E})=>e.jsxs(e.Fragment,{children:[e.jsx(Ps,{...j,ref:a,__scopeCheckbox:r}),E&&e.jsx($s,{__scopeCheckbox:r})]})})});At.displayName=at;var Is="CheckboxIndicator",Rs=u.forwardRef((s,a)=>{const{__scopeCheckbox:r,forceMount:d,...n}=s,o=Rt(Is,r);return e.jsx(gs,{present:d||ve(o.checked)||o.checked===!0,children:e.jsx(we.span,{"data-state":Fs(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{pointerEvents:"none",...s.style}})})});Rs.displayName=Is;var As="CheckboxBubbleInput",$s=u.forwardRef(({__scopeCheckbox:s,...a},r)=>{const{control:d,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:l,required:f,disabled:m,name:t,value:N,form:j,bubbleInput:E,setBubbleInput:k}=Rt(As,s),P=De(r,k),h=ws(o),U=bs(d);u.useEffect(()=>{const F=E;if(!F)return;const I=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(I,"checked").set,c=!n.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,n]);const T=u.useRef(ve(o)?!1:o);return e.jsx(we.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??T.current,required:f,disabled:m,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%)"}})});$s.displayName=As;function vr(s){return typeof s=="function"}function ve(s){return s==="indeterminate"}function Fs(s){return ve(s)?"indeterminate":s?"checked":"unchecked"}const rt=u.forwardRef(({className:s,style:a,...r},d)=>e.jsx(At,{ref:d,className:Ye("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},...r,children:e.jsx(Rs,{className:Ye("flex items-center justify-center text-current"),children:e.jsx(ye,{className:"h-4 w-4"})})}));rt.displayName=At.displayName;function yr(s,a,r){if(!s)return s;const d=n=>n.paper_id!==a||n.paper_title===r?n:{...n,paper_title:r};if(Array.isArray(s)){const n=s.map(d);return n.some((l,f)=>l!==s[f])?n:s}if(Array.isArray(s.results)){const n=s.results.map(d);return n.some((l,f)=>l!==s.results[f])?{...s,results:n}:s}return s}function Pe(s,a,r){new Set([...r,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 n=String(a.id),o=l=>yr(l,n,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 _r=250,kr=100;function wr({open:s,onOpenChange:a,paperId:r,arxivId:d,initialTaskIds:n,initialTasks:o,onSuccess:l,submitMode:f="direct",isAuthor:m=!1}){const[t,N]=u.useState(n),[j,E]=u.useState(!1),[k,P]=u.useState(""),[h,U]=u.useState(""),[T,F]=u.useState(new Map),I=he(),{toast:D}=pe(),y=u.useRef(!1);u.useEffect(()=>{if(!s){y.current=!1;return}if(y.current)return;y.current=!0,N(n),P(""),U("");const x=new Map;(o||[]).forEach(A=>{const L=parseInt(A.id);Number.isNaN(L)||x.set(L,A)}),F(x)},[s,n,o]),u.useEffect(()=>{const x=window.setTimeout(()=>{U(k.trim())},_r);return()=>window.clearTimeout(x)},[k]);const{data:c,isFetching:p}=ne({queryKey:["tasks-search",h],queryFn:()=>vs({page_size:kr,...h?{q:h}:{}}),enabled:s});u.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=u.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):ua(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([r,d].filter(S=>!!S)));await Promise.all(L.flatMap(S=>[I.cancelQueries({queryKey:["paper",S]}),I.cancelQueries({queryKey:["paper-arxiv",S]})]));const M=[];return L.forEach(S=>{["paper","paper-arxiv"].forEach(Y=>{const W=[Y,S],g=I.getQueryData(W);M.push({key:W,data:g}),g&&I.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&&Pe(I,x,[r,d])},onError:(x,A,L)=>{var Y,W;(Y=L==null?void 0:L.snapshots)==null||Y.forEach(({key:g,data:C})=>{I.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"&&n.some(x=>!t.includes(x))&&!window.confirm("Remove one or more task links from this paper?")||$.mutate({paperId:r,taskIds:t})},K=u.useMemo(()=>{if(t.length!==n.length)return!0;const x=new Set(n);return t.some(A=>!x.has(A))},[t,n]),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:m}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Ze,{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(js,{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(rt,{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(Ze,{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.jsxs(me,{children:[e.jsx(H,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new task"}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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:r,kind:"task"})]})}const Nr=250,Cr=100;function Er({open:s,onOpenChange:a,paperId:r,arxivId:d,initialMethodIds:n,initialMethods:o,onSuccess:l,submitMode:f="direct",isAuthor:m=!1}){const[t,N]=u.useState(n),[j,E]=u.useState(!1),[k,P]=u.useState(""),[h,U]=u.useState(""),[T,F]=u.useState(new Map),I=he(),{toast:D}=pe(),y=u.useRef(!1);u.useEffect(()=>{if(!s){y.current=!1;return}if(y.current)return;y.current=!0,N(n),P(""),U("");const x=new Map;(o||[]).forEach(A=>{const L=parseInt(A.id);Number.isNaN(L)||x.set(L,A)}),F(x)},[s,n,o]),u.useEffect(()=>{const x=window.setTimeout(()=>{U(k.trim())},Nr);return()=>window.clearTimeout(x)},[k]);const{data:c,isFetching:p}=ne({queryKey:["methods-search",h],queryFn:()=>ha({page_size:Cr,...h?{q:h}:{}}),enabled:s});u.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=u.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):ma(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&&Pe(I,x,[r,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"&&n.some(x=>!t.includes(x))&&!window.confirm("Remove one or more method links from this paper?")||$.mutate({paperId:r,methodIds:t})},K=u.useMemo(()=>{if(t.length!==n.length)return!0;const x=new Set(n);return t.some(A=>!x.has(A))},[t,n]),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:m}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Ze,{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(js,{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(rt,{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(Ze,{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.jsxs(me,{children:[e.jsx(H,{variant:"ghost",className:"sm:mr-auto",onClick:()=>E(!0),children:"Suggest a new method"}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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:r,kind:"method"})]})}function Te(s){const a=s.trim();if(!a)return null;let r=a;!r.startsWith("http://")&&!r.startsWith("https://")&&(r=`https://${r}`);try{const d=new URL(r);if(d.hostname.toLowerCase()!=="github.com")return null;const n=d.pathname.split("/").filter(Boolean);if(n.length<2)return null;const o=n[0].toLowerCase();let l=n[1].toLowerCase();return l.endsWith(".git")&&(l=l.slice(0,-4)),`https://github.com/${o}/${l}`}catch{return null}}function os(s,a){const r=Te(s),d=Te(a);return r&&d?r===d:s.trim()===a.trim()}function Sr({open:s,onOpenChange:a,paperId:r,arxivId:d,initialRepositories:n,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[m,t]=u.useState(n),[N,j]=u.useState(""),E=he(),{toast:k}=pe(),P=u.useRef(!1);u.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(n),j(""))},[s,n]);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):pa(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&&Pe(E,p,[r,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=>os(K.url,$.url));if(q)q.is_official=q.is_official||$.is_official;else{const K=Te($.url);w.push({url:K??$.url.trim(),is_official:$.is_official})}}return w},T=()=>{const p=N.trim(),w=p?[...m,{url:p,is_official:!1}]:m;return p&&m.some($=>os($.url,p))?(alert("This repository URL is already added"),null):U(w)},F=()=>{const p=T();p!==null&&p.length!==m.length&&(t(p),j(""))},I=p=>{t(m.filter(w=>w.url!==p))},D=p=>{t(m.map(w=>w.url===p?{...w,is_official:!w.is_official}:w))},y=()=>{const p=T();p!==null&&(l==="direct"&&n.some(w=>!p.some($=>$.url===w.url))&&!window.confirm("Remove one or more repositories from this paper?")||h.mutate({paperId:r,repositories:p}))},c=u.useMemo(()=>{const p=N.trim(),w=p?[...m,{url:p,is_official:!1}]:m;if(w.length!==n.length)return!0;const $=U(n),q=U(w);if(q.length!==$.length)return!0;const K=new Map($.map(G=>[Te(G.url)??G.url.trim(),!!G.is_official]));return q.some(G=>{const X=Te(G.url)??G.url.trim(),x=K.get(X);return x===void 0||x!==!!G.is_official})},[m,N,n]);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(H,{onClick:F,size:"sm",disabled:!N.trim(),children:[e.jsx(tt,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:m.length>0?e.jsx("div",{className:"space-y-2",children:m.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(ns,{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(Ns,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(H,{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(Cs,{className:`w-3.5 h-3.5 mr-1 ${p.is_official?"fill-current":""}`}),p.is_official?"Official":"Mark official"]}),e.jsx(H,{variant:"ghost",size:"sm",onClick:()=>I(p.url),className:"h-8 px-2 text-destructive hover:text-destructive",title:"Remove repository",children:e.jsx(st,{className:"w-4 h-4"})})]})]},w))}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(ns,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No repositories added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a repository URL above to get started"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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 Pr({open:s,onOpenChange:a,paperId:r,arxivId:d,initialProjectPages:n,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[m,t]=u.useState(n),[N,j]=u.useState(""),E=he(),{toast:k}=pe(),P=u.useRef(!1);u.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(n),j(""))},[s,n]);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):fa(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&&Pe(E,c,[r,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?m.some(p=>p.url===c)?(alert("This project page URL is already added"),null):[...m,{url:c,is_official:!1}]:m},T=()=>{const c=U();c!==null&&c.length!==m.length&&(t(c),j(""))},F=c=>{t(m.filter(p=>p.url!==c))},I=c=>{t(m.map(p=>p.url===c?{...p,is_official:!p.is_official}:p))},D=()=>{const c=U();c!==null&&(l==="direct"&&n.some(p=>!c.some(w=>w.url===p.url))&&!window.confirm("Remove one or more project pages from this paper?")||h.mutate({paperId:r,projectPages:c}))},y=u.useMemo(()=>{const c=N.trim(),p=c?[...m,{url:c,is_official:!1}]:m;if(p.length!==n.length)return!0;const w=new Map(n.map($=>[$.url.trim(),!!$.is_official]));return p.some($=>{const q=w.get($.url.trim());return q===void 0||q!==!!$.is_official})},[m,N,n]);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(H,{onClick:T,size:"sm",disabled:!N.trim(),children:[e.jsx(tt,{className:"w-4 h-4 mr-1"}),"Add"]})]})]}),e.jsx("div",{className:"py-4 overflow-y-auto max-h-[350px]",children:m.length>0?e.jsx("div",{className:"space-y-2",children:m.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(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:c.url}),c.is_official&&e.jsx(Ns,{variant:"secondary",className:"text-xs",children:"Official"})]})}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs(H,{variant:c.is_official?"default":"outline",size:"sm",onClick:()=>I(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(Cs,{className:`w-3.5 h-3.5 mr-1 ${c.is_official?"fill-current":""}`}),c.is_official?"Official":"Mark official"]}),e.jsx(H,{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(st,{className:"w-4 h-4"})})]})]},p))}):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 project pages added yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add a project page URL above to get started"})]})}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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:r,arxivId:d,initialUrl:n,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[m,t]=u.useState(n),N=he(),{toast:j}=pe(),E=u.useRef(!1);u.useEffect(()=>{if(!s){E.current=!1;return}E.current||(E.current=!0,t(n))},[s,n]);const k=fe({mutationFn:async({paperId:F,sourceUrl:I})=>l==="pending"?(await _e({paper_id:parseInt(F),edit_type:"source_url",proposed_payload:{source_url:I}}),null):ga(F,I),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&&Pe(N,F,[r,d]),o==null||o(),a(!1)},onError:F=>{var y;const I=F;let D=I.message||(l==="pending"?"Failed to submit your edit. Please try again.":"Failed to update source URL.");if(I.response)try{const c=JSON.parse(I.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=I.response}j({title:l==="pending"?"Could not submit edit":"Could not save source URL",description:D,variant:"destructive"})}}),P=m.trim(),h=/^https?:\/\//i.test(P),U=P!==(n||"").trim(),T=()=>{h&&k.mutate({paperId:r,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:m,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.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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 gt=100;function Rr(s){return(s??[]).some(a=>a.slug==="coding-agents"||a.name.trim().toLowerCase()==="coding agents")}function ls(s){const a=parseInt(s.task_id,10),r=parseInt(s.dataset_id,10);return!(!Number.isFinite(a)||!Number.isFinite(r)||!s.metric_name.trim()||!s.metric_value.trim())}function Ar(s){return s.map(a=>{const r=a.best_metric||Object.keys(a.metrics)[0],d=a.metrics[r];return{id:a.id,task_id:a.task_id,dataset_id:a.dataset_id,model_name:a.model_name||"",harness:a.harness||"",metric_name:r||"",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 $r(s){const a=new Map;return s.forEach(r=>{r.task_id&&r.task_name&&a.set(r.task_id,{id:r.task_id,name:r.task_name,slug:r.task_slug,level:0})}),a}function Fr(s){const a=new Map;return s.forEach(r=>{r.dataset_id&&r.dataset_name&&a.set(r.dataset_id,{id:r.dataset_id,name:r.dataset_name,slug:r.dataset_slug})}),a}function cs(s,a){return`${s}:${a}`}function Ve(s){const a=s.trim();if(a==="")return null;const r=Number(a);return!Number.isFinite(r)||r<0?null:Math.trunc(r)}function Je(s){const a=s.trim();return a===""?null:a}function Lr({open:s,onOpenChange:a,paperId:r,arxivId:d,initialEvaluations:n,paperTasks:o,onSuccess:l,submitMode:f="direct",isAdmin:m=!1,isAuthor:t=!1}){const N=Rr(o),[j,E]=u.useState([]),[k,P]=u.useState(null),[h,U]=u.useState(new Map),[T,F]=u.useState(new Map),I=he(),{toast:D}=pe(),y=u.useRef(!1),c=u.useRef(!1);u.useEffect(()=>{if(!s){y.current=!1,c.current=!1;return}y.current||c.current||n.length!==0&&(y.current=!0,E(Ar(n)),U($r(n)),F(Fr(n)))},[s,n]);const p=u.useMemo(()=>Array.from(new Set(j.map(g=>g.task_id).filter(g=>g&&g!==""))),[j]),w=u.useMemo(()=>{const g=new Set;return j.forEach(C=>{C.task_id&&C.dataset_id&&g.add(cs(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 R=await as({task_id:parseInt(C),page_size:gt});g[C]=R.results}catch(R){console.error(`Error fetching datasets for task ${C}:`,R),g[C]=[]}})),g},enabled:s&&p.length>0});u.useEffect(()=>{$.data&&F(g=>{const C=new Map(g);return Object.values($.data).forEach(R=>{R.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[R,b]=C.split(":");try{g[C]=await ba(b,R)}catch(_){console.error(`Error fetching metrics for leaderboard ${C}:`,_),g[C]=[]}})),g},enabled:s&&w.length>0}),K=async g=>{const C=await vs({page_size:gt,...g?{q:g}:{}});return U(R=>{const b=new Map(R);return C.results.forEach(_=>b.set(_.id,_)),b}),C.results.map(R=>{var b;return{value:R.id,label:R.name,description:(b=R.description)==null?void 0:b.slice(0,100)}})},G=g=>async C=>{const R=await as({task_id:parseInt(g),page_size:gt,...C?{q:C}:{}});return F(b=>{const _=new Map(b);return R.results.forEach(O=>_.set(O.id,O)),_}),R.results.map(b=>({value:b.id,label:b.name,description:b.full_name}))},X=(g,C)=>{if(!g||!C)return!1;const R=T.get(C);return!!(R!=null&&R.supports_harness)},x=(g,C,R)=>{var O;if(!g||!C)return[];const _=(((O=q.data)==null?void 0:O[cs(g,C)])||[]).map(B=>({value:B.metric_name,label:B.metric_name,description:B.metric_direction==="higher_is_better"?"Higher is better":"Lower is better"}));return R&&!_.some(B=>B.value===R)&&_.unshift({value:R,label:`${R} (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(!ls(_))continue;const B=Ve(_.num_parameters),Z={task_id:parseInt(_.task_id),dataset_id:parseInt(_.dataset_id),metrics:{[_.metric_name]:_.metric_value},best_metric:_.metric_name},Ne=Je(_.hf_model_url);_.model_name&&(Z.model_name=_.model_name),O&&_.harness&&(Z.harness=_.harness),_.best_rank&&(Z.best_rank=parseInt(_.best_rank)),B!=null&&(Z.num_parameters=B),Ne!=null&&(Z.hf_model_url=Ne),Z.is_open=_.is_open,b.push({op:"create",data:Z})}else if(_.operation==="update"&&_.id){const B={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:Ve(_.num_parameters),hf_model_url:Je(_.hf_model_url),is_open:_.is_open};b.push({op:"update",evaluation_id:parseInt(_.id),data:B})}}return b.length===0?{submitted:!1}:(await _e({paper_id:parseInt(g),edit_type:"evaluations",proposed_payload:{operations:b}}),{submitted:!0})}const R=[];for(const b of C)if(b.operation==="delete"&&b.id)R.push({operation:"delete",evaluation_id:parseInt(b.id)});else if(b.operation==="create"){if(!ls(b))continue;const _=X(b.task_id,b.dataset_id),O=Ve(b.num_parameters);R.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:Je(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);R.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:Ve(b.num_parameters),hf_model_url:Je(b.hf_model_url),is_open:b.is_open,harness_set:!0,num_parameters_set:!0,hf_model_url_set:!0}})}if(!m&&R.length>50)throw new Error("Contributor evaluation batches are limited to 50 operations; contact an admin.");return R.length>0&&await xa(parseInt(g),R),{submitted:R.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}I.invalidateQueries({queryKey:["paper-arxiv",d]}),I.invalidateQueries({queryKey:["evaluations","paper",r]}),l==null||l(),a(!1)},onError:g=>{var b;const C=g;let R=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"?R=_.detail:Array.isArray(_==null?void 0:_.detail)&&((b=_.detail[0])!=null&&b.msg)&&(R=_.detail[0].msg)}catch{R=C.response}D({title:f==="pending"?"Could not submit edit":"Could not save evaluations",description:R,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((R,b)=>b===g?{...R,operation:"delete"}:R))}else E(j.filter((R,b)=>b!==g))},S=(g,C,R)=>{c.current=!0,E(j.map((b,_)=>{if(_!==g)return b;const O={...b,[C]:R};return C==="task_id"&&(O.dataset_id="",O.metric_name="",O.harness=""),C==="dataset_id"&&(O.metric_name="",R&&!X(O.task_id,R)&&(O.harness="")),b.operation==="unchanged"&&(O.operation="update"),O}))},Y=(g,C)=>{c.current=!0,E(j.map((R,b)=>{if(b!==g)return R;const _={...R,is_open:C};return R.operation==="unchanged"&&(_.operation="update"),_}))},W=()=>{const g=j.filter(C=>C.operation!=="delete"||C.id);A.mutate({paperId:r,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 R=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(rs,{value:g.task_id,onChange:B=>S(C,"task_id",B),placeholder:"Select task",searchPlaceholder:"Search tasks...",emptyMessage:"No tasks found.",selectedOption:R?{value:R.id,label:R.name}:null,queryKey:["eval-edit-task-search"],queryFn:K,enabled:s})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(rs,{value:g.dataset_id,onChange:B=>S(C,"dataset_id",B),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:B=>S(C,"model_name",B.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:B=>S(C,"harness",B.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:B=>S(C,"metric_name",B.target.value),children:[e.jsx("option",{value:"",children:"Select metric"}),_.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"No configured metrics"})}),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:B=>S(C,"metric_value",B.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:B=>S(C,"num_parameters",B.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:B=>S(C,"hf_model_url",B.target.value),title:"Hugging Face model page for this row (must start with https://huggingface.co/). Leave blank if none."})}),e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx("input",{type:"checkbox",className:"h-4 w-4 align-middle",checked:g.is_open,onChange:B=>Y(C,B.target.checked),title:"Whether the evaluated model is open-source. Uncheck for closed-source models."})}),e.jsx("td",{className:"py-2 px-2",children:e.jsx(H,{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(st,{className:"w-4 h-4"})})})]},C)})})]})}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Wa,{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(H,{variant:"outline",size:"sm",onClick:L,className:"flex items-center space-x-2",children:[e.jsx(tt,{className:"w-4 h-4"}),e.jsx("span",{children:"Add Row"})]})})]}),e.jsxs(me,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2 sm:mr-auto",children:[e.jsx(H,{variant:"ghost",onClick:()=>P("benchmark"),children:"Suggest a new benchmark"}),e.jsx(H,{variant:"ghost",onClick:()=>P("metric"),children:"Suggest a new metric"})]}),e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{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:r,kind:k??"benchmark"})]})}const xt=[{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 ds(s){return s.map(a=>a.trim()).filter(Boolean)}function bt(s,a){const r=ds(s).sort(),d=ds(a).sort();return r.length!==d.length?!1:r.every((n,o)=>n===d[o])}function Tr(s,a){return bt(s.hf_models,a.hf_models)&&bt(s.hf_datasets,a.hf_datasets)&&bt(s.hf_spaces,a.hf_spaces)}function Ur({open:s,onOpenChange:a,paperId:r,arxivId:d,initialArtifacts:n,onSuccess:o,submitMode:l="direct",isAuthor:f=!1}){const[m,t]=u.useState(n),[N,j]=u.useState({hf_models:"",hf_datasets:"",hf_spaces:""}),E=he(),{toast:k}=pe(),P=u.useRef(!1);u.useEffect(()=>{if(!s){P.current=!1;return}P.current||(P.current=!0,t(n),j({hf_models:"",hf_datasets:"",hf_spaces:""}))},[s,n]);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):ja(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&&Pe(E,y,[r,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:[...m.hf_models],hf_datasets:[...m.hf_datasets],hf_spaces:[...m.hf_spaces]};for(const{key:c}of xt){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(m[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)}))},I=()=>{const y=U();if(y===null)return;const c=Object.keys(n).some(p=>n[p].some(w=>!y[p].includes(w)));l==="direct"&&c&&!window.confirm("Remove one or more Hugging Face artifact links?")||h.mutate({paperId:r,artifacts:y})},D=u.useMemo(()=>{const y={hf_models:[...m.hf_models],hf_datasets:[...m.hf_datasets],hf_spaces:[...m.hf_spaces]};for(const{key:c}of xt){const p=N[c].trim();if(p){if(y[c].some(w=>w.trim()===p))return!1;y[c]=[...y[c],p]}}return!Tr(y,n)},[m,N,n]);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:xt.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(H,{onClick:()=>T(y),size:"sm",disabled:!N[y].trim(),children:[e.jsx(tt,{className:"w-4 h-4 mr-1"}),"Add"]})]}),m[y].length>0?e.jsx("div",{className:"space-y-2",children:m[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(H,{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(st,{className:"w-4 h-4"})})]},w))}):e.jsxs("div",{className:"text-xs text-muted-foreground",children:["No ",c.toLowerCase()," linked yet."]})]},y))}),e.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:I,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 Dr=({open:s,onOpenChange:a,paperId:r,initialOrganizationIds:d,submitMode:n,isAuthor:o})=>{var j;const[l,f]=u.useState(d),m=he();u.useEffect(()=>{s&&f(d)},[d,s]);const t=ne({queryKey:["organizations","curation"],queryFn:()=>ya(!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.")||(n==="pending"?await _e({paper_id:Number(r),edit_type:"organizations",proposed_payload:{organization_ids:l}}):await va(r,l))},onSuccess:()=>{m.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."})]}),n==="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.jsxs(me,{children:[e.jsx(H,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(H,{onClick:()=>N.mutate(),disabled:N.isPending,children:n==="pending"?"Submit test edit":"Save changes"})]})]})})},Se=["my-bookmark-ids"];function Mr(){var d,n;const{user:s}=et(),a=ne({queryKey:Se,queryFn:()=>je.getMyBookmarkIds(),enabled:!!s,staleTime:60*1e3,refetchOnWindowFocus:!1}),r=Pt.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:((n=a.data)==null?void 0:n.paper_ids)??[],idSet:r,isLoading:a.isLoading,isError:a.isError}}function Br(){const{user:s}=et(),a=he(),r=fe({mutationFn:async({paperId:n,isBookmarked:o})=>{o?await je.removeBookmark(n):await je.addBookmark(n)},onMutate:async({paperId:n,isBookmarked:o})=>{await a.cancelQueries({queryKey:Se});const l=a.getQueryData(Se),f=typeof n=="string"?Number(n):n,m=(l==null?void 0:l.paper_ids)??[],t=o?m.filter(N=>N!==f):[f,...m.filter(N=>N!==f)];return a.setQueryData(Se,{paper_ids:t}),{previous:l}},onError:(n,o,l)=>{l!=null&&l.previous&&a.setQueryData(Se,l.previous)},onSettled:()=>{a.invalidateQueries({queryKey:Se}),a.invalidateQueries({queryKey:["my-bookmarks"]})}});return{toggle:Pt.useCallback((n,o)=>{if(!s){if(ys())return;const l=typeof window<"u"?window.location.pathname+window.location.search:"/";window.location.href=_s(`/api/v1/auth/hf/login?return_to=${encodeURIComponent(l)}`);return}r.mutate({paperId:n,isBookmarked:o})},[r,s]),isPending:r.isPending}}const Hr=({paperId:s})=>{const{user:a}=et(),{idSet:r}=Mr(),{toggle:d,isPending:n}=Br();if(ys())return null;const o=Number(s),l=!!a&&r.has(o),f=()=>{Number.isFinite(o)&&d(o,l)},m=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:n,"aria-pressed":l,"aria-label":t,title:t,children:[e.jsx(V,{name:"bookmark",size:12}),m]})};function Xe({children:s,showEdit:a=!1,onEdit:r,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:r,"aria-label":d,children:"edit"})]}):s}const qr={"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:ar,get:sr,cancel:tr},"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:er,get:Za,cancel:Ya}};function zr({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(ir,{remarkPlugins:[or],components:{a:({children:a,...r})=>e.jsx("a",{...r,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 Ls({kind:s,paperId:a,paperTitle:r,triggerClassName:d,onComplete:n}){const o=qr[s],[l,f]=u.useState(!1),[m,t]=u.useState(null),[N,j]=u.useState(!1),[E,k]=u.useState(null),P=u.useRef(null),h=(m==null?void 0:m.status)==="queued"||(m==null?void 0:m.status)==="dispatching"||(m==null?void 0:m.status)==="running",U=m==null?void 0:m.id;u.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]),u.useEffect(()=>{(m==null?void 0:m.status)!=="completed"||P.current===m.id||(P.current=m.id,n())},[m,n]);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},I=async()=>{if(m){k(null);try{t(await o.cancel(m.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:(m==null?void 0:m.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(r)})]}),m?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: ",m.status]}),m.hf_job_url&&e.jsx("a",{className:"text-sm underline",href:m.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:[m.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."]}),m.report&&e.jsx(zr,{report:m.report}),m.error&&e.jsx("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:m.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(H,{variant:"outline",onClick:()=>f(!1),children:h?"Close":"Cancel"}),h&&e.jsx(H,{variant:"outline",onClick:()=>void I(),children:"Cancel job"}),!m&&e.jsx(H,{onClick:T,disabled:N,children:N?"Starting…":o.action}),m&&!h&&e.jsx(H,{variant:"outline",onClick:F,children:"Run again"})]})]})]})}function Kr(s){return e.jsx(Ls,{...s,kind:"add-evals",triggerClassName:"edit-link"})}function Or(s){return e.jsx(Ls,{...s,kind:"enrich-paper",triggerClassName:"action-btn"})}var $t="Radio",[Gr,Ts]=St($t),[Qr,Vr]=Gr($t),Us=u.forwardRef((s,a)=>{const{__scopeRadio:r,name:d,checked:n=!1,required:o,disabled:l,value:f="on",onCheck:m,form:t,...N}=s,[j,E]=u.useState(null),k=De(a,U=>E(U)),P=u.useRef(!1),h=j?t||!!j.closest("form"):!0;return e.jsxs(Qr,{scope:r,checked:n,disabled:l,children:[e.jsx(we.button,{type:"button",role:"radio","aria-checked":n,"data-state":Hs(n),"data-disabled":l?"":void 0,disabled:l,value:f,...N,ref:k,onClick:Ue(s.onClick,U=>{n||m==null||m(),h&&(P.current=U.isPropagationStopped(),P.current||U.stopPropagation())})}),h&&e.jsx(Bs,{control:j,bubbles:!P.current,name:d,value:f,checked:n,required:o,disabled:l,form:t,style:{transform:"translateX(-100%)"}})]})});Us.displayName=$t;var Ds="RadioIndicator",Ms=u.forwardRef((s,a)=>{const{__scopeRadio:r,forceMount:d,...n}=s,o=Vr(Ds,r);return e.jsx(gs,{present:d||o.checked,children:e.jsx(we.span,{"data-state":Hs(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:a})})});Ms.displayName=Ds;var Jr="RadioBubbleInput",Bs=u.forwardRef(({__scopeRadio:s,control:a,checked:r,bubbles:d=!0,...n},o)=>{const l=u.useRef(null),f=De(l,o),m=ws(r),t=bs(a);return u.useEffect(()=>{const N=l.current;if(!N)return;const j=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(j,"checked").set;if(m!==r&&k){const P=new Event("click",{bubbles:d});k.call(N,r),N.dispatchEvent(P)}},[m,r,d]),e.jsx(we.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...n,tabIndex:-1,ref:f,style:{...n.style,...t,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Bs.displayName=Jr;function Hs(s){return s?"checked":"unchecked"}var Xr=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],nt="RadioGroup",[Wr]=St(nt,[ks,Ts]),qs=ks(),zs=Ts(),[Yr,Zr]=Wr(nt),Ks=u.forwardRef((s,a)=>{const{__scopeRadioGroup:r,name:d,defaultValue:n,value:o,required:l=!1,disabled:f=!1,orientation:m,dir:t,loop:N=!0,onValueChange:j,...E}=s,k=qs(r),P=_a(t),[h,U]=xs({prop:o,defaultProp:n??null,onChange:j,caller:nt});return e.jsx(Yr,{scope:r,name:d,required:l,disabled:f,value:h,onValueChange:U,children:e.jsx(ka,{asChild:!0,...k,orientation:m,dir:P,loop:N,children:e.jsx(we.div,{role:"radiogroup","aria-required":l,"aria-orientation":m,"data-disabled":f?"":void 0,dir:P,...E,ref:a})})})});Ks.displayName=nt;var Os="RadioGroupItem",Gs=u.forwardRef((s,a)=>{const{__scopeRadioGroup:r,disabled:d,...n}=s,o=Zr(Os,r),l=o.disabled||d,f=qs(r),m=zs(r),t=u.useRef(null),N=De(a,t),j=o.value===n.value,E=u.useRef(!1);return u.useEffect(()=>{const k=h=>{Xr.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(wa,{asChild:!0,...f,focusable:!l,active:j,children:e.jsx(Us,{disabled:l,required:o.required,checked:j,...m,...n,name:o.name,ref:N,onCheck:()=>o.onValueChange(n.value),onKeyDown:Ue(k=>{k.key==="Enter"&&k.preventDefault()}),onFocus:Ue(n.onFocus,()=>{var k;E.current&&((k=t.current)==null||k.click())})})})});Gs.displayName=Os;var en="RadioGroupIndicator",Qs=u.forwardRef((s,a)=>{const{__scopeRadioGroup:r,...d}=s,n=zs(r);return e.jsx(Ms,{...n,...d,ref:a})});Qs.displayName=en;var Vs=Ks,Js=Gs,tn=Qs;const Nt=u.forwardRef(({className:s,...a},r)=>e.jsx(Vs,{className:Ye("grid gap-2",s),...a,ref:r}));Nt.displayName=Vs.displayName;const Le=u.forwardRef(({className:s,...a},r)=>e.jsx(Js,{ref:r,className:Ye("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(tn,{className:"flex items-center justify-center",children:e.jsx(Na,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Le.displayName=Js.displayName;const sn={model:"Model",dataset:"Dataset",space:"Space",github:"GitHub"},Ct=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function jt(s){return"'"+s.replace(/'/g,`'"'"'`)+"'"}function vt(s,a){try{const r=new URL(s);if(r.hostname!=="huggingface.co")return null;const d=r.pathname.split("/").filter(Boolean),n=a==="model"?[]:[`${a}s`];if(n.length&&d[0]!==n[0])return null;const o=d.slice(n.length,n.length+2);if(o.length!==2||o.some(m=>!Ct.test(m)))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 an(s){try{const a=new URL(s);if(a.hostname!=="github.com"&&a.hostname!=="www.github.com")return null;const r=a.pathname.split("/").filter(Boolean);if(r.length<2)return null;const d=r[0],n=r[1].replace(/\.git$/,"");if(!Ct.test(d)||!Ct.test(n))return null;const o=`${d}/${n}`;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 rn({githubUrls:s,hfModelUrls:a,hfDatasetUrls:r,hfSpaceUrls:d}){const n=[...a.map(l=>vt(l,"model")),...r.map(l=>vt(l,"dataset")),...d.map(l=>vt(l,"space")),...s.map(an)],o=new Set;return n.filter(l=>!l||o.has(l.id)?!1:(o.add(l.id),!0))}function nn(s,a,r){const d=["# Requires the Hugging Face CLI: https://huggingface.co/docs/huggingface_hub/guides/cli",`HF_BUCKET=${jt(s.trim())}`];r.create&&d.push(`hf buckets create "$HF_BUCKET" --exist-ok${r.isPrivate?" --private":""}`);for(const o of a.filter(l=>l.kind!=="github"))d.push(`hf cp ${jt(o.source)} "hf://buckets/$HF_BUCKET/${o.destination}"`);const n=a.filter(o=>o.kind==="github");if(n.length){d.push('PWC_COPY_DIR="$(mktemp -d)"',`trap 'rm -rf "$PWC_COPY_DIR"' EXIT`);for(const o of n){const l=`$PWC_COPY_DIR/${o.destination.replace(/\/$/,"")}`;d.push(`git clone --depth 1 -- ${jt(o.source)} "${l}"`,`hf sync "${l}" "hf://buckets/$HF_BUCKET/${o.destination}" --exclude '.git/**'`)}}return d.join(` -`)}function on(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 ln(s){const{toast:a}=pe(),r=u.useMemo(()=>rn(s),[s.githubUrls,s.hfDatasetUrls,s.hfModelUrls,s.hfSpaceUrls]),[d,n]=u.useState(!1),[o,l]=u.useState("new"),[f,m]=u.useState(""),[t,N]=u.useState("public"),[j,E]=u.useState(()=>new Set(r.map(I=>I.id))),k=r.filter(I=>j.has(I.id)),P=/^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/.test(f.trim()),h=nn(f,k,{create:o==="new",isPrivate:t==="private"}),U=(I,D)=>{E(y=>{const c=new Set(y);return D?c.add(I):c.delete(I),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(r.map(I=>I.id))),!f&&s.suggestedBucketId&&m(s.suggestedBucketId),n(!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:r.length?`${r.length} linked artifact${r.length===1?"":"s"}`:"No linked artifacts yet"})]}),e.jsx(oe,{open:d,onOpenChange:n,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."})]}),r.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(Nt,{value:o,onValueChange:I=>l(I),className:"grid grid-cols-2 gap-2",children:[e.jsxs(re,{className:"bucket-choice",children:[e.jsx(Le,{value:"new"}),"New bucket"]}),e.jsxs(re,{className:"bucket-choice",children:[e.jsx(Le,{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:I=>m(I.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(Nt,{value:t,onValueChange:I=>N(I),className:"flex gap-5",children:[e.jsxs(re,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Le,{value:"public"}),"Public"]}),e.jsxs(re,{className:"flex items-center gap-2 font-normal",children:[e.jsx(Le,{value:"private"}),"Private"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{children:"Artifacts"}),e.jsx("div",{className:"bucket-artifact-list",children:r.map(I=>e.jsxs("div",{className:"bucket-artifact-row",children:[e.jsx(rt,{id:`bucket-artifact-${I.id}`,checked:j.has(I.id),onCheckedChange:D=>U(I.id,D===!0)}),e.jsxs(re,{htmlFor:`bucket-artifact-${I.id}`,className:"min-w-0 flex-1 cursor-pointer font-normal",children:[e.jsx("span",{className:"bucket-artifact-kind",children:sn[I.kind]}),e.jsx("span",{className:"bucket-artifact-name",children:I.label})]}),e.jsxs("a",{href:I.url,target:"_blank",rel:"noopener noreferrer",className:"bucket-artifact-open",children:[I.kind==="github"?"Open":"Web copy",e.jsx(V,{name:"external",size:10})]})]},I.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(H,{type:"button",onClick:T,disabled:!P||k.length===0,children:[e.jsx(V,{name:"copy",size:12}),"Copy commands"]})]})]})})]})}const cn={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"},We=360,yt=3,us=3,dn=["tldr","abstract","tasks","methods","results"];function un(s){if(!s)return{section:null,resultsTaskSlug:null};const[a,r]=s.split("?",2);if(!dn.includes(a))return{section:null,resultsTaskSlug:null};const d=a;return d!=="results"||!r?{section:d,resultsTaskSlug:null}:{section:d,resultsTaskSlug:new URLSearchParams(r).get("task")}}function ms(s){return`results-task-${s}`}function mn(s){return`#results?task=${encodeURIComponent(s)}`}function $e({id:s,label:a,accent:r}){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})}),r]})}function hs(s){if(!s)return"—";try{return new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function ps(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}function fs(s,a){try{const r=new URL(s),n=r.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);return n?n.replace(/[-_]+/g," "):r.hostname.replace(/^www\./,"")}catch{return a}}const Hn=()=>{var Vt,Jt,Xt,Wt,Yt,Zt,es,ts,ss;const{arxivId:s}=Ca(),a=s?Ea(s):"",r=Sa(),{toast:d}=pe(),{user:n}=et(),o=(n==null?void 0:n.is_admin)??!1,l=!!n,f=lr(n),m=!0,{data:t,isLoading:N,error:j,refetch:E}=Qa(a||"",!!a),[k,P]=u.useState(!1);u.useEffect(()=>{if(!s||s===a)return;const i=window.location.search+window.location.hash;r(`/paper/${a}${i}`,{replace:!0})},[a,r,s]),u.useEffect(()=>{if(t!=null&&t.title)return document.title=Oa(t.title),()=>{document.title=Ga}},[t==null?void 0:t.title]),u.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}=fr(k?t==null?void 0:t.arxiv_id:void 0),{data:T,isLoading:F,refetch:I}=ur(t==null?void 0:t.id,k&&!!(t!=null&&t.id));u.useEffect(()=>{const i=()=>{E(),I(),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 your changes 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,I,d]);const{preferences:D}=Pa(),y=u.useMemo(()=>!T||!D.hide_closed_source_evals?T:T.filter(i=>i.is_open!==!1),[T,D.hide_closed_source_evals]),c=u.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=u.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:fs(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=u.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]),$=u.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(_s(`/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]=u.useState(!1),[x,A]=u.useState(!1),[L,M]=u.useState(!1),S=u.useRef(!1);u.useEffect(()=>{S.current=!1},[a]),u.useEffect(()=>{let i=0;const v=(Q=!1,ae=!1)=>{const{section:J,resultsTaskSlug:se}=un(window.location.hash.slice(1));if(!J||!t||J==="tldr"&&!t.tldr||J==="results"&&(!k||F)||!Q&&S.current)return;let Ee=null;if(J==="results"&&se){if(Ee=document.getElementById(ms(se)),!Ee){if(w.find(ca=>ca.taskSlug===se))return;Ee=document.getElementById("results")}}else Ee=document.getElementById(J);if(!Ee)return;const la=Ee;i=window.requestAnimationFrame(()=>{S.current=!0,la.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:R,setIsEditingRepositories:b,isEditingProjectPages:_,setIsEditingProjectPages:O,isEditingEvaluations:B,setIsEditingEvaluations:Z,isEditingSourceUrl:Ne,setIsEditingSourceUrl:Me,isEditingHfArtifacts:it,setIsEditingHfArtifacts:Be,isEditingOrganizations:ot,setIsEditingOrganizations:He}=gr();u.useEffect(()=>{f!=="direct"||!(t!=null&&t.id)||((Y||g||R||_||Ne||it||ot)&&je.primePaperCurationState(t.id).catch(()=>{}),B&&je.primeEvaluationCurationState(t.id).catch(()=>{}))},[f,B,it,g,ot,_,R,Ne,Y,t==null?void 0:t.id]);const[lt,Ft]=u.useState(null);u.useEffect(()=>{var z;if(!n||!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:()=>Be(!0),organizations:()=>He(!0),source_url:()=>Me(!0)};(z=v[i])==null||z.call(v)},[t,Z,Be,He,C,O,b,Me,W,n]);const ge=u.useMemo(()=>{if(!n||!(t!=null&&t.author_links))return!1;const i=n.username.toLowerCase();return t.author_links.some(v=>!!v.hf_username&&v.hf_username.toLowerCase()===i)},[n,t==null?void 0:t.author_links]),ee=i=>{if(!l){Ft(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":Be(!0);return;case"organizations":He(!0);return;case"source-url":Me(!0);return}},[Lt,ct]=u.useState("idle"),[Tt,Ut]=u.useState(null),[Dt,Mt]=u.useState(null),Xs=async()=>{if(a){ct("indexing"),Ut(null),Mt(null);try{await Ta(a),d({title:"Indexed",description:"Paper added to database."}),setTimeout(()=>E(),1200),ct("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}Ut(z),(v.status===429||v.status===503)&&Mt("Try again later after arXiv has lifted the temporary limit."),ct("idle")}}},{citationDisplay:Ws,citationCopy:Bt}=u.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]),Ht=u.useMemo(()=>cr(t==null?void 0:t.leaderboard_ranks),[t==null?void 0:t.leaderboard_ranks]),[Ys,qt]=u.useState(!1),Zs=async()=>{if(Bt)try{await navigator.clipboard.writeText(Bt),qt(!0),d({title:"Citation copied",description:"BibTeX entry copied to clipboard."}),window.setTimeout(()=>qt(!1),1500)}catch{d({title:"Copy failed",description:"Could not access the clipboard. Please copy manually.",variant:"destructive"})}},ea=async()=>{if(!t)return;const i=t.arxiv_id||t.id,v=dr(i,Ht);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(Fe,{className:"h-12 w-3/4 mb-4"}),e.jsx(Fe,{className:"h-6 w-1/3 mb-8"}),e.jsx(Fe,{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."]}),Tt&&e.jsx(Va,{variant:"destructive",className:"mt-4 max-w-xl",children:e.jsxs(Ja,{children:[e.jsx("div",{children:Tt}),Dt&&e.jsx("div",{className:"mt-2",children:Dt})]})}),e.jsxs("div",{className:"action-row",children:[o&&e.jsxs("button",{className:"action-btn",onClick:Xs,disabled:Lt==="indexing",children:[e.jsx(V,{name:"sparkle",size:12}),Lt==="indexing"?"Indexing…":"Index from arXiv"]}),e.jsx(H,{variant:"outline",onClick:()=>r("/papers"),children:"Browse Papers"})]})]});const zt=q.data||[],Ie=Ka(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)}),ta=L?xe:xe.slice(0,yt),dt={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)??[]])]},ut=((Vt=t.arxiv_id)==null?void 0:Vt.replace(/v\d+$/,""))??null,mt=t.arxiv_id?{isLoading:U,paperHref:`https://huggingface.co/papers/${ut}`,rows:[{label:"Models",href:kt(`https://huggingface.co/models?other=arxiv:${t.arxiv_id}`,c.models),count:wt(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:kt(`https://huggingface.co/datasets?other=arxiv:${t.arxiv_id}`,c.datasets),count:wt(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:kt(`https://huggingface.co/papers/${ut}`,c.spaces),count:wt(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/${ut} in a HF README to link it here.`}:{isLoading:!1,paperHref:null,rows:[{label:"Models",href:_t(c.models),count:c.models.length,links:p.models},{label:"Datasets",href:_t(c.datasets),count:c.datasets.length,links:p.datasets},{label:"Spaces",href:_t(c.spaces),count:c.spaces.length,links:p.spaces}],footer:null},Kt=t.tldr||null,Ot=t.num_pages||null,Ce=t.abstract||"",sa=Ce.length>We?Ce.slice(0,We)+"…":Ce,aa=G||Ce.length<=We?Ce:sa,qe=(t.methods||[]).filter(i=>i.source_paper_id===t.id),ze=t.introduced_benchmarks||[],Re=t.introduced_frameworks||[],ra=qe.length>0||ze.length>0||Re.length>0,Gt=t.arxiv_id?`arXiv:${t.arxiv_id}`:"External resource",na=t.source==="external"?"Source page":"arXiv page",Ae=((Jt=t.project_pages)==null?void 0:Jt.filter(i=>i.url))??[],ia=(()=>{const i=[];return qe.length>0&&i.push(qe.length===1?"this method":"these methods"),ze.length>0&&i.push(ze.length===1?"this benchmark":"these benchmarks"),Re.length>0&&i.push(Re.length===1?"this framework":"these frameworks"),i.length===0?"":i.length===1?i[0]:i.join(" and ")})(),Ke=t.predecessor_papers||[],Oe=t.successor_papers||[],oa=Ke.length>0||Oe.length>0,Ge=12,ht=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}}),Qt=x||ht.length<=Ge?ht:ht.slice(0,Ge);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:Gt})]}),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(Qe,{title:t.title})}),e.jsxs("div",{className:"detail-meta",children:[e.jsx("span",{children:Gt}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["Submitted ",hs(t.published)]}),Ot&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Ot," 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}$/,"")})]}),zt.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&&r(`/paper/${t.arxiv_id.replace(/v\d+$/,"")}${v?`?version=${v}`:""}`)},children:zt.map(i=>e.jsxs("option",{value:i.version,children:[i.version," — ",hs(i.published)]},i.version))})]})]}),e.jsxs("div",{className:"detail-authors",children:[Qt.map((i,v)=>e.jsxs(Pt.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}),vGe&&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-Ge} 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(Xe,{showEdit:t.source==="external"&&m,onEdit:()=>ee("source-url"),editAriaLabel:"Edit source URL",children:e.jsxs("a",{className:t.source==="external"&&m?"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})," ",na]})}),mt.paperHref&&(h==null?void 0:h.paperExists)&&e.jsxs("a",{className:"bm-action-btn",href:mt.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(Xe,{showEdit:m,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:["· ",ps(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"]}),Ae.length===1?e.jsx(Xe,{showEdit:m,onEdit:()=>ee("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs("a",{className:"action-btn-segment action-btn-main",href:Ae[0].url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(V,{name:"globe",size:12})," Project page"]})}):null,Ae.length>1?e.jsx(Xe,{showEdit:m,onEdit:()=>ee("project-pages"),editAriaLabel:"Edit project pages",children:e.jsxs(Ia,{children:[e.jsx(Ra,{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(Aa,{align:"start",className:"project-page-menu",children:Ae.map((i,v)=>e.jsx($a,{asChild:!0,children:e.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",children:fs(i.url,`Project page ${v+1}`)})},i.url))})]})}):null,Ae.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&&rr()&&e.jsx(Or,{paperId:t.id,paperTitle:t.title,onComplete:()=>void E()}),e.jsx(Hr,{paperId:t.id})]}),t.leaderboard_ranks&&t.leaderboard_ranks.length>0&&e.jsx(Ua,{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(Da,{paperId:t.arxiv_id||t.id,title:t.title,thumbnailUrl:Fa(t.thumbnail_url),priority:!0})})]}),ra&&e.jsxs("div",{className:`introduced-banner${Re.length>0?" introduced-banner--framework":""}`,children:[e.jsx("span",{className:"introduced-label",children:"Introduced"}),e.jsxs("div",{className:"introduced-methods",children:[qe.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>r(`/methods/${i.slug||i.id}`),children:[i.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`method-${i.id}`)),ze.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>r(`/benchmark/${i.slug||i.id}`),children:[i.name,e.jsx("span",{className:"introduced-arrow",children:"→"})]},`benchmark-${i.id}`)),Re.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill",onClick:()=>r(`/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 ",ia,"."]})]}),oa&&e.jsxs("div",{className:"introduced-banner lineage-banner",children:[Oe.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Oe.length===1?"Follow-up paper":"Follow-up papers"}),e.jsx("div",{className:"introduced-methods",children:Oe.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>r(`/paper/${i.route_identifier}`),children:[e.jsx(Qe,{title:i.title}),e.jsx("span",{className:"introduced-arrow",children:"→"})]},`successor-${i.id}`))})]}),Ke.length>0&&e.jsxs("div",{className:"lineage-row",children:[e.jsx("span",{className:"introduced-label lineage-label",children:Ke.length===1?"Predecessor paper":"Predecessor papers"}),e.jsx("div",{className:"introduced-methods",children:Ke.map(i=>e.jsxs("button",{type:"button",className:"introduced-pill lineage-pill",onClick:()=>r(`/paper/${i.route_identifier}`),children:[e.jsx("span",{className:"introduced-arrow lineage-arrow-back",children:"←"}),e.jsx(Qe,{title:i.title})]},`predecessor-${i.id}`))})]})]}),Kt&&e.jsxs(e.Fragment,{children:[e.jsx($e,{id:"tldr",label:"TL;DR · AI-generated"}),e.jsx("div",{className:"tldr-box",children:Kt})]}),e.jsx($e,{id:"abstract",label:"Abstract"}),e.jsx("p",{className:"abstract-text",style:{marginBottom:8},children:e.jsx(za,{text:aa})}),Ce.length>We&&e.jsx("div",{className:"read-full",onClick:()=>X(i=>!i),children:G?"− collapse abstract":"+ read full abstract"}),e.jsx($e,{id:"tasks",label:"Tasks",accent:e.jsxs("span",{className:"accent",children:[((Xt=t.tasks)==null?void 0:Xt.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(Ma,{slug:i.slug||"",label:i.name},i.id))}),e.jsx($e,{id:"methods",label:"Methods",accent:e.jsxs("span",{className:"accent",children:[((Wt=t.methods)==null?void 0:Wt.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(Ba,{method:i},i.id))}),e.jsx($e,{id:"results",label:"Results",accent:e.jsxs("span",{className:"accent",children:[(y==null?void 0:y.length)||0," benchmarks",Ht.length>0&&e.jsxs("button",{type:"button",className:"edit-link results-badge-copy",onClick:ea,title:"Copy live leaderboard badges for your repository README",children:[e.jsx(V,{name:"copy",size:10})," Copy PwC badge"]}),o&&nr()&&e.jsx(Kr,{paperId:t.id,paperTitle:t.title,onComplete:()=>void I()}),e.jsx("button",{type:"button",onClick:()=>ee("results"),className:"edit-link",children:"edit"})]})}),F?e.jsx(Fe,{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?ms(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:mn(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(Ha,{}),(v.external??v.is_external)&&e.jsx(qa,{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:La((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"})]})]}),ta.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:["★ ",ps(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>yt&&e.jsx("button",{type:"button",className:"bench-show-more",onClick:()=>M(i=>!i),children:L?"− show top 3":`+ show ${xe.length-yt} more repos`})]}),e.jsx(hn,{viewer:mt,onEdit:()=>ee("hf-artifacts")}),e.jsx(ln,{githubUrls:xe.map(i=>i.url),hfModelUrls:dt.models,hfDatasetUrls:dt.datasets,hfSpaceUrls:dt.spaces,suggestedBucketId:n?`${n.username}/${on(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&&(((Yt=K.data)==null?void 0:Yt.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(Qe,{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:Zs,"aria-label":"Copy citation to clipboard",title:"Copy citation to clipboard",children:[e.jsx(V,{name:"copy",size:11}),Ys?"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:Ws})]})]})]}),e.jsx(wr,{open:Y,onOpenChange:W,paperId:t.id,arxivId:a,initialTaskIds:((Zt=t.tasks)==null?void 0:Zt.map(i=>parseInt(i.id)))||[],initialTasks:t.tasks||[],submitMode:f,isAuthor:ge}),e.jsx(Er,{open:g,onOpenChange:C,paperId:t.id,arxivId:a,initialMethodIds:((es=t.methods)==null?void 0:es.map(i=>parseInt(i.id)))||[],initialMethods:t.methods||[],submitMode:f,isAuthor:ge}),e.jsx(Sr,{open:R,onOpenChange:b,paperId:t.id,arxivId:a,initialRepositories:((ts=t.repositories)==null?void 0:ts.map(i=>({url:i.url,is_official:i.is_official||!1})))||[],submitMode:f,isAuthor:ge}),e.jsx(Pr,{open:_,onOpenChange:O,paperId:t.id,arxivId:a,initialProjectPages:((ss=t.project_pages)==null?void 0:ss.map(i=>({url:i.url,is_official:i.is_official||!1})))||[],submitMode:f,isAuthor:ge}),e.jsx(Lr,{open:B,onOpenChange:Z,paperId:t.id,arxivId:a,initialEvaluations:T||[],paperTasks:t.tasks||[],submitMode:f,isAdmin:o,isAuthor:ge}),e.jsx(Ir,{open:Ne,onOpenChange:Me,paperId:t.id,arxivId:a,initialUrl:t.source_url??t.url_abs??"",submitMode:f,isAuthor:ge}),e.jsx(Ur,{open:it,onOpenChange:Be,paperId:t.id,arxivId:a,initialArtifacts:{hf_models:c.models,hf_datasets:c.datasets,hf_spaces:c.spaces},submitMode:f,isAuthor:ge}),e.jsx(Dr,{open:ot,onOpenChange:He,paperId:t.id,initialOrganizationIds:(t.organizations||[]).map(i=>Number(i.id)),submitMode:f,isAuthor:ge}),e.jsx(Xa,{open:lt!==null,onOpenChange:i=>{i||Ft(null)},sectionLabel:lt?cn[lt]:"this paper",returnTo:typeof window<"u"?window.location.pathname:"/"})]})},hn=({viewer:s,onEdit:a})=>e.jsxs("div",{className:"sidebar-card",children:[e.jsxs("div",{className:"sidebar-card-title",children:[s.paperHref?e.jsx("a",{href:s.paperHref,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:"🤗 Hugging Face"}):e.jsx("span",{children:"🤗 Hugging Face"}),e.jsx("button",{type:"button",onClick:a,className:"edit-link",children:"edit"})]}),s.isLoading?e.jsx(Fe,{className:"h-16 w-full"}):e.jsxs(e.Fragment,{children:[s.rows.map(r=>e.jsx(pn,{...r},r.label)),s.footer&&e.jsx("div",{style:{fontFamily:"var(--mono)",fontSize:10,color:"var(--ink-faint)",marginTop:12},children:s.footer})]})]}),pn=({label:s,href:a,count:r,isLimited:d,links:n})=>{const[o,l]=u.useState(!1),f=((n==null?void 0:n.length)??0)>0,m=((n==null?void 0:n.length)??0)>us,t=o?n:n==null?void 0:n.slice(0,us),N=r!=null?`${r}${d?"+":""}`:"—",j=r?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)),m&&e.jsx("button",{type:"button",className:"hf-artifact-toggle","aria-expanded":o,onClick:()=>l(E=>!E),children:o?"Show fewer":`View all ${n.length}`})]})]})};function _t(s){return s[0]??"https://huggingface.co"}function kt(s,a){return a[0]??s}function wt(s,a,r){if(r==null&&s.length===0&&!(a!=null&&a.length))return;const d=new Set([...s,...a??[]]);return Math.max(r??0,d.size)}export{Hn as default};