import { type CollaborationRole } from './identity.js'; /** The awareness field every client publishes its presence under. */ export declare const PRESENCE_FIELD = "presence"; /** Presence entries older than this (ms) are dropped as stale. */ export declare const STALE_PRESENCE_MS = 30000; /** Heartbeat interval (ms): re-publish presence so peers do not time us out. */ export declare const PRESENCE_HEARTBEAT_MS = 10000; /** Minimum interval (ms) between outgoing presence broadcasts. */ export declare const BROADCAST_THROTTLE_MS = 50; /** Identity fields fixed for the lifetime of a session. */ export interface PresenceIdentity { userName: string; userColor: string; userAvatar?: string | undefined; role?: CollaborationRole | undefined; } /** A sanitised remote collaborator: identity plus product specific payload `T`. */ export type RemotePresence = PresenceIdentity & { clientId: number; lastUpdated: string; } & T; /** Sanitise the identity part of a raw awareness presence entry. */ export declare function sanitizeIdentity(raw: Record): PresenceIdentity; /** True when `lastUpdated` is parseable and within `staleMs` of `now`. */ export declare function isPresenceFresh(lastUpdated: string, now?: number, staleMs?: number): boolean; export interface DerivePresenceOptions { now?: number; staleMs?: number; } /** * Derive the remote presence list from an awareness state map: skips the local client and entries * without a `presence` object, sanitises identity, lets `sanitizePayload` validate the product * payload (return `null` to drop the entry), and drops stale entries. */ export declare function derivePresence(states: ReadonlyMap>, localClientId: number | undefined, sanitizePayload: (raw: Record) => T | null, options?: DerivePresenceOptions): RemotePresence[]; /** Cursor position in unscaled canvas pixels plus the active page (slide) and selection. */ export interface CanvasPayload { activeSlideIndex: number; cursorX: number; cursorY: number; selectedElementId?: string | undefined; } export type CanvasPresence = RemotePresence; /** Sanitise the canvas payload, clamping the cursor to the canvas bounds plus a small margin. */ export declare function sanitizeCanvasPayload(raw: Record, canvasWidth: number, canvasHeight: number): CanvasPayload; /** `derivePresence` specialised to the canvas payload. */ export declare function deriveCanvasPresence(states: ReadonlyMap>, localClientId: number | undefined, canvasWidth: number, canvasHeight: number, options?: DerivePresenceOptions): CanvasPresence[]; /** A remote collaborator's cursor, render ready. */ export interface RemoteCursor { clientId: number | string; userName: string; color: string; x: number; y: number; selectionIds?: string[]; } /** Project canvas presence to cursors, optionally only those on `activeSlideIndex`. */ export declare function presenceToCursors(presence: readonly CanvasPresence[], activeSlideIndex?: number): RemoteCursor[]; /** Coerce an unknown awareness value into a string-id array, dropping non-strings. */ export declare function asSelectionIds(value: unknown): string[]; //# sourceMappingURL=presence.d.ts.map