// ============================================================
// 设置项搜索索引(阶段4 UX 重构)
// ------------------------------------------------------------
// 静态表:覆盖全部设置项,每项绑定 i18n label/desc key(运行时按当前 locale
// 翻译成文本做匹配)。新增设置项时同步此索引,避免索引与设置项漂移(对齐 plan
// 阶段4 风险项)。分类 value 与 SettingsNav SettingsCategory 一致。
//
// 匹配维度:label + desc(当前 locale 翻译值),小写 includes 模糊匹配。
// 搜索命中 → 左导航高亮匹配类 + 选中首匹配类 + 右侧滚动到对应 setting-row
// (靠 setting-row 上的 data-setting-key 属性定位,见 SettingsNav + Settings.vue)。
// ============================================================

/** 分类值类型 — 与 Settings.vue 渲染分支 + SettingsNav categories 一致。
 *  定义在此处(纯 .ts,无循环导入),SettingsNav.vue re-export 以兼容现有引用。 */
export type SettingsCategory =
  | 'appearance'
  | 'ai-model'
  | 'knowledge'
  | 'performance'
  | 'security'
  | 'advanced'

/** 搜索索引项:category 所属分类 + labelKey/descKey(i18n key) + key 唯一标识 */
export interface SettingIndexEntry {
  /** 所属分类(与左导航 SettingsCategory 一致) */
  category: SettingsCategory
  /** 设置项 label 的 i18n key(如 'settings.labelTheme') */
  labelKey: string
  /** 设置项 desc 的 i18n key(可空,部分项仅有 label) */
  descKey?: string
  /** 唯一标识,对应右侧 setting-row 上 data-setting-key(用于 scrollIntoView 定位) */
  key: string
}

/**
 * 设置项静态索引 —— 覆盖全部 6 类设置项。
 * 分类映射(对齐 plan):
 *   appearance  外观(theme/language/aiLanguage/showTokenUsage)
 *   ai-model    AI 模型(provider 列表 / 负载均衡池 / 模型拉取)
 *   knowledge   知识库(auto_extract/trigger_mode/min_messages/auto_inject/
 *               vector_enabled/embedding_provider/embedding_model)
 *   performance 性能(global-concurrency/per-conv-concurrency/
 *               max-iterations/max-retries)
 *   security    安全(allowed_dirs)
 *   advanced    高级(autoExecuteMode/logLevel + 连接)
 */
export const SETTINGS_INDEX: SettingIndexEntry[] = [
  // ===== 外观 =====
  { category: 'appearance', key: 'theme', labelKey: 'settings.labelTheme', descKey: 'settings.descTheme' },
  { category: 'appearance', key: 'language', labelKey: 'settings.labelLanguage', descKey: 'settings.descLanguage' },
  { category: 'appearance', key: 'aiLanguage', labelKey: 'settings.labelAiLanguage', descKey: 'settings.descAiLanguage' },
  { category: 'appearance', key: 'showTokenUsage', labelKey: 'settings.labelShowTokenUsage', descKey: 'settings.descShowTokenUsage' },
  // 加固(索引漂移):streamingMd 在 AppearanceSection.vue 渲染(AR-1 流式 Markdown 渲染开关),
  // 此前漏入索引 → 搜索"流式/markdown/渲染"无法命中该项。补入 appearance 类与渲染处对齐。
  { category: 'appearance', key: 'streamingMd', labelKey: 'settings.labelStreamingMd', descKey: 'settings.descStreamingMd' },

  // ===== AI 模型(provider 卡片级设置在 ProviderPanel 动态渲染,此处索引面板标题 +
  //   负载均衡池/模型拉取等关键交互项,i18n 文案可被关键词命中) =====
  { category: 'ai-model', key: 'provider', labelKey: 'settings.panelAiProvider' },
  { category: 'ai-model', key: 'addProvider', labelKey: 'settings.addProvider' },
  { category: 'ai-model', key: 'poolEnabled', labelKey: 'settings.detailPoolEnabled', descKey: 'settings.descPoolEnabled' },
  { category: 'ai-model', key: 'poolWeight', labelKey: 'settings.detailPoolWeight', descKey: 'settings.descPoolWeight' },
  { category: 'ai-model', key: 'testConnection', labelKey: 'settings.testConnection' },
  { category: 'ai-model', key: 'modelList', labelKey: 'settings.modelListTitle' },

  // ===== 知识库 =====
  { category: 'knowledge', key: 'autoExtract', labelKey: 'settings.labelAutoExtract', descKey: 'settings.descAutoExtract' },
  { category: 'knowledge', key: 'triggerMode', labelKey: 'settings.labelTriggerMode', descKey: 'settings.descTriggerMode' },
  { category: 'knowledge', key: 'minMessages', labelKey: 'settings.labelMinMessages', descKey: 'settings.descMinMessages' },
  { category: 'knowledge', key: 'autoInject', labelKey: 'settings.labelAutoInject', descKey: 'settings.descAutoInject' },
  { category: 'knowledge', key: 'vectorEnabled', labelKey: 'settings.labelVectorEnabled', descKey: 'settings.descVectorEnabled' },
  { category: 'knowledge', key: 'embeddingProvider', labelKey: 'settings.labelEmbeddingProvider', descKey: 'settings.descEmbeddingProvider' },
  { category: 'knowledge', key: 'embeddingModel', labelKey: 'settings.labelEmbeddingModel', descKey: 'settings.descEmbeddingModel' },

  // ===== 性能 =====
  { category: 'performance', key: 'globalConcurrency', labelKey: 'settings.labelGlobalConcurrency', descKey: 'settings.descGlobalConcurrency' },
  { category: 'performance', key: 'perConvConcurrency', labelKey: 'settings.labelPerConvConcurrency', descKey: 'settings.descPerConvConcurrency' },
  { category: 'performance', key: 'agentMaxIterations', labelKey: 'settings.labelAgentMaxIterations', descKey: 'settings.descAgentMaxIterations' },
  { category: 'performance', key: 'agentMaxRetries', labelKey: 'settings.labelAgentMaxRetries', descKey: 'settings.descAgentMaxRetries' },

  // ===== 安全 =====
  { category: 'security', key: 'allowedDirs', labelKey: 'settings.panelAllowedDirs', descKey: 'settings.descAllowedDirs' },
  { category: 'security', key: 'scriptWhitelist', labelKey: 'settings.labelScriptWhitelist', descKey: 'settings.descScriptWhitelist' },
  { category: 'security', key: 'scriptBlacklist', labelKey: 'settings.labelScriptBlacklist', descKey: 'settings.descScriptBlacklist' },

  // ===== 高级 =====
  // F-#97:autoExecute(boolean) → autoExecuteMode(low/medium/all 三档),key 同步更名
  // dataDir(应用数据目录):AdvancedSection.vue 渲染行,此前漏入索引
  { category: 'advanced', key: 'dataDir', labelKey: 'settings.labelDataDir', descKey: 'settings.descDataDir' },
  { category: 'advanced', key: 'autoExecuteMode', labelKey: 'settings.labelAutoExecute', descKey: 'settings.descAutoExecute' },
  { category: 'advanced', key: 'logLevel', labelKey: 'settings.labelLogLevel', descKey: 'settings.descLogLevel' },
  { category: 'advanced', key: 'approvalTimeout', labelKey: 'settings.labelApprovalTimeout', descKey: 'settings.descApprovalTimeout' },
  { category: 'advanced', key: 'connection', labelKey: 'settings.panelConnection', descKey: 'settings.emptyConnection' },
]
