import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { notFound } from 'next/navigation';
import { resolve } from '../../../../lib/server-container.js';
import { getFeatureFlags } from '../../../../lib/feature-flags.js';
import { SupervisorConfigForm } from '../../../../components/supervisor/supervisor-config-form.js';
/** Skip static pre-rendering — the page resolves a runtime DI container. */
export const dynamic = 'force-dynamic';
/**
 * Per-feature supervisor override. The override is anchored to the feature's
 * parent repository scope when one exists, falling back to the global scope
 * (`scopeType=global`, no `scopeId`) for orphan features. The cascade
 * resolver still walks `feature → repo → app → global` when evaluating which
 * policy actually applies at runtime.
 */
export default async function FeatureSupervisorRoute({ params }) {
    const flags = getFeatureFlags();
    if (!flags.collaboration) {
        notFound();
    }
    const { featureId } = await params;
    const featureRepo = resolve('IFeatureRepository');
    const feature = await featureRepo.findById(featureId);
    if (!feature) {
        notFound();
    }
    const scopeType = feature.repositoryId ? 'repo' : 'global';
    const scopeId = feature.repositoryId;
    const useCase = resolve('GetSupervisorPolicyUseCase');
    const policy = await useCase.execute({ scopeType, scopeId, featureId });
    return (_jsxs("div", { className: "flex h-full flex-col gap-6 p-6", children: [_jsxs("header", { children: [_jsxs("h1", { className: "text-2xl font-semibold", children: ["Supervisor \u2014 ", feature.name] }), _jsxs("p", { className: "text-muted-foreground text-sm", children: ["Per-feature override. Falls back to the ", scopeType === 'repo' ? 'repository' : 'global', ' ', "policy when unset."] })] }), _jsx(SupervisorConfigForm, { scopeType: scopeType, scopeId: scopeId, featureId: featureId, initialPolicy: policy })] }));
}
