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

/**
 * 模块引用说明：
 * - html.js：提供聊天内容通用 HTML 转义和安全链接规整工具。
 * - appointment-announcement.js：处理任命/撤销公告的大卡片和系统消息。
 * - banner.js：提供 window.chatBanner 居中大卡片通知。
 * - chat-bot.js：处理 AI 小班长发送消息和清空上下文。
 * - dialog.js：提供 window.chatDialog 全局弹窗。
 * - daily-sign-in.js：处理每日签到弹窗与补签入口。
 * - earn-panel.js：提供看视频赚钱 earnPanelData Alpine 组件和播放器加载入口。
 * - font-size.js：处理聊天输入/消息字号设置。
 * - image-upload.js：处理聊天图片上传入口。
 * - composer.js：处理聊天输入框、发送按钮和快捷操作。
 * - toast.js：提供 window.chatToast 右下角通知。
 * - friend-panel.js：处理好友面板、搜索和好友快捷操作。
 * - friend-notifications.js：监听好友通知和通用 BannerNotification。
 * - lightbox.js：处理聊天图片预览灯箱。
 * - lottery-panel.js：提供双色球彩票 lotteryPanel Alpine 组件和全局开关入口。
 * - mobile-drawer.js：处理移动端抽屉、房间列表和在线名单。
 * - marriage-status.js：处理婚姻状态弹窗、已婚列表、接受拒绝和离婚申请。
 * - marriage-modals.js：处理婚姻弹窗的系统消息、求婚和婚礼设置全局入口。
 * - toolbar.js：处理工具栏按钮和功能快捷入口。
 * - user-card.js：提供用户名片弹窗 Alpine 组件和管理/礼物操作。
 * - user-target-actions.js：处理点击用户名切换私聊目标和打开名片。
 * - welcome-menu.js：处理欢迎菜单交互。
 * - admin-menu.js：处理聊天室管理菜单交互。
 * - baccarat-panel.js：提供百家乐主面板 Alpine 组件和下注流程。
 * - baccarat-fab.js：处理百家乐悬浮按钮拖动与打开面板。
 * - baccarat-events.js：处理百家乐广播事件和页面恢复当前局。
 * - baccarat-loss-cover-admin.js：处理百家乐买单活动管理弹层。
 * - baccarat-loss-cover.js：处理百家乐买单活动前台弹窗。
 * - game-hall.js：处理娱乐大厅弹窗和游戏入口卡片。
 * - game-bootstrap.js：提供非关键游戏延迟初始化工具。
 * - game-panels.js：处理通用游戏面板关闭事件。
 * - gomoku-panel.js：提供五子棋主面板 Alpine 组件和 Canvas 棋盘逻辑。
 * - gomoku-controls.js：处理五子棋外部打开和接受邀请入口。
 * - horse-race-panel.js：提供赛马竞猜主面板 Alpine 组件和下注流程。
 * - horse-race-fab.js：处理赛马竞猜悬浮按钮拖动与打开面板。
 * - horse-race-events.js：处理赛马广播事件和页面恢复当前场次。
 * - holiday-modal.js：处理节日福利弹窗、广播监听、领取状态和系统消息入口。
 * - initial-state.js：恢复首屏历史消息、欢迎消息、入场特效和挂起婚姻事件。
 * - bank-modal.js：处理银行弹窗、转账、排行和标签切换。
 * - fishing.js：处理钓鱼抛竿、收竿、浮漂和自动钓鱼循环。
 * - fortune-panel.js：提供神秘占卜 fortunePanel Alpine 组件。
 * - profile-controls.js：处理头像选择、个人资料、密码、邮箱验证码和微信绑定入口。
 * - shop-controls.js：处理商店弹窗、商品加载、购买、赠礼和改名卡入口。
 * - compact-shop-panel.js：兼容旧右侧紧凑商店面板，按需挂载旧全局函数。
 * - slot-machine.js：提供老虎机 slotPanel/slotFab Alpine 组件。
 * - vip-controls.js：处理 VIP 中心弹窗、会员数据渲染、支付跳转和专属进退场设置。
 * - preferences-status.js：处理聊天偏好、屏蔽系统播报和静音状态。
 * - right-panel.js：处理右侧在线用户列表和用户名交互。
 * - rooms.js：处理房间在线状态渲染和跳转 URL。
 * - reward-modal.js：处理职务奖励金币弹窗入口。
 * - red-packet-panel.js：处理礼包红包发包、抢包、倒计时和广播监听。
 * - message-queue.js：提供聊天消息分批渲染队列。
 * - message-utils.js：提供图片消息过期等消息渲染辅助判断。
 */

// 统一转发各子模块导出（仅保留轻量核心模块的静态导出）
export { escapeHtml, escapeHtmlWithLineBreaks, normalizeSafeChatUrl } from "./chat-room/html.js";
export { bindGlobalDialogControls } from "./chat-room/dialog.js";
export { bindChatToast } from "./chat-room/toast.js";
export { bindChatComposerControls, setChatComposerAction } from "./chat-room/composer.js";
export {
    isExpiredChatImageMessage,
    isAutoScrollEnabled,
    localClearScreen,
    scrollChatToBottom,
    setAutoScrollEnabled,
    syncAutoScrollControls,
    toggleAutoScroll,
} from "./chat-room/message-utils.js";
export {
    BLOCKABLE_SYSTEM_SENDERS,
    BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
    CHAT_SOUND_MUTED_STORAGE_KEY,
    bindBlockMenuControls,
    bindSoundMuteControl,
    buildChatPreferencesPayload,
    closeDailyStatusEditor,
    closeFeatureMenu,
    getCurrentUserDailyStatus,
    handleFeatureLocalClear,
    isSoundMuted,
    loadBlockedSystemSenders,
    normalizeChatPreferences,
    normalizeDailyStatus,
    openDailyStatusEditor,
    parseDailyStatusExpiry,
    persistBlockedSystemSenders,
    persistChatPreferencesToLocal,
    removeDailyStatusFields,
    resolveBlockedSystemSenderKey,
    saveChatPreferences,
    setOnlineUserDailyStatus,
    setRenderedMessagesVisibilityBySender,
    setSoundMuted,
    shouldMigrateLocalChatPreferences,
    syncBlockedSystemSenderCheckboxes,
    syncDailyStatusUi,
    toggleBlockMenu,
    toggleBlockedSystemSender,
    toggleFeatureMenu,
    toggleSoundMute,
} from "./chat-room/preferences-status.js";
export {
    bindInstantHoverTooltip,
} from "./chat-room/hover-tooltip.js";
export { createMessageQueue } from "./chat-room/message-queue.js";

// 新增：聊天室核心引擎模块导出
export {
    appendMessage,
    buildChatMessageContent,
    commitChatMessageRenderBatch,
    createChatMessageRenderBatch,
    enqueueChatMessage,
    flushQueuedChatMessages,
    pruneMessageContainer,
} from "./chat-room/message-renderer.js";
export {
    buildUserBadgeHtml,
    filterUserList,
    refreshRenderedUserBadges,
    renderUserList,
    renderUserListToContainer,
    scheduleFilterUserList,
    scheduleRenderUserList,
    startBadgeRotation,
    stopBadgeRotation,
} from "./chat-room/user-list.js";
export { bindChatEvents } from "./chat-room/chat-events.js";
export { leaveRoom, notifyExpiredLeave, saveExp, startHeartbeat, stopHeartbeat, HEARTBEAT_INTERVAL, MAX_HEARTBEAT_FAILS } from "./chat-room/heartbeat.js";

// ─── 懒加载工具 ──────────────────────────────────────
import { createLazyModule } from "./chat-room/lazy-loader.js";

// ─── 游戏 & 功能模块（按需懒加载 — 仅保留工具栏调用的模块）─────────
const _shop = createLazyModule(
    () => import("./chat-room/shop-controls.js"),
    (mod) => mod.bindShopControls()
);
const _ride = createLazyModule(
    () => import("./chat-room/ride-controls.js"),
    (mod) => mod.bindRideControls()
);
const _compactShop = createLazyModule(
    () => import("./chat-room/compact-shop-panel.js"),
    (mod) => mod.bindCompactShopPanelControls()
);
const _bank = createLazyModule(
    () => import("./chat-room/bank-modal.js"),
    (mod) => mod.bindBankControls()
);
const _marriageStatus = createLazyModule(
    () => import("./chat-room/marriage-status.js"),
    (mod) => mod.bindMarriageStatusControls()
);
const _profile = createLazyModule(
    () => import("./chat-room/profile-controls.js"),
    (mod) => mod.bindProfileControls()
);
const _vip = createLazyModule(
    () => import("./chat-room/vip-controls.js"),
    (mod) => mod.bindVipControls()
);
const _friendPanel = createLazyModule(
    () => import("./chat-room/friend-panel.js"),
    (mod) => mod.bindFriendPanelControls()
);
const _gameHall = createLazyModule(
    () => import("./chat-room/game-hall.js"),
    (mod) => mod.bindGameHallControls()
);

// ─── 静态导入的 Alpine 组件模块（Blade 中通过 x-data 引用，必须同步可用）──
import { userCardComponent, bindUserCardControls } from "./chat-room/user-card.js";
import {
    marriageProposeModal,
    marriageIncomingModal,
    marriageAcceptedModal,
    marriageDivorcedModal,
    divorceConfirmModal,
    divorceRequestModal,
    weddingSetupModal,
    weddingEnvelopeModal,
    appendSystemMessage,
    openProposeModal,
    openWeddingSetupModal,
    bindMarriageModalControls,
} from "./chat-room/marriage-modals.js";
import { holidayEventModal, bindHolidayModalControls, buildHolidayClaimActionButton, buildHolidaySystemMessage, openHolidayRunFromSystemMessage } from "./chat-room/holiday-modal.js";
import { rewardModal, bindRewardModalControls, openRewardModal } from "./chat-room/reward-modal.js";
import { createEarnPanelData, bindEarnPanelControls } from "./chat-room/earn-panel.js";
import { baccaratPanel, bindBaccaratPanelControls } from "./chat-room/baccarat-panel.js";
import { baccaratFab, bindBaccaratFabControls } from "./chat-room/baccarat-fab.js";
import { horseRacePanel, bindHorseRacePanelControls, requestHorseRaceJson } from "./chat-room/horse-race-panel.js";
import { horseRaceFab, bindHorseRaceFabControls } from "./chat-room/horse-race-fab.js";
import { slotPanel, slotFab, bindSlotMachineControls } from "./chat-room/slot-machine.js";
import { fortunePanel, bindFortunePanelControls } from "./chat-room/fortune-panel.js";
import { lotteryPanel, bindLotteryPanelControls, closeLotteryPanel, openLotteryPanel, showLotteryMsg } from "./chat-room/lottery-panel.js";
import { gomokuPanel, bindGomokuPanelControls } from "./chat-room/gomoku-panel.js";

// ─── 事件委托模块（需要立即注册事件监听，静态导入）─────────────────────
import { bindDailySignInControls } from "./chat-room/daily-sign-in.js";
import { bindBaccaratEvents } from "./chat-room/baccarat-events.js";
import { bindBaccaratLossCoverAdminControls, closeAdminBaccaratLossCoverModal, closeCurrentBaccaratLossCoverEvent, loadAdminCurrentLossCoverEvent, openAdminBaccaratLossCoverModal, submitBaccaratLossCoverEvent } from "./chat-room/baccarat-loss-cover-admin.js";
import { bindBaccaratLossCoverControls, claimBaccaratLossCover, closeBaccaratLossCoverModal, openBaccaratLossCoverModal, switchBaccaratLossCoverTab } from "./chat-room/baccarat-loss-cover.js";
import { bindGomokuControls, acceptGomokuInvite, openGomokuPanel } from "./chat-room/gomoku-controls.js";
import { bindHorseRaceEvents } from "./chat-room/horse-race-events.js";
import { bindFishingControls, startFishing, reelFish, stopAutoFishing, resetFishingBtn, checkAndAutoStartFishing, createBobber, removeBobber } from "./chat-room/fishing.js";
import { bindGameBootstrapControls, deferChatGameBootstrap } from "./chat-room/game-bootstrap.js";
import { bindGamePanelControls } from "./chat-room/game-panels.js";
import { bindUserTargetActions, openUserCard, switchTarget } from "./chat-room/user-target-actions.js";
import { bindRedPacketPanelControls, claimRedPacket, closeRedPacketModal, sendRedPacket, showRedPacketModal, updateRedPacketClaimsUI } from "./chat-room/red-packet-panel.js";
import { bindMobileDrawerControls, closeMobileDrawer, loadMobileRoomList, openMobileDrawer, renderMobileRoomList, renderMobileUserList, scheduleRenderMobileUserList, switchMobileTab } from "./chat-room/mobile-drawer.js";
import { bindWelcomeMenuControls, toggleWelcomeMenu } from "./chat-room/welcome-menu.js";
import { bindAdminMenuControls } from "./chat-room/admin-menu.js";
import { bindFriendNotificationControls, setupBannerNotification, setupFriendNotification, showFriendBanner } from "./chat-room/friend-notifications.js";
import { initChatImageLightboxEvents, closeChatImageLightbox, openChatImageLightbox } from "./chat-room/lightbox.js";
import { bindRoomStatusControls, normalizeRoomStatus, renderRoomStatusRow, renderRoomsOnlineStatus, renderRoomsOnlineStatusToContainer, resolveRoomUrl } from "./chat-room/rooms.js";
import { bindChatRightPanelControls } from "./chat-room/right-panel.js";
import { bindChatImageUploadControl } from "./chat-room/image-upload.js";
import { applyFontSize, bindChatFontSizeControl, CHAT_DEFAULT_FONT_SIZE, CHAT_FONT_SIZE_STORAGE_KEY, restoreChatFontSize } from "./chat-room/font-size.js";
import { bindAppointmentAnnouncementControls, showAppointmentBanner } from "./chat-room/appointment-announcement.js";
import { bindChatBanner } from "./chat-room/banner.js";
import { bindChatBotControls, clearChatBotContext, sendToChatBot } from "./chat-room/chat-bot.js";

// ─── 留言板模态弹窗 ──────────────────────
import { openGuestbookModal, closeGuestbookModal, loadGuestbookMessages, bindGuestbookControls } from "./chat-room/guestbook.js";

// ─── 反馈模态弹窗 ──────────────────────
import { openFeedbackModal, closeFeedbackModal, loadFeedbackData, loadMoreFeedback, bindFeedbackControls } from "./chat-room/feedback.js";

// ─── 轻量核心模块（保持静态导入）────────────────────
import { escapeHtml, escapeHtmlWithLineBreaks, normalizeSafeChatUrl } from "./chat-room/html.js";
import { bindGlobalDialogControls } from "./chat-room/dialog.js";
import { bindChatToast } from "./chat-room/toast.js";
import { bindChatComposerControls, setChatComposerAction } from "./chat-room/composer.js";
import {
    isExpiredChatImageMessage,
    isAutoScrollEnabled,
    localClearScreen,
    scrollChatToBottom,
    setAutoScrollEnabled,
    syncAutoScrollControls,
    toggleAutoScroll,
} from "./chat-room/message-utils.js";
import {
    BLOCKABLE_SYSTEM_SENDERS,
    BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
    CHAT_SOUND_MUTED_STORAGE_KEY,
    bindBlockMenuControls,
    bindSoundMuteControl,
    buildChatPreferencesPayload,
    closeDailyStatusEditor,
    closeFeatureMenu,
    getCurrentUserDailyStatus,
    handleFeatureLocalClear,
    isSoundMuted,
    loadBlockedSystemSenders,
    normalizeChatPreferences,
    normalizeDailyStatus,
    openDailyStatusEditor,
    parseDailyStatusExpiry,
    persistBlockedSystemSenders,
    persistChatPreferencesToLocal,
    removeDailyStatusFields,
    resolveBlockedSystemSenderKey,
    saveChatPreferences,
    setOnlineUserDailyStatus,
    setRenderedMessagesVisibilityBySender,
    setSoundMuted,
    shouldMigrateLocalChatPreferences,
    syncBlockedSystemSenderCheckboxes,
    syncDailyStatusUi,
    toggleBlockMenu,
    toggleBlockedSystemSender,
    toggleFeatureMenu,
    toggleSoundMute,
} from "./chat-room/preferences-status.js";
import {
    bindInstantHoverTooltip,
} from "./chat-room/hover-tooltip.js";
import { createMessageQueue } from "./chat-room/message-queue.js";

// 新增：聊天室核心引擎模块（共享状态、消息渲染、用户名单、事件监听、心跳）
import "./chat-room/chat-state.js";
import { appendMessage, buildChatMessageContent, commitChatMessageRenderBatch, createChatMessageRenderBatch, enqueueChatMessage, flushQueuedChatMessages, pruneMessageContainer } from "./chat-room/message-renderer.js";
import { buildUserBadgeHtml, filterUserList, refreshRenderedUserBadges, renderUserList, renderUserListToContainer, scheduleFilterUserList, scheduleRenderUserList, startBadgeRotation, stopBadgeRotation } from "./chat-room/user-list.js";
import { bindChatEvents } from "./chat-room/chat-events.js";
import { leaveRoom, notifyExpiredLeave, saveExp, startHeartbeat, stopHeartbeat } from "./chat-room/heartbeat.js";

// ─── 工具 & 初始化模块（静态保留）────────────────────
import { bindToolbarControls, runFeatureShortcut, runToolbarAction } from "./chat-room/toolbar.js";
import { bindChatInitialStateControls } from "./chat-room/initial-state.js";

// 拍一拍模块
import "./chat-room/pat.js";

// 猜成语游戏模块
import "./chat-room/riddle-quiz.js";
import { bindIdiomQuizControls } from "./chat-room/riddle-quiz.js";

// 斜杠命令菜单
import { bindSlashCommands, registerSlashCommand } from "./chat-room/slash-commands.js";

if (typeof window !== "undefined") {
    bindInstantHoverTooltip();

    // 初始化斜杠命令菜单
    bindSlashCommands();

    // 保留聚合入口，懒加载模块通过按需动态导入自动初始化。
    window.ChatRoomTools = {
        // ── 静态核心模块（直接引用） ────────────────
        escapeHtml,
        escapeHtmlWithLineBreaks,
        normalizeSafeChatUrl,
        bindGlobalDialogControls,
        bindChatToast,
        bindChatComposerControls,
        setChatComposerAction,
        isExpiredChatImageMessage,
        isAutoScrollEnabled,
        localClearScreen,
        scrollChatToBottom,
        setAutoScrollEnabled,
        syncAutoScrollControls,
        toggleAutoScroll,
        bindInstantHoverTooltip,
        createMessageQueue,
        BLOCKABLE_SYSTEM_SENDERS,
        BLOCKED_SYSTEM_SENDERS_STORAGE_KEY,
        CHAT_SOUND_MUTED_STORAGE_KEY,
        bindBlockMenuControls,
        bindSoundMuteControl,
        buildChatPreferencesPayload,
        closeDailyStatusEditor,
        closeFeatureMenu,
        getCurrentUserDailyStatus,
        handleFeatureLocalClear,
        isSoundMuted,
        loadBlockedSystemSenders,
        normalizeChatPreferences,
        normalizeDailyStatus,
        openDailyStatusEditor,
        parseDailyStatusExpiry,
        persistBlockedSystemSenders,
        persistChatPreferencesToLocal,
        removeDailyStatusFields,
        resolveBlockedSystemSenderKey,
        saveChatPreferences,
        setOnlineUserDailyStatus,
        setRenderedMessagesVisibilityBySender,
        setSoundMuted,
        shouldMigrateLocalChatPreferences,
        syncBlockedSystemSenderCheckboxes,
        syncDailyStatusUi,
        toggleBlockMenu,
        toggleBlockedSystemSender,
        toggleFeatureMenu,
        toggleSoundMute,
        bindToolbarControls,
        runFeatureShortcut,
        runToolbarAction,
        bindChatInitialStateControls,
        // 聊天室核心引擎
        bindChatEvents,
        appendMessage,
        buildChatMessageContent,
        commitChatMessageRenderBatch,
        createChatMessageRenderBatch,
        enqueueChatMessage,
        flushQueuedChatMessages,
        pruneMessageContainer,
        buildUserBadgeHtml,
        filterUserList,
        refreshRenderedUserBadges,
        renderUserListToContainer,
        startBadgeRotation,
        stopBadgeRotation,
        scheduleFilterUserList,
        leaveRoom,
        notifyExpiredLeave,
        startHeartbeat,
        stopHeartbeat,

        // ── 功能模块（懒加载包装 — 仅工具栏调用模块）────────
        bindShopControls: (...args) => _shop.wrap('bindShopControls')(...args),
        buyItem: (...args) => _shop.wrap('buyItem')(...args),
        closeGiftDialog: (...args) => _shop.wrap('closeGiftDialog')(...args),
        closeRenameModal: (...args) => _shop.wrap('closeRenameModal')(...args),
        closeShopModal: (...args) => _shop.wrap('closeShopModal')(...args),
        confirmGift: (...args) => _shop.wrap('confirmGift')(...args),
        fetchShopData: (...args) => _shop.wrap('fetchShopData')(...args),
        loadShop: (...args) => _shop.wrap('loadShop')(...args),
        openGiftDialog: (...args) => _shop.wrap('openGiftDialog')(...args),
        openRenameModal: (...args) => _shop.wrap('openRenameModal')(...args),
        openShopModal: (...args) => _shop.wrap('openShopModal')(...args),
        renderShop: (...args) => _shop.wrap('renderShop')(...args),
        showShopToast: (...args) => _shop.wrap('showShopToast')(...args),
        submitRename: (...args) => _shop.wrap('submitRename')(...args),
        bindRideControls: (...args) => _ride.wrap('bindRideControls')(...args),
        buyRide: (...args) => _ride.wrap('buyRide')(...args),
        closeRideModal: (...args) => _ride.wrap('closeRideModal')(...args),
        fetchRideData: (...args) => _ride.wrap('fetchRideData')(...args),
        loadRides: (...args) => _ride.wrap('loadRides')(...args),
        openRideModal: (...args) => _ride.wrap('openRideModal')(...args),
        renderRides: (...args) => _ride.wrap('renderRides')(...args),
        bindCompactShopPanelControls: (...args) => _compactShop.wrap('bindCompactShopPanelControls')(...args),
        buyCompactShopItem: (...args) => _compactShop.wrap('buyCompactShopItem')(...args),
        closeCompactRenameModal: (...args) => _compactShop.wrap('closeCompactRenameModal')(...args),
        fetchCompactShopData: (...args) => _compactShop.wrap('fetchCompactShopData')(...args),
        loadCompactShop: (...args) => _compactShop.wrap('loadCompactShop')(...args),
        openCompactRenameModal: (...args) => _compactShop.wrap('openCompactRenameModal')(...args),
        renderCompactShop: (...args) => _compactShop.wrap('renderCompactShop')(...args),
        showCompactShopToast: (...args) => _compactShop.wrap('showCompactShopToast')(...args),
        submitCompactRename: (...args) => _compactShop.wrap('submitCompactRename')(...args),
        bankAction: (...args) => _bank.wrap('bankAction')(...args),
        bankLoadInfo: (...args) => _bank.wrap('bankLoadInfo')(...args),
        bankShowMsg: (...args) => _bank.wrap('bankShowMsg')(...args),
        bindBankControls: (...args) => _bank.wrap('bindBankControls')(...args),
        closeBankModal: (...args) => _bank.wrap('closeBankModal')(...args),
        fetchBankRanking: (...args) => _bank.wrap('fetchBankRanking')(...args),
        openBankModal: (...args) => _bank.wrap('openBankModal')(...args),
        switchBankTab: (...args) => _bank.wrap('switchBankTab')(...args),
        toggleBankRankSort: (...args) => _bank.wrap('toggleBankRankSort')(...args),
        bindMarriageStatusControls: (...args) => _marriageStatus.wrap('bindMarriageStatusControls')(...args),
        closeMarriageStatusModal: (...args) => _marriageStatus.wrap('closeMarriageStatusModal')(...args),
        fetchMarriedList: (...args) => _marriageStatus.wrap('fetchMarriedList')(...args),
        fetchMyMarriageStatus: (...args) => _marriageStatus.wrap('fetchMyMarriageStatus')(...args),
        marriageAction: (...args) => _marriageStatus.wrap('marriageAction')(...args),
        openMarriageStatusModal: (...args) => _marriageStatus.wrap('openMarriageStatusModal')(...args),
        renderMarriedList: (...args) => _marriageStatus.wrap('renderMarriedList')(...args),
        renderMarriageStatus: (...args) => _marriageStatus.wrap('renderMarriageStatus')(...args),
        switchMarriageTab: (...args) => _marriageStatus.wrap('switchMarriageTab')(...args),
        tryDivorce: (...args) => _marriageStatus.wrap('tryDivorce')(...args),
        bindProfileControls: (...args) => _profile.wrap('bindProfileControls')(...args),
        closeAvatarPicker: (...args) => _profile.wrap('closeAvatarPicker')(...args),
        closeSettingsModal: (...args) => _profile.wrap('closeSettingsModal')(...args),
        copyWechatBindCode: (...args) => _profile.wrap('copyWechatBindCode')(...args),
        generateWechatBindCode: (...args) => _profile.wrap('generateWechatBindCode')(...args),
        handleAvatarUpload: (...args) => _profile.wrap('handleAvatarUpload')(...args),
        loadHeadfaces: (...args) => _profile.wrap('loadHeadfaces')(...args),
        openAvatarPicker: (...args) => _profile.wrap('openAvatarPicker')(...args),
        openSettingsModal: (...args) => _profile.wrap('openSettingsModal')(...args),
        saveAvatar: (...args) => _profile.wrap('saveAvatar')(...args),
        savePassword: (...args) => _profile.wrap('savePassword')(...args),
        saveSettings: (...args) => _profile.wrap('saveSettings')(...args),
        selectAvatar: (...args) => _profile.wrap('selectAvatar')(...args),
        sendEmailCode: (...args) => _profile.wrap('sendEmailCode')(...args),
        showInlineMsg: (...args) => _profile.wrap('showInlineMsg')(...args),
        unbindWechat: (...args) => _profile.wrap('unbindWechat')(...args),
        bindVipControls: (...args) => _vip.wrap('bindVipControls')(...args),
        buyVip: (...args) => _vip.wrap('buyVip')(...args),
        closeVipModal: (...args) => _vip.wrap('closeVipModal')(...args),
        openVipModal: (...args) => _vip.wrap('openVipModal')(...args),
        saveVipPresenceSettings: (...args) => _vip.wrap('saveVipPresenceSettings')(...args),
        switchVipTab: (...args) => _vip.wrap('switchVipTab')(...args),
        bindFriendPanelControls: (...args) => _friendPanel.wrap('bindFriendPanelControls')(...args),
        closeFriendPanel: (...args) => _friendPanel.wrap('closeFriendPanel')(...args),
        friendSearch: (...args) => _friendPanel.wrap('friendSearch')(...args),
        loadFriends: (...args) => _friendPanel.wrap('loadFriends')(...args),
        openFriendPanel: (...args) => _friendPanel.wrap('openFriendPanel')(...args),
        quickFriendAction: (...args) => _friendPanel.wrap('quickFriendAction')(...args),
        bindGameHallControls: (...args) => _gameHall.wrap('bindGameHallControls')(...args),
        closeGameHall: (...args) => _gameHall.wrap('closeGameHall')(...args),
        openGameHall: (...args) => _gameHall.wrap('openGameHall')(...args),

        // ── 已转为静态导入的功能模块（直接引用）───
        bindAppointmentAnnouncementControls,
        showAppointmentBanner,
        bindChatBanner,
        bindChatBotControls,
        clearChatBotContext,
        sendToChatBot,
        applyFontSize,
        bindChatFontSizeControl,
        CHAT_DEFAULT_FONT_SIZE,
        CHAT_FONT_SIZE_STORAGE_KEY,
        restoreChatFontSize,
        bindChatImageUploadControl,
        bindFriendNotificationControls,
        setupBannerNotification,
        setupFriendNotification,
        showFriendBanner,
        bindMobileDrawerControls,
        closeMobileDrawer,
        loadMobileRoomList,
        openMobileDrawer,
        renderMobileRoomList,
        renderMobileUserList,
        scheduleRenderMobileUserList,
        switchMobileTab,
        bindUserTargetActions,
        openUserCard,
        switchTarget,
        bindWelcomeMenuControls,
        toggleWelcomeMenu,
        bindAdminMenuControls,
        registerSlashCommand,
        bindBaccaratEvents,
        bindBaccaratLossCoverAdminControls,
        closeAdminBaccaratLossCoverModal,
        closeCurrentBaccaratLossCoverEvent,
        loadAdminCurrentLossCoverEvent,
        openAdminBaccaratLossCoverModal,
        submitBaccaratLossCoverEvent,
        bindBaccaratLossCoverControls,
        claimBaccaratLossCover,
        closeBaccaratLossCoverModal,
        openBaccaratLossCoverModal,
        switchBaccaratLossCoverTab,
        bindGameBootstrapControls,
        deferChatGameBootstrap,
        bindGamePanelControls,
        acceptGomokuInvite,
        bindGomokuControls,
        openGomokuPanel,
        requestHorseRaceJson,
        bindHorseRaceEvents,
        buildHolidayClaimActionButton,
        buildHolidaySystemMessage,
        openHolidayRunFromSystemMessage,
        bindFishingControls,
        checkAndAutoStartFishing,
        createBobber,
        reelFish,
        removeBobber,
        resetFishingBtn,
        startFishing,
        stopAutoFishing,
        closeChatImageLightbox,
        initChatImageLightboxEvents,
        openChatImageLightbox,
        bindChatRightPanelControls,
        bindRoomStatusControls,
        normalizeRoomStatus,
        renderRoomStatusRow,
        renderRoomsOnlineStatus,
        renderRoomsOnlineStatusToContainer,
        resolveRoomUrl,
        bindRedPacketPanelControls,
        claimRedPacket,
        closeRedPacketModal,
        sendRedPacket,
        showRedPacketModal,
        updateRedPacketClaimsUI,

        // ── 静态导入的 Alpine 组件模块 ──
        // 这些模块已通过静态导入编译到主包，直接引用导出
        userCardComponent,
        bindUserCardControls,
        marriageProposeModal,
        marriageIncomingModal,
        marriageAcceptedModal,
        marriageDivorcedModal,
        divorceConfirmModal,
        divorceRequestModal,
        weddingSetupModal,
        weddingEnvelopeModal,
        appendSystemMessage,
        openProposeModal,
        openWeddingSetupModal,
        bindMarriageModalControls,
        holidayEventModal,
        bindHolidayModalControls,
        rewardModal,
        bindRewardModalControls,
        openRewardModal,
        createEarnPanelData,
        bindEarnPanelControls,
        baccaratPanel,
        bindBaccaratPanelControls,
        baccaratFab,
        bindBaccaratFabControls,
        horseRacePanel,
        bindHorseRacePanelControls,
        horseRaceFab,
        bindHorseRaceFabControls,
        slotPanel,
        slotFab,
        bindSlotMachineControls,
        fortunePanel,
        bindFortunePanelControls,
        lotteryPanel,
        bindLotteryPanelControls,
        closeLotteryPanel,
        openLotteryPanel,
        showLotteryMsg,
        gomokuPanel,
        bindGomokuPanelControls,
    };

    // 直接挂载只服务暂未迁移的 Blade 调用点；新代码优先通过模块导入或 ChatRoomTools 复用。
    // ── 静态核心模块 window 挂载 ──
    window.escapeHtml = escapeHtml;
    window.isExpiredChatImageMessage = isExpiredChatImageMessage;
    window.isChatAutoScrollEnabled = isAutoScrollEnabled;
    window.localClearScreen = localClearScreen;
    window.normalizeSafeChatUrl = normalizeSafeChatUrl;
    window.setChatAutoScrollEnabled = setAutoScrollEnabled;
    window.setAction = setChatComposerAction;
    window.syncAutoScrollControls = syncAutoScrollControls;

    // ── 懒加载功能模块 window 挂载（仅保留工具栏调用模块的懒加载包装）──
    window.closeFriendPanel = (...args) => _friendPanel.wrap('closeFriendPanel')(...args);
    window.friendSearch = (...args) => _friendPanel.wrap('friendSearch')(...args);
    window.openFriendPanel = (...args) => _friendPanel.wrap('openFriendPanel')(...args);
    window.quickFriendAction = (...args) => _friendPanel.wrap('quickFriendAction')(...args);
    window.bankAction = (...args) => _bank.wrap('bankAction')(...args);
    window.bankLoadInfo = (...args) => _bank.wrap('bankLoadInfo')(...args);
    window.bankShowMsg = (...args) => _bank.wrap('bankShowMsg')(...args);
    window.closeBankModal = (...args) => _bank.wrap('closeBankModal')(...args);
    window.fetchBankRanking = (...args) => _bank.wrap('fetchBankRanking')(...args);
    window.openBankModal = (...args) => _bank.wrap('openBankModal')(...args);
    window.switchBankTab = (...args) => _bank.wrap('switchBankTab')(...args);
    window.toggleBankRankSort = (...args) => _bank.wrap('toggleBankRankSort')(...args);
    window.closeGameHall = (...args) => _gameHall.wrap('closeGameHall')(...args);
    window.openGameHall = (...args) => _gameHall.wrap('openGameHall')(...args);
    window.buyVip = (...args) => _vip.wrap('buyVip')(...args);
    window.closeVipModal = (...args) => _vip.wrap('closeVipModal')(...args);
    window.openVipModal = (...args) => _vip.wrap('openVipModal')(...args);
    window.saveVipPresenceSettings = (...args) => _vip.wrap('saveVipPresenceSettings')(...args);
    window.switchVipTab = (...args) => _vip.wrap('switchVipTab')(...args);
    window.closeMarriageStatusModal = (...args) => _marriageStatus.wrap('closeMarriageStatusModal')(...args);
    window.fetchMarriedList = (...args) => _marriageStatus.wrap('fetchMarriedList')(...args);
    window.fetchMyMarriageStatus = (...args) => _marriageStatus.wrap('fetchMyMarriageStatus')(...args);
    window.marriageAction = (...args) => _marriageStatus.wrap('marriageAction')(...args);
    window.openMarriageStatusModal = (...args) => _marriageStatus.wrap('openMarriageStatusModal')(...args);
    window.renderMarriedList = (...args) => _marriageStatus.wrap('renderMarriedList')(...args);
    window.renderMarriageStatus = (...args) => _marriageStatus.wrap('renderMarriageStatus')(...args);
    window.switchMarriageTab = (...args) => _marriageStatus.wrap('switchMarriageTab')(...args);
    window.tryDivorce = (...args) => _marriageStatus.wrap('tryDivorce')(...args);
    window.buyItem = (...args) => _shop.wrap('buyItem')(...args);
    window.closeGiftDialog = (...args) => _shop.wrap('closeGiftDialog')(...args);
    window.closeRenameModal = (...args) => _shop.wrap('closeRenameModal')(...args);
    window.closeShopModal = (...args) => _shop.wrap('closeShopModal')(...args);
    window.confirmGift = (...args) => _shop.wrap('confirmGift')(...args);
    window.fetchShopData = (...args) => _shop.wrap('fetchShopData')(...args);
    window.loadShop = (...args) => _shop.wrap('loadShop')(...args);
    window.openGiftDialog = (...args) => _shop.wrap('openGiftDialog')(...args);
    window.openRenameModal = (...args) => _shop.wrap('openRenameModal')(...args);
    window.openShopModal = (...args) => _shop.wrap('openShopModal')(...args);
    window.renderShop = (...args) => _shop.wrap('renderShop')(...args);
    window.showShopToast = (...args) => _shop.wrap('showShopToast')(...args);
    window.submitRename = (...args) => _shop.wrap('submitRename')(...args);
    window.buyRide = (...args) => _ride.wrap('buyRide')(...args);
    window.closeRideModal = (...args) => _ride.wrap('closeRideModal')(...args);
    window.fetchRideData = (...args) => _ride.wrap('fetchRideData')(...args);
    window.loadRides = (...args) => _ride.wrap('loadRides')(...args);
    window.openRideModal = (...args) => _ride.wrap('openRideModal')(...args);
    window.renderRides = (...args) => _ride.wrap('renderRides')(...args);
    window.closeAvatarPicker = (...args) => _profile.wrap('closeAvatarPicker')(...args);
    window.closeSettingsModal = (...args) => _profile.wrap('closeSettingsModal')(...args);
    window.copyWechatBindCode = (...args) => _profile.wrap('copyWechatBindCode')(...args);
    window.generateWechatBindCode = (...args) => _profile.wrap('generateWechatBindCode')(...args);
    window.handleAvatarUpload = (...args) => _profile.wrap('handleAvatarUpload')(...args);
    window.loadHeadfaces = (...args) => _profile.wrap('loadHeadfaces')(...args);
    window.openAvatarPicker = (...args) => _profile.wrap('openAvatarPicker')(...args);
    window.openSettingsModal = (...args) => _profile.wrap('openSettingsModal')(...args);
    window.saveAvatar = (...args) => _profile.wrap('saveAvatar')(...args);
    window.savePassword = (...args) => _profile.wrap('savePassword')(...args);
    window.saveSettings = (...args) => _profile.wrap('saveSettings')(...args);
    window.selectAvatar = (...args) => _profile.wrap('selectAvatar')(...args);
    window.sendEmailCode = (...args) => _profile.wrap('sendEmailCode')(...args);
    window.showInlineMsg = (...args) => _profile.wrap('showInlineMsg')(...args);
    window.unbindWechat = (...args) => _profile.wrap('unbindWechat')(...args);

    // ── 已转为静态导入的功能模块 window 挂载（直接引用）──
    window.closeChatImageLightbox = closeChatImageLightbox;
    window.openChatImageLightbox = openChatImageLightbox;
    window.setupBannerNotification = setupBannerNotification;
    window.setupFriendNotification = setupFriendNotification;
    window.showFriendBanner = showFriendBanner;
    window.closeMobileDrawer = closeMobileDrawer;
    window.loadMobileRoomList = loadMobileRoomList;
    window.openMobileDrawer = openMobileDrawer;
    window.openUserCard = openUserCard;
    window.renderMobileRoomList = renderMobileRoomList;
    window.renderMobileUserList = renderMobileUserList;
    window.scheduleRenderMobileUserList = scheduleRenderMobileUserList;
    window.switchMobileTab = switchMobileTab;
    window.switchTarget = switchTarget;
    window.clearChatBotContext = clearChatBotContext;
    window.sendToChatBot = sendToChatBot;
    window.runFeatureShortcut = runFeatureShortcut;
    window.runToolbarAction = runToolbarAction;
    window.closeAdminBaccaratLossCoverModal = closeAdminBaccaratLossCoverModal;
    window.closeCurrentBaccaratLossCoverEvent = closeCurrentBaccaratLossCoverEvent;
    window.claimBaccaratLossCover = claimBaccaratLossCover;
    window.closeBaccaratLossCoverModal = closeBaccaratLossCoverModal;
    window.openBaccaratLossCoverModal = openBaccaratLossCoverModal;
    window.openAdminBaccaratLossCoverModal = openAdminBaccaratLossCoverModal;
    window.submitBaccaratLossCoverEvent = submitBaccaratLossCoverEvent;
    window.switchBaccaratLossCoverTab = switchBaccaratLossCoverTab;
    window.deferChatGameBootstrap = deferChatGameBootstrap;
    window.acceptGomokuInvite = acceptGomokuInvite;
    window.openGomokuPanel = openGomokuPanel;
    window.checkAndAutoStartFishing = checkAndAutoStartFishing;
    window.createBobber = createBobber;
    window.reelFish = reelFish;
    window.removeBobber = removeBobber;
    window.resetFishingBtn = resetFishingBtn;
    window.startFishing = startFishing;
    window.stopAutoFishing = stopAutoFishing;
    window.claimRedPacket = claimRedPacket;
    window.closeRedPacketModal = closeRedPacketModal;
    window.sendRedPacket = sendRedPacket;
    window.showRedPacketModal = showRedPacketModal;
    window.updateRedPacketClaimsUI = updateRedPacketClaimsUI;
    window.applyFontSize = applyFontSize;
    window.openGuestbookModal = openGuestbookModal;
    window.closeGuestbookModal = closeGuestbookModal;
    window.loadGuestbookMessages = loadGuestbookMessages;
    window.openFeedbackModal = openFeedbackModal;
    window.closeFeedbackModal = closeFeedbackModal;
    window.loadFeedbackData = loadFeedbackData;
    window.loadMoreFeedback = loadMoreFeedback;
    window.bindFeedbackControls = bindFeedbackControls;
    window.registerSlashCommand = registerSlashCommand;

    // ── Alpine 组件（静态导入，Blade 中 x-data 引用时同步可用） ──
    window.userCardComponent = userCardComponent;
    window.marriageProposeModal = marriageProposeModal;
    window.marriageIncomingModal = marriageIncomingModal;
    window.marriageAcceptedModal = marriageAcceptedModal;
    window.marriageDivorcedModal = marriageDivorcedModal;
    window.divorceConfirmModal = divorceConfirmModal;
    window.divorceRequestModal = divorceRequestModal;
    window.weddingSetupModal = weddingSetupModal;
    window.weddingEnvelopeModal = weddingEnvelopeModal;
    window.appendSystemMessage = appendSystemMessage;
    window.openProposeModal = openProposeModal;
    window.openWeddingSetupModal = openWeddingSetupModal;
    window.holidayEventModal = holidayEventModal;
    window.rewardModal = rewardModal;
    window.baccaratPanel = baccaratPanel;
    window.baccaratFab = baccaratFab;
    window.slotFab = slotFab;
    window.slotPanel = slotPanel;
    window.fortunePanel = fortunePanel;
    window.lotteryPanel = lotteryPanel;
    window.gomokuPanel = gomokuPanel;
    window.horseRacePanel = horseRacePanel;
    window.horseRaceFab = horseRaceFab;

    // 聊天室核心引擎 window 挂载
    window.bindChatEvents = bindChatEvents;
    window.startBadgeRotation = startBadgeRotation;
    window.stopBadgeRotation = stopBadgeRotation;
    window.startHeartbeat = startHeartbeat;
    window.stopHeartbeat = stopHeartbeat;

    // 页面加载后立即注册事件委托（仅静态核心模块，懒加载模块通过 createLazyModule initFn 自动初始化）
    bindGlobalDialogControls();
    bindChatComposerControls();
    bindChatToast();
    bindBlockMenuControls();
    bindSoundMuteControl();
    bindInstantHoverTooltip();
    bindToolbarControls();
    bindChatInitialStateControls();
    bindChatEvents();
    startBadgeRotation();
    startHeartbeat();

    // ── 静态导入的 Alpine 组件模块控制绑定 ──
    bindUserCardControls();
    bindMarriageModalControls();
    bindHolidayModalControls();
    bindRewardModalControls();
    bindEarnPanelControls();
    bindBaccaratPanelControls();
    bindBaccaratFabControls();
    bindHorseRacePanelControls();
    bindHorseRaceFabControls();
    bindSlotMachineControls();
    bindFortunePanelControls();
    bindLotteryPanelControls();
    bindGomokuPanelControls();
    bindDailySignInControls();

    // ── 已转为静态导入的事件委托模块控制绑定 ──
    bindBaccaratEvents();
    bindBaccaratLossCoverAdminControls();
    bindBaccaratLossCoverControls();
    bindGomokuControls();
    bindHorseRaceEvents();
    bindFishingControls();
    bindGameBootstrapControls();
    bindGamePanelControls();
    bindUserTargetActions();
    bindRedPacketPanelControls();
    bindMobileDrawerControls();
    bindWelcomeMenuControls();
    bindAdminMenuControls();
    bindFriendNotificationControls();
    initChatImageLightboxEvents();
    bindRoomStatusControls();
    bindChatRightPanelControls();
    bindChatImageUploadControl();
    bindChatFontSizeControl();
    bindAppointmentAnnouncementControls();
    bindChatBanner();
    bindChatBotControls();
    bindGuestbookControls();
    bindFeedbackControls();
    bindIdiomQuizControls();
}
