/**
 * @djangocfg/api - Pre-configured API Clients
 *
 * Ready-to-use API instances for accounts, webpush, and centrifugo.
 *
 * Usage:
 *   import { apiAccounts, apiWebPush, apiCentrifugo } from '@djangocfg/api/clients';
 *   import { useAccountsOauthGithubCallbackCreate } from '@djangocfg/api/clients';
 */

import { API as AccountsAPIClass, LocalStorageAdapter } from './generated/cfg_accounts';
import { API as CentrifugoAPIClass } from './generated/cfg_centrifugo';
import { API as TotpAPIClass } from './generated/cfg_totp';
import { API as WebPushAPIClass } from './generated/cfg_webpush';

// ============================================================================
// Pre-configured API instances (for hooks and direct usage)
// ============================================================================
const isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === 'true';
const apiUrl = isStaticBuild ? '' : process.env.NEXT_PUBLIC_API_URL || '';
const storage = new LocalStorageAdapter();

export const apiAccounts = new AccountsAPIClass(apiUrl, { storage });
export const apiTotp = new TotpAPIClass(apiUrl, { storage });
export const apiWebPush = new WebPushAPIClass(apiUrl, { storage });
export const apiCentrifugo = new CentrifugoAPIClass(apiUrl, { storage });

// ============================================================================
// Enums (re-export from accounts)
// ============================================================================
export * as Enums from './generated/cfg_accounts/enums';

// ============================================================================
// CFG Accounts (primary exports - includes shared types)
// ============================================================================
export * from './generated/cfg_accounts/_utils/hooks';
export * from './generated/cfg_accounts/_utils/fetchers';
export * from './generated/cfg_accounts/_utils/schemas';

// ============================================================================
// CFG WebPush (namespaced to avoid conflicts)
// ============================================================================
export * as WebPushHooks from './generated/cfg_webpush/_utils/hooks';
export * as WebPushFetchers from './generated/cfg_webpush/_utils/fetchers';
export * as WebPushTypes from './generated/cfg_webpush/_utils/schemas';

// ============================================================================
// CFG Centrifugo (namespaced to avoid conflicts)
// ============================================================================
export * as CentrifugoHooks from './generated/cfg_centrifugo/_utils/hooks';
export * as CentrifugoFetchers from './generated/cfg_centrifugo/_utils/fetchers';
export * as CentrifugoTypes from './generated/cfg_centrifugo/_utils/schemas';

// ============================================================================
// CFG TOTP (namespaced to avoid conflicts)
// ============================================================================
export * as TotpHooks from './generated/cfg_totp/_utils/hooks';
export * as TotpFetchers from './generated/cfg_totp/_utils/fetchers';
export * as TotpTypes from './generated/cfg_totp/_utils/schemas';

// ============================================================================
// API Classes (for creating custom instances)
// ============================================================================
export { API as AccountsAPI } from './generated/cfg_accounts';
export { API as TotpAPI } from './generated/cfg_totp';
export { API as WebPushAPI } from './generated/cfg_webpush';
export { API as CentrifugoAPI } from './generated/cfg_centrifugo';
