import type {
  Tenant,
  PortalUser,
  ADUser,
  ADGroup,
  AuditLog,
  AgentTask,
  SyncStatus,
  DashboardStats,
  TenantPolicy,
} from './types'

// ======================================
// TENANTS
// ======================================
export const mockTenants: Tenant[] = [
  {
    id: 't1',
    name: 'Construtora Horizonte S.A.',
    domain: 'horizonte.local',
    status: 'active',
    agentStatus: 'online',
    lastAgentHeartbeat: '2025-01-15T14:32:00Z',
    agentVersion: '1.2.0',
    agentHostname: 'DC01-HORIZONTE',
    usersCount: 248,
    groupsCount: 32,
    portalUsersCount: 3,
    createdAt: '2024-03-10T09:00:00Z',
    updatedAt: '2025-01-15T14:32:00Z',
    baseDn: 'DC=horizonte,DC=local',
    defaultUserOU: 'OU=Usuarios,DC=horizonte,DC=local',
    defaultGroupOU: 'OU=Grupos,DC=horizonte,DC=local',
    preferredDC: '192.168.1.10',
    ldapPort: 389,
    useSSL: false,
    upnSuffix: 'horizonte.local',
    adUser: 'svc_admanager',
  },
  {
    id: 't2',
    name: 'Grupo Farmacêutico Vida',
    domain: 'grupovida.com.br',
    status: 'active',
    agentStatus: 'online',
    lastAgentHeartbeat: '2025-01-15T14:30:00Z',
    agentVersion: '1.2.0',
    agentHostname: 'SRV-AD-VIDA01',
    usersCount: 512,
    groupsCount: 64,
    portalUsersCount: 5,
    createdAt: '2024-05-22T11:00:00Z',
    updatedAt: '2025-01-15T14:30:00Z',
    baseDn: 'DC=grupovida,DC=com,DC=br',
    defaultUserOU: 'OU=Corp,OU=Users,DC=grupovida,DC=com,DC=br',
    defaultGroupOU: 'OU=Corp,OU=Groups,DC=grupovida,DC=com,DC=br',
    preferredDC: '10.0.0.5',
    ldapPort: 636,
    useSSL: true,
    upnSuffix: 'grupovida.com.br',
    adUser: 'adm_ldap',
  },
  {
    id: 't3',
    name: 'Logística Rápida Express',
    domain: 'lograpida.net',
    status: 'active',
    agentStatus: 'warning',
    lastAgentHeartbeat: '2025-01-15T11:15:00Z',
    agentVersion: '1.1.5',
    agentHostname: 'WINSERVER-LOG01',
    usersCount: 89,
    groupsCount: 14,
    portalUsersCount: 2,
    createdAt: '2024-08-01T08:00:00Z',
    updatedAt: '2025-01-15T11:15:00Z',
    baseDn: 'DC=lograpida,DC=net',
    defaultUserOU: 'OU=Funcionarios,DC=lograpida,DC=net',
    defaultGroupOU: 'OU=Departamentos,DC=lograpida,DC=net',
    preferredDC: '172.16.0.2',
    ldapPort: 389,
    useSSL: false,
    upnSuffix: 'lograpida.net',
    adUser: 'svc_portal',
  },
  {
    id: 't4',
    name: 'Advocacia Mello & Associados',
    domain: 'melloadvocacia.adv.br',
    status: 'active',
    agentStatus: 'offline',
    lastAgentHeartbeat: '2025-01-13T09:22:00Z',
    agentVersion: '1.1.0',
    agentHostname: 'MELLO-AD01',
    usersCount: 45,
    groupsCount: 8,
    portalUsersCount: 2,
    createdAt: '2024-10-15T10:30:00Z',
    updatedAt: '2025-01-13T09:22:00Z',
    baseDn: 'DC=melloadvocacia,DC=adv,DC=br',
    defaultUserOU: 'OU=Advogados,DC=melloadvocacia,DC=adv,DC=br',
    defaultGroupOU: 'OU=Grupos,DC=melloadvocacia,DC=adv,DC=br',
    preferredDC: '192.168.100.1',
    ldapPort: 389,
    useSSL: false,
    upnSuffix: 'melloadvocacia.adv.br',
    adUser: 'ad_service',
  },
  {
    id: 't5',
    name: 'TechSoft Sistemas',
    domain: 'techsoft.com.br',
    status: 'inactive',
    agentStatus: 'unknown',
    lastAgentHeartbeat: null,
    agentVersion: null,
    agentHostname: null,
    usersCount: 0,
    groupsCount: 0,
    portalUsersCount: 1,
    createdAt: '2025-01-05T16:00:00Z',
    updatedAt: '2025-01-05T16:00:00Z',
    baseDn: 'DC=techsoft,DC=com,DC=br',
    defaultUserOU: 'OU=Users,DC=techsoft,DC=com,DC=br',
    defaultGroupOU: 'OU=Groups,DC=techsoft,DC=com,DC=br',
    preferredDC: '',
    ldapPort: 389,
    useSSL: false,
    upnSuffix: 'techsoft.com.br',
    adUser: '',
  },
]

// ======================================
// PORTAL USERS
// ======================================
export const mockPortalUsers: PortalUser[] = [
  {
    id: 'u1',
    tenantId: null,
    tenantName: null,
    name: 'Carlos Administrador',
    email: 'admin@consultarti.tec.br',
    role: 'admin_global',
    status: 'active',
    mfaEnabled: true,
    lastLogin: '2025-01-15T14:00:00Z',
    createdAt: '2024-01-01T00:00:00Z',
    permissions: [],
  },
  {
    id: 'u2',
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    name: 'Ana Lima',
    email: 'ana.lima@horizonte.local',
    role: 'tenant_admin',
    status: 'active',
    mfaEnabled: true,
    lastLogin: '2025-01-15T13:45:00Z',
    createdAt: '2024-03-11T09:00:00Z',
    permissions: [],
  },
  {
    id: 'u3',
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    name: 'Pedro Santos',
    email: 'pedro.santos@horizonte.local',
    role: 'tenant_operator',
    status: 'active',
    mfaEnabled: true,
    lastLogin: '2025-01-14T10:30:00Z',
    createdAt: '2024-04-01T09:00:00Z',
    permissions: [],
  },
  {
    id: 'u4',
    tenantId: 't2',
    tenantName: 'Grupo Farmacêutico Vida',
    name: 'Marcos Oliveira',
    email: 'marcos.oliveira@grupovida.com.br',
    role: 'tenant_admin',
    status: 'active',
    mfaEnabled: true,
    lastLogin: '2025-01-15T09:00:00Z',
    createdAt: '2024-05-23T09:00:00Z',
    permissions: [],
  },
  {
    id: 'u5',
    tenantId: 't3',
    tenantName: 'Logística Rápida Express',
    name: 'Fernanda Costa',
    email: 'fernanda@lograpida.net',
    role: 'tenant_operator',
    status: 'blocked',
    mfaEnabled: false,
    lastLogin: '2025-01-10T08:00:00Z',
    createdAt: '2024-08-05T09:00:00Z',
    permissions: [],
  },
]

// ======================================
// AD USERS
// ======================================
export const mockADUsers: ADUser[] = [
  {
    id: 'adu1',
    tenantId: 't1',
    samAccountName: 'joao.silva',
    upn: 'joao.silva@horizonte.local',
    displayName: 'João da Silva',
    firstName: 'João',
    lastName: 'da Silva',
    email: 'joao.silva@horizonte.local',
    department: 'Engenharia',
    title: 'Engenheiro Civil',
    phone: '+55 11 99999-0001',
    ou: 'OU=Engenharia,OU=Usuarios,DC=horizonte,DC=local',
    groups: ['Engenharia', 'VPN-Users', 'FileServer-Read'],
    enabled: true,
    passwordNeverExpires: false,
    mustChangePassword: false,
    cannotChangePassword: false,
    lastSync: '2025-01-15T12:00:00Z',
    createdAt: '2023-05-10T09:00:00Z',
  },
  {
    id: 'adu2',
    tenantId: 't1',
    samAccountName: 'maria.santos',
    upn: 'maria.santos@horizonte.local',
    displayName: 'Maria dos Santos',
    firstName: 'Maria',
    lastName: 'dos Santos',
    email: 'maria.santos@horizonte.local',
    department: 'RH',
    title: 'Analista de RH',
    phone: '+55 11 99999-0002',
    ou: 'OU=RH,OU=Usuarios,DC=horizonte,DC=local',
    groups: ['RH-Equipe', 'VPN-Users'],
    enabled: true,
    passwordNeverExpires: true,
    mustChangePassword: false,
    cannotChangePassword: false,
    lastSync: '2025-01-15T12:00:00Z',
    createdAt: '2022-11-01T09:00:00Z',
  },
  {
    id: 'adu3',
    tenantId: 't1',
    samAccountName: 'roberto.alves',
    upn: 'roberto.alves@horizonte.local',
    displayName: 'Roberto Alves',
    firstName: 'Roberto',
    lastName: 'Alves',
    email: 'roberto.alves@horizonte.local',
    department: 'TI',
    title: 'Analista de TI',
    phone: null,
    ou: 'OU=TI,OU=Usuarios,DC=horizonte,DC=local',
    groups: ['TI-Equipe', 'Domain Admins', 'VPN-Users'],
    enabled: false,
    passwordNeverExpires: false,
    mustChangePassword: false,
    cannotChangePassword: false,
    lastSync: '2025-01-15T12:00:00Z',
    createdAt: '2021-03-15T09:00:00Z',
  },
  {
    id: 'adu4',
    tenantId: 't1',
    samAccountName: 'luciana.ferreira',
    upn: 'luciana.ferreira@horizonte.local',
    displayName: 'Luciana Ferreira',
    firstName: 'Luciana',
    lastName: 'Ferreira',
    email: 'luciana.ferreira@horizonte.local',
    department: 'Financeiro',
    title: 'Gerente Financeira',
    phone: '+55 11 99999-0004',
    ou: 'OU=Financeiro,OU=Usuarios,DC=horizonte,DC=local',
    groups: ['Financeiro-Gerencia', 'VPN-Users', 'FileServer-Full'],
    enabled: true,
    passwordNeverExpires: false,
    mustChangePassword: false,
    cannotChangePassword: false,
    lastSync: '2025-01-15T12:00:00Z',
    createdAt: '2020-09-20T09:00:00Z',
  },
  {
    id: 'adu5',
    tenantId: 't1',
    samAccountName: 'carlos.medeiros',
    upn: 'carlos.medeiros@horizonte.local',
    displayName: 'Carlos Medeiros',
    firstName: 'Carlos',
    lastName: 'Medeiros',
    email: 'carlos.medeiros@horizonte.local',
    department: 'Comercial',
    title: 'Vendedor',
    phone: '+55 11 99999-0005',
    ou: 'OU=Comercial,OU=Usuarios,DC=horizonte,DC=local',
    groups: ['Comercial-Equipe', 'VPN-Users'],
    enabled: true,
    passwordNeverExpires: false,
    mustChangePassword: true,
    cannotChangePassword: false,
    lastSync: '2025-01-15T12:00:00Z',
    createdAt: '2024-12-01T09:00:00Z',
  },
]

// ======================================
// AD GROUPS
// ======================================
export const mockADGroups: ADGroup[] = [
  {
    id: 'g1',
    tenantId: 't1',
    samAccountName: 'Domain Admins',
    displayName: 'Domain Admins',
    description: 'Administradores do domínio',
    dn: 'CN=Domain Admins,CN=Users,DC=horizonte,DC=local',
    membersCount: 3,
    protected: true,
    lastSync: '2025-01-15T12:00:00Z',
  },
  {
    id: 'g2',
    tenantId: 't1',
    samAccountName: 'Engenharia',
    displayName: 'Equipe de Engenharia',
    description: 'Todos os engenheiros',
    dn: 'OU=Engenharia,OU=Grupos,DC=horizonte,DC=local',
    membersCount: 48,
    protected: false,
    lastSync: '2025-01-15T12:00:00Z',
  },
  {
    id: 'g3',
    tenantId: 't1',
    samAccountName: 'RH-Equipe',
    displayName: 'Equipe de RH',
    description: 'Recursos Humanos',
    dn: 'OU=RH,OU=Grupos,DC=horizonte,DC=local',
    membersCount: 12,
    protected: false,
    lastSync: '2025-01-15T12:00:00Z',
  },
  {
    id: 'g4',
    tenantId: 't1',
    samAccountName: 'VPN-Users',
    displayName: 'Usuários VPN',
    description: 'Acesso à VPN corporativa',
    dn: 'OU=Acesso,OU=Grupos,DC=horizonte,DC=local',
    membersCount: 185,
    protected: false,
    lastSync: '2025-01-15T12:00:00Z',
  },
  {
    id: 'g5',
    tenantId: 't1',
    samAccountName: 'TI-Equipe',
    displayName: 'Equipe de TI',
    description: 'Time de tecnologia da informação',
    dn: 'OU=TI,OU=Grupos,DC=horizonte,DC=local',
    membersCount: 8,
    protected: false,
    lastSync: '2025-01-15T12:00:00Z',
  },
]

// ======================================
// AUDIT LOGS
// ======================================
export const mockAuditLogs: AuditLog[] = [
  {
    id: 'al1',
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    userId: 'u2',
    userName: 'Ana Lima',
    action: 'user.create',
    objectType: 'ADUser',
    objectId: 'adu5',
    objectName: 'Carlos Medeiros',
    details: 'Usuário criado: carlos.medeiros@horizonte.local, OU=Comercial',
    ipAddress: '187.45.123.88',
    status: 'success',
    taskId: 'task-001',
    agentResponse: '{"result":"success","dn":"CN=Carlos Medeiros,OU=Comercial,OU=Usuarios,DC=horizonte,DC=local"}',
    createdAt: '2024-12-01T09:05:00Z',
  },
  {
    id: 'al2',
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    userId: 'u3',
    userName: 'Pedro Santos',
    action: 'user.reset_password',
    objectType: 'ADUser',
    objectId: 'adu1',
    objectName: 'João da Silva',
    details: 'Senha redefinida para joao.silva@horizonte.local',
    ipAddress: '187.45.123.90',
    status: 'success',
    taskId: 'task-002',
    agentResponse: '{"result":"success"}',
    createdAt: '2025-01-10T10:30:00Z',
  },
  {
    id: 'al3',
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    userId: 'u2',
    userName: 'Ana Lima',
    action: 'user.assign_group',
    objectType: 'ADUser',
    objectId: 'adu1',
    objectName: 'João da Silva',
    details: 'Grupo adicionado: FileServer-Read',
    ipAddress: '187.45.123.88',
    status: 'success',
    taskId: 'task-003',
    agentResponse: '{"result":"success"}',
    createdAt: '2025-01-12T14:00:00Z',
  },
  {
    id: 'al4',
    tenantId: 't2',
    tenantName: 'Grupo Farmacêutico Vida',
    userId: 'u4',
    userName: 'Marcos Oliveira',
    action: 'user.disable',
    objectType: 'ADUser',
    objectId: 'adu-vida-22',
    objectName: 'Patricia Nunes',
    details: 'Conta inativada',
    ipAddress: '200.176.44.12',
    status: 'success',
    taskId: 'task-004',
    agentResponse: '{"result":"success"}',
    createdAt: '2025-01-13T16:20:00Z',
  },
  {
    id: 'al5',
    tenantId: 't3',
    tenantName: 'Logística Rápida Express',
    userId: 'u5',
    userName: 'Fernanda Costa',
    action: 'user.create',
    objectType: 'ADUser',
    objectId: 'adu-log-new',
    objectName: 'Thiago Ramos',
    details: 'Falha ao criar usuário: agente offline',
    ipAddress: '189.50.22.100',
    status: 'error',
    taskId: 'task-005',
    agentResponse: '{"result":"error","message":"Agent timeout"}',
    createdAt: '2025-01-14T08:45:00Z',
  },
  {
    id: 'al6',
    tenantId: null,
    tenantName: null,
    userId: 'u1',
    userName: 'Carlos Administrador',
    action: 'tenant.create',
    objectType: 'Tenant',
    objectId: 't5',
    objectName: 'TechSoft Sistemas',
    details: 'Novo tenant cadastrado',
    ipAddress: '201.30.55.8',
    status: 'success',
    taskId: null,
    agentResponse: null,
    createdAt: '2025-01-05T16:05:00Z',
  },
]

// ======================================
// AGENT TASKS
// ======================================
export const mockAgentTasks: AgentTask[] = [
  {
    id: 'task-001',
    tenantId: 't1',
    type: 'user.create',
    status: 'success',
    payload: { upn: 'carlos.medeiros@horizonte.local', firstName: 'Carlos', lastName: 'Medeiros' },
    result: { dn: 'CN=Carlos Medeiros,OU=Comercial,OU=Usuarios,DC=horizonte,DC=local' },
    errorMessage: null,
    createdBy: 'u2',
    createdAt: '2024-12-01T09:04:00Z',
    startedAt: '2024-12-01T09:04:30Z',
    completedAt: '2024-12-01T09:04:35Z',
  },
  {
    id: 'task-005',
    tenantId: 't3',
    type: 'user.create',
    status: 'error',
    payload: { upn: 'thiago.ramos@lograpida.net', firstName: 'Thiago', lastName: 'Ramos' },
    result: null,
    errorMessage: 'Agent timeout after 30s',
    createdBy: 'u5',
    createdAt: '2025-01-14T08:44:00Z',
    startedAt: null,
    completedAt: null,
  },
  {
    id: 'task-006',
    tenantId: 't1',
    type: 'sync.full',
    status: 'pending',
    payload: {},
    result: null,
    errorMessage: null,
    createdBy: 'system',
    createdAt: '2025-01-15T03:00:00Z',
    startedAt: null,
    completedAt: null,
  },
]

// ======================================
// SYNC STATUS
// ======================================
export const mockSyncStatus: SyncStatus[] = [
  {
    tenantId: 't1',
    tenantName: 'Construtora Horizonte S.A.',
    lastFullSync: '2025-01-15T03:00:00Z',
    lastPartialSync: '2025-01-15T12:00:00Z',
    syncStatus: 'idle',
    usersCount: 248,
    groupsCount: 32,
    errorMessage: null,
  },
  {
    tenantId: 't2',
    tenantName: 'Grupo Farmacêutico Vida',
    lastFullSync: '2025-01-15T03:00:00Z',
    lastPartialSync: '2025-01-15T13:30:00Z',
    syncStatus: 'idle',
    usersCount: 512,
    groupsCount: 64,
    errorMessage: null,
  },
  {
    tenantId: 't3',
    tenantName: 'Logística Rápida Express',
    lastFullSync: '2025-01-12T03:00:00Z',
    lastPartialSync: null,
    syncStatus: 'error',
    usersCount: 89,
    groupsCount: 14,
    errorMessage: 'Falha na sincronização: agente não respondeu',
  },
  {
    tenantId: 't4',
    tenantName: 'Advocacia Mello & Associados',
    lastFullSync: null,
    lastPartialSync: null,
    syncStatus: 'never',
    usersCount: 0,
    groupsCount: 0,
    errorMessage: 'Agente offline há mais de 48h',
  },
]

// ======================================
// DASHBOARD STATS
// ======================================
export const mockDashboardStats: DashboardStats = {
  totalTenants: 5,
  activeTenants: 4,
  totalPortalUsers: 5,
  agentsOnline: 2,
  agentsOffline: 2,
  tasksToday: 14,
  errorsToday: 2,
  pendingTasks: 1,
}

// ======================================
// POLICIES
// ======================================
export const mockPolicies: TenantPolicy[] = [
  {
    tenantId: 't1',
    mustChangePasswordOnFirstLogin: true,
    cannotChangePassword: false,
    passwordNeverExpires: false,
    accountStartsEnabled: true,
    operatorCanChooseMustChange: true,
    operatorCanChooseCannotChange: false,
    operatorCanChooseNeverExpires: true,
    operatorCanChooseEnabled: true,
  },
  {
    tenantId: 't2',
    mustChangePasswordOnFirstLogin: true,
    cannotChangePassword: false,
    passwordNeverExpires: false,
    accountStartsEnabled: false,
    operatorCanChooseMustChange: false,
    operatorCanChooseCannotChange: false,
    operatorCanChooseNeverExpires: false,
    operatorCanChooseEnabled: true,
  },
]
