/**
 * @license MIT
 * @copyright Copyright (c) 2026, GoldFrite
 */
import { EMLLibError, ErrorType } from '../../types/errors.js';
export default class Profile {
    /**
     * Get the profiles from the EML AdminTool.
     *
     * **Attention!** This class only works with EML AdminTool. Please do not use it without the it.
     * @param url The URL of your EML AdminTool website.
     */
    constructor(url) {
        this.url = `${url}/api`;
    }
    /**
     * Get the profiles from the EML AdminTool.
     * @returns The list of Profile objects.
     */
    async getProfiles() {
        try {
            const req = await fetch(`${this.url}/profiles`);
            if (!req.ok) {
                const errorText = await req.text();
                throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching profiles: HTTP ${req.status} ${errorText}`);
            }
            const data = await req.json();
            return data.profiles ?? [];
        }
        catch (err) {
            if (err instanceof EMLLibError)
                throw err;
            throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching profiles: ${err instanceof Error ? err.message : err}`);
        }
    }
}
//# sourceMappingURL=profiles.js.map