import Image from "next/image";
import Link from "next/link";
import { ChevronLeftIcon } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
import { SiteHeader } from "@/components/public/site-header";
import { LiveRefresh } from "@/components/live-refresh";
import type { PublicGuide } from "@/lib/guides/queries";
import { cn } from "@/lib/utils";
function hasSection(guide: PublicGuide, slug: string): boolean {
if (slug === "weapon") return guide.weapons.length > 0;
if (slug === "artifact") return guide.artifactGroups.some((group) => group.rows.length > 0) || Boolean(guide.artifactProfile && (guide.artifactProfile.sands.length || guide.artifactProfile.goblet.length || guide.artifactProfile.circlet.length));
if (slug === "constellations") return guide.constellations.length > 0;
if (slug === "team") return guide.teams.length > 0;
return guide.extras.some((extra) => extra.slug === slug && extra.rows.length > 0);
}
export function publicSections(guide: PublicGuide) {
return guide.sections.filter((section) => hasSection(guide, section.slug));
}
export function StructuredGuideShell({ guide, section }: { guide: PublicGuide; section?: string }) {
const sections = publicSections(guide);
return
{guide.character.element ?
{guide.character.element} : null}
{section ? : } ;
}
function GuideOverview({ guide, sections }: { guide: PublicGuide; sections: ReturnType }) {
return
Build Overview
{guide.name}
{guide.overview}
{sections.length ?
{sections.map((item) => {item.title}เปิดดูคำแนะนำฉบับเต็ม)}
:
กำลังจัดทำเนื้อหากลับมาตรวจสอบอีกครั้งหลังผู้ดูแลเพิ่มข้อมูล}
;
}
function GuideSection({ guide, section }: { guide: PublicGuide; section: string }) {
if (section === "weapon") return ;
if (section === "artifact") return ;
if (section === "constellations") return ;
if (section === "team") return ;
const extra = guide.extras.find((item) => item.slug === section);
return extra ? : null;
}
function metric(value: string | null) { return value === null ? null : `${Number(value).toLocaleString(undefined, { maximumFractionDigits: 2 })}%`; }
function WeaponSection({ guide }: { guide: PublicGuide }) { return {guide.weapons.map((row, index) =>
{index + 1}. {row.weapon.name} R{row.refinement}
{row.weapon.weaponType}
{row.overallPercent ? Overall
{metric(row.overallPercent)}
: null}{row.personalPercent ? Personal
{metric(row.personalPercent)}
: null})}
; }
function ArtifactSection({ guide }: { guide: PublicGuide }) { const profile = guide.artifactProfile; return {guide.artifactGroups.map((group) =>
{group.name}{group.rows.map((row, index) => {row.second ? : null}
{index + 1}. {row.first.name}{row.second ? ` + ${row.second.name}` : ""}
{metric(row.percent)}
)})}
{profile ?
Recommended Stats{profile.targets.length ? Target Stats
{profile.targets.map((target) =>
{target.stat}{target.value}
)}
: null}{profile.talents.length ? Talent Priority
{[...profile.talents].sort((a,b) => a.priority-b.priority).map((talent) => {talent.priority}. {talent.type}{talent.level ? ` ${talent.level}` : ""})}
: null}{profile.note ? {profile.note}
: null} : null}
; }
function StatLine({ label, values }: { label: string; values: string[] }) { return {label}
{values.map((value) => {value})}
; }
function ConstellationSection({ guide }: { guide: PublicGuide }) { return {guide.constellations.map((row) =>
{row.iconUrl ? : null}C{row.level} · {row.name}{metric(row.cumulativePercent)} of C0{row.detail}
)}
; }
function TeamSection({ guide }: { guide: PublicGuide }) { return คำนวณความเสียหาย
Team Calc
{guide.teams.map((team) => { const total = team.members.reduce((sum, member) => sum + Number(member.damage), 0); const seconds = Number(team.rotationSeconds); return
{team.title}{seconds}s rotation{team.members.map((member) =>
{member.character.name}
{Number(member.damage).toLocaleString(undefined, { maximumFractionDigits: 2 })}
{total ? (Number(member.damage) / total * 100).toFixed(2) : "0.00"}%
)}
Total damage
{total.toLocaleString()}
Total DPS
{(total / seconds).toLocaleString(undefined, { maximumFractionDigits: 0 })}
{team.combo}
; })}
; }
function ExtraSection({ extra }: { extra: PublicGuide["extras"][number] }) { return {extra.rows.map((row) =>
{row.imageUrl ?
: null}{row.heading}{row.body}{row.percent ? {metric(row.percent)} : null})}
; }