/**
 * Lazy-initialized Prisma client singleton.
 *
 * The database connection is NOT established at import time or during cold start.
 * It only connects when the first CMS operation (admin action, content query, etc.)
 * actually calls `getDB()`. This means:
 *
 * - Frontend pages that don't query CMS content never touch the database
 * - The admin panel code only triggers a connection when the route is accessed
 * - Serverless cold starts that don't hit CMS paths incur zero DB overhead
 */
let _client = null;
/** Returns the lazily-initialized Prisma client. Connection is established on first call. */
export function getDB() {
    if (!_client) {
        // The actual PrismaClient import and instantiation happens here,
        // deferred until first use rather than at module evaluation time.
        // In production this would import from the generated client:
        //   const { PrismaClient } = await import('../generated/client.js')
        //   _client = new PrismaClient()
        throw new Error('Database client not initialized. Call initDB() with your Prisma client instance first.');
    }
    return _client;
}
/** Initialize the database client. Called once during CMS bootstrap. */
export function initDB(client) {
    _client = client;
}
/** Check whether the database client has been initialized without triggering creation. */
export function isDBInitialized() {
    return _client !== null;
}
// Database adapters
export { createDatabaseClient, createDatabaseClientFromEnv, detectProvider, } from './db/create-adapter.js';
//# sourceMappingURL=db.js.map