import{jsx as e,jsxs as r}from"react/jsx-runtime";import{C as c}from"./class-icon-CASn9-jM.js";import{B as p}from"./badge-CFi7bqqA.js";import{r as m}from"../app.js";import{memo as h,useState as b,useCallback as g,useEffect as x}from"react";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-slot";import"class-variance-authority";/* empty css     */import"axios";import"sonner";import"@inertiajs/react";import"react-dom/client";const u=a=>a===1?"bg-yellow-100 text-yellow-800 border-yellow-300 dark:bg-yellow-900/60 dark:text-yellow-300 dark:border-yellow-700":a===2?"bg-gray-100 text-gray-800 border-gray-300 dark:bg-gray-700/60 dark:text-gray-300 dark:border-gray-600":a===3?"bg-orange-100 text-orange-800 border-orange-300 dark:bg-orange-900/60 dark:text-orange-300 dark:border-orange-700":"bg-blue-100 text-blue-800 border-blue-300 dark:bg-blue-900/60 dark:text-blue-300 dark:border-blue-700",z=h(function({topSpenders:l,widgetBackgroundUrl:n}){const[s,d]=b(l),o=g(async()=>{try{const t=await fetch(m("api.topspenders"));if(t.ok){const i=await t.json();d(i)}}catch{}},[]);return x(()=>{const t=setInterval(o,6e4);return()=>clearInterval(t)},[o]),e("div",{className:"side-block rounded-lg border p-4",style:{backgroundImage:`url('${n||"/img/step/bg.webp"}')`,backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundColor:"transparent"},children:r("div",{className:"flex flex-col gap-3",children:[r("div",{className:"flex items-center gap-4",children:[e("div",{className:"flex-shrink-0",children:e("img",{src:"/img/step/pic-red-pvp.webp",alt:"Top Spender Icon",width:159,height:158,className:"h-16 w-auto",style:{filter:"hue-rotate(50deg)"}})}),e("h3",{className:"text-xl font-bold tracking-widest text-white",style:{fontFamily:"serif"},children:"TOP SPENDER"})]}),e("div",{className:"w-full",children:s&&s.length>0?e("div",{className:"overflow-x-auto",children:r("table",{className:"w-full text-sm",children:[e("thead",{children:r("tr",{className:"border-b border-white/30",children:[e("th",{className:"px-2 py-2 text-left text-xs font-bold text-white/80 uppercase",children:"Rank"}),e("th",{className:"px-2 py-2 text-left text-xs font-bold text-white/80 uppercase",children:"Player"}),e("th",{className:"px-2 py-2 text-right text-xs font-bold text-white/80 uppercase",children:"Total"})]})}),e("tbody",{children:s.slice(0,10).map(t=>r("tr",{className:"border-b border-white/10 transition-colors hover:bg-white/5",children:[e("td",{className:"px-2 py-3",children:e(p,{variant:"outline",className:u(t.rank),children:t.rank})}),e("td",{className:"px-2 py-3",children:r("div",{className:"flex items-center gap-2",children:[t.class!==null&&t.class_name&&t.class_name!=="Unknown"&&e(c,{classId:t.class,size:"md"}),e("span",{className:"font-medium text-white",children:t.name})]})}),e("td",{className:"px-2 py-3 text-right",children:r("span",{className:"font-semibold text-yellow-400",children:["Rp. ",t.amount.toLocaleString("id-ID")]})})]},t.id))})]})}):r("div",{className:"py-4 text-center text-white/60",children:[e("p",{className:"font-medium",children:"No Top Spenders Yet"}),e("p",{className:"text-sm",children:"Be the first to top up!"})]})})]})})});export{z as TopSpenderWidget};
