import { EventEmitter } from '../../stencil-public-runtime';
import { ScrollPosition } from '../../utils/message-scroller';
export type ScrollerEdgeDetail = {
atStart: boolean;
atEnd: boolean;
};
export type ScrollerVisibilityDetail = {
currentAnchorId: string | null;
visibleMessageIds: string[];
};
/**
* seki-message-scroller: streaming chat-transcript container (shadcn/ui parity).
*
* The scroller keeps a streamed reply pinned to the bottom while the reader is
* at the live edge, never fights an upward scroll, preserves the reading
* position when older history is prepended, and drives a jump-to-end button.
* It merges shadcn's `MessageScrollerProvider` + `MessageScroller` into one host
* element because Stencil has no React context — this host owns *all* scroll
* state.
*
* ## Composition
* ```html
*
*
*
* …
* …
*
*
* ↓
*
* ```
*
* ## Implementation notes
* All dynamic behaviour (follow-output, prepend preservation, edge/visibility
* detection, edge-state attributes read by the button) is applied **directly to
* the DOM** from observer/scroll callbacks rather than through Stencil `@State`
* + `render()`. This mirrors shadcn's imperative design — rows must never
* re-render mid-scroll — and deliberately side-steps the confirmed re-render bug
* (#244) where a `@State` bump from an event/observer callback does not reliably
* re-invoke `render()`. `render()` here runs exactly once, at mount.
*
* @component MessageScroller
* @slot - `seki-message-scroller-viewport` and `seki-message-scroller-button`.
*/
export declare class SekiMessageScroller {
el: HTMLElement;
/**
* Follow streamed output while the reader is at the live edge. Any upward
* user scroll disengages following until the bottom is reached again.
* @default true
*/
autoScroll: boolean;
/**
* Where to position the transcript on first mount.
* `last-anchor` scrolls the last `scroll-anchor` row to the top.
* @default 'end'
*/
defaultScrollPosition: ScrollPosition;
/**
* Pixels of the previous turn kept visible above an anchored row when
* resolving `last-anchor` / `scrollToMessage`.
* @default 0
*/
scrollPreviousItemPeek: number;
/**
* Compute and emit `sekiScrollerVisibilityChange`. Off by default so the
* IntersectionObserver only runs when a consumer actually needs visibility.
* @default false
*/
trackVisibility: boolean;
/**
* Emitted when the set of visible messages (or the governing anchor) changes.
* Only fires while `track-visibility` is set.
*/
visibilityChange: EventEmitter;
/**
* Emitted when the viewport reaches or leaves an edge. Drives the active
* state of `seki-message-scroller-button`.
*/
edgeChange: EventEmitter;
private viewportEl;
private contentEl;
private resizeObserver;
private mutationObserver;
private intersectionObserver;
private visibleIds;
/** Follow-output currently engaged. */
private engaged;
/** Last emitted edge state, to only emit on change. */
private lastEdge;
/** Reference row for prepend detection + its pre-mutation offset. */
private anchorRef;
private anchorRefOffset;
private scrollRaf;
private mounted;
private loaded;
private restoring;
private lastScrollTop;
private followedScrollTop;
private viewportBound;
private contentObserved;
private initialScheduled;
private hostObserver;
connectedCallback(): void;
componentDidLoad(): void;
disconnectedCallback(): void;
/**
* Idempotent: (re)discover the viewport/content elements and (re)attach the
* scroll listener and observers when they changed (or were torn down).
* Called on load, on reconnect, and whenever descendants change so children
* that arrive late are picked up.
*/
private setup;
/**
* Detaching an element resets its descendants' scroll offsets to 0. Put the
* reader back where they were: the live edge if they were following, else
* the last offset we saw. Scroll events from the reset are ignored meanwhile.
*/
private restoreAfterMove;
private teardown;
/** Scroll a row (by `message-id`) to the top of the viewport, minus peek. Resolves to whether the row was found. */
scrollToMessage(id: string): Promise;
/** Scroll to the live edge and re-engage follow-output. */
scrollToEnd(): Promise;
/** Scroll to the very top. */
scrollToStart(): Promise;
/** Current edge state — exposed so children/tests can read it without touching internal state. */
getEdgeState(): Promise;
private handleScroll;
private handleContentResize;
private handleContentMutation;
private preserveOnPrepend;
private getItems;
private getItemById;
/** Offset of an element within the viewport's scroll coordinate space. */
private offsetOf;
private itemPositions;
private getEdge;
private scrollViewportToEnd;
private applyInitialPosition;
/**
* Record the topmost *visible* item as the scroll-anchor reference plus its
* current offset, purely to *detect* a prepend on the next mutation (its
* offset moving down means content landed above it). A visible row is
* always rendered at its real size, unlike an off-screen
* `content-visibility` row, so this detection is reliable even though the
* actual compensation amount is measured separately (see
* `handleContentMutation`) rather than derived from this offset shift.
*/
private snapshotAnchorRef;
/**
* Reflect the edge state onto the host as `data-at-start` / `data-at-end`
* attributes (read by the button on mount) and emit `sekiScrollerEdgeChange`
* when it changes. Attributes are set imperatively — never via `render()`.
*/
private syncEdgeState;
private setupVisibility;
private updateVisibility;
private emitVisibility;
render(): any;
}