/**
 * Collab footer status — shows room, peers, and sync info when in a collab session.
 *
 * Uses the FooterDataProvider's setExtensionStatus('collab', text) pattern.
 */
/**
 * Start the collab footer status updater.
 *
 * Registers event handlers on the collab client to keep the footer
 * line up to date. Returns a cleanup function.
 */
export function startCollabStatusUpdater(session, client, setStatus, requestRender) {
    function update() {
        const state = client.state;
        if (!state.roomId) {
            setStatus('collab', undefined);
            requestRender();
            return;
        }
        const peerNames = [...state.peers.values()].map((p) => p.displayName);
        const peerPart = peerNames.length > 0 ? peerNames.join(', ') : 'waiting for peers';
        const pool = session.sheetPool;
        const wbCount = pool?.size ?? 0;
        const wbPart = wbCount > 0 ? `${wbCount} workbook${wbCount > 1 ? 's' : ''}` : '';
        const parts = [`room ${state.roomId}`, `${state.peers.size + 1} peers (${peerPart})`];
        if (wbPart)
            parts.push(wbPart);
        setStatus('collab', parts.join(' · '));
        requestRender();
    }
    // Initial update
    update();
    // Subscribe to events that change the status
    client.on('onPeerJoined', update);
    client.on('onPeerLeft', update);
    client.on('onAwareness', update);
    client.on('onDisconnect', () => {
        setStatus('collab', undefined);
        requestRender();
    });
    return () => {
        setStatus('collab', undefined);
        requestRender();
    };
}
//# sourceMappingURL=collab-status.js.map