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