1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,258885,e=>{e.v("/_next/static/media/logo-p.ce49d995.png")},200517,e=>{e.v("/_next/static/media/user1.5c337f4c.svg")},56819,e=>{"use strict";e.s(["default",()=>t]);let t={src:e.i(200517).default,width:800,height:800,blurWidth:0,blurHeight:0}},135171,e=>{"use strict";e.s(["default",()=>d],135171);var t=e.i(843476),a=e.i(271645),s=e.i(509503),r=e.i(657688),l=e.i(56819),n=e.i(369620),i=e.i(473665),o=e.i(654238);let c=()=>(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 animate-pulse",children:[1,2,3].map(e=>(0,t.jsx)("div",{className:"bg-linear-to-br from-pink-50 to-purple-50 border-4 border-black shadow-[6px_6px_0px_#000]",children:(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsx)("div",{className:"bg-gray-300 border-2 border-black h-52 mb-4 flex items-center justify-center",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-6xl mb-2 text-gray-400",children:"ð«"}),(0,t.jsx)("p",{className:"text-sm font-bold text-gray-400",children:"Loading..."})]})}),(0,t.jsx)("div",{className:"bg-gray-300 h-6 rounded mb-2 w-3/4"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"bg-gray-300 h-4 rounded w-1/2"}),(0,t.jsx)("div",{className:"bg-gray-300 h-4 rounded w-1/3"}),(0,t.jsx)("div",{className:"bg-gray-300 h-4 rounded w-2/3"}),(0,t.jsx)("div",{className:"bg-gray-300 border-2 border-black h-6 w-20 mt-2"})]})]})},e))}),d=()=>{var e,d;let{authenticated:x,user:p,login:m}=(0,s.usePrivy)(),[h,b]=(0,a.useState)(!1),[f,u]=(0,a.useState)(!1),[g,v]=(0,a.useState)(!1),[w,j]=(0,a.useState)([]),[N,y]=(0,a.useState)([]),[k,_]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(x){var e;u(!1),(null==p||null==(e=p.wallet)?void 0:e.address)&&C()}else u(!0)},[x,p]);let C=async()=>{var e;if(null==p||null==(e=p.wallet)?void 0:e.address)try{v(!0),_(null);let e=new o.ethers.JsonRpcProvider("https://sepolia-rollup.arbitrum.
1io/rpc"),t=p.wallet.address.toLowerCase(),a=["function prizeDescription() external view returns (string memory)","function ticketPrice() external view returns (uint256)","function maxTickets() external view returns (uint256)","function totalTicketsSold() external view returns (uint256)","function endTime() external view returns (uint256)","function isClosed() external view returns (bool)","function winner() external view returns (address)","function maxTicketsPerUser() external view returns (uint256)","function houseFeePercentage() external view returns (uint256)","function prizeAmount() external view returns (uint256)","function entrantTickets(address) external view returns (uint256)","function prizeClaimed() external view returns (bool)"],s=new o.ethers.Contract("0xea82FE34F42bCAa9c74dD63843AAf0e5835aC22b",["function getRaffles() external view returns (address[] memory)"],e),r=[];try{r=await s.getRaffles(),console.log("Found raffles:",r.length)}catch(e){if(console.error("Error calling getRaffles():",e),e instanceof Error&&e.message.includes("could not decode result data")&&e.message.includes('value="0x"'))console.log("â¹ï¸ Factory contract returned empty data - no raffles exist yet"),r=[];else throw e}if(0===r.length){console.log("No raffles found, returning empty user data"),j([]),y([]),v(!1);return}let l=new Map;try{console.log("ð¼ï¸ Fetching images from MongoDB...");let e=await fetch("/api/raffles");if(e.ok){let t=await e.json();t.success&&t.raffles&&(console.log("ð Found MongoDB raffles:",t.raffles.length),t.raffles.forEach(e=>{e.contractAddress&&e.imageUrl&&(l.set(e.contractAddress.toLowerCase(),e.imageUrl),console.log("ð¼ï¸ Found image for ".concat(e.contractAddress,": ").concat(e.imageUrl)))}))}}catch(e){console.log("â ï¸ Could not fetch images from MongoDB:",e)}let n=[],i=[];for(let s of r)try{console.log("Checking raffle: ".concat(s));let r=new o.ethers.Contract(s,a,e),[c,d,x,p,m,h]=await Promise.all([r.prizeDescription().catch(()=>"Unknown Prize"),r.endTime().catch(()=>0),r.isClosed().catch(()=>!1),r.winner().catch(()=>"0x0000000000000000000000000000000000000000"),r.prizeAmount().catch(()=>0),r.prizeClaimed().catch(()=>!1)]),b="string"==typeof p?p:String(p),f=b.toLowerCase()===t.toLowerCase();console.log("Checking winner for raffle ".concat(s,":"),{winnerAddress:b,userAddress:t,isWinner:f,addressesMatch:b.toLowerCase()===t.toLowerCase()});let u=0;try{u=await r.entrantTickets(t),console.log("User tickets in ".concat(s,": ").concat(u))}catch(e){console.log("No tickets found for user in ".concat(s,":"),e)}if(u>0||f){let e=Math.floor(Date.now()/1e3)>=Number(d),a=m?o.ethers.formatEther(BigInt(m)):"0";console.log("Raffle ".concat(s," data:"),{title:c,userTickets:u,isWinner:f,hasEnded:e,isClosed:x,winner:b,userAddress:t,prizeAmount:a});let r="ongoing";x?r="closed":e&&(r="ended");let p=l.get(s.toLowerCase());p&&console.log("â
Found image for raffle ".concat(s,": ").concat(p));let g={address:s,title:c,image:"/api/placeholder/300/200",imageUrl:p||void 0,entryDate:new Date().toISOString().split("T")[0],tickets:Number(u),status:r,prizeValue:"".concat(a," PYUSD"),isWinner:f,prizeClaimed:f?h:void 0,endTime:Number(d)};(u>0||f)&&n.push(g),f&&i.push(g)}}catch(e){console.error("Error fetching raffle ".concat(s,":"),e)}n.sort((e,t)=>t.endTime-e.endTime),i.sort((e,t)=>t.endTime-e.endTime),console.log("Final data:",{participatedRaffles:n.length,wonRaffles:i.length,participatedData:n,wonData:i}),j(n),y(i)}catch(e){console.error("Error fetching user raffle data:",e),_("Failed to load raffle data")}finally{v(!1)}},T=async()=>{var e;(null==p||null==(e=p.wallet)?void 0:e.address)&&(await navigator.clipboard.writeText(p.wallet.address),b(!0),setTimeout(()=>b(!1),2e3))};return f?(0,t.jsx)("div",{className:"font-rubik min-h-screen flex items-center justify-center p-4 bg-linear-to-br from-purple-50 to-blue-50",children:(0,t.jsx)("div",{className:"bg-white border-4 border-black shadow-[8px_8px_0px_#000] p-8 max-w-md w-full",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"mb-6",children:(0,t.jsx)("svg",{className:"w-20 h-20 mx-auto text-[#f97028]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,t.jsx)("h2",{className:"text-3xl font-black mb-4 uppercase",children:"Wallet Connection Required"}),(0,t.jsx)("p",{className:"text-gray-600 mb-6 text-lg",children:"You need to connect your wallet to view your profile page"}),(0,t.jsx)("button",{onClick:()=>{m()},className:"bg-[#f97028] border-4 border-black px-8 py-3 font-black text-white uppercase tracking-tight shadow-[4px_4px_0px_#000] hover:shadow-[2px_2px_0px_#000] hover:translate-x-[2px] hover:translate-y-[2px] active:shadow-none active:translate-x-[4px] active:translate-y-[4px] transition-all duration-100 w-full",children:"Connect Wallet"})]})})}):(0,t.jsx)("div",{className:"font-rubik min-h-screen bg-linear-to-br from-purple-50 to-blue-50 p-4 md:p-8",children:(0,t.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,t.jsx)("div",{className:"bg-white border-4 border-black shadow-[8px_8px_0px_#000] p-6 md:p-8 mb-8",children:(0,t.jsxs)("div",{className:"flex flex-col md:flex-row items-center md:items-start gap-6",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"w-32 h-32 md:w-40 md:h-40 border-4 rounded-full border-black shadow-[4px_4px_0px_#000] overflow-hidden",children:(0,t.jsx)(r.default,{src:l.default,alt:"Profile",width:160,height:160,className:"object-cover w-full h-full"})}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 bg-[#f97028] border-4 border-black rounded-full p-2",children:(0,t.jsx)(i.MdVerified,{className:"text-white text-2xl"})})]}),(0,t.jsxs)("div",{className:"flex-1 text-center md:text-left",children:[(0,t.jsx)("h1",{className:"text-3xl md:text-4xl font-black mb-2 uppercase",children:(null==p||null==(e=p.wallet)?void 0:e.address)?"Crypto Enthusiast":"Anonymous User"}),(null==p||null==(d=p.wallet)?void 0:d.address)&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-center md:justify-start gap-2 bg-gray-100 border-2 border-black px-4 py-2",children:[(0,t.jsx)("span",{className:"font-mono font-bold text-sm md:text-base",children:(e=>"".concat(e.slice(0,8),"...").concat(e.slice(-6)))(p.wallet.address)}),(0,t.jsx)("button",{onClick:T,className:"text-[#f97028] hover:text-[#d85f20] transition-colors",title:"Copy address",children:(0,t.jsx)(n.IoCopy,{className:"text-xl"})})]}),h&&(0,t.jsx)("p",{className:"text-green-600 text-sm mt-1 font-bold",children:"Address copied!"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-4 mt-6",children:[(0,t.jsxs)("div",{className:"bg-[#f489a3] border-4 border-black p-4 shadow-[4px_4px_0px_#000]",children:[(0,t.jsx)("div",{className:"text-3xl font-black",children:w.length}),(0,t.jsx)("div",{className:"text-sm font-bold uppercase",children:"Participated"})]}),(0,t.jsxs)("div",{className:"bg-[#f0bb0d] border-4 border-black p-4 shadow-[4px_4px_0px_#000]",children:[(0,t.jsx)("div",{className:"text-3xl font-black",children:N.length}),(0,t.jsx)("div",{className:"text-sm font-bold uppercase",children:"Won"})]}),(0,t.jsxs)("div",{className:"bg-[#8b5cf6] border-4 border-black p-4 shadow-[4px_4px_0px_#000]",children:[(0,t.jsx)("div",{className:"text-3xl font-black text-white",children:w.reduce((e,t)=>
1e+t.tickets,0)}),(0,t.jsx)("div",{className:"text-sm font-bold uppercase text-white",children:"Total Tickets"})]})]})]})]})}),(0,t.jsxs)("div",{className:"bg-white border-4 border-black shadow-[8px_8px_0px_#000] p-6 md:p-8 mb-8",children:[(0,t.jsx)("h2",{className:"text-2xl md:text-3xl font-black mb-6 uppercase flex items-center gap-2",children:(0,t.jsx)("span",{className:"bg-[#f0bb0d] border-4 border-black px-4 py-2 shadow-[4px_4px_0px_#000]",children:"Won Raffles"})}),g?(0,t.jsx)(c,{}):k?(0,t.jsxs)("div",{className:"text-center py-12 text-red-500",children:[(0,t.jsx)("p",{className:"text-xl font-bold",children:"Error loading data"}),(0,t.jsx)("p",{className:"mt-2",children:k}),(0,t.jsx)("button",{onClick:C,className:"mt-4 bg-[#f97028] border-4 border-black px-6 py-2 font-black text-white uppercase tracking-tight shadow-[4px_4px_0px_#000] hover:shadow-[2px_2px_0px_#000] hover:translate-x-[2px] hover:translate-y-[2px] active:shadow-none active:translate-x-[4px] active:translate-y-[4px] transition-all duration-100",children:"Retry"})]}):0===N.length?(0,t.jsxs)("div",{className:"text-center py-12 text-gray-500",children:[(0,t.jsx)("p",{className:"text-xl font-bold",children:"No raffles won yet"}),(0,t.jsx)("p",{className:"mt-2",children:"Keep participating to win prizes!"})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:N.map(e=>(0,t.jsx)("div",{className:"bg-linear-to-br from-pink-50 to-purple-50 border-4 border-black shadow-[6px_6px_0px_#000] hover:shadow-[4px_4px_0px_#000] hover:translate-x-[2px] hover:translate-y-[2px] transition-all duration-100",children:(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"bg-white border-2 border-black h-52 mb-4 flex items-center justify-center relative overflow-hidden",children:[e.imageUrl?(0,t.jsx)(r.default,{src:e.imageUrl,alt:e.title,fill:!0,className:"object-cover",onError:t=>{console.log("Image failed to load:",e.imageUrl),t.currentTarget.style.display="none";let a=t.currentTarget.nextElementSibling;a&&(a.style.display="flex")}}):null,(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-linear-to-br from-yellow-100 to-orange-100 ".concat(e.imageUrl?"absolute inset-0 hidden":""),children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-6xl mb-2",children:"ð"}),(0,t.jsx)("p",{className:"text-sm font-bold text-gray-600",children:"Prize"})]})})]}),(0,t.jsx)("h3",{className:"font-black text-lg mb-2 uppercase",children:e.title}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsxs)("p",{className:"font-bold",children:["Won:"," ",new Date(1e3*e.endTime).toLocaleDateString()]}),(0,t.jsxs)("p",{className:"font-bold text-[#f97028]",children:["Prize: ",e.prizeValue]}),(0,t.jsx)("span",{className:"inline-block text-white px-3 py-1 border-2 border-black font-bold uppercase text-xs ".concat(e.prizeClaimed?"bg-green-500":"bg-yellow-500"),children:e.prizeClaimed?"claimed":"pending"})]})]})},e.address))})]}),(0,t.jsxs)("div",{className:"bg-white border-4 border-black shadow-[8px_8px_0px_#000] p-6 md:p-8",children:[(0,t.jsx)("h2",{className:"text-2xl md:text-3xl font-black mb-6 uppercase flex items-center gap-2",children:(0,t.jsx)("span",{className:"bg-[#f489a3] border-4 border-black px-4 py-2 shadow-[4px_4px_0px_#000]",children:"Participated Raffles"})}),g?(0,t.jsx)(c,{}):k?(0,t.jsxs)("div",{className:"text-center py-12 text-red-500",children:[(0,t.jsx)("p",{className:"text-xl font-bold",children:"Error loading data"}),(0,t.jsx)("p",{className:"mt-2",children:k}),(0,t.jsx)("button",{onClick:C,className:"mt-4 bg-[#f97028] border-4 border-black px-6 py-2 font-black text-white uppercase tracking-tight shadow-[4px_4px_0px_#000] hover:shadow-[2px_2px_0px_#000] hover:translate-x-[2px] hover:translate-y-[2px] active:shadow-none active:translate-x-[4px] active:translate-y-[4px] transition-all duration-100",children:"Retry"})]}):0===w.length?(0,t.jsxs)("div",{className:"text-center py-12 text-gray-500",children:[(0,t.jsx)("p",{className:"text-xl font-bold",children:"No raffles participated yet"}),(0,t.jsx)("p",{className:"mt-2",children:"Start participating in raffles n
1ow!"}),(0,t.jsxs)("p",{className:"mt-2 text-sm",children:["Debug: Found ",w.length," participated raffles"]})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:w.map(e=>(0,t.jsx)("div",{className:"bg-linear-to-br from-pink-50 to-purple-50 border-4 border-black shadow-[6px_6px_0px_#000] hover:shadow-[4px_4px_0px_#000] hover:translate-x-[2px] hover:translate-y-[2px] transition-all duration-100",children:(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"bg-white border-2 border-black h-52 mb-4 flex items-center justify-center relative overflow-hidden",children:[e.imageUrl?(0,t.jsx)(r.default,{src:e.imageUrl,alt:e.title,fill:!0,className:"object-cover",onError:t=>{console.log("Image failed to load:",e.imageUrl),t.currentTarget.style.display="none";let a=t.currentTarget.nextElementSibling;a&&(a.style.display="flex")}}):null,(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center bg-linear-to-br from-blue-100 to-purple-100 ".concat(e.imageUrl?"absolute inset-0 hidden":""),children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("div",{className:"text-6xl mb-2",children:"ð«"}),(0,t.jsx)("p",{className:"text-sm font-bold text-gray-600",children:"Raffle"})]})})]}),(0,t.jsx)("h3",{className:"font-black text-lg mb-2 uppercase",children:e.title}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsxs)("p",{className:"font-bold",children:["Entered: ",e.entryDate]}),(0,t.jsxs)("p",{className:"font-bold",children:["Tickets: ",e.tickets]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"inline-block text-white px-3 py-1 border-2 border-black font-bold uppercase text-xs ".concat("ongoing"===e.status?"bg-blue-500":"ended"===e.status?"bg-yellow-500":"bg-gray-500"),children:e.status}),e.isWinner&&(0,t.jsx)("span",{className:"inline-block bg-green-500 text-white px-3 py-1 border-2 border-black font-bold uppercase text-xs",children:"ð Winner!"})]})]})]})},e.address))})]})]})})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.