import { Cell } from "@mdxeditor/gurx"; import type { ResearchLauncher } from "./research-launcher"; import type { PublishedInvestigation } from "@chopin/experiment/records"; import type { SelectionPatch } from "@chopin/experiment"; import type { ReactNode } from "react"; import type { CardMetaStore } from "./card-meta"; import type { Binding } from "@lexical/yjs"; import type { ChangeStore } from "./changes"; import type { ContentSwapMotion } from "./content-swap"; import type { MotionDisclosureContract } from "./disclosure-motion"; import type { Research } from "@chopin/protocol"; import type { ResearchDraftStore } from "./research-draft"; import type { QuestionnaireStore } from "./questionnaires"; import type { ThreadStore } from "./threads"; import type { Transport } from "./transport"; export type CommentPresentation = "popover" | "sheet"; export type QuestionStepMotion = { contract: ContentSwapMotion; immediately: () => boolean; }; export type ResearchOpener = { readonly current: HTMLElement | null }; /** App-owned HTTP state and actions for durable Research Workspace references. */ export type ResearchStore = { subscribe(listener: () => void): () => void; retain(id: string): () => void; get(id: string): Research.RequestView | undefined; mutating(id: string): boolean; refresh(id: string): void; create(question: string, requestId: string): Promise; cancel(id: string): Promise; retry(id: string): Promise; opener(id: string, current?: HTMLElement | null): ResearchOpener; open(child: Research.ReadyChild, opener: ResearchOpener): void; }; export type WidgetOptions = { experiments?: ExperimentResources; binding?: Binding; commentPresentation?: CommentPresentation; motionImmediately?: () => boolean; disclosureMotion?: MotionDisclosureContract; questionMotion?: QuestionStepMotion; questions?: QuestionnaireStore; cardMeta?: CardMetaStore; onCardSource?: (questionnaireId: string) => void; /** Whether a card has a Chat message to go back to. */ hasCardSource?: (questionnaireId: string) => boolean; /** False when no Planner will review where decisions live. */ planner?: boolean; evidence?: (questionnaireId: string) => ReactNode | null; research?: ResearchStore; researchDrafts?: ResearchDraftStore; researchLauncher?: ResearchLauncher; threads?: ThreadStore; changes?: ChangeStore; wire?: Transport; connected?: boolean; synced?: boolean; canEdit?: boolean; /** The viewer's own handle. */ self?: string; }; export type ExperimentResources = { subscribe(listener: () => void): () => void; snapshot(): number; get(id: string): PublishedInvestigation | undefined; load(id: string): Promise; change(id: string, view: string, patch: SelectionPatch): Promise; place(id: string, view: string, decision?: string, remove?: boolean): Promise; }; export const widgets$ = Cell({});