// 聊天室 Vite 入口，集中导出从 Blade 内联脚本迁移出的纯前端工具。

// 统一转发各子模块导出，方便测试或后续模块继续复用同一组工具。
export { escapeHtml, escapeHtmlWithLineBreaks } from "./chat-room/html.js";
export { bindGlobalDialogControls } from "./chat-room/dialog.js";
export { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
export { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
export { bindChatImageUploadControl } from "./chat-room/image-upload.js";
export { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
export { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
export {
    bindMobileDrawerControls,
    closeMobileDrawer,
    loadMobileRoomList,
    openMobileDrawer,
    renderMobileRoomList,
    renderMobileUserList,
    scheduleRenderMobileUserList,
    switchMobileTab,
} from "./chat-room/mobile-drawer.js";
export { bindMarriageStatusControls } from "./chat-room/marriage-status.js";
export { bindToolbarControls, runFeatureShortcut, runToolbarAction } from "./chat-room/toolbar.js";
export { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js";
export { bindAdminMenuControls } from "./chat-room/admin-menu.js";
export {
    bindBaccaratLossCoverAdminControls,
    closeAdminBaccaratLossCoverModal,
    closeCurrentBaccaratLossCoverEvent,
    loadAdminCurrentLossCoverEvent,
    openAdminBaccaratLossCoverModal,
    submitBaccaratLossCoverEvent,
} from "./chat-room/baccarat-loss-cover-admin.js";
export {
    bankAction,
    bankLoadInfo,
    bankShowMsg,
    bindBankControls,
    closeBankModal,
    fetchBankRanking,
    openBankModal,
    switchBankTab,
    toggleBankRankSort,
} from "./chat-room/bank-modal.js";
export { bindFishingControls } from "./chat-room/fishing.js";
export { bindProfileControls } from "./chat-room/profile-controls.js";
export { bindShopControls } from "./chat-room/shop-controls.js";
export { bindVipControls } from "./chat-room/vip-controls.js";
export {
    BLOCKABLE_SYSTEM_SENDERS,
    BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
    CHAT_SOUND_MUTED_STORAGE_KEY,
    bindBlockMenuControls,
    bindSoundMuteControl,
    isSoundMuted,
    loadBlockedSystemSenders,
    normalizeChatPreferences,
    normalizeDailyStatus,
    parseDailyStatusExpiry,
    persistBlockedSystemSenders,
    setSoundMuted,
    shouldMigrateLocalChatPreferences,
} from "./chat-room/preferences-status.js";
export { bindChatRightPanelControls } from "./chat-room/right-panel.js";
export {
    bindRoomStatusControls,
    normalizeRoomStatus,
    renderRoomStatusRow,
    renderRoomsOnlineStatus,
    renderRoomsOnlineStatusToContainer,
    resolveRoomUrl,
} from "./chat-room/rooms.js";
export { createMessageQueue } from "./chat-room/message-queue.js";

import { escapeHtml, escapeHtmlWithLineBreaks } from "./chat-room/html.js";
import { bindGlobalDialogControls } from "./chat-room/dialog.js";
import { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
import { applyFontSize, bindChatFontSizeControl, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
import { bindChatImageUploadControl } from "./chat-room/image-upload.js";
import { bindFriendPanelControls, closeFriendPanel, friendSearch, loadFriends, openFriendPanel, quickFriendAction } from "./chat-room/friend-panel.js";
import { closeChatImageLightbox, initChatImageLightboxEvents, openChatImageLightbox } from "./chat-room/lightbox.js";
import {
    bindMobileDrawerControls,
    closeMobileDrawer,
    loadMobileRoomList,
    openMobileDrawer,
    renderMobileRoomList,
    renderMobileUserList,
    scheduleRenderMobileUserList,
    switchMobileTab,
} from "./chat-room/mobile-drawer.js";
import { bindMarriageStatusControls } from "./chat-room/marriage-status.js";
import { bindToolbarControls, runFeatureShortcut, runToolbarAction } from "./chat-room/toolbar.js";
import { bindWelcomeMenuControls } from "./chat-room/welcome-menu.js";
import { bindAdminMenuControls } from "./chat-room/admin-menu.js";
import {
    bindBaccaratLossCoverAdminControls,
    closeAdminBaccaratLossCoverModal,
    closeCurrentBaccaratLossCoverEvent,
    loadAdminCurrentLossCoverEvent,
    openAdminBaccaratLossCoverModal,
    submitBaccaratLossCoverEvent,
} from "./chat-room/baccarat-loss-cover-admin.js";
import {
    bankAction,
    bankLoadInfo,
    bankShowMsg,
    bindBankControls,
    closeBankModal,
    fetchBankRanking,
    openBankModal,
    switchBankTab,
    toggleBankRankSort,
} from "./chat-room/bank-modal.js";
import { bindFishingControls } from "./chat-room/fishing.js";
import { bindProfileControls } from "./chat-room/profile-controls.js";
import { bindShopControls } from "./chat-room/shop-controls.js";
import { bindVipControls } from "./chat-room/vip-controls.js";
import {
    BLOCKABLE_SYSTEM_SENDERS,
    BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
    CHAT_SOUND_MUTED_STORAGE_KEY,
    bindBlockMenuControls,
    bindSoundMuteControl,
    isSoundMuted,
    loadBlockedSystemSenders,
    normalizeChatPreferences,
    normalizeDailyStatus,
    parseDailyStatusExpiry,
    persistBlockedSystemSenders,
    setSoundMuted,
    shouldMigrateLocalChatPreferences,
} from "./chat-room/preferences-status.js";
import { bindChatRightPanelControls } from "./chat-room/right-panel.js";
import {
    bindRoomStatusControls,
    normalizeRoomStatus,
    renderRoomStatusRow,
    renderRoomsOnlineStatus,
    renderRoomsOnlineStatusToContainer,
    resolveRoomUrl,
} from "./chat-room/rooms.js";
import { createMessageQueue } from "./chat-room/message-queue.js";

if (typeof window !== "undefined") {
    // 保留聚合入口，给新迁移模块、测试和仍在 Blade 内的存量脚本统一读取工具。
    window.ChatRoomTools = {
        escapeHtml,
        escapeHtmlWithLineBreaks,
        bindGlobalDialogControls,
        bindDailySignInControls,
        applyFontSize,
        bindChatFontSizeControl,
        bindChatImageUploadControl,
        bindFriendPanelControls,
        closeFriendPanel,
        friendSearch,
        loadFriends,
        openFriendPanel,
        quickFriendAction,
        bindMobileDrawerControls,
        closeMobileDrawer,
        loadMobileRoomList,
        openMobileDrawer,
        renderMobileRoomList,
        renderMobileUserList,
        scheduleRenderMobileUserList,
        switchMobileTab,
        bindToolbarControls,
        runFeatureShortcut,
        runToolbarAction,
        bindWelcomeMenuControls,
        bindAdminMenuControls,
        bindBaccaratLossCoverAdminControls,
        closeAdminBaccaratLossCoverModal,
        closeCurrentBaccaratLossCoverEvent,
        loadAdminCurrentLossCoverEvent,
        openAdminBaccaratLossCoverModal,
        submitBaccaratLossCoverEvent,
        bankAction,
        bankLoadInfo,
        bankShowMsg,
        bindBankControls,
        closeBankModal,
        fetchBankRanking,
        openBankModal,
        switchBankTab,
        toggleBankRankSort,
        bindFishingControls,
        bindMarriageStatusControls,
        bindProfileControls,
        bindShopControls,
        bindVipControls,
        CHAT_FONT_SIZE_STORAGE_KEY,
        restoreChatFontSize,
        closeChatImageLightbox,
        initChatImageLightboxEvents,
        openChatImageLightbox,
        BLOCKABLE_SYSTEM_SENDERS,
        BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
        CHAT_SOUND_MUTED_STORAGE_KEY,
        bindBlockMenuControls,
        bindSoundMuteControl,
        isSoundMuted,
        loadBlockedSystemSenders,
        normalizeChatPreferences,
        normalizeDailyStatus,
        parseDailyStatusExpiry,
        persistBlockedSystemSenders,
        setSoundMuted,
        shouldMigrateLocalChatPreferences,
        bindChatRightPanelControls,
        bindRoomStatusControls,
        normalizeRoomStatus,
        renderRoomStatusRow,
        renderRoomsOnlineStatus,
        renderRoomsOnlineStatusToContainer,
        resolveRoomUrl,
        createMessageQueue,
    };

    // 直接挂载只服务暂未迁移的 Blade 调用点；新代码优先通过模块导入或 ChatRoomTools 复用。
    window.closeChatImageLightbox = closeChatImageLightbox;
    window.openChatImageLightbox = openChatImageLightbox;
    window.closeFriendPanel = closeFriendPanel;
    window.friendSearch = friendSearch;
    window.openFriendPanel = openFriendPanel;
    window.quickFriendAction = quickFriendAction;
    window.closeMobileDrawer = closeMobileDrawer;
    window.loadMobileRoomList = loadMobileRoomList;
    window.openMobileDrawer = openMobileDrawer;
    window.renderMobileRoomList = renderMobileRoomList;
    window.renderMobileUserList = renderMobileUserList;
    window.scheduleRenderMobileUserList = scheduleRenderMobileUserList;
    window.switchMobileTab = switchMobileTab;
    window.runFeatureShortcut = runFeatureShortcut;
    window.runToolbarAction = runToolbarAction;
    window.closeAdminBaccaratLossCoverModal = closeAdminBaccaratLossCoverModal;
    window.closeCurrentBaccaratLossCoverEvent = closeCurrentBaccaratLossCoverEvent;
    window.openAdminBaccaratLossCoverModal = openAdminBaccaratLossCoverModal;
    window.submitBaccaratLossCoverEvent = submitBaccaratLossCoverEvent;
    window.bankAction = bankAction;
    window.bankLoadInfo = bankLoadInfo;
    window.bankShowMsg = bankShowMsg;
    window.closeBankModal = closeBankModal;
    window.fetchBankRanking = fetchBankRanking;
    window.openBankModal = openBankModal;
    window.switchBankTab = switchBankTab;
    window.toggleBankRankSort = toggleBankRankSort;
    window.applyFontSize = applyFontSize;

    // 页面加载后立即注册事件委托，具体业务逻辑仍由各子模块负责。
    bindGlobalDialogControls();
    bindDailySignInControls();
    bindChatFontSizeControl();
    bindChatImageUploadControl();
    bindFriendPanelControls();
    bindToolbarControls();
    bindAdminMenuControls();
    bindBaccaratLossCoverAdminControls();
    bindBankControls();
    bindFishingControls();
    bindMarriageStatusControls();
    bindProfileControls();
    bindShopControls();
    bindVipControls();
    bindChatRightPanelControls();
    bindRoomStatusControls();
    bindMobileDrawerControls();
    bindWelcomeMenuControls();
    bindBlockMenuControls();
}
