import { SheetsBridgeAdapter } from './bridges/sheets.cjs';
import './tool-host-BBSaU7IJ.cjs';
import './types-ITRQFAir.cjs';
import './types-D_H2f-wF.cjs';
import '@particle-academy/fancy-sheets';
/**
* Shared-session helpers for `@particle-academy/fancy-sheets`.
*
* fancy-sheets' `SheetWorkbook` is already controlled (`data` + `onChange`).
* The two missing pieces for a clean shared-session experience are:
*
* 1. an adapter object the host can hand to {@link registerSheetsBridge}
* without writing boilerplate, and
* 2. a derived `CellHighlightMap` so agent edits visibly pulse on the
* humans' screens — wired from the presence registry's per-bridge
* activity stream.
*
* These are kept as host-side hooks (not part of the bridge itself) so
* agent-integrations keeps zero hard deps on fancy-sheets. The host
* imports SheetWorkbook directly and feeds these hooks' outputs into
* its props.
*
* const wb = useSheetsAdapter(initial, { screenId: "deal-sheet" });
* const highlights = useSheetsActivityHighlights({ screenId: "deal-sheet" });
*
* useEffect(() => {
* const bridge = registerSheetsBridge(host, { adapter: wb.adapter });
* return bridge.dispose;
* }, [host, wb.adapter]);
*
*
*/
type WorkbookLike = {
sheets: Array<{
id: string;
name: string;
}>;
activeSheetId: string;
};
type SheetsAdapterOptions = {
/** Tags the bridge's screen id so presence events route correctly. */
screenId?: string;
};
type UseSheetsAdapterResult = {
/** Controlled workbook state. Wire to ``. */
workbook: W;
/** Setter for the controlled state. Wire to ``. */
setWorkbook: (next: W) => void;
/** Wire to `` to track focus. */
onActiveCellChange: (address: string) => void;
/** Stable adapter to hand to `registerSheetsBridge({ adapter })`. */
adapter: SheetsBridgeAdapter;
/** Imperative: set the active sheet + cell. Mirrors the adapter's hook. */
setActiveCell: (sheetId: string, address: string) => void;
/** Read-only: the address last focused (any source). */
activeCell: string | null;
};
/**
* useSheetsAdapter — one-liner glue between fancy-sheets' SheetWorkbook
* and the sheets bridge.
*
* const wb = useSheetsAdapter(initialWorkbook, { screenId: "..." });
*
* useEffect(() => registerSheetsBridge(host, { adapter: wb.adapter }).dispose,
* [host, wb.adapter]);
*
*
*/
declare function useSheetsAdapter(initial: W, options?: SheetsAdapterOptions): UseSheetsAdapterResult;
/**
* Mirror of fancy-sheets' `CellHighlight` — structurally identical so the
* map returned from {@link useSheetsActivityHighlights} can be passed
* straight into `` without any casts.
*
* Fields match `@particle-academy/fancy-sheets` exactly:
* - `color: string` (required) — border/outline color
* - `backgroundColor?: string` — auto-derived from `color` if omitted
* - `label?: string` — small badge in the cell's top-left corner
*/
type SheetsCellHighlight = {
/** Border/outline color (any CSS color value). Required. */
color: string;
/** Background tint; if omitted, derived from `color` at low alpha. */
backgroundColor?: string;
/** Optional label rendered in a chip on the cell. */
label?: string;
};
type SheetsCellHighlightMap = Record;
type SheetsHighlightOptions = {
/** Only include events for this screen (recommended). */
screenId?: string;
/** Highlight TTL in ms before a hit fades from the map. Default 2200. */
ttlMs?: number;
};
/**
* useSheetsActivityHighlights — subscribe to the presence registry,
* produce a CellHighlightMap reflecting recent sheet-bridge activity.
*
* Pass the result straight into ``. Each
* agent edit pulses in the agent's color for `ttlMs` then fades out.
*
* The bridge's target shape is `${sheetId}!${address}` — this hook
* filters for the currently-active sheet and exposes only its cells.
*
* const highlights = useSheetsActivityHighlights({ screenId: "deal-sheet" });
*
*/
declare function useSheetsActivityHighlights(options?: SheetsHighlightOptions): SheetsCellHighlightMap;
export { type SheetsAdapterOptions, type SheetsCellHighlight, type SheetsCellHighlightMap, type SheetsHighlightOptions, type UseSheetsAdapterResult, type WorkbookLike, useSheetsActivityHighlights, useSheetsAdapter };