var le=Object.defineProperty,ce=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var F=(e,t,o)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))pe.call(t,o)&&F(e,o,t[o]);if($)for(var o of $(t))ue.call(t,o)&&F(e,o,t[o]);return e},C=(e,t)=>ce(e,de(t));var y=(e,t,o)=>new Promise((s,r)=>{var l=c=>{try{a(o.next(c))}catch(d){r(d)}},h=c=>{try{a(o.throw(c))}catch(d){r(d)}},a=c=>c.done?s(c.value):Promise.resolve(c.value).then(l,h);a((o=o.apply(e,t)).next())});import{Flex as ie}from"@chakra-ui/layout";import{Box as Fe,Skeleton as v,Table as De,TableContainer as Ne,Tbody as _e,Td as k,Text as ae,Th as Ue,Thead as We,Tr as E}from"@chakra-ui/react";import Ve from"@emotion/styled";import{useCallback as se,useEffect as qe,useState as A}from"react";import{Flex as J,Text as we}from"@chakra-ui/react";import Q from"@emotion/styled";import{useEffect as ve,useState as j}from"react";var D=(e,t)=>e?e.length>t?e.substr(0,t-1)+"..."+e.substr(e.length-(t-1),e.length-1):e:"";var N=(e,t)=>{if(navigator.clipboard&&navigator.permissions)navigator.clipboard.writeText(e).then(t);else if(document.queryCommandSupported("copy")){let o=document.createElement("textarea");o.value=e,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),t==null||t()}};import _,{jsNumberForAddress as fe}from"react-jazzicon";import{default as me}from"react-shadow/emotion";import{jsx as ge}from"react/jsx-runtime";var he=({address:e})=>{let t=Object.keys(me).length?_.default:_;return ge(t,{diameter:"24",seed:fe(e),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},U=he;import"react";import{jsx as W,jsxs as Ce}from"react/jsx-runtime";var xe=e=>{var t,o;return Ce("svg",C(m({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[W("path",{d:"M21.5 13L14.1625 20L10.5 16.5",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),W("path",{d:"M16 28C22.6274 28 28 22.6274 28 16C28 9.37258 22.6274 4 16 4C9.37258 4 4 9.37258 4 16C4 22.6274 9.37258 28 16 28Z",stroke:(o=e.iconcolor)!=null?o:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}))},V=xe;import"react";import{jsx as q,jsxs as be}from"react/jsx-runtime";var ye=e=>{var t,o;return be("svg",C(m({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[q("path",{d:"M27 23V5H9",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),q("path",{d:"M23 9H5V27H23V9Z",stroke:(o=e.iconcolor)!=null?o:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}))},O=ye;import{jsx as S,jsxs as K}from"react/jsx-runtime";var ke=Q(O)`
  cursor: pointer;
`,Pe=Q(V)`
  cursor: pointer;
`,Te=({address:e,domain:t})=>{let[o,s]=j(!1),[r,l]=j(e),h=()=>{s(!0),N(e),setTimeout(()=>{s(!1)},1e3)};return ve(()=>{l(t||D(e,6))},[t,e]),K(J,{alignItems:"center",children:[S(U,{address:e}),K(J,{alignItems:"center",children:[S(we,{mx:"1",children:r}),o?S(Pe,{width:24,height:24,iconcolor:o&&"green"}):S(ke,{width:24,height:24,onClick:h})]})]})},Y=Te;import{useContext as Ie}from"react";import{createContext as Se,useCallback as qt,useEffect as Ot,useState as Jt}from"react";import Lt from"axios";import{createContext as Re,useMemo as wt}from"react";import{jsx as Pt}from"react/jsx-runtime";var vt=Re(void 0),H="production";var z=H==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";import{jsx as Ft,jsxs as Dt}from"react/jsx-runtime";import{jsx as Yt}from"react/jsx-runtime";var Z=Se(void 0);var G=()=>Ie(Z);import Ae from"axios";var X=(e,t,o,s)=>y(void 0,null,function*(){try{return(yield Ae.get(`${z}/spaces/leaderboard?space_ids=${e}&offset=${t}&limit=${o}`,{headers:{"X-API-KEY":s}})).data}catch(r){throw r}});import"react";import{useMemo as ze}from"react";var w="...",I=(e,t)=>{let o=t-e+1;return Array.from({length:o},(s,r)=>r+e)},ee=({totalCount:e,pageSize:t,siblingCount:o=1,currentPage:s})=>ze(()=>{let l=Math.ceil(e/t);if(o+5>=l)return I(1,l);let a=Math.max(s-o,1),c=Math.min(s+o,l),d=a>2,p=c<l-2,u=1,g=l;if(!d&&p){let n=3+2*o;return[...I(1,n),w,l]}if(d&&!p){let n=3+2*o,f=I(l-n+1,l);return[u,w,...f]}if(d&&p){let n=I(a,c);return[u,w,...n,w,g]}},[e,t,o,s]);import te from"@emotion/styled";var oe=te.ul`
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: none;
`,L=te.li`
  padding: 0 12px;
  height: 32px;
  min-width: 32px;
  text-align: center;
  margin: auto 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;

  ${({disabled:e})=>e&&`
    pointer-events: none;

    &:hover {
      background-color: transparent;
      cursor: default;
    }
  `}

  &.dots:hover {
    background-color: transparent;
    cursor: default;
  }
  &:hover {
    background-color: var(--bad-colors-muted);
    cursor: pointer;
  }

  &.selected {
    background-color: var(--bad-colors-muted);
  }

  &.disabled {
  }
`;import{ChevronLeftIcon as Le,ChevronRightIcon as Ee}from"@chakra-ui/icons";import{Box as re,Flex as Be}from"@chakra-ui/react";import{jsx as b,jsxs as $e}from"react/jsx-runtime";var Me=e=>{let{onPageChange:t,totalCount:o,siblingCount:s=1,currentPage:r,pageSize:l,className:h}=e,a=ee({currentPage:r,totalCount:o,siblingCount:s,pageSize:l});if(r===0||a.length<2)return null;let c=()=>{t(r+1)},d=()=>{t(r-1)},p=a[a.length-1];return $e(Be,{align:"center",children:[b(re,{children:b(Le,{boxSize:6,onClick:r===1?()=>{}:d,opacity:r===1?.1:1,cursor:r===1?"not-allowed":"pointer"})}),b(oe,{children:a.map((u,g)=>u===w?b(L,{className:"dots",children:"\u2026"},g):b(L,{className:u===r?"selected":"",onClick:u===r?()=>{}:()=>t(u),children:u},g))}),b(re,{children:b(Ee,{boxSize:6,onClick:r===p?()=>{}:c,opacity:r===p?.1:1,cursor:r===p?"not-allowed":"pointer"})})]})},ne=Me;import{jsx as i,jsxs as T}from"react/jsx-runtime";var B=Ve(Ue)`
  padding-left: 0;
  text-transform: unset;
  /* color: ${({theme:e})=>e.colors.text}; */
  font-size: 14px;
`,M=10,Oe=({selectedSpaceId:e})=>{var g;let[t,o]=A(1),[s,r]=A(!1),[l,h]=A(0),[a,c]=A({}),{accessKey:d}=G(),p=se(()=>y(void 0,null,function*(){try{r(!0);let{data:n,totalResults:f}=yield X(e,(t-1)*M,M,d);c(R=>C(m({},R),{[t]:n.map(x=>{var P;return m({collectionId:(P=x==null?void 0:x.User)==null?void 0:P.username},x)})})),h(f)}catch(n){}finally{r(!1)}}),[e,t,c]);qe(()=>{e&&p()},[e,p]);let u=se(n=>{r(!0),o(n)},[]);return T(ie,{flexDir:"column",w:"full",children:[i(Ne,{pt:"20px",children:T(De,{size:"sm",children:[i(We,{width:"100",children:T(E,{pb:"2",children:[i(B,{color:"mutedForeground",borderColor:"input",children:"Ranking"}),i(B,{color:"mutedForeground",borderColor:"input",textAlign:"left",px:"0",children:"User"}),i(B,{color:"mutedForeground",borderColor:"input",textAlign:"right",px:"0",children:"Quest completed"})]})}),i(_e,{children:a!=null&&a[t]?(g=a==null?void 0:a[t])==null?void 0:g.map((n,f)=>{var R,x,P;return T(E,{children:[i(k,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:s?i(v,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"}):i(Fe,{children:i(ae,{children:n==null?void 0:n.rank})})}),i(k,{"data-title":"User",borderColor:"input",px:"0",children:s?i(v,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"}):i(Y,{domain:(R=n==null?void 0:n.user)==null?void 0:R.domainName,address:(x=n==null?void 0:n.user)==null?void 0:x.username})}),i(k,{"data-title":"Quest completed",borderColor:"input",px:"0",children:s?i(v,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"}):i(ae,{textAlign:"right",fontWeight:600,fontSize:14,children:(P=n==null?void 0:n.stats)==null?void 0:P.questCompleted})})]},f)}):[1,2,3,4,5,6,7,8,9,10].map((n,f)=>T(E,{children:[i(k,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:i(v,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"})}),i(k,{"data-title":"User",borderColor:"input",px:"0",children:i(v,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"})}),i(k,{"data-title":"Quest completed",borderColor:"input",px:"0",children:i(v,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"})})]},f))})]})}),i(ie,{justify:"center",marginY:3,children:i(ne,{currentPage:t,totalCount:l,pageSize:M,onPageChange:u})})]})},Io=Oe;export{Io as default};
