/**
 * Server Container Accessor
 *
 * Provides a `resolve()` helper for server components and API routes to
 * obtain DI-managed instances. The tsyringe container is placed on globalThis
 * by the CLI bootstrap (`shep ui`) or the dev-server (`pnpm dev:web`).
 */
const CONTAINER_KEY = '__shepContainer';
/**
 * Resolve a dependency from the DI container.
 *
 * Usage in server components / API routes:
 * ```ts
 * import { resolve } from './server-container.js';
 * import { ListFeaturesUseCase } from '../../../../packages/core/src/application/use-cases/features/list-features.use-case.js';
 *
 * const features = await resolve(ListFeaturesUseCase).execute();
 * ```
 */
export function resolve(token) {
    const container = globalThis[CONTAINER_KEY];
    if (!container) {
        throw new Error('DI container not available. Ensure the CLI bootstrap or dev-server has initialized it.');
    }
    return container.resolve(token);
}
