1import{j as t,e as Ct,o as qe,a0 as _t,r as Ce,a as _e,w as Qe,M as Tt,d as he,t as We,v as Ge,S as ze,i as Je,p as Ze,a1 as et}from"./index.C_jEAofg.js";/* empty css */import{r as n,d as Rt}from"./reactRouter.C6cvQAHO.js";import"./PackItem.D5eL2g8B.js";import{P as Ot}from"./PlayerCard.CPf5AheA.js";import"./packcard.CmgWfOZs.js";import{F as At,S as Lt,R as Et}from"./SortIcon.CYuzrCM8.js";import{S as Ut,a as It}from"./SortDescIcon.CZKLl-Qm.js";import{R as tt}from"./RewindIcon.Bj9w8ogu.js";import{a as Vt}from"./entityMeta.DRNc0NpJ.js";/* empty css *//* empty css */import{u as ot}from"./i18n.BxWiIRpk.js";/* empty css */import{V as Kt}from"./VirtualList.CE9jB2m0.js";import{C as Xt}from"./levelcreditseditpopup.Bv94erU-.js";import{C as de}from"./Select.BO5et_f4.js";import{S as Bt}from"./ScrollButton.BuRsjz3s.js";import{C as Ht}from"./CreatorAssignmentPopup.CKsZyxTT.js";import"./sortable.esm.CFCmxV-Q.js";import"./recharts.DzmhKP_O.js";import"./dnd.esm.Cdkn9E5v.js";import"./raf-schd.esm.Do3U_zjQ.js";import"./DownloadIcon.DjUIGIn8.js";import"./InfoIcon.D6E0BSOK.js";import"./DragHandleIcon.DD8FtFny.js";import"./FolderIcon.C9FyMAKL.js";import"./SongSelectorPopup.DKzLh1D3.js";import"./WebAdofaiViewerButton.B_YDorpM.js";import"./CreatorStatusBadge.BebQkP3q.js";import"./verificationStates.C-65KJT3.js";import"./MarkdownText.L8wnX1BN.js";import"./ExternalLink.Dqxd3OTW.js";import"./EditLevelPopup.DRNO7Nwl.js";import"./RefreshIcon.C6h3Vb3d.js";import"./GraphIcon.CYoVe_gk.js";import"./ChartIcon.D6Na6YlP.js";import"./RatingInput.DaDmVNeA.js";import"./LevelUploadManagementPopup.D_Jm9B8a.js";import"./toastMessage.BnceMJYi.js";import"./levelselectionpopup.XTKS7ydm.js";import"./LevelSelectionPopup.BM_HqWse.js";import"./levelHelpers.CkOxyFNP.js";import"./passJudgementHitCount.Ccm5-J09.js";import"./communityTags.D2n_4RPi.js";import"./ItemPickManager.ByW3m6Qa.js";import"./TrashIcon.BeVW0keM.js";import"./useUnsavedClose.DBVfPN3-.js";/* empty css *//* empty css */import"./useVideoLinkResolver.CRdJO4N2.js";import"./resolveVideoUrl.CQLZGZ0c.js";/* empty css */import"./AdminLevelXaccCurvePopup.CEc05nAv.js";import"./XaccPassPickerJudgementStrip.RmYhi90o.js";import"./statFormatters.D_f0oQsy.js";import"./AdminReasonPrompt.DCSPFRYl.js";/* empty css */import"./SearchHelpPopup.BSQYCqH7.js";import"./EditIcon.C3zEPxhx.js";import"./PackIcon.BLDIeBiY.js";import"./TimeIcon.C24S6xSS.js";import"./LikeButton.JOd7Q3w3.js";import"./LikeIcon.DMlP2VPj.js";import"./curationTypeUtils.UzM-6L0y.js";import"./PlusIcon.CBMb1dFY.js";import"./SearchIcon.qDkSL_MV.js";import"./ImageIcon.CKUsHZmQ.js";import"./uploadErrors.BuoBavFt.js";import"./ImageSelectorPopup.sFab1OF6.js";import"./packRefUtils.Ch95Re_b.js";/* empty css */import"./TagConfidenceBar.kbpMl9x7.js";import"./MarqueeText.C_DzVbgp.js";import"./TUFStellarIcon.C48VmVKL.js";import"./CreatorIcon.D9igEVbR.js";import"./EyeIcon.B3GYw7db.js";import"./rateLimitError.ByypYhRt.js";import"./CurationTypeSelector.CbUjpZdk.js";import"./profileIconSlots.D8bRZ9GW.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};r.SENTRY_RELEASE={id:"aec9389561908f1f1b5366362ca3b629220ab900"},r._sentryModuleMetadata=r._sentryModuleMetadata||{},r._sentryModuleMetadata[new r.Error().stack]=function(o){for(var d=1;d<arguments.length;d++){var h=arguments[d];if(h!=null)for(var m in h)h.hasOwnProperty(m)&&(o[m]=h[m])}return o}({},r._sentryModuleMetadata[new r.Error().stack],{"_sentryBundlerPluginAppKey:tuf-website":!0});var l=new r.Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="9b4e74db-aecb-430d-8993-9af02a6fc817",r._sentryDebugIdIdentifier="sentry-dbid-9b4e74db-aecb-430d-8993-9af02a6fc817")}catch{}})();const rt=({values:r=[0,100],decimals:l=0,suffix:o="",onChange:d,onChangeComplete:h,min:m=0,max:y=100,step:_=1,minLabel:H="Min",maxLabel:F="Max"})=>{const $=n.useRef(null),[v,K]=n.useState(!1),[k,j]=n.useState(null),[U,L]=n.useState(null),[ee,c]=n.useState(null),[p,C]=n.useState(r),[X,E]=n.useState([r[0].toFixed(l),r[1].toFixed(l)]);n.useEffect(()=>{v||C(e=>r[0]!==e[0]||r[1]!==e[1]?(E([r[0].toFixed(l),r[1].toFixed(l)]),r):e)},[r[0],r[1],v,l]);const Y=n.useCallback(e=>Math.max(m,Math.min(y,Math.round(e/_)*_)),[m,y,_]),B=n.useCallback(e=>(e-m)/(y-m)*100,[m,y]),le=n.useCallback(e=>m+e/100*(y-m),[m,y]),M=n.useCallback(e=>{if(!v||k===null||!$.current)return;const a=e.touches?e.touches[0].clientX:e.clientX,f=$.current.getBoundingClientRect().width,x=y-m,N=a-U,V=Math.round(N/f*x/_)*_,z=Y(ee+V),P=[...p];P[k]=z,k===0&&z>p[1]?P[0]=p[1]:k===1&&z<p[0]&&(P[1]=p[0]),C(P),E([P[0].toFixed(l),P[1].toFixed(l)]),d==null||d(P)},[v,k,U,ee,p,m,y,_,l,d,Y]),w=n.useCallback(()=>
1{if(v){const e=[Math.min(p[0],p[1]),Math.max(p[0],p[1])];C(e),E([e[0].toFixed(l),e[1].toFixed(l)]),d==null||d(e),h==null||h(e),K(!1),j(null),L(null),c(null)}},[v,p,l,d,h]);n.useEffect(()=>(v&&(window.addEventListener("mousemove",M),window.addEventListener("mouseup",w),window.addEventListener("touchmove",M),window.addEventListener("touchend",w)),()=>{window.removeEventListener("mousemove",M),window.removeEventListener("mouseup",w),window.removeEventListener("touchmove",M),window.removeEventListener("touchend",w)}),[v,M,w]);const R=n.useCallback(e=>{if(!$.current||v)return;const a=$.current.getBoundingClientRect(),i=e.touches?e.touches[0].clientX:e.clientX,x=Math.min(Math.max(0,i-a.left),a.width)/a.width*100,N=Y(le(x)),V=Math.abs(p[0]-N),z=Math.abs(p[1]-N),P=V<=z?0:1,J=[...p];J[P]=N;const te=[Math.min(J[0],J[1]),Math.max(J[0],J[1])];C(te),E([te[0].toFixed(l),te[1].toFixed(l)]),d==null||d(te),h==null||h(te)},[v,p,l,d,h,Y,le]),T=n.useCallback((e,a)=>{a.preventDefault(),K(!0),j(e);const i=a.touches?a.touches[0].clientX:a.clientX;L(i),c(p[e])},[p]),oe=n.useCallback((e,a)=>{const i=[...X];i[e]=a,E(i)},[X]),I=n.useCallback(e=>{const a=X[e],i=a===""?0:parseFloat(a);if(isNaN(i)){E(N=>{const V=[...N];return V[e]=p[e].toFixed(l),V});return}const f=Y(i),x=[...p];x[e]=f,e===0&&f>p[1]?x[0]=p[1]:e===1&&f<p[0]&&(x[1]=p[0]),C(x),E([x[0].toFixed(l),x[1].toFixed(l)]),d==null||d(x),h==null||h(x)},[X,p,l,d,h,Y]),ie=B(Math.min(...p)),q=B(Math.max(...p))-ie;return t.jsx("div",{className:`range-selector-container ${v?"dragging":""}`,children:t.jsxs("div",{className:"input-row",children:[t.jsxs("div",{className:"manual-input-container",children:[t.jsx("input",{type:"number",className:"range-input",value:X[0],onChange:e=>oe(0,e.target.value),onBlur:()=>I(0),min:m,max:y,step:_}),t.jsx("label",{className:"label",children:H})]}),t.jsx("div",{className:"slider-wrapper",children:t.jsxs("div",{ref:$,className:"slider-track",children:[t.jsx("div",{className:"range-highlight",style:{left:`${ie}%`,width:`${q}%`}}),t.jsx("div",{className:"slider-track-clickable",onClick:R,onTouchStart:R}),t.jsxs("div",{className:"slider-knobs",children:[t.jsxs("div",{className:"knob-container",style:{left:`${B(p[0])}%`},onMouseDown:e=>T(0,e),onTouchStart:e=>T(0,e),children:[t.jsx("div",{className:"knob"}),v&&k===0&&t.jsx("div",{className:"value-display",children:p[0].toFixed(l)})]}),t.jsxs("div",{className:"knob-container",style:{left:`${B(p[1])}%`},onMouseDown:e=>T(1,e),onTouchStart:e=>T(1,e),children:[t.jsx("div",{className:"knob"}),v&&k===1&&t.jsx("div",{className:"value-display",children:p[1].toFixed(l)})]})]})]})}),t.jsxs("div",{className:"manual-input-container",children:[t.jsx("input",{type:"number",className:"range-input",value:X[1],onChange:e=>oe(1,e.target.value),onBlur:()=>I(1),min:m,max:y,step:_}),t.jsx("label",{className:"label",children:F})]})]})})},$t=864e5,ve=14,it=ve/2,Yt=280;function st(r){return r*ve+it}function qt(r,l){const o=Math.round((r-it)/ve);return Math.max(0,Math.min(l-1,o))}function Z(r){const l=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.exec(String(r??"").trim());if(!l)return null;const o=Number(l[1]),d=Number(l[2]),h=Number(l[3]),m=new Date(Date.UTC(o,d-1,h));return m.getUTCFullYear()!==o||m.getUTCMonth()!==d-1||m.getUTCDate()!==h?null:m}function ct(r){const l=r.getUTCFullYear(),o=String(r.getUTCMonth()+1).padStart(2,"0"),d=String(r.getUTCDate()).padStart(2,"0");return`${l}-${o}-${d}`}function ye(r,l,o){return r?l&&r<l?l:o&&r>o?o:r:l||o||null}function at(r,l){return new Date(Date.UTC(r,l,0)).getUTCDate()}function Qt(r,l){const o=Z(r),d=Z(l);if(!o||!d||o>d)return[];const h=[];for(let m=o.getTime();m<=d.getTime();m+=$t)h.push(ct(new Date(m)));return h}const Wt=({value:r,min:l,max:o,onChange:d,onChangeComplete:h})=>{const{t:m}=ot("pages"),y=n.useRef(null),_=n.useRef(null),H=n.useRef(!1),F=n.useRef({active:!1,moved:!1,startX:0,startScroll:0,pointerId:null}),[$,v]=n.useState(!1),[K,k]=n.useState(()=>ye(r,l,o)),j=n.useMemo(()=>Qt(l,o),[l,o]),U=n.useMemo(()=>{const e=new Map;return j.forEach((a,i)=>e.set(a,i)),e},[j]),L=ye(K||r,l,o),ee=n.useCallback(e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{h==null||h(e)},Yt)},[h]),c=n.useCallback((e,{scroll:a=!0,complete:i=!0}={})=>{const f=ye(e,l,o);if(f&&(k(f),d==null||d(f),i&&ee(f),a&&y.current)){const x=U.get(f);x!=null&&(H.current=!0,y.current.scrollLeft=st(x),requestAnimationFrame(()=>{H.current=!1}))}},[l,o,d,ee,U]);n.useEffect(()=>{const e=ye(r,l,o);if(!e)return;k(f=>f===e?f:e);const a=y.current;if(!a)return;const i=U.get(e);i!=null&&(H.current=!0,a.scrollLeft=st(i),requestAnimationFrame(()=>{H.current=!1}))},[r,l,o,U]),n.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]);const p=()=>
1{if(H.current||!y.current||j.length===0)return;const e=qt(y.current.scrollLeft,j.length),a=j[e];!a||a===K||(k(a),d==null||d(a),ee(a))},C=n.useCallback(e=>{var f;const a=F.current;if(!a.active)return;a.active=!1,v(!1);const i=y.current;if(i&&e!=null)try{(f=i.hasPointerCapture)!=null&&f.call(i,e)&&i.releasePointerCapture(e)}catch{}},[]),X=e=>{if(e.button!==0&&e.pointerType==="mouse")return;const a=y.current;if(!a)return;const i=a.getBoundingClientRect();i.height-(e.clientY-i.top)<=8||(F.current={active:!0,moved:!1,startX:e.clientX,startScroll:a.scrollLeft,pointerId:e.pointerId},a.setPointerCapture(e.pointerId),v(!0),e.preventDefault())},E=e=>{const a=F.current;if(!a.active)return;const i=y.current;if(!i)return;const f=e.clientX-a.startX;Math.abs(f)>2&&(a.moved=!0),i.scrollLeft=a.startScroll-f},Y=e=>{C(e.pointerId)},B=e=>{C(e.pointerId)},le=(e,a)=>{if(F.current.moved){a.preventDefault(),a.stopPropagation(),F.current.moved=!1;return}c(e)},M=Z(L),w=(M==null?void 0:M.getUTCFullYear())??null,R=M?M.getUTCMonth()+1:null,T=(M==null?void 0:M.getUTCDate())??null,oe=n.useMemo(()=>{const e=Z(l),a=Z(o);if(!e||!a)return[];const i=[];for(let f=e.getUTCFullYear();f<=a.getUTCFullYear();f++)i.push({value:f,label:String(f)});return i},[l,o]),I=n.useMemo(()=>{if(w==null)return[];const e=Z(l),a=Z(o);if(!e||!a)return[];const i=w===e.getUTCFullYear()?e.getUTCMonth()+1:1,f=w===a.getUTCFullYear()?a.getUTCMonth()+1:12,x=[];for(let N=i;N<=f;N++)x.push({value:N,label:m(`leaderboard.past.months.${N}`,{defaultValue:String(N).padStart(2,"0")})});return x},[w,l,o,m]),ie=n.useMemo(()=>{if(w==null||R==null)return[];const e=Z(l),a=Z(o);if(!e||!a)return[];const i=at(w,R);let f=1,x=i;w===e.getUTCFullYear()&&R===e.getUTCMonth()+1&&(f=e.getUTCDate()),w===a.getUTCFullYear()&&R===a.getUTCMonth()+1&&(x=a.getUTCDate());const N=[];for(let V=f;V<=x;V++)N.push({value:V,label:String(V).padStart(2,"0")});return N},[w,R,l,o]),q=(e,a,i)=>{if(e==null||a==null||i==null)return;const f=at(e,a),x=Math.min(i,f);c(ct(new Date(Date.UTC(e,a-1,x))))};return!l||!o||j.length===0?t.jsx("div",{className:"history-timeline history-timeline--empty",children:t.jsx("p",{className:"history-timeline__empty-msg",children:m("leaderboard.past.noData")})}):t.jsxs("div",{className:"history-timeline",children:[t.jsxs("div",{className:"history-timeline__selects",children:[t.jsxs("div",{className:"history-timeline__select",children:[t.jsx("span",{className:"history-timeline__select-label",children:m("leaderboard.past.date.year")}),t.jsx(de,{value:oe.find(e=>e.value===w)??null,onChange:e=>q(e==null?void 0:e.value,R,T),options:oe,width:"6.5rem",direction:"auto"})]}),t.jsxs("div",{className:"history-timeline__select",children:[t.jsx("span",{className:"history-timeline__select-label",children:m("leaderboard.past.date.month")}),t.jsx(de,{value:I.find(e=>e.value===R)??null,onChange:e=>q(w,e==null?void 0:e.value,T),options:I,width:"8rem",direction:"auto"})]}),t.jsxs("div",{className:"history-timeline__select",children:[t.jsx("span",{className:"history-timeline__select-label",children:m("leaderboard.past.date.day")}),t.jsx(de,{value:ie.find(e=>e.value===T)??null,onChange:e=>q(w,R,e==null?void 0:e.value),options:ie,width:"5.5rem",direction:"auto"})]})]}),t.jsxs("div",{className:"history-timeline__ruler-wrap",children:[t.jsx("div",{className:"history-timeline__indicator","aria-hidden":"true"}),t.jsxs("div",{className:["history-timeline__track",$?"history-timeline__track--dragging":""].filter(Boolean).join(" "),ref:y,onScroll:p,onPointerDown:X,onPointerMove:E,onPointerUp:Y,onPointerCancel:B,role:"slider","aria-valuemin":0,"aria-valuemax":j.length-1,"aria-valuenow":U.get(L)??0,"aria-valuetext":L,"aria-label":m("leaderboard.past.timelineLabel"),tabIndex:0,onKeyDown:e=>{const a=U.get(L)??0;if(e.key==="ArrowLeft"||e.key==="ArrowDown"){e.preventDefault();const i=j[Math.max(0,a-1)];i&&c(i)}else if(e.key==="ArrowRight"||e.key==="ArrowUp"){e.preventDefault();const i=j[Math.min(j.length-1,a+1)];i&&c(i)}else e.key==="Home"?(e.preventDefault(),c(j[0])):e.key==="End"&&(e.preventDefault(),c(j[j.length-1]))},children:[t.jsx("div",{className:"history-timeline__spacer",style:{width:"50%"}}),t.jsx("div",{className:"history-timeline__ticks",children:j.map(e=>{const a=Z(e),i=(a==null?void 0:a.getUTCDate())===1,f=e===L;return t.jsxs("button",{type:"button",className:["history-timeline__tick",i?"history-timeline__tick--month":"",f?"history-timeline__tick--selected":""].filter(
1Boolean).join(" "),style:{width:ve},title:e,onClick:x=>le(e,x),children:[t.jsx("span",{className:"history-timeline__tick-mark"}),i&&t.jsx("span",{className:"history-timeline__tick-label",children:m(`leaderboard.past.monthsShort.${a.getUTCMonth()+1}`,{defaultValue:String(a.getUTCMonth()+1)})})]},e)})}),t.jsx("div",{className:"history-timeline__spacer",style:{width:"50%"}})]})]}),t.jsx("p",{className:"history-timeline__current",children:L})]})},lt=30,nt={field:"isBanned",mode:"hide"},Gt=["isBanned","isSubmissionsPaused","isRatingBanned"];function Te(r){if(!Array.isArray(r)||r.length<2)return null;const l=Math.floor(Number(r[0])),o=Math.floor(Number(r[1]));if(!Number.isFinite(l)||!Number.isFinite(o))return null;const d=Math.max(1,Math.min(l,o)),h=Math.max(d,l,o);return[d,h]}function zt(r,l){return r?l<1?!1:r[0]<=1&&r[1]>=l:!0}function Jt(r){if(!r||typeof r!="object")return{};const l={...r};return delete l.rankedScoreRank,l}const Ms=()=>{const{t:r}=ot("pages"),l=Rt(),{user:o}=Ct(),[d,h]=n.useState(!0),[m,y]=n.useState(!1),[_,H]=n.useState(null),[F,$]=n.useState(null),[v,K]=n.useState({}),[k,j]=n.useState(null),U=qe(500),L=qe(500),ee=n.useRef(!0),[c,p]=n.useState(!1),[C,X]=n.useState(null),[E,Y]=n.useState("rankedScore"),[B,le]=n.useState("ASC"),[M,w]=n.useState(""),[R,T]=n.useState(null),[oe,I]=n.useState(null),[ie,q]=n.useState(!0),[e,a]=n.useState(null),[i,f]=n.useState(null),[x,N]=n.useState(!1),{playerData:V,setPlayerData:z,displayedPlayers:P,setDisplayedPlayers:J,leaderboardListTotal:te,setLeaderboardListTotal:Se,filterOpen:je,setFilterOpen:ke,sortOpen:Re,setSortOpen:we,maxFields:me,setMaxFields:dt,filters:ne,setFilters:re,country:pe,setCountry:Me,query:Ne,setQuery:Oe,sort:be,setSort:Ae,sortBy:xe,setSortBy:Le,playerFlagFilter:ue,setPlayerFlagFilter:Ee,followingFilter:se,setFollowingFilter:Fe,forceUpdate:ut,setForceUpdate:ge}=n.useContext(_t),ft=n.useMemo(()=>Vt({title:c?r("leaderboard.past.metaTitle",{date:C||""}):r("leaderboard.meta.title"),description:c?r("leaderboard.past.metaDescription",{date:C||""}):r("leaderboard.meta.description"),pathname:l.pathname,players:c?R:P}),[r,l.pathname,P,c,C,R]),Pe=[{value:"rankedScore",label:r("leaderboard.sortOptions.rankedScore")},{value:"totalScoreV2",label:r("leaderboard.sortOptions.totalScoreV2")},{value:"ppScore",label:r("leaderboard.sortOptions.ppScore")},{value:"wfScore",label:r("leaderboard.sortOptions.wfScore")},{value:"wfPPScore",label:r("leaderboard.sortOptions.wfPPScore")},{value:"averageXacc",label:r("leaderboard.sortOptions.averageXacc")},{value:"totalPasses",label:r("leaderboard.sortOptions.totalPasses")},{value:"universalPassCount",label:r("leaderboard.sortOptions.universalPassCount")},{value:"score12K",label:r("leaderboard.sortOptions.score12K")},{value:"generalScore",label:r("leaderboard.sortOptions.generalScore")},{value:"worldsFirstCount",label:r("leaderboard.sortOptions.worldsFirstCount")},{value:"worldsFirstPPCount",label:r("leaderboard.sortOptions.worldsFirstPPCount")},{value:"topDiff",label:r("leaderboard.sortOptions.topDiff")},{value:"top12kDiff",label:r("leaderboard.sortOptions.top12kDiff")}],Ue=n.useMemo(()=>[{value:"rankedScore",label:r("leaderboard.past.metricRanked")},{value:"generalScore",label:r("leaderboard.past.metricGeneral")}],[r]),Ie=n.useMemo(()=>Gt.map(s=>({value:s,label:r(`leaderboard.playerFlagFilter.fields.${s}`)})),[r]),Ve=s=>{Ee(s),J(null),z(null),Se(null),ge(u=>!u)},De=[{key:"rankedScore",label:r("leaderboard.sortOptions.rankedScore"),maxKey:"maxRankedScore",step:1},{key:"totalScoreV2",label:r("leaderboard.sortOptions.totalScoreV2"),maxKey:"maxTotalScoreV2",step:1},{key:"ppScore",label:r("leaderboard.sortOptions.ppScore"),maxKey:"maxPpScore",step:1},{key:"wfScore",label:r("leaderboard.sortOptions.wfScore"),maxKey:"maxWfScore",step:1},{key:"wfPPScore",label:r("leaderboard.sortOptions.wfPPScore"),maxKey:"maxWfPPScore",step:1},{key:"score12K",label:r("leaderboard.sortOptions.score12K"),maxKey:"maxScore12K",step:1},{key:"generalScore",label:r("leaderboard.sortOptions.generalScore"),maxKey:"maxGeneralScore",step:1},{key:"averageXacc",label:r("leaderboard.sortOptions.averageXacc"),maxKey:"maxAverageXacc",step:.01,isPercentage:!0}
1,{key:"totalPasses",label:r("leaderboard.sortOptions.totalPasses"),maxKey:"maxTotalPasses",step:1},{key:"universalPassCount",label:r("leaderboard.sortOptions.universalPassCount"),maxKey:"maxUniversalPassCount",step:1},{key:"worldsFirstCount",label:r("leaderboard.sortOptions.worldsFirstCount"),maxKey:"maxWorldsFirstCount",step:1},{key:"worldsFirstPPCount",label:r("leaderboard.sortOptions.worldsFirstPPCount"),maxKey:"maxWorldsFirstPPCount",step:1}],Ke=async(s=0,{immediate:u=!1}={})=>{const b=u?U.flush:U,S=Je(o,Ze.SUPER_ADMIN)?ue:nt,O=new URLSearchParams({query:Ne,sortBy:xe,order:be.toLowerCase(),offset:s,limit:lt,flagField:S.field,flagMode:S.mode});if(ne&&Object.keys(ne).length>0||pe){const g={...ne};g.averageXacc&&(g.averageXacc=[g.averageXacc[0]/100,g.averageXacc[1]/100]);const G=Math.max(0,Math.floor(Number(me.rankedPopulation)||0)),D=Te(g.rankedScoreRank);!D||zt(D,G)?delete g.rankedScoreRank:g.rankedScoreRank=D,O.append("filters",JSON.stringify({...g,country:pe}))}o&&se==="only"&&O.set("following","only");const A=`${Ce.playersV3.leaderboard()}?${O.toString()}`;try{const g=await b(({signal:ae})=>_e.get(A,{signal:ae})),G=Array.isArray(g.data.results)?g.data.results:[],D=s===0?0:(P==null?void 0:P.length)??0,ce=s===0?G.length:D+G.length,fe=g.data.count??ce;s===0?(z(G),J(G),Se(fe),g.data.maxFields&&dt(g.data.maxFields)):(z(ae=>[...ae??[],...G]),J(ae=>[...ae??[],...G])),h(ce<fe)}catch(g){if(Qe.isCancel(g))return;console.error("Error fetching leaderboard data:",g)}},Xe=n.useCallback(async(s=0,{immediate:u=!1,dateOverride:b}={})=>{var G;const S=b??C;if(!S)return;const O=u?L.flush:L,A=new URLSearchParams({date:S,metric:E,order:B.toLowerCase(),offset:String(s),limit:String(lt)});M&&A.set("query",M),o&&se==="only"&&A.set("following","only");const g=`${Ce.playersV3.leaderboardHistory()}?${A.toString()}`;try{const D=await O(({signal:ae})=>_e.get(g,{signal:ae})),ce=Array.isArray(D.data.results)?D.data.results:[];D.data.minDate&&a(D.data.minDate),D.data.maxDate&&f(D.data.maxDate);const fe=D.data.count??ce.length;s===0?(T(ce),I(fe),q(ce.length<fe)):T(ae=>{const Ye=[...ae??[],...ce];return q(Ye.length<fe),Ye})}catch(D){if(Qe.isCancel(D))return;if(((G=D==null?void 0:D.response)==null?void 0:G.status)===429){console.warn("Historical leaderboard rate limited; try again shortly");return}console.error("Error fetching historical leaderboard:",D),s===0&&(T([]),I(0),q(!1))}},[C,E,B,M,L,o,se]);n.useEffect(()=>{const s=Jt(ne);Object.keys(s).length>0&&K(s)},[]),n.useEffect(()=>{if(!c){if(ee.current&&(ee.current=!1,Array.isArray(P)&&P.length>0&&te!=null&&!(se==="only"&&!o)&&Number(me.rankedPopulation)>0)){h(P.length<te);return}Se(null),z(null),J(null),Ke(0)}},[ut,Ne,be,xe,ue,pe,ne,c,se,o]),n.useEffect(()=>{!c||!C||(T(null),I(null),Xe(0))},[c,C,E,B,M,se,o]);const mt=async()=>{if(p(!0),T(null),I(null),N(!1),ke(!1),we(!1),!(C&&e&&i))try{const s=await _e.get(Ce.playersV3.leaderboardHistoryBounds()),u=s.data.minDate??null,b=s.data.maxDate??null;if(a(u),f(b),!b){T([]),I(0),q(!1);return}X(b)}catch(s){console.error("Error entering past mode:",s),T([]),I(0),q(!1)}},pt=()=>{L.cancel(),p(!1),T(null),I(null)};function ht(s){if(c){w(et(s.target.value));return}Oe(et(s.target.value)),ge(u=>!u)}function bt(){ke(!je)}function xt(){if(c){N(!x);return}we(!Re)}function gt(s){Le(s.value)}function Be(s){Ae(s)}const yt=()=>{if(F&&!v[F.key]){let s=me[F.maxKey]||1e3;F.isPercentage&&(s=s*100);const u=[0,Math.ceil(s)];K(b=>({...b,[F.key]:u})),re(b=>({...b,[F.key]:u})),j(F.key),$(null)}},vt=s=>{if(K(u=>{const b={...u};return delete b[s],b}),re(u=>{const b={...u};return delete b[s],b}),k===s){const u=Object.keys(v).filter(b=>b!==s);j(u[0]||null)}};function St(){if(c){L.cancel(),Y("rankedScore"),le("ASC"),w(""),i&&X(i),Fe("no");return}U.cancel(),Le(Pe[0].value),Ae("DESC"),Oe(""),Ee(nt),Me(""),Fe("no"),K({}),re({}),$(null),j(null),ge(s=>!s)}const jt=s=>{H(s),y(!0)},kt=()=>{y(!1),H(null)},wt=()=>{ge(s=>!s),y(!1),H(null)},Mt=c?R:V,Q=c?R:P,He=c?oe:te,Nt=c?ie:d,Ft=c?M:Ne,$e=c?x:Re,W=Math.max(0,Math.floor(Number(me.rankedPopulation)||0)),Pt=Te(ne.rankedScoreRank)??(W>=1?[1,W]:[1,1]);n.useEffect(()=>{if(W<1)return;const s=Te(ne.rankedScoreRank);if(!s)return;const u=Math.min(Math.max(1,s[0]),W),b=Math.min(Math.max(u,s[1]),W);if(u===1&&b>=W){re(S=>{if(!S.rankedScoreRank)return S;const O={...S};return delete O.rankedScoreRank,O});return}(u!==s[0]||b!==s[1])&&re(S=>({...S,rankedScoreRank:[u,b]}))},[W,ne.rankedScoreRank,re]);const Dt=s=>{const u=Math.max(1,Math.floor(Number(s[0]))),b=Math.max(u,Math.floor(Number(s[1])));if(W>=1&&u===1&&b>=W){re(S=>{if(!S.rankedScoreRank)return S;const O={...S};return delete O.rankedScoreRank,O});return}re(S=>({...S,rankedScoreRank:[u,b]}))};return t.jsxs("div",{className:`leaderboard-page${c?" leaderboard-page--past":""}`,children:[t.jsx(Tt,{...ft}),t.jsxs("div",{className:"leaderboard-body page-content-70rem",children:[t.jsx(Bt,{}),t.jsx("div",{className:"leaderboard-past-toggle-row",children:c?t.jsxs("button",{type:"button",className:"leaderboard-past-toggle leaderboard-past-toggle--active",onClick:pt,children:[t.jsx(tt,{color:"#fff",size:18}),t.jsx("span",{children:r("leaderboard.past.backToPresent")})]}):t.jsxs("button",{type:"button",className:"leaderboard-past-toggle",onClick:mt,children:[t.jsx(tt,{color:"#fff",size:18}),t.jsx("span",{children:r("leaderboard.past.button")})]})}),c&&t.jsxs("div",{className:"leaderboard-past-banner",children:[t.jsx("h2",{className:"leaderboard-past-banner__title",children:r("leaderboard.past.title")}),t.jsx(Wt,{value:C,min:e,max:i,onChangeComplete:s=>X(s)})]}),t.jsxs("div",{className:"leaderboard-input-option",children:[t.jsx("div",{className:"search-container",children:t.jsx("input",{value:Ft,autoComplete:"off",type:"text",placeholder:r("leaderboard.input.placeholder"),onChange:ht})}),t.jsxs("div",{className:"button-container",children:[t.jsx(he,{id:"filter",place:"bottom",noArrow:!0,children:r("leaderboard.tooltips.filter")}),t.jsx(he,{id:"sort",place:"bottom",noArrow:!0,children:r("leaderboard.tooltips.sort")}),t.jsx(he,{id:"reset",place:"bottom",noArrow:!0,children:r("leaderboard.tooltips.reset")}),(!c||o)&&t.jsx(At,{"data-tooltip-id":"filter",color:"#ffffff",style:{backgroundColor:je||o&&se==="only"?"rgba(255, 255, 255, 0.7)":""},onClick:bt}),t.jsx(Lt,{"data-tooltip-id":"sort",color:"#ffffff",style:{backgroundColor:$e?"rgba(255, 255, 255, 0.7)":""},onClick:xt}),t.jsx(Et,{color:"#ffffff",onClick:St,"data-tooltip-id":"reset"})]})]}
1),t.jsxs("div",{className:"input-setting",children:[t.jsx(We,{open:je&&(!c||!!o),onOpenChange:ke,revealOverflow:!0,duration:"0.6s",children:t.jsx(Ge,{children:t.jsxs("div",{className:"filter settings-class",children:[t.jsx("h2",{className:"setting-title",children:r("leaderboard.settings.filter.header")}),t.jsxs("div",{className:"filter-section",children:[t.jsxs("div",{className:"filter-row",children:[o&&t.jsx(ze,{label:r("leaderboard.settings.filter.following"),currentState:se,onChange:Fe,states:["no","only"],showValue:!1}),!c&&t.jsxs("div",{className:"filter-container country-filter",children:[t.jsx("p",{className:"setting-description",children:r("leaderboard.settings.filter.country")}),t.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[t.jsx(Xt,{value:pe,onChange:s=>{Me(s)}}),pe&&t.jsx("button",{className:"country-clear-button",onClick:()=>Me(""),title:"Clear country filter",children:"Ã"})]})]})]}),!c&&W>=2&&t.jsxs("div",{className:"filter-container rank-filter",children:[t.jsx("p",{className:"setting-description",children:r("leaderboard.settings.filter.rankedScoreRank")}),t.jsx(rt,{values:Pt,onChangeComplete:Dt,min:1,max:W,decimals:0,step:1,minLabel:r("leaderboard.settings.filter.min"),maxLabel:r("leaderboard.settings.filter.max")})]}),!c&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"filter-builder",children:[t.jsx("p",{className:"setting-description",children:r("leaderboard.settings.filter.addStatFilters")}),t.jsxs("div",{className:"filter-selector-row",children:[t.jsx("div",{className:"filter-selector-container",children:t.jsx(de,{value:F?{value:F,label:F.label}:null,onChange:s=>$((s==null?void 0:s.value)||null),options:De.filter(s=>!v[s.key]).map(s=>({value:s,label:s.label})),placeholder:r("leaderboard.settings.filter.selectStatPlaceholder"),width:"100%"})}),t.jsx("button",{onClick:yt,disabled:!F,className:"add-filter-button",children:r("leaderboard.settings.filter.addFilterButton")})]}),Object.keys(v).length>0&&t.jsx("div",{className:"filter-chips",style:{marginTop:"1rem"},children:Object.entries(v).map(([s,u])=>{const b=De.find(A=>A.key===s);if(!b)return null;const S=b.step<1?2:0,O=b.isPercentage?"%":"";return t.jsxs("div",{className:`filter-chip ${k===s?"selected":""}`,onClick:()=>j(s),children:[t.jsx("span",{className:"filter-chip-label",children:b.label}),t.jsxs("span",{className:"filter-chip-range",children:[u[0].toFixed(S),O," - ",u[1].toFixed(S),O]}),t.jsx("button",{className:"filter-chip-remove",onClick:A=>{A.stopPropagation(),vt(s)},children:"Ã"})]},s)})}),k&&v[k]&&t.jsx("div",{className:"filter-range-editor",style:{marginTop:"1rem"},children:(()=>{const s=De.find(A=>A.key===k);if(!s)return null;let u=me[s.maxKey]||1e3;s.isPercentage&&(u=u*100);const b=s.step<1?2:0,S=s.isPercentage?"%":"",O=v[k];return t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"setting-description",style:{marginBottom:"0.5rem"},children:s.label}),t.jsx(rt,{values:O,onChange:A=>{K(g=>({...g,[k]:A}))},onChangeComplete:A=>{K(g=>({...g,[k]:A})),re(g=>({...g,[k]:A}))},min:0,max:Math.ceil(u),decimals:b,suffix:S,step:s.step,minLabel:r("leaderboard.settings.filter.min")+S,maxLabel:r("leaderboard.settings.filter.max")+S})]})})()})]}),Je(o,Ze.SUPER_ADMIN)&&t.jsx("div",{className:"player-flag-filter",children:t.jsxs("div",{className:"player-flag-filter__controls",children:[t.jsx(de,{value:Ie.find(s=>s.value===ue.field),onChange:s=>{s!=null&&s.value&&Ve({...ue,field:s.value})},options:Ie,width:"100%"}),t.jsx(ze,{showLabel:!1,currentState:ue.mode,onChange:s=>{Ve({...ue,mode:s})},states:["show","hide","only"],width:60,height:24})]})})]})]})]})})}),t.jsx(We,{open:$e,onOpenChange:c?N:we,revealOverflow:!0,duration:"0.6s",children:t.jsx(Ge,{children:t.jsxs("div",{className:"sort settings-class",children:[t.jsx("h2",{className:"setting-title",children:r("leaderboard.settings.sort.header")}),t.jsxs("div",{className:"sort-option",children:[t.jsxs("div",{className:"recent",children:[t.jsx("p",{children:r("leaderboard.settings.sort.sortOrder")}),t.jsx(he,{id:"ra",place:"top",noArrow:!0,children:r("leaderboard.tooltips.recentAsc")}),t.jsx(he,{id:"rd",place:"top",noArrow:!0,children:r("leaderboard.tooltips.recentDesc")}),t.jsxs("div",{className:"wrapper",children:[t.jsx(Ut,{"data-tooltip-id":"ra",style:{backgroundColor:(c?B:be)==="ASC"?"rgba(255, 255, 255, 0.7)":""},onClick:()=>c?le("ASC"):Be("ASC")}),t.jsx(It,{"data-tooltip-id":"rd",style:{backgroundColor:(c?B:be)==="DESC"?"rgba(255, 255, 255, 0.7)":""},onClick:()=>c?le("DESC"):Be("DESC")})]})]}),t.jsxs("div",{className:"recent",children:[t.jsx("p",{children:r("leaderboard.settings.sort.sortBy")}
1),c?t.jsx(de,{value:Ue.find(s=>s.value===E),onChange:s=>{s!=null&&s.value&&Y(s.value)},options:Ue,width:"11rem"}):t.jsx(de,{value:Pe.find(s=>s.value===xe),onChange:gt,options:Pe,width:"11rem"})]})]})]})})})]}),He!=null&&t.jsx("span",{className:"total-search-results",children:r("totalResults",{ns:"common",count:He})}),t.jsx("div",{className:"leaderboard-page__list",style:{minHeight:"500px"},children:Mt===null?t.jsx("div",{className:"loader-shell loader-shell--tall",children:t.jsx("div",{className:"loader loader-relative"})}):(Q==null?void 0:Q.length)===0?t.jsx("p",{className:"leaderboard-empty-msg",children:r(o&&se==="only"?"leaderboard.list.emptyFollowing":c?"leaderboard.past.noData":"leaderboard.infiniteScroll.end")}):t.jsx(Kt,{style:{paddingBottom:"4rem",overflow:"visible"},items:Q,loadMore:()=>{c?Xe((Q==null?void 0:Q.length)??0,{immediate:!0}):Ke((Q==null?void 0:Q.length)??0,{immediate:!0})},hasMore:Nt,loader:t.jsx("div",{className:"loader loader-relative"}),endMessage:Q.length>0&&t.jsx("p",{style:{textAlign:"center"},children:t.jsx("b",{children:r("leaderboard.infiniteScroll.end")})}),renderItem:(s,u)=>t.jsx(Ot,{currSort:c?E:xe,player:s,listIndex:u,historical:c,onCreatorAssignmentClick:c?void 0:jt}),computeItemKey:(s,u)=>(u==null?void 0:u.id)??s})})]}),!c&&m&&_&&t.jsx(Ht,{user:_,onClose:kt,onUpdate:wt})]})};export{Ms as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.