var x=Object.defineProperty,y=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var p=(r,e,a)=>e in r?x(r,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[e]=a,C=(r,e)=>{for(var a in e||(e={}))B.call(e,a)&&p(r,a,e[a]);if(_)for(var a of _(e))v.call(e,a)&&p(r,a,e[a]);return r},b=(r,e)=>y(r,U(e));import{j as n,e as N,r as P,h as l,F as d,B as E,T as t,I as w,k as H}from"./vendor.e6eaca24.js";import{d as L,b as i,a as q,R as f,m as A,u as G,c as S,L as h,E as T}from"./index.c6944236.js";import{P as j}from"./Pagination.3d9a4d43.js";import{U as I}from"./UserLink.eec3c14e.js";import{U as M}from"./UserSearch.2e1d12f5.js";import F from"./MarkdownContent.1e1566a9.js";import"./UserAvatar.acd4ab4e.js";import"./lodash.default.91c04a21.js";import"./PreviewSearch.7b29c032.js";import"./onEnterPress.b56e5f51.js";import"./v4.90f1a8cc.js";import"./CodeBox.16e9a888.js";const $="_header_1w5xh_1",z="_manageGroups_1w5xh_10",D="_link_1w5xh_17",J="_table_1w5xh_20",K="_columnRank_1w5xh_20",O="_columnUsername_1w5xh_23",Q="_columnBio_1w5xh_26",V="_columnAcceptedProblemCount_1w5xh_35",W="_columnRating_1w5xh_38",X="_bio_1w5xh_42",Y="_searchContainer_1w5xh_49",Z="_pagination_1w5xh_53";var o={header:$,manageGroups:z,link:D,table:J,columnRank:K,columnUsername:O,columnBio:Q,columnAcceptedProblemCount:V,columnRating:W,bio:X,searchContainer:Y,pagination:Z};const u=i.serverPreference.pagination.userList;var k=(r=>(r.rating="rating",r.acceptedProblemCount="acceptedProblemCount",r))(k||{});async function ee(r,e){const{requestError:a,response:s}=await q.user.getUserList({sortBy:r,skipCount:u*(e-1),takeCount:u});if(a)throw new f(a,{showRefresh:!0,showBack:!0});if(s.error)throw new f(A(`users.error.${s.error}`));return[s.userMetas,s.count]}let g=r=>{const e=G("users"),a=S(),s=N();P.exports.useEffect(()=>{i.enterNewPage(e(".title"),"members")},[i.locale]);const m=document.documentElement;return P.exports.useEffect(()=>{m.scrollTop=0},[r.currentPage]),l(d,{children:[l("div",{className:o.header,children:[n(M,{onResultSelect:c=>a.navigate(`/u/${c.username}`)}),i.currentUserHasPrivilege("ManageUserGroup")&&n("div",{className:o.manageGroups,children:n(E,{primary:!0,content:e(".manage_groups"),as:h,href:"/groups"})})]}),l(t,{unstackable:!0,basic:"very",textAlign:"center",className:o.table,children:[n(t.Header,{children:l(t.Row,{children:[n(t.HeaderCell,{className:o.columnRank,children:e(".rank")}),n(t.HeaderCell,{className:o.columnUsername,children:e(".username")}),n(t.HeaderCell,{className:o.columnBio,children:e(".bio")}),n(t.HeaderCell,{className:o.columnAcceptedProblemCount,children:r.sortBy==="acceptedProblemCount"?l(d,{children:[e(".accepted_problem_count"),n(w,{name:"angle down"})]}):n(h,{className:o.link,href:{query:{sortBy:"acceptedProblemCount"}},children:e(".accepted_problem_count")})}),n(t.HeaderCell,{className:o.columnRating,children:r.sortBy==="rating"?l(d,{children:[e(".rating"),n(w,{name:"angle down"})]}):n(h,{className:o.link,href:{query:{sortBy:"rating"}},children:e(".rating")})})]})}),n(t.Body,{children:r.users.map((c,R)=>l(t.Row,{children:[n(t.Cell,{children:n("strong",{children:(r.currentPage-1)*u+R+1})}),n(t.Cell,{children:n(I,{user:c})}),n(t.Cell,{className:o.columnBio,children:i.serverPreference.misc.renderMarkdownInUserBio?n(F,{content:c.bio,dontUseContentFont:!0}):n(T,{children:n("div",{children:c.bio})})}),n(t.Cell,{children:c.acceptedProblemCount}),n(t.Cell,{children:c.rating})]},c.id))})]}),r.totalCount<=u?null:n("div",{className:o.pagination,children:n(j,{totalCount:r.totalCount,currentPage:r.currentPage,itemsPerPage:u,pageUrl:c=>({query:b(C({},s.url.query),{page:c.toString()})})})})]})};g=H(g);var ge=L(async r=>{let e=parseInt(r.query.page)||1;e<1&&(e=1);let a=r.query.sortBy;a in k||(a=i.serverPreference.misc.sortUserByRating?"rating":"acceptedProblemCount");const[s,m]=await ee(a,e);return n(g,{sortBy:a,users:s,totalCount:m,currentPage:e})});export{ge as default};
