'use server';
import { resolve } from '../../lib/server-container.js';
import { GitHubAuthError } from '../../../../../packages/core/src/application/ports/output/services/github-repository-service.interface.js';
export async function listGitHubOrganizations() {
    try {
        const useCase = resolve('ListGitHubOrganizationsUseCase');
        const orgs = await useCase.execute();
        return { orgs };
    }
    catch (error) {
        if (error instanceof GitHubAuthError) {
            return { error: 'GitHub CLI is not authenticated. Run `gh auth login` to sign in.' };
        }
        const message = error instanceof Error ? error.message : 'Failed to list organizations';
        return { error: message };
    }
}
