/**
 * iMessage/BlueBubbles Channel Adapter
 *
 * Connects to a BlueBubbles server to send/receive iMessages.
 * This is a stub implementation that manages internal state
 * without making real connections.
 */
import { logger } from '../../utils/logger.js';
export class IMessageAdapter {
    config;
    running = false;
    constructor(config) {
        this.config = { ...config };
        if (this.config.port === undefined) {
            this.config.port = 1234;
        }
    }
    async start() {
        if (this.running) {
            throw new Error('IMessageAdapter is already running');
        }
        logger.debug('IMessageAdapter: connecting to BlueBubbles server', {
            serverUrl: this.config.serverUrl,
            port: this.config.port,
        });
        this.running = true;
    }
    async stop() {
        if (!this.running) {
            throw new Error('IMessageAdapter is not running');
        }
        logger.debug('IMessageAdapter: disconnecting');
        this.running = false;
    }
    isRunning() {
        return this.running;
    }
    async sendMessage(chatId, text) {
        if (!this.running) {
            throw new Error('IMessageAdapter is not running');
        }
        logger.debug('IMessageAdapter: sending message', { chatId, textLength: text.length });
        return { success: true, messageId: `imsg_${Date.now()}` };
    }
    async sendReaction(chatId, messageId, reaction) {
        if (!this.running) {
            throw new Error('IMessageAdapter is not running');
        }
        logger.debug('IMessageAdapter: sending reaction', { chatId, messageId, reaction });
        return { success: true };
    }
    async getChats() {
        if (!this.running) {
            throw new Error('IMessageAdapter is not running');
        }
        return [];
    }
    async getMessages(chatId, limit) {
        if (!this.running) {
            throw new Error('IMessageAdapter is not running');
        }
        return [];
    }
    getConfig() {
        return { ...this.config };
    }
}
export default IMessageAdapter;
//# sourceMappingURL=index.js.map