/**
 * Nextcloud Talk Channel Adapter
 *
 * Connects to Nextcloud Talk for messaging and room management.
 * This is a stub implementation.
 */
import { logger } from '../../utils/logger.js';
export class NextcloudTalkAdapter {
    config;
    running = false;
    joinedRooms = new Set();
    constructor(config) {
        this.config = { ...config };
    }
    async start() {
        if (this.running) {
            throw new Error('NextcloudTalkAdapter is already running');
        }
        logger.debug('NextcloudTalkAdapter: connecting', { url: this.config.url, username: this.config.username });
        this.running = true;
    }
    async stop() {
        if (!this.running) {
            throw new Error('NextcloudTalkAdapter is not running');
        }
        logger.debug('NextcloudTalkAdapter: disconnecting');
        this.joinedRooms.clear();
        this.running = false;
    }
    isRunning() {
        return this.running;
    }
    async sendMessage(roomToken, text) {
        if (!this.running) {
            throw new Error('NextcloudTalkAdapter is not running');
        }
        logger.debug('NextcloudTalkAdapter: sending message', { roomToken, textLength: text.length });
        return { success: true, messageId: `nc_${Date.now()}` };
    }
    async getRooms() {
        if (!this.running) {
            throw new Error('NextcloudTalkAdapter is not running');
        }
        return [];
    }
    async joinRoom(roomToken) {
        if (!this.running) {
            throw new Error('NextcloudTalkAdapter is not running');
        }
        this.joinedRooms.add(roomToken);
        logger.debug('NextcloudTalkAdapter: joined room', { roomToken });
        return { success: true };
    }
    async leaveRoom(roomToken) {
        if (!this.running) {
            throw new Error('NextcloudTalkAdapter is not running');
        }
        const existed = this.joinedRooms.delete(roomToken);
        logger.debug('NextcloudTalkAdapter: left room', { roomToken, existed });
        return { success: existed };
    }
    getConfig() {
        return { ...this.config };
    }
}
export default NextcloudTalkAdapter;
//# sourceMappingURL=index.js.map