/**
 * CRDT (Conflict-free Replicated Data Types) Core Primitives
 * Following categorical design principles with commutative monoid laws
 */
import { Signal } from '../core/signal';
export interface CRDT<T> {
    readonly value: () => T;
    readonly merge: (other: any) => void;
    readonly clone: () => CRDT<T>;
    readonly toJSON: () => any;
    readonly fromJSON: (json: any) => void;
}
export interface Timestamp {
    readonly time: number;
    readonly nodeId: string;
}
export declare const timestamp: (nodeId?: string) => Timestamp;
export declare const compareTimestamps: (a: Timestamp, b: Timestamp) => number;
export interface CRDTOperation {
    readonly type: string;
    readonly value: any;
    readonly timestamp?: Timestamp;
    readonly crdtId: string;
}
export interface GCounter extends CRDT<number> {
    readonly increment: (amount?: number) => void;
}
export declare const gCounter: (nodeId?: string) => GCounter;
export interface PNCounter extends CRDT<number> {
    readonly increment: (amount?: number) => void;
    readonly decrement: (amount?: number) => void;
}
export declare const pnCounter: (nodeId?: string) => PNCounter;
export interface GSet<T> extends CRDT<Set<T>> {
    readonly add: (element: T) => void;
    readonly has: (element: T) => boolean;
}
export declare const gSet: <T>() => GSet<T>;
export interface LWWRegister<T> extends CRDT<T | undefined> {
    readonly set: (value: T) => void;
    readonly getTimestamp: () => Timestamp | undefined;
}
export declare const lwwRegister: <T>(nodeId?: string, initialValue?: T) => LWWRegister<T>;
export interface ORSet<T> extends CRDT<Set<T>> {
    readonly add: (element: T) => void;
    readonly remove: (element: T) => void;
    readonly has: (element: T) => boolean;
}
export declare const orSet: <T>(nodeId?: string) => ORSet<T>;
export interface ReactiveCRDT<T, C extends CRDT<T>> {
    readonly crdt: C;
    readonly signal: Signal<T>;
    readonly subscribe: (fn: (value: T) => void) => () => void;
}
export declare const reactiveGCounter: (nodeId?: string) => ReactiveCRDT<number, GCounter>;
export declare const reactivePNCounter: (nodeId?: string) => ReactiveCRDT<number, PNCounter>;
export declare const reactiveORSet: <T>(nodeId?: string) => ReactiveCRDT<Set<T>, ORSet<T>>;
export declare const reactiveLWWRegister: <T>(nodeId?: string, initialValue?: T) => ReactiveCRDT<T | undefined, LWWRegister<T>>;
