/**
 * @deprecated Scheduled for removal in v2.0.0
 * --------------------------------------------------------------------------
 * ⚠️ NOTICE: V2 DATA&UI REFACTORING (by 0xfullex)
 * --------------------------------------------------------------------------
 * STOP: Feature PRs affecting this file are currently BLOCKED.
 * Only critical bug fixes are accepted during this migration phase.
 *
 * This file is being refactored to v2 standards.
 * Any non-critical changes will conflict with the ongoing work.
 *
 * 🔗 Context & Status:
 * - Contribution Hold: https://github.com/CherryHQ/cherry-studio/issues/10954
 * - v2 Refactor PR   : https://github.com/CherryHQ/cherry-studio/pull/10162
 * --------------------------------------------------------------------------
 */
import type { PayloadAction } from '@reduxjs/toolkit'
import { createSlice } from '@reduxjs/toolkit'

export interface CopilotState {
  username?: string
  avatar?: string
  defaultHeaders?: Record<string, string>
}

const initialState: CopilotState = {
  username: '',
  avatar: ''
}

export const copilotSlice = createSlice({
  name: 'copilot',
  initialState,
  reducers: {
    setUsername: (state, action: PayloadAction<string>) => {
      state.username = action.payload
    },
    setAvatar: (state, action: PayloadAction<string>) => {
      state.avatar = action.payload
    },
    setDefaultHeaders: (state, action: PayloadAction<Record<string, string>>) => {
      state.defaultHeaders = action.payload
    },
    updateCopilotState: (state, action: PayloadAction<Partial<CopilotState>>) => {
      return { ...state, ...action.payload }
    },
    resetCopilotState: () => initialState
  }
})

export const { setUsername, setAvatar, setDefaultHeaders, updateCopilotState, resetCopilotState } = copilotSlice.actions

export default copilotSlice.reducer
