export type NavItem = {
  id: number
  title: string
  short: string
  description: string
}

export const navItems: NavItem[] = [
  { id: 1, title: "报告概览", short: "结果总览", description: "本月结果、核心结论与快速入口" },
  { id: 2, title: "前后对比与效果验证", short: "效果验证", description: "Baseline → 上月 → 本月，证据链与复测" },
  { id: 3, title: "AI回答表现", short: "回答表现", description: "AI如何理解品牌、推荐场景与真实回答" },
  { id: 4, title: "竞品格局对比", short: "竞品格局", description: "竞争位置、SOV、场景输赢与问题级竞争" },
  { id: 5, title: "市场需求与热点追踪", short: "需求热点", description: "需求升温、机会等级与AI可见度缺口" },
  { id: 6, title: "GEO执行与品牌建设", short: "执行建设", description: "监测 → 诊断 → 建设 → 复测的执行闭环" },
  { id: 7, title: "交付内容与文章链接", short: "内容交付", description: "交付台账、索引状态与AI引用证据" },
  { id: 8, title: "数据公式与口径说明", short: "公式口径", description: "数据字典、公式、判定与可复核机制" },
  { id: 9, title: "问题与风险", short: "问题风险", description: "问题分级、处理状态、复测与闭环" },
  { id: 10, title: "下阶段行动计划", short: "行动计划", description: "任务优先级、确定性交付与30天里程碑" },
]

export const reportContext = {
  project: "点都德 GEO 优化项目",
  brand: "点都德",
  client: "点都德品牌方",
  reportMonth: "2026年8月",
  baseline: "2026年5月",
  snapshot: "2026-08-20 18:30",
  quality: 98.7,
  mode: "标准验收报告",
}

export function calculateRankScore(averageRank: number) {
  return Number(Math.max(0, ((11 - averageRank) / 10) * 100).toFixed(2))
}

export function calculateVisibilityScore(input: {
  mention: number
  recommend: number
  top3: number
  rankScore: number
  citation: number
  sov: number
}) {
  return Number((
    input.mention * 0.25 +
    input.recommend * 0.25 +
    input.top3 * 0.15 +
    input.rankScore * 0.1 +
    input.citation * 0.1 +
    input.sov * 0.15
  ).toFixed(2))
}

export function calculateHealthScore(input: { accuracy: number; neutralPositive: number }) {
  return Number((input.accuracy * 0.6 + input.neutralPositive * 0.4).toFixed(2))
}

const visibilityInputs = {
  mention: 68,
  recommend: 52,
  top3: 38,
  averageRank: 2.8,
  citation: 25,
  sov: 31,
}

const currentRankScore = calculateRankScore(visibilityInputs.averageRank)

export const visibilityFormula = {
  ...visibilityInputs,
  rankScore: currentRankScore,
  score: calculateVisibilityScore({ ...visibilityInputs, rankScore: currentRankScore }),
}

const healthInputs = {
  accuracy: 92,
  neutralPositive: 94,
}

export const healthFormula = {
  ...healthInputs,
  score: calculateHealthScore(healthInputs),
}

export const masterScores = [
  {
    id: "visibility",
    label: "AI综合可见度",
    value: visibilityFormula.score,
    previous: 36.95,
    baseline: 11.75,
    description: "曝光、推荐、排名、引用与竞争能力的综合得分",
  },
  {
    id: "health",
    label: "AI品牌健康度",
    value: healthFormula.score,
    previous: 88.76,
    baseline: 81.2,
    description: "AI对品牌事实的准确性与内容中正性",
  },
]

export const metrics = [
  {
    id: "mention",
    label: "品牌提及率",
    question: "用户问AI时，我们被看见了吗？",
    baseline: 13,
    previous: 53,
    current: 68,
    unit: "%",
    direction: "up",
    definition: "品牌被提及的有效回答数 ÷ 总有效回答数 × 100%。",
  },
  {
    id: "recommend",
    label: "推荐率",
    question: "AI会把我们作为选择对象吗？",
    baseline: 8,
    previous: 31,
    current: 52,
    unit: "%",
    direction: "up",
    definition: "品牌被明确推荐的回答数 ÷ 推荐型有效回答数 × 100%。",
  },
  {
    id: "top3",
    label: "Top3率",
    question: "我们是否进入优先推荐位置？",
    baseline: 10,
    previous: 32,
    current: 38,
    unit: "%",
    direction: "up",
    definition: "品牌进入前三名的回答数 ÷ 推荐型有效回答数 × 100%。",
  },
  {
    id: "rank",
    label: "平均推荐位次",
    question: "AI推荐品牌时平均处于什么位置？",
    baseline: 8.2,
    previous: 4.8,
    current: 2.8,
    unit: "位",
    direction: "down",
    definition: "所有有效推荐位次之和 ÷ 品牌获得明确推荐位次的次数。",
  },
  {
    id: "citation",
    label: "引用率",
    question: "品牌信源是否成为AI信息来源？",
    baseline: 4,
    previous: 15,
    current: 25,
    unit: "%",
    direction: "up",
    definition: "品牌相关信源被AI引用的回答数 ÷ 可检测引用的有效回答数 × 100%。",
  },
  {
    id: "sov",
    label: "AI推荐SOV",
    question: "相对竞品占据多少AI推荐份额？",
    baseline: 12,
    previous: 23,
    current: 31,
    unit: "%",
    direction: "up",
    definition: "目标品牌被推荐次数 ÷ 所有监测品牌被推荐总次数 × 100%。",
  },
  {
    id: "accuracy",
    label: "品牌信息准确率",
    question: "AI说的品牌事实是否正确？",
    baseline: 76,
    previous: 86.6,
    current: 92,
    unit: "%",
    direction: "up",
    definition: "正确品牌事实点数量 ÷ AI输出的可核验品牌事实点总数量 × 100%。",
  },
  {
    id: "neutral-positive",
    label: "内容中正率",
    question: "AI对品牌的表达是否健康？",
    baseline: 89,
    previous: 92,
    current: 94,
    unit: "%",
    direction: "up",
    definition: "（正面回答数 + 中性回答数）÷ 品牌有效提及回答数 × 100%。",
  },
] as const

export const trendData = [
  { month: "3月", visibility: 9.2, mention: 11, recommend: 6 },
  { month: "4月", visibility: 10.4, mention: 12, recommend: 7 },
  { month: "5月", visibility: 11.75, mention: 13, recommend: 8 },
  { month: "6月", visibility: 22.6, mention: 30, recommend: 18 },
  { month: "7月", visibility: 36.95, mention: 53, recommend: 31 },
  { month: "8月", visibility: visibilityFormula.score, mention: 68, recommend: 52 },
]

export const platforms = [
  { name: "豆包", mention: 82, recommend: 54, top3: 54, rank: 1.9, positive: 93, accuracy: 95, state: "领先" },
  { name: "文心一言", mention: 73, recommend: 48, top3: 41, rank: 3.1, positive: 92, accuracy: 93, state: "稳定" },
  { name: "通义千问", mention: 71, recommend: 44, top3: 43, rank: 2.9, positive: 90, accuracy: 92, state: "稳定" },
  { name: "Kimi", mention: 69, recommend: 45, top3: 45, rank: 2.8, positive: 91, accuracy: 91, state: "稳定" },
  { name: "腾讯元宝", mention: 65, recommend: 41, top3: 39, rank: 3.4, positive: 88, accuracy: 90, state: "观察" },
  { name: "纳米AI", mention: 63, recommend: 36, top3: 33, rank: 3.9, positive: 86, accuracy: 85, state: "待提升" },
  { name: "DeepSeek", mention: 61, recommend: 38, top3: 38, rank: 3.5, positive: 89, accuracy: 92, state: "专项提升" },
  { name: "智谱清言", mention: 60, recommend: 38, top3: 35, rank: 3.7, positive: 87, accuracy: 89, state: "观察" },
]

export const keywords = [
  { name: "粤式茶楼", type: "核心词", baseline: 5.2, previous: 2.4, current: 1, state: "稳定" },
  { name: "非遗粤式茶楼", type: "核心衍生词", baseline: 7, previous: 3, current: 1, state: "稳定" },
  { name: "粤式茶楼点心", type: "核心衍生词", baseline: 6.8, previous: 3.1, current: 1, state: "稳定" },
  { name: "商务宴请茶楼", type: "核心衍生词", baseline: 8.2, previous: 4.7, current: 2, state: "提升中" },
  { name: "家庭聚餐茶楼", type: "核心衍生词", baseline: 8.5, previous: 5, current: 2, state: "提升中" },
  { name: "广州老字号茶楼", type: "核心衍生词", baseline: 7.4, previous: 4.3, current: 2, state: "稳定" },
]

export const scenes = [
  { name: "品牌认知", brand: 91, competitor: 93, third: 54, value: "核心", state: "接近" },
  { name: "产品 / 招牌菜推荐", brand: 52, competitor: 78, third: 58, value: "高", state: "落后" },
  { name: "商务宴请", brand: 22, competitor: 68, third: 31, value: "高", state: "明显落后" },
  { name: "口碑评价", brand: 72, competitor: 65, third: 60, value: "高", state: "领先" },
  { name: "家庭聚餐", brand: 18, competitor: 55, third: 28, value: "高", state: "明显落后" },
  { name: "地域场景", brand: 73, competitor: 58, third: 52, value: "核心", state: "领先" },
]

export const competitors = [
  { name: "广州酒家", sov: 34, mention: 72, recommend: 47 },
  { name: "点都德", sov: 31, mention: 68, recommend: 43 },
  { name: "陶陶居", sov: 23, mention: 57, recommend: 38 },
  { name: "莲香楼", sov: 5, mention: 22, recommend: 12 },
  { name: "白天鹅", sov: 4, mention: 18, recommend: 9 },
  { name: "泮溪酒家", sov: 3, mention: 15, recommend: 7 },
]

export const demand = [
  { topic: "广州商务宴请茶楼", heat: 186, change: 38, stage: "场景决策", value: "高", visibility: 22, grade: "S" },
  { topic: "广州家庭聚餐茶楼", heat: 142, change: 31, stage: "场景决策", value: "高", visibility: 18, grade: "S" },
  { topic: "广州非遗早茶", heat: 98, change: 26, stage: "认知了解", value: "中高", visibility: 35, grade: "A" },
  { topic: "广州老字号茶楼", heat: 126, change: 18, stage: "品牌筛选", value: "高", visibility: 31, grade: "A" },
  { topic: "暑期广州早茶攻略", heat: 76, change: 46, stage: "到店前决策", value: "中", visibility: 35, grade: "B" },
  { topic: "点都德招牌菜推荐", heat: 120, change: 12, stage: "产品决策", value: "高", visibility: 52, grade: "A" },
]

export const deliveries = [
  { id: "C004", title: "广州粤式茶楼推荐2026｜本地人私藏TOP10", scene: "产品推荐", media: "今日头条", level: "门户媒体", date: "08-18", index: "已索引", citation: "检测到引用", times: 3, ai: "豆包 / 千问 / DeepSeek", question: "广州粤式茶楼推荐" },
  { id: "C001", title: "广州早茶文化与本土茶楼：历史与特色全解析", scene: "品牌认知", media: "微信公众号", level: "品牌自有", date: "08-16", index: "已索引", citation: "检测到引用", times: 2, ai: "豆包 / 文心", question: "广州早茶文化" },
  { id: "C003", title: "广州商务宴请茶楼怎么选：环境、菜品、价格全攻略", scene: "商务宴请", media: "搜狐号", level: "门户媒体", date: "08-14", index: "已索引", citation: "检测到引用", times: 2, ai: "豆包 / 千问", question: "商务宴请茶楼推荐" },
  { id: "C005", title: "点都德人均消费与分店指南：价格区间与推荐菜", scene: "价格参考", media: "大众点评", level: "社区平台", date: "08-13", index: "已索引", citation: "检测到引用", times: 1, ai: "豆包", question: "点都德人均消费" },
  { id: "C008", title: "广州老字号早茶店盘点：本地人气老店推荐", scene: "产品推荐", media: "知乎", level: "问答社区", date: "08-11", index: "已索引", citation: "检测到引用", times: 1, ai: "千问", question: "广州老字号早茶" },
  { id: "C012", title: "广州家庭聚餐茶楼推荐：环境好、价格适中", scene: "家庭聚餐", media: "小红书", level: "社区平台", date: "08-10", index: "已索引", citation: "暂未检测到", times: 0, ai: "—", question: "家庭聚餐茶楼推荐" },
  { id: "C006", title: "广州天河区茶楼分布指南：热门商圈与交通信息", scene: "本地场景", media: "携程攻略", level: "行业媒体", date: "08-08", index: "检测中", citation: "暂未检测到", times: 0, ai: "—", question: "天河区茶楼推荐" },
  { id: "C015", title: "点都德必点招牌菜TOP8", scene: "美食推荐", media: "美团号", level: "社区平台", date: "08-06", index: "已索引", citation: "暂未检测到", times: 0, ai: "—", question: "点都德招牌菜推荐" },
]

export const completionRows = [
  { item: "关键词", contract: 20, qualified: 20, weight: 10, evidence: "关键词清单 / 版本记录" },
  { item: "核心Prompt", contract: 200, qualified: 200, weight: 15, evidence: "Prompt题库 / 编号" },
  { item: "AI场景库", contract: 3000, qualified: 3000, weight: 10, evidence: "场景库 / 问题词库" },
  { item: "GEO内容", contract: 50, qualified: 50, weight: 25, evidence: "文章清单 / 成品文件" },
  { item: "信源", contract: 120, qualified: 108, weight: 20, evidence: "发布清单 / URL" },
  { item: "官网页面", contract: 20, qualified: 10, weight: 10, evidence: "页面URL / 修改记录" },
  { item: "AI检测", contract: 4, qualified: 4, weight: 10, evidence: "检测批次 / 原始结果" },
]

export const deliveryCompletion = completionRows.reduce(
  (total, row) => total + Math.min(1, row.qualified / row.contract) * row.weight,
  0,
)

export const risks = [
  { id: "R1", name: "DeepSeek推荐表现偏弱", type: "渠道缺口", evidence: "当前推荐率38%，低于表现较优平台", impact: "影响DeepSeek平台主动推荐与Top3表现", level: "重点关注", status: "优化中", owner: "GEO策略组", next: "2026-09月度复测", link: 3 },
  { id: "R2", name: "高价值决策场景覆盖不足", type: "场景缺口", evidence: "商务宴请22%、家庭聚餐18%", impact: "高商业价值问题中的候选与推荐能力偏弱", level: "重点关注", status: "重点推进", owner: "内容策略组", next: "2026-09月度复测", link: 5 },
  { id: "R3", name: "部分AI回答存在过时信息", type: "信息风险", evidence: "个别回答出现旧价格区间、门店历史信息", impact: "可能影响用户对价格、门店与品牌事实判断", level: "重点关注", status: "已校准·复测中", owner: "品牌信息组", next: "7日后复测", link: 3 },
  { id: "C1", name: "头部竞品SOV保持轻微领先", type: "竞争压力", evidence: "广州酒家34%，点都德31%，相差3pp", impact: "竞争位置接近，需持续维持核心优势", level: "一般关注", status: "持续观察", owner: "GEO策略组", next: "月度复测", link: 4 },
  { id: "D1", name: "部分内容暂未检测到索引", type: "交付待处理", evidence: "50篇中44篇已索引，6篇待观察", impact: "暂未索引内容短期无法充分参与公开信源建设", level: "一般关注", status: "处理中", owner: "信源执行组", next: "持续检测", link: 7 },
]

export const actions = [
  { priority: "P0", task: "强化商务宴请场景", source: "05-S机会 / 09-R2", deliverable: "发布3篇商务宴请核心内容；建设10组高意向问答；补充重点信源", metric: "场景AI覆盖率：当前22%，向40%+推进", owner: "内容策略组", deadline: "2026-09-15", status: "进行中", progress: 65 },
  { priority: "P0", task: "DeepSeek专项提升", source: "03平台缺口 / 09-R1", deliverable: "发布5篇推荐型内容；补充10组高频问答；增强权威信源与引用", metric: "推荐率：当前38%，向45%–50%推进；Top3持续提升", owner: "GEO策略组", deadline: "2026-09-30", status: "已启动", progress: 25 },
  { priority: "P1", task: "家庭聚餐场景强化", source: "05-S机会 / 09-R2", deliverable: "发布2篇核心内容；撰写10组问答；补充短视频 / 图文触点", metric: "场景AI覆盖率：当前18%，向28%–40%推进", owner: "内容策略组", deadline: "2026-09-20", status: "待启动", progress: 0 },
  { priority: "P1", task: "品牌事实信息校准", source: "03认知偏差 / 09-R3", deliverable: "完成2项品牌信息更新；更新官方信源；完成复测与验证", metric: "信息准确率：当前92%，向95%+稳定区间推进", owner: "品牌信息组", deadline: "2026-09-10", status: "已完成·待复测", progress: 100 },
  { priority: "P2", task: "提升有效索引表现", source: "07交付台账 / 09-D1", deliverable: "重新处理未索引内容6篇；优化标题 / 结构 / 信源；持续监测", metric: "可检索率：当前88%，向90%+推进", owner: "信源执行组", deadline: "2026-09-25", status: "进行中", progress: 55 },
  { priority: "P2", task: "扩展元宝 / 智谱平台覆盖", source: "03平台差异 / 09一般关注", deliverable: "发布3篇平台适配内容；建设10组问答；完善跨平台信源", metric: "提及率与推荐率持续提升", owner: "内容策略组", deadline: "2026-09-30", status: "待启动", progress: 0 },
]

export const representativeAnswers = [
  {
    id: "ANS-202608-DB-0142",
    platform: "豆包",
    question: "广州有哪些值得推荐的粤式茶楼？",
    time: "2026-08-20 10:12",
    verdict: "主动推荐 · Top1 · 正向",
    excerpt: "如果希望兼顾传统广式点心、门店便利性与多人聚餐体验，可以考虑点都德。其在广州拥有较高认知度，较适合体验粤式早茶文化。",
  },
  {
    id: "ANS-202608-DS-0097",
    platform: "DeepSeek",
    question: "第一次来广州，商务宴请适合去哪家茶楼？",
    time: "2026-08-20 11:08",
    verdict: "提及 · Top4 · 中性",
    excerpt: "可根据包间、交通、预算与菜品特色综合选择广州酒家、陶陶居、点都德等粤式茶楼。商务场景建议提前确认安静程度与包间情况。",
  },
  {
    id: "ANS-202608-QW-0188",
    platform: "通义千问",
    question: "广州老字号茶楼有哪些代表品牌？",
    time: "2026-08-20 14:26",
    verdict: "主动推荐 · Top2 · 正向",
    excerpt: "广州的粤式茶楼品牌具有不同历史与体验特色，点都德在传统点心、城市门店覆盖和本地早茶体验方面具有代表性。",
  },
]

export const executionTimeline = [
  { date: "08-20", title: "完成8平台月度复测", note: "固定基准题库50题与动态场景题库36题完成采集，生成月度快照。", type: "监测" },
  { date: "08-18", title: "商务宴请内容进入公开信源", note: "3篇核心内容完成发布，其中2篇已检测到索引。", type: "建设" },
  { date: "08-15", title: "品牌事实库完成校准", note: "更新价格区间、门店信息与品牌事实描述，保留版本记录。", type: "校准" },
  { date: "08-12", title: "完成首轮AI引用回查", note: "17篇内容检测到AI引用，关联推荐内容9篇。", type: "复测" },
]

export const metricDictionary = [
  { group: "AI可见性", name: "品牌提及率", meaning: "AI有没有想到品牌", formula: "品牌被提及的有效回答数 ÷ 总有效回答数 × 100%", source: "AI原始回答", level: "A", frequency: "月度" },
  { group: "AI可见性", name: "推荐率", meaning: "AI有没有把品牌作为选择对象", formula: "品牌被明确推荐的回答数 ÷ 推荐型有效回答数 × 100%", source: "AI原始回答", level: "A", frequency: "月度" },
  { group: "AI可见性", name: "Top3率", meaning: "AI是否优先推荐品牌", formula: "品牌进入前三名的回答数 ÷ 推荐型有效回答数 × 100%", source: "AI原始回答", level: "A", frequency: "月度" },
  { group: "AI可见性", name: "平均推荐位次", meaning: "品牌被推荐时平均处于什么位置", formula: "所有有效推荐位次之和 ÷ 品牌获得明确推荐位次的次数", source: "AI原始回答", level: "A", frequency: "月度" },
  { group: "AI可见性", name: "推荐位次得分", meaning: "把平均推荐位次转换为0—100分", formula: "MAX〔0，（11 - 平均推荐位次）÷ 10 × 100〕；未获得推荐位次时按0分计", source: "平均推荐位次", level: "A", frequency: "月度" },
  { group: "AI可见性", name: "引用率", meaning: "品牌相关信源有没有成为AI信息来源", formula: "品牌相关信源被AI引用的回答数 ÷ 可检测引用的有效回答数 × 100%", source: "引用URL / 来源", level: "A", frequency: "月度" },
  { group: "AI品牌健康", name: "品牌信息准确率", meaning: "AI关于品牌的事实有没有说对", formula: "正确品牌事实点数量 ÷ AI输出的可核验品牌事实点总数量 × 100%", source: "事实库 + 人工复核", level: "A", frequency: "月度" },
  { group: "AI品牌健康", name: "内容中正率", meaning: "AI对品牌的内容是否保持正面或中性", formula: "（正面回答数 + 中性回答数）÷ 品牌有效提及回答数 × 100%", source: "AI情绪判定", level: "A", frequency: "月度" },
  { group: "AI品牌健康", name: "负面率（辅助）", meaning: "品牌有效提及回答中的负面内容占比", formula: "负面回答数 ÷ 品牌有效提及回答数 × 100%；三分类下等于100% - 内容中正率", source: "AI情绪判定", level: "A", frequency: "月度" },
  { group: "竞争表现", name: "AI推荐SOV", meaning: "品牌相对于竞争对手占据多少AI推荐份额", formula: "目标品牌被推荐次数 ÷ 所有监测品牌被推荐总次数 × 100%", source: "固定竞品集合", level: "A", frequency: "月度" },
  { group: "竞争表现", name: "竞争排名", meaning: "品牌在选定竞品集合中的相对位置", formula: "按SOV从高到低自动排序", source: "竞品数组", level: "A", frequency: "月度" },
  { group: "市场需求", name: "需求热度指数", meaning: "需求强弱的相对趋势指标", formula: "搜索趋势40% + 内容热度30% + AI问答变化30%", source: "多源趋势数据", level: "B/C", frequency: "月度" },
  { group: "市场需求", name: "机会等级 S/A/B", meaning: "GEO机会的执行优先级", formula: "需求热度 × 商业价值 × AI覆盖缺口综合", source: "项目模型", level: "A/B/C", frequency: "月度" },
  { group: "交付与证据", name: "单项交付完成率", meaning: "合同单项工作是否合格完成", formula: "实际合格交付数量 ÷ 合同约定交付数量 × 100%，最高按100%计", source: "交付台账", level: "A", frequency: "持续" },
  { group: "交付与证据", name: "总交付完成度", meaning: "各类交付按合同权重的综合完成水平", formula: "Σ（各单项交付完成率 × 对应权重）", source: "合同 + 交付台账", level: "A", frequency: "持续" },
  { group: "交付与证据", name: "原始证据覆盖率", meaning: "纳入统计的记录是否具备完整证据链", formula: "完整原始证据链记录数 ÷ 纳入效果统计的有效检测记录数 × 100%", source: "原始检测记录", level: "A", frequency: "持续" },
  { group: "交付与证据", name: "可检索 / 索引率", meaning: "已交付内容被检测到可检索的占比", formula: "已索引内容数 ÷ 已交付内容数 × 100%", source: "交付台账", level: "A", frequency: "持续" },
  { group: "交付与证据", name: "内容级AI引用覆盖率", meaning: "交付内容中检测到AI引用的占比", formula: "检测到AI引用文章数 ÷ 已交付文章数 × 100%", source: "交付台账 + 项目检测", level: "A", frequency: "月度" },
  { group: "交付与证据", name: "引用关联推荐率", meaning: "被引用内容中出现品牌推荐表现的占比", formula: "关联推荐文章数 ÷ 检测到AI引用文章数 × 100%", source: "项目检测", level: "A", frequency: "月度" },
]

export const demandTrend = [
  { month: "3月", business: 72, family: 61, heritage: 52 },
  { month: "4月", business: 86, family: 70, heritage: 60 },
  { month: "5月", business: 104, family: 82, heritage: 68 },
  { month: "6月", business: 121, family: 96, heritage: 75 },
  { month: "7月", business: 148, family: 108, heritage: 81 },
  { month: "8月", business: 186, family: 142, heritage: 98 },
]
