import{_ as lt,u as ct,a1 as ot,r as k,j as n,L as re,a7 as Y,n as dt,a0 as ut,a as se}from"./index-BzfLml0t.js";import{u as ne}from"./useQuery-B9_VgOir.js";import{S as we}from"./skeleton-DWgX1Pkq.js";import{S as Be}from"./switch-DpPI0p8D.js";import{A as mt,a as ht}from"./alert-ByP9KeSr.js";import{L as me}from"./LatexTitle-becjMI_d.js";import{I as ft}from"./components-Bt8j-Ti3.js";import{C as pt,E as gt}from"./ExternalSourceEvalBadge-BlE3UtwF.js";import"./index-B5MqrQjo.js";import"./katex.min-BSBacQyE.js";import"./transform-DGxuYrgz.js";function xt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const r=document.implementation.createHTMLDocument(),s=r.createElement("base"),i=r.createElement("a");return r.head.appendChild(s),r.body.appendChild(i),t&&(s.href=t),i.href=e,i.href}const yt=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function V(e){const t=[];for(let r=0,s=e.length;rF||e.height>F)&&(e.width>F&&e.height>F?e.width>e.height?(e.height*=F/e.width,e.width=F):(e.width*=F/e.height,e.height=F):e.width>F?(e.height*=F/e.width,e.width=F):(e.width*=F/e.height,e.height=F))}function kt(e,t={}){return e.toBlob?new Promise(r=>{e.toBlob(r,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(r=>{const s=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),i=s.length,a=new Uint8Array(i);for(let o=0;o{const s=new Image;s.onload=()=>{s.decode().then(()=>{requestAnimationFrame(()=>t(s))})},s.onerror=r,s.crossOrigin="anonymous",s.decoding="async",s.src=e})}async function St(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function _t(e,t,r){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg"),a=document.createElementNS(s,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${r}`),i.setAttribute("viewBox",`0 0 ${t} ${r}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),i.appendChild(a),a.appendChild(e),St(i)}const M=(e,t)=>{if(e instanceof t)return!0;const r=Object.getPrototypeOf(e);return r===null?!1:r.constructor.name===t.name||M(r,t)};function Ct(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function Et(e,t){return Ye(t).map(r=>{const s=e.getPropertyValue(r),i=e.getPropertyPriority(r);return`${r}: ${s}${i?" !important":""};`}).join(" ")}function Rt(e,t,r,s){const i=`.${e}:${t}`,a=r.cssText?Ct(r):Et(r,s);return document.createTextNode(`${i}{${a}}`)}function He(e,t,r,s){const i=window.getComputedStyle(e,r),a=i.getPropertyValue("content");if(a===""||a==="none")return;const o=yt();try{t.className=`${t.className} ${o}`}catch{return}const c=document.createElement("style");c.appendChild(Rt(o,r,i,s)),t.appendChild(c)}function $t(e,t,r){He(e,t,":before",r),He(e,t,":after",r)}const Ve="application/font-woff",We="image/jpeg",Nt={woff:Ve,woff2:Ve,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:We,jpeg:We,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Tt(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function _e(e){const t=Tt(e).toLowerCase();return Nt[t]||""}function Mt(e){return e.split(/,/)[1]}function Se(e){return e.search(/^(data:)/)!==-1}function Ft(e,t){return`data:${t};base64,${e}`}async function et(e,t,r){const s=await fetch(e,t);if(s.status===404)throw new Error(`Resource "${s.url}" not found`);const i=await s.blob();return new Promise((a,o)=>{const c=new FileReader;c.onerror=o,c.onloadend=()=>{try{a(r({res:s,result:c.result}))}catch(u){o(u)}},c.readAsDataURL(i)})}const ve={};function Lt(e,t,r){let s=e.replace(/\?.*/,"");return r&&(s=e),/ttf|otf|eot|woff2?/i.test(s)&&(s=s.replace(/.*\//,"")),t?`[${t}]${s}`:s}async function Ce(e,t,r){const s=Lt(e,t,r.includeQueryParams);if(ve[s]!=null)return ve[s];r.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const a=await et(e,r.fetchRequestInit,({res:o,result:c})=>(t||(t=o.headers.get("Content-Type")||""),Mt(c)));i=Ft(a,t)}catch(a){i=r.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;a&&(o=typeof a=="string"?a:a.message),o&&console.warn(o)}return ve[s]=i,i}async function At(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):fe(t)}async function Pt(e,t){if(e.currentSrc){const a=document.createElement("canvas"),o=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,o==null||o.drawImage(e,0,0,a.width,a.height);const c=a.toDataURL();return fe(c)}const r=e.poster,s=_e(r),i=await Ce(r,s,t);return fe(i)}async function It(e,t){var r;try{if(!((r=e==null?void 0:e.contentDocument)===null||r===void 0)&&r.body)return await pe(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Dt(e,t){return M(e,HTMLCanvasElement)?At(e):M(e,HTMLVideoElement)?Pt(e,t):M(e,HTMLIFrameElement)?It(e,t):e.cloneNode(tt(e))}const Bt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",tt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Ht(e,t,r){var s,i;if(tt(t))return t;let a=[];return Bt(e)&&e.assignedNodes?a=V(e.assignedNodes()):M(e,HTMLIFrameElement)&&(!((s=e.contentDocument)===null||s===void 0)&&s.body)?a=V(e.contentDocument.body.childNodes):a=V(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),a.length===0||M(e,HTMLVideoElement)||await a.reduce((o,c)=>o.then(()=>pe(c,r)).then(u=>{u&&t.appendChild(u)}),Promise.resolve()),t}function Vt(e,t,r){const s=t.style;if(!s)return;const i=window.getComputedStyle(e);i.cssText?(s.cssText=i.cssText,s.transformOrigin=i.transformOrigin):Ye(r).forEach(a=>{let o=i.getPropertyValue(a);a==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),M(e,HTMLIFrameElement)&&a==="display"&&o==="inline"&&(o="block"),a==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),s.setProperty(a,o,i.getPropertyPriority(a))})}function Wt(e,t){M(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),M(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function Ot(e,t){if(M(e,HTMLSelectElement)){const r=t,s=Array.from(r.children).find(i=>e.value===i.getAttribute("value"));s&&s.setAttribute("selected","")}}function Ut(e,t,r){return M(t,Element)&&(Vt(e,t,r),$t(e,t,r),Wt(e,t),Ot(e,t)),t}async function qt(e,t){const r=e.querySelectorAll?e.querySelectorAll("use"):[];if(r.length===0)return e;const s={};for(let a=0;aDt(s,t)).then(s=>Ht(e,s,t)).then(s=>Ut(e,s,t)).then(s=>qt(s,t))}const rt=/url\((['"]?)([^'"]+?)\1\)/g,zt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Gt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Kt(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Qt(e){const t=[];return e.replace(rt,(r,s,i)=>(t.push(i),r)),t.filter(r=>!Se(r))}async function Xt(e,t,r,s,i){try{const a=r?xt(t,r):t,o=_e(t);let c;return i||(c=await Ce(a,o,s)),e.replace(Kt(t),`$1${c}$3`)}catch{}return e}function Jt(e,{preferredFontFormat:t}){return t?e.replace(Gt,r=>{for(;;){const[s,,i]=zt.exec(r)||[];if(!i)return"";if(i===t)return`src: ${s};`}}):e}function st(e){return e.search(rt)!==-1}async function nt(e,t,r){if(!st(e))return e;const s=Jt(e,r);return Qt(s).reduce((a,o)=>a.then(c=>Xt(c,o,t,r)),Promise.resolve(s))}async function J(e,t,r){var s;const i=(s=t.style)===null||s===void 0?void 0:s.getPropertyValue(e);if(i){const a=await nt(i,null,r);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function Yt(e,t){await J("background",e,t)||await J("background-image",e,t),await J("mask",e,t)||await J("-webkit-mask",e,t)||await J("mask-image",e,t)||await J("-webkit-mask-image",e,t)}async function Zt(e,t){const r=M(e,HTMLImageElement);if(!(r&&!Se(e.src))&&!(M(e,SVGImageElement)&&!Se(e.href.baseVal)))return;const s=r?e.src:e.href.baseVal,i=await Ce(s,_e(s),t);await new Promise((a,o)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...u)=>{try{a(t.onImageErrorHandler(...u))}catch(g){o(g)}}:o;const c=e;c.decode&&(c.decode=a),c.loading==="lazy"&&(c.loading="eager"),r?(e.srcset="",e.src=i):e.href.baseVal=i})}async function er(e,t){const s=V(e.childNodes).map(i=>at(i,t));await Promise.all(s).then(()=>e)}async function at(e,t){M(e,Element)&&(await Yt(e,t),await Zt(e,t),await er(e,t))}function tr(e,t){const{style:r}=e;t.backgroundColor&&(r.backgroundColor=t.backgroundColor),t.width&&(r.width=`${t.width}px`),t.height&&(r.height=`${t.height}px`);const s=t.style;return s!=null&&Object.keys(s).forEach(i=>{r[i]=s[i]}),e}const Oe={};async function Ue(e){let t=Oe[e];if(t!=null)return t;const s=await(await fetch(e)).text();return t={url:e,cssText:s},Oe[e]=t,t}async function qe(e,t){let r=e.cssText;const s=/url\(["']?([^"')]+)["']?\)/g,a=(r.match(/url\([^)]+\)/g)||[]).map(async o=>{let c=o.replace(s,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),et(c,t.fetchRequestInit,({result:u})=>(r=r.replace(o,`url(${u})`),[o,u]))});return Promise.all(a).then(()=>r)}function ze(e){if(e==null)return[];const t=[],r=/(\/\*[\s\S]*?\*\/)/gi;let s=e.replace(r,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const u=i.exec(s);if(u===null)break;t.push(u[0])}s=s.replace(i,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(o,"gi");for(;;){let u=a.exec(s);if(u===null){if(u=c.exec(s),u===null)break;a.lastIndex=c.lastIndex}else c.lastIndex=a.lastIndex;t.push(u[0])}return t}async function rr(e,t){const r=[],s=[];return e.forEach(i=>{if("cssRules"in i)try{V(i.cssRules||[]).forEach((a,o)=>{if(a.type===CSSRule.IMPORT_RULE){let c=o+1;const u=a.href,g=Ue(u).then(f=>qe(f,t)).then(f=>ze(f).forEach(w=>{try{i.insertRule(w,w.startsWith("@import")?c+=1:i.cssRules.length)}catch(x){console.error("Error inserting rule from remote css",{rule:w,error:x})}})).catch(f=>{console.error("Error loading remote css",f.toString())});s.push(g)}})}catch(a){const o=e.find(c=>c.href==null)||document.styleSheets[0];i.href!=null&&s.push(Ue(i.href).then(c=>qe(c,t)).then(c=>ze(c).forEach(u=>{o.insertRule(u,o.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",a)}}),Promise.all(s).then(()=>(e.forEach(i=>{if("cssRules"in i)try{V(i.cssRules||[]).forEach(a=>{r.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${i.href}`,a)}}),r))}function sr(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>st(t.style.getPropertyValue("src")))}async function nr(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=V(e.ownerDocument.styleSheets),s=await rr(r,t);return sr(s)}function it(e){return e.trim().replace(/["']/g,"")}function ar(e){const t=new Set;function r(s){(s.style.fontFamily||getComputedStyle(s).fontFamily).split(",").forEach(a=>{t.add(it(a))}),Array.from(s.children).forEach(a=>{a instanceof HTMLElement&&r(a)})}return r(e),t}async function ir(e,t){const r=await nr(e,t),s=ar(e);return(await Promise.all(r.filter(a=>s.has(it(a.style.fontFamily))).map(a=>{const o=a.parentStyleSheet?a.parentStyleSheet.href:null;return nt(a.cssText,o,t)}))).join(` `)}async function lr(e,t){const r=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await ir(e,t);if(r){const s=document.createElement("style"),i=document.createTextNode(r);s.appendChild(i),e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s)}}async function cr(e,t={}){const{width:r,height:s}=Ze(e,t),i=await pe(e,t,!0);return await lr(i,t),await at(i,t),tr(i,t),await _t(i,r,s)}async function or(e,t={}){const{width:r,height:s}=Ze(e,t),i=await cr(e,t),a=await fe(i),o=document.createElement("canvas"),c=o.getContext("2d"),u=t.pixelRatio||vt(),g=t.canvasWidth||r,f=t.canvasHeight||s;return o.width=g*u,o.height=f*u,t.skipAutoScale||jt(o),o.style.width=`${g}`,o.style.height=`${f}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,o.width,o.height)),c.drawImage(a,0,0,o.width,o.height),o}async function dr(e,t={}){const r=await or(e,t);return await kt(r)}const Ge="#ffffff";function ur(e){if(typeof window>"u")return Ge;const t=window.getComputedStyle(e).backgroundColor;return!t||t==="rgba(0, 0, 0, 0)"||t==="transparent"?Ge:t}async function mr(e){var r,s;if(typeof window>"u"||!((s=(r=window.navigator)==null?void 0:r.clipboard)!=null&&s.write))throw new Error("Clipboard image copy is not supported in this browser.");if(typeof window.ClipboardItem>"u")throw new Error("Clipboard image copy is not supported in this browser.");const t=await dr(e,{pixelRatio:2,cacheBust:!0,backgroundColor:ur(e)});if(!t)throw new Error("Failed to render screenshot.");await window.navigator.clipboard.write([new window.ClipboardItem({"image/png":t})])}const hr=5;function fr(e){if(!e)return null;const t=e.trim(),r=t.match(/^https?:\/\/(?:www\.)?arxiv\.org\/(?:abs|pdf)\/([^/?#]+)/i);if(r!=null&&r[1])return r[1].replace(/\.pdf$/i,"");const s=t.match(/^(?:https?:\/\/(?:www\.)?paperswithcode\.co)?\/paper\/([^/?#]+)/i);return(s==null?void 0:s[1])??null}function ue(e,t){return e?n.jsx(me,{title:e}):t||"—"}function Ke(e){const t=e.length===7?`${e}-01`:e,r=new Date(t).getTime();return Number.isFinite(r)?r:0}const je=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ke(e){const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth()}}function pr(e,t){if(e===t){const{year:u,month:g}=ke(e);return[{timestamp:new Date(u,g,1).getTime(),key:`${u}-${g}`,label:`${je[g]} ${u}`}]}const r=ke(e),s=ke(t);if(r.year===s.year){const u=s.month-r.month+1;let g=1;const f=12;u>f&&(g=Math.ceil(u/f));const w=[];for(let x=r.month;x<=s.month;x+=g)w.push({timestamp:new Date(r.year,x,1).getTime(),key:`${r.year}-${x}`,label:u<=3?`${je[x]} ${r.year}`:je[x]});return w}const i=s.year-r.year+1;let a=1;const o=12;i>o&&(a=Math.ceil(i/o));const c=[];for(let u=r.year;u<=s.year;u+=a)c.push({timestamp:new Date(u,0,1).getTime(),key:String(u),label:String(u)});return c}const gr=({points:e,metric:t})=>{const r=ut(),[s,i]=k.useState(null),a=880,o=320,c=60,u=30,g=40,f=50,w=e.map(l=>l.value),x=Math.min(...w),W=Math.max(...w)-x||1,ie=a-c-u,T=o-g-f,L=e.map(l=>Ke(l.date)),O=Math.min(...L),G=Math.max(...L),A=G-O||1,le=l=>O===G?c+ie/2:c+(l-O)/A*ie,B=e.map((l,m)=>{const _=le(Ke(l.date)),y=(l.value-x)/W,C=g+T*(1-y);return{x:_,y:C,data:l,idx:m}}),v=B.filter(l=>l.data.isSota);let K="";if(v.length>=2){K=`M${v[0].x},${v[0].y}`;for(let l=1;l{const m=l.data.modelName||l.data.paperTitle||"";if(!m)return null;const _=m.length>22?m.slice(0,21)+"…":m,y=_.length*b;let C=l.x-y/2,R=l.x+y/2,P="middle";return Ca-u&&(R=a-u,C=R-y,P="end"),{x:P==="start"?c:P==="end"?a-u:l.x,y:l.y-U,text:_,anchor:P,left:C,right:R}},Q=[],I=v.length>0?H(v[v.length-1]):null;let ce=-1/0;for(let l=0;lI.left-ge||(ce=m.right,Q.push({x:m.x,y:m.y,text:m.text,anchor:m.anchor})))}I&&Q.push({x:I.x,y:I.y,text:I.text,anchor:I.anchor});const oe=pr(O,G),q=5,S=l=>i(m=>m===l?null:m),z=l=>{l&&r(`/paper/${l}`)},Z=(l,m)=>{const y=`${l.data.modelName||l.data.paperTitle||"Unknown model"}: ${Y(l.data.value)} on ${l.data.dateLabel}`,C=!!l.data.paperRouteId;return n.jsxs("g",{children:[m,n.jsx("circle",{cx:l.x,cy:l.y,r:"10",fill:"transparent",style:{cursor:C?"pointer":"default",outline:"none"},tabIndex:0,role:C?"link":"img","aria-label":y,onMouseEnter:()=>i(l.idx),onMouseLeave:()=>S(l.idx),onFocus:()=>i(l.idx),onBlur:()=>S(l.idx),onClick:()=>z(l.data.paperRouteId),onKeyDown:R=>{C&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),z(l.data.paperRouteId))},children:n.jsx("title",{children:y})})]},l.idx)};return n.jsxs("svg",{width:"100%",viewBox:`0 0 ${a} ${o}`,style:{display:"block"},children:[n.jsx("text",{x:c-38,y:g+T/2,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"middle",transform:`rotate(-90 ${c-38} ${g+T/2})`,children:t}),Array.from({length:q}).map((l,m)=>{const _=m/(q-1),y=g+T*(1-_),C=x+W*_;return n.jsxs("g",{children:[n.jsx("line",{x1:c,y1:y,x2:a-u,y2:y,stroke:"var(--hairline)",strokeWidth:"1"}),n.jsx("text",{x:c-10,y:y+4,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-faint)",textAnchor:"end",children:Y(C)})]},m)}),oe.map(l=>{const m=le(l.timestamp);return n.jsx("text",{x:m,y:o-f+18,fontSize:"11",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:"middle",children:l.label},l.key)}),B.filter(l=>!l.data.isSota).map(l=>{const m=s===l.idx;return Z(l,n.jsx("circle",{cx:l.x,cy:l.y,r:m?3:2,fill:"var(--ink-faint)",opacity:m?1:.45,style:{transition:"r 0.12s ease, opacity 0.12s ease"}}))}),K&&n.jsx("path",{d:K,stroke:"var(--accent)",strokeWidth:"2",fill:"none",strokeLinejoin:"round",strokeLinecap:"round"}),v.map(l=>{const m=s===l.idx;return Z(l,n.jsx("circle",{cx:l.x,cy:l.y,r:m?4.5:3,fill:m?"var(--accent)":"var(--bg-elevated)",stroke:"var(--accent)",strokeWidth:"1.5",style:{transition:"r 0.12s ease, fill 0.12s ease"}}))}),Q.map((l,m)=>n.jsx("text",{x:l.x,y:l.y,fontSize:"9.5",fontFamily:"var(--mono)",fill:"var(--ink-soft)",textAnchor:l.anchor,pointerEvents:"none",style:{paintOrder:"stroke",stroke:"var(--bg-elevated)",strokeWidth:3,strokeLinejoin:"round"},children:l.text},`label-${m}`)),s!==null&&B[s]&&(()=>{const l=B[s],m=l.data.modelName||l.data.paperTitle||"Unknown model",y=`${m.length>40?m.slice(0,39)+"…":m}: ${Y(l.data.value)}`,R=Math.max(120,Math.min(340,y.length*6.6+24)),P=30;let D=l.x-R/2;Da-u&&(D=a-u-R);const ee=l.y-P-14>=g?l.y-P-12:l.y+12;return n.jsxs("g",{pointerEvents:"none",children:[n.jsx("rect",{x:D,y:ee,width:R,height:P,rx:"6",ry:"6",fill:"var(--bg-elevated)",stroke:"var(--hairline-strong)",strokeWidth:"1",style:{filter:"drop-shadow(0 2px 6px rgba(0,0,0,0.08))"}}),n.jsx("text",{x:D+12,y:ee+19,fontSize:"12",fontFamily:"var(--sans)",fill:"var(--ink)",fontWeight:500,children:y})]})})()]})};function ae(e){if(e==null)return null;if(typeof e=="number")return Number.isFinite(e)?e:null;const t=e.includes("±")?e.split("±")[0].trim():e.trim(),r=parseFloat(t);return Number.isFinite(r)?r:null}function xr(e){return[e.paper_id,e.task_id,e.dataset_id,e.model_name,e.harness??""].join("|")}function yr(e){const t=new Map;for(const r of e){const s=xr(r),i=t.get(s);if(!i){t.set(s,{...r,metrics:{...r.metrics||{}},sourceEvaluationIds:[r.id],ranksByMetric:r.best_metric&&r.best_rank!=null?{[r.best_metric]:r.best_rank}:{}});continue}i.metrics={...i.metrics,...r.metrics||{}},i.sourceEvaluationIds.push(r.id),r.best_metric&&r.best_rank!=null&&(i.ranksByMetric[r.best_metric]=r.best_rank)}return Array.from(t.values())}function Qe(e,t){return t?e.id===t||e.sourceEvaluationIds.includes(t):!1}function Xe(e,t){return e.ranksByMetric[t]??e.best_rank??9999}function br(e,t,r){if(e.length===0)return{points:[],sota:0,sotaModel:""};const s=e.map(f=>{var N;const w=ae((N=f.metrics)==null?void 0:N[t]),x=f.paper_published_date||"";return{eval:f,value:w,date:x}}).filter(f=>f.value!==null&&!!f.date).sort((f,w)=>f.date.localeCompare(w.date)),i=[];let a=null;for(const f of s){const w=a==null?!0:r==="↓"?f.valuea;w&&(a=f.value),i.push({value:f.value,date:f.date,dateLabel:f.date.slice(0,7),modelName:f.eval.model_name||"",paperTitle:f.eval.paper_title||"",paperRouteId:f.eval.paper_arxiv_id||f.eval.paper_id||null,isSota:w})}const c=e.map(f=>{var w;return{eval:f,value:ae((w=f.metrics)==null?void 0:w[t])}}).filter(f=>f.value!==null).sort((f,w)=>r==="↓"?f.value-w.value:w.value-f.value)[0],u=(c==null?void 0:c.value)??0,g=(c==null?void 0:c.eval.model_name)||(c==null?void 0:c.eval.paper_title)||"";return{points:i,sota:u,sotaModel:g}}const Je=({targetRef:e,label:t})=>{const{toast:r}=dt(),[s,i]=k.useState("idle"),a=k.useRef(null);k.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=k.useCallback(async()=>{const u=e.current;if(u){i("copying"),u.classList.add("is-capturing"),u.offsetHeight,await new Promise(g=>window.requestAnimationFrame(()=>g()));try{await mr(u),i("copied"),r({title:"Screenshot copied",description:`Image of the ${t} copied to your clipboard.`}),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>i("idle"),1500)}catch(g){i("idle"),r({title:"Copy failed",description:g instanceof Error&&g.message?g.message:"Could not copy the screenshot to your clipboard.",variant:"destructive"})}finally{u.classList.remove("is-capturing")}}},[e,t,r]),c=s==="copied"?"Copied":s==="copying"?"Copying…":"Copy image";return n.jsxs("button",{type:"button",className:"bm-copy-btn",onClick:o,disabled:s==="copying","aria-label":`Copy ${t} screenshot to clipboard`,title:`Copy ${t} screenshot to clipboard`,children:[n.jsx(ft,{name:"copy",size:11}),c]})},Tr=()=>{var D,xe,ee,Ee,Re,$e,Ne,Te,Me,Fe;const{datasetSlug:e}=lt(),[t]=ct(),r=t.get("task")||void 0,s=t.get("eval")||void 0,{preferences:i,setHideClosedSourceEvals:a}=ot(),[o,c]=k.useState(void 0),u=k.useRef(null),g=k.useRef(!1),f=k.useRef(null),w=k.useRef(null),x=ne({queryKey:["dataset",e,"with-paper"],queryFn:()=>se.getDatasetBySlug(e,{include_paper:!0}),enabled:!!e,staleTime:10*60*1e3}),N=ne({queryKey:["dataset-evals",(D=x.data)==null?void 0:D.id],queryFn:()=>se.getEvaluationsByDataset(x.data.id),enabled:!!((xe=x.data)!=null&&xe.id),staleTime:5*60*1e3}),W=ne({queryKey:["dataset-tasks",(ee=x.data)==null?void 0:ee.id],queryFn:()=>se.getDatasetTasks(x.data.id),enabled:!!((Ee=x.data)!=null&&Ee.id),staleTime:10*60*1e3}),ie=ne({queryKey:["metric-directions"],queryFn:()=>se.getMetricDirections(),staleTime:60*60*1e3}),T=k.useMemo(()=>{var d;return!s||!((d=N.data)!=null&&d.length)?null:N.data.find(p=>p.id===s)||null},[s,N.data]),L=k.useMemo(()=>{const d=W.data||[];if(d.length===0)return null;if(T!=null&&T.task_id&&d.some(h=>h.id===T.task_id))return T.task_id;if(r){const h=d.find(E=>E.slug===r);if(h)return h.id}if(d.length===1)return d[0].id;const p=N.data||[];if(p.length>0){const h=new Map;for(const j of p)h.set(j.task_id,(h.get(j.task_id)||0)+1);let E=null,$=-1;for(const j of d){const te=h.get(j.id)||0;te>$&&($=te,E=j.id)}if(E)return E}return d[0].id},[W.data,N.data,r,T]),O=ne({queryKey:["leaderboard-metrics",(Re=x.data)==null?void 0:Re.id,L],queryFn:()=>se.getLeaderboardMetrics(x.data.id,L),enabled:!!(($e=x.data)!=null&&$e.id)&&!!L,staleTime:10*60*1e3}),G=k.useMemo(()=>{let d=N.data||[];return i.hide_closed_source_evals&&(d=d.filter(p=>p.is_open!==!1)),L?d.filter(p=>p.task_id===L):d},[N.data,L,i.hide_closed_source_evals]),A=k.useMemo(()=>yr(G),[G]),le=k.useMemo(()=>{const d=new Set;return A.forEach(p=>{p.best_metric&&d.add(p.best_metric),Object.keys(p.metrics||{}).forEach(h=>d.add(h))}),Array.from(d)},[A]),B=k.useMemo(()=>(O.data||[]).map(d=>d.metric_name),[O.data]),v=B.length?B:le,K=k.useMemo(()=>{var E;if(A.length===0)return v[0]||"";const d=new Map;for(const $ of A)for(const j of Object.keys($.metrics||{}))B.length&&!v.includes(j)||d.set(j,(d.get(j)||0)+1);let p=null,h=0;for(const[$,j]of d)j>h&&(h=j,p=$);return p||v[0]||((E=A[0])==null?void 0:E.best_metric)||""},[A,v,B]),b=o||(T==null?void 0:T.best_metric)||K,U=(((Te=(Ne=ie.data)==null?void 0:Ne.directions)==null?void 0:Te[b])||"higher_is_better")==="lower_is_better"?"↓":"↑",H=k.useMemo(()=>!b||!v.includes(b)?v:[b,...v.filter(d=>d!==b)],[v,b]),Q=k.useMemo(()=>H.length===0?b?[b]:[]:H.slice(0,hr),[H,b]),{points:I,sota:ce,sotaModel:oe}=k.useMemo(()=>br(A,b,U),[A,b,U]);k.useEffect(()=>{if(g.current||!s||!N.data||N.data.length===0)return;const d=u.current;d&&(g.current=!0,d.scrollIntoView({behavior:"smooth",block:"start"}))},[s,N.data]);const q=k.useMemo(()=>{const d=W.data||[];return L?d.find(p=>p.id===L)||d[0]||null:d[0]||null},[W.data,L]);if(x.isLoading)return n.jsxs("div",{className:"page",children:[n.jsx(we,{className:"h-12 w-1/2 mb-6"}),n.jsx(we,{className:"h-64 w-full"})]});if(x.error||!x.data)return n.jsx("div",{className:"page",children:n.jsx(mt,{variant:"destructive",children:n.jsx(ht,{children:"Benchmark not found."})})});const S=x.data,z=A.slice().sort((d,p)=>{var $,j;const h=ae(($=d.metrics)==null?void 0:$[b]),E=ae((j=p.metrics)==null?void 0:j[b]);return h!==null&&E!==null?U==="↓"?h-E:E-h:h!==null?-1:E!==null?1:Xe(d,b)-Xe(p,b)}),Z=!!S.supports_harness,l=s&&z.find(d=>Qe(d,s))||null,m=S.introducing_paper??void 0,_=(m==null?void 0:m.arxiv_id)||(m==null?void 0:m.id)||fr(S.paper_url),y=(m==null?void 0:m.title)||S.introducing_paper_title||null,C=((Me=m==null?void 0:m.published)==null?void 0:Me.slice(0,4))||S.introduced_year||null,R=!!_||!!S.paper_url||!!y,P=m!=null&&m.arxiv_id||(Fe=S.paper_url)!=null&&Fe.match(/^https?:\/\/(?:www\.)?arxiv\.org\//i)?`arXiv:${_}`:`Paper ${_}`;return n.jsx("div",{className:"page",children:n.jsxs("div",{className:"bm-page",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx(re,{to:"/tasks",children:"Tasks"}),q&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sep",children:"/"}),n.jsx(re,{to:`/tasks/${q.slug||q.id}`,children:q.name})]}),n.jsx("span",{className:"sep",children:"/"}),n.jsx("span",{style:{color:"var(--accent-text)"},children:S.name})]}),n.jsx("h1",{className:"bm-title",children:S.name}),n.jsxs("div",{className:"bm-subtitle",style:{display:"flex",alignItems:"center",gap:16,flexWrap:"wrap"},children:[n.jsxs("span",{children:[b&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"metric-tag",children:b}),n.jsx("span",{style:{color:"var(--hairline-strong)",margin:"0 8px"},children:"·"})]}),oe?n.jsxs("span",{children:["Best: ",n.jsx("span",{className:"best-name",children:Y(ce)})," by ",n.jsx("span",{className:"best-name",style:{fontStyle:"normal"},children:oe})]}):n.jsxs("span",{children:[z.length," evaluations"]})]}),S.hf_url&&n.jsxs("a",{className:"bm-action-btn",href:S.hf_url,target:"_blank",rel:"noopener noreferrer",children:[n.jsx("span",{"aria-hidden":"true",children:"🤗"})," View on Hugging Face"]})]}),S.description&&n.jsx("p",{style:{fontFamily:"var(--serif)",color:"var(--ink-soft)",maxWidth:760,marginBottom:16},children:S.description}),R&&n.jsxs("div",{className:"method-source",style:{marginTop:0,marginBottom:18},children:[n.jsx("span",{className:"method-source-label",children:"Source"}),_?n.jsxs(re,{to:`/paper/${_}`,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[n.jsx("span",{className:"method-source-title",children:y?n.jsx(me,{title:y}):P}),C&&n.jsx("span",{className:"method-source-meta",children:C})]}):S.paper_url?n.jsxs("a",{href:S.paper_url,target:"_blank",rel:"noopener noreferrer",className:"method-source-link",children:[n.jsx("span",{className:"method-source-title",children:y?n.jsx(me,{title:y}):S.paper_url}),C&&n.jsx("span",{className:"method-source-meta",children:C})]}):n.jsxs("div",{className:"method-source-link is-static",children:[n.jsx("span",{className:"method-source-title",children:y?n.jsx(me,{title:y}):null}),C&&n.jsx("span",{className:"method-source-meta",children:C})]})]}),I.filter(d=>d.isSota).length>=2&&n.jsxs("div",{className:"bm-card",ref:f,children:[n.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[n.jsxs("div",{className:"bm-card-screenshot-title",children:[n.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),n.jsx("span",{className:"bm-card-screenshot-name",children:S.name})]}),n.jsxs("div",{className:"bm-card-screenshot-brand",children:[n.jsxs("span",{className:"brand",children:[n.jsx("span",{className:"brand-mark"}),n.jsxs("span",{className:"brand-name",children:["Papers ",n.jsx("em",{children:"With Code"})]})]}),n.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),n.jsxs("div",{className:"bm-card-head",children:[n.jsx("div",{className:"bm-card-title",children:"SOTA progression"}),n.jsxs("div",{className:"bm-card-actions",children:[v.length>1&&n.jsxs("label",{className:"bm-view-select",children:[n.jsx("span",{className:"bm-view-select-label",children:"View"}),n.jsx("select",{value:b,onChange:d=>c(d.target.value),children:H.map(d=>n.jsx("option",{value:d,children:d},d))})]}),n.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[n.jsx(Be,{className:"bm-closed-toggle-switch",checked:!i.hide_closed_source_evals,onCheckedChange:d=>{a(!d)},"aria-label":"Show closed-source models"}),n.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),n.jsx(Je,{targetRef:f,label:"SOTA chart"})]})]}),n.jsx("div",{className:"bm-chart-wrap",children:n.jsx(gr,{points:I,metric:b})}),n.jsxs("div",{className:"bm-chart-foot",children:[n.jsx("span",{className:"legend-dot"}),"All models over time · highlighted dots track the running best · hover for the model · click to open the paper"]})]}),l&&(()=>{var $,j;const d=l.paper_arxiv_id||l.paper_id,p=l.paper_title||(l.paper_arxiv_id?`arXiv:${l.paper_arxiv_id}`:null),h=l.best_metric&&(($=l.metrics)==null?void 0:$[l.best_metric])!==void 0?l.best_metric:b,E=(j=l.metrics)==null?void 0:j[h];return n.jsxs("div",{className:"bm-highlight-banner",role:"status",children:[n.jsx("span",{className:"bm-highlight-dot","aria-hidden":"true"}),n.jsxs("div",{className:"bm-highlight-text",children:[n.jsx("span",{className:"bm-highlight-label",children:"Comparing result"}),n.jsxs("span",{className:"bm-highlight-paper",children:[l.model_name||p||"—",l.harness?` · ${l.harness}`:""]}),n.jsxs("span",{className:"bm-highlight-meta",children:[E!==void 0&&h?n.jsxs(n.Fragment,{children:[h,": ",Y(E),p?" · ":""]}):null,d?n.jsx(re,{to:`/paper/${d}`,children:ue(l.paper_title,p)}):ue(l.paper_title,p)]})]})]})})(),n.jsxs("div",{className:"bm-card",ref:w,children:[n.jsxs("div",{className:"bm-card-screenshot-header","aria-hidden":"true",children:[n.jsxs("div",{className:"bm-card-screenshot-title",children:[n.jsx("span",{className:"bm-card-screenshot-eyebrow",children:"Benchmark"}),n.jsx("span",{className:"bm-card-screenshot-name",children:S.name})]}),n.jsxs("div",{className:"bm-card-screenshot-brand",children:[n.jsxs("span",{className:"brand",children:[n.jsx("span",{className:"brand-mark"}),n.jsxs("span",{className:"brand-name",children:["Papers ",n.jsx("em",{children:"With Code"})]})]}),n.jsx("span",{className:"bm-card-screenshot-url",children:"paperswithcode.co"})]})]}),n.jsxs("div",{className:"bm-card-head",children:[n.jsx("div",{className:"bm-card-title",children:"Leaderboard"}),n.jsxs("div",{className:"bm-card-actions",children:[v.length>1&&n.jsxs("label",{className:"bm-view-select",children:[n.jsx("span",{className:"bm-view-select-label",children:"View"}),n.jsx("select",{value:b,onChange:d=>c(d.target.value),children:H.map(d=>n.jsx("option",{value:d,children:d},d))})]}),n.jsxs("label",{className:"bm-closed-toggle",title:"Show or hide evaluations of closed-source models",children:[n.jsx(Be,{className:"bm-closed-toggle-switch",checked:!i.hide_closed_source_evals,onCheckedChange:d=>{a(!d)},"aria-label":"Show closed-source models"}),n.jsx("span",{className:"bm-closed-toggle-label",children:"Closed-source"})]}),n.jsx(Je,{targetRef:w,label:"leaderboard"})]})]}),N.isLoading?n.jsx("div",{style:{padding:16},children:Array.from({length:5}).map((d,p)=>n.jsx(we,{className:"h-10 w-full mb-2"},p))}):z.length===0?n.jsx("div",{className:"no-results",children:"No evaluations submitted yet."}):n.jsx("div",{className:"bm-table-scroll",children:n.jsxs("table",{className:"bm-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:"col-rank",children:"Rank"}),n.jsx("th",{className:"col-model",children:"Model"}),Z&&n.jsx("th",{className:"col-harness",children:"Harness"}),Q.map(d=>{const p=d===b;return n.jsx("th",{className:`col-value ${p?"is-active":""}`,"aria-sort":p?U==="↓"?"ascending":"descending":"none",children:n.jsxs("button",{type:"button",className:"bm-metric-header",onClick:()=>c(d),"aria-pressed":p,title:`Sort by ${d}`,children:[d,p?` ${U}`:""]})},d)}),n.jsx("th",{className:"col-paper",children:"Paper"}),n.jsx("th",{className:"col-year",children:"Year"})]})}),n.jsx("tbody",{children:(()=>{let d=null,p=0;return z.map((h,E)=>{var Ae,Pe;const $=ae((Ae=h.metrics)==null?void 0:Ae[b]);let j=null;$!==null&&((d===null||$!==d)&&(p=E+1,d=$),j=p);const te=h.paper_arxiv_id||h.paper_id,Le=h.paper_title||(h.paper_arxiv_id?`arXiv:${h.paper_arxiv_id}`:null),ye=Qe(h,s);return n.jsxs("tr",{ref:ye?u:void 0,className:ye?"is-highlighted":void 0,children:[n.jsx("td",{className:"col-rank",children:j??"—"}),n.jsxs("td",{className:"col-model",children:[ye&&n.jsx("span",{className:"bm-row-marker","aria-hidden":"true"}),h.hf_model_url?n.jsx("a",{href:h.hf_model_url,target:"_blank",rel:"noopener noreferrer",className:"bm-model-link",title:`Open ${h.model_name||"model"} on Hugging Face`,children:h.model_name||"—"}):h.model_name||"—",h.is_open===!1&&n.jsx(pt,{}),(h.external??h.is_external)&&n.jsx(gt,{sourceUrl:h.source_url||h.external_source_url||h.result_url})]}),Z&&n.jsx("td",{className:"col-harness",children:h.harness||"—"}),Q.map(be=>{var De;const Ie=be===b,de=(De=h.metrics)==null?void 0:De[be];return n.jsx("td",{className:`col-value${Ie?" is-active":""}${Ie&&j===1?" is-best":""}`,children:de!=null&&de!==""?Y(de):"—"},be)}),n.jsx("td",{className:"col-paper",children:te?n.jsx(re,{to:`/paper/${te}`,children:ue(h.paper_title,Le)}):ue(h.paper_title,Le)}),n.jsx("td",{className:"col-year",children:((Pe=h.paper_published_date)==null?void 0:Pe.slice(0,4))||"—"})]},h.id)})})()})]})})]})]})})};export{Tr as default};