/**
 * This file contains the class Frontend.
 *
 * @file frontend.ts
 * @author Luca Liguori
 * @date 2025-01-13
 * @version 1.0.2
 *
 * Copyright 2025, 2026, 2027 Luca Liguori.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. *
 */
import { LogLevel } from './logger/export.js';
import { Matterbridge } from './matterbridge.js';
/**
 * Websocket message ID for logging.
 * @constant {number}
 */
export declare const WS_ID_LOG = 0;
/**
 * Websocket message ID indicating a refresh is needed.
 * @constant {number}
 */
export declare const WS_ID_REFRESH_NEEDED = 1;
/**
 * Websocket message ID indicating a restart is needed.
 * @constant {number}
 */
export declare const WS_ID_RESTART_NEEDED = 2;
/**
 * Websocket message ID indicating a cpu update.
 * @constant {number}
 */
export declare const WS_ID_CPU_UPDATE = 3;
/**
 * Websocket message ID indicating a memory update.
 * @constant {number}
 */
export declare const WS_ID_MEMORY_UPDATE = 4;
/**
 * Websocket message ID indicating an uptime update.
 * @constant {number}
 */
export declare const WS_ID_UPTIME_UPDATE = 5;
/**
 * Websocket message ID indicating a snackbar message.
 * @constant {number}
 */
export declare const WS_ID_SNACKBAR = 6;
/**
 * Websocket message ID indicating matterbridge has un update available.
 * @constant {number}
 */
export declare const WS_ID_UPDATE_NEEDED = 7;
/**
 * Websocket message ID indicating a state update.
 * @constant {number}
 */
export declare const WS_ID_STATEUPDATE = 8;
/**
 * Websocket message ID indicating a shelly system update.
 * check:
 * curl -k http://127.0.0.1:8101/api/updates/sys/check
 * perform:
 * curl -k http://127.0.0.1:8101/api/updates/sys/perform
 * @constant {number}
 */
export declare const WS_ID_SHELLY_SYS_UPDATE = 100;
/**
 * Websocket message ID indicating a shelly main update.
 * check:
 * curl -k http://127.0.0.1:8101/api/updates/main/check
 * perform:
 * curl -k http://127.0.0.1:8101/api/updates/main/perform
 * @constant {number}
 */
export declare const WS_ID_SHELLY_MAIN_UPDATE = 101;
export declare class Frontend {
    private matterbridge;
    private log;
    private port;
    private initializeError;
    private expressApp;
    private httpServer;
    private httpsServer;
    private webSocketServer;
    private prevCpus;
    private lastCpuUsage;
    private memoryData;
    private memoryInterval?;
    private memoryTimeout?;
    constructor(matterbridge: Matterbridge);
    set logLevel(logLevel: LogLevel);
    start(port?: number): Promise<void>;
    stop(): Promise<void>;
    private formatMemoryUsage;
    private formatOsUpTime;
    /**
     * Retrieves the api settings data.
     * @returns {Promise<object>} A promise that resolve in the api settings object.
     */
    private getApiSettings;
    /**
     * Retrieves the reachable attribute.
     * @param {MatterbridgeDevice} device - The MatterbridgeDevice object.
     * @returns {boolean} The reachable attribute.
     */
    private getReachability;
    /**
     * Retrieves the cluster text description from a given device.
     * @param {MatterbridgeDevice} device - The MatterbridgeDevice object.
     * @returns {string} The attributes description of the cluster servers in the device.
     */
    private getClusterTextFromDevice;
    /**
     * Retrieves the base registered plugins sanitized for res.json().
     * @returns {BaseRegisteredPlugin[]} An array of BaseRegisteredPlugin.
     */
    private getBaseRegisteredPlugins;
    /**
     * Handles incoming websocket messages for the Matterbridge frontend.
     *
     * @param {WebSocket} client - The websocket client that sent the message.
     * @param {WebSocket.RawData} message - The raw data of the message received from the client.
     * @returns {Promise<void>} A promise that resolves when the message has been handled.
     */
    private wsMessageHandler;
    /**
     * Sends a WebSocket message to all connected clients. The function is called by AnsiLogger.setGlobalCallback.
     *
     * @param {string} level - The logger level of the message: debug info notice warn error fatal...
     * @param {string} time - The time string of the message
     * @param {string} name - The logger name of the message
     * @param {string} message - The content of the message.
     */
    wssSendMessage(level: string, time: string, name: string, message: string): void;
    /**
     * Sends a need to refresh WebSocket message to all connected clients.
     *
     * @param {string} changed - The changed value. If null, the whole page will be refreshed.
     * possible values:
     * - 'matterbridgeLatestVersion'
     * - 'matterbridgeAdvertise'
     * - 'online'
     * - 'offline'
     * - 'reachability'
     * - 'settings'
     * - 'plugins'
     * - 'devices'
     * - 'fabrics'
     * - 'sessions'
     */
    wssSendRefreshRequired(changed?: string | null): void;
    /**
     * Sends a need to restart WebSocket message to all connected clients.
     *
     */
    wssSendRestartRequired(snackbar?: boolean): void;
    /**
     * Sends a need to update WebSocket message to all connected clients.
     *
     */
    wssSendUpdateRequired(): void;
    /**
     * Sends a memory update message to all connected clients.
     *
     */
    wssSendCpuUpdate(cpuUsage: number): void;
    /**
     * Sends a cpu update message to all connected clients.
     *
     */
    wssSendMemoryUpdate(totalMemory: string, freeMemory: string, rss: string, heapTotal: string, heapUsed: string, external: string, arrayBuffers: string): void;
    /**
     * Sends a memory update message to all connected clients.
     *
     */
    wssSendUptimeUpdate(systemUptime: string, processUptime: string): void;
    /**
     * Sends a cpu update message to all connected clients.
     * @param {string} message - The message to send.
     * @param {number} timeout - The timeout in seconds for the snackbar message.
     * @param {'info' | 'warning' | 'error' | 'success'} severity - The severity of the snackbar message (default info).
     *
     */
    wssSendSnackbarMessage(message: string, timeout?: number, severity?: 'info' | 'warning' | 'error' | 'success'): void;
    /**
     * Sends an attribute update message to all connected WebSocket clients.
     *
     * @param {string | undefined} plugin - The name of the plugin.
     * @param {string | undefined} serialNumber - The serial number of the device.
     * @param {string | undefined} uniqueId - The unique identifier of the device.
     * @param {string} cluster - The cluster name where the attribute belongs.
     * @param {string} attribute - The name of the attribute that changed.
     * @param {number | string | boolean} value - The new value of the attribute.
     *
     * @remarks
     * This method logs a debug message and sends a JSON-formatted message to all connected WebSocket clients
     * with the updated attribute information.
     */
    wssSendAttributeChangedMessage(plugin: string | undefined, serialNumber: string | undefined, uniqueId: string | undefined, cluster: string, attribute: string, value: number | string | boolean): void;
    /**
     * Sends a message to all connected clients.
     * @param {number} id - The message id.
     * @param {string} method - The message method.
     * @param {Record<string, string | number | boolean>} params - The message parameters.
     *
     */
    wssBroadcastMessage(id: number, method?: string, params?: Record<string, string | number | boolean>): void;
}
//# sourceMappingURL=frontend.d.ts.map