/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see .
*/
/** @jsxRuntime automatic */
/** @jsxImportSource hono/jsx */
import {hasPermission} from '@fluxer/admin/src/AccessControlList';
import type {Archive} from '@fluxer/admin/src/api/Archives';
import {listArchives} from '@fluxer/admin/src/api/Archives';
import {getErrorMessage} from '@fluxer/admin/src/api/Errors';
import type {GuildLookupResult} from '@fluxer/admin/src/api/Guilds';
import {lookupGuild} from '@fluxer/admin/src/api/Guilds';
import {ErrorCard} from '@fluxer/admin/src/components/ErrorDisplay';
import {Layout} from '@fluxer/admin/src/components/Layout';
import {HStack} from '@fluxer/admin/src/components/ui/Layout/HStack';
import {VStack} from '@fluxer/admin/src/components/ui/Layout/VStack';
import {Heading, Text} from '@fluxer/admin/src/components/ui/Typography';
import {EmojisTab} from '@fluxer/admin/src/pages/guild_detail/tabs/EmojisTab';
import {FeaturesTab} from '@fluxer/admin/src/pages/guild_detail/tabs/FeaturesTab';
import {MembersTab} from '@fluxer/admin/src/pages/guild_detail/tabs/MembersTab';
import {ModerationTab} from '@fluxer/admin/src/pages/guild_detail/tabs/ModerationTab';
import {OverviewTab} from '@fluxer/admin/src/pages/guild_detail/tabs/OverviewTab';
import {SettingsTab} from '@fluxer/admin/src/pages/guild_detail/tabs/SettingsTab';
import {StickersTab} from '@fluxer/admin/src/pages/guild_detail/tabs/StickersTab';
import type {Session} from '@fluxer/admin/src/types/App';
import type {AdminConfig as Config} from '@fluxer/admin/src/types/Config';
import {AdminACLs} from '@fluxer/constants/src/AdminACLs';
import {formatTimestamp} from '@fluxer/date_utils/src/DateFormatting';
import type {Flash} from '@fluxer/hono/src/Flash';
import type {UserAdminResponse} from '@fluxer/schema/src/domains/admin/AdminUserSchemas';
import {Button} from '@fluxer/ui/src/components/Button';
import {CsrfInput} from '@fluxer/ui/src/components/CsrfInput';
import {EmptyState} from '@fluxer/ui/src/components/EmptyState';
import {getGuildIconUrl, getInitials as getInitialsFromName} from '@fluxer/ui/src/utils/FormatUser';
import type {Child, FC} from 'hono/jsx';
interface GuildDetailPageProps {
config: Config;
session: Session;
currentAdmin: UserAdminResponse | undefined;
flash: Flash | undefined;
guildId: string;
referrer?: string | undefined;
tab?: string | undefined;
page?: string | undefined;
assetVersion: string;
csrfToken: string;
}
interface Tab {
label: string;
path: string;
active: boolean;
}
function canViewArchives(adminAcls: Array): boolean {
return adminAcls.some(
(acl) =>
acl === AdminACLs.ARCHIVE_VIEW_ALL || acl === AdminACLs.ARCHIVE_TRIGGER_GUILD || acl === AdminACLs.WILDCARD,
);
}
function canManageAssets(adminAcls: Array): boolean {
return hasPermission(adminAcls, AdminACLs.ASSET_PURGE);
}
function getStatusText(archive: Archive): string {
if (archive.failed_at) {
return 'Failed';
}
if (archive.completed_at) {
return 'Completed';
}
return archive.progress_step ?? 'In Progress';
}
const RenderTabs: FC<{config: Config; tabs: Array}> = ({config, tabs}) => {
return (
);
};
const RenderArchiveTable: FC<{config: Config; archives: Array}> = ({config, archives}) => {
if (archives.length === 0) {
return (
);
}
return (