import { loadIpsasRegistryPath } from './omnl-ipsas-gl';
import { loadJournalMatrixPath } from './omnl-journal-matrix';
import { omnlComplianceCore138, omnlReserveStore138 } from './omnl-chain138-addresses';

/** Non-secret snapshot of which OMNL integrations are configured (for probes and dashboards). */
export function getOmnlIntegrationStatus(): Record<string, unknown> {
  return {
    fineract: Boolean(
      (process.env.OMNL_FINERACT_BASE_URL || '').trim() && (process.env.OMNL_FINERACT_PASSWORD || '').trim()
    ),
    complianceCore138: Boolean(omnlComplianceCore138()),
    complianceCoreV2_138: Boolean((process.env.OMNL_COMPLIANCE_CORE_V2_138 || '').trim()),
    complianceCore651940: Boolean((process.env.OMNL_COMPLIANCE_CORE_651940 || '').trim()),
    instrumentRegistry138: Boolean(
      (process.env.OMNL_INSTRUMENT_REGISTRY_138 || process.env.OMNL_INSTRUMENT_REGISTRY || '').trim()
    ),
    reserveStore138: Boolean(omnlReserveStore138()),
    reserveStoreV2_138: Boolean((process.env.OMNL_RESERVE_STORE_V2_138 || '').trim()),
    reserveStore651940: Boolean((process.env.OMNL_RESERVE_STORE_651940 || '').trim()),
    circuitBreaker138: Boolean((process.env.OMNL_CIRCUIT_BREAKER_138 || '').trim()),
    circuitBreaker651940: Boolean((process.env.OMNL_CIRCUIT_BREAKER_651940 || '').trim()),
    mirrorCoordinator138: Boolean(
      (process.env.OMNL_MIRROR_COORDINATOR_138 || process.env.OMNL_MIRROR_COORDINATOR || '').trim()
    ),
    zkVerifierConfigured: Boolean((process.env.OMNL_ZK_VERIFIER || '').trim()),
    webhooksConfigured: Boolean((process.env.OMNL_WEBHOOK_URLS || '').trim()),
    eventPollerEnabled: ['1', 'true', 'yes', 'on'].includes(
      (process.env.ENABLE_OMNL_EVENT_POLLER || '').trim().toLowerCase()
    ),
    apiKeyRequiredRoutes: Boolean((process.env.OMNL_API_KEY || '').trim()),
    ipsasRegistryPath: loadIpsasRegistryPath(),
    journalMatrixPath: loadJournalMatrixPath(),
  };
}
