/**
 * 公共常量 - 从统一配置中心导入并重新导出
 * 保持向后兼容，所有旧引用无需修改
 */

import {
  ANIMATION_CONFIG,
  PAGINATION_CONFIG,
  PROGRESS_THRESHOLDS,
} from '../config/app';

// ==================== 状态映射配置 ====================

/** 计划状态枚举值（消除散落的字符串字面量） */
export const PLAN_STATUS = {
  PENDING: 'pending',
  PRODUCING: 'producing',
  COMPLETED: 'completed',
  REJECTED: 'rejected',
} as const;

/** 流程步骤状态枚举值 */
export const STEP_STATUS = {
  PENDING: 'pending',
  ACTIVE: 'active',
  COMPLETED: 'completed',
  REJECTED: 'rejected',
} as const;

/** 工厂类型枚举值 */
export const FACTORY_TYPE = {
  TEXTILE: 'textile',
  WASHING: 'washing',
} as const;

/** 仓库类型枚举值 */
export const WAREHOUSE_TYPE = {
  RAW_FABRIC: 'raw_fabric',
  FABRIC: 'fabric',
  FINISHED: 'finished',
  YARN: 'yarn',
} as const;

/** 结款状态枚举值 */
export const PAYMENT_STATUS = {
  PENDING: 'pending',
  COMPLETED: 'completed',
} as const;

/** 分享链接状态枚举值 */
export const SHARE_LINK_STATUS = {
  PENDING: 'pending',
  CLICKED: 'clicked',
  CONFIRMED: 'confirmed',
  REJECTED: 'rejected',
  EXPIRED: 'expired',
  CANCELLED: 'cancelled',
} as const;

/** 水洗计划状态枚举值 */
export const WASHING_PLAN_STATUS = {
  PENDING: 'pending',
  IN_PROGRESS: 'in_progress',
  COMPLETED: 'completed',
} as const;

/** 出入库记录类型 */
export const INVENTORY_RECORD_TYPE = {
  IN: 'in',
  OUT: 'out',
} as const;

/** 出库类型 */
export const OUTBOUND_TYPE = {
  MANUAL: 'manual',
  AUTO: 'auto',
} as const;

// ==================== UI 状态映射 ====================

// 状态映射配置
export const statusMap: Record<string, { label: string; color: string; bgColor: string; borderColor: string }> = {
  [PLAN_STATUS.PENDING]: { label: '待确定', color: 'text-amber-700', bgColor: 'bg-amber-50', borderColor: 'border-amber-200' },
  [PLAN_STATUS.PRODUCING]: { label: '生产中', color: 'text-blue-700', bgColor: 'bg-blue-50', borderColor: 'border-blue-200' },
  [PLAN_STATUS.COMPLETED]: { label: '已完成', color: 'text-emerald-700', bgColor: 'bg-emerald-50', borderColor: 'border-emerald-200' },
  [PLAN_STATUS.REJECTED]: { label: '已拒绝', color: 'text-gray-700', bgColor: 'bg-gray-100', borderColor: 'border-gray-300' }
};

// 简化的状态映射（用于纺织厂）
export const simpleStatusMap: Record<string, { label: string; color: string }> = {
  [PLAN_STATUS.PENDING]: { label: '待确定', color: 'bg-yellow-100 text-yellow-700' },
  [PLAN_STATUS.PRODUCING]: { label: '生产中', color: 'bg-blue-100 text-blue-700' },
  [PLAN_STATUS.COMPLETED]: { label: '已完成', color: 'bg-green-100 text-green-700' },
  [PLAN_STATUS.REJECTED]: { label: '已拒绝', color: 'bg-gray-100 text-gray-600' }
};

// ==================== 步骤配置 ====================

// 步骤类型配置
export const stepTypeConfig: Record<string, { name: string; icon: string }> = {
  confirm: { name: '确认计划', icon: 'Check' },
  yarn_purchase: { name: '采纱', icon: 'Clock' },
  dyeing: { name: '染纱', icon: 'Clock' },
  machine_start: { name: '上机', icon: 'Clock' },
  fabric_warehouse: { name: '坯布生产', icon: 'Package' }
};

// 步骤名称映射
export const stepNames: Record<string, string> = {
  confirm: '确认计划',
  yarn_purchase: '采纱',
  dyeing: '染纱',
  machine_start: '上机',
  fabric_warehouse: '坯布生产'
};

// 步骤顺序
export const stepOrder = ['confirm', 'yarn_purchase', 'dyeing', 'machine_start', 'fabric_warehouse'];

// ==================== 从配置中心导出的常量（向后兼容） ====================

// 动画配置
export const animationConfig = ANIMATION_CONFIG;

// 分页配置
export const paginationConfig = {
  defaultPageSize: PAGINATION_CONFIG.defaultPageSize,
  maxInventoryRecords: PAGINATION_CONFIG.maxInventoryRecords,
  maxPriceHistory: PAGINATION_CONFIG.maxPriceHistory,
};

// 进度阈值
export const progressThresholds = {
  complete: PROGRESS_THRESHOLDS.complete,
};
