import type { RuntimePlatform } from './platform-detection.rules';

/** Lazily loads a Capacitor-only adapter while keeping web/electron shells on the web fallback. */
export async function resolveMobileAdapter<TWeb, TCapacitor>(
  runtime: RuntimePlatform,
  webAdapter: TWeb,
  loadCapacitorAdapter: () => Promise<TCapacitor>
): Promise<TWeb | TCapacitor> {
  if (runtime !== 'capacitor') {
    return webAdapter;
  }

  return loadCapacitorAdapter();
}
