import type { ApplyFieldPatchCommandPayload, BridgeItemDescriptor, SerializableField } from "../bridge/protocol";
import type { Field } from "../pageModel";
export type ActiveBridgeInlineEdit = {
    elementKey: string;
    fieldId?: string;
    item?: BridgeItemDescriptor;
    sessionId?: string;
    value?: string;
};
type BridgePatchDisplayValue = {
    source: ApplyFieldPatchCommandPayload["source"];
    value: string;
};
export type BridgeInlineEditRefreshEvent = {
    type: "started";
} | {
    type: "completed";
    applied?: "bridge" | "host-app";
    fields?: readonly SerializableField[];
} | {
    type: "structureUpdated";
    fields: readonly SerializableField[];
};
export type RemoteCaretDraft = {
    fieldId?: string | null;
    item?: BridgeItemDescriptor | null;
    value?: string | null;
};
export declare function buildRemoteCaretFieldPatches({ remoteCarets, structureFields, activeInlineEdit, }: {
    remoteCarets: Record<string, RemoteCaretDraft>;
    structureFields: readonly SerializableField[];
    activeInlineEdit: ActiveBridgeInlineEdit | null | undefined;
}): ApplyFieldPatchCommandPayload[];
/**
 * True when a remote session is live-syncing this field (an active remote
 * caret carries a draft value for it). While that holds, saved-value echo
 * patches must not be applied to the canvas: during active typing the saved
 * value is always several keystrokes stale, and rolling the text back makes
 * concurrent caret measurements map offsets against the shorter text — the
 * remote caret visibly jumps backward and the text flickers.
 */
export declare function hasRemoteCaretDraftForField({ remoteCarets, fieldId, item, }: {
    remoteCarets: Record<string, RemoteCaretDraft> | undefined;
    fieldId: string | undefined;
    item: BridgeItemDescriptor | null | undefined;
}): boolean;
export declare function isBridgePatchableTextField(field: Pick<Field, "type">, isRichText: boolean | undefined): boolean;
export declare function getBridgeFieldPatchValue(field: Pick<Field, "rawValue" | "value">): string;
export declare function buildBridgeFieldPatchSignature(patch: Pick<ApplyFieldPatchCommandPayload, "value" | "isRichText" | "source">, observedTextContent?: string | null): string;
/**
 * True when the last patch sent for a field (recorded as its dedupe signature)
 * put a suggestion preview on the canvas. Such fields need an explicit restore
 * patch when suggestion display turns off — the host markup still shows the
 * merged suggestion text until something overwrites it.
 */
export declare function isSuggestionPreviewPatchSignature(signature: string | undefined): boolean;
export declare function buildBridgeFieldPatchPayload({ field, structureField, display, activeInlineEdit, }: {
    field: Field;
    structureField: SerializableField;
    display: BridgePatchDisplayValue;
    activeInlineEdit: ActiveBridgeInlineEdit | null | undefined;
}): ApplyFieldPatchCommandPayload | undefined;
export declare function reconcileActiveBridgeInlineEditAfterRefresh<TActiveEdit extends ActiveBridgeInlineEdit>(activeInlineEdit: TActiveEdit | null | undefined, refreshedFields: readonly SerializableField[] | undefined): TActiveEdit | null;
export declare function reduceActiveBridgeInlineEditForRefreshEvent<TActiveEdit extends ActiveBridgeInlineEdit>(activeInlineEdit: TActiveEdit | null | undefined, event: BridgeInlineEditRefreshEvent): TActiveEdit | null;
export declare function activeInlineEditMatchesField(activeInlineEdit: ActiveBridgeInlineEdit | null | undefined, structureField: Pick<SerializableField, "fieldId" | "item">): boolean;
export {};
