/**
 * ListSupervisorPoliciesUseCase
 *
 * Returns every persisted {@link SupervisorPolicy} grouped by scope kind
 * (global/app/repo/feature). Powers the top-level /supervisor dashboard
 * (FR-31). Read-only — no DB writes.
 *
 * Per-scope auth is still enforced by the underlying repository; this
 * use case is a flat read intended for the operator-facing dashboard,
 * not for cross-tenant data exfiltration. Callers MUST gate the route
 * on the same feature flag (`collaboration`) used elsewhere in this
 * spec to avoid accidentally exposing the surface (NFR-14).
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe';
let ListSupervisorPoliciesUseCase = class ListSupervisorPoliciesUseCase {
    policyRepository;
    constructor(policyRepository) {
        this.policyRepository = policyRepository;
    }
    async execute() {
        const policies = await this.policyRepository.listAll();
        const byScope = { global: [], app: [], repo: [], feature: [] };
        for (const policy of policies) {
            if (policy.featureId) {
                byScope.feature.push(policy);
                continue;
            }
            if (policy.scopeType === 'global')
                byScope.global.push(policy);
            else if (policy.scopeType === 'app')
                byScope.app.push(policy);
            else if (policy.scopeType === 'repo')
                byScope.repo.push(policy);
        }
        return { policies, byScope, total: policies.length };
    }
};
ListSupervisorPoliciesUseCase = __decorate([
    injectable(),
    __param(0, inject('ISupervisorPolicyRepository')),
    __metadata("design:paramtypes", [Object])
], ListSupervisorPoliciesUseCase);
export { ListSupervisorPoliciesUseCase };
