import { useStorage } from '@vueuse/core'

export interface MarkingSettings {
  // 图片位置
  imagePosition: 'left' | 'center' | 'right'
  // 背景颜色
  backgroundColor: string
  // 键盘大小
  keyboardSize: 'normal' | 'large'
  // 快捷打分鼠标右键提交
  quickScoreRightClick: boolean
  // 图片排列
  imageLayout: 'horizontal' | 'vertical'

  // MarkingToolbar 相关设置
  showTraceToolbar: boolean
  showScoreKeyboard: boolean
  showQuickScore: boolean
  stepSize: number
  scoreMode: 'add' | 'subtract'
  autoSubmit: boolean
  // 隐藏打分栏
  hideMarkingToolbar: boolean

  // 快捷打分点击模式
  quickScoreClickMode: boolean
  quickScoreClickValue: number

  // TraceToolbar 相关设置
  penColor: string
  penWidth: number
  textColor: string
  textSize: number
  showToolOptions: boolean

  // MultiModeToolbar 相关设置
  displayCount: number
  hideMarked: boolean

  // 快捷打分相关设置
  quickScoreScores: number[]
  quickScoreMode: 'onekey' | 'quick'
  quickScoreLayout: 'single' | 'double'

  // 一键打分相关设置
  onekeyScoreScores: number[]
}

// 默认设置
const defaultSettings: MarkingSettings = {
  imagePosition: 'left',
  backgroundColor: '#F0F0F0',
  keyboardSize: 'normal',
  quickScoreRightClick: false,
  imageLayout: 'vertical',

  // MarkingToolbar 默认值
  showTraceToolbar: true,
  showScoreKeyboard: false,
  showQuickScore: false,
  stepSize: 1,
  scoreMode: 'add',
  autoSubmit: true,
  hideMarkingToolbar: false,

  // 快捷打分点击模式默认值
  quickScoreClickMode: false,
  quickScoreClickValue: 0,

  // TraceToolbar 默认值
  penColor: '#ff0000',
  penWidth: 2,
  textColor: '#000000',
  textSize: 14,
  showToolOptions: false,

  // MultiModeToolbar 默认值
  displayCount: 4,
  hideMarked: false,

  // 快捷打分默认值
  quickScoreMode: 'onekey',
  quickScoreScores: [1, 2],
  quickScoreLayout: 'single',

  // 一键打分默认值
  onekeyScoreScores: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
}

export const markingSettings = useStorage<MarkingSettings>('marking_settings', defaultSettings)

export function useMarkingSettings() {
  return markingSettings
}
