import { Moment } from 'moment';
import { TypePeriod, TypeRotation } from './DevicesCardInfo/Endpoint/types';

export enum EndpointGroupName {
  Main = 'main',
  Scan = 'scanDirAtStartUp',
  WhiteList = 'whiteList',
  Device = 'deviceManagementSettings',
  Antivirus = 'antivirusSettings',
  Rotation = 'rotation',
  Validation = 'validation',
}

export enum FirewallGroupName {
  Main = 'main',
  Validation = 'validation',
}

export type TEventsGroup = {
  [key: string]: {
    name: string;
    type: string;
    key: string;
    gridId?: string;
    columnFields?: any;
  }[];
};

export type TGroup = {
  [key: string]: { name: string; type: string; key: string }[][];
};

export type TypeCollectiveActionMessages = {
  downloadFireWallConfig: {
    confirmMessage: string;
    popoverMessage: string;
  };
  updateClamAVDB: {
    confirmMessage: string;
    popoverMessage: string;
  };
  uploadFireWallConfig: {
    confirmMessage: string;
    popoverMessage: string;
  };
  uploadFireWallRules: {
    confirmMessage: string;
    popoverMessage: string;
    notification: {
      warning: string;
      success: string;
    };
  };
  updateEndpointConfig: {
    confirmMessage: string;
    popoverMessage: string;
  };
  successMessages: string;
  warningMessage: string;
  errorMessage: string;
  descriptionErrorAndWarningMessage: string;
};

export type TypeRotationMessages = {
  title: string;
  period: string;
  day: string;
  week: string;
  month: string;
  time: string;
  periodExtra: string;
  timeExtra: string;
};

export type TypeEndpointGroupNameAntivirusSettings = {
  title: string;
  scanBlockTitle: string;
  clamavEnabled: string;
  clamavStartScan: string;
  clamavStartScanExtra: string;
  clamavResults: string;
  clamavResultsExtra: string;
  clamavDeleteInfectedFiles: string;
  clamavUpdateDb: string;
  loadUpdateFiles: string;
  viewLog: string;
  table: {
    search: string;
    selectAll: string;
    columns: {
      clamav_paths: string;
      actions: string;
    };
  };
};

export type TypeCardInfoEndpointMessages = {
  [EndpointGroupName.Main]: {
    title: string;
    name: string;
    namePlaceholder: string;
    nameExtra: string;
    ip: string;
    ipPlaceholder: string;
    ipExtra: string;
    port: string;
    portPlaceholder: string;
    portExtra: string;
    manufacturer: string;
    group: string;
    groupExtra: string;
    info: string;
  };
  [EndpointGroupName.Scan]: {
    title: string;
    icEnabled: string;
    icTimeout: string;
    icTimeoutExtra: string;
    table: {
      search: string;
      searchPlaceholder: string;
      selectAll: string;
      columns: {
        ic_scan_folders: string;
        actions: string;
      };
    };
  };
  [EndpointGroupName.WhiteList]: {
    title: string;
    wlEnable: string;
    wlAdmin: string;
    table: {
      search: string;
      selectAll: string;
      columns: {
        whiteList: string;
        actions: string;
      };
    };
  };
  [EndpointGroupName.Device]: {
    title: string;

    dcEnabled: string;
    prohibitCdAccess: string;
    prohibitCdAccessExtra: string;
    usbControlEnabled: string;
    usbControlEnabledExtra: string;
    table: {
      search: string;
      selectColumns: string;
      manageDeviceClassAccess: string;
      columns: {
        name: string;
        deviceClass: string;
        deviceSubClass: string;
        sn: string;
        connected: string;
        controlStatus: string;
      };
    };
  };
  [EndpointGroupName.Antivirus]: TypeEndpointGroupNameAntivirusSettings;
  [EndpointGroupName.Rotation]: TypeRotationMessages;
  dynamicTable: {
    selectAll: string;
    unSelectAll: string;
    searchPlaceholder: string;
    pathToFile: string;
    edit: string;
    delete: string;
    save: string;
    cancel: string;
    selectedEntries: string;
    deleteQuestions: string;
    deleteEditQuestions: string;
    cancelQuestions: string;
    deleteMasQuestions: string;
    ok: string;
    actions: string;
    validation: {
      thisPathExist: string;
    };
  };
};

export type TypeCardInfoFirewallMessages = {
  [FirewallGroupName.Main]: {
    title: string;
    name: string;
    namePlaceholder: string;
    nameExtra: string;
    ip: string;
    ipPlaceholder: string;
    ipExtra: string;
    key: string;
    keyPlaceholder: string;
    keyExtra: string;
    secret: string;
    secretPlaceholder: string;
    secretExtra: string;
    port: string;
    portPlaceholder: string;
    portExtra: string;
    group: string;
    groupExtra: string;
    info: string;
  };
};

export type TypeCardInfoSensorMessages = {
  main: {
    title: string;
    name: {
      title: string;
      placeholder: string;
      extra: string;
    };
    ip: { title: string; placeholder: string; extra: string };
    port: { title: string; placeholder: string; extra: string };
    group: {
      title: string;
      extra: string;
    };
    description: string;
    authenticationKey: {
      title: string;
      help: {
        emptyField: string;
        fullField: string;
      };
    };
  };
  interfaceFields: {
    title: string;
    name: string;
    extra: string;
  };
  networkTrafficAnalyzers: {
    title: string;
    enableSignatureAnalysis: string;
    enableDpiProtocolAnalysis: string;
  };
  notification: {
    copyAuthorizationKeySuccess: string;
  };
};

export type TypeCardInfoMessages = {
  title: string;
  copyEndpointTitle: string;
  typeSelector: { placeholder: string; validation: string };
  type: string;
  endpoint: TypeCardInfoEndpointMessages;
  firewall: TypeCardInfoFirewallMessages;
  sensor: TypeCardInfoSensorMessages;
  formFieldValidation: {
    fieldExist: (field: string) => string;
  };
};

export type TypeSingleActionMessages = {
  downloadFireWallConfig: string;
  uploadFireWallConfig: string;
  uploadFireWallRules: string;
  downloadEndpointConfig: string;
  updateEndpointConfig: string;
  firewallReboot: string;
  deleting: {
    popover: string;
    confirm: string;
  };
  edit: string;
};

export type TUseDevicesMessages = {
  title: string;
  leftSideBar: { [key: string]: string };
  notification: {
    newDevicesConnected: string;
    deviceChanged: string;
    deviceDeleted: string;
    deviceDeletedQuestion: string;
    saved: string;
    uploaded: string;
    successSavedConfiguration: string;
    failedSavedConfiguration: string;
    uploadedConfiguration: string;
    uploadedRules: string;
    uploadedRulesNotFullRules: (count: number, total: number) => string;
    preUploadedRules: string;
    uploadedError: string;
    uploadedErrorDescription: string;
    updated: string;
    updatedConfiguration: string;
    updatedError: string;
    updatedErrorDescription: string;
    updatedClamAVDBSuccess: string;
    updatedClamAVDBWarningFileExistTitle: string;
    updatedClamAVDBWarningFileExistSubTitle: string;
    tryLater: string;
    groupSuccessDelete: string;
    groupFailedDelete: string;
    firewallFailConnect: string;
    firewallFailChangeConfiguration: string;
    endpointFailChangeConfiguration: string;
    sensorFailedCreate: string;
    sensorFailChangeConfiguration: string;
    tryAgain: string;
    firewallReboot: {
      success: string;
      failed: string;
    };
    failedFetchEventSourceData: string;
  };
  table: {
    columnMessages: {
      [key: string]: string;
    };
    button: { [key: string]: string };
  };
  localeCardInfo: TypeCardInfoMessages;
  singleActionMessages: TypeSingleActionMessages;
  collectiveActionsMessages: TypeCollectiveActionMessages;
};

export type TypeEndpointDynamicTablePath = { id: number; path: string }[];

export type TypeRotationFormField = {
  event_rotation_period: TypePeriod;
  event_rotation_size?: number;
  event_rotation_time?: Moment | null;
  event_rotation_type: TypeRotation;
};

export type TypeUploadedIdsRules = {
  id: number;
  response: { status: string; success: number; failed: number };
};
