import { defineStore } from 'pinia';

export type ModelKey = 'kimi-k2.5' | 'kimi' | 'deepseek' | 'qwen3-vl-plus' | 'minimax-m2.5';

export interface ModelOption {
  key: ModelKey;
  label: string;
  description: string;
  fastOnly: boolean;
  supportsThinking: boolean;
  deepOnly?: boolean;
}

interface ModelState {
  currentModelKey: ModelKey;
  models: ModelOption[];
}

export const useModelStore = defineStore('model', {
  state: (): ModelState => ({
    currentModelKey: 'kimi-k2.5',
    models: [
      {
        key: 'kimi-k2.5',
        label: 'Kimi-k2.5',
        description: '新版 Kimi，支持图文 & 思考开关',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'kimi',
        label: 'Kimi-k2',
        description: '综合能力较强',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'deepseek',
        label: 'Deepseek-V3.2',
        description: '数学能力较强',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'qwen3-vl-plus',
        label: 'Qwen3.5',
        description: '图文视频多模态 + 深度思考',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'minimax-m2.5',
        label: 'MiniMax-M2.5',
        description: '仅深度思考，超长上下文',
        fastOnly: false,
        supportsThinking: true,
        deepOnly: true
      }
    ]
  }),
  getters: {
    currentModel(state): ModelOption {
      return state.models.find(m => m.key === state.currentModelKey) || state.models[0];
    }
  },
  actions: {
    setModel(key: ModelKey) {
      if (this.currentModelKey === key) return;
      const exists = this.models.some(m => m.key === key);
      if (exists) {
        this.currentModelKey = key;
      }
    }
  }
});
