/**
 * Cross-Channel Message Tool
 *
 * Provides unified messaging operations (send, react, pin, thread, search,
 * role management, kick, ban) across all supported channels.
 */
import { logger } from '../utils/logger.js';
// ============================================================================
// MessageTool
// ============================================================================
export class MessageTool {
    static instance = null;
    actions = [];
    supportedChannels = ['telegram', 'discord', 'slack', 'whatsapp', 'signal', 'matrix', 'teams', 'webchat'];
    static getInstance() {
        if (!MessageTool.instance) {
            MessageTool.instance = new MessageTool();
        }
        return MessageTool.instance;
    }
    static resetInstance() {
        MessageTool.instance = null;
    }
    send(target, text) {
        logger.info(`Sending message to ${target.channel}/${target.chatId}: ${text.substring(0, 50)}`);
        const messageId = `msg-${Date.now()}`;
        this.actions.push({
            action: 'send',
            target,
            timestamp: Date.now(),
            details: { text },
        });
        return { success: true, action: 'send', messageId };
    }
    react(target, messageId, emoji) {
        logger.info(`Adding reaction ${emoji} to ${messageId} on ${target.channel}`);
        this.actions.push({
            action: 'react',
            target,
            timestamp: Date.now(),
            details: { messageId, emoji },
        });
        return { success: true, action: 'react', messageId };
    }
    pin(target, messageId) {
        logger.info(`Pinning message ${messageId} on ${target.channel}`);
        this.actions.push({
            action: 'pin',
            target,
            timestamp: Date.now(),
            details: { messageId },
        });
        return { success: true, action: 'pin', messageId };
    }
    threadCreate(target, messageId, text) {
        logger.info(`Creating thread on ${messageId} in ${target.channel}`);
        const threadId = `thread-${Date.now()}`;
        this.actions.push({
            action: 'thread_create',
            target,
            timestamp: Date.now(),
            details: { messageId, text },
        });
        return { success: true, action: 'thread_create', messageId: threadId };
    }
    search(target, query) {
        logger.info(`Searching messages in ${target.channel}/${target.chatId}: ${query}`);
        this.actions.push({
            action: 'search',
            target,
            timestamp: Date.now(),
            details: { query },
        });
        return { success: true, action: 'search' };
    }
    roleAdd(target, userId, role) {
        logger.info(`Adding role ${role} to ${userId} in ${target.channel}`);
        this.actions.push({
            action: 'role_add',
            target,
            timestamp: Date.now(),
            details: { userId, role },
        });
        return { success: true, action: 'role_add' };
    }
    kick(target, userId, reason) {
        logger.info(`Kicking ${userId} from ${target.channel}: ${reason || 'no reason'}`);
        this.actions.push({
            action: 'kick',
            target,
            timestamp: Date.now(),
            details: { userId, reason },
        });
        return { success: true, action: 'kick' };
    }
    ban(target, userId, reason) {
        logger.info(`Banning ${userId} from ${target.channel}: ${reason || 'no reason'}`);
        this.actions.push({
            action: 'ban',
            target,
            timestamp: Date.now(),
            details: { userId, reason },
        });
        return { success: true, action: 'ban' };
    }
    getActions() {
        return [...this.actions];
    }
    getSupportedChannels() {
        return [...this.supportedChannels];
    }
}
//# sourceMappingURL=message-tool.js.map