import { ReactiveControllerHost } from 'lit'; import { Store } from '../store/store'; import { AnnotatorState } from '../store/store.types'; import { MeasureShape, NormPoint, Pin, Shape } from '../types/annotation.types'; import { Comment, CommentFilter, CommentSort, User } from '../types/comment.types'; type ControllerHost = ReactiveControllerHost & EventTarget; /** * Minimal video-playback surface the comments panel drives when a comment is * selected. Structurally satisfied by `VideoController`; kept as a narrow * interface so the comments controller stays decoupled from the video engine. */ export interface CommentVideoTarget { seek(time: number): void; pause(): void; } /** * Owns comment CRUD, the pin-to-comment draft flow, panel filter/sort, and the * active/hover linkage between the panel and the canvas. Emits the public * comment + pin events. Comments are API-backed domain records and are * deliberately NOT part of undo/redo: each mutation fires a public event the * host mirrors to its backend, and reversing a mutation is an explicit action * (delete, reopen, edit) that fires its own event — so undo can never desync the * canvas from the server. Undo/redo is scoped to the pre-commit drawing buffer * (see DrawController). */ export declare class CommentsController { private host; private store; /** Video controller for reveal-on-select seeking; wired by the session. */ private video; /** * Cached @mention roster, so `parseMentions` can capture multi-word handles * (e.g. `@Sara Lin`) whole rather than truncating at the first space. Resolved * from `config.getUsers('')` by the session (the same empty-query convention * the thread renderer uses); left empty when no provider is configured. */ private knownUsers; constructor(host: ControllerHost, store: Store); /** Connect the video controller so selecting a comment can seek to its frame. */ setVideoTarget(video: CommentVideoTarget): void; /** * Resolve and cache the @mention roster from the consumer's `getUsers` * provider (empty query → full roster). A stale resolve can't clobber a newer * provider; a rejection leaves the previous roster in place. */ setUsersProvider(getUsers?: (query: string) => User[] | Promise): void; private usersProvider?; private get state(); private get author(); /** Current user's id — used by the UI for like/subscribe pressed state. */ get currentUserId(): string; /** * Whether a real current user is configured (vs the anonymous fallback). The * UI uses this to decide whether ownership-gated actions (edit/delete) can be * enforced at all — with no known user there is no "own", so those actions * stay available rather than vanishing for every comment. */ get hasCurrentUser(): boolean; /** * Host-granted moderation role (owner/admin): may resolve and delete ANY * comment. The widget can't know app roles, so the host sets this via * `config.canManageAllComments`. */ get canManageAllComments(): boolean; /** May edit a comment's body — own comments only (managers included). */ canEditComment(comment: Comment): boolean; /** May resolve/reopen a comment — own comments, or any when a manager. */ canResolveComment(comment: Comment): boolean; /** May delete a comment — own comments, or any when a manager. */ canDeleteComment(comment: Comment): boolean; /** Begin composing a comment anchored at a normalized position. */ startDraft(position: NormPoint): void; /** Discard the in-progress draft pin without creating a comment. */ cancelDraft(): void; /** * Commit the draft as a new root comment plus its anchored pin. * Returns the created comment, or null if there was no draft / empty body. */ submitDraft(body: string, opts?: { shapes?: Shape[]; timestamp?: number; attachments?: Comment['attachments']; }): Comment | null; /** * Open the inline composer for freshly drawn shapes, anchored near the * drawing (draw-to-comment). The shapes are already in the `draftShapes` * buffer; this just positions the popover. In "Draw more" mode the popover is * suppressed — the shapes are composed in the side-panel composer instead. */ openShapeDraft(anchor: NormPoint): void; /** * Switch the active drawing session into "Draw more" mode: close the inline * popover and keep the drawing tool armed so further shapes accumulate on the * draft, composed in the side-panel composer. Reset on submit/discard. */ enableDrawMore(): void; /** Discard the in-progress shape draft (anchor + buffered shapes). */ cancelShapeDraft(): void; /** * Create a comment from the pending draft shapes (draw-to-comment). The * shapes are snapshotted onto the comment and the draft buffer is cleared. * Requires non-empty body text. Returns the comment, or null. */ submitComment(body: string, opts?: { attachments?: Comment['attachments']; }): Comment | null; /** * Turn a measurement into a comment: attaches the measure shape (for the * property card) and drops a numbered pin at its anchor. Ownership of the * shape transfers from standalone markup to the comment — it's removed from * `shapes` so the pin represents it on the canvas (and the drawing reappears * on hover/active), and deleting the comment removes the drawing too. */ addMeasureComment(shape: MeasureShape, body?: string): Comment; /** Discard pending draft shapes (the composer "clear" action). */ clearDraftShapes(): void; addReply(parentId: string, body: string, opts?: { attachments?: Comment['attachments']; }): Comment | null; /** Edit a comment's body. Re-parses mentions and stamps `editedAt`. */ editComment(id: string, body: string): Comment | null; /** Toggle the current user's like on a comment. */ toggleLike(id: string): void; /** Toggle the current user's subscription (watch) on a comment thread. */ toggleSubscribe(id: string): void; setStatus(id: string, status: 'open' | 'resolved'): void; toggleResolved(id: string): void; /** * Ask to delete a comment: enforce the delete permission, then open the * confirm modal (see {@link confirmPendingDelete}). Returns false — without * opening anything — when the comment is gone or the user isn't allowed, so * callers (menu, keyboard shortcut) share one gate. Does NOT delete directly. */ requestDeleteComment(id: string): boolean; /** Confirm the pending deletion from the modal — deletes and closes it. */ confirmPendingDelete(): void; /** Dismiss the confirm modal without deleting. */ cancelPendingDelete(): void; private confirmHostSeq; /** Register a view as a possible modal host; returns its stable id. */ registerConfirmHost(): number; /** Unregister a modal host (on disconnect). */ unregisterConfirmHost(id: number): void; /** The single elected host id (lowest), or null when none are mounted. */ get electedConfirmHost(): number | null; /** Delete a comment and (if it's a root) its replies and anchored pin. */ deleteComment(id: string): void; setFilter(filter: CommentFilter): void; setSort(sort: CommentSort): void; /** Set / clear the in-progress timeline range selection (seconds). */ setRange(range: { start: number; end: number; } | null): void; setActive(id: string | null): void; /** * On video media, moving the playhead to the frame a comment was anchored to * is the only way its pin/shapes become visible (timed annotations are * time-gated). So when a comment is selected we pause playback and seek to its * timestamp — replies inherit their root's. No-op for images, when there is no * video controller, or for untimed comments. */ private revealOnTimeline; setHovered(id: string | null): void; /** * Spotlight comments in the panel (background highlight) from a media-side * hover — a canvas pin (one id) or a timeline marker (one or more ids stacked * on the same timestamp). Pass `[]` (or {@link clearHighlightedComments}) on * pointer-leave. Deduped, and a no-op when the set is unchanged so a moving * pointer doesn't churn the store. */ setHighlightedComments(ids: readonly string[]): void; /** Clear the panel spotlight (pointer left the pin/marker). */ clearHighlightedComments(): void; /** Handle a pin click on the canvas → activate its comment, emit event. */ onPinClicked(pin: Pin): void; private notifyChanged; } export {}; //# sourceMappingURL=comments.controller.d.ts.map