"use client"
import { getHeads } from "@/lib/hypixel/skywars/skywars"
import { cn } from "@/lib/utils"
import Image from "next/image"
import Link from "next/link"
import { useEffect, useState } from "react"
import { Tooltip } from "react-tooltip"
export function PresigeousHeads({ heads }: { heads: { username: string, timestamp: number, sacrifice: string }[] }) {
const [pos, setPos] = useState({ x: 0, y: 0 })
useEffect(() => {
const controller = new AbortController()
window.addEventListener("mousemove", (e) => {
if (!(e.target instanceof HTMLImageElement)) return
if (e.target.dataset.id !== "presigeous-heads") return
setPos({ x: e.clientX, y: e.clientY - 10 })
}, { signal: controller.signal })
return () => {
controller.abort()
}
})
return (
{heads.map(({ username, sacrifice }, index) => {
const text = sacrifice.at(0) + sacrifice.split("").slice(1, sacrifice.length).join("").toLowerCase()
return (
)
})}
)
}
export function HeadsBar({ heads, heads_total }: { heads: [string, number][], heads_total: number }) {
const [pos, setPos] = useState({ x: 0, y: 0 })
useEffect(() => {
const controller = new AbortController()
window.addEventListener("mousemove", (e) => {
if (!(e.target instanceof HTMLDivElement)) return
if (e.target.dataset.id !== "heads-bar") return
setPos({ x: e.clientX, y: e.clientY - 10 })
}, { signal: controller.signal })
return () => {
controller.abort()
}
})
return (
<>
{heads.map(([key, total], index) => {
const head = getHeads(key)
const percent = heads_total === 0 ? 0 : total / heads_total
return (
)
})}
>
)
}