var le=Object.create;var A=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var r in t)A(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!ue.call(e,i)&&i!==r&&A(e,i,{get:()=>t[i],enumerable:!(a=ce(t,i))||a.enumerable});return e};var C=(e,t,r)=>(r=e!=null?le(pe(e)):{},W(t||!e||!e.__esModule?A(r,"default",{value:e,enumerable:!0}):r,e)),me=e=>W(A({},"__esModule",{value:!0}),e);var Se={};fe(Se,{default:()=>Re});module.exports=me(Se);var _=require("@chakra-ui/layout"),o=require("@chakra-ui/react"),se=C(require("@emotion/styled"),1),m=require("react");var P=require("@chakra-ui/react"),E=C(require("@emotion/styled"),1),T=require("react");var V=(e,t)=>e?e.length>t?e.substr(0,t-1)+"..."+e.substr(e.length-(t-1),e.length-1):e:"";var q=(e,t)=>{if(navigator.clipboard&&navigator.permissions)navigator.clipboard.writeText(e).then(t);else if(document.queryCommandSupported("copy")){let r=document.createElement("textarea");r.value=e,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),t?.()}};var w=C(require("react-jazzicon"),1),O=C(require("react-shadow/emotion"),1),j=require("react/jsx-runtime"),he=({address:e})=>{let t=Object.keys(O.default).length?w.default.default:w.default;return(0,j.jsx)(t,{diameter:"24",seed:(0,w.jsNumberForAddress)(e),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},J=he;var Le=require("react"),v=require("react/jsx-runtime"),ge=e=>(0,v.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",...e,children:[(0,v.jsx)("path",{d:"M21.5 13L14.1625 20L10.5 16.5",stroke:e.iconcolor??"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,v.jsx)("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:e.iconcolor??"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Q=ge;var Me=require("react"),k=require("react/jsx-runtime"),xe=e=>(0,k.jsxs)("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",...e,children:[(0,k.jsx)("path",{d:"M27 23V5H9",stroke:e.iconcolor??"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,k.jsx)("path",{d:"M23 9H5V27H23V9Z",stroke:e.iconcolor??"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),Y=xe;var h=require("react/jsx-runtime"),Ce=(0,E.default)(Y)`
  cursor: pointer;
`,ye=(0,E.default)(Q)`
  cursor: pointer;
`,be=({address:e,domain:t})=>{let[r,a]=(0,T.useState)(!1),[i,s]=(0,T.useState)(e),b=()=>{a(!0),q(e),setTimeout(()=>{a(!1)},1e3)};return(0,T.useEffect)(()=>{s(t||V(e,6))},[t,e]),(0,h.jsxs)(P.Flex,{alignItems:"center",children:[(0,h.jsx)(J,{address:e}),(0,h.jsxs)(P.Flex,{alignItems:"center",children:[(0,h.jsx)(P.Text,{mx:"1",children:i}),r?(0,h.jsx)(ye,{width:24,height:24,iconcolor:r&&"green"}):(0,h.jsx)(Ce,{width:24,height:24,onClick:b})]})]})},H=be;var X=require("react");var R=require("react");var ve=C(require("axios"),1);var B=require("react"),we=require("react/jsx-runtime"),Je=(0,B.createContext)(void 0),K="production";var M=K==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var Z=require("react/jsx-runtime");var ke=require("react/jsx-runtime"),G=(0,R.createContext)(void 0);var ee=()=>(0,X.useContext)(G);var te=C(require("axios"),1);var oe=async(e,t,r,a)=>{try{return(await te.default.get(`${M}/spaces/leaderboard?space_ids=${e}&offset=${t}&limit=${r}`,{headers:{"X-API-KEY":a}})).data}catch(i){throw i}};var mt=require("react");var re=require("react"),y="...",z=(e,t)=>{let r=t-e+1;return Array.from({length:r},(a,i)=>i+e)},ne=({totalCount:e,pageSize:t,siblingCount:r=1,currentPage:a})=>(0,re.useMemo)(()=>{let s=Math.ceil(e/t);if(r+5>=s)return z(1,s);let d=Math.max(a-r,1),g=Math.min(a+r,s),x=d>2,p=g<s-2,u=1,l=s;if(!x&&p){let c=3+2*r;return[...z(1,c),y,s]}if(x&&!p){let c=3+2*r,I=z(s-c+1,s);return[u,y,...I]}if(x&&p){let c=z(d,g);return[u,y,...c,y,l]}},[e,t,r,a]);var D=C(require("@emotion/styled"),1),ie=D.default.ul`
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: none;
`,$=D.default.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 {
  }
`;var L=require("@chakra-ui/icons"),S=require("@chakra-ui/react"),f=require("react/jsx-runtime");var Pe=e=>{let{onPageChange:t,totalCount:r,siblingCount:a=1,currentPage:i,pageSize:s,className:b}=e,d=ne({currentPage:i,totalCount:r,siblingCount:a,pageSize:s});if(i===0||d.length<2)return null;let g=()=>{t(i+1)},x=()=>{t(i-1)},p=d[d.length-1];return(0,f.jsxs)(S.Flex,{align:"center",children:[(0,f.jsx)(S.Box,{children:(0,f.jsx)(L.ChevronLeftIcon,{boxSize:6,onClick:i===1?()=>{}:x,opacity:i===1?.1:1,cursor:i===1?"not-allowed":"pointer"})}),(0,f.jsx)(ie,{children:d.map((u,l)=>u===y?(0,f.jsx)($,{className:"dots",children:"\u2026"},l):(0,f.jsx)($,{className:u===i?"selected":"",onClick:u===i?()=>{}:()=>t(u),children:u},l))}),(0,f.jsx)(S.Box,{children:(0,f.jsx)(L.ChevronRightIcon,{boxSize:6,onClick:i===p?()=>{}:g,opacity:i===p?.1:1,cursor:i===p?"not-allowed":"pointer"})})]})},ae=Pe;var n=require("react/jsx-runtime"),F=(0,se.default)(o.Th)`
  padding-left: 0;
  text-transform: unset;
  /* color: ${({theme:e})=>e.colors.text}; */
  font-size: 14px;
`,N=10,Te=({selectedSpaceId:e})=>{let[t,r]=(0,m.useState)(1),[a,i]=(0,m.useState)(!1),[s,b]=(0,m.useState)(0),[d,g]=(0,m.useState)({}),{accessKey:x}=ee(),p=(0,m.useCallback)(async()=>{try{i(!0);let{data:l,totalResults:c}=await oe(e,(t-1)*N,N,x);g(I=>({...I,[t]:l.map(U=>({collectionId:U?.User?.username,...U}))})),b(c)}catch{}finally{i(!1)}},[e,t,g]);(0,m.useEffect)(()=>{e&&p()},[e,p]);let u=(0,m.useCallback)(l=>{i(!0),r(l)},[]);return(0,n.jsxs)(_.Flex,{flexDir:"column",w:"full",children:[(0,n.jsx)(o.TableContainer,{pt:"20px",children:(0,n.jsxs)(o.Table,{size:"sm",children:[(0,n.jsx)(o.Thead,{width:"100",children:(0,n.jsxs)(o.Tr,{pb:"2",children:[(0,n.jsx)(F,{color:"mutedForeground",borderColor:"input",children:"Ranking"}),(0,n.jsx)(F,{color:"mutedForeground",borderColor:"input",textAlign:"left",px:"0",children:"User"}),(0,n.jsx)(F,{color:"mutedForeground",borderColor:"input",textAlign:"right",px:"0",children:"Quest completed"})]})}),(0,n.jsx)(o.Tbody,{children:d?.[t]?d?.[t]?.map((l,c)=>(0,n.jsxs)(o.Tr,{children:[(0,n.jsx)(o.Td,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:a?(0,n.jsx)(o.Skeleton,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"}):(0,n.jsx)(o.Box,{children:(0,n.jsx)(o.Text,{children:l?.rank})})}),(0,n.jsx)(o.Td,{"data-title":"User",borderColor:"input",px:"0",children:a?(0,n.jsx)(o.Skeleton,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"}):(0,n.jsx)(H,{domain:l?.user?.domainName,address:l?.user?.username})}),(0,n.jsx)(o.Td,{"data-title":"Quest completed",borderColor:"input",px:"0",children:a?(0,n.jsx)(o.Skeleton,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"}):(0,n.jsx)(o.Text,{textAlign:"right",fontWeight:600,fontSize:14,children:l?.stats?.questCompleted})})]},c)):[1,2,3,4,5,6,7,8,9,10].map((l,c)=>(0,n.jsxs)(o.Tr,{children:[(0,n.jsx)(o.Td,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:(0,n.jsx)(o.Skeleton,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"})}),(0,n.jsx)(o.Td,{"data-title":"User",borderColor:"input",px:"0",children:(0,n.jsx)(o.Skeleton,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"})}),(0,n.jsx)(o.Td,{"data-title":"Quest completed",borderColor:"input",px:"0",children:(0,n.jsx)(o.Skeleton,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"})})]},c))})]})}),(0,n.jsx)(_.Flex,{justify:"center",marginY:3,children:(0,n.jsx)(ae,{currentPage:t,totalCount:s,pageSize:N,onPageChange:u})})]})},Re=Te;
