/* Shared domain data — confección, datos realistas y consistentes entre pantallas */

const TENANT = { name: 'Confecciones Norte', slug: 'confecciones-norte' };
const USER = { name: 'Marcela Ríos', role: 'Supervisora', initials: 'MR' };

// status helpers: pill kind + label
const ORDERS = [
  { n: 1,  op: 'OP-1042', ref: 'CN-1042', gar: 'Camisa Classic',  cli: 'Almacenes Vélez', plant: 'Planta Norte', mono: 'CC', tile: 'cl', stage: 'ensamble',
    pct: 61, bar: 'cl', units: '340 / 560', delivery: '31 dic', days: 5, daysSoon: true, status: ['cl','En producción'], sig: ['ct','Delantero frena en ~40 min'] },
  { n: 2,  op: 'OP-1051', ref: 'BOM-22',   gar: 'Chaqueta Bomber', cli: 'Arturo Calle',    plant: 'Planta Norte', mono: 'CB', tile: '', stage: 'costura',
    pct: 38, bar: 'wn', units: '152 / 400', delivery: '02 ene', days: 7, daysSoon: false, status: ['cl','En producción'], sig: ['wn','Cuello · stock bajo 30/50'] },
  { n: 3,  op: 'OP-1039', ref: 'PQ-Polo',  gar: 'Polo Piqué',      cli: 'Tennis S.A.',     plant: 'Planta Sur',  mono: 'PP', tile: '', stage: 'terminado',
    pct: 84, bar: 'ok', units: '672 / 800', delivery: '04 ene', days: 9, daysSoon: false, status: ['cl','En producción'], sig: ['ok','Flujo normal'] },
  { n: 4,  op: 'OP-1058', ref: 'VL-Lino',  gar: 'Vestido Lino',    cli: 'Studio F',        plant: 'Planta Sur',  mono: 'VL', tile: '', stage: 'corte',
    pct: 12, bar: 'cl', units: '36 / 300',  delivery: '12 ene', days: 17, daysSoon: false, status: ['cl','En producción'], sig: ['ok','Flujo normal'] },
  { n: 5,  op: 'OP-1033', ref: 'CH-Chino', gar: 'Pantalón Chino',  cli: 'Gef',             plant: 'Planta Norte', mono: 'PC', tile: '', stage: 'empaque',
    pct: 100, bar: 'ok', units: '500 / 500', delivery: '28 dic', days: 2, daysSoon: false, status: ['ok','Completada'], sig: [null,''] },
  { n: 6,  op: 'OP-1061', ref: '',         gar: 'Buzo Hoodie',     cli: 'Naf Naf',         plant: 'Planta Sur',  mono: 'BH', tile: '', stage: 'corte',
    pct: 0,  bar: 'cl', units: '0 / 450',   delivery: '18 ene', days: 23, daysSoon: false, status: ['wt','Borrador'], sig: [null,''] },
  { n: 7,  op: 'OP-1047', ref: 'FAL-A',    gar: 'Falda Plisada',   cli: 'Pat Primo',       plant: 'Planta Norte', mono: 'FP', tile: 'wn', stage: 'costura',
    pct: 47, bar: 'wn', units: '188 / 400', delivery: '06 ene', days: 11, daysSoon: false, status: ['cl','En producción'], sig: ['wn','Ritmo bajo vs objetivo'] },
  { n: 8,  op: 'OP-1066', ref: 'CB-Basic', gar: 'Camiseta Básica', cli: 'Koaj',            plant: 'Planta Sur',  mono: 'TB', tile: '', stage: 'ensamble',
    pct: 73, bar: 'ok', units: '438 / 600', delivery: '05 ene', days: 10, daysSoon: false, status: ['cl','En producción'], sig: ['ok','Flujo normal'] },
  { n: 9,  op: 'OP-1070', ref: 'JJ-Jean',  gar: 'Chaqueta Jean',   cli: 'Chevignon',       plant: 'Planta Norte', mono: 'CJ', tile: '', stage: 'corte',
    pct: 22, bar: 'cl', units: '66 / 300',  delivery: '14 ene', days: 19, daysSoon: false, status: ['cl','En producción'], sig: ['ok','Flujo normal'] },
  { n: 10, op: 'OP-1072', ref: 'LG-Sport', gar: 'Leggings Sport',  cli: 'Bronzini',        plant: 'Planta Sur',  mono: 'LS', tile: 'wn', stage: 'costura',
    pct: 55, bar: 'wn', units: '330 / 600', delivery: '07 ene', days: 12, daysSoon: false, status: ['cl','En producción'], sig: ['wn','Ritmo bajo vs objetivo'] },
  { n: 11, op: 'OP-1075', ref: 'BZ-Sastre',gar: 'Blazer Sastre',   cli: 'Arturo Calle',    plant: 'Planta Norte', mono: 'BS', tile: '', stage: 'terminado',
    pct: 91, bar: 'ok', units: '273 / 300', delivery: '03 ene', days: 8, daysSoon: false, status: ['cl','En producción'], sig: ['ok','Flujo normal'] },
  { n: 12, op: 'OP-1029', ref: 'PJ-Set',   gar: 'Pijama Set',      cli: 'Pat Primo',       plant: 'Planta Sur',  mono: 'PJ', tile: '', stage: 'empaque',
    pct: 100, bar: 'ok', units: '400 / 400', delivery: '27 dic', days: 1, daysSoon: false, status: ['ok','Completada'], sig: [null,''] },
];

// operations DAG for OP-1042 (Camisa Classic)
const OPS = [
  { id: 'c1', name: 'Cortar cuello',  piece: 'Cuello', mach: 'CORT', sam: '0.8', status: 'ok', dot: 'ok', pct: 100, bar: 'ok', fin: false, lane: 0, col: 0 },
  { id: 'c2', name: 'Fusionar cuello',piece: 'Cuello', mach: 'FUSO', sam: '0.6', status: 'ok', dot: 'ok', pct: 92,  bar: 'ok', fin: false, lane: 0, col: 1 },
  { id: 'c3', name: 'Voltear cuello', piece: 'Cuello', mach: 'PL1A', sam: '1.1', status: 'wn', dot: 'wn', pct: 54,  bar: 'wn', fin: true,  lane: 0, col: 2 },
  { id: 'm1', name: 'Cortar manga',   piece: 'Manga',  mach: 'CORT', sam: '0.7', status: 'ok', dot: 'ok', pct: 100, bar: 'ok', fin: false, lane: 1, col: 0 },
  { id: 'm2', name: 'Dobladillar manga', piece: 'Manga', mach: 'RECU', sam: '1.8', status: 'cl', dot: 'cl', pct: 88, bar: 'cl', fin: true, lane: 1, col: 2 },
  { id: 'a1', name: 'Unir delant.+esp.', piece: 'Ensamble', mach: 'PL1A', sam: '2.4', status: 'ct', dot: 'ct', pct: 86, bar: 'ct', fin: false, lane: 2, col: 3, consumes: '' },
  { id: 'a2', name: 'Pegar cuello',   piece: 'Ensamble', mach: 'PL1A', sam: '2.1', status: 'nt', dot: 'nt', pct: 0, bar: 'cl', fin: false, lane: 2, col: 4, consumes: 'Cuello' },
  { id: 'a3', name: 'Pegar mangas',   piece: 'Ensamble', mach: 'FILE', sam: '2.0', status: 'nt', dot: 'nt', pct: 0, bar: 'cl', fin: false, lane: 2, col: 5, consumes: 'Manga' },
  { id: 'a4', name: 'Cerrar costados',piece: 'Ensamble', mach: 'FILE', sam: '1.6', status: 'nt', dot: 'nt', pct: 0, bar: 'cl', fin: false, lane: 2, col: 6 },
  { id: 'a5', name: 'Empaque',        piece: 'Ensamble', mach: '—',    sam: '0.9', status: 'nt', dot: 'nt', pct: 0, bar: 'cl', fin: false, lane: 2, col: 7 },
];
const EDGES = [
  ['c1','c2'],['c2','c3'],['m1','m2'],
  ['a1','a2'],['a2','a3'],['a3','a4'],['a4','a5'],
  ['c3','a2'],['m2','a3'],
];

const USERS = [
  { n: 'Marcela Ríos',     email: 'marcela@cnorte.co',  role: 'Supervisora', plant: 'Planta Norte', mod: 'Costura 1', on: true,  init: 'MR', tile: 'cl' },
  { n: 'Andrés Patiño',    email: 'andres@cnorte.co',   role: 'Operario',    plant: 'Planta Norte', mod: 'Corte A',   on: true,  init: 'AP', tile: '' },
  { n: 'Liliana Gómez',    email: 'liliana@cnorte.co',  role: 'Operaria',    plant: 'Planta Norte', mod: 'Ensamble',  on: true,  init: 'LG', tile: '' },
  { n: 'Carlos Mendoza',   email: 'carlos@cnorte.co',   role: 'Mecánico',    plant: 'Planta Sur',   mod: 'Costura 2', on: true,  init: 'CM', tile: '' },
  { n: 'Diana Restrepo',   email: 'diana@cnorte.co',    role: 'Analista',    plant: 'Todas',        mod: '—',         on: true,  init: 'DR', tile: '' },
  { n: 'Jorge Salazar',    email: 'jorge@cnorte.co',    role: 'Operario',    plant: 'Planta Sur',   mod: 'Empaque',   on: false, init: 'JS', tile: '' },
];

// Etapas de producción para el tablero kanban (orden = flujo físico de la planta)
const STAGES = [
  { id: 'corte',     label: 'Corte',     color: '#7b99b1', icon: 'scissors' },
  { id: 'costura',   label: 'Costura',   color: '#4c6b8b', icon: 'flow' },
  { id: 'ensamble',  label: 'Ensamble',  color: '#2b4260', icon: 'boxes' },
  { id: 'terminado', label: 'Terminado', color: '#5f7a59', icon: 'check' },
  { id: 'empaque',   label: 'Empaque',   color: '#8893a1', icon: 'pkg' },
];

// Throughput de planta — unidades terminadas por día (la caída del jueves = rotura del flujo)
const THROUGHPUT = {
  unit: 'uds',
  target: 520,
  days: [
    { d: 'Lun 22', label: 'lunes 22 dic',   v: 486 },
    { d: 'Mar 23', label: 'martes 23 dic',  v: 534 },
    { d: 'Mié 24', label: 'miércoles 24',   v: 502 },
    { d: 'Jue 25', label: 'jueves 25 dic',  v: 188, note: 'Rotura · delantero detenido' },
    { d: 'Vie 26', label: 'viernes 26 dic', v: 441 },
    { d: 'Sáb 27', label: 'sábado 27 dic',  v: 528 },
    { d: 'Hoy',    label: 'hoy · en curso', v: 312, partial: true },
  ],
};

Object.assign(window, { TENANT, USER, ORDERS, OPS, EDGES, USERS, STAGES, THROUGHPUT });
