// ✅ Slice: /redux/slices/kueDataSlice.ts
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface KueDataState {
  //---------------------
  kueBezeichnungen: string[];
  isolationsgrenzwerte: number[];
  verzoegerung: number[];
  untereSchleifenGrenzwerte: number[];
  obereSchleifenGrenzwerte: number[];
  schleifenintervall: number[];
  //---------------
  counter: number | null;
  flutter: string | null;
  //-----------------------
  //-----------------------
  kueOnline: number[];
  kueID: string[];
  kuePSTmMinus96V: number[];
  kueAlarm1: number[];
  kueAlarm2: number[];
  kueIso: number[];
  kueResidence: number[];
  kueCableBreak: number[];
  kueGroundFault: number[];
  kueLimit1: number[];
  kueLimit2Low: number[];
  kueDelay1: number[];
  kueLoopInterval: number[];
  kueVersion: number[];
  kueOverflow: number[];

  tdrAtten: number[];
  tdrPulse: number[];
  tdrSpeed: number[];
  tdrAmp: number[];
  tdrTrigger: number[];
  tdrLocation: number[];
  tdrActive: number[];
  tdrLast: string[];
  tdrOverflow: number[];
  kueLimit2High: number[];
  memoryInterval: number[];
}

const initialState: KueDataState = {
  //---------------------
  kueBezeichnungen: [],
  isolationsgrenzwerte: [],
  verzoegerung: [],
  untereSchleifenGrenzwerte: [],
  obereSchleifenGrenzwerte: [],
  schleifenintervall: [],
  //---------------
  counter: null,
  flutter: null,
  //-----------------------
  //-----------------------
  kueOnline: [],
  kueID: [],
  kuePSTmMinus96V: [],
  kueAlarm1: [],
  kueAlarm2: [],
  kueIso: [],
  kueResidence: [],
  kueCableBreak: [],
  kueGroundFault: [],
  kueLimit1: [],
  kueLimit2Low: [],
  kueDelay1: [],
  kueLoopInterval: [],
  kueVersion: [],
  kueOverflow: [],

  tdrAtten: [],
  tdrPulse: [],
  tdrSpeed: [],
  tdrAmp: [],
  tdrTrigger: [],
  tdrLocation: [],
  tdrActive: [],
  tdrLast: [],
  tdrOverflow: [],
  kueLimit2High: [],
  memoryInterval: [],
};

const kueDataSlice = createSlice({
  name: "kueDataSlice",
  initialState,
  reducers: {
    setKueData: (state, action: PayloadAction<Partial<KueDataState>>) => {
      return { ...state, ...action.payload };
    },
  },
});

export const { setKueData } = kueDataSlice.actions;
export default kueDataSlice.reducer;
