<template>
	<div class="home-wrapper">
		<div class="home-main" ref="containerRef">
			<div class="home-top-bg"></div>

			<div class="home-content">
				<div class="home-content-header">
					<SearchContainer style="margin-bottom: 0; height: fit-content" v-if="containerRef" placeholder="搜索科技法案"
						:containerRef="containerRef" areaName="法案" :enableBillTypeSwitch="true" defaultBillSearchType="federal" />
				</div>

				<div class="committee-cards-section">
					<div class="committee-cards-filter">
						<span class="committee-cards-desc">近期美国国会各委员会涉华提案数量汇总</span>
						<el-radio-group v-model="committeeTimeRange" class="committee-time-switch" size="default">
							<el-radio-button v-for="item in committeeTimeOptions" :key="item.value" :label="item.value">
								<span class="committee-time-switch-inner">
									<el-icon v-if="committeeTimeRange === item.value" class="committee-time-switch-icon">
										<Calendar />
									</el-icon>
									{{ item.label }}
								</span>
							</el-radio-button>
						</el-radio-group>
					</div>
					<div class="committee-cards-row">
						<div v-for="item in committeeCardList" :key="item.id" class="committee-card">
							<div class="committee-card-icon"></div>
							<div class="committee-card-content">
								<div class="committee-card-name">{{ item.name }}</div>
								<div class="committee-card-chamber">{{ item.chamber }}</div>
							</div>
							<div class="committee-card-count">{{ item.count }}项 &gt;</div>
						</div>
					</div>
				</div>

				<DivideHeader id="position1" class="divide1" :titleText="'最新动态'"></DivideHeader>
				<div class="home-content-center">
					<div class="center-top">
						<overviewMainBox class="box1" title="热门法案" @toDetail="handleClickToDetail">
							<template #headerIcon>
								<img style="width: 100%; height: 100%" src="./assets/images/box1-header-icon.png"
									alt="" />
							</template>
							<div class="box1-left" @click="handleSwithCurBill('left')">
								<div class="icon">
									<img src="./assets/images/box1-left.svg" alt="" />
								</div>
							</div>
							<div class="box1-right" @click="handleSwithCurBill('right')">
								<div class="icon">
									<img src="./assets/images/box1-right.svg" alt="" />
								</div>
							</div>
							<div class="box1-main" style="display: block">
								<el-carousel ref="carouselRef" height="354px" :autoplay="true" :interval="3000" arrow="never"
									indicator-position="none" @change="handleCarouselChange">
									<el-carousel-item v-for="(bill, billIndex) in hotBillList" :key="billIndex">
										<div class="carousel-content" style="display: flex; height: 100%">
											<div class="box1-main-left">
												<div class="box1-main-left-title">
													{{ bill.billName }}
												</div>
												<div class="box1-main-left-info">
													<AreaTag v-for="(item, index) in bill.hylyList" :key="index" :tagName="item.industryName">
													</AreaTag>
												</div>
												<div class="box1-main-left-info1">
													<div class="info1-box">
														<div class="icon"></div>
														<div class="info1-box-left">{{ "提案人：" }}</div>
														<div class="info1-box-right">{{ bill.tarName }}</div>
													</div>
													<div class="info1-box">
														<div class="icon"></div>
														<div class="info1-box-left">{{ "提出时间：" }}</div>
														<div class="info1-box-right">
															{{ bill.introductionDate }}
														</div>
													</div>
												</div>
												<div class="box1-main-left-info2">
													<div class="info2-item" v-for="(item, index) in bill.dyqkList" :key="index">
														<div class="time-line" v-if="index !== bill.dyqkList.length - 1"></div>
														<div class="item-icon">
															<img src="./assets/images/info2-icon.png" alt="" />
														</div>
														<div class="item-time" :class="{ itemTimeActive: index === 0 }">
															{{ item.actionDate }}
														</div>
														<div class="item-title" :class="{ itemTitleActive: index === 0 }">
															{{ item.actionContentCn }}
														</div>
													</div>
												</div>
											</div>
											<div class="box1-main-right">
												<img :src="bill.news?.newsImage" alt="" />
												<div class="inner-box">
													<div class="inner-box-header">
														<div class="inner-box-title">
															{{ bill.news?.newsTitle }}
														</div>
														<div class="inner-box-time">
															{{ bill.news?.newsTime.replace("T", " ") }}
														</div>
													</div>
													<div class="inner-box-content">
														{{ bill.news?.newsContent }}
													</div>
												</div>
											</div>
										</div>
									</el-carousel-item>
								</el-carousel>
							</div>
						</overviewMainBox>
						<RiskSignal :list="warningList" @more-click="handleToMoreRiskSignal" @item-click="handleClickToDetailO"
							riskLevel="signalLevel" postDate="signalTime" name="signalTitle" />
					</div>

					<DivideHeader id="position2" class="divide2" :titleText="'资讯要闻'"></DivideHeader>
					<div class="center-center">
						<NewsList :newsList="newsList" img="newsImage" title="newsTitle" from="from"
							content="newsContent" />
						<MessageBubble :messageList="messageList" imageUrl="personImage"
							@more-click="handleToSocialDetail" @person-click="handleClickToCharacter" name="personName"
							content="remarks" source="orgName" />
					</div>

					<DivideHeader id="position3" class="divide3" :titleText="'数据总览'"></DivideHeader>
					<div class="center-footer">
						<OverviewCard class="overview-card--double box5" title="涉华法案数量变化趋势" :icon="box5HeaderIcon">
							<template #right>
								<el-select v-model="box5Select" placeholder="选择领域" @change="handleBox5Change"
									style="width: 150px">
									<el-option label="全部领域" value="全部领域" />
									<el-option v-for="item in categoryList" :key="item.id" :label="item.name"
										:value="item.id" />
								</el-select>
								<el-select v-model="box5ProposalTime" placeholder="提案时间" @change="handleBox5Change"
									style="width: 120px; margin-left: 8px">
									<el-option v-for="item in box5ProposalTimeList" :key="item.value"
										:label="item.label" :value="item.value" />
								</el-select>
							</template>
							<div class="overview-card-body box5-main">
								<div class="overview-chart-wrap" :class="{ 'is-empty': !box5HasData }">
									<el-empty v-if="!box5HasData" description="暂无数据" :image-size="100" />
									<div v-else id="box5Chart" class="overview-chart"></div>
								</div>
								<div class="overview-tip-row">
									<TipTab class="overview-tip" />
									<AiButton class="overview-tip-action" @mouseenter="handleShowAiPane('box5')" />
								</div>
								<div v-if="aiPaneVisible.box5" class="overview-ai-pane"
									@mouseleave="handleHideAiPane('box5')">
									<AiPane :aiContent="overviewAiContent.box5" />
								</div>
							</div>
						</OverviewCard>
						<OverviewCard class="overview-card--single box6" title="涉华法案领域分布" :icon="box6HeaderIcon">
							<template #right>
								<el-select v-model="box9selectetedTime" placeholder="选择时间" style="width: 90px">
									<el-option v-for="item in box9YearList" :key="item.value" :label="item.label"
										:value="item.value" />
								</el-select>
								<el-select v-model="box9LegislativeStatus" placeholder="立法状态" @change="handleBox9StatusChange"
									style="width: 110px; margin-left: 8px">
									<el-option v-for="item in box9LegislativeStatusList" :key="item.value"
										:label="item.label" :value="item.value" />
								</el-select>
							</template>
							<div class="overview-card-body box6-main">
								<div class="overview-chart-wrap" :class="{ 'is-empty': !box9HasData }">
									<el-empty v-if="!box9HasData" description="暂无数据" :image-size="100" />
									<div v-else id="box9Chart" class="overview-chart"></div>
								</div>
								<div class="overview-tip-row">
									<TipTab class="overview-tip" />
									<AiButton class="overview-tip-action" @mouseenter="handleShowAiPane('box6')" />
								</div>
								<div v-if="aiPaneVisible.box6" class="overview-ai-pane"
									@mouseleave="handleHideAiPane('box6')">
									<AiPane :aiContent="overviewAiContent.box6" />
								</div>
							</div>
						</OverviewCard>
					</div>
					<div class="center-footer1">
						<OverviewCard class="overview-card--single box7" title="涉华法案提出部门" :icon="box7HeaderIcon">
							<template #right>
								<el-select v-model="box7selectetedTime" placeholder="选择时间" style="width: 90px">
									<el-option v-for="item in box7YearList" :key="item.value" :label="item.label"
										:value="item.value" />
								</el-select>
							</template>
							<div class="overview-card-body box7-main">
								<div class="overview-chart-wrap" :class="{ 'is-empty': !box7HasData }">
									<el-empty v-if="!box7HasData" description="暂无数据" :image-size="100" />
									<div v-else id="box7Chart" class="overview-chart"></div>
								</div>
								<div class="overview-tip-row">
									<TipTab class="overview-tip" />
									<AiButton class="overview-tip-action" @mouseenter="handleShowAiPane('box7')" />
								</div>
								<div v-if="aiPaneVisible.box7" class="overview-ai-pane"
									@mouseleave="handleHideAiPane('box7')">
									<AiPane :aiContent="overviewAiContent.box7" />
								</div>
							</div>
						</OverviewCard>
						<OverviewCard class="overview-card--single box8" title="涉华法案进展分布" :icon="box7HeaderIcon">
							<template #right>
								<el-select v-model="box8selectetedTime" placeholder="选择时间" style="width: 90px">
									<el-option v-for="item in box8YearList" :key="item.value" :label="item.label"
										:value="item.value" />
								</el-select>
							</template>
							<div class="overview-card-body box8-main">
								<div class="overview-chart-wrap" :class="{ 'is-empty': !box8HasData }">
									<el-empty v-if="!box8HasData" description="暂无数据" :image-size="100" />
									<template v-else>
										<div class="box8-desc">• 通过涉华法案{{ box8Summary }}项</div>
										<div id="box8Chart" class="overview-chart box8-chart"></div>
									</template>
								</div>
								<div class="overview-tip-row">
									<TipTab class="overview-tip" />
									<AiButton class="overview-tip-action" @mouseenter="handleShowAiPane('box8')" />
								</div>
								<div v-if="aiPaneVisible.box8" class="overview-ai-pane"
									@mouseleave="handleHideAiPane('box8')">
									<AiPane :aiContent="overviewAiContent.box8" />
								</div>
							</div>
						</OverviewCard>
						<OverviewCard class="overview-card--single box9" title="涉华法案关键条款" :icon="box7HeaderIcon">
							<div class="overview-card-body box9-main">
								<div class="overview-chart-wrap">
									<el-empty v-if="!wordCloudHasData" description="暂无数据" :image-size="100" />
									<WordCloundChart v-else class="overview-chart" width="100%" height="100%"
										:data="wordCloudData" />
								</div>
								<div class="overview-tip-row">
									<TipTab class="overview-tip" />
									<AiButton class="overview-tip-action" @mouseenter="handleShowAiPane('box9')" />
								</div>
								<div v-if="aiPaneVisible.box9" class="overview-ai-pane"
									@mouseleave="handleHideAiPane('box9')">
									<AiPane :aiContent="overviewAiContent.box9" />
								</div>
							</div>
						</OverviewCard>
					</div>
				</div>
			</div>
			<div class="home-content-footer">
				<DivideHeader id="position4" class="divide4" :titleText="'资源库'"></DivideHeader>
				<ResourceLibrarySection :on-click-to-detail="handleClickToDetailO"
					:on-after-page-change="handlePageChange" />
			</div>
		</div>
	</div>
</template>

<script setup>
import RiskSignal from "@/components/base/riskSignal/index.vue";
import { onMounted, ref, onUnmounted, nextTick, watch, computed } from "vue";
import router from "@/router/index";
import setChart from "@/utils/setChart";
import {
	getBillIndustry,
	getHotBills,
	getBillRiskSignal,
	getHylyList,
	getBillOverviewKeyTK,
	getBillCount,
	getBillPostOrg,
	getBillProcess,
	getNews,
	getRemarks
} from "@/api/bill/billHome";
import { getPersonSummaryInfo } from "@/api/common/index";
import { getChartAnalysis } from "@/api/aiAnalysis/index";
import DivideHeader from "@/components/DivideHeader.vue";
import overviewMainBox from "@/components/base/boxBackground/overviewMainBox.vue";
import OverviewCard from "./OverviewCard.vue";
import ResourceLibrarySection from "./ResourceLibrarySection.vue";
import { useContainerScroll } from "@/hooks/useScrollShow";
import TipTab from "@/components/base/TipTab/index.vue";
import AiButton from "@/components/base/Ai/AiButton/index.vue";
import AiPane from "@/components/base/Ai/AiPane/index.vue";
import WordCloundChart from "@/components/base/WordCloundChart/index.vue";

import getMultiLineChart from "./utils/multiLineChart";
import getPieChart from "./utils/piechart";
import getDoublePieChart from "./utils/doublePieChart";

import box5HeaderIcon from "./assets/images/box5-header-icon.png";
import box6HeaderIcon from "./assets/images/box6-header-icon.png";
import box7HeaderIcon from "./assets/images/box7-header-icon.png";


import { ElMessage } from "element-plus";
import { Calendar } from "@element-plus/icons-vue";

// 跳转人物主页
const handleClickToCharacter = async (id, name) => {
	const personTypeList = JSON.parse(window.sessionStorage.getItem("personTypeList"));

	let type = 0;
	let personTypeName = "";

	const params = {
		personId: id
	};
	try {
		const res = await getPersonSummaryInfo(params);
		console.log("人物全局信息2", res);
		if (res.code === 200 && res.data) {
			const arr = personTypeList.filter(item => {
				return item.typeId === res.data.personType;
			});
			console.log("arr", arr);

			if (arr && arr.length > 0) {
				personTypeName = arr[0].typeName;
				console.log("personTypeName", personTypeName);

				if (personTypeName === "科技企业领袖") {
					type = 1;
				} else if (personTypeName === "国会议员") {
					type = 2;
				} else if (personTypeName === "智库研究人员") {
					type = 3;
				} else {
					personTypeName = "";
					ElMessage.warning("找不到当前人员的类型值！");
					return;
				}
				window.sessionStorage.setItem("curTabName", name);
				const route = router.resolve({
					path: "/characterPage",
					query: {
						type: type, // type=1为科技企业领袖，2为国会议员，3为智库研究人员
						personId: id
					}
				});
				window.open(route.href, "_blank");
			} else {
				personTypeName = "";
				ElMessage.warning("找不到当前人员的类型值！");
				return;
			}
		} else {
			ElMessage.warning("找不到当前人员的类型值！");
			return;
		}
	} catch (error) { }
};

const containerRef = ref(null);
const { isShow } = useContainerScroll(containerRef);

// 委员会卡片占位数据
const committeeTimeRange = ref("近一月");
const committeeTimeOptions = [
	{ label: "近一周", value: "近一周" },
	{ label: "近一月", value: "近一月" },
	{ label: "近一年", value: "近一年" }
];
const committeeCardList = ref([
	{ id: 1, name: "众议院外交委员会", chamber: "众议院", count: 42 },
	{ id: 2, name: "参议院军事委员会", chamber: "参议院", count: 28 },
	{ id: 3, name: "众议院情报委员会", chamber: "众议院", count: 19 }
]);

const hotBillList = ref([]); // 热门法案列表
const carouselRef = ref(null);

const handleCarouselChange = index => {
	if (hotBillList.value && hotBillList.value.length > 0) {
		curBill.value = hotBillList.value[index];
	}
};

// 切换热门法案
const handleSwithCurBill = name => {
	if (name === "left") {
		carouselRef.value.prev();
	} else {
		carouselRef.value.next();
	}
};

// 当前法案
const curBill = ref({
	billName: "",
	billId: 0,
	dyqkList: [],
	hylyList: [],
	tarName: "",
	introductionDate: ""
});

// 查看详情
const handleClickToDetail = () => {
	window.sessionStorage.setItem("billId", curBill.value.billId);
	window.sessionStorage.setItem("curTabName", curBill.value.billName);
	const route = router.resolve({
		path: "/billLayout",
		query: {
			billId: curBill.value.billId
		}
	});
	console.log(route);

	window.open(route.href, "_blank");
};
// 查看详情 传递参数
const handleClickToDetailO = item => {
	window.sessionStorage.setItem("billId", item.billId);
	window.sessionStorage.setItem("curTabName", item.name || item.signalTitle);
	const route = router.resolve("/billLayout?billId=" + item.billId);
	window.open(route.href, "_blank");
};

// 查看更多风险信号
const handleToMoreRiskSignal = () => {
	const route = router.resolve("/viewRiskSignal");
	window.open(route.href, "_blank");
};
// 风险信号
const warningList = ref([]);

const box7selectetedTime = ref("2025");
const box7YearList = ref([
	{
		label: "2025",
		value: "2025"
	},
	{
		label: "2024",
		value: "2024"
	},
	{
		label: "2023",
		value: "2023"
	},
	{
		label: "2022",
		value: "2022"
	}
]);

const aiPaneVisible = ref({
	box5: false,
	box6: false,
	box7: false,
	box8: false,
	box9: false
});

const overviewAiContent = ref({
	box5: "智能总结生成中...",
	box6: "智能总结生成中...",
	box7: "智能总结生成中...",
	box8: "智能总结生成中...",
	box9: "智能总结生成中..."
});

const aiPaneFetched = ref({
	box5: false,
	box6: false,
	box7: false,
	box8: false,
	box9: false
});

const aiPaneLoading = ref({
	box5: false,
	box6: false,
	box7: false,
	box8: false,
	box9: false
});

const buildAiChartPayload = key => {
	if (key === "box5") {
		const title = Array.isArray(box5Data.value.title) ? box5Data.value.title : [];
		const proposed = box5Data.value?.data?.[0]?.value || [];
		const passed = box5Data.value?.data?.[1]?.value || [];
		const rate =
			box5Data.value.percent ||
			title.map((_, i) => {
				const p = Number(proposed[i] || 0);
				const pass = Number(passed[i] || 0);
				return p ? Number(((pass / p) * 100).toFixed(2)) : 0;
			});
		return {
			type: "折线图",
			name: "涉华法案数量变化趋势",
			data: title.map((month, i) => ({
				month,
				proposed: Number(proposed[i] || 0),
				passed: Number(passed[i] || 0),
				pass_rate: Number(rate[i] || 0)
			}))
		};
	}

	if (key === "box6") {
		return {
			type: "饼图",
			name: "涉华法案领域分布",
			data: (Array.isArray(box9ChartData.value) ? box9ChartData.value : []).map(item => ({
				industry_name: item.industryName,
				count_bill: Number(item.countBill || 0)
			}))
		};
	}

	if (key === "box7") {
		return {
			type: "环形图",
			name: "涉华法案提出部门",
			data: {
				inner: box7AiData.value.inner,
				outer: box7AiData.value.outer
			}
		};
	}

	if (key === "box8") {
		return {
			type: "柱状图",
			name: "涉华法案进展分布",
			data: box8StageList.value
		};
	}

	if (key === "box9") {
		return {
			type: "词云图",
			name: "涉华法案关键条款",
			data: Array.isArray(wordCloudData.value) ? wordCloudData.value : []
		};
	}

	return { type: "", name: "", data: [] };
};

const requestAiPaneContent = async key => {
	if (!key || aiPaneLoading.value[key] || aiPaneFetched.value[key]) return;
	aiPaneLoading.value = { ...aiPaneLoading.value, [key]: true };
	overviewAiContent.value = { ...overviewAiContent.value, [key]: "智能总结生成中..." };

	try {
		const payload = buildAiChartPayload(key);
		const res = await getChartAnalysis(
			{ text: JSON.stringify(payload) },
			{
				onChunk: chunk => {
					const current = overviewAiContent.value[key];
					const base = current === "智能总结生成中..." ? "" : current;
					overviewAiContent.value = {
						...overviewAiContent.value,
						[key]: base + chunk
					};
				}
			}
		);
		const list = res?.data;
		const first = Array.isArray(list) ? list[0] : null;
		const interpretation = first?.解读 || first?.["解读"];
		// 流式已渲染过内容，最终用解析出的解读覆盖（保证显示格式统一）
		if (interpretation) {
			overviewAiContent.value = {
				...overviewAiContent.value,
				[key]: interpretation
			};
		}
		aiPaneFetched.value = { ...aiPaneFetched.value, [key]: true };
	} catch (error) {
		console.error("获取图表解读失败", error);
		overviewAiContent.value = { ...overviewAiContent.value, [key]: "智能总结生成失败" };
	} finally {
		aiPaneLoading.value = { ...aiPaneLoading.value, [key]: false };
	}
};

const handleShowAiPane = key => {
	aiPaneVisible.value = {
		...aiPaneVisible.value,
		[key]: true
	};
	requestAiPaneContent(key);
};

const handleHideAiPane = key => {
	aiPaneVisible.value = {
		...aiPaneVisible.value,
		[key]: false
	};
};

const box8selectetedTime = ref("2025");
const box8YearList = ref([
	{
		label: "2025",
		value: "2025"
	},
	{
		label: "2024",
		value: "2024"
	},
	{
		label: "2023",
		value: "2023"
	},
	{
		label: "2022",
		value: "2022"
	}
]);
// 涉华法案数量使用的领域分类列表
const categoryList = ref([]);

// 获取领域分类
const handleGetHylyList = async () => {
	try {
		const res = await getHylyList();
		console.log("行业领域列表", res);
		categoryList.value = res.data;
	} catch (error) { }
};
// 新闻资讯
const newsList = ref([]);

// 社交媒体
const messageList = ref([]);

// 获取热门法案
const handleGetHotBills = async () => {
	try {
		const res = await getHotBills();
		console.log("热门法案", res);
		hotBillList.value = res.data;
	} catch (error) {
		console.error(error);
	}
};

// 获取法案风险信号
const handleGetBillRiskSignal = async () => {
	const params = {
		moduleId: "0100"
	};
	try {
		const res = await getBillRiskSignal(params);
		console.log("法案风险信号", res);
		if (res.code === 200) {
			warningList.value = res.data;
		}
	} catch (error) { }
};

// 获取新闻资讯
const handleGetNews = async () => {
	const params = {
		moduleId: "0100"
	};
	try {
		const res = await getNews(params);
		console.log("新闻资讯", res);
		if (res.code === 200 && Array.isArray(res.data)) {
			newsList.value = res.data.map(item => {
				return {
					...item,
					from: `${item.newsOrg} · ${item.newsDate ? item.newsDate.slice(5) : ""}`
				};
			});
		} else {
			newsList.value = [];
		}
	} catch (error) { }
};

// 获取社交媒体
const handleGetRemarks = async () => {
	const params = {
		moduleId: "0100"
	};
	try {
		const res = await getRemarks(params);
		console.log("社交媒体", res);
		if (res.code === 200) {
			messageList.value = res.data.map(item => {
				return {
					...item,
					time: item.time.replace("T", " ")
				};
			});
		}
	} catch (error) { }
};

// 涉华法案数量
const box5Select = ref("全部领域");
const box5ProposalTime = ref("近一年");
const box5ProposalTimeList = ref([
	{ label: "近一年", value: "近一年" },
	{ label: "近两年", value: "近两年" },
	{ label: "近三年", value: "近三年" },
	{ label: "全部", value: "全部" }
]);
const box5Data = ref({
	title: [
		"2024-09",
		"2024-10",
		"2024-11",
		"2024-12",
		"2025-01",
		"2025-02",
		"2025-03",
		"2025-04",
		"2025-05",
		"2025-06",
		"2025-07",
		"2025-08"
	],
	data: [
		{
			name: "提出法案",
			value: [145, 52, 84, 99, 71, 96, 128, 144, 140, 168, 188, 172]
		},
		{
			name: "通过法案",
			value: [6, 3, 4, 6, 11, 5, 2, 14, 16, 27, 28, 44]
		}
	]
});
const box5HasData = ref(true);
const handleGetBillCount = async () => {
	try {
		const params = {
			dateDesc: box5ProposalTime.value
		};
		if (box5Select.value !== "全部领域") {
			params.industryId = box5Select.value;
		}
		const res = await getBillCount(params);
		console.log("涉华法案统计", res);
		if (res.code === 200 && res.data && res.data.length > 0) {
			box5HasData.value = true;
			const sortedData = res.data.sort((a, b) => a.month.localeCompare(b.month));
			box5Data.value = {
				title: sortedData.map(item => item.month),
				data: [
					{
						name: "提出法案",
						value: sortedData.map(item => item.totalCount)
					},
					{
						name: "通过法案",
						value: sortedData.map(item => item.passCount)
					}
				],
				percent: sortedData.map(item => item.percent)
			};
		} else {
			// 接口异常（如500）时，清空图表数据以避免报错或显示错误信息
			box5HasData.value = false;
			box5Data.value = {
				title: [],
				data: [
					{ name: "提出法案", value: [] },
					{ name: "通过法案", value: [] }
				],
				percent: []
			};
		}
	} catch (error) {
		console.error("获取涉华法案统计error", error);
		// 发生错误时同样清空数据
		box5HasData.value = false;
		box5Data.value = {
			title: [],
			data: [
				{ name: "提出法案", value: [] },
				{ name: "通过法案", value: [] }
			],
			percent: []
		};
	}
};

const handleBox5 = async () => {
	await handleGetBillCount();
	if (box5HasData.value) {
		await nextTick();
		const proposed = box5Data.value.data[0].value;
		const passed = box5Data.value.data[1].value;
		const rate =
			box5Data.value.percent ||
			proposed.map((p, i) => {
				const pass = passed[i] || 0;
				return p ? ((pass / p) * 100).toFixed(2) : 0;
			});
		const box5Chart = getMultiLineChart(box5Data.value.title, proposed, passed, rate);
		setChart(box5Chart, "box5Chart");
	}
};

const handleBox5Change = () => {
	handleBox5();
};

// 法案提出部门
const box7HasData = ref(true);
const box7AiData = ref({ inner: [], outer: [] });
const handleBox7Data = async () => {
	try {
		const res = await getBillPostOrg({ year: box7selectetedTime.value });
		console.log("法案提出部门", res);
		const orgBillNumList = res?.data?.orgBillNumList || [];
		const orgBillNumMap = res?.data?.orgBillNumMap || {};
		if (res.code === 200 && Array.isArray(orgBillNumList) && orgBillNumList.length > 0) {
			box7HasData.value = true;
			// 必须等待DOM更新，因为v-if切换可能导致元素刚被创建
			await nextTick();

			const data1 = [];
			const houseTotal = Number(orgBillNumMap?.House || 0);
			const senateTotal = Number(orgBillNumMap?.Senate || 0);
			if (houseTotal > 0) data1.push({ name: "众议院", value: houseTotal });
			if (senateTotal > 0) data1.push({ name: "参议院", value: senateTotal });

			const getOrgTypeLabel = orgType => (orgType === "Senate" ? "参议院" : "众议院");
			const typeOrderMap = { 众议院: 0, 参议院: 1 };

			const data2 = orgBillNumList
				.map(item => ({
					name: item.orgName,
					value: Number(item.count || 0),
					percent: typeof item.percent === "number" ? item.percent : Number(item.percent || 0),
					type: getOrgTypeLabel(item.orgType)
				}))
				// 关键：外环顺序必须按内环（众→参）分组，否则扇区角度会交错导致“不对应”
				.sort((a, b) => {
					const t1 = typeOrderMap[a.type] ?? 99;
					const t2 = typeOrderMap[b.type] ?? 99;
					if (t1 !== t2) return t1 - t2;
					return (b.value ?? 0) - (a.value ?? 0);
				});

			const box7Chart = getDoublePieChart(data1, data2);
			setChart(box7Chart, "box7Chart");
			box7AiData.value = { inner: data1, outer: data2 };
		} else {
			// 接口异常（如500）时，清空图表数据以避免报错或显示错误信息
			box7HasData.value = false;
			setChart({}, "box7Chart");
			box7AiData.value = { inner: [], outer: [] };
		}
	} catch (error) {
		console.error("获取法案提出部门数据失败", error);
		box7HasData.value = false;
		box7AiData.value = { inner: [], outer: [] };
	}
};

watch(box7selectetedTime, () => {
	handleBox7Data();
});
// 查看社交媒体详情
const handleToSocialDetail = item => {
	const route = router.resolve({
		path: "/characterPage",
		query: {
			personId: item.id
		}
	});
	window.open(route.href, "_blank");
};
// 关键条款
const wordCloudData = ref([]);
const wordCloudHasData = computed(() => Array.isArray(wordCloudData.value) && wordCloudData.value.length > 0);
const handleGetKeyTK = async () => {
	try {
		const res = await getBillOverviewKeyTK();
		console.log("关键条款", res);
		if (res.code === 200 && res.data) {
			wordCloudData.value = res.data.map(item => {
				return {
					name: item.clause,
					value: item.count
				};
			});
		}
	} catch (error) {
		console.error("获取关键条款error", error);
	}
};
const handleBox6 = async () => {
	await handleGetKeyTK();
};

// 涉华领域分布
const box9ChartData = ref([]);
const box9selectetedTime = ref("2025");
const box9LegislativeStatus = ref("提出法案");
const box9LegislativeStatusList = ref([
	{ label: "提出法案", value: "提出法案" },
	{ label: "通过法案", value: "通过法案" }
]);
const box9YearList = ref([
	{
		label: "2026",
		value: "2026"
	},
	{
		label: "2025",
		value: "2025"
	},
	{
		label: "2024",
		value: "2024"
	},
	{
		label: "2023",
		value: "2023"
	},
	{
		label: "2022",
		value: "2022"
	}
]);
const box9HasData = ref(true);
let box9ChartInstance = null;
const getBox9Data = async () => {
	const params = {
		year: box9selectetedTime.value,
		status: box9LegislativeStatus.value
	};
	try {
		const res = await getBillIndustry(params);
		console.log("box9-涉华法案领域分布", res.data);
		if (res.code === 200 && res.data && res.data.length > 0) {
			box9HasData.value = true;
			box9ChartData.value = res.data;
		} else {
			box9HasData.value = false;
			box9ChartData.value = [];
		}
	} catch (error) {
		box9HasData.value = false;
		box9ChartData.value = [];
	}
};
const handleBox9Data = async () => {
	await getBox9Data();
	if (box9HasData.value) {
		await nextTick();
		const box9Chart = getPieChart(
			box9ChartData.value.map(item => {
				return {
					name: item.industryName,
					value: item.countBill
				};
			}),
			null,
			{ showCount: false }
		);
		box9ChartInstance = setChart(box9Chart, "box9Chart");
	}
};

watch(box9selectetedTime, () => {
	handleBox9Data();
});

const handleBox9StatusChange = () => {
	handleBox9Data();
};

const box8HasData = ref(true);
const box8Summary = ref(0);
let box8ChartInstance = null;
const box8StageList = ref([]);

const box8MockDataByYear = {
	"2025": {
		passCount: 19,
		stages: [
			{ name: "已提案", count: 24 },
			{ name: "众议院通过", count: 20 },
			{ name: "众议院不通过", count: 25 },
			{ name: "解决分歧", count: 23 },
			{ name: "参议院通过", count: 26 },
			{ name: "总统否决", count: 48 },
			{ name: "已立法", count: 19 }
		]
	}
};

const getBox8ChartOption = stageList => {
	const truncateLabel = (value, maxLen = 6) => {
		if (value === null || value === undefined) return "";
		const str = String(value);
		const chars = Array.from(str);
		if (chars.length <= maxLen) return str;
		return `${chars.slice(0, maxLen).join("")}...`;
	};

	const axisMax = 100;
	const countList = stageList.map(item => item.count || 0);
	const totalCount = countList.reduce((sum, cur) => sum + cur, 0);
	const safeTotal = totalCount > 0 ? totalCount : 1;
	const rawWidths = countList.map(count => (count / safeTotal) * axisMax);
	const markerData = rawWidths.map((width, index) => {
		if (index === rawWidths.length - 1) {
			const used = rawWidths.slice(0, index).reduce((sum, cur) => sum + Number(cur.toFixed(4)), 0);
			return Number(Math.max(axisMax - used, 0).toFixed(4));
		}
		return Number(width.toFixed(4));
	});
	let cumulative = 0;
	const offsetData = markerData.map(width => {
		const start = Number(cumulative.toFixed(4));
		cumulative += width;
		return start;
	});
	const trackData = stageList.map(() => axisMax);

	return {
		tooltip: {
			trigger: "item",
			confine: true,
			backgroundColor: "rgba(34, 44, 58, 0.92)",
			borderWidth: 0,
			textStyle: {
				color: "#fff",
				fontSize: 13
			},
			formatter: params => {
				const item = stageList[params.dataIndex];
				if (!item) return "";
				return `${item.name}<br/>${item.count}项`;
			}
		},
		grid: {
			left: 118,
			right: 60,
			top: 6,
			bottom: 6
		},
		xAxis: {
			type: "value",
			min: 0,
			max: axisMax,
			show: false
		},
		yAxis: {
			type: "category",
			inverse: true,
			data: stageList.map(item => item.name),
			axisTick: { show: false },
			axisLine: { show: false },
			axisLabel: {
				formatter: value => truncateLabel(value, 6),
				color: "#3b414b",
				fontSize: 16
			}
		},
		series: [
			{
				type: "bar",
				barWidth: 32,
				barGap: "-100%",
				silent: true,
				data: trackData,
				itemStyle: {
					color: params => (params.dataIndex === stageList.length - 1 ? "rgba(206, 79, 81, 0.1)" : "rgb(246, 250, 255)")
				},
				label: {
					show: true,
					position: "right",
					formatter: params => `${countList[params.dataIndex]}项`,
					color: params => (params.dataIndex === stageList.length - 1 ? "rgb(206, 79, 81)" : "#3b414b"),
					fontSize: 36 / 2,
					fontWeight: params => (params.dataIndex === stageList.length - 1 ? 700 : 400)
				}
			},
			{
				type: "bar",
				stack: "progress",
				barWidth: 32,
				silent: true,
				data: offsetData,
				itemStyle: { color: "transparent" }
			},
			{
				type: "bar",
				stack: "progress",
				barWidth: 32,
				data: markerData,
				itemStyle: {
					color: params => (params.dataIndex === stageList.length - 1 ? "rgb(206, 79, 81)" : "rgb(5, 95, 194)")
				},
				emphasis: {
					disabled: false,
					itemStyle: {
						borderColor: "rgba(255, 255, 255, 0.9)",
						borderWidth: 2,
						shadowBlur: 10,
						shadowColor: "rgba(5, 95, 194, 0.35)"
					}
				}
			}
		]
	};
};

const handleBox8Data = async () => {
	const stageOrder = ["提案", "众议院通过", "众议院不通过", "分歧已解决", "参议院通过", "总统否决或未签署", "完成立法"];
	const stageNameMap = {
		提案: "已提案",
		众议院通过: "众议院通过",
		众议院不通过: "众议院不通过",
		分歧已解决: "解决分歧",
		参议院通过: "参议院通过",
		"总统否决或未签署": "总统否决",
		完成立法: "已立法"
	};

	try {
		const res = await getBillProcess({ year: box8selectetedTime.value });
		console.log("涉华法案进展分布", res);
		if (res.code === 200 && res.data && res.data.length > 0) {
			const countMap = new Map(res.data.map(item => [item.progressName, item.countBill]));
			const stages = stageOrder.map(name => ({
				name: stageNameMap[name],
				count: countMap.get(name) || 0
			}));

			box8HasData.value = true;
			box8Summary.value = countMap.get("完成立法") || 0;
			box8StageList.value = stages;
			await nextTick();
			const box8Chart = getBox8ChartOption(stages);
			box8ChartInstance = setChart(box8Chart, "box8Chart");
		} else {
			const data = box8MockDataByYear[box8selectetedTime.value];
			if (data && data.stages && data.stages.length > 0) {
				box8HasData.value = true;
				box8Summary.value = data.passCount || 0;
				box8StageList.value = data.stages;
				await nextTick();
				const box8Chart = getBox8ChartOption(data.stages);
				box8ChartInstance = setChart(box8Chart, "box8Chart");
			} else {
				box8HasData.value = false;
				box8Summary.value = 0;
				box8StageList.value = [];
				setChart({}, "box8Chart");
			}
		}
	} catch (error) {
		console.error("获取涉华法案进展分布失败", error);
		const data = box8MockDataByYear[box8selectetedTime.value];
		if (data && data.stages && data.stages.length > 0) {
			box8HasData.value = true;
			box8Summary.value = data.passCount || 0;
			box8StageList.value = data.stages;
			await nextTick();
			const box8Chart = getBox8ChartOption(data.stages);
			box8ChartInstance = setChart(box8Chart, "box8Chart");
		} else {
			box8HasData.value = false;
			box8Summary.value = 0;
			box8StageList.value = [];
			setChart({}, "box8Chart");
		}
	}
};

watch(box8selectetedTime, () => {
	handleBox8Data();
});

const handleToPosi = id => {
	const element = document.getElementById(id);
	if (element && containerRef.value) {
		// 1. 如果是从完整搜索框跳转，先强制切换状态稳定布局
		if (!isShow.value) {
			isShow.value = true;
		}

		// 2. 使用 nextTick 等待 DOM 布局（如高度切换）完成后再进行坐标计算
		nextTick(() => {
			const containerRect = containerRef.value.getBoundingClientRect();
			const elementRect = element.getBoundingClientRect();
			// 使用 getBoundingClientRect 计算元素相对于容器顶部的绝对距离
			const top = elementRect.top - containerRect.top + containerRef.value.scrollTop;

			containerRef.value.scrollTo({
				top: top,
				behavior: "smooth"
			});
		});
	}
};

// 资源库分页变更后滚动到资源库区域
const handlePageChange = () => handleToPosi("position4");

const handleResize = () => {
	box8ChartInstance && box8ChartInstance.resize();
	box9ChartInstance && box9ChartInstance.resize();
};

onMounted(async () => {
	window.addEventListener("resize", handleResize);
	handleGetHylyList();
	handleGetBillRiskSignal();
	handleGetNews();
	handleGetRemarks();

	handleBox5(); //涉华法案统计
	handleBox6(); // 关键条款

	handleBox7Data();

	handleBox8Data();

	await handleGetHotBills();
	curBill.value = hotBillList.value[0];

	handleBox9Data();
});

onUnmounted(() => {
	window.removeEventListener("resize", handleResize);
});
</script>

<style lang="scss" scoped>
.home-wrapper {
	width: 100%;
	height: 100%;
	position: relative;
	overflow-y: hidden;

	.search-header {
		width: 100%;
		// height: 144px;
		background: var(--bg-white-100);

		// overflow: hidden;
		box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);

		.search-header-container {
			width: 1600px;
			margin: 0 auto;
			padding: 16px 0px 16px 0px;
		}

		.home-content-header-center {
			// margin-top: 20px;
			// margin-left: 200px;
			width: 800px;
			height: 48px;
			border-radius: 10px;
			// box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
			border: 1px solid var(--color-primary-35);
			background: var(--bg-white-100);
			box-sizing: border-box;
			padding: 1px;
			position: relative;

			&:hover {
				border: 1px solid var(--color-main-active);
			}

			.search {
				position: absolute;
				right: -1px;
				top: 0px;
				width: 120px;
				height: 46px;
				border-radius: 10px;
				background: var(--color-main-active);
				display: flex;
				justify-content: center;
				align-items: center;
				cursor: pointer;

				.search-icon {
					width: 18px;
					height: 18px;

					img {
						width: 100%;
						height: 100%;
					}
				}

				.search-text {
					margin-left: 8px;
					height: 22px;
					color: var(--bg-white-100);
					font-family: Microsoft YaHei;
					font-size: var(--font-size-base);
					font-weight: 400;
					line-height: 22px;
				}
			}
		}

		.home-content-header-btn-box {
			margin-top: 16px;
			// margin-left: 200px;
			display: flex;
			gap: 16px;

			.btn {
				display: flex;
				align-items: center;
				gap: 9px;
				width: 140px;
				height: 36px;
				border: 1px solid #aed6ff;
				box-sizing: border-box;
				border-radius: 24px;
				background: var(--color-primary-10);
				cursor: pointer;
				position: relative;

				&:hover {
					background: #cae3fc;
				}

				.btn-text {
					width: 80px;
					color: var(--color-main-active);
					font-family: Microsoft YaHei;
					font-size: 20px;
					font-weight: 400;
					line-height: 48px;
					margin-left: 24px;
					text-align: center;
				}

				.btn-icon {
					position: absolute;
					top: 10px;
					right: 19px;
					width: 6px;
					height: 12px;

					img {
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}

	.scrollHomeBox {
		height: calc(100% - 144px);
	}

	.home-top-bg {
		background: url("./assets/images/background.png"),
			linear-gradient(180deg, rgba(229, 241, 254, 1) 0%, rgba(246, 251, 255, 0) 30%);
		background-size: 100% 100%;
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: -100;
		top: -64px;
	}

	.home-main {
		position: relative;
		width: 100%;
		height: 100%;
		// background: url("./assets/images/background.png"),linear-gradient(180.00deg, rgba(229, 241, 254, 1) 0%,rgba(246, 251, 255, 0) 100%);
		// background-size: 100% 100%;
		overflow-y: auto;

		.home-content {
			width: 1600px;
			margin: 0 auto;
			margin-top: 48px;

			.home-content-header {
				display: flex;
				flex-direction: column;
				align-items: center;

				.home-content-header-center {
					width: 960px;
					height: 48px;
					border-radius: 10px;
					box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
					background: var(--bg-white-65);
					box-sizing: border-box;
					padding: 1px;
					position: relative;
					border: 1px solid rgba(255, 255, 255, 1);

					&:hover {
						border: 1px solid var(--color-main-active);
					}

					.search {
						position: absolute;
						right: -1px;
						top: 0px;
						width: 120px;
						height: 46px;
						border-radius: 10px;
						background: var(--color-main-active);
						display: flex;
						justify-content: center;
						align-items: center;
						cursor: pointer;

						.search-icon {
							width: 18px;
							height: 18px;

							img {
								width: 100%;
								height: 100%;
							}
						}

						.search-text {
							margin-left: 8px;
							height: 22px;
							color: var(--bg-white-100);
							font-family: Microsoft YaHei;
							font-size: var(--font-size-base);
							font-weight: 400;
							line-height: 22px;
						}
					}
				}

				.home-content-header-footer {
					margin-top: 38px;
					width: 960px;
					height: 64px;
					box-sizing: border-box;
					padding: 0 108px;
					display: flex;
					justify-content: space-between;

					.home-content-header-footer-item {
						padding: 0 10px;
						text-align: center;

						.item-top {
							height: 22px;
							color: rgba(20, 89, 187, 1);
							font-family: Microsoft YaHei;
							font-size: 36px;
							font-weight: 700;
							line-height: 22px;
						}

						.item-footer {
							margin-top: 10px;
							height: 30px;
							color: var(--text-primary-65-color);
							font-family: Microsoft YaHei;
							font-size: var(--font-size-base);
							font-weight: 400;
							line-height: 30px;
						}
					}
				}

				.home-content-header-btn-box {
					width: 688px;
					margin: 0 auto;
					margin-top: 39px;
					display: flex;
					justify-content: space-between;

					.btn {
						display: flex;
						align-items: center;
						gap: 9px;
						width: 160px;
						height: 48px;
						border: 1px solid #aed6ff;
						box-sizing: border-box;
						border-radius: 24px;
						background: var(--color-primary-10);
						cursor: pointer;
						position: relative;

						&:hover {
							background: #cae3fc;
						}

						.btn-text {
							width: 80px;
							color: var(--color-main-active);
							font-family: Microsoft YaHei;
							font-size: 20px;
							font-weight: 400;
							line-height: 48px;
							margin-left: 36px;
							text-align: center;
						}

						.btn-icon {
							position: absolute;
							top: 16px;
							right: 19px;
							width: 6px;
							height: 12px;

							img {
								width: 100%;
								height: 100%;
							}
						}
					}
				}
			}

			.committee-cards-section {
				width: 100%;
				margin-top: 64px;
				margin-bottom: 0;

				.committee-cards-filter {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 16px;

					.committee-cards-desc {
						color: var(--text-primary-65-color);
						font-family: Microsoft YaHei;
						font-size: var(--font-size-base);
						font-weight: 400;
						line-height: 22px;
					}

					.committee-time-switch {
						:deep(.el-radio-group) {
							display: inline-flex;
							align-items: stretch;
							padding: 4px;
							border-radius: 50px;
							background: var(--bg-black-10);
							gap: 0;
							flex-wrap: nowrap;
						}

						:deep(.el-radio-button) {
							margin: 0;

							.el-radio-button__inner {
								display: inline-flex;
								align-items: center;
								justify-content: center;
								gap: 6px;
								height: 100%;
								padding: 8px 20px;
								border: none;
								border-radius: 50px;
								background: transparent;
								box-shadow: none;
								color: var(--text-primary-50-color);
								font-family: Microsoft YaHei;
								font-size: 16px;
								font-weight: 400;
								line-height: 22px;
							}

							&:first-child .el-radio-button__inner {
								border-radius: 50px;
							}

							&:last-child .el-radio-button__inner {
								border-radius: 50px;
							}
						}

						:deep(.el-radio-button.is-active) {
							.el-radio-button__inner {
								background: rgba(255, 255, 255, 0.65);
								color: var(--text-primary-80-color);
								box-shadow: 0 2px 8px rgba(22, 119, 255, 0.12);
							}
						}

						.committee-time-switch-inner {
							display: inline-flex;
							align-items: center;
							gap: 6px;
						}

						.committee-time-switch-icon {
							font-size: 16px;
						}
					}
				}

				.committee-cards-row {
					display: flex;
					gap: 16px;
					width: 100%;

					.committee-card {
						flex: 1;
						min-height: 100px;
						display: flex;
						align-items: center;
						gap: 16px;
						padding: 21px 23px;
						border-radius: 10px;
						box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
						background: var(--bg-white-100);
						box-sizing: border-box;

						.committee-card-icon {
							width: 54px;
							height: 54px;
							min-width: 54px;
							border-radius: 50%;
							background: var(--color-primary-10);
							flex-shrink: 0;
						}

						.committee-card-content {
							flex: 1;
							min-width: 0;
							text-align: left;

							.committee-card-name {
								color: var(--text-primary-80-color);
								font-family: Microsoft YaHei;
								font-size: 20px;
								font-weight: 700;
								line-height: 26px;
								margin-bottom: 4px;
							}

							.committee-card-chamber {
								color: var(--text-primary-50-color);
								font-family: Microsoft YaHei;
								font-size: 16px;
								font-weight: 400;
								line-height: 22px;
							}
						}

						.committee-card-count {
							flex-shrink: 0;
							align-self: center;
							text-align: right;
							color: var(--color-primary-100);
							font-family: Microsoft YaHei;
							font-size: 20px;
							font-weight: 700;
							line-height: 26px;
							white-space: nowrap;
						}
					}
				}
			}

			.divide1 {
				margin-top: 64px;
				margin-bottom: 36px;
			}

			.home-content-center {
				margin-top: 34px;

				.center-top {
					height: 450px;
					display: flex;
					gap: 20px;

					.box1 {
						width: 1064px;
						height: 450px;
						border-radius: 10px;
						box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
						background: var(--bg-white-100);
						box-sizing: border-box;
						position: relative;

						.box1-left {
							position: absolute;
							left: 0;
							top: 200px;
							width: 24px;
							height: 48px;
							display: flex;
							justify-content: center;
							align-items: center;
							cursor: pointer;
							z-index: 10;

							.icon {
								width: 24px;
								height: 48px;

								img {
									width: 100%;
									height: 100%;
								}
							}
						}

						.box1-right {
							position: absolute;
							right: 0;
							top: 200px;
							width: 24px;
							height: 48px;
							display: flex;
							justify-content: center;
							align-items: center;
							cursor: pointer;
							z-index: 10;

							.icon {
								width: 24px;
								height: 48px;

								img {
									width: 100%;
									height: 100%;
								}
							}
						}

						.box1-header {
							height: 48px;
							border-bottom: 1px solid rgba(240, 242, 244, 1);
							display: flex;
							justify-content: space-between;
							box-sizing: border-box;
							padding: 0 40px 0 21px;

							.box1-header-left {
								display: flex;

								.icon {
									width: 18px;
									height: 18px;
									margin-top: 15px;

									img {
										width: 100%;
										height: 100%;
									}
								}

								.title {
									width: 112px;
									height: 48px;
									background: var(--color-main-active);
									margin-left: 21px;
									color: var(--bg-white-100);
									font-family: Microsoft YaHei;
									font-size: 20px;
									font-weight: 700;
									line-height: 48px;
									text-align: center;
								}
							}

							.box1-header-right {
								margin-top: 19px;
								height: 16px;
								color: rgba(20, 89, 187, 1);
								font-family: Microsoft YaHei;
								font-size: 16px;
								font-weight: 400;
								line-height: 16px;
								cursor: pointer;
							}
						}

						.box1-main {
							display: flex;
							height: 354px;
							margin-top: 22px;
							box-sizing: border-box;
							padding-left: 31px;

							.box1-main-left {
								margin-left: 39px;
								width: 484px;

								.box1-main-left-title {
									color: rgba(20, 89, 187, 1);
									font-family: "Microsoft YaHei";
									font-size: 20px;
									font-weight: 700;
									line-height: 22px;
									margin-bottom: 14px;
								}

								.box1-main-left-info {
									margin-top: 17px;
									display: flex;
									gap: 8px;
								}

								.box1-main-left-info1 {
									margin-top: 25px;
									margin-left: 4px;

									.info1-box {
										display: flex;

										.icon {
											margin-top: 15px;
											width: 4px;
											height: 4px;
											border-radius: 2px;
											background: var(--text-primary-50-color);
										}

										.info1-box-left {
											margin-left: 18px;
											width: 100px;
											height: 30px;
											color: var(--text-primary-65-color);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 400;
											line-height: 30px;
										}

										.info1-box-right {
											margin-left: 40px;
											height: 30px;
											color: var(--text-primary-65-color);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 400;
											line-height: 30px;
										}
									}
								}

								.box1-main-left-info2 {
									margin-top: 21px;
									height: 200px;
									width: 440px;
									position: relative;

									.time-line {
										position: absolute;
										z-index: 0;
										top: 15px;
										left: 4px;
										width: 2px;
										background: var(--bg-black-10);
									}

									.info2-item {
										margin-left: 1px;
										margin-bottom: 8px;
										height: 30px;
										display: flex;
										// background: orange;
										position: relative;

										.time-line {
											position: absolute;
											left: 4px;
											top: 18px;
											width: 2px;
											background: var(--bg-black-10);
											height: 34px;
										}

										.item-icon {
											margin-top: 8px;
											width: 10px;
											height: 10px;
											position: relative;
											z-index: 1;

											img {
												width: 10px;
												height: 10px;
											}
										}

										.itemTimeActive {
											color: rgba(20, 89, 187, 1) !important;
										}

										.itemTitleActive {
											font-weight: 700 !important;
											color: rgba(20, 89, 187, 1) !important;
										}

										.item-time {
											margin-left: 15px;
											width: 147px;
											height: 30px;
											color: var(--text-primary-80-color);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 700;
											line-height: 30px;
										}

										.item-title {
											margin-left: 10px;
											width: 320px;
											height: 30px;
											color: var(--text-primary-80-color);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 400;
											line-height: 30px;
											overflow: hidden;
											text-overflow: ellipsis;
											white-space: nowrap;
										}
									}
								}
							}

							.box1-main-right {
								height: 354px;
								width: 458px;
								border-radius: 4px;
								overflow: hidden;
								position: relative;

								img {
									width: 100%;
									height: 100%;
								}

								.inner-box {
									width: 100%;
									height: 93px;
									background: rgba(10, 18, 30, 0.75);
									position: absolute;
									left: 0;
									bottom: 0;
									box-sizing: border-box;
									padding: 9px 10px 12px 10px;

									.inner-box-header {
										height: 30px;
										display: flex;

										.inner-box-title {
											flex: 9;
											color: var(--bg-white-100);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 700;
											line-height: 30px;
											overflow: hidden;
											text-overflow: ellipsis;
											white-space: nowrap;
										}

										.inner-box-time {
											flex: 2;
											height: 30px;
											color: var(--bg-white-65);
											font-family: Microsoft YaHei;
											font-size: 14px;
											font-weight: 400;
											line-height: 30px;
											overflow: hidden;
											text-overflow: ellipsis;
											white-space: nowrap;
										}
									}

									.inner-box-content {
										width: 100%;
										height: 40px;
										overflow: hidden;
										color: var(--bg-white-80);
										font-family: Microsoft YaHei;
										font-size: 14px;
										font-weight: 400;
										line-height: 20px;
									}
								}
							}
						}
					}

					.box2 {
						width: 520px;
						height: 450px;
						border-radius: 10px;
						box-shadow: 0px 0px 15px 0px rgba(22, 119, 255, 0.1);
						background: var(--bg-white-100);
						position: relative;

						.box2-header {
							height: 48px;
							display: flex;
							box-sizing: border-box;
							padding-right: 20px;
							border-bottom: 1px solid rgba(234, 236, 238, 1);

							.icon {
								width: 24px;
								height: 22px;
								margin-left: 18px;
								margin-top: 13px;

								img {
									width: 100%;
									height: 100%;
								}
							}

							.title {
								margin-left: 18px;
								width: 148px;
								height: 48px;
								background: var(--color-red-100);
								display: flex;

								.text {
									margin-left: 16px;
									height: 22px;
									color: var(--bg-white-100);
									font-family: Microsoft YaHei;
									font-size: 20px;
									font-weight: 700;
									line-height: 48px;
								}

								.num {
									width: 24px;
									height: 20px;
									line-height: 20px;
									text-align: center;
									color: rgba(255, 255, 255, 1);
									font-family: Microsoft YaHei;
									font-size: 12px;
									margin-left: 10px;
									margin-top: 15px;
									// border: 1px solid rgba(255, 255, 255, 1);
									border-radius: 100px;
									background: rgba(255, 255, 255, 0.3);
								}
							}
						}

						.box2-main {
							height: 330px;
							overflow-y: auto;
							overflow-x: hidden;
							box-sizing: border-box;
							padding-right: 20px;

							.box2-main-item {
								margin-left: 23px;
								height: 47px;
								width: 464px;
								display: flex;
								cursor: pointer;

								&:hover {
									background: var(--color-bg-hover);
								}

								.itemLeftStatus1 {
									color: rgba(245, 34, 45, 1) !important;
									background: rgba(255, 241, 240) !important;
								}

								.itemLeftStatus2 {
									color: rgba(250, 140, 22, 1) !important;
									background: rgba(255, 247, 230, 1) !important;
								}

								.item-left {
									margin-top: 4px;
									margin-left: 2px;
									width: 40px;
									height: 40px;
									border-radius: 20px;
									color: rgba(82, 196, 26, 1);
									background: rgba(246, 255, 237, 1);
									font-family: Microsoft YaHei;
									font-size: 12px;
									font-weight: 400;
									line-height: 14px;
									box-sizing: border-box;
									padding: 6px 4px;
									text-align: center;
								}

								.item-right {
									margin-left: 13px;
									width: 408px;
									height: 47px;
									border-bottom: 1px solid rgba(240, 242, 244, 1);
									display: flex;

									.text {
										width: 315px;
										color: var(--text-primary-80-color);
										font-family: Microsoft YaHei;
										font-size: var(--font-size-base);
										font-weight: 400;
										line-height: 47px;
										overflow: hidden;
										text-overflow: ellipsis;
										white-space: nowrap;
									}

									.time {
										width: 88px;
										margin-left: 5px;
										line-height: 47px;
										color: var(--text-primary-50-color);
										font-family: Microsoft YaHei;
										font-size: 14px;
										font-weight: 400;
										text-align: center;
										overflow: hidden;
										text-overflow: ellipsis;
										white-space: nowrap;
									}
								}
							}
						}

						.box2-footer {
							position: absolute;
							left: 30px;
							bottom: 20px;
							width: 460px;
							height: 42px;
							display: flex;
							flex-direction: row;
							justify-content: center;
							align-items: center;
							border-radius: 6px;
							background: var(--color-main-active);
							cursor: pointer;

							.icon {
								width: 16px;
								height: 16px;

								img {
									width: 100%;
									height: 100%;
								}
							}

							.text {
								margin-left: 8px;
								color: rgba(255, 255, 255, 1);
								font-family: Microsoft YaHei;
								font-size: 14px;
								font-weight: 400;
								line-height: 22px;
							}
						}
					}
				}

				.divide2 {
					margin-top: 68px;
					margin-bottom: 36px;
				}

				.center-center {
					margin-top: 21px;
					height: 450px;
					display: flex;
					gap: 16px;

					.box3 {
						width: 792px;
						height: 450px;
						border-radius: 10px;
						box-shadow: 0px 0px 15px 0px rgba(25, 69, 130, 0.2);
						background: var(--bg-white-100);

						.box3-header {
							height: 48px;
							border-bottom: 1px solid rgba(240, 242, 244, 1);
							margin: 0 auto;
							display: flex;
							justify-content: space-between;
							padding: 0 20px;
							position: relative;

							.box3-header-left {
								display: flex;

								.box3-header-icon {
									margin-top: 16px;
									width: 19px;
									height: 19px;

									img {
										width: 100%;
										height: 100%;
									}
								}

								.box3-header-title {
									margin-top: 11px;
									margin-left: 19px;
									height: 26px;
									color: rgba(20, 89, 187, 1);
									font-family: Microsoft YaHei;
									font-size: 20px;
									font-weight: 700;
									line-height: 26px;
								}

								.more {
									width: 49px;
									height: 24px;
									position: absolute;
									top: 14px;
									right: 27px;
									color: rgba(20, 89, 187, 1);
									font-family: Microsoft YaHei;
									font-size: 16px;
									font-weight: 400;
									line-height: 24px;
									cursor: pointer;
								}
							}
						}

						.box3-main {
							height: 402px;
							overflow-y: hidden;
							overflow-x: hidden;
							padding-top: 6px;

							.box3-item {
								display: flex;
								height: 77px;
								width: 749px;
								margin-left: 21px;
								border-bottom: 1px solid rgba(240, 242, 244, 1);
								cursor: pointer;

								&:last-child {
									border-bottom: 0px;
								}

								&:hover {
									background: var(--color-bg-hover);
								}

								.left {
									width: 72px;
									height: 48px;
									margin-top: 15px;

									img {
										width: 100%;
										height: 100%;
									}
								}

								.right {
									width: 657px;
									margin-left: 20px;

									.right-top {
										margin-top: 16px;
										width: 657px;
										height: 24px;
										display: flex;
										justify-content: space-between;

										.title {
											width: 440px;
											height: 24px;
											color: var(--text-primary-80-color);
											font-family: Microsoft YaHei;
											font-size: var(--font-size-base);
											font-weight: 700;
											line-height: 24px;
											overflow: hidden;
											text-overflow: ellipsis;
											white-space: nowrap;
										}

										.time {
											flex: 1;
											text-align: right;
											height: 24px;
											color: var(--text-primary-65-color);
											font-family: Microsoft YaHei;
											font-size: 14px;
											font-weight: 400;
											line-height: 24px;
											overflow: hidden;
										}
									}

									.right-footer {
										width: 657px;
										height: 24px;
										color: var(--text-primary-80-color);
										font-family: Microsoft YaHei;
										font-size: var(--font-size-base);
										font-weight: 400;
										line-height: 24px;
										overflow: hidden;
										text-overflow: ellipsis;
										white-space: nowrap;
									}
								}
							}
						}
					}

					.box4 {
						margin-left: 20px;
						width: 792px;
						height: 450px;
						border-radius: 10px;
						box-shadow: 0px 0px 15px 0px rgba(25, 69, 130, 0.2);
						background: var(--bg-white-100);

						.box4-header {
							width: 792px;
							height: 48px;
							border-bottom: 1px solid rgba(240, 242, 244, 1);
							display: flex;
							box-sizing: border-box;
							padding-left: 22px;
							position: relative;

							.header-icon {
								margin-top: 15px;
								width: 20px;
								height: 20px;

								img {
									width: 100%;
									height: 100%;
								}
							}

							.header-title {
								margin-top: 11px;
								margin-left: 18px;
								height: 26px;
								color: var(--color-main-active);
								font-family: Microsoft YaHei;
								font-size: 20px;
								font-weight: 700;
								line-height: 26px;
							}

							.more {
								width: 49px;
								height: 24px;
								position: absolute;
								top: 14px;
								right: 27px;
								color: rgba(20, 89, 187, 1);
								font-family: Microsoft YaHei;
								font-size: 16px;
								font-weight: 400;
								line-height: 24px;
								cursor: pointer;
							}
						}

						.box4-main {
							height: 402px;
							overflow-y: auto;
							box-sizing: border-box;
							padding-top: 8px;
							padding-bottom: 20px;
							padding-left: 24px;
							// .box4-main-item {
							// 	margin-top: 16px;
							// 	display: flex;
							// 	margin-left: 21px;
							// 	.left {
							// 		margin-top: 5px;
							// 		width: 36px;
							// 		height: 36px;
							// 		cursor: pointer;
							// 		img {
							// 			width: 100%;
							// 			height: 100%;
							// 			border-radius: 50%;
							// 		}
							// 	}
							// 	.right {
							// 		margin-left: 10px;
							// 		width: 690px;
							// 		box-sizing: border-box;
							// 		border: 1px solid rgba(231, 243, 255, 1);
							// 		background: rgba(246, 250, 255, 1);
							// 		padding: 10px 15px;
							// 		.right-top {
							// 			display: flex;
							// 			justify-content: space-between;
							// 			.name {
							// 				height: 24px;
							// 				color: rgba(59, 65, 75, 1);
							// 				font-family: Microsoft YaHei;
							// 				font-size: 16px;
							// 				font-weight: 700;
							// 				line-height: 24px;
							// 			}
							// 			.time {
							// 				height: 30px;
							// 				color: rgba(95, 101, 108, 1);
							// 				font-family: Microsoft YaHei;
							// 				font-size: 16px;
							// 				font-weight: 400;
							// 				line-height: 30px;
							// 			}
							// 		}
							// 		.content {
							// 			color: rgba(59, 65, 75, 1);
							// 			font-family: Microsoft YaHei;
							// 			font-size: 16px;
							// 			font-weight: 400;
							// 			line-height: 24px;
							// 		}
							// 	}
							// }
						}
					}
				}

				.divide3 {
					margin-top: 64px;
					margin-bottom: 36px;
				}

				$overview-card-gap: 16px;
				$overview-single-width: calc((100% - #{$overview-card-gap} * 2) / 3);

				.center-footer {
					margin-top: 21px;
					display: flex;
					gap: $overview-card-gap;
					width: 100%;
				}

				.center-footer1 {
					display: flex;
					gap: $overview-card-gap;
					margin-top: 16px;
					width: 100%;
				}

				.overview-card--single {
					width: $overview-single-width;
				}

				.overview-card--double {
					width: calc(#{$overview-single-width} * 2 + #{$overview-card-gap});
				}

				.box5-main,
				.box6-main,
				.box7-main,
				.box9-main {
					height: 100%;
					box-sizing: border-box;
					padding: 8px 30px 20px;
				}

				.box8-main {
					height: 100%;
					box-sizing: border-box;
					padding: 12px 30px 20px;

					.box8-desc {
						height: 24px;
						line-height: 24px;
						color: var(--color-red-100);
						font-family: Microsoft YaHei;
						font-size: var(--font-size-base);
						font-weight: 700;
					}

					.box8-chart {
						cursor: pointer;
					}
				}

				.box9-main {
					padding: 10px 30px 20px;
				}

				.overview-card-body {
					display: flex;
					flex-direction: column;
					position: relative;
				}

				.overview-ai-pane {
					position: absolute;
					left: 0;
					bottom: 0;
					width: 100%;
					z-index: 3;
					pointer-events: none;

					.ai-pane-wrapper {
						pointer-events: auto;
					}
				}

				.overview-chart-wrap {
					flex: 1;
					min-height: 0;
					display: flex;
					flex-direction: column;
					align-items: stretch;
					justify-content: flex-start;

					&.is-empty {
						align-items: center;
						justify-content: center;
					}
				}

				.overview-chart {
					width: 100%;
					height: 100%;
					min-height: 0;
				}

				.overview-tip-row {
					margin-top: 10px;
					position: relative;
					display: flex;
					align-items: center;
					justify-content: center;
				}

				.overview-tip-action {
					position: absolute;
					right: -30px;
				}
			}
		}

		.home-content-footer {
			width: 100%;
			min-height: 1740px;
			background: rgba(248, 249, 250, 1);
			margin-bottom: 20px;
			margin-top: 36px;
			overflow: visible;

			.divide4 {
				margin: 0 auto;
				margin-top: 52px;
				margin-bottom: 36px;
			}

			.home-content-footer-header {
				width: 1600px;
				margin: 0 auto;
				margin-top: 37px;
				margin-bottom: 36px;
				// width: 1600px;
				height: 42px;
				// background: orange;
				display: flex;
				justify-content: space-between;

				.btn-box {
					display: flex;
					gap: 24px;
					width: 1000px;

					.btn {
						height: 42px;
						line-height: 42px;
						padding: 0 20px;
						color: var(--text-primary-80-color);
						font-family: Microsoft YaHei;
						font-size: 20px;
						font-weight: 400;
						border-radius: 21px;
						// background: rgba(20, 89, 187, 0);

						cursor: pointer;

						&:hover {
							background: rgba(20, 89, 187, 0.1);
						}
					}

					.btnActive {
						background: var(--color-main-active);
						color: var(--bg-white-100);
						font-weight: 700;

						&:hover {
							color: var(--bg-white-100);
							background: var(--color-main-active);
						}
					}

					.disabled {
						cursor: not-allowed;
						opacity: 0.5;

						&:hover {
							background: transparent;
						}
					}
				}

				.select-box {
					height: 42px;
					box-sizing: border-box;
					padding: 5px 0;
				}
			}

			.home-content-footer-main {
				width: 1600px;
				height: 1401px;
				margin: 0 auto;
				display: flex;
				justify-content: space-between;
				align-items: flex-start;

				.left {
					width: 300px;
					// min-height: 784px;
					padding-bottom: 33px;
					box-sizing: border-box;
					border: 1px solid rgba(234, 236, 238, 1);
					border-radius: 10px;
					box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
					background: var(--bg-white-100);

					.select-box {
						margin-top: 20px;

						.select-box-header {
							display: flex;
							gap: 17px;

							.icon {
								margin-top: 4px;
								width: 8px;
								height: 16px;
								background: var(--color-main-active);
								border-radius: 0 4px 4px 0;
							}

							.title {
								// height: 24px;
								color: var(--color-main-active);
								font-family: Microsoft YaHei;
								font-size: 20px;
								font-weight: 700;
								line-height: 26px;
								letter-spacing: 1px;
								text-align: left;
							}
						}

						.select-main {
							margin-left: 25px;
							margin-top: 16px;

							.checkbox-group {
								display: flex;
								flex-wrap: wrap;

								.filter-checkbox {
									width: 50%;
									margin-right: 0;
									margin-bottom: 4px;

									:deep(.el-checkbox__label) {
										color: var(--text-primary-65-color);
										font-size: var(--font-size-base);
										font-weight: 400;
										font-family: "Microsoft YaHei";
										line-height: 24px;
									}
								}
							}
						}

						.select-main1 {
							width: 100px;
						}
					}
				}

				.right {
					margin-left: 20px;
					width: 1280px;

					.right-header {
						height: 48px;
						display: flex;
						gap: 18px;
					}

					.right-main {
						height: 1264px;

						// overflow: hidden;
						.right-main-box {
							width: 1280px;
							height: 300px;
							padding-bottom: 24px;
							border-radius: 10px;
							box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
							background: var(--bg-white-100);
							margin-bottom: 16px;
							overflow: hidden;

							// overflow-y: auto;
							// cursor: pointer;
							.header {
								height: 91px;
								width: 1200px;
								margin: 0 auto;
								border-bottom: 1px solid rgba(234, 236, 238, 1);
								padding-top: 19px;

								.title {
									cursor: pointer;
									height: 26px;
									color: var(--text-primary-80-color);
									font-family: Microsoft YaHei;
									font-size: 20px;
									font-weight: 700;
									line-height: 26px;
									letter-spacing: 0px;
									text-align: left;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}

								.en-title {
									margin-top: 8px;
									height: 24px;
									color: var(--text-primary-65-color);
									font-family: Microsoft YaHei;
									font-size: var(--font-size-base);
									font-weight: 400;
									line-height: 24px;
									letter-spacing: 0px;
									text-align: left;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}
							}

							.main {
								width: 1200px;
								margin: 0 auto;
								margin-top: 2px;

								.item {
									margin-top: 12px;
									// height: 24px;
									display: flex;

									.item-left {
										width: 100px;
										// height: 24px;
										color: var(--text-primary-80-color);
										font-family: "Microsoft YaHei";
										font-size: var(--font-size-base);
										font-weight: 700;
										line-height: 24px;
										letter-spacing: 1px;
										text-align: left;
									}

									.item-right {
										max-width: 1000px;
										margin-left: 10px;
										color: var(--text-primary-65-color);
										font-family: "Microsoft YaHei";
										font-size: var(--font-size-base);
										font-weight: 400;
										line-height: 24px;
										letter-spacing: 0px;
										text-align: left;
									}

									.item-right1 {
										margin-left: 10px;
										display: flex;
										gap: 8px;

										.tag {
											height: 24px;
											line-height: 24px;
											padding: 0 8px;
											border-radius: 4px;
											background: var(--color-primary-10);
											color: var(--color-main-active);
											font-family: "Microsoft YaHei";
											font-size: 14px;
											font-weight: 400;
										}
									}

									.item-right2 {
										margin-left: 10px;
										display: flex;
										align-items: center;

										.tag {
											height: 24px;
											line-height: 22px;
											padding: 0 10px 0 30px;
											background: var(--bg-white-100);
											color: var(--text-primary-65-color);
											border-top: 1px solid rgb(234, 236, 238);
											border-bottom: 1px solid rgb(234, 236, 238);
											position: relative;
											margin-left: -10px;
											font-family: "Microsoft YaHei";
											font-size: 14px;
											font-weight: 400;

											&::after {
												content: "";
												position: absolute;
												top: 50%;
												right: -8.485px;
												width: 16.97px;
												height: 16.97px;
												background: inherit;
												border-top: 1px solid rgb(234, 236, 238);
												border-right: 1px solid rgb(234, 236, 238);
												transform: translateY(-50%) rotate(45deg);
												z-index: 1;
												box-shadow: 2px -2px 2px rgba(0, 0, 0, 0.05);
												box-sizing: border-box;
											}

											&:first-child {
												margin-left: 0;
												padding-left: 10px;
												border-left: 1px solid rgb(234, 236, 238);
												border-radius: 4px 0 0 4px;
											}

											&:last-child {
												background: var(--text-primary-80-color);
												color: rgba(255, 255, 255, 1);
												border-color: var(--text-primary-80-color);
												padding-right: 10px;
												border-radius: 0;
												border-right: none;

												&::after {
													display: block;
													border-color: var(--text-primary-80-color);
													box-shadow: none;
												}
											}

											&:first-child:last-child {
												margin-left: 0;
												padding: 0 10px;
												border-radius: 4px 0 0 4px;
												background: var(--text-primary-80-color);
												color: rgba(255, 255, 255, 1);
												border: 1px solid var(--text-primary-80-color);
												border-right: none;
											}
										}
									}
								}
							}
						}
					}

					.right-footer {
						height: 85px;
						display: flex;
						justify-content: space-between;
						box-sizing: border-box;
						padding-top: 12px;

						.footer-left {
							color: var(--text-primary-80-color);
							font-family: "Microsoft YaHei";
							font-size: var(--font-size-base);
							font-weight: 400;
							line-height: 32px;
						}
					}
				}
			}

			.home-content-footer-footer {
				width: 1600px;
				margin: 0 auto;
				height: 32px;
				margin-top: 30px;
				display: flex;
				justify-content: space-between;

				.footer-left {
					color: var(--text-primary-80-color);
					font-family: "Microsoft YaHei";
					font-size: var(--font-size-base);
					font-weight: 400;
					line-height: 32px;
				}
			}
		}
	}
}

:deep(.el-input__wrapper) {
	box-shadow: none;
	border-radius: 10px;
}

:deep(.el-input__wrapper:hover) {
	box-shadow: none !important;
}

:deep(.el-input__wrapper.is-focus) {
	box-shadow: none !important;
}
</style>
