import { EventType } from "./event-type.enum";

export const EventCategory = {
  UserEvents: "userEvents",
  ItemEvents: "itemEvents",
  CollectionEvents: "collectionEvents",
  GroupEvents: "groupEvents",
  OrganizationMemberEvents: "organizationMemberEvents",
  OrganizationEvents: "organizationEvents",
  ProviderEvents: "providerEvents",
} as const;

export type EventCategory = (typeof EventCategory)[keyof typeof EventCategory];

export const EventCategoryEventTypes: Record<EventCategory, EventType[]> = {
  [EventCategory.UserEvents]: [
    EventType.User_LoggedIn,
    EventType.User_ChangedPassword,
    EventType.User_Updated2fa,
    EventType.User_Disabled2fa,
    EventType.User_Recovered2fa,
    EventType.User_FailedLogIn,
    EventType.User_FailedLogIn2fa,
    EventType.User_ClientExportedVault,
    EventType.User_UpdatedTempPassword,
    EventType.User_MigratedKeyToKeyConnector,
    EventType.User_RequestedDeviceApproval,
    EventType.User_TdeOffboardingPasswordSet,
  ],
  [EventCategory.ItemEvents]: [
    EventType.Cipher_Created,
    EventType.Cipher_Updated,
    EventType.Cipher_Deleted,
    EventType.Cipher_AttachmentCreated,
    EventType.Cipher_AttachmentDeleted,
    EventType.Cipher_Shared,
    EventType.Cipher_UpdatedCollections,
    EventType.Cipher_ClientViewed,
    EventType.Cipher_ClientToggledPasswordVisible,
    EventType.Cipher_ClientToggledHiddenFieldVisible,
    EventType.Cipher_ClientToggledCardCodeVisible,
    EventType.Cipher_ClientCopiedPassword,
    EventType.Cipher_ClientCopiedHiddenField,
    EventType.Cipher_ClientCopiedCardCode,
    EventType.Cipher_ClientAutofilled,
    EventType.Cipher_SoftDeleted,
    EventType.Cipher_Restored,
    EventType.Cipher_ClientToggledCardNumberVisible,
    EventType.Cipher_ClientToggledTOTPSeedVisible,
  ],
  [EventCategory.CollectionEvents]: [
    EventType.Collection_Created,
    EventType.Collection_Updated,
    EventType.Collection_Deleted,
  ],
  [EventCategory.GroupEvents]: [
    EventType.Group_Created,
    EventType.Group_Updated,
    EventType.Group_Deleted,
  ],
  [EventCategory.OrganizationMemberEvents]: [
    EventType.OrganizationUser_Invited,
    EventType.OrganizationUser_Confirmed,
    EventType.OrganizationUser_Updated,
    EventType.OrganizationUser_Removed,
    EventType.OrganizationUser_UpdatedGroups,
    EventType.OrganizationUser_UnlinkedSso,
    EventType.OrganizationUser_ResetPassword_Enroll,
    EventType.OrganizationUser_ResetPassword_Withdraw,
    EventType.OrganizationUser_AdminResetPassword,
    EventType.OrganizationUser_ResetSsoLink,
    EventType.OrganizationUser_FirstSsoLogin,
    EventType.OrganizationUser_Revoked,
    EventType.OrganizationUser_Restored,
    EventType.OrganizationUser_ApprovedAuthRequest,
    EventType.OrganizationUser_RejectedAuthRequest,
    EventType.OrganizationUser_Deleted,
    EventType.OrganizationUser_Left,
  ],
  [EventCategory.OrganizationEvents]: [
    EventType.Organization_Updated,
    EventType.Organization_PurgedVault,
    EventType.Organization_ClientExportedVault,
    EventType.Organization_VaultAccessed,
    EventType.Organization_EnabledSso,
    EventType.Organization_DisabledSso,
    EventType.Organization_EnabledKeyConnector,
    EventType.Organization_DisabledKeyConnector,
    EventType.Organization_SponsorshipsSynced,
    EventType.Organization_CollectionManagementUpdated,
    EventType.Organization_CollectionManagement_LimitCollectionCreationEnabled,
    EventType.Organization_CollectionManagement_LimitCollectionCreationDisabled,
    EventType.Organization_CollectionManagement_LimitCollectionDeletionEnabled,
    EventType.Organization_CollectionManagement_LimitCollectionDeletionDisabled,
    EventType.Organization_CollectionManagement_LimitItemDeletionEnabled,
    EventType.Organization_CollectionManagement_LimitItemDeletionDisabled,
    EventType.Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsEnabled,
    EventType.Organization_CollectionManagement_AllowAdminAccessToAllCollectionItemsDisabled,
  ],
  [EventCategory.ProviderEvents]: [
    EventType.ProviderUser_Invited,
    EventType.ProviderUser_Confirmed,
    EventType.ProviderUser_Updated,
    EventType.ProviderUser_Removed,
    EventType.ProviderOrganization_Created,
    EventType.ProviderOrganization_Added,
    EventType.ProviderOrganization_Removed,
    EventType.ProviderOrganization_VaultAccessed,
  ],
};
