import { defineStore } from 'pinia';

export type ModelKey = 'kimi' | 'deepseek' | 'qwen3-max' | 'qwen3-vl-plus';

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

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

export const useModelStore = defineStore('model', {
  state: (): ModelState => ({
    currentModelKey: 'kimi',
    models: [
      {
        key: 'kimi',
        label: 'Kimi-k2',
        description: '综合能力较强',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'deepseek',
        label: 'Deepseek-V3.2',
        description: '数学能力较强',
        fastOnly: false,
        supportsThinking: true
      },
      {
        key: 'qwen3-max',
        label: 'Qwen-Max',
        description: '仅支持快速模式',
        fastOnly: true,
        supportsThinking: false
      },
      {
        key: 'qwen3-vl-plus',
        label: 'Qwen-VL',
        description: '支持图片输入',
        fastOnly: false,
        supportsThinking: 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;
      }
    }
  }
});
