import { jsx as _jsx } from "react/jsx-runtime";
import { resolve } from '../../../../../lib/server-container.js';
import { WorkItemDetailClient } from './work-item-detail-client.js';
export const dynamic = 'force-dynamic';
export default async function WorkItemDetailPage({ params }) {
    const { slug, itemId } = await params;
    const projectUseCase = resolve('GetPmProjectUseCase');
    const projectResult = await projectUseCase.execute(slug);
    if (!projectResult.ok) {
        return (_jsx("div", { className: "flex h-full items-center justify-center p-6", children: _jsx("p", { className: "text-muted-foreground text-sm", children: projectResult.error }) }));
    }
    const project = projectResult.project;
    const getWorkItem = resolve('GetWorkItemUseCase');
    const workItemResult = await getWorkItem.execute(itemId);
    if (!workItemResult.ok) {
        return (_jsx("div", { className: "flex h-full items-center justify-center p-6", children: _jsx("p", { className: "text-muted-foreground text-sm", children: workItemResult.error }) }));
    }
    const workItem = workItemResult.workItem;
    const [allWorkItems, states, relationsResult, attachmentsResult, timeEntriesResult] = await Promise.all([
        resolve('ListWorkItemsUseCase').execute(project.id),
        resolve('ManageWorkItemStatesUseCase').list(project.id),
        resolve('ListWorkItemRelationsUseCase').execute(workItem.id),
        resolve('ListAttachmentsUseCase').execute(workItem.id),
        resolve('ListTimeEntriesUseCase').execute(workItem.id),
    ]);
    return (_jsx("div", { className: "flex h-full flex-col p-6", children: _jsx(WorkItemDetailClient, { project: project, workItem: workItem, allWorkItems: allWorkItems, states: states, relations: relationsResult, attachments: attachmentsResult.attachments, timeEntries: timeEntriesResult.timeEntries, totalMinutes: timeEntriesResult.totalMinutes }) }));
}
