/*
Copyright (C) 2025 QuantumNous
This program 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.
This program 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 this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
import React, {
useState,
useEffect,
Suspense,
lazy,
useContext,
useMemo,
} from 'react';
import { useTranslation } from 'react-i18next';
import { initVChartTheme } from '@/components/ui/chartTheme';
import {
Button,
Spin,
Radio,
DatePicker,
Collapsible,
Tabs,
TabPane,
} from '@/components/ui';
import { IconRefresh } from '@/components/ui/icons';
import {
BarChart2,
Users,
TrendingUp,
Server,
Trophy,
CreditCard,
FileText,
UserCheck,
Wallet,
ShieldAlert,
History,
Upload,
Building2,
Activity,
} from 'lucide-react';
import useAnalyticsData from '../../hooks/analytics/useAnalyticsData';
import useOrgConsumptionData from '../../hooks/analytics/useOrgConsumptionData';
import useRiskControlData from '../../hooks/analytics/useRiskControlData';
import OverviewCards from '../../components/analytics/OverviewCards';
import TrendCharts from '../../components/analytics/TrendCharts';
import ChannelConsumption from '../../components/analytics/ChannelConsumption';
import UserRanking from '../../components/analytics/UserRanking';
import TopupChannelChart from '../../components/analytics/TopupChannelChart';
import DailyStatsTable from '../../components/analytics/DailyStatsTable';
import CollapsibleHeader from '../../components/analytics/CollapsibleHeader';
import UserSurveyStats from '../../components/analytics/UserSurveyStats';
import UserTopupRanking from '../../components/analytics/UserTopupRanking';
import HighFreqLowCostUsers from '../../components/analytics/HighFreqLowCostUsers';
import RiskControlRulesModal from '../../components/analytics/RiskControlRulesModal';
import RiskControlBanLogs from '../../components/analytics/RiskControlBanLogs';
import OrgReportPanel from '../../components/analytics/orgReport';
import { StatusContext } from '../../context/Status';
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
// audit 面板单独切 chunk:仅用户切到审计 Tab 时按需加载
const ExperienceCenterAuditPanel = lazy(
() => import('../ExperienceCenterAudit'),
);
// 调用质量看板单独切 chunk(含多张图表),仅切到该 Tab 时加载
const QualityDashboard = lazy(
() => import('../../components/quality/QualityDashboard'),
);
// 内嵌的 chunk 加载占位:不能用全屏的 ,否则会撑出 100vh 的开机闪屏
const TabChunkFallback = () => (