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