import type { Component } from 'vue';

import NoticeTicker from '../components/NoticeTicker.vue';
import WidgetAppointmentUpcoming from '../components/WidgetAppointmentUpcoming.vue';
import WidgetCalendarTodo from '../components/WidgetCalendarTodo.vue';
import WidgetClinicToday from '../components/WidgetClinicToday.vue';
import WidgetDoctorToday from '../components/WidgetDoctorToday.vue';
import WidgetOrderPending from '../components/WidgetOrderPending.vue';
import WidgetPharmacistPending from '../components/WidgetPharmacistPending.vue';
import WidgetPlatformOverview from '../components/WidgetPlatformOverview.vue';
import WidgetQuickEntry from '../components/WidgetQuickEntry.vue';
import WidgetSalespersonSummary from '../components/WidgetSalespersonSummary.vue';
import WidgetTodoCenter from '../components/WidgetTodoCenter.vue';
import WidgetWorkCalendar from '../components/WidgetWorkCalendar.vue';

/**
 * widget_code → 组件映射（与后端 WorkbenchWidgetEnum 对齐）
 * 后端 layout 下发未知 code 时前端直接跳过，保证两端可独立灰度上线
 * notice 已由列表卡（WidgetNotice，弃用保留）换成单行轮播条 NoticeTicker，
 * 实际渲染位置由 index.vue 固定插槽控制（驾驶舱卡底内嵌 / 无驾驶舱独立一行）
 */
export const WIDGET_COMPONENT_MAP: Record<string, Component> = {
  quick_nav: WidgetQuickEntry,
  notice: NoticeTicker,
  doctor_today: WidgetDoctorToday,
  pharmacist_pending: WidgetPharmacistPending,
  salesperson_summary: WidgetSalespersonSummary,
  clinic_today: WidgetClinicToday,
  order_pending: WidgetOrderPending,
  platform_overview: WidgetPlatformOverview,
  todo_center: WidgetTodoCenter,
  appointment_upcoming: WidgetAppointmentUpcoming,
  // 日程待办（快捷入口行右侧）与日程日历（快捷入口行下方全宽），布局位置固定不进 KPI 区
  calendar_todo: WidgetCalendarTodo,
  work_calendar: WidgetWorkCalendar,
};

/** KPI 类模块（渲染在中部 KPI 区，其余按固定位置渲染） */
export const KPI_WIDGET_CODES = new Set([
  'doctor_today',
  'pharmacist_pending',
  'salesperson_summary',
  'clinic_today',
  'order_pending',
  'platform_overview',
  'todo_center',
  'appointment_upcoming',
]);
