/**
 * Represents the results of a moderation request.
 * Can contain one or multiple results if multiple inputs were provided.
 */
export class Moderation {
    response;
    constructor(response) {
        this.response = response;
    }
    get id() {
        return this.response.id;
    }
    get model() {
        return this.response.model;
    }
    /**
     * Returns all results as ModerationItem instances
     */
    get results() {
        return this.response.results.map((r) => new ModerationItem(r));
    }
    /**
     * Returns the number of results
     */
    get length() {
        return this.response.results.length;
    }
    /**
     * Returns true if any of the results are flagged
     */
    get flagged() {
        return this.response.results.some((r) => r.flagged);
    }
    /**
     * Aggregates all flagged categories across all results
     */
    get flaggedCategories() {
        const all = new Set();
        for (const item of this.results) {
            item.flaggedCategories.forEach((cat) => all.add(cat));
        }
        return Array.from(all);
    }
    /**
     * Returns categories for the first result (most common case)
     */
    get categories() {
        return this.results[0]?.categories || {};
    }
    /**
     * Returns category scores for the first result
     */
    get categoryScores() {
        return this.results[0]?.categoryScores || {};
    }
    // --- Ruby-compatible aliases ---
    get flagged_categories() {
        return this.flaggedCategories;
    }
    get category_scores() {
        return this.categoryScores;
    }
    isFlagged() {
        return this.flagged;
    }
    /**
     * Makes the Moderation object iterable (yields results)
     */
    *[Symbol.iterator]() {
        for (const item of this.results) {
            yield item;
        }
    }
}
/**
 * Represents a single result within a moderation request
 */
export class ModerationItem {
    raw;
    constructor(raw) {
        this.raw = raw;
    }
    get flagged() {
        return this.raw.flagged;
    }
    get categories() {
        return this.raw.categories;
    }
    get categoryScores() {
        return this.raw.category_scores;
    }
    get flaggedCategories() {
        return Object.keys(this.categories).filter((cat) => this.categories[cat]);
    }
    // --- Ruby-compatible aliases ---
    get flagged_categories() {
        return this.flaggedCategories;
    }
    get category_scores() {
        return this.categoryScores;
    }
}
