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