import { employeeItems, knowledgeItems, skillItems } from "../data/mockData";
import EditorBlock from "../components/EditorBlock";
import Field from "../components/Field";
import SectionHeading from "../components/SectionHeading";
import Terminal from "../components/Terminal";
import ToggleRow from "../components/ToggleRow";

export default function SettingsContent({ active }) {
  if (active === "基础配置") {
    return (
      <div className="flex min-h-0 flex-1 flex-col gap-5">
        <SectionHeading title="大模型 key 配置" desc="兼容 OpenAI 协议" />
        <div className="grid gap-3">
          <Field label="模型厂家" value="豆包 / 火山引擎 / DeepSeek / 自定义" disabled />
          <Field label="请求地址" value="https://api.example.com/v1" />
          <Field label="API Key" value="sk-****************" secret  />
          <Field label="模型名称" value="doubao-pro-32k" />
        </div>
        <div className="flex gap-3">
          <button className="btn-primary  flex-1">保存</button>
          <button className="btn-test  flex-1">测试连接</button>
        </div>
        <Terminal
          title="大模型请求记录"
          lines={[
            { level: "info", message: "[ready] 等待测试连接" },
            { level: "warning", message: "[hint] 保存后由 Rust command 写入本地配置" },
          ]}
        />
      </div>
    );
  }

  if (active === "提示词配置") {
    return (
      <div className="flex min-h-0 flex-1 flex-col gap-5">
        <SectionHeading title="提示词配置" desc="固定提示词不可编辑，自定义提示词可保存。" />
        <EditorBlock title="固定提示词"  text="你是本地微信分身助手，需要遵守托管策略、回复边界与用户授权。" />
        <EditorBlock title="自定义提示词" text="保持友好、简洁、可信赖。优先调用知识库和已授权员工能力。" fill />
        <button className="btn-primary">保存提示词</button>
      </div>
    );
  }

  const listMap = {
    回复规则: ["免打扰模式", "自动加好友", "主动联系客户", "开启蒸馏", "拉黑用户名称列表", "白名单用户名称列表"],
    skill管理: ["开启 skill 功能", ...skillItems.map((item) => item.name)],
    员工管理: ["开启使用员工功能", ...employeeItems.map((item) => item.name)],
    知识库管理: ["开启使用知识库功能", ...knowledgeItems.map((item) => item.title)],
    托管配置: ["开启托管功能", "本地消息服务", "发送前人工确认", "异常自动暂停"],
  };

  return (
    <>
      <SectionHeading title={active} desc="授权开关将在接入 Tauri command 后持久化到 sqlite 配置表。" />
      <div className="space-y-3">
        {(listMap[active] || []).map((item, index) => (
          <ToggleRow key={item} label={item} enabled={index % 3 !== 1} />
        ))}
      </div>
      <button className="btn-primary">保存配置</button>
    </>
  );
}
