// API Version
export const API_VERSION = 'v1'

// API Base URL
export const API_BASE_URL = (window as any).ENV?.VITE_API_URL || 'https://mitlistbe.mohamad.dev'

// API Endpoints
export const API_ENDPOINTS = {
  // Auth
  AUTH: {
    LOGIN: '/auth/jwt/login',
    SIGNUP: '/auth/register',
    LOGOUT: '/auth/jwt/logout',
    REFRESH: '/auth/jwt/refresh',
    VERIFY_EMAIL: '/auth/verify',
    RESET_PASSWORD: '/auth/forgot-password',
    FORGOT_PASSWORD: '/auth/forgot-password',
  },

  // Users
  USERS: {
    PROFILE: '/users/me',
    UPDATE_PROFILE: '/users/me',
    PASSWORD: '/api/v1/users/password',
    AVATAR: '/api/v1/users/avatar',
    SETTINGS: '/api/v1/users/settings',
    NOTIFICATIONS: '/api/v1/users/notifications',
    PREFERENCES: '/api/v1/users/preferences',
  },

  // Lists
  LISTS: {
    BASE: '/lists',
    BY_ID: (id: string) => `/lists/${id}`,
    ITEMS: (listId: string) => `/lists/${listId}/items`,
    ITEM: (listId: string, itemId: string) => `/lists/${listId}/items/${itemId}`,
    EXPENSES: (listId: string) => `/lists/${listId}/expenses`,
    SHARE: (listId: string) => `/lists/${listId}/share`,
    UNSHARE: (listId: string) => `/lists/${listId}/unshare`,
    COMPLETE: (listId: string) => `/lists/${listId}/complete`,
    REOPEN: (listId: string) => `/lists/${listId}/reopen`,
    ARCHIVE: (listId: string) => `/lists/${listId}/archive`,
    RESTORE: (listId: string) => `/lists/${listId}/restore`,
    DUPLICATE: (listId: string) => `/lists/${listId}/duplicate`,
    EXPORT: (listId: string) => `/lists/${listId}/export`,
    IMPORT: '/lists/import',
  },

  // Groups
  GROUPS: {
    BASE: '/groups',
    BY_ID: (id: string) => `/groups/${id}`,
    LISTS: (groupId: string) => `/groups/${groupId}/lists`,
    MEMBERS: (groupId: string) => `/groups/${groupId}/members`,
    MEMBER: (groupId: string, userId: string) => `/groups/${groupId}/members/${userId}`,
    CREATE_INVITE: (groupId: string) => `/groups/${groupId}/invites`,
    GET_ACTIVE_INVITE: (groupId: string) => `/groups/${groupId}/invites`,
    LEAVE: (groupId: string) => `/groups/${groupId}/leave`,
    DELETE: (groupId: string) => `/groups/${groupId}`,
    SETTINGS: (groupId: string) => `/groups/${groupId}/settings`,
    ROLES: (groupId: string) => `/groups/${groupId}/roles`,
    ROLE: (groupId: string, roleId: string) => `/groups/${groupId}/roles/${roleId}`,
  },

  // Invites
  INVITES: {
    BASE: '/invites',
    BY_ID: (id: string) => `/invites/${id}`,
    ACCEPT: (id: string) => `/invites/accept/${id}`,
    DECLINE: (id: string) => `/invites/decline/${id}`,
    REVOKE: (id: string) => `/invites/revoke/${id}`,
    LIST: '/invites',
    PENDING: '/invites/pending',
    SENT: '/invites/sent',
  },

  // Items (for direct operations like update, get by ID)
  ITEMS: {
    BY_ID: (itemId: string) => `/items/${itemId}`,
  },

  // OCR
  OCR: {
    PROCESS: '/ocr/extract-items',
    STATUS: (jobId: string) => `/ocr/status/${jobId}`,
    RESULT: (jobId: string) => `/ocr/result/${jobId}`,
    BATCH: '/ocr/batch',
    CANCEL: (jobId: string) => `/ocr/cancel/${jobId}`,
    HISTORY: '/ocr/history',
  },

  // Costs
  COSTS: {
    BASE: '/costs',
    LIST_SUMMARY: (listId: string | number) => `/costs/lists/${listId}/cost-summary`,
    GROUP_BALANCE_SUMMARY: (groupId: string | number) => `/costs/groups/${groupId}/balance-summary`,
  },

  // Financials
  FINANCIALS: {
    EXPENSES: '/financials/expenses',
    EXPENSE: (id: string) => `/financials/expenses/${id}`,
    SETTLEMENTS: '/financials/settlements',
    SETTLEMENT: (id: string) => `/financials/settlements/${id}`,
    BALANCES: '/financials/balances',
    BALANCE: (userId: string) => `/financials/balances/${userId}`,
    REPORTS: '/financials/reports',
    REPORT: (id: string) => `/financials/reports/${id}`,
    CATEGORIES: '/financials/categories',
    CATEGORY: (id: string) => `/financials/categories/${id}`,
  },

  // Health
  HEALTH: {
    CHECK: '/health',
    VERSION: '/health/version',
    STATUS: '/health/status',
    METRICS: '/health/metrics',
    LOGS: '/health/logs',
  },
}
