<template>
	<details v-if="diagnostics" class="subagent-diagnostics">
		<summary class="subagent-diagnostics__summary">
			<span>投影诊断</span>
			<span>{{ summary }}</span>
		</summary>
		<div class="subagent-diagnostics__body">
			<div class="subagent-diagnostics__chips">
				<span
					v-if="display.projectionPathLabel"
					class="subagent-diagnostics__chip"
				>
					路径 {{ display.projectionPathLabel }}
				</span>
				<span class="subagent-diagnostics__chip">
					来源 {{ display.selectedSourceLabel }}
				</span>
				<span class="subagent-diagnostics__chip" :class="{ 'is-fallback': diagnostics.fallbackUsed }">
					{{ diagnostics.fallbackUsed ? '使用了 fallback' : '未使用 fallback' }}
				</span>
			</div>
			<div class="subagent-diagnostics__metrics">
				<span>原始 {{ diagnostics.rawResultCount }}</span>
				<span>去重后 {{ diagnostics.dedupedResultCount }}</span>
				<span>投影后 {{ diagnostics.projectedTaskCount }}</span>
				<span>跳过 {{ diagnostics.skippedResultCount }}</span>
			</div>
			<div class="subagent-diagnostics__lists">
				<p>输入源：{{ display.inputSourcesLabel }}</p>
				<p v-if="diagnostics.ignoredSources.length">
					忽略源：{{ display.ignoredSourcesLabel }}
				</p>
			</div>
		</div>
	</details>
</template>

<script lang="ts" setup>
import type { SubagentProjectionDiagnostics } from '../../types/index.d';

type DiagnosticsDisplay = {
	projectionPathLabel: string;
	selectedSourceLabel: string;
	inputSourcesLabel: string;
	ignoredSourcesLabel: string;
};

defineProps<{
	diagnostics: SubagentProjectionDiagnostics | null;
	display: DiagnosticsDisplay;
	summary: string;
}>();
</script>
