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