/**
 * @license MIT
 * @copyright Copyright (c) 2026, GoldFrite
 */
import { EMLLibError, ErrorType } from '../../types/errors.js';
export default class Maintenance {
    /**
     * @param url The URL of your EML AdminTool website.
     */
    constructor(url) {
        this.url = `${url}/api`;
    }
    /**
     * Manage the Maintenance of the Launcher.
     *
     * **Attention!** This class only works with EML AdminTool. Please do not use it without the it.
     * Get the current Maintenance status from the EML AdminTool.
     * @returns `null` if there is no maintenance, otherwise it will return the maintenance status.
     * You can check the `startTime` and `endTime` properties to see if the maintenance is active.
     */
    async getMaintenance() {
        try {
            const req = await fetch(`${this.url}/maintenance`);
            if (!req.ok) {
                const errorText = await req.text();
                throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching maintenance status: HTTP ${req.status} ${errorText}`);
            }
            const data = await req.json();
            if (data.startTime)
                return data;
            else
                return null;
        }
        catch (err) {
            if (err instanceof EMLLibError)
                throw err;
            throw new EMLLibError(ErrorType.FETCH_ERROR, `Error while fetching maintenance status: ${err instanceof Error ? err.message : err}`);
        }
    }
}
//# sourceMappingURL=maintenance.js.map