var g=(t,o,n)=>new Promise((e,r)=>{var c=u=>{try{a(n.next(u))}catch(f){r(f)}},l=u=>{try{a(n.throw(u))}catch(f){r(f)}},a=u=>u.done?e(u.value):Promise.resolve(u.value).then(c,l);a((n=n.apply(t,o)).next())});import{useEffect as E,useState as m}from"react";import{Box as C,Flex as x,Image as L,Modal as N,ModalBody as $,ModalCloseButton as z,ModalContent as H,ModalHeader as W,ModalOverlay as _,Skeleton as b,Text as w}from"@chakra-ui/react";import{useWeb3React as v}from"@web3-react/core";import{useMemo as B}from"react";import{isAddress as R}from"@ethersproject/address";import{AddressZero as U}from"@ethersproject/constants";import{Contract as I}from"@ethersproject/contracts";function T(t,o){return t.getSigner(o).connectUnchecked()}function k(t,o){return o?T(t,o):t}function h(t,o,n,e){if(!R(t)||t===U)throw Error(`Invalid 'address' parameter '${t}'.`);return new I(t,o,k(n,e))}function y(t,o,n=!0){let{provider:e,account:r,chainId:c}=v();return B(()=>{if(!t||!o||!e||!c)return null;let l;if(typeof t=="string"?l=t:l=t[c],!l)return null;try{return h(l,o,e,n&&r?r:void 0)}catch(a){return console.error("Failed to get contract",a),null}},[t,o,e,c,n,r])}import K from"axios";import{jsx as i,jsxs as d}from"react/jsx-runtime";var V=[{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}],M=t=>t?t.split("/")[t.split("/").length-1]:"",Z=({isOpen:t,onClose:o,contractAddress:n,mintedTokens:e})=>{let[r,c]=m(null),[l,a]=m(!0),[u,f]=m(!1),p=y(n,V);return E(()=>{t&&e&&p&&(()=>g(void 0,null,function*(){try{if(f(!1),e.length<=0)return a(!1);a(!0);let s=yield p.tokenURI(e[e.length-1]);if(s){let S=M(s),{data:F}=yield K.get(`https://bandit.infura-ipfs.io/ipfs/${S}`);c(F)}}catch(s){f(!0),console.log(s)}finally{a(!1)}}))()},[e,p,t]),d(N,{blockScrollOnMount:!1,isOpen:t,onClose:o,isCentered:!0,children:[i(_,{}),d(H,{children:[i(W,{}),i(z,{}),i($,{children:d(x,{direction:"column",align:"center",mb:4,children:[i(C,{borderRadius:8,p:2,w:"180px",borderColor:"input",border:"1px solid",children:d(x,{direction:"column",align:"center",children:[i(b,{isLoaded:!l,startColor:"muted",endColor:"input",children:i(C,{h:40,w:40,bg:"muted",children:i(L,{h:"full",w:"full",borderRadius:8,objectFit:"cover",src:`https://bandit.infura-ipfs.io/ipfs/${M(r==null?void 0:r.image)}`})})}),i(b,{isLoaded:!l,mt:2,startColor:"muted",endColor:"input",children:i(w,{fontSize:14,fontWeight:600,children:r==null?void 0:r.name})})]})}),u&&i(w,{fontSize:14,color:"red",mt:2,children:"Something went wrong! Failed to load your NFT."})]})})]})]})},nt=Z;export{nt as default};
