/**
 * @license MIT
 * @copyright Copyright (c) 2026, GoldFrite
 */
import { EMLLibError, ErrorType } from '../../types/errors.js';
export default class Background {
    /**
     * Manage the background of the Launcher.
     *
     * **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 current background from the EML AdminTool.
     * @returns The current Background object, or `null` if no background is set.
     */
    async getBackground() {
        try {
            const req = await fetch(`${this.url}/background`);
            if (!req.ok) {
                const errorText = await req.text();
                throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching background: HTTP ${req.status} ${errorText}`);
            }
            const data = await req.json();
            return data ?? null;
        }
        catch (err) {
            if (err instanceof EMLLibError)
                throw err;
            throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching background: ${err instanceof Error ? err.message : err}`);
        }
    }
}
//# sourceMappingURL=background.js.map