import{ChevronLeftIcon as K,ChevronRightIcon as Y}from"@chakra-ui/icons";import{Box as P,Flex as f,Grid as D,GridItem as L,Modal as X,ModalBody as _,ModalCloseButton as q,ModalContent as J,ModalHeader as U,ModalOverlay as j,Skeleton as H,Text as S,useDisclosure as V}from"@chakra-ui/react";import{useCallback as W,useEffect as Q,useState as i}from"react";import x,{jsNumberForAddress as B}from"react-jazzicon";import{default as R}from"react-shadow/emotion";import{jsx as O}from"react/jsx-runtime";var N=({address:t})=>{let r=Object.keys(R).length?x.default:x;return O(r,{diameter:"24",seed:B(t),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},u=N;import G from"axios";import{createContext as F,useMemo as lt}from"react";import{jsx as dt}from"react/jsx-runtime";var pt=F(void 0),w="production";var C=w==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var v=async(t,r,s,d)=>{try{return(await G.get(`${C}/collection/contest/${t}/participants?offset=${r}&limit=${s}`,{headers:{"X-API-KEY":d}})).data}catch(n){throw n}};var b=(t,r)=>t?t.length>r?t.substr(0,r-1)+"..."+t.substr(t.length-(r-1),t.length-1):t:"";import{Fragment as tt,jsx as e,jsxs as a}from"react/jsx-runtime";var Z=({collectionId:t,accessKey:r})=>{let[s,d]=i(0),[n,$]=i(1),[c,A]=i(0),[m,I]=i([]),[k,M]=i(!0),[et,h]=i(!0),{isOpen:E,onOpen:z,onClose:T}=V(),l=12,y=W(async()=>{try{if(!t||!r)return;h(!0);let{data:o,totalResult:p}=await v(t,s,l,r);I(o),A(p)}catch(o){console.log(o)}finally{h(!1),M(!1)}},[t,r,s,n]);Q(()=>{y()},[y]);let g=o=>{$(o),d((o-1)*l)};return k?e(H,{mt:2,ml:"2",isLoaded:!1,fadeDuration:.1,minW:"40",minH:8,startColor:"muted",endColor:"input",borderRadius:"8"}):m.length?a(tt,{children:[a(f,{onClick:z,alignItems:"flex-end",cursor:"pointer",children:[m.slice(0,11).map((o,p)=>e(P,{h:"24px",ml:p>0?"-15px":"0",children:e(u,{address:o},o)},o)),a(S,{fontWeight:"medium",fontSize:14,ml:2,children:[c," Participants"]})]}),a(X,{isOpen:E,onClose:T,size:"2xl",isCentered:!0,blockScrollOnMount:!1,children:[e(j,{}),a(J,{children:[e(U,{pb:"0",children:`Participants (${c})`}),e(q,{}),e(_,{children:a(P,{mr:3,mt:2,children:[e(D,{templateColumns:["repeat(2, 1fr)","repeat(2, 1fr)","repeat(3, 1fr)"],gap:4,mt:4,children:m.map((o,p)=>e(L,{children:a(f,{align:"center",children:[e(u,{address:o}),e(S,{ml:2,fontSize:14,children:b(o,6)})]})},p))}),e(f,{alignItems:"center",mt:"2",justifyContent:"center",children:a(f,{children:[e(K,{w:"7",h:"7",color:n===1?"brand.400":"mutedForeground",cursor:n===1?"not-allowed":"pointer",mx:"1",onClick:n===1?()=>{}:()=>g(n-1)}),e(Y,{w:"7",h:"7",color:s+l>=c?"brand.400":"mutedForeground",cursor:s+l>=c?"not-allowed":"pointer",mx:"1",onClick:s+l>=c?()=>{}:()=>g(n+1)})]})})]})})]})]})]}):null},kt=Z;export{kt as default};
