import InstanceRenderManager from "../../../utils/instanceRenderMgr.js";

const statisticsItems = [
  { id: 0, name: "totalHrs", label: "total_hours_in_production" },
  { id: 1, name: "totalAmountInProduction", label: "total_amount_in_production" },
  { id: 2, name: "totalLAB", label: "total_lab_in_production" },
  { id: 3, name: "totalLAR", label: "total_lar_in_production" },
  { id: 4, name: "jobsInProduction", label: "jobs_in_production" },

  {
    id: 5,
    name: "totalHrsOnBoard",
    label: InstanceRenderManager({
      imex: "total_hours_in_view",
      rome: "total_hours_on_board"
    })
  },
  {
    id: 6,
    name: "totalAmountOnBoard",
    label: InstanceRenderManager({
      imex: "total_amount_in_view",
      rome: "total_amount_on_board"
    })
  },
  {
    id: 7,
    name: "totalLABOnBoard",
    label: InstanceRenderManager({
      imex: "total_lab_in_view",
      rome: "total_lab_on_board"
    })
  },
  {
    id: 8,
    name: "totalLAROnBoard",
    label: InstanceRenderManager({
      imex: "total_lar_in_view",
      rome: "total_lar_on_board"
    })
  },
  {
    id: 9,
    name: "jobsOnBoard",
    label: InstanceRenderManager({
      imex: "total_jobs_in_view",
      rome: "total_jobs_on_board"
    })
  },
  {
    id: 10,
    name: "tasksOnBoard",
    label: InstanceRenderManager({
      imex: "tasks_in_view",
      rome: "tasks_on_board"
    })
  },
  { id: 11, name: "tasksInProduction", label: "tasks_in_production" }
];

const defaultKanbanSettings = {
  ats: true,
  clm_no: true,
  compact: false,
  ownr_nm: true,
  sublets: true,
  ins_co_nm: true,
  production_note: true,
  employeeassignments: true,
  scheduled_completion: true,
  cardcolor: false,
  orientation: false,
  tasks: false,
  cardSize: "small",
  model_info: true,
  kiosk: false,
  partsreceived: false,
  totalHrs: true,
  totalAmountInProduction: false,
  totalLAB: true,
  totalLAR: true,
  jobsInProduction: true,
  totalHrsOnBoard: false,
  totalLABOnBoard: false,
  totalLAROnBoard: false,
  jobsOnBoard: false,
  tasksOnBoard: false,
  tasksInProduction: false,
  totalAmountOnBoard: true,
  estimator: false,
  subtotal: false,
  statisticsOrder: statisticsItems.map((item) => item.id),
  selectedMdInsCos: [],
  selectedEstimators: [],
  excludeSuspended: false
};

const defaultFilters = { search: "", employeeId: null, alert: false };

const mergeWithDefaults = (settings) => {
  // Create a new object that starts with the default settings
  const mergedSettings = { ...defaultKanbanSettings };

  // Override with the provided settings, if any
  if (settings) {
    for (const key in settings) {
      if (Object.prototype.hasOwnProperty.call(settings, key)) {
        mergedSettings[key] = settings[key];
      }
    }
  }

  return mergedSettings;
};

export { defaultKanbanSettings, statisticsItems, mergeWithDefaults, defaultFilters };
