import * as icon from '@mdi/js';
import { MenuAsideItem } from './interfaces';

const resolveMenuIcon = (name: string) => (
  name in icon ? (icon[name as keyof typeof icon] as string) : icon.mdiViewDashboardOutline
);

const menuAside: MenuAsideItem[] = [
  {
    icon: resolveMenuIcon('mdiOrbitVariant'),
    label: 'VORTA Universe',
    menu: [
      {
        href: '/vorta-universe#vorta-overview',
        icon: resolveMenuIcon('mdiViewDashboardOutline'),
        label: 'Dashboard',
      },
      {
        href: '/vorta-universe#vorta-auth',
        icon: resolveMenuIcon('mdiShieldKeyOutline'),
        label: 'Login & OTP',
      },
      {
        href: '/vorta-universe#vorta-modules',
        icon: resolveMenuIcon('mdiApps'),
        label: 'Modules',
      },
      {
        href: '/vorta-feed',
        icon: resolveMenuIcon('mdiPostOutline'),
        label: 'VORTA Feed',
      },
      {
        href: '/vorta-universe#vorta-social',
        icon: resolveMenuIcon('mdiPostOutline'),
        label: 'Feed Bisnis Dashboard',
      },
      {
        href: '/vorta-universe#vorta-marketplace',
        icon: resolveMenuIcon('mdiStorefrontOutline'),
        label: 'Marketplace',
      },
      {
        href: '/vorta-universe#vorta-settings',
        icon: resolveMenuIcon('mdiCogOutline'),
        label: 'Settings',
      },
      {
        href: '/trust_profiles/trust_profiles-list',
        icon: resolveMenuIcon('mdiShieldCheck'),
        label: 'Nexus Score Entity',
        permissions: 'READ_TRUST_PROFILES',
      },
      {
        href: '/wallets/wallets-list',
        icon: resolveMenuIcon('mdiWallet'),
        label: 'Wallet Entity',
        permissions: 'READ_WALLETS',
      },
      {
        href: '/products/products-list',
        icon: resolveMenuIcon('mdiPackageVariantClosed'),
        label: 'Products Entity',
        permissions: 'READ_PRODUCTS',
      },
    ],
  },

  {
    href: '/vorta-commerce',
    icon: resolveMenuIcon('mdiStorefrontOutline'),
    label: '1. VORTA Commerce',
  },
  {
    href: '/vorta-synapse',
    label: '2. Vorta Synapse',
    icon: resolveMenuIcon('mdiTransitConnectionVariant'),
  },
  {
    href: '/mega-super-app',
    label: '3. Mega Super-App',
    icon: resolveMenuIcon('mdiApps'),
  },
  {
    href: '/vorta-universe#vorta-overview',
    label: '4. Vorta Nexus',
    icon: resolveMenuIcon('mdiShieldCheck'),
  },
  {
    href: '/facta_queries/facta_queries-list',
    label: '5. Facta.Ai',
    icon: resolveMenuIcon('mdiShieldSearchOutline'),
    permissions: 'READ_FACTA_QUERIES',
  },

  {
    href: '/users/users-list',
    label: 'Pengguna',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon: icon.mdiAccountGroup ?? icon.mdiTable,
    permissions: 'READ_USERS',
  },
  {
    href: '/roles/roles-list',
    label: 'Peran',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon: icon.mdiShieldAccountVariantOutline ?? icon.mdiTable,
    permissions: 'READ_ROLES',
  },
  {
    href: '/permissions/permissions-list',
    label: 'Izin Akses',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon: icon.mdiShieldAccountOutline ?? icon.mdiTable,
    permissions: 'READ_PERMISSIONS',
  },
  {
    href: '/organizations/organizations-list',
    label: 'Organisasi',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon: icon.mdiTable ?? icon.mdiTable,
    permissions: 'READ_ORGANIZATIONS',
  },
  {
    href: '/trust_profiles/trust_profiles-list',
    label: 'Profil Kepercayaan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiShieldCheck' in icon
        ? icon['mdiShieldCheck' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_TRUST_PROFILES',
  },
  {
    href: '/identity_verifications/identity_verifications-list',
    label: 'Verifikasi Identitas',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiCardAccountDetailsOutline' in icon
        ? icon['mdiCardAccountDetailsOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_IDENTITY_VERIFICATIONS',
  },
  {
    href: '/wallets/wallets-list',
    label: 'Dompet',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiWallet' in icon
        ? icon['mdiWallet' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_WALLETS',
  },
  {
    href: '/wallet_transactions/wallet_transactions-list',
    label: 'Transaksi Dompet',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiSwapHorizontal' in icon
        ? icon['mdiSwapHorizontal' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_WALLET_TRANSACTIONS',
  },
  {
    href: '/chats/chats-list',
    label: 'Percakapan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiChat' in icon
        ? icon['mdiChat' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_CHATS',
  },
  {
    href: '/chat_participants/chat_participants-list',
    label: 'Peserta Percakapan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiAccountGroup' in icon
        ? icon['mdiAccountGroup' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_CHAT_PARTICIPANTS',
  },
  {
    href: '/messages/messages-list',
    label: 'Pesan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiMessageTextOutline' in icon
        ? icon['mdiMessageTextOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_MESSAGES',
  },
  {
    href: '/stores/stores-list',
    label: 'Toko',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiStore' in icon
        ? icon['mdiStore' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_STORES',
  },
  {
    href: '/addresses/addresses-list',
    label: 'Alamat',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiMapMarker' in icon
        ? icon['mdiMapMarker' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_ADDRESSES',
  },
  {
    href: '/product_categories/product_categories-list',
    label: 'Kategori Produk',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiShapeOutline' in icon
        ? icon['mdiShapeOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_PRODUCT_CATEGORIES',
  },
  {
    href: '/products/products-list',
    label: 'Produk',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiPackageVariantClosed' in icon
        ? icon['mdiPackageVariantClosed' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_PRODUCTS',
  },
  {
    href: '/orders/orders-list',
    label: 'Pesanan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiReceiptTextOutline' in icon
        ? icon['mdiReceiptTextOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_ORDERS',
  },
  {
    href: '/order_items/order_items-list',
    label: 'Item Pesanan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiFormatListBulleted' in icon
        ? icon['mdiFormatListBulleted' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_ORDER_ITEMS',
  },
  {
    href: '/payments/payments-list',
    label: 'Pembayaran',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiCreditCardOutline' in icon
        ? icon['mdiCreditCardOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_PAYMENTS',
  },
  {
    href: '/product_reviews/product_reviews-list',
    label: 'Ulasan Produk',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiStarCircleOutline' in icon
        ? icon['mdiStarCircleOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_PRODUCT_REVIEWS',
  },
  {
    href: '/shipments/shipments-list',
    label: 'Pengiriman',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiTruckDeliveryOutline' in icon
        ? icon['mdiTruckDeliveryOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_SHIPMENTS',
  },
  {
    href: '/posts/posts-list',
    label: 'Postingan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiPlayCircleOutline' in icon
        ? icon['mdiPlayCircleOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_POSTS',
  },
  {
    href: '/deep_dive_links/deep_dive_links-list',
    label: 'Tautan Deep Dive',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiLinkVariant' in icon
        ? icon['mdiLinkVariant' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_DEEP_DIVE_LINKS',
  },
  {
    href: '/citations/citations-list',
    label: 'Sitasi',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiFileDocumentCheckOutline' in icon
        ? icon['mdiFileDocumentCheckOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_CITATIONS',
  },
  {
    href: '/post_engagements/post_engagements-list',
    label: 'Interaksi Postingan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiThumbUpOutline' in icon
        ? icon['mdiThumbUpOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_POST_ENGAGEMENTS',
  },
  {
    href: '/rewards/rewards-list',
    label: 'Hadiah',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiTrophyOutline' in icon
        ? icon['mdiTrophyOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_REWARDS',
  },
  {
    href: '/forum_spaces/forum_spaces-list',
    label: 'Ruang Forum',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiForumOutline' in icon
        ? icon['mdiForumOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_FORUM_SPACES',
  },
  {
    href: '/forum_threads/forum_threads-list',
    label: 'Topik Forum',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiMessageBulleted' in icon
        ? icon['mdiMessageBulleted' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_FORUM_THREADS',
  },
  {
    href: '/forum_posts/forum_posts-list',
    label: 'Posting Forum',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiReplyOutline' in icon
        ? icon['mdiReplyOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_FORUM_POSTS',
  },
  {
    href: '/job_companies/job_companies-list',
    label: 'Perusahaan Lowongan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiOfficeBuildingOutline' in icon
        ? icon['mdiOfficeBuildingOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_JOB_COMPANIES',
  },
  {
    href: '/job_listings/job_listings-list',
    label: 'Daftar Lowongan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiBriefcaseOutline' in icon
        ? icon['mdiBriefcaseOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_JOB_LISTINGS',
  },
  {
    href: '/job_applications/job_applications-list',
    label: 'Lamaran Kerja',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiFileAccountOutline' in icon
        ? icon['mdiFileAccountOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_JOB_APPLICATIONS',
  },
  {
    href: '/user_credentials/user_credentials-list',
    label: 'Kredensial Pengguna',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiCertificateOutline' in icon
        ? icon['mdiCertificateOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_USER_CREDENTIALS',
  },
  {
    href: '/affiliate_programs/affiliate_programs-list',
    label: 'Program Afiliasi',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiAccountNetworkOutline' in icon
        ? icon['mdiAccountNetworkOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_AFFILIATE_PROGRAMS',
  },
  {
    href: '/affiliate_memberships/affiliate_memberships-list',
    label: 'Keanggotaan Afiliasi',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiLinkBoxOutline' in icon
        ? icon['mdiLinkBoxOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_AFFILIATE_MEMBERSHIPS',
  },
  {
    href: '/commissions/commissions-list',
    label: 'Komisi',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiCashCheck' in icon
        ? icon['mdiCashCheck' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_COMMISSIONS',
  },
  {
    href: '/geo_rules/geo_rules-list',
    label: 'Aturan Geo',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiMapMarkerRadiusOutline' in icon
        ? icon['mdiMapMarkerRadiusOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_GEO_RULES',
  },
  {
    href: '/facta_queries/facta_queries-list',
    label: 'Facta.Ai Kueri',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiMagnify' in icon
        ? icon['mdiMagnify' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_FACTA_QUERIES',
  },
  {
    href: '/facta_answers/facta_answers-list',
    label: 'Facta.Ai Jawaban',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiShieldSearchOutline' in icon
        ? icon['mdiShieldSearchOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_FACTA_ANSWERS',
  },
  {
    href: '/subscriptions/subscriptions-list',
    label: 'Langganan',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiCrownOutline' in icon
        ? icon['mdiCrownOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_SUBSCRIPTIONS',
  },
  {
    href: '/api_clients/api_clients-list',
    label: 'Klien API',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiApi' in icon
        ? icon['mdiApi' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_API_CLIENTS',
  },
  {
    href: '/audit_events/audit_events-list',
    label: 'Peristiwa Audit',
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    icon:
      'mdiClipboardTextOutline' in icon
        ? icon['mdiClipboardTextOutline' as keyof typeof icon]
        : (icon.mdiTable ?? icon.mdiTable),
    permissions: 'READ_AUDIT_EVENTS',
  },
  {
    href: '/profile',
    label: 'Profil',
    icon: icon.mdiAccountCircle,
  },

  {
    href: '/api-docs',
    target: '_blank',
    label: 'Dokumentasi API',
    icon: icon.mdiFileCode,
    permissions: 'READ_API_DOCS',
  },
];

export default menuAside;
