/**
 * ======================================================
 * Notifications Service Constants
 * ======================================================
 *
 * This file defines:
 * - Notification message types and labels
 * - Notification mediums and delivery types
 * - Module-wise notification event identifiers
 * - Alert and Reminder notification configurations
 *
 * These constants are used by:
 * - Notification creation services
 * - User notification settings
 * - UI labels and filters
 * - Role / category based notification targeting
 */

/**
 * Notification message types
 * Used for high-level classification in UI and logic
 */
export const NOTIFICATION_MESSAGE_TYPES = {
  '1': 'Alert',
  '2': 'Task',
  '3': 'Message',
  '4': 'Reminder',
};

/**
 * Reverse mapping of message labels to numeric identifiers
 * Useful when storing message types in DB
 */
export const NOTIFICATION_LABELS = {
  alert: 1,
  task: 2,
  message: 3,
  reminder: 4,
};

/**
 * Notification delivery behavior types
 * - Single: individual notifications
 * - Grouped: merged notifications
 */
export const NOTIFICATION_TYPES = {
  1: 'Single',
  2: 'Grouped',
};
/**
 * Supported notification delivery mediums
 */
export const NOTIFICATION_MEDIUMS = {
  1: 'Email',
  2: 'System Notification',
};

/**
 * ======================================================
 * Notification Target Categories
 * ======================================================
 */

/**
 * Lead-level notification categories
 */
export const LEAD_NOTIFY_CATEGORIES = {
  employee: 'Employee',
  branch: 'Branch',
  department: 'Department',
};

/**
 * Client-level notification categories
 * More granular, based on assignment context
 */
export const CLIENT_NOTIFY_CATEGORIES = {
  employee_assigned_lead: 'Employee - Assigned Lead',
  branch_assigned_lead: 'Branch - Assigned Lead',
  department_assigned_lead: 'Department - Assigned Lead',
  employee_assigned_visa_case: 'Employee - Assigned Visa Case',
  branch_assigned_visa_case: 'Branch - Assigned Visa Case',
  department_assigned_visa_case: 'Department - Assigned Visa Case',
};

/**
 * ======================================================
 * Alert Notification Namespaces (ANS)
 * ======================================================
 * These constants define:
 * - Module identifiers
 * - Event identifiers under each module
 */

/**
 * Lead module alert events
 */
export const ANS_LEAD = 'lead';
export const ANS_LEAD_ASSIGNED = 'assigned';
export const ANS_LEAD_RE_ASSIGNED = 're_assigned';
export const ANS_LEAD_UNASSIGNED = 'unassigned';
export const ANS_LEAD_TEMPORARY_ASSIGNED = 'temporary_assigned';
export const ANS_LEAD_TEMPORARY_ASSIGNED_REVERTED =
  'temporary_assigned_reverted';
export const ANS_LEAD_DROPPED = 'dropped';
export const ANS_LEAD_CLOSED = 'closed';
export const ANS_LEAD_DROPPED_CLOSED_ACTIVE = 'dropped_closed_active';
export const ANS_LEAD_RE_ENQUIRY = 're_enquiry';
export const ANS_LEAD_MISSED_FOLLOWUP = 'missed_followup';
export const ANS_LEAD_SALE_ON_LEAD = 'sale_on_lead';
export const ANS_LEAD_NEW_REMARK = 'new_remark';

/**
 * Lead reminder events
 */
export const RNS_LEAD_UPCOMING_FOLLOWUP = 'upcoming_followup';

/**
 * Client module alert & reminder events
 */
export const ANS_CLIENT = 'client';
export const ANS_CLIENT_PRIMARY_NUMBER_CHANGED = 'primary_number_changed';
export const ANS_CLIENT_PASSPORT_EXPIRED = 'passport_expired';
export const ANS_CLIENT_PROFICIENCY_EXPIRED = 'language_proficiency_expired';
export const ANS_CLIENT_VISA_EXPIRED = 'visa_expired';
export const RNS_CLIENT_PASSPORT_EXPIRY = 'passport_expiry';
export const RNS_CLIENT_LANGUAGE_PROFICIENCY_EXPIRY =
  'language_proficiency_expiry';
export const RNS_CLIENT_VISA_EXPIRY = 'visa_expiry';

/**
 * Sales module events
 */
export const ANS_SALES = 'sales';
export const ANS_SALE_STATUS_CHANGED = 'sale_status_changed';
export const ANS_SALE_PAYMENT_STATUS_CHANGED = 'payment_request_status_changed';
export const ANS_SALE_INSTALLMENT_DUE_TRIGGERED = 'installment_due_triggered';
export const ANS_SALE_NEW_TRANSACTION_CONDUCTED = 'new_transaction_conducted';
export const RNS_SALE_DUE_DATE = 'due_date';

/**
 * Visa Service Case module events
 */
export const ANS_VISA_SERVICE_CASE = 'visa_service_case';
export const ANS_VSC_CASE_CREATED = 'case_created';
export const ANS_VSC_CASE_ASSIGNED = 'case_assigned';
export const ANS_VSC_CASE_RE_ASSIGNED = 'case_re_assigned';
export const ANS_VSC_CASE_UNASSIGNED = 'case_unassigned';
export const ANS_VSC_TEMPORARY_ASSIGNED = 'temporary_assigned';
export const ANS_VSC_TEMPORARY_ASSIGNED_REVERTED =
  'temporary_assigned_reverted';
export const ANS_VSC_ITERATION_CREATED = 'iteration_created';
export const ANS_VSC_STATE_CHANGED = 'state_changed';
export const ANS_VSC_STATUS_CHANGED = 'status_changed';
export const ANS_VSC_PIPELINE_CHANGED = 'pipeline_changed';
export const ANS_VSC_NEW_REMARK = 'new_remark';
export const ANS_VSC_NEW_AFFILIATE_MESSAGE = 'new_affiliate_message';
export const ANS_VSC_MISSED_FOLLOWUP = 'missed_followup';
export const RNS_VSC_UPCOMING_FOLLOWUP = 'upcoming_followup';

/**
 * Workspace module events
 */
export const ANS_WORKSPACE = 'workspace';
export const ANS_WORKSPACE_ITEM_ASSIGNED = 'item_assigned';
export const ANS_WORKSPACE_RESOLUTION_UPDATED = 'resolution_updated';
export const ANS_WORKSPACE_STATUS_UPDATED = 'status_updated';

/**
 * Request Permissions module events
 */
export const ANS_REQUEST_PERMISSIONS = 'request_permissions';
export const ANS_RP_WAIVER_PERMISSION = 'waiver_permission';
export const ANS_RP_CLIENT_PERMISSION = 'client_permission';
export const ANS_RP_SALE_ADJUSTMENT_PERMISSION = 'sale_adjustment_permission';
export const ANS_RP_LEAD_PERMISSION = 'lead_permission';
export const ANS_RP_VISA_PERMISSION = 'visa_permission';

/**
 * ======================================================
 * Alert Notification Settings
 * ======================================================
 *
 * Used to:
 * - Build notification settings UI
 * - Determine titles and categories per event
 * - Control who should receive which alerts
 */
export const ALERT_NOTIFY_SETTINGS = {
  [ANS_LEAD]: {
    title: 'Lead',
    description: '',
    events: {
      [ANS_LEAD_ASSIGNED]: {
        title: 'Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_RE_ASSIGNED]: {
        title: 'Re-Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_UNASSIGNED]: {
        title: 'Unassigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_TEMPORARY_ASSIGNED]: {
        title: 'Temporary Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_TEMPORARY_ASSIGNED_REVERTED]: {
        title: 'Temporary Assigned Reverted',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_DROPPED]: {
        title: 'Dropped',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_CLOSED]: {
        title: 'Closed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_DROPPED_CLOSED_ACTIVE]: {
        title: 'Dropped / Closed to Active',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_RE_ENQUIRY]: {
        title: 'Re-Enquiry / New History',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_MISSED_FOLLOWUP]: {
        title: 'Missed Followup',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_SALE_ON_LEAD]: {
        title: 'Sale on Lead',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_LEAD_NEW_REMARK]: {
        title: 'New Remark',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_CLIENT]: {
    title: 'Client',
    description: '',
    events: {
      [ANS_CLIENT_PRIMARY_NUMBER_CHANGED]: {
        title: 'Primary Number Changed',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
      [ANS_CLIENT_PASSPORT_EXPIRED]: {
        title: 'Passport Expired',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
      [ANS_CLIENT_PROFICIENCY_EXPIRED]: {
        title: 'Language Proficiency Expired',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
      [ANS_CLIENT_VISA_EXPIRED]: {
        title: 'Visa Expired',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_SALES]: {
    title: 'Sales',
    description: '',
    events: {
      [ANS_SALE_STATUS_CHANGED]: {
        title: 'Sale Status Changed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_SALE_PAYMENT_STATUS_CHANGED]: {
        title: 'Payment Request Status Changed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_SALE_INSTALLMENT_DUE_TRIGGERED]: {
        title: 'Installment Due Triggered',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_SALE_NEW_TRANSACTION_CONDUCTED]: {
        title: 'New Transaction Conducted',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_VISA_SERVICE_CASE]: {
    title: 'Visa Service Case',
    description: '',
    events: {
      [ANS_VSC_CASE_CREATED]: {
        title: 'Case Created',
        categories: {
          assessment: 'Assessment',
          enrollment: 'Enrollment',
          admissions: 'Admissions',
          filing: 'Filing',
          sop: 'SOP',
          ssa: 'SSA',
        },
      },
      [ANS_VSC_CASE_ASSIGNED]: {
        title: 'Case Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_CASE_RE_ASSIGNED]: {
        title: 'Case Re-Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_CASE_UNASSIGNED]: {
        title: 'Case Unassigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_TEMPORARY_ASSIGNED]: {
        title: 'Temporary Assigned',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_TEMPORARY_ASSIGNED_REVERTED]: {
        title: 'Temporary Assigned Reverted',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_ITERATION_CREATED]: {
        title: 'Iteration Created',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_STATE_CHANGED]: {
        title: 'State Changed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_STATUS_CHANGED]: {
        title: 'Status Changed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_PIPELINE_CHANGED]: {
        title: 'Pipeline Changed',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_NEW_REMARK]: {
        title: 'New Remark',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_NEW_AFFILIATE_MESSAGE]: {
        title: 'New Affiliate Message',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_VSC_MISSED_FOLLOWUP]: {
        title: 'Missed Followup',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_WORKSPACE]: {
    title: 'Workspace',
    description: '',
    events: {
      [ANS_WORKSPACE_ITEM_ASSIGNED]: {
        title: 'Item Assigned',
        categories: {
          visa_service_task: 'Visa Service Task',
          general_task: 'General Task',
          reminder: 'Reminder',
        },
      },
      [ANS_WORKSPACE_RESOLUTION_UPDATED]: {
        title: 'Resolution Updated',
        categories: {
          visa_service_task: 'Visa Service Task',
          general_task: 'General Task',
        },
      },
      [ANS_WORKSPACE_STATUS_UPDATED]: {
        title: 'Status Updated',
        categories: {
          visa_service_task: 'Visa Service Task',
          general_task: 'General Task',
        },
      },
    },
  },
  [ANS_REQUEST_PERMISSIONS]: {
    title: 'Request Permissions',
    description: '',
    events: {
      [ANS_RP_WAIVER_PERMISSION]: {
        title: 'Waiver Permission',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_RP_CLIENT_PERMISSION]: {
        title: 'Client Permission',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_RP_SALE_ADJUSTMENT_PERMISSION]: {
        title: 'Sale Adjustment Permission',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_RP_LEAD_PERMISSION]: {
        title: 'Lead Permission',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
      [ANS_RP_VISA_PERMISSION]: {
        title: 'Visa Permission',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
};

/**
 * ======================================================
 * Reminder Notification Settings
 * ======================================================
 *
 * Used for time-based or scheduled notifications
 * (expiry dates, upcoming followups, due dates, etc.)
 */
export const REMINDER_NOTIFY_SETTINGS = {
  [ANS_LEAD]: {
    title: 'Lead',
    description: '',
    events: {
      [RNS_LEAD_UPCOMING_FOLLOWUP]: {
        title: 'Upcoming Followup',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_CLIENT]: {
    title: 'Client',
    description: '',
    events: {
      [RNS_CLIENT_PASSPORT_EXPIRY]: {
        title: 'Passport Expiry',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
      [RNS_CLIENT_LANGUAGE_PROFICIENCY_EXPIRY]: {
        title: 'Language Proficiency Expiry',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
      [RNS_CLIENT_VISA_EXPIRY]: {
        title: 'Visa Expiry',
        categories: CLIENT_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_SALES]: {
    title: 'Sales',
    description: '',
    events: {
      [RNS_SALE_DUE_DATE]: {
        title: 'Due Date',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
  [ANS_VISA_SERVICE_CASE]: {
    title: 'Visa Service Case',
    description: '',
    events: {
      [RNS_VSC_UPCOMING_FOLLOWUP]: {
        title: 'Upcoming Followup',
        categories: LEAD_NOTIFY_CATEGORIES,
      },
    },
  },
};
