import type { PrimitiveButtonAttributes, PrimitiveDivAttributes } from "../internal/attributes.js"; import type { WithChild, WithChildNoChildrenSnippetProps, Without } from "../internal/types.js"; import type { Snippet } from "svelte"; /** * Default `scrollEdgeThreshold`. Sub-pixel tolerance so edge detection does not * flicker across engines that round `scrollTop` differently. */ declare const DEFAULT_SCROLL_EDGE_THRESHOLD = 8; /** * Default `scrollPreviousItemPeek`. Pixels of the previous item kept visible above * a newly anchored row. */ declare const DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK = 64; /** Default `scrollMargin` for `scrollToMessage` and programmatic targets. */ declare const DEFAULT_SCROLL_MARGIN = 0; /** * Two fractional `scrollTop` values within this range are treated as equal, to * absorb zoom and HiDPI rounding drift. */ declare const SCROLL_POSITION_EPSILON = 0.5; /** * How long (ms) `data-autoscrolling` stays set during a programmatic smooth scroll * before clearing. */ declare const AUTOSCROLLING_CLEAR_DELAY = 180; /** Viewport keys that count as deliberate scroll intent and release follow-bottom. */ declare const USER_SCROLL_KEYS: Set; /** * Internal scroll mode. Derived from intent and commands; decides how the * viewport reacts to content and resize. */ type MessageScrollerMode = /** `autoScroll` on, pinned to the latest message. */ "following-bottom" /** Reader scrolled away; position left alone (prepends still preserved). */ | "free-scrolling" /** Holding a turn at the reading line while it streams. */ | "anchored-to-message" /** A programmatic jump is animating; intent detection suppressed until it settles. */ | "settling-jump"; /** Where a saved transcript opens on the first non-empty render. */ type MessageScrollerDefaultScrollPosition = "start" | "end" | "last-anchor"; /** Which transcript edge `MessageScrollerButton` scrolls toward. */ type MessageScrollerButtonDirection = "start" | "end"; /** Viewport alignment for `scrollToMessage` and programmatic jumps. */ type MessageScrollerScrollAlign = "start" | "center" | "end" | "nearest"; /** Options for `scrollToMessage`, `scrollToEnd`, and `scrollToStart`. */ type MessageScrollerScrollOptions = { /** Viewport edge or center to align the target to. */ align?: MessageScrollerScrollAlign; /** Native scroll behavior. */ behavior?: ScrollBehavior; /** * Margin on the aligned edge, in pixels. * * @default the provider's `scrollMargin` */ scrollMargin?: number; }; /** * Scroll snapshot from `useMessageScrollerScrollable`: which edges the viewport can * still scroll toward. */ type MessageScrollerScrollable = { /** The viewport can scroll toward the start (content is hidden above). */ start: boolean; /** The viewport can scroll toward the end (content is hidden below). */ end: boolean; }; /** Visibility snapshot from `useMessageScrollerVisibility`. */ type MessageScrollerVisibilityState = { /** * The anchored turn the reader is in, or `null`. Stays set after the anchor * scrolls above the viewport. */ currentAnchorId: string | null; /** `messageId` values intersecting the viewport, in document order. */ visibleMessageIds: string[]; }; /** Mutable holder for a value that must survive re-renders without triggering them. */ type MessageScrollerRef = { current: T; }; /** * Headless provider for a chat transcript scroller. Owns scroll behavior and * state; renders no DOM. */ type MessageScrollerProviderProps = { children?: Snippet; /** * Follow new content at the bottom while the viewport is already at the end. * * @default false */ autoScroll?: boolean; /** * Opening position on the first non-empty render, applied once. * * @default "end" */ defaultScrollPosition?: MessageScrollerDefaultScrollPosition; /** * Distance from an edge that still counts as at-top/at-bottom. * * @default 8 */ scrollEdgeThreshold?: number; /** * Extra top margin for a newly anchored row, added to `scrollMargin`. * * @default 64 */ scrollPreviousItemPeek?: number; /** * Default margin on the aligned edge for commands and visibility. * * @default 0 */ scrollMargin?: number; }; type MessageScrollerRootPropsWithoutHTML = WithChild; type MessageScrollerRootProps = MessageScrollerRootPropsWithoutHTML & Without; type MessageScrollerViewportPropsWithoutHTML = WithChild<{ /** * Keep the first visible `messageId` row stable on prepend. * * @default true */ preserveScrollOnPrepend?: boolean; }>; type MessageScrollerViewportProps = MessageScrollerViewportPropsWithoutHTML & Without; type MessageScrollerContentPropsWithoutHTML = WithChild<{ /** Class name for the internal tail spacer used when anchoring turns near the top. */ spacerClassName?: string; }>; type MessageScrollerContentProps = MessageScrollerContentPropsWithoutHTML & Without; type MessageScrollerItemPropsWithoutHTML = WithChild<{ /** Stable row id for `scrollToMessage`, visibility, and prepend preservation. */ messageId?: string; /** * Marks a turn boundary that newly appended anchors and `last-anchor` restore use. * * @default false */ scrollAnchor?: boolean; }>; type MessageScrollerItemProps = MessageScrollerItemPropsWithoutHTML & Without; /** State passed to `MessageScrollerButton`'s `child` snippet. */ type MessageScrollerButtonRenderState = { /** Whether overflow exists toward this button's direction. */ active: boolean; /** The transcript edge this button scrolls toward. */ direction: MessageScrollerButtonDirection; }; type MessageScrollerButtonPropsWithoutHTML = WithChildNoChildrenSnippetProps<{ /** * Native scroll behavior when clicked. * * @default "smooth" */ behavior?: ScrollBehavior; /** * Transcript edge to scroll toward. * * @default "end" */ direction?: MessageScrollerButtonDirection; }, MessageScrollerButtonRenderState>; type MessageScrollerButtonProps = MessageScrollerButtonPropsWithoutHTML & Without; /** * Registers (or, with `removedElement`, unregisters) a `MessageScrollerItem` node by * `messageId`. */ type MessageScrollerRegisterMessage = (messageId: string, element: HTMLElement | null, removedElement?: HTMLElement | null) => void; /** * Initial `MessageScrollerScrollable` before measurement. Stable reference for the * server and first-render snapshot. */ declare const EMPTY_MESSAGE_SCROLLER_SCROLLABLE: MessageScrollerScrollable; /** Shared empty array so empty visibility snapshots stay referentially stable. */ declare const EMPTY_VISIBLE_MESSAGE_IDS: string[]; /** Initial `MessageScrollerVisibilityState`. Nothing tracked, no current anchor. */ declare const EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE: MessageScrollerVisibilityState; export { AUTOSCROLLING_CLEAR_DELAY, DEFAULT_SCROLL_EDGE_THRESHOLD, DEFAULT_SCROLL_MARGIN, DEFAULT_SCROLL_PREVIOUS_ITEM_PEEK, EMPTY_MESSAGE_SCROLLER_SCROLLABLE, EMPTY_MESSAGE_SCROLLER_VISIBILITY_STATE, EMPTY_VISIBLE_MESSAGE_IDS, SCROLL_POSITION_EPSILON, USER_SCROLL_KEYS, }; export type { MessageScrollerButtonDirection, MessageScrollerButtonProps, MessageScrollerButtonRenderState, MessageScrollerContentProps, MessageScrollerDefaultScrollPosition, MessageScrollerItemProps, MessageScrollerMode, MessageScrollerProviderProps, MessageScrollerRef, MessageScrollerRegisterMessage, MessageScrollerRootProps, MessageScrollerScrollAlign, MessageScrollerScrollOptions, MessageScrollerScrollable, MessageScrollerViewportProps, MessageScrollerVisibilityState, };