/**
 * 작업자 화면 목업 데이터
 *
 * 실제 API 연동 전환 시 참조용으로 보존
 * USE_MOCK = true 일 때 API 데이터 뒤에 병합됨
 */

import type { ProcessTab, WorkItemData } from './types';

// ===== 목업 ON/OFF 플래그 =====
// true: API 데이터 + 목업 데이터 병합 (개발 중)
// false: API 데이터만 사용 (운영)
export const USE_MOCK = false;

// ===== 공정별 목업 데이터 =====
export const MOCK_ITEMS: Record<ProcessTab, WorkItemData[]> = {
  screen: [
    {
      id: 'mock-s1', itemNo: 1, itemCode: 'KWWS03', itemName: '와이어', floor: '1층', code: 'FSS-01',
      width: 8260, height: 8350, quantity: 2, processType: 'screen',
      cuttingInfo: { width: 1210, sheets: 8 },
      steps: [
        { id: 's1-1', name: '자재투입', isMaterialInput: true, isCompleted: true },
        { id: 's1-2', name: '절단', isMaterialInput: false, isCompleted: true },
        { id: 's1-3', name: '미싱', isMaterialInput: false, isCompleted: false },
        { id: 's1-4', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
      materialInputs: [
        { id: 'm1', lotNo: 'LOT-2026-001', itemName: '스크린 원단 A', quantity: 500, unit: 'm' },
        { id: 'm2', lotNo: 'LOT-2026-002', itemName: '와이어 B', quantity: 120, unit: 'EA' },
      ],
    },
    {
      id: 'mock-s2', itemNo: 2, itemCode: 'KWWS05', itemName: '메쉬', floor: '2층', code: 'FSS-03',
      width: 6400, height: 5200, quantity: 4, processType: 'screen',
      cuttingInfo: { width: 1600, sheets: 4 },
      steps: [
        { id: 's2-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
        { id: 's2-2', name: '절단', isMaterialInput: false, isCompleted: false },
        { id: 's2-3', name: '미싱', isMaterialInput: false, isCompleted: false },
        { id: 's2-4', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
    },
    {
      id: 'mock-s3', itemNo: 3, itemCode: 'KWWS08', itemName: '와이어(광폭)', floor: '3층', code: 'FSS-05',
      width: 12000, height: 4500, quantity: 1, processType: 'screen',
      cuttingInfo: { width: 2400, sheets: 5 },
      steps: [
        { id: 's3-1', name: '자재투입', isMaterialInput: true, isCompleted: true },
        { id: 's3-2', name: '절단', isMaterialInput: false, isCompleted: true },
        { id: 's3-3', name: '미싱', isMaterialInput: false, isCompleted: true },
        { id: 's3-4', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
      materialInputs: [
        { id: 'm3', lotNo: 'LOT-2026-005', itemName: '광폭 원단', quantity: 300, unit: 'm' },
      ],
    },
  ],
  slat: [
    {
      id: 'mock-l1', itemNo: 1, itemCode: 'KQTS01', itemName: '슬랫코일', floor: '1층', code: 'FSS-01',
      width: 8260, height: 8350, quantity: 2, processType: 'slat',
      slatInfo: { length: 3910, slatCount: 40, jointBar: 4, glassQty: 2 },
      steps: [
        { id: 'l1-1', name: '자재투입', isMaterialInput: true, isCompleted: true },
        { id: 'l1-2', name: '포밍/절단', isMaterialInput: false, isCompleted: false },
        { id: 'l1-3', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
      materialInputs: [
        { id: 'm4', lotNo: 'LOT-2026-010', itemName: '슬랫 코일 A', quantity: 200, unit: 'kg' },
      ],
    },
    {
      id: 'mock-l2', itemNo: 2, itemCode: 'KQTS03', itemName: '슬랫코일(광폭)', floor: '2층', code: 'FSS-02',
      width: 10500, height: 6200, quantity: 3, processType: 'slat',
      slatInfo: { length: 5200, slatCount: 55, jointBar: 6, glassQty: 3 },
      steps: [
        { id: 'l2-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
        { id: 'l2-2', name: '포밍/절단', isMaterialInput: false, isCompleted: false },
        { id: 'l2-3', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
    },
  ],
  bending: [
    {
      id: 'mock-b1', itemNo: 1, itemCode: 'KWWS03', itemName: '가이드레일', floor: '1층', code: 'FSS-01',
      width: 0, height: 0, quantity: 6, processType: 'bending',
      bendingInfo: {
        common: {
          kind: '혼합형 120X70', type: '혼합형',
          lengthQuantities: [{ length: 4000, quantity: 6 }, { length: 3000, quantity: 6 }],
        },
        detailParts: [
          { partName: '엘바', material: 'EGI 1.6T', barcyInfo: '16 I 75' },
          { partName: '하장바', material: 'EGI 1.6T', barcyInfo: '16|75|16|75|16(A각)' },
        ],
      },
      steps: [
        { id: 'b1-1', name: '자재투입', isMaterialInput: true, isCompleted: true },
        { id: 'b1-2', name: '절단', isMaterialInput: false, isCompleted: true },
        { id: 'b1-3', name: '절곡', isMaterialInput: false, isCompleted: false },
        { id: 'b1-4', name: '포장완료', isMaterialInput: false, isCompleted: false },
      ],
    },
  ],
};

// ===== 절곡 재공품 전용 목업 데이터 =====
export const MOCK_ITEMS_BENDING_WIP: WorkItemData[] = [
  {
    id: 'mock-bw1', itemNo: 1, itemCode: 'KWWS03', itemName: '케이스 - 전면부', floor: '-', code: '-',
    width: 0, height: 0, quantity: 6, processType: 'bending',
    isWip: true,
    wipInfo: { specification: 'EGI 1.55T (W576)', lengthQuantity: '4,000mm X 6개' },
    steps: [
      { id: 'bw1-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
      { id: 'bw1-2', name: '절단', isMaterialInput: false, isCompleted: false },
    ],
  },
  {
    id: 'mock-bw2', itemNo: 2, itemCode: 'KWWS04', itemName: '케이스 - 후면부', floor: '-', code: '-',
    width: 0, height: 0, quantity: 4, processType: 'bending',
    isWip: true,
    wipInfo: { specification: 'EGI 1.55T (W576)', lengthQuantity: '3,500mm X 4개' },
    steps: [
      { id: 'bw2-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
      { id: 'bw2-2', name: '절단', isMaterialInput: false, isCompleted: false },
    ],
  },
  {
    id: 'mock-bw3', itemNo: 3, itemCode: 'KWWS05', itemName: '하단마감재', floor: '-', code: '-',
    width: 0, height: 0, quantity: 10, processType: 'bending',
    isWip: true,
    wipInfo: { specification: 'EGI 1.2T (W400)', lengthQuantity: '2,800mm X 10개' },
    steps: [
      { id: 'bw3-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
      { id: 'bw3-2', name: '절단', isMaterialInput: false, isCompleted: false },
    ],
  },
];

// ===== 슬랫 조인트바 전용 목업 데이터 =====
export const MOCK_ITEMS_SLAT_JOINTBAR: WorkItemData[] = [
  {
    id: 'mock-jb1', itemNo: 1, itemCode: 'KQJB01', itemName: '조인트바 A', floor: '1층', code: 'FSS-01',
    width: 0, height: 0, quantity: 8, processType: 'slat',
    isJointBar: true,
    slatJointBarInfo: { specification: 'EGI 1.6T', length: 3910, quantity: 8 },
    steps: [
      { id: 'jb1-1', name: '자재투입', isMaterialInput: true, isCompleted: true },
      { id: 'jb1-2', name: '포밍/절단', isMaterialInput: false, isCompleted: false },
      { id: 'jb1-3', name: '포장완료', isMaterialInput: false, isCompleted: false },
    ],
    materialInputs: [
      { id: 'mjb1', lotNo: 'LOT-2026-020', itemName: '조인트바 코일', quantity: 100, unit: 'kg' },
    ],
  },
  {
    id: 'mock-jb2', itemNo: 2, itemCode: 'KQJB02', itemName: '조인트바 B', floor: '2층', code: 'FSS-02',
    width: 0, height: 0, quantity: 12, processType: 'slat',
    isJointBar: true,
    slatJointBarInfo: { specification: 'EGI 1.6T', length: 5200, quantity: 12 },
    steps: [
      { id: 'jb2-1', name: '자재투입', isMaterialInput: true, isCompleted: false },
      { id: 'jb2-2', name: '포밍/절단', isMaterialInput: false, isCompleted: false },
      { id: 'jb2-3', name: '포장완료', isMaterialInput: false, isCompleted: false },
    ],
  },
];

// ===== 하드코딩된 공정별 단계 폴백 =====
export const PROCESS_STEPS_FALLBACK: Record<string, { name: string; isMaterialInput: boolean }[]> = {
  screen: [
    { name: '자재투입', isMaterialInput: true },
    { name: '절단', isMaterialInput: false },
    { name: '미싱', isMaterialInput: false },
    { name: '포장완료', isMaterialInput: false },
  ],
  slat: [
    { name: '자재투입', isMaterialInput: true },
    { name: '포밍/절단', isMaterialInput: false },
    { name: '포장완료', isMaterialInput: false },
  ],
  bending: [
    { name: '자재투입', isMaterialInput: true },
    { name: '절단', isMaterialInput: false },
    { name: '절곡', isMaterialInput: false },
    { name: '포장완료', isMaterialInput: false },
  ],
  bending_wip: [
    { name: '자재투입', isMaterialInput: true },
    { name: '절단', isMaterialInput: false },
  ],
};